Skip to content

Commit 01b63ba

Browse files
committed
add logs when receiving and sending Rpcs
1 parent 81182dd commit 01b63ba

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

protocols/gossipsub/src/behaviour.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3133,11 +3133,12 @@ where
31333133

31343134
// Try sending the message to the connection handler,
31353135
// High priority messages should not fail.
3136+
tracing::debug!(%peer_id, ?rpc, "Sending Rpc");
31363137
match peer.messages.try_push(rpc) {
31373138
Ok(()) => true,
31383139
Err(rpc) => {
31393140
// Sending failed because the channel is full.
3140-
tracing::warn!(peer=%peer_id, "Send Queue full. Could not send {:?}.", rpc);
3141+
tracing::warn!(%peer_id, ?rpc, "Send Queue full. Could not send Rpc.");
31413142

31423143
// Update failed message counter.
31433144
let failed_messages = self.failed_messages.entry(peer_id).or_default();
@@ -3521,6 +3522,7 @@ where
35213522
invalid_messages,
35223523
} => {
35233524
// Handle the gossipsub RPC
3525+
tracing::debug!(rpc = ?rpc, "Received RPC");
35243526

35253527
// Handle subscriptions
35263528
// Update connected peers topics

protocols/gossipsub/src/types.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub enum PeerKind {
127127
}
128128

129129
/// A message received by the gossipsub system and stored locally in caches..
130-
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
130+
#[derive(Clone, PartialEq, Eq, Hash)]
131131
pub struct RawMessage {
132132
/// Id of the peer that published this message.
133133
pub source: Option<PeerId>,
@@ -151,6 +151,20 @@ pub struct RawMessage {
151151
pub validated: bool,
152152
}
153153

154+
impl std::fmt::Debug for RawMessage {
155+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
156+
f.debug_struct("RawMessage")
157+
.field("source", &self.source)
158+
.field("data length", &self.data.len())
159+
.field("sequence_number", &self.sequence_number)
160+
.field("topic", &self.topic)
161+
.field("signature", &self.signature)
162+
.field("key", &self.key)
163+
.field("validated", &self.validated)
164+
.finish()
165+
}
166+
}
167+
154168
impl PeerKind {
155169
/// Returns true if peer speaks any gossipsub version.
156170
pub(crate) fn is_gossipsub(&self) -> bool {

0 commit comments

Comments
 (0)