소스 검색

event_graph: remove unused UnreadEvents struct

Dastan-glitch 3 년 전
부모
커밋
6782f8e9f6
1개의 변경된 파일2개의 추가작업 그리고 45개의 파일을 삭제
  1. 2 45
      src/event_graph/protocol_event.rs

+ 2 - 45
src/event_graph/protocol_event.rs

@@ -16,10 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
 
 
-use std::{
-    collections::{HashMap, VecDeque},
-    fmt::Debug,
-};
+use std::{collections::VecDeque, fmt::Debug};
 
 
 use async_std::sync::{Arc, Mutex};
 use async_std::sync::{Arc, Mutex};
 use async_trait::async_trait;
 use async_trait::async_trait;
@@ -31,11 +28,10 @@ use super::EventMsg;
 use crate::{
 use crate::{
     event_graph::model::{Event, EventId, ModelPtr},
     event_graph::model::{Event, EventId, ModelPtr},
     net,
     net,
-    util::{async_util::sleep, time::Timestamp},
+    util::async_util::sleep,
     Result,
     Result,
 };
 };
 
 
-const UNREAD_EVENT_EXPIRE_TIME: u64 = 3600; // in seconds
 const SIZE_OF_SEEN_BUFFER: usize = 65536;
 const SIZE_OF_SEEN_BUFFER: usize = 65536;
 // const MAX_CONFIRM: u8 = 3;
 // const MAX_CONFIRM: u8 = 3;
 
 
@@ -106,45 +102,6 @@ impl<T: Eq + PartialEq + Clone> Seen<T> {
     }
     }
 }
 }
 
 
-pub type UnreadEventsPtr<T> = Arc<Mutex<UnreadEvents<T>>>;
-
-#[derive(Debug)]
-pub struct UnreadEvents<T: Send + Sync> {
-    pub events: HashMap<EventId, Event<T>>,
-}
-
-impl<T> UnreadEvents<T>
-where
-    T: Send + Sync + Encodable + Decodable + Clone + EventMsg,
-{
-    pub fn new() -> UnreadEventsPtr<T> {
-        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<Event<T>> {
-        self.events.get(key).cloned()
-    }
-
-    pub fn insert(&mut self, event: &Event<T>) {
-        // 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<T>
 pub struct ProtocolEvent<T>
 where
 where
     T: Send + Sync + Encodable + Decodable + Debug + 'static,
     T: Send + Sync + Encodable + Decodable + Debug + 'static,