pub trait ChainStateAccess {
// Required methods
fn has_object(&self, hash: &Hash) -> bool;
fn get_object(&self, hash: &Hash) -> Option<ChainObject>;
fn get_headers_for_locator(
&self,
locator: &[Hash],
stop: &Hash,
) -> Vec<BlockHeader>;
fn get_mempool_transactions(&self) -> Vec<Transaction>;
// Provided methods
fn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>> { ... }
fn ban_entries(&self) -> Vec<BanEntry> { ... }
fn apply_ban(&self, entry: &BanEntry) -> Result<(), String> { ... }
fn stored_utxo_commitment(
&self,
_block_hash: &Hash,
) -> Result<Option<UTXOCommitment>, String> { ... }
fn stored_block_filter(
&self,
_block_hash: &Hash,
) -> Result<Option<(BlockHeader, Vec<u8>)>, String> { ... }
}Expand description
Trait for chain state access (node layer implements this)
This trait allows the protocol layer to query chain state without owning it. The node layer provides real implementations using its storage modules (BlockStore, TxIndex, MempoolManager).
Required Methods§
Sourcefn has_object(&self, hash: &Hash) -> bool
fn has_object(&self, hash: &Hash) -> bool
Check if we have an object (block or transaction) by hash
Sourcefn get_object(&self, hash: &Hash) -> Option<ChainObject>
fn get_object(&self, hash: &Hash) -> Option<ChainObject>
Get an object (block or transaction) by hash
Sourcefn get_headers_for_locator(
&self,
locator: &[Hash],
stop: &Hash,
) -> Vec<BlockHeader>
fn get_headers_for_locator( &self, locator: &[Hash], stop: &Hash, ) -> Vec<BlockHeader>
Get headers for a block locator (for GetHeaders requests) This implements the Bitcoin block locator algorithm
Sourcefn get_mempool_transactions(&self) -> Vec<Transaction>
fn get_mempool_transactions(&self) -> Vec<Transaction>
Get all mempool transactions
Provided Methods§
Sourcefn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>>
fn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>>
Witness stacks for a stored block (SegWit relay). Default: not available.
Sourcefn ban_entries(&self) -> Vec<BanEntry>
fn ban_entries(&self) -> Vec<BanEntry>
Ban entries this node would return from getbanlist. Default: none stored.
Sourcefn apply_ban(&self, entry: &BanEntry) -> Result<(), String>
fn apply_ban(&self, entry: &BanEntry) -> Result<(), String>
Apply one ban the way setban does: the address is the IP with port 0, and
timestamp is the absolute unban time (0 is permanent).
Sourcefn stored_utxo_commitment(
&self,
_block_hash: &Hash,
) -> Result<Option<UTXOCommitment>, String>
fn stored_utxo_commitment( &self, _block_hash: &Hash, ) -> Result<Option<UTXOCommitment>, String>
Stored UTXO commitment for a block, when this node has one.
Sourcefn stored_block_filter(
&self,
_block_hash: &Hash,
) -> Result<Option<(BlockHeader, Vec<u8>)>, String>
fn stored_block_filter( &self, _block_hash: &Hash, ) -> Result<Option<(BlockHeader, Vec<u8>)>, String>
Basic block filter for a block, the bytes getblockfilter already builds.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".