Skip to content

Commit 08ee58c

Browse files
authored
Fix the wallets limit filter in the wallet maintainer redemptions code (#3683)
Closes: #3682 As described in #3682, the current logic is wrong. If the `WalletsLimit` filter is on, always the same oldest wallets will be taken into account so redemption requests targeting newer wallets can be missed by the wallet maintainer. We are fixing that by applying the `WalletsLimit` filter at a later stage.
2 parents 584f47c + df84a71 commit 08ee58c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg/maintainer/wallet/redemptions.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,11 @@ func FindPendingRedemptions(
206206
}
207207

208208
logger.Infof(
209-
"built an initial list of [%v] wallets that will be checked "+
209+
"built a list of [%v] wallets that will be checked "+
210210
"for pending redemption requests",
211211
len(walletPublicKeyHashes),
212212
)
213213

214-
// Apply the wallets number limit if needed.
215-
if limit := int(filter.WalletsLimit); limit > 0 && len(walletPublicKeyHashes) > limit {
216-
walletPublicKeyHashes = walletPublicKeyHashes[:limit]
217-
218-
logger.Infof(
219-
"limited the initial wallets list to [%v] wallets",
220-
len(walletPublicKeyHashes),
221-
)
222-
}
223-
224214
result := make(map[[20]byte][]bitcoin.Script)
225215

226216
for _, walletPublicKeyHash := range walletPublicKeyHashes {
@@ -265,6 +255,17 @@ func FindPendingRedemptions(
265255
pendingRedemption.RedeemerOutputScript,
266256
)
267257
}
258+
259+
// Apply the wallets number limit if needed.
260+
if limit := int(filter.WalletsLimit); limit > 0 && len(result) == limit {
261+
logger.Infof(
262+
"aborting pending redemptions checks due to the "+
263+
"configured wallets limit; [%v] wallets with pending "+
264+
"redemptions were found so far",
265+
len(result),
266+
)
267+
break
268+
}
268269
}
269270

270271
return result, nil

0 commit comments

Comments
 (0)