pub trait ApiExt<Block: BlockT>: ApiErrorExt {
type StateBackend: StateBackend<HashFor<Block>>;
// Required methods
fn execute_in_transaction<F: FnOnce(&Self) -> TransactionOutcome<R>, R>(
&self,
call: F,
) -> R
where Self: Sized;
fn has_api<A: RuntimeApiInfo + ?Sized>(
&self,
at: &BlockId<Block>,
) -> Result<bool, Self::Error>
where Self: Sized;
fn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at: &BlockId<Block>,
pred: P,
) -> Result<bool, Self::Error>
where Self: Sized;
fn record_proof(&mut self);
fn extract_proof(&mut self) -> Option<StorageProof>;
fn into_storage_changes(
&self,
backend: &Self::StateBackend,
changes_trie_state: Option<&ChangesTrieState<'_, HashFor<Block>, NumberFor<Block>>>,
parent_hash: Block::Hash,
) -> Result<StorageChanges<Self::StateBackend, Block>, String>
where Self: Sized;
}Expand description
Extends the runtime api implementation with some common functionality.
Required Associated Types§
Sourcetype StateBackend: StateBackend<HashFor<Block>>
type StateBackend: StateBackend<HashFor<Block>>
The state backend that is used to store the block states.
Required Methods§
Sourcefn execute_in_transaction<F: FnOnce(&Self) -> TransactionOutcome<R>, R>(
&self,
call: F,
) -> Rwhere
Self: Sized,
fn execute_in_transaction<F: FnOnce(&Self) -> TransactionOutcome<R>, R>(
&self,
call: F,
) -> Rwhere
Self: Sized,
Execute the given closure inside a new transaction.
Depending on the outcome of the closure, the transaction is committed or rolled-back.
The internal result of the closure is returned afterwards.
Sourcefn has_api<A: RuntimeApiInfo + ?Sized>(
&self,
at: &BlockId<Block>,
) -> Result<bool, Self::Error>where
Self: Sized,
fn has_api<A: RuntimeApiInfo + ?Sized>(
&self,
at: &BlockId<Block>,
) -> Result<bool, Self::Error>where
Self: Sized,
Checks if the given api is implemented and versions match.
Sourcefn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at: &BlockId<Block>,
pred: P,
) -> Result<bool, Self::Error>where
Self: Sized,
fn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at: &BlockId<Block>,
pred: P,
) -> Result<bool, Self::Error>where
Self: Sized,
Check if the given api is implemented and the version passes a predicate.
Sourcefn record_proof(&mut self)
fn record_proof(&mut self)
Start recording all accessed trie nodes for generating proofs.
Sourcefn extract_proof(&mut self) -> Option<StorageProof>
fn extract_proof(&mut self) -> Option<StorageProof>
Extract the recorded proof.
This stops the proof recording.
If record_proof was not called before, this will return None.
Sourcefn into_storage_changes(
&self,
backend: &Self::StateBackend,
changes_trie_state: Option<&ChangesTrieState<'_, HashFor<Block>, NumberFor<Block>>>,
parent_hash: Block::Hash,
) -> Result<StorageChanges<Self::StateBackend, Block>, String>where
Self: Sized,
fn into_storage_changes(
&self,
backend: &Self::StateBackend,
changes_trie_state: Option<&ChangesTrieState<'_, HashFor<Block>, NumberFor<Block>>>,
parent_hash: Block::Hash,
) -> Result<StorageChanges<Self::StateBackend, Block>, String>where
Self: Sized,
Convert the api object into the storage changes that were done while executing runtime api functions.
After executing this function, all collected changes are reset.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".