mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-01-07 15:43:09 +00:00
Update config with human readable parsing
This commit is contained in:
parent
a7dc4aa410
commit
a3764d85c3
@ -8,6 +8,7 @@ anyhow = "1.0.93"
|
|||||||
clap = { version = "4.5.20", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
crossbeam = "0.8.4"
|
crossbeam = "0.8.4"
|
||||||
ctrlc = "3.4"
|
ctrlc = "3.4"
|
||||||
|
humantime = "2"
|
||||||
parking_lot = "0.12.3"
|
parking_lot = "0.12.3"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
serde = { version = "1.0.214", features = ["derive"] }
|
serde = { version = "1.0.214", features = ["derive"] }
|
||||||
|
|||||||
@ -38,12 +38,12 @@
|
|||||||
],
|
],
|
||||||
"connected_peers_count": 3,
|
"connected_peers_count": 3,
|
||||||
"data_message_lottery_interval": "20s",
|
"data_message_lottery_interval": "20s",
|
||||||
"stake_proportion": "1.0",
|
"stake_proportion": 1.0,
|
||||||
"epoch_duration": "432000s",
|
"epoch_duration": "432000s",
|
||||||
"slot_duration": "20s",
|
"slot_duration": "20s",
|
||||||
"persistent_transmission": {
|
"persistent_transmission": {
|
||||||
"max_emission_frequency": "1.0",
|
"max_emission_frequency": 1.0,
|
||||||
"drop_message_probability": "0.0"
|
"drop_message_probability": 0.0
|
||||||
},
|
},
|
||||||
"number_of_mix_layers": 4,
|
"number_of_mix_layers": 4,
|
||||||
"max_delay_seconds": 10,
|
"max_delay_seconds": 10,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use netrunner::settings::SimulationSettings;
|
use netrunner::settings::SimulationSettings;
|
||||||
use nomos_mix::persistent_transmission::PersistentTransmissionSettings;
|
use nomos_mix::persistent_transmission::PersistentTransmissionSettings;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Deserializer};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -8,12 +8,23 @@ pub struct SimSettings {
|
|||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub simulation_settings: SimulationSettings,
|
pub simulation_settings: SimulationSettings,
|
||||||
pub connected_peers_count: usize,
|
pub connected_peers_count: usize,
|
||||||
|
#[serde(deserialize_with = "deserialize_duration_with_human_time")]
|
||||||
pub data_message_lottery_interval: Duration,
|
pub data_message_lottery_interval: Duration,
|
||||||
pub stake_proportion: f64,
|
pub stake_proportion: f64,
|
||||||
|
#[serde(deserialize_with = "deserialize_duration_with_human_time")]
|
||||||
pub epoch_duration: Duration,
|
pub epoch_duration: Duration,
|
||||||
|
#[serde(deserialize_with = "deserialize_duration_with_human_time")]
|
||||||
pub slot_duration: Duration,
|
pub slot_duration: Duration,
|
||||||
pub persistent_transmission: PersistentTransmissionSettings,
|
pub persistent_transmission: PersistentTransmissionSettings,
|
||||||
pub number_of_mix_layers: usize,
|
pub number_of_mix_layers: usize,
|
||||||
pub max_delay_seconds: u64,
|
pub max_delay_seconds: u64,
|
||||||
pub slots_per_epoch: usize,
|
pub slots_per_epoch: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn deserialize_duration_with_human_time<'de, D>(deserializer: D) -> Result<Duration, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let s = String::deserialize(deserializer)?;
|
||||||
|
humantime::parse_duration(&s).map_err(serde::de::Error::custom)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user