Trait sc_client_api::backend::Backend [−][src]
Client backend.
Manages the data layer.
Note on state pruning: while an object from state_at
is alive, the state
should not be pruned. The backend should internally reference-count
its state objects.
The same applies for live BlockImportOperation
s: while an import operation building on a
parent P
is alive, the state for P
should not be pruned.
Associated Types
type BlockImportOperation: BlockImportOperation<Block, State = Self::State>
[src]
Associated block insertion operation type.
type Blockchain: BlockchainBackend<Block>
[src]
Associated blockchain backend type.
type State: StateBackend<HashFor<Block>> + Send
[src]
Associated state backend type.
type OffchainStorage: OffchainStorage
[src]
Offchain workers local storage.
Required methods
fn begin_operation(&self) -> Result<Self::BlockImportOperation>
[src]
Begin a new block insertion transaction with given parent block id.
When constructing the genesis, this is called with all-zero hash.
fn begin_state_operation(
&self,
operation: &mut Self::BlockImportOperation,
block: BlockId<Block>
) -> Result<()>
[src]
&self,
operation: &mut Self::BlockImportOperation,
block: BlockId<Block>
) -> Result<()>
Note an operation to contain state transition.
fn commit_operation(
&self,
transaction: Self::BlockImportOperation
) -> Result<()>
[src]
&self,
transaction: Self::BlockImportOperation
) -> Result<()>
Commit block insertion.
fn finalize_block(
&self,
block: BlockId<Block>,
justification: Option<Justification>
) -> Result<()>
[src]
&self,
block: BlockId<Block>,
justification: Option<Justification>
) -> Result<()>
Finalize block with given Id.
This should only be called if the parent of the given block has been finalized.
fn blockchain(&self) -> &Self::Blockchain
[src]
Returns reference to blockchain backend.
fn usage_info(&self) -> Option<UsageInfo>
[src]
Returns current usage statistics.
fn changes_trie_storage(
&self
) -> Option<&dyn PrunableStateChangesTrieStorage<Block>>
[src]
&self
) -> Option<&dyn PrunableStateChangesTrieStorage<Block>>
Returns reference to changes trie storage.
fn offchain_storage(&self) -> Option<Self::OffchainStorage>
[src]
Returns a handle to offchain storage.
fn state_at(&self, block: BlockId<Block>) -> Result<Self::State>
[src]
Returns state backend with post-state of given block.
fn revert(
&self,
n: NumberFor<Block>,
revert_finalized: bool
) -> Result<(NumberFor<Block>, HashSet<Block::Hash>)>
[src]
&self,
n: NumberFor<Block>,
revert_finalized: bool
) -> Result<(NumberFor<Block>, HashSet<Block::Hash>)>
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.
Returns the number of blocks that were successfully reverted and the list of finalized blocks that has been reverted.
fn get_import_lock(&self) -> &RwLock<()>
[src]
Gain access to the import lock around this backend.
Note Backend isn’t expected to acquire the lock by itself ever. Rather the using components should acquire and hold the lock whenever they do something that the import of a block would interfere with, e.g. importing a new block or calculating the best head.
Provided methods
fn have_state_at(&self, hash: &Block::Hash, _number: NumberFor<Block>) -> bool
[src]
Returns true if state for given block is available.
fn insert_aux<'a, 'b: 'a, 'c: 'a, I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>, D: IntoIterator<Item = &'a &'b [u8]>>(
&self,
insert: I,
delete: D
) -> Result<()>
[src]
&self,
insert: I,
delete: D
) -> Result<()>
Insert auxiliary data into key-value store.
fn get_aux(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
[src]
Query auxiliary data from key-value store.
Implementors
impl<Block: BlockT> Backend<Block> for Backend<Block> where
Block::Hash: Ord,
[src]
Block::Hash: Ord,
type BlockImportOperation = BlockImportOperation<Block>
type Blockchain = Blockchain<Block>
type State = InMemoryBackend<HashFor<Block>>
type OffchainStorage = OffchainStorage
fn begin_operation(&self) -> Result<Self::BlockImportOperation>
[src]
fn begin_state_operation(
&self,
operation: &mut Self::BlockImportOperation,
block: BlockId<Block>
) -> Result<()>
[src]
&self,
operation: &mut Self::BlockImportOperation,
block: BlockId<Block>
) -> Result<()>
fn commit_operation(&self, operation: Self::BlockImportOperation) -> Result<()>
[src]
fn finalize_block(
&self,
block: BlockId<Block>,
justification: Option<Justification>
) -> Result<()>
[src]
&self,
block: BlockId<Block>,
justification: Option<Justification>
) -> Result<()>
fn blockchain(&self) -> &Self::Blockchain
[src]
fn usage_info(&self) -> Option<UsageInfo>
[src]
fn changes_trie_storage(
&self
) -> Option<&dyn PrunableStateChangesTrieStorage<Block>>
[src]
&self
) -> Option<&dyn PrunableStateChangesTrieStorage<Block>>
fn offchain_storage(&self) -> Option<Self::OffchainStorage>
[src]
fn state_at(&self, block: BlockId<Block>) -> Result<Self::State>
[src]
fn revert(
&self,
_n: NumberFor<Block>,
_revert_finalized: bool
) -> Result<(NumberFor<Block>, HashSet<Block::Hash>)>
[src]
&self,
_n: NumberFor<Block>,
_revert_finalized: bool
) -> Result<(NumberFor<Block>, HashSet<Block::Hash>)>