Define pragma raises

This commit is contained in:
Arnaud 2025-09-09 20:30:25 +02:00 committed by Eric
parent fee0c80db8
commit 86040b0853
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -68,11 +68,13 @@ method stop*(clock: OnChainClock) {.async.} =
await clock.trackedFutures.cancelTracked()
clock.started = false
method now*(clock: OnChainClock): SecondsSince1970 =
method now*(clock: OnChainClock): SecondsSince1970 {.raises: [].} =
doAssert clock.started, "clock should be started before calling now()"
return toUnix(getTime() + clock.offset)
method waitUntil*(clock: OnChainClock, time: SecondsSince1970) {.async.} =
method waitUntil*(
clock: OnChainClock, time: SecondsSince1970
) {.async: (raises: [CancelledError]).} =
while (let difference = time - clock.now(); difference > 0):
clock.newBlock.clear()
discard await clock.newBlock.wait().withTimeout(chronos.seconds(difference))

View File

@ -80,7 +80,7 @@ proc removeSlotsThatHaveEnded(validation: Validation) {.async.} =
proc markProofAsMissing(
validation: Validation, slotId: SlotId, period: Period
) {.async.} =
) {.async: (raises: [CancelledError]).} =
logScope:
currentPeriod = validation.getCurrentPeriod()
@ -91,18 +91,18 @@ proc markProofAsMissing(
else:
let inDowntime {.used.} = await validation.market.inDowntime(slotId)
trace "Proof not missing", checkedPeriod = period, inDowntime
except CancelledError:
raise
except CancelledError as e:
raise e
except CatchableError as e:
error "Marking proof as missing failed", msg = e.msg
proc markProofsAsMissing(validation: Validation) {.async.} =
proc markProofsAsMissing(validation: Validation) {.async: (raises: [CancelledError]).} =
let slots = validation.slots
for slotId in slots:
let previousPeriod = validation.getCurrentPeriod() - 1
await validation.markProofAsMissing(slotId, previousPeriod)
proc run(validation: Validation) {.async: (raises: []).} =
proc run(validation: Validation) {.async: (raises: [CancelledError]).} =
trace "Validation started"
try:
while true: