pub trait DbReader: Send + Sync {
Show 25 methods // Required methods fn get_epoch_ending_ledger_infos( &self, start_epoch: u64, end_epoch: u64 ) -> Result<EpochChangeProof>; fn get_transactions( &self, start_version: Version, batch_size: u64, ledger_version: Version, fetch_events: bool ) -> Result<TransactionListWithProof>; fn get_events( &self, event_key: &EventKey, start: u64, order: Order, limit: u64 ) -> Result<Vec<(u64, ContractEvent)>>; fn get_events_with_proofs( &self, event_key: &EventKey, start: u64, order: Order, limit: u64, known_version: Option<u64> ) -> Result<Vec<EventWithProof>>; fn get_block_timestamp(&self, version: u64) -> Result<u64>; fn get_event_by_version_with_proof( &self, event_key: &EventKey, event_version: u64, proof_version: u64 ) -> Result<EventByVersionWithProof>; fn get_latest_account_state( &self, address: AccountAddress ) -> Result<Option<AccountStateBlob>>; fn get_latest_ledger_info(&self) -> Result<LedgerInfoWithSignatures>; fn get_startup_info(&self) -> Result<Option<StartupInfo>>; fn get_account_transaction( &self, address: AccountAddress, seq_num: u64, include_events: bool, ledger_version: Version ) -> Result<Option<TransactionWithProof>>; fn get_account_transactions( &self, address: AccountAddress, seq_num: u64, limit: u64, include_events: bool, ledger_version: Version ) -> Result<AccountTransactionsWithProof>; fn get_state_proof_with_ledger_info( &self, known_version: u64, ledger_info: LedgerInfoWithSignatures ) -> Result<StateProof>; fn get_state_proof(&self, known_version: u64) -> Result<StateProof>; fn get_account_state_with_proof( &self, address: AccountAddress, version: Version, ledger_version: Version ) -> Result<AccountStateWithProof>; fn get_account_state_with_proof_by_version( &self, address: AccountAddress, version: Version ) -> Result<(Option<AccountStateBlob>, SparseMerkleProof<AccountStateBlob>)>; fn get_latest_state_root(&self) -> Result<(Version, HashValue)>; fn get_latest_tree_state(&self) -> Result<TreeState>; fn get_epoch_ending_ledger_info( &self, known_version: u64 ) -> Result<LedgerInfoWithSignatures>; // Provided methods fn get_last_version_before_timestamp( &self, _timestamp: u64, _ledger_version: Version ) -> Result<Version> { ... } fn get_latest_version(&self) -> Result<Version> { ... } fn get_latest_commit_metadata(&self) -> Result<(Version, u64)> { ... } fn get_latest_transaction_info_option( &self ) -> Result<Option<(Version, TransactionInfo)>> { ... } fn get_accumulator_root_hash(&self, _version: Version) -> Result<HashValue> { ... } fn get_accumulator_consistency_proof( &self, _client_known_version: Option<Version>, _ledger_version: Version ) -> Result<AccumulatorConsistencyProof> { ... } fn get_accumulator_summary( &self, ledger_version: Version ) -> Result<TransactionAccumulatorSummary> { ... }
}
Expand description

Trait that is implemented by a DB that supports certain public (to client) read APIs expected of a Diem DB

Required Methods§

source

fn get_epoch_ending_ledger_infos( &self, start_epoch: u64, end_epoch: u64 ) -> Result<EpochChangeProof>

source

fn get_transactions( &self, start_version: Version, batch_size: u64, ledger_version: Version, fetch_events: bool ) -> Result<TransactionListWithProof>

source

fn get_events( &self, event_key: &EventKey, start: u64, order: Order, limit: u64 ) -> Result<Vec<(u64, ContractEvent)>>

Returns events by given event key

source

fn get_events_with_proofs( &self, event_key: &EventKey, start: u64, order: Order, limit: u64, known_version: Option<u64> ) -> Result<Vec<EventWithProof>>

Returns events by given event key

source

fn get_block_timestamp(&self, version: u64) -> Result<u64>

source

fn get_event_by_version_with_proof( &self, event_key: &EventKey, event_version: u64, proof_version: u64 ) -> Result<EventByVersionWithProof>

Returns the [NewBlockEvent] for the block containing the requested version and proof that the block actually contains the version.

source

fn get_latest_account_state( &self, address: AccountAddress ) -> Result<Option<AccountStateBlob>>

source

fn get_latest_ledger_info(&self) -> Result<LedgerInfoWithSignatures>

Returns the latest ledger info.

source

fn get_startup_info(&self) -> Result<Option<StartupInfo>>

