1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::time::SystemTime;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct NodeStatsDto {
    pub version: String,
    pub state: NodeState,
    #[serde(flatten)]
    pub stats: Option<NodeStats>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct NodeStats {
    pub block_recv_cnt: u64,
    pub last_block_content_size: u32,
    pub last_block_date: Option<String>,
    pub last_block_fees: u64,
    pub last_block_hash: Option<String>,
    pub last_block_height: Option<String>,
    pub last_block_sum: u64,
    pub last_block_time: Option<SystemTime>,
    pub last_block_tx: u64,
    pub last_received_block_time: Option<SystemTime>,
    pub block_content_size_avg: f64,
    pub peer_available_cnt: usize,
    pub peer_connected_cnt: usize,
    pub peer_quarantined_cnt: usize,
    pub peer_total_cnt: usize,
    pub tx_recv_cnt: u64,
    pub mempool_usage_ratio: f64,
    pub mempool_tx_count: u64,
    pub tx_rejected_cnt: u64,
    pub votes_cast: u64,
    pub uptime: Option<u64>,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub enum NodeState {
    StartingRestServer,
    PreparingStorage,
    PreparingBlock0,
    Bootstrapping,
    StartingWorkers,
    Running,
}