pub struct StateDb<BlockHash: Hash, Key: Hash, D: MetaDb> { /* private fields */ }Expand description
State DB maintenance. See module description. Can be shared across threads.
Implementations§
Source§impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D>
impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D>
Sourcepub fn open(
db: D,
requested_mode: Option<PruningMode>,
ref_counting: bool,
should_init: bool,
) -> Result<(CommitSet<Key>, StateDb<BlockHash, Key, D>), Error<D::Error>>
pub fn open( db: D, requested_mode: Option<PruningMode>, ref_counting: bool, should_init: bool, ) -> Result<(CommitSet<Key>, StateDb<BlockHash, Key, D>), Error<D::Error>>
Create an instance of StateDb.
pub fn pruning_mode(&self) -> PruningMode
Sourcepub fn insert_block(
&self,
hash: &BlockHash,
number: u64,
parent_hash: &BlockHash,
changeset: ChangeSet<Key>,
) -> Result<CommitSet<Key>, Error<D::Error>>
pub fn insert_block( &self, hash: &BlockHash, number: u64, parent_hash: &BlockHash, changeset: ChangeSet<Key>, ) -> Result<CommitSet<Key>, Error<D::Error>>
Add a new non-canonical block.
Sourcepub fn canonicalize_block(
&self,
hash: &BlockHash,
) -> Result<CommitSet<Key>, Error<D::Error>>
pub fn canonicalize_block( &self, hash: &BlockHash, ) -> Result<CommitSet<Key>, Error<D::Error>>
Finalize a previously inserted block.
Sourcepub fn pin<F>(
&self,
hash: &BlockHash,
number: u64,
hint: F,
) -> Result<(), PinError>
pub fn pin<F>( &self, hash: &BlockHash, number: u64, hint: F, ) -> Result<(), PinError>
Prevents pruning of specified block and its descendants.
hint used for further checking if the given block exists
Sourcepub fn unpin(&self, hash: &BlockHash)
pub fn unpin(&self, hash: &BlockHash)
Allows pruning of specified block.
Sourcepub fn sync(&self)
pub fn sync(&self)
Confirm that all changes made to commit sets are on disk. Allows for temporarily pinned blocks to be released.
Sourcepub fn get<DB: NodeDb, Q>(
&self,
key: &Q,
db: &DB,
) -> Result<Option<DBValue>, Error<DB::Error>>
pub fn get<DB: NodeDb, Q>( &self, key: &Q, db: &DB, ) -> Result<Option<DBValue>, Error<DB::Error>>
Get a value from non-canonical/pruning overlay or the backing DB.
Sourcepub fn revert_one(&self) -> Option<CommitSet<Key>>
pub fn revert_one(&self) -> Option<CommitSet<Key>>
Revert all non-canonical blocks with the best block number.
Returns a database commit or None if not possible.
For archive an empty commit set is returned.
Sourcepub fn remove(&self, hash: &BlockHash) -> Option<CommitSet<Key>>
pub fn remove(&self, hash: &BlockHash) -> Option<CommitSet<Key>>
Remove specified non-canonical block.
Returns a database commit or None if not possible.
Sourcepub fn last_canonicalized(&self) -> LastCanonicalized
pub fn last_canonicalized(&self) -> LastCanonicalized
Returns last canonicalized block.
Sourcepub fn is_pruned(&self, hash: &BlockHash, number: u64) -> IsPruned
pub fn is_pruned(&self, hash: &BlockHash, number: u64) -> IsPruned
Check if block is pruned away.
Auto Trait Implementations§
impl<BlockHash, Key, D> !Freeze for StateDb<BlockHash, Key, D>
impl<BlockHash, Key, D> !RefUnwindSafe for StateDb<BlockHash, Key, D>
impl<BlockHash, Key, D> Send for StateDb<BlockHash, Key, D>where
D: Send,
impl<BlockHash, Key, D> Sync for StateDb<BlockHash, Key, D>
impl<BlockHash, Key, D> Unpin for StateDb<BlockHash, Key, D>
impl<BlockHash, Key, D> UnsafeUnpin for StateDb<BlockHash, Key, D>where
BlockHash: UnsafeUnpin,
D: UnsafeUnpin,
impl<BlockHash, Key, D> UnwindSafe for StateDb<BlockHash, Key, D>
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.