Accumulate outbound message counts

This commit is contained in:
Youngjoon Lee 2024-11-08 13:37:28 +07:00
parent 8faafcfb6f
commit f00c560b3e
No known key found for this signature in database
GPG Key ID: 25CA11F37F095E5D
2 changed files with 7 additions and 2 deletions

View File

@ -192,6 +192,7 @@ impl MixNode {
step_id: 0,
data_messages_generated: HashMap::new(),
data_messages_fully_unwrapped: HashMap::new(),
accum_num_inbound_messages: 0,
},
data_msg_lottery_update_time_sender,
data_msg_lottery_interval,
@ -225,8 +226,9 @@ impl MixNode {
}
fn receive(&mut self) -> Vec<NetworkMessage<MixMessage>> {
self.network_interface
.receive_messages()
let received_messages = self.network_interface.receive_messages();
self.state.accum_num_inbound_messages += received_messages.len();
received_messages
.into_iter()
// Retain only messages that have not been seen before
.filter(|msg| self.message_cache.insert(Self::sha256(&msg.payload().0)))

View File

@ -16,8 +16,11 @@ pub struct MixnodeState {
#[serde(serialize_with = "serialize_node_id_as_index")]
pub node_id: NodeId,
pub step_id: usize,
// For latency measurement
pub data_messages_generated: HashMap<PayloadId, usize>,
pub data_messages_fully_unwrapped: HashMap<PayloadId, usize>,
// For anonymity measurement
pub accum_num_inbound_messages: usize,
}
#[derive(Serialize)]