Trait lightning_block_sync::Cache [−][src]
pub trait Cache { fn look_up(&self, block_hash: &BlockHash) -> Option<&ValidatedBlockHeader>; fn block_connected(
&mut self,
block_hash: BlockHash,
block_header: ValidatedBlockHeader
); fn block_disconnected(
&mut self,
block_hash: &BlockHash
) -> Option<ValidatedBlockHeader>; }
Expand description
The Cache
trait defines behavior for managing a block header cache, where block headers are
keyed by block hash.
Used by ChainNotifier
to store headers along the best chain, which is important for ensuring
that blocks can be disconnected if they are no longer accessible from a block source (e.g., if
the block source does not store stale forks indefinitely).
Implementations may define how long to retain headers such that it’s unlikely they will ever be needed to disconnect a block. In cases where block sources provide access to headers on stale forks reliably, caches may be entirely unnecessary.
Required methods
fn look_up(&self, block_hash: &BlockHash) -> Option<&ValidatedBlockHeader>
[src]
fn look_up(&self, block_hash: &BlockHash) -> Option<&ValidatedBlockHeader>
[src]Retrieves the block header keyed by the given block hash.
fn block_connected(
&mut self,
block_hash: BlockHash,
block_header: ValidatedBlockHeader
)
[src]
fn block_connected(
&mut self,
block_hash: BlockHash,
block_header: ValidatedBlockHeader
)
[src]Called when a block has been connected to the best chain to ensure it is available to be disconnected later if needed.
fn block_disconnected(
&mut self,
block_hash: &BlockHash
) -> Option<ValidatedBlockHeader>
[src]
fn block_disconnected(
&mut self,
block_hash: &BlockHash
) -> Option<ValidatedBlockHeader>
[src]Called when a block has been disconnected from the best chain. Once disconnected, a block’s header is no longer needed and thus can be removed.