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:
Pierre Krieger
2019-02-28 19:28:38 +01:00
committed by Gav Wood
parent 72b9df8237
commit c21d7436cc
9 changed files with 300 additions and 21 deletions
+11
View File
@@ -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())
}
}