From e188b6109cf9fdcc93dbed4fa0bcc78a3e008152 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:46:43 +0700 Subject: [PATCH] Add winning_probability param to replace num_hops in CoverTrafficSettings --- nomos-mix/core/src/cover_traffic.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/nomos-mix/core/src/cover_traffic.rs b/nomos-mix/core/src/cover_traffic.rs index 1451704c..4126a3ae 100644 --- a/nomos-mix/core/src/cover_traffic.rs +++ b/nomos-mix/core/src/cover_traffic.rs @@ -12,13 +12,12 @@ use std::task::{Context, Poll}; #[derive(Copy, Clone, Deserialize)] pub struct CoverTrafficSettings { pub node_id: [u8; 32], - pub number_of_hops: usize, + pub winning_probability: f64, pub slots_per_epoch: usize, pub network_size: usize, } pub struct CoverTraffic { - winning_probability: f64, settings: CoverTrafficSettings, epoch_stream: EpochStream, slot_stream: SlotStream, @@ -36,9 +35,7 @@ where epoch_stream: EpochStream, slot_stream: SlotStream, ) -> Self { - let winning_probability = winning_probability(settings.number_of_hops); CoverTraffic { - winning_probability, settings, epoch_stream, slot_stream, @@ -58,7 +55,6 @@ where fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let Self { - winning_probability, settings, epoch_stream, slot_stream, @@ -71,7 +67,7 @@ where epoch, settings.network_size, settings.slots_per_epoch, - *winning_probability, + settings.winning_probability, ); } if let Poll::Ready(Some(slot)) = slot_stream.poll_next_unpin(cx) { @@ -107,7 +103,3 @@ fn select_slot + Copy>( } w } - -fn winning_probability(number_of_hops: usize) -> f64 { - 1.0 / number_of_hops as f64 -}