public ResultWrapper <ReceiptForRpc[]> parity_getBlockReceipts(BlockParameter blockParameter) { var filterBlock = blockParameter.ToFilterBlock(); var block = _blockFinder.GetBlock(filterBlock); var receipts = _receiptStorage.FindForBlock(block); var result = receipts.Zip(block.Transactions, (r, t) => new ReceiptForRpc(t.Hash, r)); return(ResultWrapper <ReceiptForRpc[]> .Success(result.ToArray())); }
public static Block GetBlock(this IBlockchainBridge blockchainBridge, BlockParameter blockParameter, bool allowNulls = false, bool recoverTxSenders = false) { Block block; switch (blockParameter.Type) { case BlockParameterType.BlockNumber: { if (blockParameter.BlockNumber == null) { throw new JsonRpcException(ErrorType.InvalidParams, $"Block number is required for {BlockParameterType.BlockNumber}"); } block = blockchainBridge.GetBlock(blockParameter.ToFilterBlock()); break; } case BlockParameterType.Pending: case BlockParameterType.Latest: case BlockParameterType.Earliest: { block = blockchainBridge.GetBlock(blockParameter.ToFilterBlock()); break; } default: throw new ArgumentException($"{nameof(BlockParameterType)} not supported: {blockParameter.Type}"); } if (block == null && !allowNulls) { throw new JsonRpcException(ErrorType.NotFound, $"Cannot find block {blockParameter}"); } // if (block != null && recoverTxSenders) // { // blockchainBridge.RecoverTxSenders(block); // } return(block); }
public static BlockHeader GetHeader(this IBlockchainBridge blockchainBridge, BlockParameter blockParameter, bool allowNulls = false) { BlockHeader header; switch (blockParameter.Type) { case BlockParameterType.BlockNumber: { if (blockParameter.BlockNumber == null) { throw new JsonRpcException(ErrorType.InvalidParams, $"Block number is required for {BlockParameterType.BlockNumber}"); } header = blockchainBridge.GetHeader(blockParameter.ToFilterBlock()); break; } case BlockParameterType.Pending: case BlockParameterType.Latest: case BlockParameterType.Earliest: { header = blockchainBridge.GetHeader(blockParameter.ToFilterBlock()); break; } default: throw new ArgumentException($"{nameof(BlockParameterType)} not supported: {blockParameter.Type}"); } if (header == null && !allowNulls) { throw new JsonRpcException(ErrorType.NotFound, $"Cannot find block {blockParameter}"); } return(header); }