gnostr_crawler/
stats.rs

1/// Keep track of some stats: count encountered event, time of last event, etc.
2pub struct Stats {
3    /// Count of Contact events seen
4    pub count_contacts: u64,
5    /// Count of Relay events seen
6    pub count_relays: u64,
7}
8
9impl Default for Stats {
10    fn default() -> Self {
11        Self::new()
12    }
13}
14
15impl Stats {
16    pub fn new() -> Self {
17        Stats {
18            count_contacts: 0,
19            count_relays: 0,
20        }
21    }
22
23    pub fn add_contacts(&mut self) {
24        self.count_contacts += 1;
25    }
26
27    pub fn add_relays(&mut self) {
28        self.count_relays += 1;
29    }
30
31    // pub fn print_summary(&self) {
32    //     println!("ev_cnts {} {} \t ", self.count_contacts, self.count_relays);
33    // }
34}