瀏覽代碼

map: cleaned up warnings

lunar-mining 4 年之前
父節點
當前提交
c3441828b5
共有 4 個文件被更改,包括 12 次插入17 次删除
  1. 2 7
      bin/map/src/main.rs
  2. 1 3
      bin/map/src/model.rs
  3. 8 5
      bin/map/src/ui.rs
  4. 1 2
      bin/map/src/view.rs

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

@@ -107,8 +107,7 @@ async fn main() -> Result<()> {
 
     terminal.clear()?;
 
-    let infos = Vec::new();
-    let info_list = InfoList::new(infos.clone());
+    let info_list = InfoList::new();
     let ids = HashSet::new();
     let id_list = IdList::new(ids);
 
@@ -142,7 +141,6 @@ async fn run_rpc(config: &MapConfig, ex: Arc<Executor<'_>>, model: Arc<Model>) -
     for node in rpc_vec {
         debug!("Created client: {}", node.node_id);
         let client = Map::new(node.node_id);
-        // TODO: ping/ pong protocol
         ex.spawn(poll(client, model.clone())).detach();
     }
 
@@ -236,10 +234,7 @@ async fn render<B: Backend>(terminal: &mut Terminal<B>, model: Arc<Model>) -> io
     view.info_list.index = 0;
 
     loop {
-        view.update(
-            model.id_list.node_id.lock().await.clone(),
-            model.info_list.infos.lock().await.clone(),
-        );
+        view.update(model.info_list.infos.lock().await.clone());
         if view.info_list.infos.is_empty() {
             // TODO: make this a loading widget
             // TODO: this lags forever if IRC is not running. add an error

+ 1 - 3
bin/map/src/model.rs

@@ -1,6 +1,4 @@
 use async_std::sync::Mutex;
-use darkfi::error::Result;
-use log::debug;
 use std::collections::{HashMap, HashSet};
 use tui::widgets::ListState;
 
@@ -33,7 +31,7 @@ pub struct InfoList {
 }
 
 impl InfoList {
-    pub fn new(infos: Vec<NodeInfo>) -> InfoList {
+    pub fn new() -> InfoList {
         let index = 0;
         let index = Mutex::new(index);
         let infos = Mutex::new(HashMap::new());

+ 8 - 5
bin/map/src/ui.rs

@@ -1,9 +1,8 @@
 use crate::view::View;
-use log::debug;
 use tui::{
     backend::Backend,
     layout::{Constraint, Direction, Layout, Rect},
-    style::{Color, Modifier, Style},
+    style::Style,
     text::{Span, Spans},
     widgets::{Block, Borders, List, ListItem, Paragraph},
     Frame,
@@ -17,7 +16,6 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
         .split(f.size());
 
     let info = &view.info_list.infos;
-    let index = view.info_list.index;
 
     let nodes: Vec<ListItem> = view
         .id_list
@@ -28,7 +26,7 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
             // TODO: handle the None case
             // TODO: fix formatting (indentation must be margins)
             let connects = info.get(id).unwrap();
-            for line in lines.clone() {
+            for _line in lines.clone() {
                 lines.push(Spans::from(Span::styled("  Outgoing:", Style::default())));
                 lines.push(Spans::from(format!(
                     "    {}         [R: {}]",
@@ -62,7 +60,12 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
     render_info_right(view.clone(), f, index, slice);
 }
 
-fn render_info_right<B: Backend>(view: View, f: &mut Frame<'_, B>, index: usize, slice: Vec<Rect>) {
+fn render_info_right<B: Backend>(
+    _view: View,
+    f: &mut Frame<'_, B>,
+    _index: usize,
+    slice: Vec<Rect>,
+) {
     let span = vec![];
     let graph =
         Paragraph::new(span).block(Block::default().borders(Borders::ALL)).style(Style::default());

+ 1 - 2
bin/map/src/view.rs

@@ -1,5 +1,4 @@
 use crate::model::NodeInfo;
-use log::debug;
 use std::collections::{HashMap, HashSet};
 use tui::widgets::ListState;
 
@@ -14,7 +13,7 @@ impl View {
         View { id_list, info_list }
     }
 
-    pub fn update(&mut self, node_id: HashSet<String>, infos: HashMap<String, NodeInfo>) {
+    pub fn update(&mut self, infos: HashMap<String, NodeInfo>) {
         for (id, info) in infos.clone() {
             self.id_list.node_id.insert(id.clone());
             self.info_list.infos.insert(id, info);