diff --git a/nomos-cli/src/cmds/chat/mod.rs b/nomos-cli/src/cmds/chat/mod.rs index 920ebff4..af4db37d 100644 --- a/nomos-cli/src/cmds/chat/mod.rs +++ b/nomos-cli/src/cmds/chat/mod.rs @@ -85,6 +85,8 @@ impl NomosChat { let backend = CrosstermBackend::new(stdout); let mut terminal = Terminal::new(backend)?; + let node_addr = Some(self.node.clone()); + let (payload_sender, payload_receiver) = tokio::sync::mpsc::unbounded_channel(); let (status_sender, status_updates) = std::sync::mpsc::channel(); @@ -97,7 +99,7 @@ impl NomosChat { timeout: DEFAULT_TIMEOUT, da_protocol, status_updates: status_sender, - node_addr: None, + node_addr, output: None, }, }, @@ -168,7 +170,14 @@ fn run_app(terminal: &mut Terminal, mut app: App) { if !app.message_in_flight && !app.input.value().is_empty() { app.message_in_flight = true; app.payload_sender - .send(app.input.value().as_bytes().into()) + .send( + wire::serialize(&ChatMessage { + author: app.username.clone().unwrap(), + message: app.input.value().into(), + }) + .unwrap() + .into(), + ) .unwrap(); } } @@ -187,7 +196,7 @@ fn run_app(terminal: &mut Terminal, mut app: App) { } } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct ChatMessage { author: String, message: String, @@ -209,7 +218,7 @@ async fn fetch_new_messages( old_blocks: &mut HashSet, node: Url, ) -> Result, Box> { - const NODE_CARNOT_INFO_PATH: &str = "consensus/info"; + const NODE_CARNOT_INFO_PATH: &str = "carnot/info"; let mut new_messages = Vec::new(); @@ -221,7 +230,7 @@ async fn fetch_new_messages( let new_blocks = info .committed_blocks .into_iter() - .filter(|id| !old_blocks.contains(id)) + .filter(|id| !old_blocks.contains(id) && id != BlockId::zeros()) .collect::>(); // note that number of attestations is ignored here since we only use the da protocol to diff --git a/nomos-cli/src/da/retrieve.rs b/nomos-cli/src/da/retrieve.rs index 40c04cba..a7664899 100644 --- a/nomos-cli/src/da/retrieve.rs +++ b/nomos-cli/src/da/retrieve.rs @@ -8,6 +8,9 @@ use nomos_node::Tx; use reqwest::Url; use thiserror::Error; +const BLOCK_PATH: &str = "storage/block"; +const BLOBS_PATH: &str = "da/blobs"; + #[derive(Error, Debug)] pub enum Error { #[error(transparent)] @@ -30,7 +33,7 @@ pub async fn get_block_contents( block: BlockId, ) -> Result>, reqwest::Error> { let block = reqwest::Client::new() - .post(node.join("storage/block").unwrap()) + .post(node.join(BLOCK_PATH).unwrap()) .body(serde_json::to_string(&block).unwrap()) .send() .await? @@ -44,7 +47,7 @@ pub async fn get_blobs( ids: Vec<::Hash>, ) -> Result, reqwest::Error> { reqwest::Client::new() - .post(node) + .post(node.join(BLOBS_PATH).unwrap()) .body(serde_json::to_string(&ids).unwrap()) .send() .await?