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>

Repository housing blockchain information.

BlockchainRepository(chainMetadata: KeyValueStore<Bytes, Bytes>, blockBodyStore: KeyValueStore<Bytes, Bytes>, blockHeaderStore: KeyValueStore<Bytes, Bytes>, transactionReceiptStore: KeyValueStore<Bytes, Bytes>, transactionStore: KeyValueStore<Bytes, Bytes>, stateStore: KeyValueStore<Bytes, Bytes>, blockchainIndex: BlockchainIndex)

Functions

findBlockByHashOrNumber

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

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

findBlocksByParentHash

Finds hashes of blocks which have a matching parent hash.

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

hasBlockBody

Returns true if the store contains the block body.

suspend fun hasBlockBody(blockHash: Bytes): Boolean

hasBlockHeader

Returns true if the store contains the block header.

suspend fun hasBlockHeader(blockHash: Bytes): Boolean

retrieveBlock

Retrieves a block into the repository.

suspend fun retrieveBlock(blockHash: Bytes): Block?

retrieveBlockBody

Retrieves a block body into the repository.

suspend fun retrieveBlockBody(blockHash: Bytes): BlockBody?

retrieveBlockBodyBytes

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

suspend fun retrieveBlockBodyBytes(blockHash: Bytes): Bytes?

retrieveBlockHeader

Retrieves a block header into the repository.

suspend fun retrieveBlockHeader(blockHash: Bytes): BlockHeader?

retrieveBlockHeaderBytes

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

suspend fun retrieveBlockHeaderBytes(blockHash: Bytes): Bytes?

retrieveChainHead

Retrieves the block identified as the chain head

suspend fun retrieveChainHead(): Block

retrieveChainHeadHeader

Retrieves the block header identified as the chain head

suspend fun retrieveChainHeadHeader(): BlockHeader?

retrieveChainHeadTotalDifficulty

fun retrieveChainHeadTotalDifficulty(): UInt256

retrieveGenesisBlock

Retrieves the block identified as the genesis block

suspend fun retrieveGenesisBlock(): Block

retrieveNodeData

suspend fun retrieveNodeData(hashes: List<Hash>): List<Bytes?>

retrieveTransactionReceipt

Retrieves a transaction receipt associated with a block and an index

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

retrieveTransactionReceipts

Retrieves all transaction receipts associated with a block.

suspend fun retrieveTransactionReceipts(blockHash: Bytes): List<TransactionReceipt>

storeBlock

Stores a block into the repository.

suspend fun storeBlock(block: Block): Unit

storeBlockBody

Stores a block body into the repository.

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

storeBlockHeader

Stores a block header in the repository.

suspend fun storeBlockHeader(header: BlockHeader): Unit

storeNodeData

Stores state node data into the repository.

suspend fun storeNodeData(hash: Hash, bytes: Bytes): Unit

storeTransaction

suspend fun storeTransaction(transaction: Transaction): Unit

storeTransactionReceipt

Stores a transaction receipt in the repository.

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

Companion Object Properties

GENESIS_BLOCK

val GENESIS_BLOCK: Bytes!

logger

val logger: Logger!

Companion Object Functions

init

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

suspend fun init(blockBodyStore: KeyValueStore<Bytes, Bytes>, blockHeaderStore: KeyValueStore<Bytes, Bytes>, chainMetadata: KeyValueStore<Bytes, Bytes>, transactionReceiptsStore: KeyValueStore<Bytes, Bytes>, transactionStore: KeyValueStore<Bytes, Bytes>, stateStore: KeyValueStore<Bytes, Bytes>, blockchainIndex: BlockchainIndex, genesisBlock: Block): BlockchainRepository