From 7492be95fbba1ce8b41aca643ac05b7a99535f30 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Wed, 15 May 2024 17:21:31 +0900 Subject: [PATCH] yield 0 in the broadcast func --- mixnet/v2/sim/p2p.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mixnet/v2/sim/p2p.py b/mixnet/v2/sim/p2p.py index 452aff7..22fb013 100644 --- a/mixnet/v2/sim/p2p.py +++ b/mixnet/v2/sim/p2p.py @@ -19,7 +19,10 @@ class P2p: self.log("Broadcasting a msg: %d bytes" % len(msg)) self.message_sizes.append(len(msg)) - yield self.env.timeout(1) + # Yield 0 to ensure that the broadcast is done in the same time step. + # Without this, SimPy complains that the broadcast func is not a generator. + yield self.env.timeout(0) + # TODO: gossipsub or something similar for node in self.nodes: self.env.process(node.receive_message(msg))