Skip to content

Commit

Permalink
update log to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
t-botclive committed May 1, 2024
1 parent e3ea0b2 commit 5133ebb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/p2p/p2p-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use std::time::Duration;
use tracing::{error, info, warn};
use tracing::{debug, error, info, warn};

use crate::config::P2pConfig;

Expand Down Expand Up @@ -170,48 +170,48 @@ where
match result {
kad::QueryResult::GetProviders(Ok(kad::GetProvidersOk::FoundProviders { key, providers, .. })) => {
for peer in providers {
println!(
debug!(
"KAD: Peer {peer:?} provides key {:?}",
std::str::from_utf8(key.as_ref()).unwrap()
);
}
}
kad::QueryResult::GetProviders(Err(err)) => {
println!("KAD: Failed to get providers: {err:?}");
debug!("KAD: Failed to get providers: {err:?}");
}
kad::QueryResult::GetRecord(Ok(
kad::GetRecordOk::FoundRecord(kad::PeerRecord {
record: kad::Record { key, value, .. },
..
})
)) => {
println!(
debug!(
"KAD: Got record {:?} {:?}",
std::str::from_utf8(key.as_ref()).unwrap(),
std::str::from_utf8(&value).unwrap(),
);
}
kad::QueryResult::GetRecord(Ok(_)) => {}
kad::QueryResult::GetRecord(Err(err)) => {
println!("KAD: Failed to get record: {err:?}");
debug!("KAD: Failed to get record: {err:?}");
}
kad::QueryResult::PutRecord(Ok(kad::PutRecordOk { key })) => {
println!(
debug!(
"KAD: Successfully put record {:?}",
std::str::from_utf8(key.as_ref()).unwrap()
);
}
kad::QueryResult::PutRecord(Err(err)) => {
println!("KAD: Failed to put record: {err:?}");
debug!("KAD: Failed to put record: {err:?}");
}
kad::QueryResult::StartProviding(Ok(kad::AddProviderOk { key })) => {
println!(
debug!(
"KAD: Successfully put provider record {:?}",
std::str::from_utf8(key.as_ref()).unwrap()
);
}
kad::QueryResult::StartProviding(Err(err)) => {
println!("KAD: Failed to put provider record: {err:?}");
debug!("KAD: Failed to put provider record: {err:?}");
}
_ => {}
}
Expand All @@ -223,7 +223,7 @@ where
message,
})) => {
// TODO: when message is received - verify topic inside message.topic to be of a valid one
println!("GOSSIP: Received gossipsub message. peer {}, id {}, data {}", peer_id, id, std::str::from_utf8(&message.data).unwrap());
debug!("GOSSIP: Received gossipsub message. peer {}, id {}, data {}", peer_id, id, std::str::from_utf8(&message.data).unwrap());

// first validate that received message is received from the right topic
if message.topic != self.topic.hash() {
Expand All @@ -236,7 +236,7 @@ where
peer_id,
topic,
})) => {
println!("GOSSIP: New peer subscribed to topic. peer {}, topic {}", peer_id, topic);
debug!("GOSSIP: New peer subscribed to topic. peer {}, topic {}", peer_id, topic);

// if connected peer is not a boot node and the topic is wrong - disconnect from it
if !self.is_boot_node(&peer_id) && topic != self.topic.hash() {
Expand Down

0 comments on commit 5133ebb

Please sign in to comment.