fix: prevent underflow

The compiler should not allow this totalBlocks is a Natural, but...
This commit is contained in:
E M 2026-02-23 22:45:46 +11:00
parent 3bc6aa8b8d
commit 4c3cfabe6c
No known key found for this signature in database

View File

@ -94,9 +94,9 @@ proc updateTotalBlocksCount*(
proc(maybeCurrCount: ?Natural): Future[?Natural] {.async.} =
let count: Natural =
if currCount =? maybeCurrCount:
currCount + plusCount - minusCount
max(0, currCount + plusCount - minusCount)
else:
plusCount - minusCount
max(0, plusCount - minusCount)
self.totalBlocks = count
storage_repostore_blocks.set(count.int64)