use of tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException in project teku by ConsenSys.
the class MergeTransitionBlockValidator method verifyFinalizedTransitionBlock.
private SafeFuture<PayloadValidationResult> verifyFinalizedTransitionBlock() {
return recentChainData.getStore().getFinalizedOptimisticTransitionPayload().map(slotAndPayload -> verifyTransitionPayload(slotAndPayload.getSlot(), slotAndPayload.getExecutionPayload())).orElse(SafeFuture.completedFuture(PayloadStatus.VALID)).thenCompose(status -> {
if (status.hasInvalidStatus()) {
return SafeFuture.failedFuture(new FatalServiceFailureException("fork choice", "Optimistic sync finalized an invalid transition block. Unable to recover."));
}
if (status.hasValidStatus()) {
final StoreTransaction transaction = recentChainData.startStoreTransaction();
transaction.removeFinalizedOptimisticTransitionPayload();
return transaction.commit().thenApply(__ -> new PayloadValidationResult(status));
}
return SafeFuture.completedFuture(new PayloadValidationResult(status));
});
}
Aggregations