1use crate::slot::Slot;
4use massa_time::MassaTime;
5use serde::{Deserialize, Serialize};
6use std::fmt::Formatter;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ExecutionStats {
11 pub time_window_start: MassaTime,
13 pub time_window_end: MassaTime,
15 pub final_block_count: usize,
17 pub final_executed_operations_count: usize,
19 pub active_cursor: Slot,
21 pub final_cursor: Slot,
23}
24
25impl std::fmt::Display for ExecutionStats {
26 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
27 writeln!(f, "Execution stats:")?;
28 writeln!(
29 f,
30 "\tStart stats timespan time: {}",
31 self.time_window_start.format_instant()
32 )?;
33 writeln!(
34 f,
35 "\tEnd stats timespan time: {}",
36 self.time_window_end.format_instant()
37 )?;
38 writeln!(
39 f,
40 "\tFinal executed block count: {}",
41 self.final_block_count
42 )?;
43 writeln!(
44 f,
45 "\tFinal executed operation count: {}",
46 self.final_executed_operations_count
47 )?;
48 writeln!(f, "\tActive cursor: {}", self.active_cursor)?;
49 writeln!(f, "\tFinal cursor: {}", self.final_cursor)?;
50 Ok(())
51 }
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct NetworkStats {
57 pub in_connection_count: u64,
59 pub out_connection_count: u64,
61 pub known_peer_count: u64,
63 pub banned_peer_count: u64,
65 pub active_node_count: u64,
67}
68
69impl std::fmt::Display for NetworkStats {
70 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
71 writeln!(f, "Network stats:")?;
72 writeln!(f, "\tIn connections: {}", self.in_connection_count)?;
73 writeln!(f, "\tOut connections: {}", self.out_connection_count)?;
74 writeln!(f, "\tKnown peers: {}", self.known_peer_count)?;
75 writeln!(f, "\tBanned peers: {}", self.banned_peer_count)?;
76 writeln!(f, "\tActive nodes: {}", self.active_node_count)?;
77 Ok(())
78 }
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct ConsensusStats {
84 pub start_timespan: MassaTime,
86 pub end_timespan: MassaTime,
88 pub final_block_count: u64,
90 pub stale_block_count: u64,
92 pub clique_count: u64,
94}
95
96impl std::fmt::Display for ConsensusStats {
97 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
98 writeln!(f, "Consensus stats:")?;
99 writeln!(
100 f,
101 "\tStart stats timespan time: {}",
102 self.start_timespan.format_instant()
103 )?;
104 writeln!(
105 f,
106 "\tEnd stats timespan time: {}",
107 self.end_timespan.format_instant()
108 )?;
109 writeln!(f, "\tFinal block count: {}", self.final_block_count)?;
110 writeln!(f, "\tStale block count: {}", self.stale_block_count)?;
111 writeln!(f, "\tClique count: {}", self.clique_count)?;
112 Ok(())
113 }
114}
115
116#[derive(Serialize, Deserialize, Debug)]
118pub struct PoolStats {
119 pub operation_count: u64,
121 pub endorsement_count: u64,
123}
124
125impl std::fmt::Display for PoolStats {
126 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
127 writeln!(f, "Pool stats:")?;
128 writeln!(f, "\tOperations: {}", self.operation_count)?;
129 writeln!(f, "\tEndorsements: {}", self.endorsement_count)?;
130 Ok(())
131 }
132}