Пример #1
0
        private void CheckPreparations()
        {
            if (context.PreparationPayloads.Count(p => p != null) >= context.M() && context.TransactionHashes.All(p => context.Transactions.ContainsKey(p)))
            {
                ConsensusPayload payload = context.MakeCommit();
                Log($"send commit");
                context.Save();
                localNode.Tell(new LocalNode.SendDirectly {
                    Inventory = payload
                });
                // Set timer, so we will resend the commit in case of a networking issue
                ChangeTimer(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock));

                StateRoot stateRoot = context.CreateStateRoot();
                Log($"relay stateRoot: height={stateRoot.Index} hash={stateRoot.Root}");
                localNode.Tell(new LocalNode.Relay {
                    Inventory = stateRoot
                });

                CheckCommits();
            }
        }