From 445a4a837cbbae12a20f8b9b744d11ad371eafbe Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Sun, 31 Jul 2022 11:40:10 +0200 Subject: [PATCH] dchat: renamed message to msg and removed unnecessary util methods --- Cargo.lock | 7 +------ example/dchat/Cargo.toml | 2 -- example/dchat/src/dchatmsg.rs | 2 +- example/dchat/src/main.rs | 20 ++++++++------------ 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7162be33..9de297c32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1356,18 +1356,13 @@ dependencies = [ "async-executor", "async-std", "async-trait", - "clap 3.2.8", "darkfi", "easy-parallel", - "futures", "log", "num_cpus", - "ringbuffer", "serde", "simplelog", "smol", - "structopt", - "structopt-toml", "termion", "toml 0.4.10", "url", @@ -4020,7 +4015,7 @@ dependencies = [ "structopt", "structopt-toml", "thiserror", - "toml", + "toml 0.5.9", "url", ] diff --git a/example/dchat/Cargo.toml b/example/dchat/Cargo.toml index 001348444..36b657d74 100644 --- a/example/dchat/Cargo.toml +++ b/example/dchat/Cargo.toml @@ -4,8 +4,6 @@ version = "0.1.0" edition = "2021" description = "Demo chat to document darkfi net code" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] darkfi = {path = "../../", features = ["net", "rpc"]} diff --git a/example/dchat/src/dchatmsg.rs b/example/dchat/src/dchatmsg.rs index 1a0791ad7..831ac5ce4 100644 --- a/example/dchat/src/dchatmsg.rs +++ b/example/dchat/src/dchatmsg.rs @@ -15,5 +15,5 @@ impl net::Message for Dchatmsg { #[derive(Debug, Clone, SerialEncodable, SerialDecodable)] pub struct Dchatmsg { - pub message: String, + pub msg: String, } diff --git a/example/dchat/src/main.rs b/example/dchat/src/main.rs index bd7e50345..a18c0b56e 100644 --- a/example/dchat/src/main.rs +++ b/example/dchat/src/main.rs @@ -13,11 +13,7 @@ use url::Url; use termion::{event::Key, input::TermRead, raw::IntoRawMode}; -use darkfi::{ - net, - net::Settings, - util::cli::{get_log_config, get_log_level}, -}; +use darkfi::{net, net::Settings}; use crate::{ dchatmsg::{Dchatmsg, DchatmsgsBuffer}, @@ -161,14 +157,14 @@ impl Dchat { DisplayMode::Inbox => { let msgs = self.recv_msgs.lock().await; for i in msgs.iter() { - if !i.message.is_empty() { + if !i.msg.is_empty() { write!( stdout, "{}{}{}received msg: {}", termion::clear::All, termion::style::Bold, termion::cursor::Goto(1, 2), - i.message + i.msg )?; } else { write!( @@ -238,8 +234,8 @@ impl Dchat { } async fn send(&self) -> Result<()> { - let message = self.input.clone(); - let dchatmsg = Dchatmsg { message }; + let msg = self.input.clone(); + let dchatmsg = Dchatmsg { msg }; self.p2p.broadcast(dchatmsg).await?; Ok(()) } @@ -294,8 +290,8 @@ fn bob() -> Result { #[async_std::main] async fn main() -> Result<()> { - let log_level = get_log_level(1); - let log_config = get_log_config(); + let log_level = simplelog::LevelFilter::Debug; + let log_config = simplelog::Config::default(); let log_path = "/tmp/dchat.log"; let file = File::create(log_path).unwrap(); @@ -318,7 +314,7 @@ async fn main() -> Result<()> { let ex = Arc::new(Executor::new()); let ex2 = ex.clone(); - let msgs: DchatmsgsBuffer = Arc::new(Mutex::new(vec![Dchatmsg { message: String::new() }])); + let msgs: DchatmsgsBuffer = Arc::new(Mutex::new(vec![Dchatmsg { msg: String::new() }])); let mut dchat = Dchat::new(p2p, msgs, String::new(), DisplayMode::Normal);