pub trait ApiExt<Block: BlockT> {
// 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_hash: Block::Hash,
) -> Result<bool, ApiError>
where Self: Sized;
fn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at_hash: Block::Hash,
pred: P,
) -> Result<bool, ApiError>
where Self: Sized;
fn api_version<A: RuntimeApiInfo + ?Sized>(
&self,
at_hash: Block::Hash,
) -> Result<Option<u32>, ApiError>
where Self: Sized;
fn record_proof(&mut self);
fn record_proof_with_recorder(&mut self, recorder: ProofRecorder<Block>);
fn extract_proof(&mut self) -> Option<StorageProof>;
fn proof_recorder(&self) -> Option<ProofRecorder<Block>>;
fn into_storage_changes<B: StateBackend<HashingFor<Block>>>(
&self,
backend: &B,
parent_hash: Block::Hash,
) -> Result<StorageChanges<Block>, String>
where Self: Sized;
fn set_call_context(&mut self, call_context: CallContext);
fn register_extension<E: Extension>(&mut self, extension: E);
fn set_overlayed_changes(
&mut self,
changes: OverlayedChanges<HashingFor<Block>>,
);
}Expand description
Extends the runtime api implementation with some common functionality.
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_hash: Block::Hash,
) -> Result<bool, ApiError>where
Self: Sized,
fn has_api<A: RuntimeApiInfo + ?Sized>(
&self,
at_hash: Block::Hash,
) -> Result<bool, ApiError>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_hash: Block::Hash,
pred: P,
) -> Result<bool, ApiError>where
Self: Sized,
fn has_api_with<A: RuntimeApiInfo + ?Sized, P: Fn(u32) -> bool>(
&self,
at_hash: Block::Hash,
pred: P,
) -> Result<bool, ApiError>where
Self: Sized,
Check if the given api is implemented and the version passes a predicate.
Sourcefn api_version<A: RuntimeApiInfo + ?Sized>(
&self,
at_hash: Block::Hash,
) -> Result<Option<u32>, ApiError>where
Self: Sized,
fn api_version<A: RuntimeApiInfo + ?Sized>(
&self,
at_hash: Block::Hash,
) -> Result<Option<u32>, ApiError>where
Self: Sized,
Returns the version of the given api.
Sourcefn record_proof(&mut self)
fn record_proof(&mut self)
Start recording all accessed trie nodes.
The recorded trie nodes can be converted into a proof using Self::extract_proof.
Sourcefn record_proof_with_recorder(&mut self, recorder: ProofRecorder<Block>)
fn record_proof_with_recorder(&mut self, recorder: ProofRecorder<Block>)
Start recording all accessed trie nodes using the given proof recorder.
The recorded trie nodes can be converted into a proof using Self::extract_proof.
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 proof_recorder(&self) -> Option<ProofRecorder<Block>>
fn proof_recorder(&self) -> Option<ProofRecorder<Block>>
Returns the current active proof recorder.
Sourcefn into_storage_changes<B: StateBackend<HashingFor<Block>>>(
&self,
backend: &B,
parent_hash: Block::Hash,
) -> Result<StorageChanges<Block>, String>where
Self: Sized,
fn into_storage_changes<B: StateBackend<HashingFor<Block>>>(
&self,
backend: &B,
parent_hash: Block::Hash,
) -> Result<StorageChanges<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.
Sourcefn set_call_context(&mut self, call_context: CallContext)
fn set_call_context(&mut self, call_context: CallContext)
Set the CallContext to be used by the runtime api calls done by this instance.
Sourcefn register_extension<E: Extension>(&mut self, extension: E)
fn register_extension<E: Extension>(&mut self, extension: E)
Register an [Extension] that will be accessible while executing a runtime api call.
Sourcefn set_overlayed_changes(
&mut self,
changes: OverlayedChanges<HashingFor<Block>>,
)
fn set_overlayed_changes( &mut self, changes: OverlayedChanges<HashingFor<Block>>, )
Replace the overlayed changes used by subsequent runtime API calls on this instance.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.