Skip to content

Commit

Permalink
add missing net_peerCount method
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Jan 8, 2025
1 parent 422d4f7 commit 2cb0295
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions substrate/frame/revive/rpc/src/rpc_health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub trait SystemHealthRpc {
/// Proxy the substrate chain system_health RPC call.
#[method(name = "system_health")]
async fn system_health(&self) -> RpcResult<Health>;

///Returns the number of peers currently connected to the client.
#[method(name = "net_peerCount")]
async fn net_peer_count(&self) -> RpcResult<U64>;
}

pub struct SystemHealthRpcServerImpl {
Expand All @@ -47,4 +51,9 @@ impl SystemHealthRpcServer for SystemHealthRpcServerImpl {
should_have_peers: health.should_have_peers,
})
}

async fn net_peer_count(&self) -> RpcResult<U64> {
let health = self.client.system_health().await?;
Ok((health.peers as u64).into())
}
}

0 comments on commit 2cb0295

Please sign in to comment.