mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 22:31:33 +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:
@ -232,7 +232,11 @@ impl GossipsubConfigBuilder {
|
||||
impl std::fmt::Debug for GossipsubConfig {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut builder = f.debug_struct("GossipsubConfig");
|
||||
let _ = builder.field("protocol_id", &self.protocol_id);
|
||||
let _ = if let Ok(text) = std::str::from_utf8(&self.protocol_id) {
|
||||
builder.field("protocol_id", &text)
|
||||
} else {
|
||||
builder.field("protocol_id", &hex_fmt::HexFmt(&self.protocol_id))
|
||||
};
|
||||
let _ = builder.field("history_length", &self.history_length);
|
||||
let _ = builder.field("history_gossip", &self.history_gossip);
|
||||
let _ = builder.field("mesh_n", &self.mesh_n);
|
||||
|
Reference in New Issue
Block a user