[][src]Struct substrate_client::Client

pub struct Client<B, E, Block, RA> where
    Block: BlockT
{ /* fields omitted */ }

Substrate Client

Methods

impl<B, E, Block, RA> Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

pub fn new<S: BuildStorage>(
    backend: Arc<B>,
    executor: E,
    build_genesis_storage: S,
    execution_strategies: ExecutionStrategies
) -> Result<Self>
[src]

Creates new Substrate Client with given blockchain and code executor.

pub fn execution_strategies(&self) -> &ExecutionStrategies[src]

Get a reference to the execution strategies.

pub fn state_at(&self, block: &BlockId<Block>) -> Result<B::State>[src]

Get a reference to the state at a given block.

pub fn storage_keys(
    &self,
    id: &BlockId<Block>,
    key_prefix: &StorageKey
) -> Result<Vec<StorageKey>>
[src]

Given a BlockId and a key prefix, return the matching child storage keys in that block.

pub fn storage(
    &self,
    id: &BlockId<Block>,
    key: &StorageKey
) -> Result<Option<StorageData>>
[src]

Given a BlockId and a key, return the value under the key in that block.

pub fn storage_hash(
    &self,
    id: &BlockId<Block>,
    key: &StorageKey
) -> Result<Option<Block::Hash>>
[src]

Given a BlockId and a key, return the value under the hash in that block.

pub fn child_storage_keys(
    &self,
    id: &BlockId<Block>,
    child_storage_key: &StorageKey,
    key_prefix: &StorageKey
) -> Result<Vec<StorageKey>>
[src]

Given a BlockId, a key prefix, and a child storage key, return the matching child storage keys.

pub fn child_storage(
    &self,
    id: &BlockId<Block>,
    child_storage_key: &StorageKey,
    key: &StorageKey
) -> Result<Option<StorageData>>
[src]

Given a BlockId, a key and a child storage key, return the value under the key in that block.

pub fn child_storage_hash(
    &self,
    id: &BlockId<Block>,
    child_storage_key: &StorageKey,
    key: &StorageKey
) -> Result<Option<Block::Hash>>
[src]

Given a BlockId, a key and a child storage key, return the hash under the key in that block.

pub fn code_at(&self, id: &BlockId<Block>) -> Result<Vec<u8>>[src]

Get the code at a given block.

pub fn runtime_version_at(&self, id: &BlockId<Block>) -> Result<RuntimeVersion>[src]

Get the RuntimeVersion at a given block.

pub fn executor(&self) -> &E[src]

Get call executor reference.

pub fn read_proof<I>(
    &self,
    id: &BlockId<Block>,
    keys: I
) -> Result<Vec<Vec<u8>>> where
    I: IntoIterator,
    I::Item: AsRef<[u8]>, 
[src]

Reads storage value at a given block + key, returning read proof.

pub fn read_child_proof<I>(
    &self,
    id: &BlockId<Block>,
    storage_key: &[u8],
    keys: I
) -> Result<Vec<Vec<u8>>> where
    I: IntoIterator,
    I::Item: AsRef<[u8]>, 
[src]

Reads child storage value at a given block + storage_key + key, returning read proof.

pub fn execution_proof(
    &self,
    id: &BlockId<Block>,
    method: &str,
    call_data: &[u8]
) -> Result<(Vec<u8>, Vec<Vec<u8>>)>
[src]

Execute a call to a contract on top of state in a block of given hash AND returning execution proof.

No changes are made.

pub fn header_proof(
    &self,
    id: &BlockId<Block>
) -> Result<(Block::Header, Vec<Vec<u8>>)>
[src]

Reads given header and generates CHT-based header proof.

pub fn block_hash(
    &self,
    block_number: <<Block as BlockT>::Header as HeaderT>::Number
) -> Result<Option<Block::Hash>>
[src]

Get block hash by number.

pub fn header_proof_with_cht_size(
    &self,
    id: &BlockId<Block>,
    cht_size: NumberFor<Block>
) -> Result<(Block::Header, Vec<Vec<u8>>)>
[src]

Reads given header and generates CHT-based header proof for CHT of given size.

pub fn max_key_changes_range(
    &self,
    first: NumberFor<Block>,
    last: BlockId<Block>
) -> Result<Option<(NumberFor<Block>, BlockId<Block>)>>
[src]

