Bläddra i källkod

map: moved NodeInfo to own crate

lunar-mining 4 år sedan
förälder
incheckning
828535a812
1 ändrade filer med 30 tillägg och 0 borttagningar
  1. 30 0
      bin/map/src/node_info.rs

+ 30 - 0
bin/map/src/node_info.rs

@@ -0,0 +1,30 @@
+//TODO: made node_id into a HashSet(u32)
+// wrap NodeInfo and NodeId in a Mutex
+
+pub type NodeId = u32;
+
+#[derive(Clone)]
+pub struct NodeInfo {
+    pub id: String,
+    pub connections: usize,
+    pub is_active: bool,
+    pub last_message: String,
+}
+
+impl NodeInfo {
+    pub fn new() -> NodeInfo {
+        let connections = 0;
+        let is_active = false;
+        NodeInfo { id: String::new(), connections, is_active, last_message: String::new() }
+    }
+}
+
+impl Default for NodeInfo {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+//pub async fn add_seen(&self, id: u32) {
+//    self.privmsg_ids.lock().await.insert(id);
+//}