Просмотр исходного кода

dnetview: add timestamp to msg log

lunar-mining 4 лет назад
Родитель
Сommit
0d5e1930e7
3 измененных файлов с 13 добавлено и 13 удалено
  1. 4 4
      bin/dnetview/src/main.rs
  2. 4 4
      bin/dnetview/src/model.rs
  3. 5 5
      bin/dnetview/src/view.rs

+ 4 - 4
bin/dnetview/src/main.rs

@@ -304,9 +304,9 @@ async fn parse_inbound(inbound: &Value, node_id: &String) -> DnetViewResult<Sess
                         let state = "state".to_string();
                         let state = "state".to_string();
                         let parent = parent.clone();
                         let parent = parent.clone();
                         let msg_values = node.unwrap().get("log").unwrap().as_array().unwrap();
                         let msg_values = node.unwrap().get("log").unwrap().as_array().unwrap();
-                        let mut msg_log: Vec<(String, String)> = Vec::new();
+                        let mut msg_log: Vec<(u64, String, String)> = Vec::new();
                         for msg in msg_values {
                         for msg in msg_values {
-                            let msg: (String, String) = serde_json::from_value(msg.clone())?;
+                            let msg: (u64, String, String) = serde_json::from_value(msg.clone())?;
                             msg_log.push(msg);
                             msg_log.push(msg);
                         }
                         }
                         let is_empty = false;
                         let is_empty = false;
@@ -411,9 +411,9 @@ async fn parse_outbound(outbound: &Value, node_id: &String) -> DnetViewResult<Se
                         let state = state.as_str().unwrap().to_string();
                         let state = state.as_str().unwrap().to_string();
                         let parent = parent.clone();
                         let parent = parent.clone();
                         let msg_values = channel["log"].as_array().unwrap();
                         let msg_values = channel["log"].as_array().unwrap();
-                        let mut msg_log: Vec<(String, String)> = Vec::new();
+                        let mut msg_log: Vec<(u64, String, String)> = Vec::new();
                         for msg in msg_values {
                         for msg in msg_values {
-                            let msg: (String, String) = serde_json::from_value(msg.clone())?;
+                            let msg: (u64, String, String) = serde_json::from_value(msg.clone())?;
                             msg_log.push(msg);
                             msg_log.push(msg);
                         }
                         }
                         let is_empty = false;
                         let is_empty = false;

+ 4 - 4
bin/dnetview/src/model.rs

