use of tech.pegasys.teku.ethereum.pow.api.InvalidDepositEventsException in project teku by ConsenSys.
the class DepositFetcher method sendNextBatchRequest.
private SafeFuture<Void> sendNextBatchRequest(final DepositFetchState fetchState) {
final BigInteger nextBatchEnd = fetchState.getNextBatchEnd();
LOG.debug("Requesting deposits between {} and {}. Batch size: {}", fetchState.nextBatchStart, nextBatchEnd, fetchState.batchSize);
return processDepositsInBatch(fetchState.nextBatchStart, nextBatchEnd).exceptionallyCompose((err) -> {
LOG.debug("Failed to request deposit events for block numbers in the range ({}, {}). Retrying.", fetchState.nextBatchStart, nextBatchEnd, err);
final Throwable rootCause = Throwables.getRootCause(err);
if (rootCause instanceof InvalidDepositEventsException) {
STATUS_LOG.eth1DepositEventsFailure(rootCause);
} else if (rootCause instanceof Eth1RequestException && ((Eth1RequestException) rootCause).containsExceptionSolvableWithSmallerRange()) {
STATUS_LOG.eth1FetchDepositsRequiresSmallerRange(fetchState.batchSize);
fetchState.reduceBatchSize();
}
return asyncRunner.runAfterDelay(() -> sendNextBatchRequest(fetchState), Constants.ETH1_DEPOSIT_REQUEST_RETRY_TIMEOUT);
}).thenCompose(__ -> {
fetchState.moveToNextBatch();
LOG.trace("Batch request completed. Done? {}", fetchState.isDone());
if (fetchState.isDone()) {
return SafeFuture.COMPLETE;
} else {
return sendNextBatchRequest(fetchState);
}
});
}
Aggregations