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§
Sourcefn write(&self, write_batch: WriteBatch) -> Result<(), ConsensusError>
fn write(&self, write_batch: WriteBatch) -> Result<(), ConsensusError>
Writes blocks, consensus commits and other data to store atomically.
Sourcefn read_blocks(
&self,
refs: &[BlockRef],
) -> Result<Vec<Option<VerifiedBlock>>, ConsensusError>
fn read_blocks( &self, refs: &[BlockRef], ) -> Result<Vec<Option<VerifiedBlock>>, ConsensusError>
Reads blocks for the given refs.
Sourcefn contains_blocks(
&self,
refs: &[BlockRef],
) -> Result<Vec<bool>, ConsensusError>
fn contains_blocks( &self, refs: &[BlockRef], ) -> Result<Vec<bool>, ConsensusError>
Checks if blocks exist in the store.
Reads blocks for an authority, from start_round.
Sourcefn read_last_commit(&self) -> Result<Option<TrustedCommit>, ConsensusError>
fn read_last_commit(&self) -> Result<Option<TrustedCommit>, ConsensusError>
Reads the last commit.
Sourcefn scan_commits(
&self,
range: CommitRange,
) -> Result<Vec<TrustedCommit>, ConsensusError>
fn scan_commits( &self, range: CommitRange, ) -> Result<Vec<TrustedCommit>, ConsensusError>
Reads all commits from start (inclusive) until end (inclusive).
Sourcefn read_commit_votes(
&self,
commit_index: CommitIndex,
) -> Result<Vec<BlockRef>, ConsensusError>
fn read_commit_votes( &self, commit_index: CommitIndex, ) -> Result<Vec<BlockRef>, ConsensusError>
Reads all blocks voting on a particular commit.
Sourcefn read_last_commit_info(
&self,
) -> Result<Option<(CommitRef, CommitInfo)>, ConsensusError>
fn read_last_commit_info( &self, ) -> Result<Option<(CommitRef, CommitInfo)>, ConsensusError>
Reads the last commit info, written atomically with the last commit.
Sourcefn read_last_finalized_commit(
&self,
) -> Result<Option<CommitRef>, ConsensusError>
fn read_last_finalized_commit( &self, ) -> Result<Option<CommitRef>, ConsensusError>
Reads the last finalized commit.