Skip to content

Commit

Permalink
Rename flag to MoreThanFNodesCommitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsolman committed Mar 19, 2019
1 parent 76bd576 commit ee72d58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions neo/Consensus/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ internal static class Helper
public static bool BlockSent(this IConsensusContext context) => context.Block != null;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool ViewChanging(this IConsensusContext context) => context.ChangeViewPayloads[context.MyIndex]?.GetDeserializedMessage<ChangeView>().NewViewNumber > context.ViewNumber && !context.FNodesCommitted();
public static bool ViewChanging(this IConsensusContext context) => context.ChangeViewPayloads[context.MyIndex]?.GetDeserializedMessage<ChangeView>().NewViewNumber > context.ViewNumber && !context.MoreThanFNodesCommitted();

// A possible attack can happen if the last node to commit is malicious and either sends change view after his
// commit to stall nodes in a higher view, or if he refuses to send recovery messages. In addition, if a node
// asking change views loses network or crashes and comes back when nodes are committed in more than one higher
// numbered view, it is possible for the node accepting recovery and commit in any of the higher views, thus
// potentially splitting nodes among views and stalling the network.
public static bool FNodesCommitted(this IConsensusContext context) => context.CommitPayloads.Count(p => p != null) > context.F();
public static bool MoreThanFNodesCommitted(this IConsensusContext context) => context.CommitPayloads.Count(p => p != null) > context.F();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint GetPrimaryIndex(this IConsensusContext context, byte viewNumber)
Expand Down

0 comments on commit ee72d58

Please sign in to comment.