Ejemplo n.º 1
0
 private void SendVote(VerificationContext context)
 {
     if (context.VoteMessage is null)
     {
         return;
     }
     Utility.Log(nameof(VerificationService), LogLevel.Info, $"relay vote, height={context.RootIndex}, retry={context.Retries}");
     StatePlugin.System.Blockchain.Tell(context.VoteMessage);
 }
Ejemplo n.º 2
0
 private void CheckVotes(VerificationContext context)
 {
     if (context.CheckSignatures())
     {
         if (context.StateRootMessage is null)
         {
             return;
         }
         Utility.Log(nameof(VerificationService), LogLevel.Info, $"relay state root, height={context.StateRoot.Index}, root={context.StateRoot.RootHash}");
         StatePlugin.System.Blockchain.Tell(context.StateRootMessage);
     }
 }
Ejemplo n.º 3
0
        private void OnBlockPersisted(uint index)
        {
            if (MaxCachedVerificationProcessCount <= contexts.Count)
            {
                contexts.Keys.OrderBy(p => p).Take(contexts.Count - MaxCachedVerificationProcessCount + 1).ForEach(p =>
                {
                    if (contexts.TryRemove(p, out var value))
                    {
                        value.Timer.CancelIfNotNull();
                    }
                });
            }
            var p = new VerificationContext(wallet, index);

            if (p.IsValidator && contexts.TryAdd(index, p))
            {
                p.Timer = Context.System.Scheduler.ScheduleTellOnceCancelable(TimeSpan.FromMilliseconds(DelayMilliseconds), Self, new Timer
                {
                    Index = index,
                }, ActorRefs.NoSender);
                Utility.Log(nameof(VerificationContext), LogLevel.Info, $"new validate process, height={index}, index={p.MyIndex}, ongoing={contexts.Count}");
            }
        }