compare before decrementing

This commit is contained in:
chirag-parmar 2024-10-31 20:53:03 +05:30
parent 329eb68657
commit e68988b287
1 changed files with 2 additions and 2 deletions

View File

@ -65,11 +65,11 @@ proc maybeClosePendingLists(self: var RlpWriter) =
let lastListIdx = self.pendingLists.len - 1
doAssert self.pendingLists[lastListIdx].remainingItems > 0
self.pendingLists[lastListIdx].remainingItems -= 1
# if one last item is remaining in the list
if self.pendingLists[lastListIdx].remainingItems == 0:
if self.pendingLists[lastListIdx].remainingItems == 1:
# A list have been just finished. It was started in `startList`.
let listStartPos = self.pendingLists[lastListIdx].startPos
self.pendingLists[lastListIdx].remainingItems -= 1
self.pendingLists.setLen lastListIdx
# How many bytes were written since the start?