mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-28 11:56:15 +00:00
fix another potential infinite loop
if a.nNew == 0 -> pickFromOldBucket=true, but we don't have enough items (a.nOld > len(oldBucketToAddrsMap) false)
This commit is contained in:
+4
-4
@@ -413,12 +413,12 @@ ADDRS_LOOP:
|
||||
for selectionIndex < numAddresses {
|
||||
|
||||
// determine whether to pick from an old bucket.
|
||||
// if there's not enough old addresses to pick from, then we cant pick from old bucket.
|
||||
pickFromOldBucket := int((float64(selectionIndex)/float64(numAddresses))*100) >= biasTowardsNewAddrs
|
||||
pickFromOldBucket = (pickFromOldBucket && a.nOld > 0 && len(oldBucketToAddrsMap) < a.nOld) || a.nNew == 0
|
||||
biasedTowardsOldAddrs := int((float64(selectionIndex)/float64(numAddresses))*100) >= biasTowardsNewAddrs
|
||||
// if there's not enough old addresses to pick from, then we can't pick from old bucket.
|
||||
pickFromOldBucket := biasedTowardsOldAddrs && a.nOld > len(oldBucketToAddrsMap)
|
||||
|
||||
// if there's not enough new addrs to pick from, just return early.
|
||||
if !pickFromOldBucket && len(newBucketToAddrsMap) >= a.nNew {
|
||||
if !pickFromOldBucket && a.nNew <= len(newBucketToAddrsMap) {
|
||||
return selection
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user