Browse Source

remove Heap.Update() call when setting Proposer field

In for loop of IncrementAccum(), Heap.Update() call is unnecessary when i == times - 1.
pull/1382/head
Eugene Chung 6 years ago
committed by GitHub
parent
commit
34f5d439ee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      types/validator_set.go

+ 5
- 4
types/validator_set.go View File

@ -60,13 +60,14 @@ func (valSet *ValidatorSet) IncrementAccum(times int) {
// Decrement the validator with most accum times times
for i := 0; i < times; i++ {
mostest := validatorsHeap.Peek().(*Validator)
// mind underflow
mostest.Accum = safeSubClip(mostest.Accum, valSet.TotalVotingPower())
if i == times-1 {
valSet.Proposer = mostest
} else {
validatorsHeap.Update(mostest, accumComparable{mostest})
}
// mind underflow
mostest.Accum = safeSubClip(mostest.Accum, valSet.TotalVotingPower())
validatorsHeap.Update(mostest, accumComparable{mostest})
}
}


Loading…
Cancel
Save