pub struct Backend<Block>where
Block: Block,{ /* private fields */ }Expand description
Disk backend.
Disk backend keeps data in a key-value store. In archive mode, trie nodes are kept from all blocks. Otherwise, trie nodes are kept only from some recent blocks.
Implementations§
Source§impl<Block> Backend<Block>where
Block: Block,
impl<Block> Backend<Block>where
Block: Block,
Sourcepub fn new(
db_config: DatabaseSettings,
canonicalization_delay: u64,
) -> Result<Backend<Block>, Error>
pub fn new( db_config: DatabaseSettings, canonicalization_delay: u64, ) -> Result<Backend<Block>, Error>
Create a new instance of database backend.
The pruning window is how old a block must be before the state is pruned.
Sourcepub fn reset_trie_cache(&self)
pub fn reset_trie_cache(&self)
Reset the shared trie cache.
Trait Implementations§
Source§impl<Block> AuxStore for Backend<Block>where
Block: Block,
impl<Block> AuxStore for Backend<Block>where
Block: Block,
Source§fn insert_aux<'a, 'b, 'c, I, D>(
&self,
insert: I,
delete: D,
) -> Result<(), Error>where
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
fn insert_aux<'a, 'b, 'c, I, D>(
&self,
insert: I,
delete: D,
) -> Result<(), Error>where
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
Insert auxiliary data into key-value store. Read more
Source§impl<Block> Backend<Block> for Backend<Block>where
Block: Block,
impl<Block> Backend<Block> for Backend<Block>where
Block: Block,
Source§type BlockImportOperation = BlockImportOperation<Block>
type BlockImportOperation = BlockImportOperation<Block>
Associated block insertion operation type.
Source§type Blockchain = BlockchainDb<Block>
type Blockchain = BlockchainDb<Block>
Associated blockchain backend type.
Source§type State = RecordStatsState<RefTrackingState<Block>, Block>
type State = RecordStatsState<RefTrackingState<Block>, Block>
Associated state backend type.
Source§type OffchainStorage = LocalStorage
type OffchainStorage = LocalStorage
Offchain workers local storage.
Source§fn begin_operation(
&self,
) -> Result<<Backend<Block> as Backend<Block>>::BlockImportOperation, Error>
fn begin_operation( &self, ) -> Result<<Backend<Block> as Backend<Block>>::BlockImportOperation, Error>
Begin a new block insertion transaction with given parent block id. Read more
Source§fn begin_state_operation(
&self,
operation: &mut <Backend<Block> as Backend<Block>>::BlockImportOperation,
block: <Block as Block>::Hash,
) -> Result<(), Error>
fn begin_state_operation( &self, operation: &mut <Backend<Block> as Backend<Block>>::BlockImportOperation, block: <Block as Block>::Hash, ) -> Result<(), Error>
Note an operation to contain state transition.
Source§fn commit_operation(
&self,
operation: <Backend<Block> as Backend<Block>>::BlockImportOperation,
) -> Result<(), Error>
fn commit_operation( &self, operation: <Backend<Block> as Backend<Block>>::BlockImportOperation, ) -> Result<(), Error>
Commit block insertion.
Source§fn finalize_block(
&self,
hash: <Block as Block>::Hash,
justification: Option<([u8; 4], Vec<u8>)>,
) -> Result<(), Error>
fn finalize_block( &self, hash: <Block as Block>::Hash, justification: Option<([u8; 4], Vec<u8>)>, ) -> Result<(), Error>
Finalize block with given
hash. Read moreSource§fn append_justification(
&self,
hash: <Block as Block>::Hash,
justification: ([u8; 4], Vec<u8>),
) -> Result<(), Error>
fn append_justification( &self, hash: <Block as Block>::Hash, justification: ([u8; 4], Vec<u8>), ) -> Result<(), Error>
Append justification to the block with the given
hash. Read moreSource§fn offchain_storage(
&self,
) -> Option<<Backend<Block> as Backend<Block>>::OffchainStorage>
fn offchain_storage( &self, ) -> Option<<Backend<Block> as Backend<Block>>::OffchainStorage>
Returns a handle to offchain storage.
Source§fn usage_info(&self) -> Option<UsageInfo>
fn usage_info(&self) -> Option<UsageInfo>
Returns current usage statistics.
Source§fn revert(
&self,
n: <<Block as Block>::Header as Header>::Number,
revert_finalized: bool,
) -> Result<(<<Block as Block>::Header as Header>::Number, HashSet<<Block as Block>::Hash>), Error>
fn revert( &self, n: <<Block as Block>::Header as Header>::Number, revert_finalized: bool, ) -> Result<(<<Block as Block>::Header as Header>::Number, HashSet<<Block as Block>::Hash>), Error>
Attempts to revert the chain by
n blocks. If revert_finalized is set it will attempt to
revert past any finalized block, this is unsafe and can potentially leave the node in an
inconsistent state. All blocks higher than the best block are also reverted and not counting
towards n. Read moreSource§fn remove_leaf_block(&self, hash: <Block as Block>::Hash) -> Result<(), Error>
fn remove_leaf_block(&self, hash: <Block as Block>::Hash) -> Result<(), Error>
Discard non-best, unfinalized leaf block.
Source§fn blockchain(&self) -> &BlockchainDb<Block>
fn blockchain(&self) -> &BlockchainDb<Block>
Returns reference to blockchain backend.
Source§fn state_at(
&self,
hash: <Block as Block>::Hash,
trie_cache_context: TrieCacheContext,
) -> Result<<Backend<Block> as Backend<Block>>::State, Error>
fn state_at( &self, hash: <Block as Block>::Hash, trie_cache_context: TrieCacheContext, ) -> Result<<Backend<Block> as Backend<Block>>::State, Error>
Returns state backend with post-state of given block.
Source§fn have_state_at(
&self,
hash: <Block as Block>::Hash,
number: <<Block as Block>::Header as Header>::Number,
) -> bool
fn have_state_at( &self, hash: <Block as Block>::Hash, number: <<Block as Block>::Header as Header>::Number, ) -> bool
Returns true if state for given block is available.
Source§fn get_import_lock(&self) -> &RwLock<RawRwLock, ()>
fn get_import_lock(&self) -> &RwLock<RawRwLock, ()>
Gain access to the import lock around this backend. Read more
Source§fn requires_full_sync(&self) -> bool
fn requires_full_sync(&self) -> bool
Tells whether the backend requires full-sync mode.
Source§fn pin_block(&self, hash: <Block as Block>::Hash) -> Result<(), Error>
fn pin_block(&self, hash: <Block as Block>::Hash) -> Result<(), Error>
Pin the block to keep body, justification and state available after pruning.
Number of pins are reference counted. Users need to make sure to perform
one call to
Self::unpin_block per call to Self::pin_block.Source§fn unpin_block(&self, hash: <Block as Block>::Hash)
fn unpin_block(&self, hash: <Block as Block>::Hash)
Unpin the block to allow pruning.
Source§fn insert_aux<'a, 'b, 'c, I, D>(
&self,
insert: I,
delete: D,
) -> Result<(), Error>where
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
fn insert_aux<'a, 'b, 'c, I, D>(
&self,
insert: I,
delete: D,
) -> Result<(), Error>where
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
Insert auxiliary data into key-value store.
impl<Block> LocalBackend<Block> for Backend<Block>where
Block: Block,
Auto Trait Implementations§
impl<Block> !Freeze for Backend<Block>
impl<Block> !RefUnwindSafe for Backend<Block>
impl<Block> Send for Backend<Block>
impl<Block> Sync for Backend<Block>
impl<Block> Unpin for Backend<Block>
impl<Block> UnsafeUnpin for Backend<Block>
impl<Block> !UnwindSafe for Backend<Block>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
Source§fn defensive_truncate_into(self) -> U
fn defensive_truncate_into(self) -> U
Defensively truncate a value and convert it into its bounded form.
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> 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> ⓘ
Converts
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> ⓘ
Converts
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>,
Consume self to return an equivalent value of
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
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.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
Consume self to return an equivalent value of
T.