mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-02-18 20:23:06 +00:00
add unified recv_seq
This commit is contained in:
parent
6908979f30
commit
1857f9f05d
@ -1,4 +1,4 @@
|
||||
use std::path::Path;
|
||||
use std::{collections::hash_map::Entry, path::Path};
|
||||
|
||||
use protocol::{
|
||||
node::{MessageId, Node, NodeId},
|
||||
@ -52,6 +52,7 @@ pub fn run_iteration(
|
||||
let mut latencies: FxHashMap<MessageId, f32> = FxHashMap::default();
|
||||
let mut sent_sequence = Sequence::new();
|
||||
let mut received_sequences: FxHashMap<NodeId, Sequence> = FxHashMap::default();
|
||||
let mut unified_received_sequence = Sequence::new();
|
||||
let mut queue_data_msg_counts: Vec<FxHashMap<NodeId, Vec<usize>>> = Vec::new();
|
||||
|
||||
let mut data_msg_rng = StdRng::seed_from_u64(seed);
|
||||
@ -111,7 +112,11 @@ pub fn run_iteration(
|
||||
Message::Data(msg) => {
|
||||
// If msg was sent by the sender (not by any mix)
|
||||
if let Some(&sent_time) = sent_times.get(&msg) {
|
||||
latencies.entry(msg).or_insert(vtime - sent_time);
|
||||
// If this is the first time to see the msg
|
||||
if let Entry::Vacant(e) = latencies.entry(msg) {
|
||||
e.insert(vtime - sent_time);
|
||||
unified_received_sequence.add_message(msg);
|
||||
}
|
||||
received_sequences
|
||||
.entry(sender_id)
|
||||
.or_insert(Sequence::new())
|
||||
@ -155,6 +160,10 @@ pub fn run_iteration(
|
||||
// Save results to CSV files
|
||||
save_latencies(&latencies, &sent_times, out_latency_path);
|
||||
save_sequence(&sent_sequence, out_sent_sequence_path);
|
||||
save_sequence(
|
||||
&unified_received_sequence,
|
||||
format!("{out_received_sequence_path_prefix}_unified.csv").as_str(),
|
||||
);
|
||||
save_sequences(&received_sequences, out_received_sequence_path_prefix);
|
||||
save_queue_data_msg_counts(
|
||||
&queue_data_msg_counts,
|
||||
@ -163,13 +172,19 @@ pub fn run_iteration(
|
||||
);
|
||||
// Calculate ordering coefficients and save them to a CSV file.
|
||||
if paramset.queue_type != QueueType::NonMix {
|
||||
let mut coeffs: Vec<[u64; 2]> = Vec::new();
|
||||
for (_, recv_seq) in received_sequences.iter() {
|
||||
let casual = sent_sequence.ordering_coefficient(recv_seq, true);
|
||||
let weak = sent_sequence.ordering_coefficient(recv_seq, false);
|
||||
coeffs.push([casual, weak]);
|
||||
if !paramset.random_topology {
|
||||
let mut coeffs: Vec<[u64; 2]> = Vec::new();
|
||||
for (_, recv_seq) in received_sequences.iter() {
|
||||
let casual = sent_sequence.ordering_coefficient(recv_seq, true);
|
||||
let weak = sent_sequence.ordering_coefficient(recv_seq, false);
|
||||
coeffs.push([casual, weak]);
|
||||
}
|
||||
save_ordering_coefficients(&coeffs, out_ordering_coeff_path);
|
||||
} else {
|
||||
let casual = sent_sequence.ordering_coefficient(&unified_received_sequence, true);
|
||||
let weak = sent_sequence.ordering_coefficient(&unified_received_sequence, false);
|
||||
save_ordering_coefficients(&[[casual, weak]], out_ordering_coeff_path);
|
||||
}
|
||||
save_ordering_coefficients(&coeffs, out_ordering_coeff_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user