[clock] Avoid crash when getBlock fails
This commit is contained in:
parent
3a8ce485e4
commit
83522e459c
|
@ -26,7 +26,8 @@ proc start*(clock: OnChainClock) {.async.} =
|
|||
let computerTime = getTime().toUnix
|
||||
clock.offset = blockTime - computerTime
|
||||
|
||||
onBlock(!await clock.provider.getBlock(BlockTag.latest))
|
||||
if latestBlock =? (await clock.provider.getBlock(BlockTag.latest)):
|
||||
onBlock(latestBlock)
|
||||
|
||||
clock.subscription = await clock.provider.subscribe(onBlock)
|
||||
|
||||
|
|
Loading…
Reference in New Issue