pub trait Backend<H: Hasher>: Debug {
    type Error: Error;
    type Transaction: Consolidate + Default + Send;
    type TrieBackendStorage: TrieBackendStorage<H, Overlay = Self::Transaction>;
    type RawIter: StorageIterator<H, Backend = Self, Error = Self::Error>;

Show 24 methods fn storage(&self, key: &[u8]) -> Result<Option<StorageValue>, Self::Error>; fn storage_hash(&self, key: &[u8]) -> Result<Option<H::Out>, Self::Error>; fn child_storage(
        &self,
        child_info: &ChildInfo,
        key: &[u8]
    ) -> Result<Option<StorageValue>, Self::Error>; fn child_storage_hash(
        &self,
        child_info: &ChildInfo,
        key: &[u8]
    ) -> Result<Option<H::Out>, Self::Error>; fn next_storage_key(
        &self,
        key: &[u8]
    ) -> Result<Option<StorageKey>, Self::Error>; fn next_child_storage_key(
        &self,
        child_info: &ChildInfo,
        key: &[u8]
    ) -> Result<Option<StorageKey>, Self::Error>; fn storage_root<'a>(
        &self,
        delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
        state_version: StateVersion
    ) -> (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]>)>,
        state_version: StateVersion
    ) -> (H::Out, bool, Self::Transaction)
    where
        H::Out: Ord
; fn raw_iter(&self, args: IterArgs<'_>) -> Result<Self::RawIter, Self::Error>; fn register_overlay_stats(&self, _stats: &StateMachineStats); fn usage_info(&self) -> UsageInfo; fn exists_storage(&self, key: &[u8]) -> Result<bool, Self::Error> { ... } fn exists_child_storage(
        &self,
        child_info: &ChildInfo,
        key: &[u8]
    ) -> Result<bool, Self::Error> { ... } fn pairs<'a>(
        &'a self,
        args: IterArgs<'_>
    ) -> Result<PairsIter<'a, H, Self::RawIter>, Self::Error> { ... } fn keys<'a>(
        &'a self,
        args: IterArgs<'_>
    ) -> Result<KeysIter<'a, H, Self::RawIter>, Self::Error> { ... } 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]>)>)>,
        state_version: StateVersion
    ) -> (H::Out, Self::Transaction)
    where
        H::Out: Ord + Encode
, { ... } fn wipe(&self) -> Result<(), Self::Error> { ... } fn commit(
        &self,
        _: H::Out,
        _: Self::Transaction,
        _: StorageCollection,
        _: ChildStorageCollection
    ) -> Result<(), Self::Error> { ... } fn read_write_count(&self) -> (u32, u32, u32, u32) { ... } fn reset_read_write_count(&self) { ... } fn get_whitelist(&self) -> Vec<TrackedStorageKey> { ... } fn set_whitelist(&self, _: Vec<TrackedStorageKey>) { ... } fn proof_size(&self) -> Option<u32> { ... } fn get_read_and_written_keys(&self) -> Vec<(Vec<u8>, u32, u32, bool)> { ... }
}
Expand description

A state backend is used to read state data and can have changes committed to it.

The clone operation (if implemented) should be cheap.

Required Associated Types§

An error type when fetching data is not possible.

Storage changes to be applied if committing

Type of trie backend storage.

Type of the raw storage iterator.

Required Methods§

Get keyed storage or None if there is nothing associated.

Get keyed storage value hash or None if there is nothing associated.

Get keyed child storage or None if there is nothing associated.

Get child keyed storage value hash or None if there is nothing associated.

Return the next key in storage in lexicographic order or None if there is no value.

Return the next key in child storage in lexicographic order or None if there is no value.

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.

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.

Returns a lifetimeless raw storage iterator.

Register stats from overlay of state machine.

By default nothing is registered.

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§

true if a key exists in storage.

true if a key exists in child storage.

Get an iterator over key/value pairs.

Get an iterator over keys.

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.

Wipe the state database.

Commit given transaction to storage.

Get the read/write count of the db

Get the read/write count of the db

Get the whitelist for tracking db reads/writes

Update the whitelist for tracking db reads/writes

Estimate proof size

Extend storage info for benchmarking db

Implementors§