consensus: update state machine to use the new consensus params (#8181)

This commit is contained in:
William Banfield
2022-03-23 11:26:42 -04:00
committed by GitHub
parent cbce877480
commit e4ae922c33
13 changed files with 127 additions and 110 deletions

View File

@@ -161,6 +161,27 @@ func DefaultTimeoutParams() TimeoutParams {
}
}
// ProposeTimeout returns the amount of time to wait for a proposal.
func (t TimeoutParams) ProposeTimeout(round int32) time.Duration {
return time.Duration(
t.Propose.Nanoseconds()+t.ProposeDelta.Nanoseconds()*int64(round),
) * time.Nanosecond
}
// VoteTimeout returns the amount of time to wait for remaining votes after receiving any +2/3 votes.
func (t TimeoutParams) VoteTimeout(round int32) time.Duration {
return time.Duration(
t.Vote.Nanoseconds()+t.VoteDelta.Nanoseconds()*int64(round),
) * time.Nanosecond
}
// CommitTime accepts ti, the time at which the consensus engine received +2/3
// precommits for a block and returns the point in time at which the consensus
// engine should begin consensus on the next block.
func (t TimeoutParams) CommitTime(ti time.Time) time.Time {
return ti.Add(t.Commit)
}
func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool {
for i := 0; i < len(val.PubKeyTypes); i++ {
if val.PubKeyTypes[i] == pubkeyType {