Skip to main content

DurableBlockReader

Trait DurableBlockReader 

Source
pub trait DurableBlockReader: StageCheckpointReader + BlockHashReader {
    // Provided method
    fn last_durable_block_num_hash(&self) -> Result<NumHash, ProviderError> { ... }
}
Expand description

Reads the last block that survives a restart.

Provided Methods§

Source

fn last_durable_block_num_hash(&self) -> Result<NumHash, ProviderError>

Returns the number and hash of the last block that is still canonical in the database after a restart.

This can be behind BlockNumReader::last_block_number: static files are written before the database transaction that commits the same blocks, and blocks above the partial state/trie frontier of the Finish stage checkpoint are unwound on startup. Returns genesis if there is no Finish checkpoint.

The hash is the database’s block at that height, never an in-memory canonical block, so it identifies the block a restart keeps even while an in-memory reorg below it is not yet persisted. Providers that serve in-memory blocks override this to read the database.

The block only survives a host crash or power loss when the database syncs every commit to disk. With --db.sync-mode safe-no-sync, it survives a process crash, but MDBX may discard the latest commits when the database is reopened after a host failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, T> DurableBlockReader for &'a T

Source§

impl<T> DurableBlockReader for Arc<T>

Implementors§

Source§

impl<C, N> DurableBlockReader for NoopProvider<C, N>
where C: Send + Sync, N: NodePrimitives,

Source§

impl<N: ProviderNodeTypes> DurableBlockReader for BlockchainProvider<N>

Source§

impl<N: ProviderNodeTypes> DurableBlockReader for ProviderFactory<N>

Source§

impl<T: NodePrimitives, ChainSpec: Send + Sync + 'static> DurableBlockReader for MockEthProvider<T, ChainSpec>

Available on crate features test-utils only.
Source§

impl<TX: DbTx + 'static, N: NodeTypes> DurableBlockReader for DatabaseProvider<TX, N>