public ResultWrapper <BlockForRpc> eth_getBlockByHash(Keccak blockHash, bool returnFullTransactionObjects) { var block = _blockchainBridge.FindBlock(blockHash); if (block != null && returnFullTransactionObjects) { _blockchainBridge.RecoverTxSenders(block); } return(ResultWrapper <BlockForRpc> .Success(block == null?null : new BlockForRpc(block, returnFullTransactionObjects))); }
public ResultWrapper <BlockForRpc> eth_getBlockByHash(Keccak blockHash, bool returnFullTransactionObjects) { try { _readerWriterLockSlim.EnterReadLock(); var block = _blockchainBridge.FindBlock(blockHash); if (block != null && returnFullTransactionObjects) { _blockchainBridge.RecoverTxSenders(block); } return(ResultWrapper <BlockForRpc> .Success(block == null?null : new BlockForRpc(block, returnFullTransactionObjects))); } finally { _readerWriterLockSlim.ExitReadLock(); } }
public static Block GetBlock(this IBlockchainBridge blockchainBridge, BlockParameter blockParameter, bool allowNulls = false, bool recoverTxSenders = false) { Block block; switch (blockParameter.Type) { case BlockParameterType.Pending: { block = blockchainBridge.FindPendingBlock(); break; } case BlockParameterType.Latest: { block = blockchainBridge.FindLatestBlock(); break; } case BlockParameterType.Earliest: { block = blockchainBridge.FindEarliestBlock(); break; } case BlockParameterType.BlockId: { if (blockParameter.BlockId == null) { throw new JsonRpcException(ErrorType.InvalidParams, $"Block number is required for {BlockParameterType.BlockId}"); } block = blockchainBridge.FindBlock(blockParameter.BlockId.Value); break; } default: throw new Exception($"{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); }
private ResultWrapper <BlockForRpc> GetBlock(BlockParameter blockParameter, bool returnFullTransactionObjects) { SearchResult <Block> searchResult = _blockFinder.SearchForBlock(blockParameter, true); if (searchResult.IsError) { return(ResultWrapper <BlockForRpc> .Fail(searchResult)); } Block block = searchResult.Object; if (block != null) { _blockchainBridge.RecoverTxSenders(block); } return(ResultWrapper <BlockForRpc> .Success(block == null?null : new BlockForRpc(block, returnFullTransactionObjects))); }