[viewchange] rename NextAfter to NthNext

The NthNext will return the nth key after the current pubkey

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3379/head
Leo Chen 4 years ago
parent 669302ea2e
commit df9d54443d
  1. 6
      consensus/quorum/quorum.go
  2. 2
      consensus/view_change.go

@ -72,7 +72,7 @@ type ParticipantTracker interface {
Participants() multibls.PublicKeys Participants() multibls.PublicKeys
IndexOf(bls.SerializedPublicKey) int IndexOf(bls.SerializedPublicKey) int
ParticipantsCount() int64 ParticipantsCount() int64
NextAfter(*bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper) NthNext(*bls.PublicKeyWrapper, int) (bool, *bls.PublicKeyWrapper)
UpdateParticipants(pubKeys []bls.PublicKeyWrapper) UpdateParticipants(pubKeys []bls.PublicKeyWrapper)
} }
@ -187,8 +187,8 @@ func (s *cIdentities) IndexOf(pubKey bls.SerializedPublicKey) int {
return -1 return -1
} }
// NextAfter return the next pubkey, next can be negative number // NthNext return the Nth next pubkey, next can be negative number
func (s *cIdentities) NextAfter(pubKey *bls.PublicKeyWrapper, next int) (bool, *bls.PublicKeyWrapper) { func (s *cIdentities) NthNext(pubKey *bls.PublicKeyWrapper, next int) (bool, *bls.PublicKeyWrapper) {
found := false found := false
idx := s.IndexOf(pubKey.Bytes) idx := s.IndexOf(pubKey.Bytes)

@ -98,7 +98,7 @@ func (consensus *Consensus) GetNextLeaderKey(viewID uint64) *bls.PublicKeyWrappe
Uint64("newViewID", viewID). Uint64("newViewID", viewID).
Uint64("myCurBlockViewID", consensus.GetCurBlockViewID()). Uint64("myCurBlockViewID", consensus.GetCurBlockViewID()).
Msg("[GetNextLeaderKey] got leaderPubKey from coinbase") Msg("[GetNextLeaderKey] got leaderPubKey from coinbase")
wasFound, next := consensus.Decider.NextAfter(consensus.LeaderPubKey, gap) wasFound, next := consensus.Decider.NthNext(consensus.LeaderPubKey, gap)
if !wasFound { if !wasFound {
consensus.getLogger().Warn(). consensus.getLogger().Warn().
Str("key", consensus.LeaderPubKey.Bytes.Hex()). Str("key", consensus.LeaderPubKey.Bytes.Hex()).

Loading…
Cancel
Save