use super::*;
use crate::amount::Amount;
use massa_time::MassaTime;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
#[derive(Debug, Deserialize, Serialize, Clone, Copy)]
pub struct CompactConfig {
pub genesis_timestamp: MassaTime,
pub end_timestamp: Option<MassaTime>,
pub thread_count: u8,
pub t0: MassaTime,
pub delta_f0: u64,
pub operation_validity_periods: u64,
pub periods_per_cycle: u64,
pub block_reward: Amount,
pub roll_price: Amount,
pub max_block_size: u32,
}
impl Default for CompactConfig {
fn default() -> Self {
Self {
genesis_timestamp: *GENESIS_TIMESTAMP,
end_timestamp: *END_TIMESTAMP,
thread_count: THREAD_COUNT,
t0: T0,
delta_f0: DELTA_F0,
operation_validity_periods: OPERATION_VALIDITY_PERIODS,
periods_per_cycle: PERIODS_PER_CYCLE,
block_reward: BLOCK_REWARD,
roll_price: ROLL_PRICE,
max_block_size: MAX_BLOCK_SIZE,
}
}
}
impl Display for CompactConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(
f,
" Genesis time: {}",
self.genesis_timestamp.format_instant()
)?;
if let Some(end) = self.end_timestamp {
writeln!(f, " End time: {}", end.format_instant())?;
}
writeln!(f, " Thread count: {}", self.thread_count)?;
writeln!(f, " t0: {}", self.t0)?;
writeln!(f, " delta_f0: {}", self.delta_f0)?;
writeln!(
f,
" Operation validity periods: {}",
self.operation_validity_periods
)?;
writeln!(f, " Periods per cycle: {}", self.periods_per_cycle)?;
writeln!(f, " Block reward: {}", self.block_reward)?;
writeln!(f, " Periods per cycle: {}", self.periods_per_cycle)?;
writeln!(f, " Roll price: {}", self.roll_price)?;
writeln!(f, " Max block size (in bytes): {}", self.max_block_size)?;
Ok(())
}
}