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