Get longest range within [first; last] that is possible to use in key_changes and key_changes_proof calls. Range could be shortened from the beginning if some changes tries have been pruned. Returns Ok(None) if changes trues are not supported.

pub fn key_changes(
    &self,
    first: NumberFor<Block>,
    last: BlockId<Block>,
    storage_key: Option<&StorageKey>,
    key: &StorageKey
) -> Result<Vec<(NumberFor<Block>, u32)>>
[src]

Get pairs of (block, extrinsic) where key has been changed at given blocks range. Works only for runtimes that are supporting changes tries.

Changes are returned in descending order (i.e. last block comes first).

pub fn key_changes_proof(
    &self,
    first: Block::Hash,
    last: Block::Hash,
    min: Block::Hash,
    max: Block::Hash,
    storage_key: Option<&StorageKey>,
    key: &StorageKey
) -> Result<ChangesProof<Block::Header>>
[src]

Get proof for computation of (block, extrinsic) pairs where key has been changed at given blocks range. min is the hash of the first block, which changes trie root is known to the requester - when we're using changes tries from ascendants of this block, we should provide proofs for changes tries roots max is the hash of the last block known to the requester - we can't use changes tries from descendants of this block. Works only for runtimes that are supporting changes tries.

pub fn key_changes_proof_with_cht_size(
    &self,
    first: Block::Hash,
    last: Block::Hash,
    min: Block::Hash,
    max: Block::Hash,
    storage_key: Option<&StorageKey>,
    key: &StorageKey,
    cht_size: NumberFor<Block>
) -> Result<ChangesProof<Block::Header>>
[src]

Does the same work as key_changes_proof, but assumes that CHTs are of passed size.

pub fn new_block(
    &self,
    inherent_digests: DigestFor<Block>
) -> Result<BlockBuilder<Block, Self>> where
    E: Clone + Send + Sync,
    RA: Send + Sync,
    Self: ProvideRuntimeApi,
    Self::Api: BlockBuilderAPI<Block>, 
[src]

Create a new block, built on the head of the chain.

pub fn new_block_at(
    &self,
    parent: &BlockId<Block>,
    inherent_digests: DigestFor<Block>
) -> Result<BlockBuilder<Block, Self>> where
    E: Clone + Send + Sync,
    RA: Send + Sync,
    Self: ProvideRuntimeApi,
    Self::Api: BlockBuilderAPI<Block>, 
[src]

Create a new block, built on top of parent.

pub fn new_block_at_with_proof_recording(
    &self,
    parent: &BlockId<Block>,
    inherent_digests: DigestFor<Block>
) -> Result<BlockBuilder<Block, Self>> where
    E: Clone + Send + Sync,
    RA: Send + Sync,
    Self: ProvideRuntimeApi,
    Self::Api: BlockBuilderAPI<Block>, 
[src]

Create a new block, built on top of parent with proof recording enabled.

While proof recording is enabled, all accessed trie nodes are saved. These recorded trie nodes can be used by a third party to proof the output of this block builder without having access to the full storage.

pub fn lock_import_and_run<R, Err, F>(&self, f: F) -> Result<R, Err> where
    F: FnOnce(&mut ClientImportOperation<Block, Blake2Hasher, B>) -> Result<R, Err>,
    Err: From<Error>, 
[src]

Lock the import lock, and run operations inside.

pub fn revert(&self, n: NumberFor<Block>) -> Result<NumberFor<Block>>[src]

Attempts to revert the chain by n blocks. Returns the number of blocks that were successfully reverted.

pub fn info(&self) -> ClientInfo<Block>[src]

Get blockchain info.

pub fn block_status(&self, id: &BlockId<Block>) -> Result<BlockStatus>[src]

Get block status.

pub fn header(
    &self,
    id: &BlockId<Block>
) -> Result<Option<<Block as BlockT>::Header>>
[src]

Get block header by id.

pub fn body(
    &self,
    id: &BlockId<Block>
) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>
[src]

Get block body by id.

pub fn justification(
    &self,
    id: &BlockId<Block>
) -> Result<Option<Justification>>
[src]

Get block justification set by id.

pub fn block(&self, id: &BlockId<Block>) -> Result<Option<SignedBlock<Block>>>[src]

Get full block by id.

pub fn uncles(
    &self,
    target_hash: Block::Hash,
    max_generation: NumberFor<Block>
) -> Result<Vec<Block::Hash>>
[src]

