Struct sc_service::client::Client[][src]

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

Substrate Client

Implementations

impl<B, E, Block, RA> Client<B, E, Block, RA> where
    B: Backend<Block>,
    E: CallExecutor<Block>,
    Block: BlockT,
    Block::Header: Clone
[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>,
    telemetry: Option<TelemetryHandle>,
    config: ClientConfig
) -> Result<Self>
[src]

Creates new Substrate Client with given blockchain and code executor.

pub fn import_notification_sinks(
    &self
) -> &Mutex<Vec<TracingUnboundedSender<BlockImportNotification<Block>>>>
[src]

returns a reference to the block import notification sinks useful for test environments.

pub fn finality_notification_sinks(
    &self
) -> &Mutex<Vec<TracingUnboundedSender<FinalityNotification<Block>>>>
[src]

returns a reference to the finality notification sinks useful for test environments.

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 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<&PrefixedStorageKey>,
    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(
    &mut self,
    n: NumberFor<Block>,
    blacklist: bool
) -> 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. If blacklist is set to true, will also blacklist reverted blocks from finalizing again. The blacklist is reset upon client restart.

Returns the number of blocks that were successfully reverted.

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>, 
[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>, 
[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>, 
[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<'impl0, B, E, Block, RA> BlockImport<Block> for &'impl0 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> + ApiExt<Block, StateBackend = B::State>,
    RA: Sync + Send,
    TransactionFor<B, Block>: Send + 'static, 
[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<'life0, 'async_trait>(
    &'life0 mut self,
    import_block: BlockImportParams<Block, TransactionFor<B, Block>>,
    new_cache: HashMap<CacheKeyId, Vec<u8>>
) -> Pin<Box<dyn Future<Output = Result<ImportResult, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[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<'life0, 'async_trait>(
    &'life0 mut self,
    block: BlockCheckParams<Block>
) -> Pin<Box<dyn Future<Output = Result<ImportResult, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[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> + ApiExt<Block, StateBackend = B::State>,
    RA: Sync + Send,
    TransactionFor<B, Block>: Send + 'static, 
[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 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]

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

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

Get usage info about current client.

Auto Trait Implementations

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

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

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

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 as Header>::Number: Unpin
[src]

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

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<Block, T> Client<Block> for T where
    Block: Block,
    T: HeaderBackend<Block> + ProofProvider<Block> + BlockIdTo<Block, Error = Error> + BlockBackend<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync
[src]

impl<Block, BE, T> ClientForGrandpa<Block, BE> for T where
    Block: Block,
    T: LockImportRun<Block, BE> + Finalizer<Block, BE> + AuxStore + HeaderMetadata<Block, Error = Error> + HeaderBackend<Block> + BlockchainEvents<Block> + ProvideRuntimeApi<Block> + ExecutorProvider<Block> + BlockImport<Block, Transaction = <<BE as Backend<Block>>::State as Backend<<<Block as Block>::Header as Header>::Hashing>>::Transaction, Error = Error>,
    BE: Backend<Block>, 
[src]

impl<T> Erased for T[src]

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

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

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

Get a reference to the inner from the outer.

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

Get a mutable reference to the inner from the outer.

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

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

type Output = T

Should always be Self

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

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

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

impl<T> WithSubscriber for T[src]