pub struct SqlMerkleState<B: Backend> { /* private fields */ }
Expand description
SqlMerkleState provides a merkle-radix implementation over a SQL database.
Databases are implemented using a Backend to provide connections. Note that the database must have the correct set of tables applied via migrations before this struct may be usable.
Implementations§
source§impl SqlMerkleState<PostgresBackend>
impl SqlMerkleState<PostgresBackend>
sourcepub fn delete_tree(self) -> Result<(), InternalError>
pub fn delete_tree(self) -> Result<(), InternalError>
Deletes the complete tree
After calling this method, no data associated with the tree name will remain in the database.
sourcepub fn remove_pruned_entries(&self) -> Result<(), InternalError>
pub fn remove_pruned_entries(&self) -> Result<(), InternalError>
Removes all entries that have been marked as pruned.
After calling this method, any records that have been marked as pruned will have been deleted from the database.
source§impl<'a> SqlMerkleState<InTransactionPostgresBackend<'a>>
impl<'a> SqlMerkleState<InTransactionPostgresBackend<'a>>
sourcepub fn delete_tree(self) -> Result<(), InternalError>
pub fn delete_tree(self) -> Result<(), InternalError>
Deletes the complete tree
After calling this method, no data associated with the tree name will remain in the database.
sourcepub fn remove_pruned_entries(&self) -> Result<(), InternalError>
pub fn remove_pruned_entries(&self) -> Result<(), InternalError>
Removes all entries that have been marked as pruned.
After calling this method, any records that have been marked as pruned will have been deleted from the database.
source§impl SqlMerkleState<SqliteBackend>
impl SqlMerkleState<SqliteBackend>
sourcepub fn delete_tree(self) -> Result<(), InternalError>
pub fn delete_tree(self) -> Result<(), InternalError>
Deletes the complete tree
After calling this method, no data associated with the tree name will remain in the database.
sourcepub fn remove_pruned_entries(&self) -> Result<(), InternalError>
pub fn remove_pruned_entries(&self) -> Result<(), InternalError>
Removes all entries that have been marked as pruned.
After calling this method, any records that have been marked as pruned will have been deleted from the database.
source§impl<'a> SqlMerkleState<InTransactionSqliteBackend<'a>>
impl<'a> SqlMerkleState<InTransactionSqliteBackend<'a>>
sourcepub fn delete_tree(self) -> Result<(), InternalError>
pub fn delete_tree(self) -> Result<(), InternalError>
Deletes the complete tree
After calling this method, no data associated with the tree name will remain in the database.
sourcepub fn remove_pruned_entries(&self) -> Result<(), InternalError>
pub fn remove_pruned_entries(&self) -> Result<(), InternalError>
Removes all entries that have been marked as pruned.
After calling this method, any records that have been marked as pruned will have been deleted from the database.
source§impl<B: Backend> SqlMerkleState<B>
impl<B: Backend> SqlMerkleState<B>
sourcepub fn initial_state_root_hash(&self) -> Result<String, InternalError>
pub fn initial_state_root_hash(&self) -> Result<String, InternalError>
Returns the initial state root.
This value is the state root that applies to a empty merkle radix tree.
Trait Implementations§
source§impl<B> Clone for SqlMerkleState<B>
impl<B> Clone for SqlMerkleState<B>
source§impl<'a> Committer for SqlMerkleState<InTransactionPostgresBackend<'a>>
impl<'a> Committer for SqlMerkleState<InTransactionPostgresBackend<'a>>
§type StateChange = StateChange
type StateChange = StateChange
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
StateId
and a slice of StateChange
values, persist the state changes and return
the resulting next StateId
value. Read moresource§impl<'a> Committer for SqlMerkleState<InTransactionSqliteBackend<'a>>
impl<'a> Committer for SqlMerkleState<InTransactionSqliteBackend<'a>>
§type StateChange = StateChange
type StateChange = StateChange
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
StateId
and a slice of StateChange
values, persist the state changes and return
the resulting next StateId
value. Read moresource§impl Committer for SqlMerkleState<PostgresBackend>
impl Committer for SqlMerkleState<PostgresBackend>
§type StateChange = StateChange
type StateChange = StateChange
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
StateId
and a slice of StateChange
values, persist the state changes and return
the resulting next StateId
value. Read moresource§impl Committer for SqlMerkleState<SqliteBackend>
impl Committer for SqlMerkleState<SqliteBackend>
§type StateChange = StateChange
type StateChange = StateChange
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
StateId
and a slice of StateChange
values, persist the state changes and return
the resulting next StateId
value. Read moresource§impl<'a> DryRunCommitter for SqlMerkleState<InTransactionPostgresBackend<'a>>
impl<'a> DryRunCommitter for SqlMerkleState<InTransactionPostgresBackend<'a>>
§type StateChange = StateChange
type StateChange = StateChange
source§fn dry_run_commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
source§impl<'a> DryRunCommitter for SqlMerkleState<InTransactionSqliteBackend<'a>>
impl<'a> DryRunCommitter for SqlMerkleState<InTransactionSqliteBackend<'a>>
§type StateChange = StateChange
type StateChange = StateChange
source§fn dry_run_commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
source§impl DryRunCommitter for SqlMerkleState<PostgresBackend>
impl DryRunCommitter for SqlMerkleState<PostgresBackend>
§type StateChange = StateChange
type StateChange = StateChange
source§fn dry_run_commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
source§impl DryRunCommitter for SqlMerkleState<SqliteBackend>
impl DryRunCommitter for SqlMerkleState<SqliteBackend>
§type StateChange = StateChange
type StateChange = StateChange
source§fn dry_run_commit(
&self,
state_id: &Self::StateId,
state_changes: &[Self::StateChange]
) -> Result<Self::StateId, StateError>
fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>
source§impl MerkleRadixLeafReader for SqlMerkleState<PostgresBackend>
impl MerkleRadixLeafReader for SqlMerkleState<PostgresBackend>
source§fn leaves(
&self,
state_id: &Self::StateId,
subtree: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<(Self::Key, Self::Value), MerkleRadixLeafReadError>>>, MerkleRadixLeafReadError>
fn leaves( &self, state_id: &Self::StateId, subtree: Option<&str> ) -> Result<Box<dyn Iterator<Item = Result<(Self::Key, Self::Value), MerkleRadixLeafReadError>>>, MerkleRadixLeafReadError>
Returns an iterator over the leaves of a merkle radix tree. By providing an optional address prefix, the caller can limit the iteration over the leaves in a specific subtree.
source§impl MerkleRadixLeafReader for SqlMerkleState<SqliteBackend>
impl MerkleRadixLeafReader for SqlMerkleState<SqliteBackend>
source§fn leaves(
&self,
state_id: &Self::StateId,
subtree: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<(Self::Key, Self::Value), MerkleRadixLeafReadError>>>, MerkleRadixLeafReadError>
fn leaves( &self, state_id: &Self::StateId, subtree: Option<&str> ) -> Result<Box<dyn Iterator<Item = Result<(Self::Key, Self::Value), MerkleRadixLeafReadError>>>, MerkleRadixLeafReadError>
Returns an iterator over the leaves of a merkle radix tree. By providing an optional address prefix, the caller can limit the iteration over the leaves in a specific subtree.
source§impl Prune for SqlMerkleState<PostgresBackend>
impl Prune for SqlMerkleState<PostgresBackend>
source§impl Prune for SqlMerkleState<SqliteBackend>
impl Prune for SqlMerkleState<SqliteBackend>
source§impl<'a> Pruner for SqlMerkleState<InTransactionPostgresBackend<'a>>
impl<'a> Pruner for SqlMerkleState<InTransactionPostgresBackend<'a>>
source§impl<'a> Pruner for SqlMerkleState<InTransactionSqliteBackend<'a>>
impl<'a> Pruner for SqlMerkleState<InTransactionSqliteBackend<'a>>
source§impl Pruner for SqlMerkleState<PostgresBackend>
impl Pruner for SqlMerkleState<PostgresBackend>
source§impl Pruner for SqlMerkleState<SqliteBackend>
impl Pruner for SqlMerkleState<SqliteBackend>
source§impl Read for SqlMerkleState<PostgresBackend>
impl Read for SqlMerkleState<PostgresBackend>
§type StateId = String
type StateId = String
source§fn get(
&self,
state_id: &Self::StateId,
keys: &[Self::Key]
) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>
fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>
StateId
, attempt to retrieve the given slice of keys. Read morefn clone_box( &self ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>
source§impl Read for SqlMerkleState<SqliteBackend>
impl Read for SqlMerkleState<SqliteBackend>
§type StateId = String
type StateId = String
source§fn get(
&self,
state_id: &Self::StateId,
keys: &[Self::Key]
) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>
fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>
StateId
, attempt to retrieve the given slice of keys. Read morefn clone_box( &self ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>
source§impl<'a> Reader for SqlMerkleState<InTransactionPostgresBackend<'a>>
impl<'a> Reader for SqlMerkleState<InTransactionPostgresBackend<'a>>
source§impl<'a> Reader for SqlMerkleState<InTransactionSqliteBackend<'a>>
impl<'a> Reader for SqlMerkleState<InTransactionSqliteBackend<'a>>
source§impl Reader for SqlMerkleState<PostgresBackend>
impl Reader for SqlMerkleState<PostgresBackend>
source§impl Reader for SqlMerkleState<SqliteBackend>
impl Reader for SqlMerkleState<SqliteBackend>
source§impl<B: Backend> State for SqlMerkleState<B>
impl<B: Backend> State for SqlMerkleState<B>
source§impl Write for SqlMerkleState<PostgresBackend>
impl Write for SqlMerkleState<PostgresBackend>
§type StateId = String
type StateId = String
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[StateChange]
) -> Result<Self::StateId, StateWriteError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>
StateId
and a slice of StateChange
values, persist the
state changes and return the resulting next StateId
value. Read moresource§fn compute_state_id(
&self,
state_id: &Self::StateId,
state_changes: &[StateChange]
) -> Result<Self::StateId, StateWriteError>
fn compute_state_id( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>
source§impl Write for SqlMerkleState<SqliteBackend>
impl Write for SqlMerkleState<SqliteBackend>
§type StateId = String
type StateId = String
source§fn commit(
&self,
state_id: &Self::StateId,
state_changes: &[StateChange]
) -> Result<Self::StateId, StateWriteError>
fn commit( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>
StateId
and a slice of StateChange
values, persist the
state changes and return the resulting next StateId
value. Read moresource§fn compute_state_id(
&self,
state_id: &Self::StateId,
state_changes: &[StateChange]
) -> Result<Self::StateId, StateWriteError>
fn compute_state_id( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>
Auto Trait Implementations§
impl<B> RefUnwindSafe for SqlMerkleState<B>where
B: RefUnwindSafe,
impl<B> Send for SqlMerkleState<B>where
B: Send,
impl<B> Sync for SqlMerkleState<B>where
B: Sync,
impl<B> Unpin for SqlMerkleState<B>where
B: Unpin,
impl<B> UnwindSafe for SqlMerkleState<B>where
B: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<'a, T> DefaultFeatures<'a> for T
impl<'a, T> DefaultFeatures<'a> for T
§fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>
Box
behind a trait object of this trait.§fn self_address_mut(&mut self) -> *mut ()
fn self_address_mut(&mut self) -> *mut ()
self
. Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
&self
to an expression for Diesel’s query builder. Read more§impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
§fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>
Box
behind a trait object of this trait.§fn self_address_mut(&mut self) -> *mut ()
fn self_address_mut(&mut self) -> *mut ()
self
. Read more§impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
§fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
ptr
, which was obtained from a prior call to Self::borrow()
,
return a value with the same nominal lifetime which is guaranteed to
survive mutations to Self
. Read more