sc-client 0.8.0-alpha.6

Substrate Client and associated logic.
sc-client-0.8.0-alpha.6 doesn't have any documentation.

Substrate Client and associated logic.

The [Client] is one of the most important components of Substrate. It mainly comprises two parts:

  • A database containing the blocks and chain state, generally referred to as the Backend.
  • A runtime environment, generally referred to as the Executor.

Initialization

Creating a [Client] is done by calling the new method and passing to it a Backend and an Executor.

The former is typically provided by the sc-client-db crate.

The latter typically requires passing one of:

Additionally, the fourth generic parameter of the Client is a marker type representing the ways in which the runtime can interface with the outside. Any code that builds a Client is responsible for putting the right marker.

Example

use std::sync::Arc;
use sc_client::{Client, in_mem::Backend, LocalCallExecutor};
use sp_runtime::Storage;
use sc_executor::{NativeExecutor, WasmExecutionMethod};

// In this example, we're using the `Block` and `RuntimeApi` types from the
// `substrate-test-runtime-client` crate. These types are automatically generated when
// compiling a runtime. In a typical use-case, these types would have been to be generated
// from your runtime.
use substrate_test_runtime_client::{LocalExecutor, runtime::Block, runtime::RuntimeApi};

let backend = Arc::new(Backend::<Block>::new());
let client = Client::<_, _, _, RuntimeApi>::new(
backend.clone(),
LocalCallExecutor::new(
backend.clone(),
NativeExecutor::<LocalExecutor>::new(WasmExecutionMethod::Interpreted, None, 8),
sp_core::tasks::executor(),
),
// This parameter provides the storage for the chain genesis.
&<Storage>::default(),
Default::default(),
Default::default(),
Default::default(),
None,
);