[−][src]Trait sp_api::ApiExt
Extends the runtime api implementation with some common functionality.
Associated Types
type StateBackend: StateBackend<HashFor<Block>>
The state backend that is used to store the block states.
Required methods
fn map_api_result<F: FnOnce(&Self) -> Result<R, E>, R, E>(
&self,
map_call: F
) -> Result<R, E> where
Self: Sized,
&self,
map_call: F
) -> Result<R, E> where
Self: Sized,
The given closure will be called with api instance. Inside the closure any api call is
allowed. After doing the api call, the closure is allowed to map the Result
to a
different Result
type. This can be important, as the internal data structure that keeps
track of modifications to the storage, discards changes when the Result
is an Err
.
On Ok
, the structure commits the changes to an internal buffer.
fn runtime_version_at(
&self,
at: &BlockId<Block>
) -> Result<RuntimeVersion, Self::Error>
&self,
at: &BlockId<Block>
) -> Result<RuntimeVersion, Self::Error>
Returns the runtime version at the given block id.
fn record_proof(&mut self)
Start recording all accessed trie nodes for generating proofs.
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
.
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,
&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.
Provided methods
fn has_api<A: RuntimeApiInfo + ?Sized>(
&self,
at: &BlockId<Block>
) -> Result<bool, Self::Error> where
Self: Sized,
&self,
at: &BlockId<Block>
) -> Result<bool, Self::Error> where
Self: Sized,
Checks if the given api is implemented and versions match.
fn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at: &BlockId<Block>,
pred: P
) -> Result<bool, Self::Error> where
Self: Sized,
&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.