Merge branch 'master' into remote-tx-exec
This commit is contained in:
@@ -329,6 +329,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 credit parameters.
|
||||
|
||||
@@ -111,6 +111,14 @@ impl RequestSet {
|
||||
pub fn collect_ids<F>(&self) -> F where F: FromIterator<ReqId> {
|
||||
self.ids.keys().cloned().collect()
|
||||
}
|
||||
|
||||
/// Number of requests in the set.
|
||||
pub fn len(&self) -> usize {
|
||||
self.ids.len()
|
||||
}
|
||||
|
||||
/// Whether the set is empty.
|
||||
pub fn is_empty(&self) -> bool { self.len() == 0 }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user