Ejemplo n.º 1
0
 private void RequestChangeView()
 {
     TR.Enter();
     context.State |= ConsensusState.ViewChanging;
     context.ExpectedView[context.MyIndex]++;
     Log($"request change view: height={context.BlockIndex} view={context.ViewNumber} nv={context.ExpectedView[context.MyIndex]} state={context.State}");
     timer.Change(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock << (context.ExpectedView[context.MyIndex] + 1)), Timeout.InfiniteTimeSpan);
     SignAndRelay(context.MakeChangeView());
     CheckExpectedView(context.ExpectedView[context.MyIndex]);
     TR.Exit();
 }
Ejemplo n.º 2
0
 private void RequestChangeView()
 {
     context.State |= ConsensusState.ViewChanging;
     context.ExpectedView[context.MyIndex]++;
     Log($"request change view: height={context.BlockIndex} view={context.ViewNumber} nv={context.ExpectedView[context.MyIndex]} state={context.State}");
     ChangeTimer(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock << (context.ExpectedView[context.MyIndex] + 1)));
     system.LocalNode.Tell(new LocalNode.SendDirectly {
         Inventory = context.MakeChangeView()
     });
     CheckExpectedView(context.ExpectedView[context.MyIndex]);
 }
Ejemplo n.º 3
0
        private void RequestChangeView()
        {
            ReportNeoBlockchain reportObj = new ReportNeoBlockchain("[NeoConsensusService-RequestChangeView]");

            context.State |= ConsensusState.ViewChanging;
            context.ExpectedView[context.MyIndex]++;
            Log($"request change view: height={context.BlockIndex} view={context.ViewNumber} nv={context.ExpectedView[context.MyIndex]} state={context.State}");
            timer.Change(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock << (context.ExpectedView[context.MyIndex] + 1)), Timeout.InfiniteTimeSpan);
            SignAndRelay(context.MakeChangeView());
            CheckExpectedView(context.ExpectedView[context.MyIndex]);

            reportObj.appendElapsedTime();
        }
Ejemplo n.º 4
0
 private void CheckExpectedView(byte viewNumber)
 {
     if (context.ViewNumber >= viewNumber)
     {
         return;
     }
     // if there are `M` change view payloads with NewViewNumber greater than viewNumber, then, it is safe to move
     if (context.ChangeViewPayloads.Count(p => p != null && p.GetDeserializedMessage <ChangeView>().NewViewNumber >= viewNumber) >= context.M)
     {
         if (!context.WatchOnly)
         {
             ChangeView message = context.ChangeViewPayloads[context.MyIndex]?.GetDeserializedMessage <ChangeView>();
             // Communicate the network about my agreement to move to `viewNumber`
             // if my last change view payload, `message`, has NewViewNumber lower than current view to change
             if (message is null || message.NewViewNumber < viewNumber)
             {
                 localNode.Tell(new LocalNode.SendDirectly {
                     Inventory = context.MakeChangeView(ChangeViewReason.ChangeAgreement)
                 });
             }
         }
         InitializeConsensus(viewNumber);
     }
 }