protocols/gossipsub: Reduce log levels (#2101)

This commit is contained in:
David Craven
2021-06-12 08:11:55 +02:00
committed by GitHub
parent f874417562
commit d45606ac97
3 changed files with 18 additions and 14 deletions

View File

@ -2,6 +2,10 @@
- Update dependencies. - Update dependencies.
- Reduce log levels across the crate to lessen noisiness of libp2p-gossipsub (see [PR 2101]).
[PR 2101]: https://github.com/libp2p/rust-libp2p/pull/2101
# 0.31.0 [2021-05-17] # 0.31.0 [2021-05-17]
- Keep connections to peers in a mesh alive. Allow closing idle connections to peers not in a mesh - Keep connections to peers in a mesh alive. Allow closing idle connections to peers not in a mesh

View File

@ -31,7 +31,7 @@ use std::{
}; };
use futures::StreamExt; use futures::StreamExt;
use log::{debug, error, info, trace, warn}; use log::{debug, error, trace, warn};
use prost::Message; use prost::Message;
use rand::{seq::SliceRandom, thread_rng}; use rand::{seq::SliceRandom, thread_rng};
use wasm_timer::{Instant, Interval}; use wasm_timer::{Instant, Interval};
@ -509,7 +509,7 @@ where
// call JOIN(topic) // call JOIN(topic)
// this will add new peers to the mesh for the topic // this will add new peers to the mesh for the topic
self.join(&topic_hash); self.join(&topic_hash);
info!("Subscribed to topic: {}", topic); debug!("Subscribed to topic: {}", topic);
Ok(true) Ok(true)
} }
@ -549,7 +549,7 @@ where
// this will remove the topic from the mesh // this will remove the topic from the mesh
self.leave(&topic_hash); self.leave(&topic_hash);
info!("Unsubscribed from topic: {:?}", topic_hash); debug!("Unsubscribed from topic: {:?}", topic_hash);
Ok(true) Ok(true)
} }
@ -700,7 +700,7 @@ where
self.send_message(*peer_id, event.clone())?; self.send_message(*peer_id, event.clone())?;
} }
info!("Published message: {:?}", &msg_id); debug!("Published message: {:?}", &msg_id);
Ok(msg_id) Ok(msg_id)
} }
@ -860,7 +860,7 @@ where
// if we are already in the mesh, return // if we are already in the mesh, return
if self.mesh.contains_key(topic_hash) { if self.mesh.contains_key(topic_hash) {
info!("JOIN: The topic is already in the mesh, ignoring JOIN"); debug!("JOIN: The topic is already in the mesh, ignoring JOIN");
return; return;
} }
@ -931,7 +931,7 @@ where
for peer_id in added_peers { for peer_id in added_peers {
// Send a GRAFT control message // Send a GRAFT control message
info!("JOIN: Sending Graft message to peer: {:?}", peer_id); debug!("JOIN: Sending Graft message to peer: {:?}", peer_id);
if let Some((peer_score, ..)) = &mut self.peer_score { if let Some((peer_score, ..)) = &mut self.peer_score {
peer_score.graft(&peer_id, topic_hash.clone()); peer_score.graft(&peer_id, topic_hash.clone());
} }
@ -1020,7 +1020,7 @@ where
if let Some((_, peers)) = self.mesh.remove_entry(topic_hash) { if let Some((_, peers)) = self.mesh.remove_entry(topic_hash) {
for peer in peers { for peer in peers {
// Send a PRUNE control message // Send a PRUNE control message
info!("LEAVE: Sending PRUNE to peer: {:?}", peer); debug!("LEAVE: Sending PRUNE to peer: {:?}", peer);
let control = self.make_prune(topic_hash, &peer, self.config.do_px()); let control = self.make_prune(topic_hash, &peer, self.config.do_px());
Self::control_pool_add(&mut self.control_pool, peer, control); Self::control_pool_add(&mut self.control_pool, peer, control);
@ -1316,7 +1316,7 @@ where
} }
// add peer to the mesh // add peer to the mesh
info!( debug!(
"GRAFT: Mesh link added for peer: {:?} in topic: {:?}", "GRAFT: Mesh link added for peer: {:?} in topic: {:?}",
peer_id, &topic_hash peer_id, &topic_hash
); );
@ -1354,7 +1354,7 @@ where
.map(|t| self.make_prune(t, peer_id, do_px)) .map(|t| self.make_prune(t, peer_id, do_px))
.collect(); .collect();
// Send the prune messages to the peer // Send the prune messages to the peer
info!( debug!(
"GRAFT: Not subscribed to topics - Sending PRUNE to peer: {}", "GRAFT: Not subscribed to topics - Sending PRUNE to peer: {}",
peer_id peer_id
); );
@ -1388,7 +1388,7 @@ where
if let Some(peers) = self.mesh.get_mut(&topic_hash) { if let Some(peers) = self.mesh.get_mut(&topic_hash) {
// remove the peer if it exists in the mesh // remove the peer if it exists in the mesh
if peers.remove(peer_id) { if peers.remove(peer_id) {
info!( debug!(
"PRUNE: Removing peer: {} from the mesh for topic: {}", "PRUNE: Removing peer: {} from the mesh for topic: {}",
peer_id.to_string(), peer_id.to_string(),
topic_hash topic_hash
@ -1827,7 +1827,7 @@ where
} }
GossipsubSubscriptionAction::Unsubscribe => { GossipsubSubscriptionAction::Unsubscribe => {
if peer_list.remove(propagation_source) { if peer_list.remove(propagation_source) {
info!( debug!(
"SUBSCRIPTION: Removing gossip peer: {} from topic: {:?}", "SUBSCRIPTION: Removing gossip peer: {} from topic: {:?}",
propagation_source.to_string(), propagation_source.to_string(),
subscription.topic_hash subscription.topic_hash
@ -2815,7 +2815,7 @@ where
return; return;
} }
info!("New peer connected: {}", peer_id); debug!("New peer connected: {}", peer_id);
// We need to send our subscriptions to the newly-connected node. // We need to send our subscriptions to the newly-connected node.
let mut subscriptions = vec![]; let mut subscriptions = vec![];
for topic_hash in self.mesh.keys() { for topic_hash in self.mesh.keys() {

View File

@ -20,7 +20,7 @@
use crate::types::GossipsubSubscription; use crate::types::GossipsubSubscription;
use crate::TopicHash; use crate::TopicHash;
use log::info; use log::debug;
use std::collections::{BTreeSet, HashMap, HashSet}; use std::collections::{BTreeSet, HashMap, HashSet};
pub trait TopicSubscriptionFilter { pub trait TopicSubscriptionFilter {
@ -66,7 +66,7 @@ pub trait TopicSubscriptionFilter {
if self.allow_incoming_subscription(s) { if self.allow_incoming_subscription(s) {
true true
} else { } else {
info!("Filtered incoming subscription {:?}", s); debug!("Filtered incoming subscription {:?}", s);
false false
} }
}); });