use std::collections::{HashMap, HashSet}; use std::sync::OnceLock; use nostr_sdk::prelude::*; static INITIALIZED_AT: OnceLock = OnceLock::new(); pub fn initialized_at() -> &'static Timestamp { INITIALIZED_AT.get_or_init(Timestamp::now) } #[derive(Debug, Clone, Default)] pub struct EventTracker { /// Tracking events that have been resent by Coop in the current session pub resent_ids: Vec>, /// Temporarily store events that need to be resent later pub resend_queue: HashMap, /// Tracking events sent by Coop in the current session pub sent_ids: HashSet, /// Tracking events seen on which relays in the current session pub seen_on_relays: HashMap>, } impl EventTracker { pub fn resent_ids(&self) -> &Vec> { &self.resent_ids } pub fn resend_queue(&self) -> &HashMap { &self.resend_queue } pub fn sent_ids(&self) -> &HashSet { &self.sent_ids } pub fn seen_on_relays(&self) -> &HashMap> { &self.seen_on_relays } }