use of tech.pegasys.teku.pow.api.Eth1EventsChannel in project teku by ConsenSys.
the class DepositProcessingController method fetchLatestDepositsOneBlockAtATime.
private synchronized void fetchLatestDepositsOneBlockAtATime() {
final BigInteger nextBlockNumber;
synchronized (DepositProcessingController.this) {
if (isActiveOrAlreadyQueriedLatestCanonicalBlock()) {
return;
}
active = true;
nextBlockNumber = latestSuccessfullyQueriedBlock.add(BigInteger.ONE);
}
depositFetcher.fetchDepositsInRange(nextBlockNumber, nextBlockNumber).thenCompose(__ -> eth1Provider.getGuaranteedEth1Block(UInt64.valueOf(nextBlockNumber))).thenAccept(block -> {
final BigInteger blockNumber = block.getNumber();
LOG.trace("Successfully fetched block {} for min genesis checking", blockNumber);
if (MinimumGenesisTimeBlockFinder.compareBlockTimestampToMinGenesisTime(config, block) >= 0) {
notifyMinGenesisTimeBlockReached(eth1EventsChannel, block);
isBlockByBlockModeOn = false;
LOG.debug("Minimum genesis time block reached, switching back to fetching deposits by range");
} else {
LOG.trace("Seconds until min genesis block {}", config.getMinGenesisTime().minus(calculateCandidateGenesisTimestamp(config, block.getTimestamp())));
}
}).finish(__ -> onSubscriptionDepositRequestSuccessful(nextBlockNumber), (err) -> onSubscriptionDepositRequestFailed(err, nextBlockNumber));
}
Aggregations