This commit is contained in:
victor 2025-08-28 09:39:52 +02:00
parent cb43facd9e
commit f31584c810
5 changed files with 11 additions and 10 deletions

4
out
View File

@ -1,4 +0,0 @@
[?1049h┏InputPane━━━━━━━━━━━━━━━━━┓┏OutputPane━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃>┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛[?25l[INFO]21:14:03|StartedRenderer[?25l[INFO]21:14:03|StartedParser[?25l[INFO]21:14:03|StartedExecutor[?25l[INFO]21:14:03|StartedNode[?25l[INFO]21:14:03|BuildingChain[?25l[?25l[?25l[?25l[?25l[?25l[?25lc[?25l[?25l[?25l[?25lc[?25l[?25l[?25l [?25l [?25l[?25l[?25l>[?25l[INFO]21:14:08|Exec:Recievedechocommand[?25l[INFO]21:14:08|Parser:Receivedmessagefromwatcher[?25lUsage:<COMMAND>Commands:nodeAblockchainnodeCLItoolclearhelpPrintthismessageorthehelpofthegivensubcommand(s)Options:-h,--helpPrinthelp[?25lc[?25l[?25l[?25la[?25l[?25l[?25l[?1049lHello, world!
[DEBUG] [src/watcher/renderer.rs:125] 21:14:11 | Renderer Exit
[?25h

View File

@ -104,7 +104,6 @@ impl node::NativeNode {
} }
_ => { } _ => { }
} }
} }
} }
} }

View File

@ -1,5 +1,5 @@
use crate::core::{self, Blockchain, ValidationError}; use crate::core::{self, Blockchain, ValidationError};
use crate::native_node::message::{self, ProtocolMessage}; use crate::native_node::message::ProtocolMessage;
use crate::seeds_constants::SEED_NODES; use crate::seeds_constants::SEED_NODES;
use crate::watcher::executor::ExecutorCommand; use crate::watcher::executor::ExecutorCommand;
@ -229,8 +229,11 @@ impl NativeNode {
self.connect_to_seeds().await; self.connect_to_seeds().await;
}, },
NodeCommand::ConnectToPeer(addr) => { NodeCommand::ConnectToPeer(addr) => {
self.log(msg!(INFO, "Received ConnectToPeer: {addr}")).await;
if let Ok(addr_sock) = addr.parse::<SocketAddr>() { if let Ok(addr_sock) = addr.parse::<SocketAddr>() {
self.connect_to_peer(addr_sock).await; self.connect_to_peer(addr_sock).await;
} else {
self.log(msg!(ERROR, "Failed to Parse to sock_addr: {addr}")).await;
} }
} }
NodeCommand::AddPeer { peer_id, addr, sender } => { NodeCommand::AddPeer { peer_id, addr, sender } => {
@ -257,7 +260,7 @@ impl NativeNode {
}, },
NodeCommand::ListPeers => { NodeCommand::ListPeers => {
self.log(msg!(INFO, "Received DebugListPeers command")).await; self.log(msg!(INFO, "Received DebugListPeers command")).await;
self.list_peers(); self.log(msg!(INFO, "{}", self.list_peers())).await;
}, },
NodeCommand::ShowId => { NodeCommand::ShowId => {
self.log(msg!(INFO, "Received DebugListBlocks command")).await; self.log(msg!(INFO, "Received DebugListBlocks command")).await;

View File

@ -2,6 +2,7 @@ use crate::{native_node::node::NodeCommand, watcher::{ watcher::Watcher, rendere
use tokio::sync::mpsc; use tokio::sync::mpsc;
use vlogger::*; use vlogger::*;
#[derive(Debug)]
pub enum ExecutorCommand { pub enum ExecutorCommand {
NodeResponse(String), NodeResponse(String),
Echo(Vec<String>), Echo(Vec<String>),
@ -45,6 +46,7 @@ impl Executor {
} }
async fn handle_node_cmd(&self, cmd: NodeCommand) { async fn handle_node_cmd(&self, cmd: NodeCommand) {
Watcher::log(&self.render_tx, msg!(INFO, "Received Node Command: {cmd:?}")).await;
self.send_node_cmd(cmd).await; self.send_node_cmd(cmd).await;
// match cmd { // match cmd {

View File

@ -31,7 +31,7 @@ impl Parser {
} }
async fn exit(&mut self) { async fn exit(&mut self) {
self.print(msg!(DEBUG, "Parser Exit")).await; self.log(msg!(DEBUG, "Parser Exit")).await;
self.exit = true; self.exit = true;
} }
@ -41,7 +41,7 @@ impl Parser {
} }
} }
pub async fn print(&self, msg: String) { pub async fn log(&self, msg: String) {
if let Err(e) = self.exec_tx.send(ExecutorCommand::Echo(vec![msg])).await { if let Err(e) = self.exec_tx.send(ExecutorCommand::Echo(vec![msg])).await {
log!(ERROR, "Error response from exec: {e}"); log!(ERROR, "Error response from exec: {e}");
} }
@ -49,13 +49,14 @@ impl Parser {
async fn listen(&mut self) { async fn listen(&mut self) {
if let Ok(Some(mes)) = timeout(Duration::from_millis(400), self.rx.recv()).await { if let Ok(Some(mes)) = timeout(Duration::from_millis(400), self.rx.recv()).await {
self.print(msg!(INFO, "Parser: Received message from watcher")).await; self.log(msg!(INFO, "Parser: Received message from watcher")).await;
match mes { match mes {
ParserCommand::ParseCmdString(s) => { ParserCommand::ParseCmdString(s) => {
let argv: Vec<&str> = std::iter::once(" ") let argv: Vec<&str> = std::iter::once(" ")
.chain(s.split_whitespace()) .chain(s.split_whitespace())
.collect(); .collect();
let cmd = cli(&argv); let cmd = cli(&argv);
self.log(msg!(INFO, "Sending command {cmd:?} to exec")).await;
let _ = self.exec_tx.send(cmd).await; let _ = self.exec_tx.send(cmd).await;
}, },
ParserCommand::Exit => { ParserCommand::Exit => {