class BlockchainRepository : CoroutineScope
(source)
Repository housing blockchain information.
This repository allows storing blocks, block headers and metadata about the blockchain, such as forks and head information.
chainMetadata
- the key-value store to store chain metadata
blockBodyStore
- the key-value store to store block bodies
blockHeaderStore
- the key-value store to store block headers
transactionReceiptStore
- the key-value store to store transaction receipts
transactionStore
- the key-value store to store transactions
stateStore
- the key-value store to store the global state
blockchainIndex
- the blockchain index to index values
meter
- an optional metering provider to watch metrics in the repository
<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, meter: Meter? = null, coroutineContext: CoroutineContext = Dispatchers.Default) |
blockBodiesStoredCounter |
val blockBodiesStoredCounter: LongCounter? |
blockHeaderListeners |
val blockHeaderListeners: MutableMap<String, (BlockHeader) -> Unit> |
blockHeadersStoredCounter |
val blockHeadersStoredCounter: LongCounter? |
blocksStoredCounter |
val blocksStoredCounter: LongCounter? |
coroutineContext |
val coroutineContext: CoroutineContext |
indexing |
var indexing: Boolean |
accountsExists |
Checks if a given account is stored in the repository. suspend fun accountsExists(address: Address): Boolean |
addBlockHeaderListener |
fun addBlockHeaderListener(listener: (BlockHeader) -> Unit): String |
close |
Closes the repository. fun close(): Unit |
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> |
getAccount |
Retrieves an account state for a given account. suspend fun getAccount(address: Address): AccountState? |
getAccountCode |
Gets the code of an account suspend fun getAccountCode(address: Address): Bytes? |
getAccountStoreValue |
Gets a value stored in an account store, or null if the account doesn't exist. suspend fun getAccountStoreValue(address: Address, key: Bytes32): Bytes32? |
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 |
indexBlockHeader |
suspend fun indexBlockHeader(header: BlockHeader): Unit |
reIndexTotalDifficulty |
suspend fun reIndexTotalDifficulty(): Unit |
removeBlockHeaderListener |
fun removeBlockHeaderListener(listenerId: String): Unit |
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 |
retrieveGenesisBlock |
Retrieves the block identified as the genesis block suspend fun retrieveGenesisBlock(): Block |
retrieveNodeData |
Retrieves data, sending back exactly the list requested. If data is missing, the list entry is null. 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> |
storeAccount |
Stores an account state for a given account. suspend fun storeAccount(address: Address, account: AccountState): Unit |
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 |
storeCode |
Stores account code in world state suspend fun storeCode(code: Bytes): Unit |
storeNodeData |
Stores state node data into the repository. suspend fun storeNodeData(hash: Hash, bytes: Bytes): Unit |
storeTransaction |
Stores a transaction. 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 |
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, meter: Meter? = null): BlockchainRepository |
inMemory |
Constructs a blockchain repository that resides entirely in heap. fun inMemory(): BlockchainRepository |