mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-03-02 18:33:10 +00:00
fix: prevent underflow
The compiler should not allow this totalBlocks is a Natural, but...
This commit is contained in:
parent
3bc6aa8b8d
commit
4c3cfabe6c
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user