Trait massa_db_exports::MassaDBController

source ·
pub trait MassaDBController: Send + Sync + Debug {
Show 17 methods // Required methods fn backup_db(&self, slot: Slot) -> PathBuf; fn get_change_id(&self) -> Result<Slot, ModelsError>; fn set_initial_change_id(&self, change_id: Slot); fn write_batch( &mut self, batch: DBBatch, versioning_batch: DBBatch, change_id: Option<Slot>, ); fn put_or_update_entry_value( &self, batch: &mut DBBatch, key: Vec<u8>, value: &[u8], ); fn delete_key(&self, batch: &mut DBBatch, key: Vec<u8>); fn delete_prefix( &mut self, prefix: &str, handle_str: &str, change_id: Option<Slot>, ); fn reset(&mut self, slot: Slot); fn get_cf( &self, handle_cf: &str, key: Key, ) -> Result<Option<Value>, MassaDBError>; fn multi_get_cf( &self, query: Vec<(&str, Key)>, ) -> Vec<Result<Option<Value>, MassaDBError>>; fn iterator_cf( &self, handle_cf: &str, mode: MassaIteratorMode<'_>, ) -> Box<dyn Iterator<Item = (Key, Value)> + '_>; fn prefix_iterator_cf( &self, handle_cf: &str, prefix: &[u8], ) -> Box<dyn Iterator<Item = (Key, Value)> + '_>; fn get_xof_db_hash(&self) -> HashXof<HASH_XOF_SIZE_BYTES>; fn flush(&self) -> Result<(), MassaDBError>; fn write_batch_bootstrap_client( &mut self, stream_changes: StreamBatch<Slot>, stream_changes_versioning: StreamBatch<Slot>, ) -> Result<(StreamingStep<Key>, StreamingStep<Key>), MassaDBError>; fn get_batch_to_stream( &self, last_state_step: &StreamingStep<Vec<u8>>, last_change_id: Option<Slot>, ) -> Result<StreamBatch<Slot>, MassaDBError>; fn get_versioning_batch_to_stream( &self, last_versioning_step: &StreamingStep<Vec<u8>>, last_change_id: Option<Slot>, ) -> Result<StreamBatch<Slot>, MassaDBError>;
}
Expand description

Controller trait for the MassaDB TODO: MOCK IT WITH MOCKALL. HAVING LIFETIMES ERRORS WITH AUTO MOCK

Required Methods§

source

fn backup_db(&self, slot: Slot) -> PathBuf

Creates a new hard copy of the DB, for the given slot

source

fn get_change_id(&self) -> Result<Slot, ModelsError>

Get the current change_id attached to the database.

source

fn set_initial_change_id(&self, change_id: Slot)

Set the initial change_id. This function should only be called at startup/reset, as it does not batch this set with other changes.

source

fn write_batch( &mut self, batch: DBBatch, versioning_batch: DBBatch, change_id: Option<Slot>, )

Writes the batch to the DB

source

fn put_or_update_entry_value( &self, batch: &mut DBBatch, key: Vec<u8>, value: &[u8], )

Utility function to put / update a key & value in the batch

source

fn delete_key(&self, batch: &mut DBBatch, key: Vec<u8>)

Utility function to delete a key & value in the batch

source

fn delete_prefix( &mut self, prefix: &str, handle_str: &str, change_id: Option<Slot>, )

Utility function to delete all keys in a prefix

source

fn reset(&mut self, slot: Slot)

Reset the database, and attach it to the given slot.

source

fn get_cf( &self, handle_cf: &str, key: Key, ) -> Result<Option<Value>, MassaDBError>

Exposes RocksDB’s “get_cf” function

source

fn multi_get_cf( &self, query: Vec<(&str, Key)>, ) -> Vec<Result<Option<Value>, MassaDBError>>

Exposes RocksDB’s “multi_get_cf” function

source

fn iterator_cf( &self, handle_cf: &str, mode: MassaIteratorMode<'_>, ) -> Box<dyn Iterator<Item = (Key, Value)> + '_>

Exposes RocksDB’s “iterator_cf” function

source

fn prefix_iterator_cf( &self, handle_cf: &str, prefix: &[u8], ) -> Box<dyn Iterator<Item = (Key, Value)> + '_>

Exposes RocksDB’s “prefix_iterator_cf” function

source

fn get_xof_db_hash(&self) -> HashXof<HASH_XOF_SIZE_BYTES>

Get the current extended state hash of the database

source

fn flush(&self) -> Result<(), MassaDBError>

Flushes the underlying db.

source

fn write_batch_bootstrap_client( &mut self, stream_changes: StreamBatch<Slot>, stream_changes_versioning: StreamBatch<Slot>, ) -> Result<(StreamingStep<Key>, StreamingStep<Key>), MassaDBError>

Write a stream_batch of database entries received from a bootstrap server

source

fn get_batch_to_stream( &self, last_state_step: &StreamingStep<Vec<u8>>, last_change_id: Option<Slot>, ) -> Result<StreamBatch<Slot>, MassaDBError>

Used for bootstrap servers (get a new batch of data from STATE_CF to stream to the client)

Returns a StreamBatch

source

fn get_versioning_batch_to_stream( &self, last_versioning_step: &StreamingStep<Vec<u8>>, last_change_id: Option<Slot>, ) -> Result<StreamBatch<Slot>, MassaDBError>

Used for bootstrap servers (get a new batch of data from VERSIONING_CF to stream to the client)

Returns a StreamBatch

Implementors§