[][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(
    backend: Arc<B>,
    executor: E,
    build_genesis_storage: &dyn BuildStorage,
    fork_blocks: ForkBlocks<Block>,
    bad_blocks: BadBlocks<Block>,
    execution_extensions: ExecutionExtensions<Block>,
    _prometheus_registry: Option<Registry>
) -> Result<Self>
[src]

Creates new Substrate Client with given blockchain and code executor.

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

Get a reference to the state at a given 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 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 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 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 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> BlockBackend<Block> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT
[src]

impl<B, E, Block, RA> BlockBuilderProvider<B, Block, Client<B, E, Block, RA>> for Client<B, E, Block, RA> where
    B: Backend<Block> + Send + Sync + 'static,
    E: CallExecutor<Block> + Send + Sync + 'static,
    Block: BlockT,
    Self: ChainHeaderBackend<Block> + ProvideRuntimeApi<Block>,
    Self::Api: ApiExt<Block, StateBackend = StateBackendFor<B, Block>> + BlockBuilderApi<Block, Error = Error>, 
[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> ExecutorProvider<Block> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT
[src]

type Executor = E

executor instance

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> LockImportRun<Block, B> for Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT
[src]

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

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

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]

impl<B, E, Block, RA> StorageProvider<Block, B> 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>,