Fix the 'maxDelay' FieldError problem during the initial deposit making when joining a testnet
This commit is contained in:
parent
0b3a468883
commit
c19321e578
|
@ -7,7 +7,7 @@
|
|||
|
||||
import
|
||||
# Standard library
|
||||
algorithm, os, tables, strutils, times, math, terminal,
|
||||
algorithm, os, tables, strutils, times, math, terminal, random,
|
||||
|
||||
# Nimble packages
|
||||
stew/[objects, byteutils], stew/shims/macros,
|
||||
|
@ -1235,12 +1235,17 @@ programMain:
|
|||
waitFor sendDeposits(config, deposits.value)
|
||||
|
||||
of DepositsCmd.send:
|
||||
var delayGenerator: DelayGenerator
|
||||
if config.maxDelay > 0.0:
|
||||
delayGenerator = proc (): chronos.Duration {.gcsafe.} =
|
||||
chronos.milliseconds (rand(config.minDelay..config.maxDelay)*1000).int
|
||||
|
||||
if config.minDelay > config.maxDelay:
|
||||
echo "The minimum delay should not be larger than the maximum delay"
|
||||
quit 1
|
||||
|
||||
let deposits = loadDeposits(config.depositsDir)
|
||||
waitFor sendDeposits(config, deposits)
|
||||
waitFor sendDeposits(config, deposits, delayGenerator)
|
||||
|
||||
of DepositsCmd.status:
|
||||
# TODO
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
os, strutils, terminal, random,
|
||||
os, strutils, terminal,
|
||||
chronicles, chronos, blscurve, nimcrypto, json_serialization, serialization,
|
||||
web3, stint, eth/keys, confutils,
|
||||
spec/[datatypes, digest, crypto, keystore], conf, ssz/merkleization, merkle_minimal
|
||||
|
@ -193,12 +193,8 @@ proc sendDeposits*(deposits: seq[Deposit],
|
|||
await sleepAsync(delayGenerator())
|
||||
|
||||
proc sendDeposits*(config: BeaconNodeConf,
|
||||
deposits: seq[Deposit]) {.async.} =
|
||||
var delayGenerator: DelayGenerator
|
||||
if config.maxDelay > 0.0:
|
||||
delayGenerator = proc (): chronos.Duration {.gcsafe.} =
|
||||
chronos.milliseconds (rand(config.minDelay..config.maxDelay)*1000).int
|
||||
|
||||
deposits: seq[Deposit],
|
||||
delayGenerator: DelayGenerator = nil) {.async.} =
|
||||
info "Sending deposits",
|
||||
web3 = config.web3Url,
|
||||
depositContract = config.depositContractAddress
|
||||
|
|
Loading…
Reference in New Issue