[][src]Struct sc_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>,
    E: CallExecutor<Block>,
    Block: BlockT
[src]

pub fn new<S: BuildStorage>(
    backend: Arc<B>,
    executor: E,
    build_genesis_storage: &S,
    fork_blocks: ForkBlocks<Block>,
    bad_blocks: BadBlocks<Block>,
    execution_extensions: ExecutionExtensions<Block>
) -> Result<Self>
[src]

Creates new Substrate Client with given blockchain and code executor.

pub fn execution_extensions(&self) -> &ExecutionExtensions<Block>[src]

Get a reference to the execution extensions.

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 storage keys in that block.

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

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

pub fn storage_keys_iter<'a>(
    &self,
    id: &BlockId<Block>,
    prefix: Option<&'a StorageKey>,
    start_key: Option<&StorageKey>
) -> Result<KeyIterator<'a, B::State, Block>>
[src]

Given a BlockId and a key prefix, return a KeyIterator iterates matching 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,
    child_info: ChildInfo,
    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>,
    storage_key: &StorageKey,
    child_info: ChildInfo,
    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>,
    storage_key: &StorageKey,
    child_info: ChildInfo,
    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<StorageProof> 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],
    child_info: ChildInfo,
    keys: I
) -> Result<StorageProof> 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>, StorageProof)>
[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, StorageProof)>
[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, StorageProof)>
[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 tries 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, B>> where
    E: Clone + Send + Sync,
    RA: Send + Sync,
    Self: ProvideRuntimeApi<Block>,
    Self::Api: BlockBuilderApi<Block, Error = Error> + ApiExt<Block, StateBackend = StateBackendFor<B, Block>>, 
[src]

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

pub fn new_block_at<R: Into<RecordProof>>(
    &self,
    parent: &BlockId<Block>,
    inherent_digests: DigestFor<Block>,
    record_proof: R
) -> Result<BlockBuilder<Block, Self, B>> where
    E: Clone + Send + Sync,
    RA: Send + Sync,
    Self: ProvideRuntimeApi<Block>,
    Self::Api: BlockBuilderApi<Block, Error = Error> + ApiExt<Block, StateBackend = StateBackendFor<B, Block>>, 
[src]

Create a new block, built on top of parent.

When 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, 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 guaranteeing that no block is reverted past the last finalized block. Returns the number of blocks that were successfully reverted.

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

Attempts to revert the chain by n blocks disregarding finality. This method will revert any finalized blocks as requested and can potentially leave the node in an inconsistent state. Other modules in the system that persist data and that rely on finality (e.g. consensus parts) will be unaffected by the revert. Use this method with caution and making sure that no other data needs to be reverted for consistency aside from the block data.

Returns the number of blocks that were successfully reverted.

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

Get usage info about current client.

pub fn chain_info(&self) -> Info<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> AuxStore for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT,
    Self: ProvideRuntimeApi<Block>,
    Self::Api: CoreApi<Block, Error = Error>, 
[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>,
    E: CallExecutor<Block>,
    Block: BlockT,
    Client<B, E, Block, RA>: ProvideRuntimeApi<Block>,
    <Client<B, E, Block, RA> as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error>, 
[src]

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

impl<B, E, Block, RA> BlockIdTo<Block> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block> + Send + Sync,
    Block: BlockT,
    RA: Send + Sync
[src]

type Error = Error

The error type that will be returned by the functions.

impl<'_, B, E, Block, RA> BlockImport<Block> for &'_ Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block> + Send + Sync,
    Block: BlockT,
    Client<B, E, Block, RA>: ProvideRuntimeApi<Block>,
    <Client<B, E, Block, RA> as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error> + ApiExt<Block, StateBackend = B::State>, 
[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

The error type.

type Transaction = TransactionFor<B, Block>

The transaction type used by the backend.

fn import_block(
    &mut self,
    import_block: BlockImportParams<Block, TransactionFor<B, 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,
    block: BlockCheckParams<Block>
) -> 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>,
    E: CallExecutor<Block> + Send + Sync,
    Block: BlockT,
    Self: ProvideRuntimeApi<Block>,
    Self::Api: CoreApi<Block, Error = Error> + ApiExt<Block, StateBackend = B::State>, 
[src]

type Error = ConsensusError

The error type.

type Transaction = TransactionFor<B, Block>

The transaction type used by the backend.

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

type Type = Block

The type of the block.

impl<B, E, Block, RA> BlockchainEvents<Block> for Client<B, E, Block, RA> where
    E: CallExecutor<Block>,
    Block: BlockT
[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> CallApiAt<Block> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block, Backend = B> + Send + Sync,
    Block: BlockT
[src]

type Error = Error

Error type used by the implementation.

type StateBackend = B::State

The state backend that is used to store the block states.

impl<BE, E, B, RA> Chain<B> for Client<BE, E, B, RA> where
    BE: Backend<B>,
    E: CallExecutor<B>,
    B: BlockT
[src]

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

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

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

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

impl<B, E, Block, RA> HeaderMetadata<Block> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT
[src]

type Error = Error

Error used in case the header metadata is not found.

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

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

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

The concrete type that provides the api.

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

Auto Trait Implementations

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

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: Header + Send,
    <<Block as Block>::Header as Header>::Number: Send

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: Header + Send,
    <<Block as Block>::Header as Header>::Number: Sync

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

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

Blanket Implementations

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

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

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

impl<T> CheckedConversion for T[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

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<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,