mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
update light client docs (#1223)
This commit is contained in:
@@ -4,45 +4,43 @@
|
|||||||
|
|
||||||
//! # Light Client
|
//! # Light Client
|
||||||
//!
|
//!
|
||||||
//! The Light Client aims to contribute to the decentralization of blockchains by providing connectivity
|
//! The light client based interface uses _Smoldot_ to connect to a _chain_, rather than an individual
|
||||||
//! to the P2P network and behaving similarly to a full node.
|
//! node. This means that you don't have to trust a specific node when interacting with some chain.
|
||||||
//!
|
//!
|
||||||
//! To enable this functionality, the unstable-light-client feature flag needs to be enabled.
|
//! This feature is currently unstable. Use the `unstable-light-client` feature flag to enable it.
|
||||||
//! To enable light client for WASM environments, also enable the web feature flag.
|
//! To use this in WASM environments, also enable the `web` feature flag.
|
||||||
//!
|
//!
|
||||||
//! To connect to a blockchain network, the Light Client requires a trusted sync state of the network, named "chain spec".
|
//! To connect to a blockchain network, the Light Client requires a trusted sync state of the network,
|
||||||
//! This can be obtained by making a `sync_state_genSyncSpec` RPC call to a trusted node.
|
//! known as a _chain spec_. One way to obtain this is by making a `sync_state_genSyncSpec` RPC call to a
|
||||||
|
//! trusted node belonging to the chain that you wish to interact with.
|
||||||
//!
|
//!
|
||||||
//! The following is an example of fetching the chain spec from a local running onde on port 9933.
|
//! The following is an example of fetching the chain spec from a local running node on port 9933:
|
||||||
//!
|
//!
|
||||||
//! ```bash
|
//! ```bash
|
||||||
//! curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "sync_state_genSyncSpec", "params":[true]}' http://localhost:9933/ | jq .result > chain_spec.json
|
//! curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "sync_state_genSyncSpec", "params":[true]}' http://localhost:9933/ | jq .result > chain_spec.json
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
//! Alternately, you can have the `LightClient` download the chain spec from a trusted node when it
|
||||||
|
//! initializes, which is not recommended in production but is useful for examples and testing, as below.
|
||||||
|
//!
|
||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! You can construct a Light Client from a trusted chain spec stored on disk.
|
//! This example connects to a local chain and submits a transaction. To run this, you first need
|
||||||
//! Similary, the Light Client can fetch the chain spec from a running node and
|
//! to have a local polkadot node running using the following command:
|
||||||
//! overwrite the bootNodes section. The `jsonrpsee` feature flag exposes the
|
|
||||||
//! `build_from_url` method.
|
|
||||||
//!
|
//!
|
||||||
//! ```rust,ignore
|
//! ```text
|
||||||
//! let light_client = LightClientBuilder::new()
|
//! polkadot --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001
|
||||||
//! .bootnodes(
|
|
||||||
//! ["/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"]
|
|
||||||
//! )
|
|
||||||
//! .build_from_url("ws://127.0.0.1:9944")
|
|
||||||
//! .await?;
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Here's an example which connects to a local chain and submits a transaction.
|
//! Leave that running for a minute, and then you can run the example using the following command
|
||||||
//!
|
//! in the `subxt` crate:
|
||||||
//! You can run the example using the following command:
|
|
||||||
//!
|
//!
|
||||||
//! ```bash
|
//! ```bash
|
||||||
//! cargo run --example unstable_light_client_tx_basic --features="unstable-light-client jsonrpsee"
|
//! cargo run --example unstable_light_client_tx_basic --features=unstable-light-client
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
//! This is the code that will be executed:
|
||||||
|
//!
|
||||||
//! ```rust,ignore
|
//! ```rust,ignore
|
||||||
#![doc = include_str!("../../../examples/unstable_light_client_tx_basic.rs")]
|
#![doc = include_str!("../../../examples/unstable_light_client_tx_basic.rs")]
|
||||||
//! ```
|
//! ```
|
||||||
|
|||||||
Reference in New Issue
Block a user