remove Heap.Update() call when setting Proposer field

In for loop of IncrementAccum(), Heap.Update() call is unnecessary when i == times - 1.
This commit is contained in:
Eugene Chung
2018-03-28 12:58:53 +09:00
committed by GitHub
parent 6f9956990c
commit 34f5d439ee

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)
if i == times-1 {
valSet.Proposer = mostest
}
// mind underflow
mostest.Accum = safeSubClip(mostest.Accum, valSet.TotalVotingPower())
validatorsHeap.Update(mostest, accumComparable{mostest})
if i == times-1 {
valSet.Proposer = mostest
} else {
validatorsHeap.Update(mostest, accumComparable{mostest})
}
}
}