Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Update subxt to read constants from metadata at runtime #1

Merged
merged 7 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ edition = "2021"
clap = { version = "3", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3" }
futures = "0.3"
subxt = { git = "https://github.com/paritytech/subxt.git", branch = "at-block-stats" }
subxt = { git = "https://github.com/paritytech/subxt.git", branch = "master" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
once_cell = "1"
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use futures::{TryStream, TryStreamExt};
use std::{boxed::Box, fmt, sync::Arc};
use subxt::{
rpc::RpcError, sp_runtime::traits::Header, ClientBuilder, DefaultConfig, DefaultExtra,
rpc::RpcError, sp_runtime::traits::Header, ClientBuilder, DefaultConfig,
SubstrateExtrinsicParams,
};

/// 50% of what is stored in configuration::activeConfig::maxPovSize at the relay chain.
Expand All @@ -10,7 +11,8 @@ const POV_MAX: u64 = 5_242_880 / 2;
#[subxt::subxt(runtime_metadata_path = "metadata/substrate.scale")]
pub mod substrate {}

type SubstrateRuntime = substrate::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>;
type SubstrateRuntime =
substrate::RuntimeApi<DefaultConfig, SubstrateExtrinsicParams<DefaultConfig>>;

#[derive(Debug)]
pub struct BlockStats {
Expand All @@ -29,7 +31,7 @@ impl fmt::Display for BlockStats {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{:04}: PoV Size={:04}KiB({:03}%) Weight={:07}µs({:03}%) Witness={:04}KiB Block={:04}KiB NumExtrinsics={:04}",
"{:04}: PoV Size={:04}KiB({:03}%) Weight={:07}ms({:03}%) Witness={:04}KiB Block={:04}KiB NumExtrinsics={:04}",
self.number,
self.pov_len / 1024,
self.pov_len * 100 / self.max_pov,
Expand Down