Trait sp_state_machine::backend::Backend [−][src]
A state backend is used to read state data and can have changes committed to it.
The clone operation (if implemented) should be cheap.
Associated Types
type Error: Error
[src]
An error type when fetching data is not possible.
type Transaction: Consolidate + Default + Send
[src]
Storage changes to be applied if committing
type TrieBackendStorage: TrieBackendStorage<H>
[src]
Type of trie backend storage.
Required methods
fn storage(&self, key: &[u8]) -> Result<Option<StorageValue>, Self::Error>
[src]
Get keyed storage or None if there is nothing associated.
fn child_storage(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageValue>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageValue>, Self::Error>
Get keyed child storage or None if there is nothing associated.
fn next_storage_key(
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
Return the next key in storage in lexicographic order or None
if there is no value.
fn next_child_storage_key(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
Return the next key in child storage in lexicographic order or None
if there is no value.
fn for_keys_in_child_storage<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
f: F
)
[src]
&self,
child_info: &ChildInfo,
f: F
)
Retrieve all entries keys of child storage and call f
for each of those keys.
fn for_key_values_with_prefix<F: FnMut(&[u8], &[u8])>(
&self,
prefix: &[u8],
f: F
)
[src]
&self,
prefix: &[u8],
f: F
)
Retrieve all entries keys and values of which start with the given prefix and
call f
for each of those keys.
fn for_child_keys_with_prefix<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
[src]
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
Retrieve all child entries keys which start with the given prefix and
call f
for each of those keys.
fn storage_root<'a>(
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
[src]
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
Calculate the storage root, with given delta over what is already stored in the backend, and produce a “transaction” that can be used to commit. Does not include child storage updates.
fn child_storage_root<'a>(
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
[src]
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
Calculate the child storage root, with given delta over what is already stored in the backend, and produce a “transaction” that can be used to commit. The second argument is true if child storage root equals default storage root.
fn pairs(&self) -> Vec<(StorageKey, StorageValue)>
[src]
Get all key/value pairs into a Vec.
fn register_overlay_stats(&mut self, _stats: &StateMachineStats)
[src]
Register stats from overlay of state machine.
By default nothing is registered.
fn usage_info(&self) -> UsageInfo
[src]
Query backend usage statistics (i/o, memory)
Not all implementations are expected to be able to do this. In the case when they don’t, empty statistics is returned.
Provided methods
fn storage_hash(&self, key: &[u8]) -> Result<Option<H::Out>, Self::Error>
[src]
Get keyed storage value hash or None if there is nothing associated.
fn child_storage_hash(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<H::Out>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<H::Out>, Self::Error>
Get child keyed storage value hash or None if there is nothing associated.
fn exists_storage(&self, key: &[u8]) -> Result<bool, Self::Error>
[src]
true if a key exists in storage.
fn exists_child_storage(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<bool, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<bool, Self::Error>
true if a key exists in child storage.
fn for_keys_with_prefix<F: FnMut(&[u8])>(&self, prefix: &[u8], f: F)
[src]
Retrieve all entries keys which start with the given prefix and
call f
for each of those keys.
fn keys(&self, prefix: &[u8]) -> Vec<StorageKey>
[src]
Get all keys with given prefix
fn child_keys(&self, child_info: &ChildInfo, prefix: &[u8]) -> Vec<StorageKey>
[src]
Get all keys of child storage with given prefix
fn as_trie_backend(
&mut self
) -> Option<&TrieBackend<Self::TrieBackendStorage, H>>
[src]
&mut self
) -> Option<&TrieBackend<Self::TrieBackendStorage, H>>
Try convert into trie backend.
fn full_storage_root<'a>(
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
child_deltas: impl Iterator<Item = (&'a ChildInfo, impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord + Encode,
[src]
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
child_deltas: impl Iterator<Item = (&'a ChildInfo, impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord + Encode,
Calculate the storage root, with given delta over what is already stored in the backend, and produce a “transaction” that can be used to commit. Does include child storage updates.
fn wipe(&self) -> Result<(), Self::Error>
[src]
Wipe the state database.
fn commit(
&self,
_: H::Out,
_: Self::Transaction,
_: StorageCollection,
_: ChildStorageCollection
) -> Result<(), Self::Error>
[src]
&self,
_: H::Out,
_: Self::Transaction,
_: StorageCollection,
_: ChildStorageCollection
) -> Result<(), Self::Error>
Commit given transaction to storage.
fn read_write_count(&self) -> (u32, u32, u32, u32)
[src]
Get the read/write count of the db
fn reset_read_write_count(&self)
[src]
Get the read/write count of the db
fn get_whitelist(&self) -> Vec<TrackedStorageKey>
[src]
Get the whitelist for tracking db reads/writes
fn set_whitelist(&self, _: Vec<TrackedStorageKey>)
[src]
Update the whitelist for tracking db reads/writes
Implementations on Foreign Types
impl<'a, T: Backend<H>, H: Hasher> Backend<H> for &'a T
[src]
type Error = T::Error
type Transaction = T::Transaction
type TrieBackendStorage = T::TrieBackendStorage
fn storage(&self, key: &[u8]) -> Result<Option<StorageKey>, Self::Error>
[src]
fn child_storage(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
fn for_keys_in_child_storage<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
f: F
)
[src]
&self,
child_info: &ChildInfo,
f: F
)
fn next_storage_key(
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
fn next_child_storage_key(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
fn for_keys_with_prefix<F: FnMut(&[u8])>(&self, prefix: &[u8], f: F)
[src]
fn for_child_keys_with_prefix<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
[src]
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
fn storage_root<'b>(
&self,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
[src]
&self,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
fn child_storage_root<'b>(
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
[src]
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
fn pairs(&self) -> Vec<(StorageKey, StorageValue)>
[src]
fn for_key_values_with_prefix<F: FnMut(&[u8], &[u8])>(
&self,
prefix: &[u8],
f: F
)
[src]
&self,
prefix: &[u8],
f: F
)
fn register_overlay_stats(&mut self, _stats: &StateMachineStats)
[src]
fn usage_info(&self) -> UsageInfo
[src]
Implementors
impl<'a, S, H> Backend<H> for ProvingBackend<'a, S, H> where
S: 'a + TrieBackendStorage<H>,
H: 'a + Hasher,
H::Out: Ord + Codec,
[src]
S: 'a + TrieBackendStorage<H>,
H: 'a + Hasher,
H::Out: Ord + Codec,
type Error = String
type Transaction = S::Overlay
type TrieBackendStorage = S
fn storage(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error>
[src]
fn child_storage(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<Vec<u8>>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<Vec<u8>>, Self::Error>
fn for_keys_in_child_storage<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
f: F
)
[src]
&self,
child_info: &ChildInfo,
f: F
)
fn next_storage_key(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error>
[src]
fn next_child_storage_key(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<Vec<u8>>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<Vec<u8>>, Self::Error>
fn for_keys_with_prefix<F: FnMut(&[u8])>(&self, prefix: &[u8], f: F)
[src]
fn for_key_values_with_prefix<F: FnMut(&[u8], &[u8])>(
&self,
prefix: &[u8],
f: F
)
[src]
&self,
prefix: &[u8],
f: F
)
fn for_child_keys_with_prefix<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
[src]
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
fn pairs(&self) -> Vec<(Vec<u8>, Vec<u8>)>
[src]
fn keys(&self, prefix: &[u8]) -> Vec<Vec<u8>>
[src]
fn child_keys(&self, child_info: &ChildInfo, prefix: &[u8]) -> Vec<Vec<u8>>
[src]
fn storage_root<'b>(
&self,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
[src]
&self,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
fn child_storage_root<'b>(
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
[src]
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'b [u8], Option<&'b [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
fn register_overlay_stats(&mut self, _stats: &StateMachineStats)
[src]
fn usage_info(&self) -> UsageInfo
[src]
impl<S: TrieBackendStorage<H>, H: Hasher> Backend<H> for TrieBackend<S, H> where
H::Out: Ord + Codec,
[src]
H::Out: Ord + Codec,
type Error = DefaultError
type Transaction = S::Overlay
type TrieBackendStorage = S
fn storage(&self, key: &[u8]) -> Result<Option<StorageValue>, Self::Error>
[src]
fn child_storage(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageValue>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageValue>, Self::Error>
fn next_storage_key(
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
fn next_child_storage_key(
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
[src]
&self,
child_info: &ChildInfo,
key: &[u8]
) -> Result<Option<StorageKey>, Self::Error>
fn for_keys_with_prefix<F: FnMut(&[u8])>(&self, prefix: &[u8], f: F)
[src]
fn for_key_values_with_prefix<F: FnMut(&[u8], &[u8])>(
&self,
prefix: &[u8],
f: F
)
[src]
&self,
prefix: &[u8],
f: F
)
fn for_keys_in_child_storage<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
f: F
)
[src]
&self,
child_info: &ChildInfo,
f: F
)
fn for_child_keys_with_prefix<F: FnMut(&[u8])>(
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
[src]
&self,
child_info: &ChildInfo,
prefix: &[u8],
f: F
)
fn pairs(&self) -> Vec<(StorageKey, StorageValue)>
[src]
fn keys(&self, prefix: &[u8]) -> Vec<StorageKey>
[src]
fn storage_root<'a>(
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
[src]
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, Self::Transaction) where
H::Out: Ord,
fn child_storage_root<'a>(
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
[src]
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>
) -> (H::Out, bool, Self::Transaction) where
H::Out: Ord,
fn as_trie_backend(
&mut self
) -> Option<&TrieBackend<Self::TrieBackendStorage, H>>
[src]
&mut self
) -> Option<&TrieBackend<Self::TrieBackendStorage, H>>