mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
562f12cd9b
* WIP Starting to write book; extrinsics first pass done * cargo fmt * Ongoing work; events, constants, wip blocks * at_latest() and wip blocks * remove need to import parity-scale-codec crate with Subxt for macro to work * More docs; expanding on setup guide and finish pass of main sections * Tidy and remove example section for now * format book lines to 100chars * Fix example code * cargo fmt * cargo fmt * fix example * Fix typos * fix broken doc links, pub mods * Update Subxt macro docs * can't link to Subxt here * move macro docs to Subxt to make linking better and fix example code * note on macro about docs * cargo fmt * document the no_default_derives macro feature * Address feedback and remove redundant text * address review comments; minor tweaks * WIP add Runtime calls to book * Improve Runtime API docs * expose thing we forgot to expose and doc link fixes
40 lines
1.7 KiB
Rust
40 lines
1.7 KiB
Rust
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
|
|
//! # Blocks
|
|
//!
|
|
//! The [blocks API](crate::blocks::BlocksClient) in Subxt unifies many of the other interfaces, and
|
|
//! allows you to:
|
|
//!
|
|
//! - Access information about specific blocks (see [`crate::blocks::BlocksClient::at()`] and
|
|
//! [`crate::blocks::BlocksClient::at_latest()`]).
|
|
//! - Subscribe to [all](crate::blocks::BlocksClient::subscribe_all()),
|
|
//! [best](crate::blocks::BlocksClient::subscribe_best()) or
|
|
//! [finalized](crate::blocks::BlocksClient::subscribe_finalized()) blocks as they are produced.
|
|
//! Prefer to subscribe to finalized blocks unless you know what you're doing.
|
|
//!
|
|
//! In either case, you'll end up with [`crate::blocks::Block`]'s, from which you can access various
|
|
//! information about the block, such a the [header](crate::blocks::Block::header()), [block
|
|
//! number](crate::blocks::Block::number()) and [body](crate::blocks::Block::body()).
|
|
//! [`crate::blocks::Block`]'s also provide shortcuts to other Subxt APIs that will operate at the
|
|
//! given block:
|
|
//!
|
|
//! - [storage](crate::blocks::Block::storage()),
|
|
//! - [events](crate::blocks::Block::events())
|
|
//! - [runtime APIs](crate::blocks::Block::runtime_api())
|
|
//!
|
|
//! ## Example
|
|
//!
|
|
//! Given a block, you can [download the block body](crate::blocks::Block::body()) and iterate over
|
|
//! the extrinsics stored within it using [`crate::blocks::BlockBody::extrinsics()`].
|
|
//!
|
|
//! Here's an example in which we subscribe to blocks and print a bunch of information about each
|
|
//! one:
|
|
//!
|
|
//!
|
|
//! ```rust,ignore
|
|
#![doc = include_str!("../../../../examples/examples/blocks_subscribing.rs")]
|
|
//! ```
|
|
//!
|