ソースを参照

map: render new data structure

lunar-mining 4 年 前
コミット
d3dbe52c1a
2 ファイル変更14 行追加19 行削除
  1. 7 7
      bin/map/src/main.rs
  2. 7 12
      bin/map/src/ui.rs

+ 7 - 7
bin/map/src/main.rs

@@ -171,18 +171,18 @@ async fn poll(client: Map, model: Arc<Model>) -> Result<()> {
                 incoming: in_connections,
             }];
 
-            //for node in infos {
-            //    // write nodes
-            //    model.info_list.infos.lock().await.push(node.clone());
-            //    // write node id
-            //    model.id_list.node_id.lock().await.push(node.clone().id);
-            //}
+            for node in infos {
+                // write nodes
+                model.info_list.infos.lock().await.push(node.clone());
+                // write node id
+                model.id_list.node_id.lock().await.push(node.clone().id);
+            }
         } else {
             // TODO: error handling
             println!("Reply is an error");
         }
 
-        async_util::sleep(2).await;
+        async_util::sleep(5).await;
     }
 }
 

+ 7 - 12
bin/map/src/ui.rs

@@ -37,22 +37,17 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
 }
 
 fn render_info<B: Backend>(view: View, f: &mut Frame<'_, B>, index: usize, slice: Vec<Rect>) {
-    // TODO: create new list of outgoing and incoming connections
     let info = &view.info_list.infos;
     let id = &info[index].id;
-    //for connect in info[index].in_connects.clone() {
-    //    let id = connect.id;
-    //    let message = connect.message;
-    //}
-    //for connect in info[index].out_connects.clone() {
-    //    let id = connect.id;
-    //    let message = connect.message;
-    //}
+
+    let i0 = info[index].incoming.clone();
+
+    let o0 = info[index].outgoing.clone();
+
     let span = vec![
         Spans::from(format!("NodeId: {}", id)),
-        //Spans::from(format!("Number of connections: {}", connections)),
-        //Spans::from(format!("Is active: {}", is_active)),
-        //Spans::from(format!("Last message: {}", message)),
+        Spans::from(format!("Outgoing connections: {:?}", i0)),
+        Spans::from(format!("Incoming connections: {:?}", o0)),
     ];
     let graph =
         Paragraph::new(span).block(Block::default().borders(Borders::ALL)).style(Style::default());