From 6782f8e9f6febfaa4875a737615dc19c75430a80 Mon Sep 17 00:00:00 2001 From: Dastan-glitch Date: Sun, 4 Jun 2023 03:54:20 +0300 Subject: [PATCH] event_graph: remove unused UnreadEvents struct --- src/event_graph/protocol_event.rs | 47 ++----------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/src/event_graph/protocol_event.rs b/src/event_graph/protocol_event.rs index 2bf12bc75..53d1c6b00 100644 --- a/src/event_graph/protocol_event.rs +++ b/src/event_graph/protocol_event.rs @@ -16,10 +16,7 @@ * along with this program. If not, see . */ -use std::{ - collections::{HashMap, VecDeque}, - fmt::Debug, -}; +use std::{collections::VecDeque, fmt::Debug}; use async_std::sync::{Arc, Mutex}; use async_trait::async_trait; @@ -31,11 +28,10 @@ use super::EventMsg; use crate::{ event_graph::model::{Event, EventId, ModelPtr}, net, - util::{async_util::sleep, time::Timestamp}, + util::async_util::sleep, Result, }; -const UNREAD_EVENT_EXPIRE_TIME: u64 = 3600; // in seconds const SIZE_OF_SEEN_BUFFER: usize = 65536; // const MAX_CONFIRM: u8 = 3; @@ -106,45 +102,6 @@ impl Seen { } } -pub type UnreadEventsPtr = Arc>>; - -#[derive(Debug)] -pub struct UnreadEvents { - pub events: HashMap>, -} - -impl UnreadEvents -where - T: Send + Sync + Encodable + Decodable + Clone + EventMsg, -{ - pub fn new() -> UnreadEventsPtr { - Arc::new(Mutex::new(Self { events: HashMap::new() })) - } - - fn _contains(&self, key: &EventId) -> bool { - self.events.contains_key(key) - } - - fn _get(&self, key: &EventId) -> Option> { - self.events.get(key).cloned() - } - - pub fn insert(&mut self, event: &Event) { - // prune expired events - let mut prune_ids = vec![]; - for (id, e) in self.events.iter() { - if e.timestamp.0 + (UNREAD_EVENT_EXPIRE_TIME * 1000) < Timestamp::current_time().0 { - prune_ids.push(*id); - } - } - for id in prune_ids { - self.events.remove(&id); - } - - self.events.insert(event.hash(), event.clone()); - } -} - pub struct ProtocolEvent where T: Send + Sync + Encodable + Decodable + Debug + 'static,