(most of) parity RPC for light client

This commit is contained in:
Robert Habermeier
2017-02-17 21:38:43 +01:00
parent 3b023c82b7
commit 9316eb4ad3
11 changed files with 587 additions and 89 deletions

View File

@@ -322,6 +322,16 @@ impl LightProtocol {
.map(|peer| peer.lock().status.clone())
}
/// Get number of (connected, active) peers.
pub fn peer_count(&self) -> (usize, usize) {
let num_pending = self.pending_peers.read().len();
let peers = self.peers.read();
(
num_pending + peers.len(),
peers.values().filter(|p| !p.lock().pending_requests.is_empty()).count(),
)
}
/// Check the maximum amount of requests of a specific type
/// which a peer would be able to serve. Returns zero if the
/// peer is unknown or has no buffer flow parameters.