Interface BlockchainService

All Superinterfaces:
BesuService

public interface BlockchainService extends BesuService
A service that plugins can use to query blocks by number
  • Method Details

    • getBlockByNumber

      Optional<BlockContext> getBlockByNumber(long number)
      Gets block by number
      Parameters:
      number - the block number
      Returns:
      the BlockContext
    • getBlockByHash

      Optional<BlockContext> getBlockByHash(org.hyperledger.besu.datatypes.Hash hash)
      Gets block by hash
      Parameters:
      hash - the block hash
      Returns:
      the BlockContext
    • getBlockHeaderByHash

      Optional<BlockHeader> getBlockHeaderByHash(org.hyperledger.besu.datatypes.Hash hash)
      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

      org.hyperledger.besu.datatypes.Wei getBlobGasPrice(BlockHeader blockHeader)
      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 header
      blockBody - the block body
      receipts - 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 chain
      UnsupportedOperationException - 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 chain
      UnsupportedOperationException - if the network is a PoS network
    • getChainId

      Optional<BigInteger> getChainId()
      Get the chain id
      Returns:
      the chain id
    • getHardforkId

      org.hyperledger.besu.datatypes.HardforkId getHardforkId(BlockHeader blockHeader)
      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 header
      timestampForNextBlock - the timestamp for the next block
      Returns:
      the hardfork identifier that will be applicable to the next block