From 5fe3e4d1918c89acec67a7e327dd1d2b07e24d6d Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:19:15 -0600 Subject: [PATCH] improve: do not remove msg from cache early if the mixnode is connected to the sender in the ordering experiments --- mixnet-rs/protocol/src/node.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mixnet-rs/protocol/src/node.rs b/mixnet-rs/protocol/src/node.rs index 8745044..74dab61 100644 --- a/mixnet-rs/protocol/src/node.rs +++ b/mixnet-rs/protocol/src/node.rs @@ -67,7 +67,11 @@ where } pub fn receive(&mut self, msg: M, from: Option) -> bool { - let first_received = self.check_and_update_cache(msg, false); + // If `from` is None, it means that the message is being sent from the node outside of the gossip network. + // In this case, the received count in the cache must start from 0, so it can be removed from the cache only when it is received from C gossip peers (not C-1). + // For that, we set `sending` to true, as if this node is sending the message. + let sending = from.is_none(); + let first_received = self.check_and_update_cache(msg, sending); if first_received { for (node_id, queue) in self.queues.iter_mut() { match from { @@ -111,7 +115,11 @@ where // If the message have been received from all connected peers, remove it from the cache // because there is no possibility that the message will be received again. if received_msgs.get(&msg).unwrap() == &self.peering_degree { - tracing::debug!("Remove message from cache: {:?}", msg); + tracing::debug!( + "Remove message from cache: {:?} because it has been received {} times, assuming that each inbound peer sent the message once.", + msg, + self.peering_degree + ); received_msgs.remove(&msg); }