use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND in project besu by hyperledger.
the class EthCall method resultByBlockHash.
@Override
protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
JsonCallParameter callParams = JsonCallParameterUtil.validateAndGetCallParams(request);
final BlockHeader header = blockchainQueries.get().getBlockHeaderByHash(blockHash).orElse(null);
if (header == null) {
return errorResponse(request, BLOCK_NOT_FOUND);
}
return transactionSimulator.process(callParams, buildTransactionValidationParams(header, callParams), OperationTracer.NO_TRACING, header).map(result -> result.getValidationResult().either((() -> result.isSuccessful() ? new JsonRpcSuccessResponse(request.getRequest().getId(), result.getOutput().toString()) : errorResponse(request, result)), reason -> new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcErrorConverter.convertTransactionInvalidReason(reason)))).orElse(errorResponse(request, INTERNAL_ERROR));
}
Aggregations