@@ -20,7 +20,7 @@ pub enum SelectableObject {
 pub struct Model {
 pub struct Model {
     pub ids: Mutex<FxHashSet<String>>,
     pub ids: Mutex<FxHashSet<String>>,
     pub nodes: Mutex<FxHashMap<String, NodeInfo>>,
     pub nodes: Mutex<FxHashMap<String, NodeInfo>>,
-    pub msg_log: Mutex<FxHashMap<String, Vec<(String, String)>>>,
+    pub msg_log: Mutex<FxHashMap<String, Vec<(u64, String, String)>>>,
     pub selectables: Mutex<FxHashMap<String, SelectableObject>>,
     pub selectables: Mutex<FxHashMap<String, SelectableObject>>,
 }
 }
 
 
@@ -28,7 +28,7 @@ impl Model {
     pub fn new(
     pub fn new(
         ids: Mutex<FxHashSet<String>>,
         ids: Mutex<FxHashSet<String>>,
         nodes: Mutex<FxHashMap<String, NodeInfo>>,
         nodes: Mutex<FxHashMap<String, NodeInfo>>,
-        msg_log: Mutex<FxHashMap<String, Vec<(String, String)>>>,
+        msg_log: Mutex<FxHashMap<String, Vec<(u64, String, String)>>>,
         selectables: Mutex<FxHashMap<String, SelectableObject>>,
         selectables: Mutex<FxHashMap<String, SelectableObject>>,
     ) -> Model {
     ) -> Model {
         Model { ids, nodes, msg_log, selectables }
         Model { ids, nodes, msg_log, selectables }
@@ -81,7 +81,7 @@ pub struct ConnectInfo {
     pub addr: String,
     pub addr: String,
     pub state: String,
     pub state: String,
     pub parent: String,
     pub parent: String,
-    pub msg_log: Vec<(String, String)>,
+    pub msg_log: Vec<(u64, String, String)>,
     pub is_empty: bool,
     pub is_empty: bool,
     pub last_msg: String,
     pub last_msg: String,
     pub last_status: String,
     pub last_status: String,
@@ -93,7 +93,7 @@ impl ConnectInfo {
         addr: String,
         addr: String,
         state: String,
         state: String,
         parent: String,
         parent: String,
-        msg_log: Vec<(String, String)>,
+        msg_log: Vec<(u64, String, String)>,
         is_empty: bool,
         is_empty: bool,
         last_msg: String,
         last_msg: String,
         last_status: String,
         last_status: String,

+ 5 - 5
bin/dnetview/src/view.rs

@@ -20,7 +20,7 @@ use log::debug;
 #[derive(Debug)]
 #[derive(Debug)]
 pub struct View {
 pub struct View {
     pub nodes: NodeInfoView,
     pub nodes: NodeInfoView,
-    pub msg_log: FxHashMap<String, Vec<(String, String)>>,
+    pub msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
     pub active_ids: IdListView,
     pub active_ids: IdListView,
     pub selectables: FxHashMap<String, SelectableObject>,
     pub selectables: FxHashMap<String, SelectableObject>,
 }
 }
@@ -28,7 +28,7 @@ pub struct View {
 impl View {
 impl View {
     pub fn new(
     pub fn new(
         nodes: NodeInfoView,
         nodes: NodeInfoView,
-        msg_log: FxHashMap<String, Vec<(String, String)>>,
+        msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
         active_ids: IdListView,
         active_ids: IdListView,
         selectables: FxHashMap<String, SelectableObject>,
         selectables: FxHashMap<String, SelectableObject>,
     ) -> View {
     ) -> View {
@@ -38,7 +38,7 @@ impl View {
     pub fn update(
     pub fn update(
         &mut self,
         &mut self,
         nodes: FxHashMap<String, NodeInfo>,
         nodes: FxHashMap<String, NodeInfo>,
-        msg_log: FxHashMap<String, Vec<(String, String)>>,
+        msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
         selectables: FxHashMap<String, SelectableObject>,
         selectables: FxHashMap<String, SelectableObject>,
     ) {
     ) {
         self.update_nodes(nodes);
         self.update_nodes(nodes);
@@ -73,7 +73,7 @@ impl View {
         }
         }
     }
     }
 
 
-    fn update_msg_log(&mut self, msg_log: FxHashMap<String, Vec<(String, String)>>) {
+    fn update_msg_log(&mut self, msg_log: FxHashMap<String, Vec<(u64, String, String)>>) {
         for (id, msg) in msg_log {
         for (id, msg) in msg_log {
             self.msg_log.insert(id, msg);
             self.msg_log.insert(id, msg);
         }
         }
@@ -207,7 +207,7 @@ impl View {
                     let log = self.msg_log.get(&connect.id);
                     let log = self.msg_log.get(&connect.id);
                     match log {
                     match log {
                         Some(values) => {
                         Some(values) => {
-                            for (k, v) in values {
+                            for (t, k, v) in values {
                                 lines.push(Spans::from(match k.as_str() {
                                 lines.push(Spans::from(match k.as_str() {
                                     "send" => Span::styled(format!("S: {}", v), style),
                                     "send" => Span::styled(format!("S: {}", v), style),
                                     "recv" => Span::styled(format!("R: {}", v), style),
                                     "recv" => Span::styled(format!("R: {}", v), style),