Gets information needed from storage during the main node startup. See DiemDB::get_startup_info.

source

fn get_account_transaction( &self, address: AccountAddress, seq_num: u64, include_events: bool, ledger_version: Version ) -> Result<Option<TransactionWithProof>>

Returns a transaction that is the seq_num-th one associated with the given account. If the transaction with given seq_num doesn’t exist, returns None.

source

fn get_account_transactions( &self, address: AccountAddress, seq_num: u64, limit: u64, include_events: bool, ledger_version: Version ) -> Result<AccountTransactionsWithProof>

Returns the list of transactions sent by an account with address starting at sequence number seq_num. Will return no more than limit transactions. Will ignore transactions with txn.version > ledger_version. Optionally fetch events for each transaction when fetch_events is true.

source

fn get_state_proof_with_ledger_info( &self, known_version: u64, ledger_info: LedgerInfoWithSignatures ) -> Result<StateProof>

Returns proof of new state for a given ledger info with signatures relative to version known to client

source

fn get_state_proof(&self, known_version: u64) -> Result<StateProof>

Returns proof of new state relative to version known to client

source

fn get_account_state_with_proof( &self, address: AccountAddress, version: Version, ledger_version: Version ) -> Result<AccountStateWithProof>

Returns the account state corresponding to the given version and account address with proof based on ledger_version

source

fn get_account_state_with_proof_by_version( &self, address: AccountAddress, version: Version ) -> Result<(Option<AccountStateBlob>, SparseMerkleProof<AccountStateBlob>)>

source

fn get_latest_state_root(&self) -> Result<(Version, HashValue)>

source

fn get_latest_tree_state(&self) -> Result<TreeState>

Gets the latest TreeState no matter if db has been bootstrapped. Used by the Db-bootstrapper.

source

fn get_epoch_ending_ledger_info( &self, known_version: u64 ) -> Result<LedgerInfoWithSignatures>

Get the ledger info of the epoch that known_version belongs to.

Provided Methods§

source

fn get_last_version_before_timestamp( &self, _timestamp: u64, _ledger_version: Version ) -> Result<Version>

Gets the version of the last transaction committed before timestamp, a commited block at or after the required timestamp must exist (otherwise it’s possible the next block committed as a timestamp smaller than the one in the request).

source

fn get_latest_version(&self) -> Result<Version>

Returns the latest ledger info.

source

fn get_latest_commit_metadata(&self) -> Result<(Version, u64)>

Returns the latest version and committed block timestamp

source

fn get_latest_transaction_info_option( &self ) -> Result<Option<(Version, TransactionInfo)>>

Gets the latest transaction info. N.B. Unlike get_startup_info(), even if the db is not bootstrapped, this can return Some – those from a db-restore run.

source

fn get_accumulator_root_hash(&self, _version: Version) -> Result<HashValue>

Gets the transaction accumulator root hash at specified version. Caller must guarantee the version is not greater than the latest version.

source

fn get_accumulator_consistency_proof( &self, _client_known_version: Option<Version>, _ledger_version: Version ) -> Result<AccumulatorConsistencyProof>

Gets an [AccumulatorConsistencyProof] starting from client_known_version (or pre-genesis if None) until ledger_version.

In other words, if the client has an accumulator summary for client_known_version, they can use the result from this API to efficiently extend their accumulator to ledger_version and prove that the new accumulator is consistent with their old accumulator. By consistent, we mean that by appending the actual ledger_version - client_known_version transactions to the old accumulator summary you get the new accumulator summary.

If the client is starting up for the first time and has no accumulator summary yet, they can call this with client_known_version=None, i.e., pre-genesis, to get the complete accumulator summary up to ledger_version.

source

fn get_accumulator_summary( &self, ledger_version: Version ) -> Result<TransactionAccumulatorSummary>

A convenience function for building a [TransactionAccumulatorSummary] at the given ledger_version.

Note: this is roughly equivalent to calling DbReader::get_accumulator_consistency_proof(None, ledger_version).

Trait Implementations§

source§

impl MoveStorage for &dyn DbReader

source§

fn batch_fetch_resources( &self, access_paths: Vec<AccessPath> ) -> Result<Vec<Vec<u8>>>

Returns a vector of Move resources as serialized byte array Order of resources returned matches the order of access_path
source§

fn batch_fetch_resources_by_version( &self, access_paths: Vec<AccessPath>, version: Version ) -> Result<Vec<Vec<u8>>>

Returns a vector of Move resources as serialized byte array from a specified version of the database Order of resources returned matches the order of access_path
source§

fn fetch_synced_version(&self) -> Result<u64>

Get the version on the latest transaction info.

Implementors§