Fix error in removing recent roots not checking AcceptableWindowSize

This commit is contained in:
stubbsta 2025-10-28 09:12:03 +02:00
parent 65494a9777
commit 6d76942950
No known key found for this signature in database

View File

@ -275,12 +275,10 @@ proc updateRoots*(g: OnchainGroupManager): Future[bool] {.async.} =
debug "adding new recent root", root = r
g.validRoots.addLast(r)
var removed = 0
let addCount = toAdd.len
while removed < addCount and g.validRoots.len > 0:
# Only trim the deque if it exceeds the acceptable window size
while g.validRoots.len > AcceptableRootWindowSize:
debug "removing old recent root", root = g.validRoots[0]
discard g.validRoots.popFirst()
inc removed
return true