From 6b490f7138ad4e32363993eb26874aaec55fcc48 Mon Sep 17 00:00:00 2001 From: ozkanonur Date: Mon, 7 Aug 2023 13:15:53 +0300 Subject: [PATCH] test Signed-off-by: ozkanonur --- protocols/gossipsub/src/behaviour.rs | 34 +++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index aa9190be6fbb..995251adcb82 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -681,7 +681,7 @@ where .outbound_transform(&topic, data.clone())?; let mut raw_message = self.build_raw_message(topic, transformed_data)?; - raw_message.source = Some(source); + // raw_message.source = Some(source); // calculate the message id from the un-transformed data let msg_id = self.config.message_id(&Message { @@ -1769,6 +1769,7 @@ where mut raw_message: RawMessage, propagation_source: &PeerId, ) { + println!("ARE WE GETTING IT?"); // Record the received metric if let Some(metrics) = self.metrics.as_mut() { metrics.msg_recvd_unfiltered(&raw_message.topic, raw_message.raw_protobuf_len()); @@ -1869,7 +1870,7 @@ where // Dispatch the message to the user if we are subscribed to any of the topics if self.mesh.contains_key(&message.topic) || self.is_relay() { - debug!("Sending received message to user"); + log::info!("Sending received message to user"); self.events .push_back(ToSwarm::GenerateEvent(Event::Message { propagation_source: *propagation_source, @@ -1878,14 +1879,14 @@ where })); } else { if !self.is_relay() { - debug!( + log::info!( "Received message on a topic we are not subscribed to: {:?}", message.topic ); return; } - debug!( + log::info!( "Received message as relay node on topic: {:?}", message.topic ); @@ -2752,9 +2753,8 @@ where let mut recipient_peers = HashSet::new(); if self.config.i_am_relay { - let topic = &message.topic; // relay simply forwards the message to topic peers that included the relay to their relays mesh - if let Some(topic_peers) = self.topic_peers.get(topic) { + if let Some(topic_peers) = self.topic_peers.get(&message.topic) { for peer_id in topic_peers { if Some(peer_id) != propagation_source && Some(peer_id) != message.source.as_ref() @@ -2764,18 +2764,16 @@ where } } } - } else { - // add mesh peers - let topic = &message.topic; - // mesh - if let Some(mesh_peers) = self.mesh.get(topic) { - for peer_id in mesh_peers { - if Some(peer_id) != propagation_source - && !originating_peers.contains(peer_id) - && Some(peer_id) != message.source.as_ref() - { - recipient_peers.insert(*peer_id); - } + } + + // add mesh peers + if let Some(mesh_peers) = self.mesh.get(&message.topic) { + for peer_id in mesh_peers { + if Some(peer_id) != propagation_source + && !originating_peers.contains(peer_id) + && Some(peer_id) != message.source.as_ref() + { + recipient_peers.insert(*peer_id); } } }