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

clean up & remove unused files

ghassmo 4 лет назад
Родитель
Сommit
f6d80e36f8
7 измененных файлов с 10 добавлено и 381 удалено
  1. 10 20
      Cargo.lock
  2. 0 5
      Cargo.toml
  3. 0 74
      script/run_demo.sh
  4. 0 3
      src/lib.rs
  5. 0 114
      src/tui/app.rs
  6. 0 5
      src/tui/mod.rs
  7. 0 160
      src/tui/widget.rs

+ 10 - 20
Cargo.lock

@@ -804,7 +804,7 @@ dependencies = [
  "native-tls",
  "num-bigint",
  "num_cpus",
- "rand 0.8.4",
+ "rand 0.8.5",
  "secp256k1",
  "serde",
  "serde_json",
@@ -1407,7 +1407,7 @@ dependencies = [
  "native-tls",
  "num-bigint",
  "pasta_curves",
- "rand 0.8.4",
+ "rand 0.8.5",
  "rocksdb",
  "serde",
  "serde_json",
@@ -2301,7 +2301,7 @@ dependencies = [
  "pasta_curves",
  "plotters",
  "proptest",
- "rand 0.8.4",
+ "rand 0.8.5",
  "subtle",
  "uint",
 ]
@@ -2615,7 +2615,7 @@ dependencies = [
  "darkfi",
  "futures",
  "log",
- "rand 0.8.4",
+ "rand 0.8.5",
  "serde_json",
  "simplelog",
  "smol",
@@ -3015,7 +3015,7 @@ dependencies = [
  "autocfg 1.0.1",
  "num-integer",
  "num-traits",
- "rand 0.8.4",
+ "rand 0.8.5",
  "serde",
 ]
 
@@ -3242,7 +3242,7 @@ dependencies = [
  "ff",
  "group",
  "lazy_static",
- "rand 0.8.4",
+ "rand 0.8.5",
  "static_assertions",
  "subtle",
 ]
@@ -3513,7 +3513,7 @@ dependencies = [
  "lazy_static",
  "num-traits",
  "quick-error 2.0.1",
- "rand 0.8.4",
+ "rand 0.8.5",
  "rand_chacha 0.3.1",
  "rand_xorshift 0.3.0",
  "regex-syntax",
@@ -3606,14 +3606,13 @@ dependencies = [
 
 [[package]]
 name = "rand"
-version = "0.8.4"
+version = "0.8.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
 dependencies = [
  "libc",
  "rand_chacha 0.3.1",
  "rand_core 0.6.3",
- "rand_hc 0.3.1",
 ]
 
 [[package]]
@@ -3697,15 +3696,6 @@ dependencies = [
  "rand_core 0.5.1",
 ]
 
-[[package]]
-name = "rand_hc"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
-dependencies = [
- "rand_core 0.6.3",
-]
-
 [[package]]
 name = "rand_isaac"
 version = "0.1.1"
@@ -5531,7 +5521,7 @@ dependencies = [
  "http",
  "httparse",
  "log",
- "rand 0.8.4",
+ "rand 0.8.5",
  "rustls 0.20.2",
  "sha-1",
  "thiserror",

+ 0 - 5
Cargo.toml

@@ -151,11 +151,6 @@ blockchain = [
     "util",
 ]
 
-tui = [
-    "async-std",
-    "termion",
-]
-
 system = [
     "rand",
 

+ 0 - 74
script/run_demo.sh

@@ -1,74 +0,0 @@
-#!/bin/bash
-
-
-arg=$1
-gatewayd_path="./target/release/gatewayd"
-cashierd_path="./target/release/cashierd"
-darkfid_path="./target/release/darkfid"
-drk_path="./target/release/drk"
-
-echo Running demo...
-
-if [ "$arg" = "-d" ]; then
-	echo DEBUG MODE	
-	gatewayd_path="./target/debug/gatewayd"
-	cashierd_path="./target/debug/cashierd"
-	darkfid_path="./target/debug/darkfid"
-	drk_path="./target/debug/drk"
-fi
-
-echo Open new tab and run: 
-echo "	$ " $drk_path --help
-
-trap cleanup SIGINT 
-
-function cleanup()
-{
-	screen -X -S "gatewayd" quit
-	screen -X -S "cashierd" quit
-	screen -X -S "darkfid" quit
-	echo Exit demo...
-}
-
-# Start gateway daemon 
-screen -S "gatewayd" -dm "$gatewayd_path" -v 
-status=$?
-if [ $status -ne 0 ]; then
-  echo "Failed to start gateway daemon: $status"
-  exit $status
-fi
-
-# Start cashier daemon 
-screen -S "cashierd" -dm "$cashierd_path" -v
-status=$?
-if [ $status -ne 0 ]; then
-  echo "Failed to start cashier daemon: $status"
-  exit $status
-fi
-
-# Start darkfi daemon 
-screen -S "darkfid" -dm "$darkfid_path" -v
-status=$?
-if [ $status -ne 0 ]; then
-  echo "Failed to start darkfi daemon: $status"
-  exit $status
-fi
-
-# Exit with an error if it detects that either of the processes has exited.
-# Otherwise it loops forever, waking up every 60 seconds 
-while sleep 60; do
-  ps aux |grep "gatewayd" |grep -q -v grep
-  PROCESS_1_STATUS=$?
-  ps aux |grep "cashierd" |grep -q -v grep
-  PROCESS_2_STATUS=$?
-  ps aux |grep "darkfid" |grep -q -v grep
-  PROCESS_3_STATUS=$?
-
-  if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 -o $PROCESS_3_STATUS -ne 0 ]; then
-    echo "One of the processes has already exited."
-	cleanup
-    exit 1
-  fi
-done
-
-

+ 0 - 3
src/lib.rs

@@ -25,9 +25,6 @@ pub mod blockchain;
 #[cfg(feature = "system")]
 pub mod system;
 
-#[cfg(feature = "tui")]
-pub mod tui;
-
 #[cfg(feature = "util")]
 pub mod util;
 

+ 0 - 114
src/tui/app.rs

@@ -1,114 +0,0 @@
-use async_std::sync::Mutex;
-use std::io::{Stdin, Stdout, Write};
-
-use termion::{
-    clear, cursor,
-    event::Key,
-    input::{Keys, TermRead},
-    raw::{IntoRawMode, RawTerminal},
-};
-
-use super::Layout;
-use crate::Result;
-
-#[allow(dead_code)]
-pub struct App {
-    layouts: Vec<Box<dyn Layout>>,
-    stdin: Mutex<Keys<Stdin>>,
-    stdout: RawTerminal<Stdout>,
-}
-
-impl App {
-    pub fn new() -> Result<Self> {
-        let stdin = Mutex::new(std::io::stdin().keys());
-
-        let stdout = std::io::stdout();
-        let stdout = stdout.into_raw_mode()?;
-
-        Ok(Self { stdin, stdout, layouts: vec![] })
-    }
-
-    fn clear(&mut self) -> Result<()> {
-        self.hide_cursor()?;
-        write!(self.stdout, "{}", clear::All)?;
-        Ok(())
-    }
-
-    fn hide_cursor(&mut self) -> Result<()> {
-        write!(self.stdout, "{}", cursor::Hide)?;
-        Ok(())
-    }
-
-    fn show_cursor(&mut self) -> Result<()> {
-        write!(self.stdout, "{}", cursor::Show)?;
-        Ok(())
-    }
-
-    fn _move_the_cursor(&mut self, x: usize, y: usize) -> Result<()> {
-        write!(self.stdout, "{}", cursor::Goto(1 + x as u16, 1 + y as u16))?;
-        Ok(())
-    }
-
-    fn flush(&mut self) -> Result<()> {
-        self.stdout.flush()?;
-        Ok(())
-    }
-
-    async fn _get_stdin_key(&self) -> Option<Key> {
-        match self.stdin.lock().await.next() {
-            Some(Ok(key)) => Some(key),
-            _ => None,
-        }
-    }
-
-    pub fn add_layout(&mut self, layout: Box<dyn Layout>) -> Result<()> {
-        self.layouts.push(layout);
-        Ok(())
-    }
-
-    pub async fn run(&mut self) -> Result<()> {
-        self.clear()?;
-
-        let mut terminal_width = termion::terminal_size()?.0 as usize;
-        let mut terminal_height = termion::terminal_size()?.1 as usize;
-
-        let mut last_box_x = 0;
-        let mut last_box_y = 0;
-
-        for layout in self.layouts.iter_mut() {
-            let (box_x, box_y) = layout.draw(
-                &mut self.stdout,
-                last_box_x,
-                last_box_y,
-                terminal_width as usize,
-                terminal_height as usize,
-            )?;
-
-            if last_box_x != box_x {
-                last_box_x += box_x;
-                if terminal_width > box_x {
-                    terminal_width -= box_x;
-                } else {
-                    break
-                }
-            }
-
-            if last_box_y != box_y {
-                last_box_y += box_y;
-                if terminal_height > box_y {
-                    terminal_height -= box_y;
-                } else {
-                    break
-                }
-            }
-        }
-
-        self.flush()?;
-
-        async_std::task::sleep(std::time::Duration::from_secs(5)).await;
-
-        self.show_cursor()?;
-
-        Ok(())
-    }
-}

+ 0 - 5
src/tui/mod.rs

@@ -1,5 +0,0 @@
-pub mod app;
-pub mod widget;
-
-pub use app::App;
-pub use widget::{HBox, Layout, VBox, Widget};

+ 0 - 160
src/tui/widget.rs

@@ -1,160 +0,0 @@
-use std::io::{Stdout, Write};
-
-use termion::{cursor, raw::RawTerminal};
-
-use crate::Result;
-
-#[derive(Clone)]
-pub struct Widget {
-    pub width: usize,
-    pub height: usize,
-    pub x: usize,
-    pub y: usize,
-    title: String,
-}
-
-impl Widget {
-    pub fn new(width: usize, height: usize, x: usize, y: usize, title: String) -> Result<Widget> {
-        Ok(Widget { width, height, x, y, title })
-    }
-
-    pub fn print(
-        &self,
-        stdout: &mut RawTerminal<Stdout>,
-        x: usize,
-        y: usize,
-        text: &str,
-    ) -> Result<()> {
-        write!(stdout, "{}{}", cursor::Goto(1 + x as u16, 1 + y as u16), text)?;
-        Ok(())
-    }
-
-    pub fn print_border(&self, stdout: &mut RawTerminal<Stdout>) -> Result<()> {
-        let x = self.x;
-        let y = self.y;
-        let width = self.width;
-        let height = self.height;
-
-        let hline = "─";
-        let vline = "│";
-        let topleftcorner = "┌";
-        let toprightcorner = "┐";
-        let downleftcorner = "└";
-        let downrightcorner = "┘";
-
-        self.print(stdout, x, y, topleftcorner)?;
-        self.print(stdout, x, y + height, downleftcorner)?;
-
-        self.print(stdout, x + width - 1, y, toprightcorner)?;
-        self.print(stdout, x + width - 1, y + height, downrightcorner)?;
-
-        for j in (y + 1)..(y + height) {
-            self.print(stdout, x, j, vline)?;
-            self.print(stdout, x + width - 1, j, vline)?;
-        }
-
-        for i in (x + 1)..(x + width - 1) {
-            self.print(stdout, i, y, hline)?;
-            self.print(stdout, i, y + height, hline)?;
-        }
-
-        Ok(())
-    }
-
-    pub fn clear_current_line(&self, stdout: &mut RawTerminal<Stdout>) -> Result<()> {
-        let width = self.width;
-        for i in self.x..(width - 3) {
-            self.print(stdout, i, self.y, " ")?;
-        }
-        Ok(())
-    }
-
-    pub fn draw(&self, stdout: &mut RawTerminal<Stdout>) -> Result<()> {
-        self.print_border(stdout)?;
-        self.print(stdout, self.x + 3, self.y, &format!(" {} ", &self.title.clone()))?;
-        Ok(())
-    }
-}
-
-pub trait Layout {
-    fn draw(
-        &mut self,
-        stdout: &mut RawTerminal<Stdout>,
-        x: usize,
-        y: usize,
-        layout_width: usize,
-        layout_height: usize,
-    ) -> Result<(usize, usize)>;
-}
-
-pub struct VBox {
-    widgets: Vec<Widget>,
-    width: usize,
-}
-
-impl VBox {
-    pub fn new(widgets: Vec<Widget>, width: usize) -> Self {
-        Self { widgets, width }
-    }
-}
-
-impl Layout for VBox {
-    fn draw(
-        &mut self,
-        stdout: &mut RawTerminal<Stdout>,
-        x: usize,
-        y: usize,
-        layout_width: usize,
-        layout_height: usize,
-    ) -> Result<(usize, usize)> {
-        let len = self.widgets.len();
-
-        let widget_width = layout_width / self.width;
-
-        for (i, widget) in self.widgets.iter_mut().enumerate() {
-            widget.width = widget_width - 1;
-            widget.height = (layout_height / len) - 1;
-            widget.x = x;
-            widget.y = (widget.height + 1) * i + y;
-            widget.draw(stdout)?;
-        }
-
-        Ok((widget_width, y))
-    }
-}
-
-pub struct HBox {
-    widgets: Vec<Widget>,
-    pub height: usize,
-}
-
-impl HBox {
-    pub fn new(widgets: Vec<Widget>, height: usize) -> Self {
-        Self { widgets, height }
-    }
-}
-
-impl Layout for HBox {
-    fn draw(
-        &mut self,
-        stdout: &mut RawTerminal<Stdout>,
-        x: usize,
-        y: usize,
-        layout_width: usize,
-        layout_height: usize,
-    ) -> Result<(usize, usize)> {
-        let len = self.widgets.len();
-
-        let widget_height = layout_height / self.height;
-
-        for (i, widget) in self.widgets.iter_mut().enumerate() {
-            widget.width = layout_width / len - 1;
-            widget.height = widget_height - 1;
-            widget.x = (widget.width + 1) * i + x;
-            widget.y = y;
-            widget.draw(stdout)?;
-        }
-
-        Ok((x, widget_height))
-    }
-}