mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 09:41:34 +00:00
Debug instance for the gossipsub behaviour (#1673)
* Add debug instances for MessageCache and GossipSub behaviour * Manual impl of Debug for GossipsubMessage * Add pretty printing of protocol_id in debug * Use hex_fmt instead of hex * Inline StringOrBytes helper struct Since it is used only once here * Limit data of gossipsub msg to 20 bytes Otherwise they might become very large and useless for debugging
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
|
||||
use crate::protocol::{GossipsubMessage, MessageId};
|
||||
use crate::topic::TopicHash;
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
/// CacheEntry stored in the history.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
@ -40,6 +40,16 @@ pub struct MessageCache {
|
||||
msg_id: fn(&GossipsubMessage) -> MessageId,
|
||||
}
|
||||
|
||||
impl fmt::Debug for MessageCache {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("MessageCache")
|
||||
.field("msgs", &self.msgs)
|
||||
.field("history", &self.history)
|
||||
.field("gossip", &self.gossip)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of the MessageCache.
|
||||
impl MessageCache {
|
||||
pub fn new(
|
||||
|
Reference in New Issue
Block a user