Search in sources :

Example 1 with BLOCK_NOT_FOUND

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));
}
Also used : ValidationResult(org.hyperledger.besu.ethereum.mainnet.ValidationResult) TransactionSimulator(org.hyperledger.besu.ethereum.transaction.TransactionSimulator) BLOCK_NOT_FOUND(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND) INTERNAL_ERROR(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR) JsonRpcError(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) JsonCallParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter) JsonRpcResponse(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) JsonRpcSuccessResponse(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse) OperationTracer(org.hyperledger.besu.evm.tracing.OperationTracer) JsonRpcErrorConverter(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter) JsonRpcErrorResponse(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse) TransactionValidationParams(org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams) TransactionProcessingResult(org.hyperledger.besu.ethereum.processing.TransactionProcessingResult) RpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod) TransactionSimulatorResult(org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult) Wei(org.hyperledger.besu.datatypes.Wei) JsonRpcRequestContext(org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext) BlockParameterOrBlockHash(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash) ImmutableTransactionValidationParams(org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams) TransactionInvalidReason(org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason) Hash(org.hyperledger.besu.datatypes.Hash) JsonCallParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) JsonRpcSuccessResponse(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse) JsonRpcErrorResponse(org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse)

Aggregations

Hash (org.hyperledger.besu.datatypes.Hash)1 Wei (org.hyperledger.besu.datatypes.Wei)1 JsonRpcErrorConverter (org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcErrorConverter)1 RpcMethod (org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod)1 JsonRpcRequestContext (org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext)1 BlockParameterOrBlockHash (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash)1 JsonCallParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter)1 JsonRpcError (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError)1 BLOCK_NOT_FOUND (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.BLOCK_NOT_FOUND)1 INTERNAL_ERROR (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.INTERNAL_ERROR)1 JsonRpcErrorResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse)1 JsonRpcResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse)1 JsonRpcSuccessResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse)1 BlockchainQueries (org.hyperledger.besu.ethereum.api.query.BlockchainQueries)1 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)1 ImmutableTransactionValidationParams (org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams)1 TransactionValidationParams (org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams)1 ValidationResult (org.hyperledger.besu.ethereum.mainnet.ValidationResult)1 TransactionProcessingResult (org.hyperledger.besu.ethereum.processing.TransactionProcessingResult)1 TransactionInvalidReason (org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason)1