Skip to content

Commit

Permalink
Optimize NextConsensus (neo-project#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiao-Jin authored and Shawn committed Jan 8, 2021
1 parent edbf999 commit aba20e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/neo/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ public void Reset(byte viewNumber)
{
PrevHash = Snapshot.CurrentBlockHash,
Index = Snapshot.Height + 1,
NextConsensus = Blockchain.GetConsensusAddress(NativeContract.NEO.ComputeNextBlockValidators(Snapshot))
NextConsensus = Blockchain.GetConsensusAddress(
NativeContract.NEO.ShouldRefreshCommittee(Snapshot.Height + 1) ?
NativeContract.NEO.ComputeNextBlockValidators(Snapshot) :
NativeContract.NEO.GetNextBlockValidators(Snapshot))
};
var pv = Validators;
Validators = NativeContract.NEO.GetNextBlockValidators(Snapshot);
Expand Down
2 changes: 1 addition & 1 deletion src/neo/SmartContract/Native/Tokens/NeoToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static void CheckCandidate(StoreView snapshot, StorageKey key, Candidate
snapshot.Storages.Delete(key);
}

private bool ShouldRefreshCommittee(uint height) => height % (ProtocolSettings.Default.CommitteeMembersCount + ProtocolSettings.Default.ValidatorsCount) == 0;
public bool ShouldRefreshCommittee(uint height) => height % (ProtocolSettings.Default.CommitteeMembersCount + ProtocolSettings.Default.ValidatorsCount) == 0;

internal override void Initialize(ApplicationEngine engine)
{
Expand Down

0 comments on commit aba20e0

Please sign in to comment.