consensus_core::storage

Trait Store

Source
pub trait Store: Send + Sync {
    // Required methods
    fn write(&self, write_batch: WriteBatch) -> Result<(), ConsensusError>;
    fn read_blocks(
        &self,
        refs: &[BlockRef],
    ) -> Result<Vec<Option<VerifiedBlock>>, ConsensusError>;
    fn contains_blocks(
        &self,
        refs: &[BlockRef],
    ) -> Result<Vec<bool>, ConsensusError>;
    fn scan_blocks_by_author(
        &self,
        authority: AuthorityIndex,
        start_round: Round,
    ) -> Result<Vec<VerifiedBlock>, ConsensusError>;
    fn scan_last_blocks_by_author(
        &self,
        author: AuthorityIndex,
        num_of_rounds: u64,
        before_round: Option<Round>,
    ) -> Result<Vec<VerifiedBlock>, ConsensusError>;
    fn read_last_commit(&self) -> Result<Option<TrustedCommit>, ConsensusError>;
    fn scan_commits(
        &self,
        range: CommitRange,
    ) -> Result<Vec<TrustedCommit>, ConsensusError>;
    fn read_commit_votes(
        &self,
        commit_index: CommitIndex,
    ) -> Result<Vec<BlockRef>, ConsensusError>;
    fn read_last_commit_info(
        &self,
    ) -> Result<Option<(CommitRef, CommitInfo)>, ConsensusError>;
    fn read_last_finalized_commit(
        &self,
    ) -> Result<Option<CommitRef>, ConsensusError>;
    fn scan_finalized_commits(
        &self,
        range: CommitRange,
    ) -> Result<Vec<(CommitRef, BTreeMap<BlockRef, Vec<TransactionIndex>>)>, ConsensusError>;
}
Expand description

A common interface for consensus storage.

Required Methods§

Source

fn write(&self, write_batch: WriteBatch) -> Result<(), ConsensusError>

Writes blocks, consensus commits and other data to store atomically.

Source

fn read_blocks( &self, refs: &[BlockRef], ) -> Result<Vec<Option<VerifiedBlock>>, ConsensusError>

Reads blocks for the given refs.

Source

fn contains_blocks( &self, refs: &[BlockRef], ) -> Result<Vec<bool>, ConsensusError>

Checks if blocks exist in the store.

Source

fn scan_blocks_by_author( &self, authority: AuthorityIndex, start_round: Round, ) -> Result<Vec<VerifiedBlock>, ConsensusError>

Reads blocks for an authority, from start_round.

Source

fn scan_last_blocks_by_author( &self, author: AuthorityIndex, num_of_rounds: u64, before_round: Option<Round>, ) -> Result<Vec<VerifiedBlock>, ConsensusError>

Source

fn read_last_commit(&self) -> Result<Option<TrustedCommit>, ConsensusError>

Reads the last commit.

Source

fn scan_commits( &self, range: CommitRange, ) -> Result<Vec<TrustedCommit>, ConsensusError>

Reads all commits from start (inclusive) until end (inclusive).

Source

fn read_commit_votes( &self, commit_index: CommitIndex, ) -> Result<Vec<BlockRef>, ConsensusError>

Reads all blocks voting on a particular commit.

Source

fn read_last_commit_info( &self, ) -> Result<Option<(CommitRef, CommitInfo)>, ConsensusError>

Reads the last commit info, written atomically with the last commit.

Source

fn read_last_finalized_commit( &self, ) -> Result<Option<CommitRef>, ConsensusError>

Reads the last finalized commit.

Source

fn scan_finalized_commits( &self, range: CommitRange, ) -> Result<Vec<(CommitRef, BTreeMap<BlockRef, Vec<TransactionIndex>>)>, ConsensusError>

Implementors§