Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize NextConsensus #2015

Merged
merged 4 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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