Struct sc_state_db::StateDb
source · 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>where
F: Fn() -> bool,
pub fn pin<F>(
&self,
hash: &BlockHash,
number: u64,
hint: F
) -> Result<(), PinError>where
F: Fn() -> bool,
Prevents pruning of specified block and its descendants.
hint
used for futher checking if the given block exists
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>>where
Q: AsRef<DB::Key> + Hash + Eq + ?Sized,
Key: Borrow<Q>,
pub fn get<DB: NodeDb, Q>(
&self,
key: &Q,
db: &DB
) -> Result<Option<DBValue>, Error<DB::Error>>where
Q: AsRef<DB::Key> + Hash + Eq + ?Sized,
Key: Borrow<Q>,
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.
Auto Trait Implementations§
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>where
D: Send + Sync,
impl<BlockHash, Key, D> Unpin for StateDb<BlockHash, Key, D>where
BlockHash: Unpin,
D: Unpin,
Key: Unpin,
impl<BlockHash, Key, D> UnwindSafe for StateDb<BlockHash, Key, D>where
BlockHash: UnwindSafe,
D: UnwindSafe,
Key: UnwindSafe,
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresource§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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§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
The counterpart to
unchecked_from
.