Gets the uncles of the block with target_hash going back max_generation ancestors.

Trait Implementations

impl<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> HeaderBackend<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Send + Sync,
    Block: BlockT<Hash = H256>,
    RA: Send + Sync
[src]

impl<'_, B, E, Block, RA> HeaderBackend<Block> for &'_ Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Send + Sync,
    Block: BlockT<Hash = H256>,
    RA: Send + Sync
[src]

impl<B, E, Block, RA> ProvideCache<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> Finalizer<Block, Blake2Hasher, B> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<'_, B, E, Block, RA> Finalizer<Block, Blake2Hasher, B> for &'_ Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> AuxStore for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

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]

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.

impl<'_, B, E, Block, RA> AuxStore for &'_ Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> BlockchainEvents<Block> for Client<B, E, Block, RA> where
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

fn import_notification_stream(&self) -> ImportNotifications<Block>[src]

Get block import event stream.

fn storage_changes_notification_stream(
    &self,
    filter_keys: Option<&[StorageKey]>,
    child_filter_keys: Option<&[(StorageKey, Option<Vec<StorageKey>>)]>
) -> Result<StorageEventStream<Block::Hash>>
[src]

Get storage changes event stream.

impl<B, E, Block, RA> BlockBody<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> ProvideUncles<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

impl<B, E, Block, RA> BlockOf for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher>,
    Block: BlockT<Hash = H256>, 
[src]

type Type = Block

The type of the block.

impl<B, E, Block, RA> ProvideRuntimeApi for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
    Block: BlockT<Hash = H256>,
    RA: ConstructRuntimeApi<Block, Self>, 
[src]

type Api = <RA as ConstructRuntimeApi<Block, Self>>::RuntimeApi

The concrete type that provides the api.

impl<'a, B, E, Block, RA> BlockImport<Block> for &'a Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
    Block: BlockT<Hash = H256>, 
[src]

NOTE: only use this implementation when you are sure there are NO consensus-level BlockImport objects. Otherwise, importing blocks directly into the client would be bypassing important verification work.

type Error = ConsensusError

fn import_block(
    &mut self,
    import_block: BlockImportParams<Block>,
    new_cache: HashMap<CacheKeyId, Vec<u8>>
) -> Result<ImportResult, Self::Error>
[src]

Import a checked and validated block. If a justification is provided in BlockImportParams then finalized must be true.

NOTE: only use this implementation when there are NO consensus-level BlockImport objects. Otherwise, importing blocks directly into the client would be bypassing important verification work.

If you are not sure that there are no BlockImport objects provided by the consensus algorithm, don't use this function.

fn check_block(
    &mut self,
    hash: Block::Hash,
    parent_hash: Block::Hash
) -> Result<ImportResult, Self::Error>
[src]

Check block preconditions.

impl<B, E, Block, RA> BlockImport<Block> for Client<B, E, Block, RA> where
    B: Backend<Block, Blake2Hasher>,
    E: CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync,
    Block: BlockT<Hash = H256>, 
[src]

type Error = ConsensusError

Auto Trait Implementations

impl<B, E, Block, RA> Send for Client<B, E, Block, RA> where
    B: Send + Sync,
    E: Send,
    RA: Send,
    <Block as Block>::Hash: Send,
    <Block as Block>::Header: Send

impl<B, E, Block, RA> Unpin for Client<B, E, Block, RA> where
    E: Unpin,
    RA: Unpin,
    <Block as Block>::Hash: Unpin

impl<B, E, Block, RA> Sync for Client<B, E, Block, RA> where
    B: Send + Sync,
    E: Sync,
    RA: Sync,
    <Block as Block>::Hash: Send + Sync,
    <Block as Block>::Header: Send

impl<B, E, Block, RA> !UnwindSafe for Client<B, E, Block, RA>

impl<B, E, Block, RA> !RefUnwindSafe for Client<B, E, Block, RA>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    Outer: AsRef<T> + AsMut<T> + From<T>,
    T: From<Outer>, 
[src]

fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Erased for T[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]

impl<T, S> UniqueSaturatedInto<T> for S where
    S: TryInto<T>,
    T: Bounded
[src]

impl<T> SaturatedConversion for T[src]

impl<T> CheckedConversion for T[src]

impl<T> Erased for T[src]