Update PeerSet metrics after every change (#1727)

This commit is contained in:
teor 2021-02-18 07:06:59 +10:00 committed by GitHub
parent 972103d797
commit 86169f6412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -446,6 +446,7 @@ where
trace!("preselected service was not ready, reselecting");
self.preselected_p2c_index = self.preselect_p2c_index();
self.update_metrics();
if self.preselected_p2c_index.is_none() {
trace!("no ready services, sending demand signal");
@ -456,7 +457,7 @@ where
}
fn call(&mut self, req: Request) -> Self::Future {
match req {
let fut = match req {
// Only do inventory-aware routing on individual items.
Request::BlocksByHash(ref hashes) if hashes.len() == 1 => {
let hash = InventoryHash::from(*hashes.iter().next().unwrap());
@ -469,6 +470,9 @@ where
Request::AdvertiseTransactions(_) => self.route_all(req),
Request::AdvertiseBlock(_) => self.route_all(req),
_ => self.route_p2c(req),
}
};
self.update_metrics();
fut
}
}