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>

source

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.

source

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>>

source

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.

source

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>

source

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.

source

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>>

source

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.

source

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>

source

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>
where B: Backend + Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Committer for SqlMerkleState<InTransactionPostgresBackend<'a>>

§

type StateChange = StateChange

Defines the type of change to apply
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

impl<'a> Committer for SqlMerkleState<InTransactionSqliteBackend<'a>>

§

type StateChange = StateChange

Defines the type of change to apply
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

impl Committer for SqlMerkleState<PostgresBackend>

§

type StateChange = StateChange

Defines the type of change to apply
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

impl Committer for SqlMerkleState<SqliteBackend>

§

type StateChange = StateChange

Defines the type of change to apply
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

impl<'a> DryRunCommitter for SqlMerkleState<InTransactionPostgresBackend<'a>>

§

type StateChange = StateChange

Defines the type of change to use for the prediction.
source§

fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more
source§

impl<'a> DryRunCommitter for SqlMerkleState<InTransactionSqliteBackend<'a>>

§

type StateChange = StateChange

Defines the type of change to use for the prediction.
source§

fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more
source§

impl DryRunCommitter for SqlMerkleState<PostgresBackend>

§

type StateChange = StateChange

Defines the type of change to use for the prediction.
source§

fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more
source§

impl DryRunCommitter for SqlMerkleState<SqliteBackend>

§

type StateChange = StateChange

Defines the type of change to use for the prediction.
source§

fn dry_run_commit( &self, state_id: &Self::StateId, state_changes: &[Self::StateChange] ) -> Result<Self::StateId, StateError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more
source§

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>

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>

source§

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>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StatePruneError>

Prune keys from state for a given set of state IDs. Read more
source§

impl Prune for SqlMerkleState<SqliteBackend>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StatePruneError>

Prune keys from state for a given set of state IDs. Read more
source§

impl<'a> Pruner for SqlMerkleState<InTransactionPostgresBackend<'a>>

source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StateError>

Prune keys from state for a given set of state IDs. Read more
source§

impl<'a> Pruner for SqlMerkleState<InTransactionSqliteBackend<'a>>

source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StateError>

Prune keys from state for a given set of state IDs. Read more
source§

impl Pruner for SqlMerkleState<PostgresBackend>

source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StateError>

Prune keys from state for a given set of state IDs. Read more
source§

impl Pruner for SqlMerkleState<SqliteBackend>

source§

fn prune( &self, state_ids: Vec<Self::StateId> ) -> Result<Vec<Self::Key>, StateError>

Prune keys from state for a given set of state IDs. Read more
source§

impl Read for SqlMerkleState<PostgresBackend>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn clone_box( &self ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>

source§

impl Read for SqlMerkleState<SqliteBackend>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateReadError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn clone_box( &self ) -> Box<dyn Read<StateId = Self::StateId, Key = Self::Key, Value = Self::Value>>

source§

impl<'a> Reader for SqlMerkleState<InTransactionPostgresBackend<'a>>

§

type Filter = str

The filter used for the iterating over state values.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn filter_iter( &self, state_id: &Self::StateId, filter: Option<&Self::Filter> ) -> ValueIterResult<ValueIter<(Self::Key, Self::Value)>>

Returns an iterator over the values of state. Read more
source§

impl<'a> Reader for SqlMerkleState<InTransactionSqliteBackend<'a>>

§

type Filter = str

The filter used for the iterating over state values.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn filter_iter( &self, state_id: &Self::StateId, filter: Option<&Self::Filter> ) -> ValueIterResult<ValueIter<(Self::Key, Self::Value)>>

Returns an iterator over the values of state. Read more
source§

impl Reader for SqlMerkleState<PostgresBackend>

§

type Filter = str

The filter used for the iterating over state values.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn filter_iter( &self, state_id: &Self::StateId, filter: Option<&Self::Filter> ) -> ValueIterResult<ValueIter<(Self::Key, Self::Value)>>

Returns an iterator over the values of state. Read more
source§

impl Reader for SqlMerkleState<SqliteBackend>

§

type Filter = str

The filter used for the iterating over state values.
source§

fn get( &self, state_id: &Self::StateId, keys: &[Self::Key] ) -> Result<HashMap<Self::Key, Self::Value>, StateError>

At a given StateId, attempt to retrieve the given slice of keys. Read more
source§

fn filter_iter( &self, state_id: &Self::StateId, filter: Option<&Self::Filter> ) -> ValueIterResult<ValueIter<(Self::Key, Self::Value)>>

Returns an iterator over the values of state. Read more
source§

impl<B: Backend> State for SqlMerkleState<B>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

impl Write for SqlMerkleState<PostgresBackend>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

fn compute_state_id( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more
source§

impl Write for SqlMerkleState<SqliteBackend>

§

type StateId = String

A reference to a checkpoint in state. It could be a merkle hash for a merkle database.
§

type Key = String

The Key that is being stored in state.
§

type Value = Vec<u8>

The Value that is being stored in state.
source§

fn commit( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>

Given a StateId and a slice of StateChange values, persist the state changes and return the resulting next StateId value. Read more
source§

fn compute_state_id( &self, state_id: &Self::StateId, state_changes: &[StateChange] ) -> Result<Self::StateId, StateWriteError>

Given a StateId and a slice of StateChange values, compute the next StateId value. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<'a, T> DefaultFeatures<'a> for T
where T: 'a + Send + Sync + Clone,

§

fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> Self::Expression
where Self: AsExpression<T> + Sized,

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression

Convert &self to an expression for Diesel’s query builder. Read more
§

impl<'a, T> NonSyncFeatures<'a> for T
where T: 'a + Clone,

§

fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
§

impl<T> SafeBorrow<T> for T
where T: ?Sized,

§

fn borrow_replacement(ptr: &T) -> &T

Given 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more