Feature/eth syncing (#721)
* Delays starting of codex until eth provider is synced * bumps nim-ethers to 0.7.2 * bumps nim-ethers to 0.7.3 * Adds increasing delay to waitForSync
This commit is contained in:
parent
5e7ce52fbe
commit
53fdc88def
|
@ -12,7 +12,7 @@ requires "bearssl >= 0.1.4"
|
||||||
requires "chronicles >= 0.7.2"
|
requires "chronicles >= 0.7.2"
|
||||||
requires "chronos >= 2.5.2"
|
requires "chronos >= 2.5.2"
|
||||||
requires "confutils"
|
requires "confutils"
|
||||||
requires "ethers >= 0.7.1 & < 0.8.0"
|
requires "ethers >= 0.7.3 & < 0.8.0"
|
||||||
requires "libbacktrace"
|
requires "libbacktrace"
|
||||||
requires "libp2p"
|
requires "libp2p"
|
||||||
requires "metrics"
|
requires "metrics"
|
||||||
|
|
|
@ -56,6 +56,14 @@ type
|
||||||
CodexPrivateKey* = libp2p.PrivateKey # alias
|
CodexPrivateKey* = libp2p.PrivateKey # alias
|
||||||
EthWallet = ethers.Wallet
|
EthWallet = ethers.Wallet
|
||||||
|
|
||||||
|
proc waitForSync(provider: Provider): Future[void] {.async.} =
|
||||||
|
var sleepTime = 1
|
||||||
|
while await provider.isSyncing:
|
||||||
|
notice "Waiting for Ethereum provider to sync..."
|
||||||
|
await sleepAsync(sleepTime.seconds)
|
||||||
|
if sleepTime < 10:
|
||||||
|
inc sleepTime
|
||||||
|
|
||||||
proc bootstrapInteractions(
|
proc bootstrapInteractions(
|
||||||
s: CodexServer): Future[void] {.async.} =
|
s: CodexServer): Future[void] {.async.} =
|
||||||
## bootstrap interactions and return contracts
|
## bootstrap interactions and return contracts
|
||||||
|
@ -79,6 +87,7 @@ proc bootstrapInteractions(
|
||||||
quit QuitFailure
|
quit QuitFailure
|
||||||
|
|
||||||
let provider = JsonRpcProvider.new(config.ethProvider)
|
let provider = JsonRpcProvider.new(config.ethProvider)
|
||||||
|
await waitForSync(provider)
|
||||||
var signer: Signer
|
var signer: Signer
|
||||||
if account =? config.ethAccount:
|
if account =? config.ethAccount:
|
||||||
signer = provider.getSigner(account)
|
signer = provider.getSigner(account)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fd16d71ea58e8d3e5a7f41e5dfdaa3a9b693a815
|
Subproject commit 4c7e351fd95af779786705eac0612b6a52b13380
|
Loading…
Reference in New Issue