From bc93bc4899ed91637c54143ab958fd91eb27d171 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 11 Nov 2024 00:06:00 +0100 Subject: [PATCH 1/2] Add error logs. --- translator/src/tasks/ship_reader.rs | 8 ++++---- translator/src/types/evm_types.rs | 5 +++-- translator/src/types/translator_types.rs | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/translator/src/tasks/ship_reader.rs b/translator/src/tasks/ship_reader.rs index 6441ea4..957eda6 100644 --- a/translator/src/tasks/ship_reader.rs +++ b/translator/src/tasks/ship_reader.rs @@ -4,8 +4,8 @@ use futures_util::StreamExt; use tokio::net::TcpStream; use tokio::sync::mpsc; use tokio_tungstenite::{MaybeTlsStream, WebSocketStream}; -use tracing::debug; use tracing::info; +use tracing::{debug, error, warn}; pub async fn ship_reader( mut ws_rx: SplitStream>>, @@ -26,14 +26,14 @@ pub async fn ship_reader( Some(Ok(msg)) => { debug!("Received message {counter}, sending to raw ds pool...",); // write to the channel - if raw_ds_tx.send(msg.into_data()).await.is_err() { - println!("Receiver dropped"); + if let Err(e) = raw_ds_tx.send(msg.into_data()).await { + error!("Receiver dropped {:?}", e); break; } debug!("Sent message {counter} to raw ds pool..."); } Some(Err(e)) => { - println!("Error receiving message: {}", e); + error!("Error receiving message: {}", e); break; } None => { diff --git a/translator/src/types/evm_types.rs b/translator/src/types/evm_types.rs index 5609c9a..f68244c 100644 --- a/translator/src/types/evm_types.rs +++ b/translator/src/types/evm_types.rs @@ -11,6 +11,7 @@ use antelope::serializer::Encoder; use antelope::util::hex_to_bytes; use antelope::StructPacker; use serde::{Deserialize, Deserializer, Serialize}; +use tracing::warn; #[derive(Debug, Clone, Default, Serialize, Deserialize, StructPacker)] pub struct RawAction { @@ -175,11 +176,11 @@ impl PrintedReceipt { let printed_receipt = serde_json::from_str::(extracted).unwrap(); Some(printed_receipt) } else { - println!("End pattern not found."); + warn!("End pattern not found."); None } } else { - println!("Start pattern not found."); + warn!("Start pattern not found."); None } } diff --git a/translator/src/types/translator_types.rs b/translator/src/types/translator_types.rs index a87db3d..9daa6f1 100644 --- a/translator/src/types/translator_types.rs +++ b/translator/src/types/translator_types.rs @@ -104,6 +104,7 @@ impl NameToAddressCache { let address = Address::from(account_row.address.data); self.cache.insert(index, address); self.index_cache.insert(account_row.index, address); + return Ok(address); } else { warn!("Got empty rows for index {index}, retry attempt {i}"); From 80c0edfd1088cba253ced61f772fde0386beb409 Mon Sep 17 00:00:00 2001 From: lesa-telos Date: Mon, 11 Nov 2024 00:41:45 +0100 Subject: [PATCH 2/2] Fix clippy. --- translator/src/tasks/ship_reader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translator/src/tasks/ship_reader.rs b/translator/src/tasks/ship_reader.rs index 957eda6..db3a13e 100644 --- a/translator/src/tasks/ship_reader.rs +++ b/translator/src/tasks/ship_reader.rs @@ -5,7 +5,7 @@ use tokio::net::TcpStream; use tokio::sync::mpsc; use tokio_tungstenite::{MaybeTlsStream, WebSocketStream}; use tracing::info; -use tracing::{debug, error, warn}; +use tracing::{debug, error}; pub async fn ship_reader( mut ws_rx: SplitStream>>,