Hotfix: don't crash on web3 provider errors during initialization

This commit is contained in:
Zahary Karadjov 2020-11-20 10:26:27 +02:00
parent 6568e428b1
commit 883e18da81
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 25 additions and 22 deletions

View File

@ -416,6 +416,7 @@ proc init*(T: type Eth1Monitor,
var web3Url = web3Url
fixupWeb3Urls web3Url
try:
let dataProviderRes = await Web3DataProvider.new(depositContractAddress, web3Url)
if dataProviderRes.isErr:
return err(dataProviderRes.error)
@ -441,6 +442,8 @@ proc init*(T: type Eth1Monitor,
depositContractDeployedAt: depositContractDeployedAt,
dataProvider: dataProvider,
eth1Progress: newAsyncEvent())
except CatchableError as err:
return err("Failed to initialize the Eth1 monitor")
proc allDepositsUpTo(m: Eth1Monitor, totalDeposits: uint64): seq[DepositData] =
for i in 0'u64 ..< totalDeposits: