Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: ozkanonur <[email protected]>
  • Loading branch information
onur-ozkan committed Aug 7, 2023
1 parent e7c2fd1 commit 6b490f7
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand All @@ -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
);
Expand Down Expand Up @@ -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()
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 6b490f7

Please sign in to comment.