Fix #1823
This commit is contained in:
parent
ee663d9fc2
commit
d913273dcc
|
@ -253,10 +253,31 @@ proc readJsonDeposits(depositsList: JsonNode): seq[Eth1Block] =
|
||||||
proc fetchDepositData*(p: Web3DataProviderRef,
|
proc fetchDepositData*(p: Web3DataProviderRef,
|
||||||
fromBlock, toBlock: Eth1BlockNumber): Future[seq[Eth1Block]]
|
fromBlock, toBlock: Eth1BlockNumber): Future[seq[Eth1Block]]
|
||||||
{.async, locks: 0.} =
|
{.async, locks: 0.} =
|
||||||
debug "Obtaining deposit log events", fromBlock, toBlock
|
var currentBlock = fromBlock
|
||||||
return readJsonDeposits(await p.ns.getJsonLogs(DepositEvent,
|
while currentBlock <= toBlock:
|
||||||
fromBlock = some blockId(fromBlock),
|
var blocksPerRequest = 128'u64
|
||||||
toBlock = some blockId(toBlock)))
|
while true:
|
||||||
|
let requestToBlock = min(toBlock, currentBlock + blocksPerRequest - 1)
|
||||||
|
|
||||||
|
debug "Obtaining deposit log events",
|
||||||
|
fromBlock = currentBlock,
|
||||||
|
toBlock = requestToBlock
|
||||||
|
|
||||||
|
let depositLogs = try:
|
||||||
|
await p.ns.getJsonLogs(
|
||||||
|
DepositEvent,
|
||||||
|
fromBlock = some blockId(currentBlock),
|
||||||
|
toBlock = some blockId(requestToBlock))
|
||||||
|
except CatchableError as err:
|
||||||
|
blocksPerRequest = blocksPerRequest div 2
|
||||||
|
if blocksPerRequest > 0:
|
||||||
|
continue
|
||||||
|
raise err
|
||||||
|
|
||||||
|
currentBlock = requestToBlock + 1
|
||||||
|
result.add readJsonDeposits(depositLogs)
|
||||||
|
break # breaks the inner "retry" loop and continues
|
||||||
|
# to the next range of blocks to request
|
||||||
|
|
||||||
proc fetchBlockDetails(p: Web3DataProviderRef, blk: Eth1Block) {.async.} =
|
proc fetchBlockDetails(p: Web3DataProviderRef, blk: Eth1Block) {.async.} =
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in New Issue