eth-repository / org.apache.tuweni.eth.repository / BlockchainRepository

BlockchainRepository

class BlockchainRepository (source)

Repository housing blockchain information.

This repository allows storing blocks, block headers and metadata about the blockchain, such as forks and head information.

Constructors

<init>

BlockchainRepository(chainMetadata: KeyValueStore, blockBodyStore: KeyValueStore, blockHeaderStore: KeyValueStore, transactionReceiptsStore: KeyValueStore, blockchainIndex: BlockchainIndex)

Repository housing blockchain information.

Functions

findBlockByHashOrNumber

fun findBlockByHashOrNumber(blockNumberOrBlockHash: Bytes32): List<Hash>

Finds a block according to the bytes, which can be a block number or block hash.

findBlocksByParentHash

fun findBlocksByParentHash(parentHash: Hash): List<Hash>

Finds hashes of blocks which have a matching parent hash.

retrieveBlock

suspend fun retrieveBlock(blockHash: Hash): Block?
suspend fun retrieveBlock(blockHash: Bytes): Block?

Retrieves a block into the repository.

retrieveBlockBody

suspend fun retrieveBlockBody(blockHash: Hash): BlockBody?
suspend fun retrieveBlockBody(blockHash: Bytes): BlockBody?

Retrieves a block body into the repository.

retrieveBlockBodyBytes

suspend fun retrieveBlockBodyBytes(blockHash: Hash): Bytes?

Retrieves a block into the repository as its serialized RLP bytes representation.

suspend fun retrieveBlockBodyBytes(blockHash: Bytes): Bytes?

Retrieves a block body into the repository as its serialized RLP bytes representation.

retrieveBlockHeader

suspend fun retrieveBlockHeader(blockHash: Hash): BlockHeader?
suspend fun retrieveBlockHeader(blockHash: Bytes): BlockHeader?

Retrieves a block header into the repository.

retrieveBlockHeaderBytes

suspend fun retrieveBlockHeaderBytes(blockHash: Hash): Bytes?
suspend fun retrieveBlockHeaderBytes(blockHash: Bytes): Bytes?

Retrieves a block header into the repository as its serialized RLP bytes representation.

retrieveChainHead

suspend fun retrieveChainHead(): Block?

Retrieves the block identified as the chain head

retrieveChainHeadHeader

suspend fun retrieveChainHeadHeader(): BlockHeader?

Retrieves the block header identified as the chain head

retrieveGenesisBlock

suspend fun retrieveGenesisBlock(): Block?

Retrieves the block identified as the genesis block

retrieveTransactionReceipt

suspend fun retrieveTransactionReceipt(blockHash: Hash, index: Int): TransactionReceipt?
suspend fun retrieveTransactionReceipt(txHash: Hash): TransactionReceipt?

Retrieves a transaction receipt associated with a block and an index

retrieveTransactionReceipts

suspend fun retrieveTransactionReceipts(blockHash: Hash): List<TransactionReceipt?>

Retrieves all transaction receipts associated with a block.

storeBlock

suspend fun storeBlock(block: Block): Unit

Stores a block into the repository.

storeBlockBody

suspend fun storeBlockBody(blockHash: Hash, blockBody: BlockBody): Unit

Stores a block body into the repository.

storeBlockHeader

suspend fun storeBlockHeader(header: BlockHeader): Unit

Stores a block header in the repository.

storeTransactionReceipt

suspend fun storeTransactionReceipt(transactionReceipt: TransactionReceipt, txIndex: Int, txHash: Hash, blockHash: Hash): Unit

Stores a transaction receipt in the repository.

storeTransactionReceipts

suspend fun storeTransactionReceipts(vararg transactionReceipts: TransactionReceipt, txHash: Hash, blockHash: Hash): Unit

Store all the transaction receipts of a block in the repository.

Companion Object Properties

GENESIS_BLOCK

val GENESIS_BLOCK: Bytes

Companion Object Functions

init

suspend fun init(blockBodyStore: KeyValueStore, blockHeaderStore: KeyValueStore, chainMetadata: KeyValueStore, transactionReceiptsStore: KeyValueStore, blockchainIndex: BlockchainIndex, genesisBlock: Block): BlockchainRepository

Initializes a blockchain repository with metadata, placing it in key-value stores.