mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
fix(rln-relay): enforce error callback to remove exception raised from retryWrapper (#2622)
This commit is contained in:
parent
963d79aee7
commit
f93e47e9eb
@ -637,7 +637,7 @@ proc startOnchainSync(
|
||||
var currentLatestBlock: BlockNumber
|
||||
g.retryWrapper(currentLatestBlock, "Failed to get the latest block number"):
|
||||
cast[BlockNumber](await ethRpc.provider.eth_blockNumber())
|
||||
|
||||
|
||||
try:
|
||||
# we always want to sync from last processed block => latest
|
||||
# chunk events
|
||||
@ -646,11 +646,10 @@ proc startOnchainSync(
|
||||
# then fetch the new toBlock
|
||||
if fromBlock >= currentLatestBlock:
|
||||
break
|
||||
|
||||
|
||||
if fromBlock + blockChunkSize.uint > currentLatestBlock.uint:
|
||||
g.retryWrapper(currentLatestBlock, "Failed to get the latest block number"):
|
||||
cast[BlockNumber](await ethRpc.provider.eth_blockNumber())
|
||||
|
||||
|
||||
let toBlock = min(fromBlock + BlockNumber(blockChunkSize), currentLatestBlock)
|
||||
debug "fetching events", fromBlock = fromBlock, toBlock = toBlock
|
||||
|
||||
@ -13,7 +13,7 @@ template retryWrapper*(
|
||||
res: auto,
|
||||
retryStrategy: RetryStrategy,
|
||||
errStr: string,
|
||||
errCallback: OnFatalErrorHandler = nil,
|
||||
errCallback: OnFatalErrorHandler,
|
||||
body: untyped,
|
||||
): auto =
|
||||
var retryCount = retryStrategy.retryCount
|
||||
@ -29,10 +29,5 @@ template retryWrapper*(
|
||||
exceptionMessage = getCurrentExceptionMsg()
|
||||
await sleepAsync(retryStrategy.retryDelay)
|
||||
if shouldRetry:
|
||||
if errCallback == nil:
|
||||
raise newException(
|
||||
CatchableError, errStr & " errCallback == nil: " & exceptionMessage
|
||||
)
|
||||
else:
|
||||
errCallback(errStr & ": " & exceptionMessage)
|
||||
return
|
||||
errCallback(errStr & ": " & exceptionMessage)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user