Skip to content

Commit

Permalink
If committed, resend the commit periodically in case of a networking …
Browse files Browse the repository at this point in the history
…issue.
  • Loading branch information
jsolman committed Jan 31, 2019
1 parent ba05cef commit b938f96
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion neo/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ private void OnStart()
}
}
if (context.State.HasFlag(ConsensusState.CommitSent) && context.BlockIndex == Blockchain.Singleton.Height + 1)
{
CheckPreparations();
// Set timer, so we will resend the commit in case of a networking issue
ChangeTimer(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock));
}
else
InitializeConsensus(0);
}
Expand Down Expand Up @@ -517,8 +521,18 @@ private void OnTimer(Timer timer)
}
else if ((context.State.HasFlag(ConsensusState.Primary) && context.State.HasFlag(ConsensusState.RequestSent)) || context.State.HasFlag(ConsensusState.Backup))
{
if (!context.State.HasFlag(ConsensusState.CommitSent))
if (context.State.HasFlag(ConsensusState.CommitSent))
{
// Re-send commit periodically in case of a network issue.
ConsensusPayload payload = context.MakeCommit();
Log($"resend commit");
localNode.Tell(new LocalNode.SendDirectly { Inventory = payload });
ChangeTimer(TimeSpan.FromSeconds(Blockchain.SecondsPerBlock << 1));
}
else
{
RequestChangeView();
}
}
}

Expand Down

0 comments on commit b938f96

Please sign in to comment.