Interface BlockchainService
- All Superinterfaces:
BesuService
A service that plugins can use to query blocks by number
-
Method Summary
Modifier and TypeMethodDescriptionorg.hyperledger.besu.datatypes.WeigetBlobGasPrice(BlockHeader blockHeader) Return the blob gas price for the specified blockgetBlockByHash(org.hyperledger.besu.datatypes.Hash hash) Gets block by hashgetBlockByNumber(long number) Gets block by numbergetBlockHeaderByHash(org.hyperledger.besu.datatypes.Hash hash) Gets block header by hashorg.hyperledger.besu.datatypes.HashGet the hash of the chain headGet the block header of the chain headGet the chain idOptional<org.hyperledger.besu.datatypes.Hash> Get the block hash of the finalized blockorg.hyperledger.besu.datatypes.HardforkIdgetHardforkId(long blockNumber) Get the hardfork identifier for the given block numberorg.hyperledger.besu.datatypes.HardforkIdgetHardforkId(BlockHeader blockHeader) Get the hardfork identifier for the given block headerOptional<org.hyperledger.besu.datatypes.Wei> Return the base fee for the next blockorg.hyperledger.besu.datatypes.HardforkIdgetNextBlockHardforkId(BlockHeader parentBlockHeader, long timestampForNextBlock) Get the hardfork identifier for the next block based on the parent block and timestampgetReceiptsByBlockHash(org.hyperledger.besu.datatypes.Hash blockHash) Get the receipts for a block by block hashOptional<org.hyperledger.besu.datatypes.Hash> Get the block hash of the safe blockOptional<org.hyperledger.besu.datatypes.Transaction> getTransactionByHash(org.hyperledger.besu.datatypes.Hash transactionHash) Get a transaction by its hashvoidsetFinalizedBlock(org.hyperledger.besu.datatypes.Hash blockHash) Set the finalized block for non-PoS networksvoidsetSafeBlock(org.hyperledger.besu.datatypes.Hash blockHash) Set the safe block for non-PoS networksvoidstoreBlock(BlockHeader blockHeader, BlockBody blockBody, List<? extends TransactionReceipt> receipts) Store a block
-
Method Details
-
getBlockByNumber
Gets block by number- Parameters:
number- the block number- Returns:
- the BlockContext
-
getBlockByHash
Gets block by hash- Parameters:
hash- the block hash- Returns:
- the BlockContext
-
getBlockHeaderByHash
Gets block header by hash- Parameters:
hash- the block hash- Returns:
- the block header if block exists otherwise empty
-
getChainHeadHash
org.hyperledger.besu.datatypes.Hash getChainHeadHash()Get the hash of the chain head- Returns:
- chain head hash
-
getBlobGasPrice
Return the blob gas price for the specified block- Parameters:
blockHeader- the block header- Returns:
- the block gas price or Wei.ZERO if blobs are not yet supported for that block header
-
getTransactionByHash
Optional<org.hyperledger.besu.datatypes.Transaction> getTransactionByHash(org.hyperledger.besu.datatypes.Hash transactionHash) Get a transaction by its hash- Parameters:
transactionHash- the transaction hash- Returns:
- the transaction
-
getReceiptsByBlockHash
Optional<List<TransactionReceipt>> getReceiptsByBlockHash(org.hyperledger.besu.datatypes.Hash blockHash) Get the receipts for a block by block hash- Parameters:
blockHash- the block hash- Returns:
- the transaction receipts
-
storeBlock
void storeBlock(BlockHeader blockHeader, BlockBody blockBody, List<? extends TransactionReceipt> receipts) Store a block- Parameters:
blockHeader- the block headerblockBody- the block bodyreceipts- the transaction receipts
-
getChainHeadHeader
BlockHeader getChainHeadHeader()Get the block header of the chain head- Returns:
- chain head block header
-
getNextBlockBaseFee
Optional<org.hyperledger.besu.datatypes.Wei> getNextBlockBaseFee()Return the base fee for the next block- Returns:
- base fee of the next block or empty if the fee market does not support base fee
-
getSafeBlock
Optional<org.hyperledger.besu.datatypes.Hash> getSafeBlock()Get the block hash of the safe block- Returns:
- the block hash of the safe block
-
getFinalizedBlock
Optional<org.hyperledger.besu.datatypes.Hash> getFinalizedBlock()Get the block hash of the finalized block- Returns:
- the block hash of the finalized block
-
setFinalizedBlock
void setFinalizedBlock(org.hyperledger.besu.datatypes.Hash blockHash) throws IllegalArgumentException, UnsupportedOperationException Set the finalized block for non-PoS networks- Parameters:
blockHash- Hash of the finalized block- Throws:
IllegalArgumentException- if the block hash is not on the chainUnsupportedOperationException- if the network is a PoS network
-
setSafeBlock
void setSafeBlock(org.hyperledger.besu.datatypes.Hash blockHash) throws IllegalArgumentException, UnsupportedOperationException Set the safe block for non-PoS networks- Parameters:
blockHash- Hash of the finalized block- Throws:
IllegalArgumentException- if the block hash is not on the chainUnsupportedOperationException- if the network is a PoS network
-
getChainId
-
getHardforkId
Get the hardfork identifier for the given block header- Parameters:
blockHeader- the block header to determine the hardfork for- Returns:
- the hardfork identifier applicable to the given block
-
getHardforkId
org.hyperledger.besu.datatypes.HardforkId getHardforkId(long blockNumber) Get the hardfork identifier for the given block number- Parameters:
blockNumber- the block number to determine the hardfork for- Returns:
- the hardfork identifier applicable to the given block number
- Throws:
IllegalArgumentException- if no block with that number exists
-
getNextBlockHardforkId
org.hyperledger.besu.datatypes.HardforkId getNextBlockHardforkId(BlockHeader parentBlockHeader, long timestampForNextBlock) Get the hardfork identifier for the next block based on the parent block and timestamp- Parameters:
parentBlockHeader- the parent block headertimestampForNextBlock- the timestamp for the next block- Returns:
- the hardfork identifier that will be applicable to the next block
-