diff --git a/subxt/src/rpc.rs b/subxt/src/rpc.rs index dd95146476..b606c1964d 100644 --- a/subxt/src/rpc.rs +++ b/subxt/src/rpc.rs @@ -222,6 +222,20 @@ pub struct BlockStats { pub num_extrinsics: u64, } +/// Health struct returned by the RPC +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Health { + /// Number of connected peers + pub peers: usize, + /// Is the node syncing + pub is_syncing: bool, + /// Should this node have any peers + /// + /// Might be false for local chains or when running without discovery. + pub should_have_peers: bool, +} + /// Client for substrate rpc interfaces pub struct Rpc { /// Rpc client for sending requests. @@ -329,6 +343,11 @@ impl Rpc { .await?) } + /// Fetch system health + pub async fn system_health(&self) -> Result { + Ok(self.client.request("system_health", rpc_params![]).await?) + } + /// Fetch system chain pub async fn system_chain(&self) -> Result { Ok(self.client.request("system_chain", rpc_params![]).await?)