massa_models/config/
compact_config.rs

1use super::*;
2use crate::amount::Amount;
3use massa_time::MassaTime;
4use serde::{Deserialize, Serialize};
5use std::fmt::Display;
6
7/// Compact representation of key values of consensus algorithm used in API
8#[derive(Debug, Deserialize, Serialize, Clone, Copy)]
9pub struct CompactConfig {
10    /// Time in milliseconds when the blockclique started.
11    pub genesis_timestamp: MassaTime,
12    /// TESTNET: time when the blockclique is ended.
13    pub end_timestamp: Option<MassaTime>,
14    /// Number of threads
15    pub thread_count: u8,
16    /// Time between the periods in the same thread.
17    pub t0: MassaTime,
18    /// Threshold for fitness.
19    pub delta_f0: u64,
20    /// Maximum operation validity period count
21    pub operation_validity_periods: u64,
22    /// cycle duration in periods
23    pub periods_per_cycle: u64,
24    /// Reward amount for a block creation
25    pub block_reward: Amount,
26    /// Price of a roll on the network
27    pub roll_price: Amount,
28    /// Max total size of a block
29    pub max_block_size: u32,
30}
31
32impl Default for CompactConfig {
33    fn default() -> Self {
34        Self {
35            genesis_timestamp: *GENESIS_TIMESTAMP,
36            end_timestamp: *END_TIMESTAMP,
37            thread_count: THREAD_COUNT,
38            t0: T0,
39            delta_f0: DELTA_F0,
40            operation_validity_periods: OPERATION_VALIDITY_PERIODS,
41            periods_per_cycle: PERIODS_PER_CYCLE,
42            block_reward: BLOCK_REWARD,
43            roll_price: ROLL_PRICE,
44            max_block_size: MAX_BLOCK_SIZE,
45        }
46    }
47}
48
49impl Display for CompactConfig {
50    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51        writeln!(
52            f,
53            "    Genesis time: {}",
54            self.genesis_timestamp.format_instant()
55        )?;
56        if let Some(end) = self.end_timestamp {
57            writeln!(f, "    End time: {}", end.format_instant())?;
58        }
59        writeln!(f, "    Thread count: {}", self.thread_count)?;
60        writeln!(f, "    t0: {}", self.t0)?;
61        writeln!(f, "    delta_f0: {}", self.delta_f0)?;
62        writeln!(
63            f,
64            "    Operation validity periods: {}",
65            self.operation_validity_periods
66        )?;
67        writeln!(f, "    Periods per cycle: {}", self.periods_per_cycle)?;
68        writeln!(f, "    Block reward: {}", self.block_reward)?;
69        writeln!(f, "    Periods per cycle: {}", self.periods_per_cycle)?;
70        writeln!(f, "    Roll price: {}", self.roll_price)?;
71        writeln!(f, "    Max block size (in bytes): {}", self.max_block_size)?;
72        Ok(())
73    }
74}