mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-30 16:37:24 +00:00
Add an RPC request for the state of the network (#1884)
* Add an RPC request for the state of the network * Fix concerns * Fix tests * Replace comment with TODO * Rename the RPC
This commit is contained in:
@@ -60,6 +60,13 @@ pub trait SystemApi<Hash, Number> {
|
||||
/// Returns currently connected peers
|
||||
#[rpc(name = "system_peers")]
|
||||
fn system_peers(&self) -> Result<Vec<PeerInfo<Hash, Number>>>;
|
||||
|
||||
/// Returns current state of the network.
|
||||
///
|
||||
/// **Warning**: This API is not stable.
|
||||
// TODO: make this stable and move structs https://github.com/paritytech/substrate/issues/1890
|
||||
#[rpc(name = "system_networkState")]
|
||||
fn system_network_state(&self) -> Result<network::NetworkState>;
|
||||
}
|
||||
|
||||
/// System API implementation
|
||||
@@ -120,4 +127,8 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
best_number: p.best_number,
|
||||
}).collect())
|
||||
}
|
||||
|
||||
fn system_network_state(&self) -> Result<network::NetworkState> {
|
||||
Ok(self.sync.network_state())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user