Explorar el Código

stop passing Config to ui::ui

NodeId is read from config and is initalized into Model.
The values from Model are then copied into View.

We therefore do not need to read this data in the UI, as it already exists in View.
lunar-mining hace 4 años
padre
commit
69161945d9
Se han modificado 2 ficheros con 5 adiciones y 9 borrados
  1. 3 7
      bin/dnetview/src/main.rs
  2. 2 2
      bin/dnetview/src/ui.rs

+ 3 - 7
bin/dnetview/src/main.rs

@@ -127,7 +127,7 @@ async fn main() -> Result<()> {
         .finish(|| {
             smol::future::block_on(async move {
                 run_rpc(&config, ex2.clone(), model.clone()).await?;
-                render(&mut terminal, model.clone(), config).await?;
+                render(&mut terminal, model.clone()).await?;
                 drop(signal);
                 Ok::<(), darkfi::Error>(())
             })
@@ -232,11 +232,7 @@ async fn poll(client: Map, model: Arc<Model>) -> Result<()> {
     }
 }
 
-async fn render<B: Backend>(
-    terminal: &mut Terminal<B>,
-    model: Arc<Model>,
-    config: DnvConfig,
-) -> io::Result<()> {
+async fn render<B: Backend>(terminal: &mut Terminal<B>, model: Arc<Model>) -> io::Result<()> {
     let mut asi = async_stdin();
 
     terminal.clear()?;
@@ -251,7 +247,7 @@ async fn render<B: Backend>(
     loop {
         view.update(model.info_list.infos.lock().await.clone());
         terminal.draw(|f| {
-            ui::ui(f, view.clone(), &config);
+            ui::ui(f, view.clone());
         })?;
         for k in asi.by_ref().keys() {
             match k.unwrap() {

+ 2 - 2
bin/dnetview/src/ui.rs

@@ -1,4 +1,4 @@
-use crate::{view::View, DnvConfig};
+use crate::view::View;
 
 use tui::{
     backend::Backend,
@@ -9,7 +9,7 @@ use tui::{
     Frame,
 };
 
-pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View, config: &DnvConfig) {
+pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
     let slice = Layout::default()
         .direction(Direction::Horizontal)
         .margin(2)