From a3607731f975133dcdf37b7a0990cb0c8e366bde Mon Sep 17 00:00:00 2001 From: "nobu.maeda" Date: Wed, 31 Jan 2024 22:55:30 +0800 Subject: [PATCH] Removed all 'unused' / 'dead code' warnings --- src/comms/comms.rs | 4 ++++ src/maker/data.rs | 5 ++++- src/manager.rs | 12 +++--------- tests/test_restore_buy.rs | 2 +- tests/test_restore_sell.rs | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/comms/comms.rs b/src/comms/comms.rs index 071f0d7..a9faeba 100644 --- a/src/comms/comms.rs +++ b/src/comms/comms.rs @@ -100,6 +100,7 @@ impl CommsAccess { rsp_rx.await.unwrap() } + #[allow(dead_code)] pub(crate) async fn unregister_peer_message_tx( &self, trade_uuid: Uuid, @@ -318,10 +319,12 @@ pub(super) enum CommsRequest { trade_uuid: Uuid, rsp_tx: oneshot::Sender>, }, + #[allow(dead_code)] RegisterFallbackTx { tx: mpsc::Sender, rsp_tx: oneshot::Sender>, }, + #[allow(dead_code)] UnregisterFallbackTx { rsp_tx: oneshot::Sender>, }, @@ -936,6 +939,7 @@ impl CommsActor { .collect() } + #[allow(dead_code)] async fn handle_resync_events(&mut self, events: Vec) { for event in events { // Get relays this event is seen in diff --git a/src/maker/data.rs b/src/maker/data.rs index 6511006..b597dc2 100644 --- a/src/maker/data.rs +++ b/src/maker/data.rs @@ -57,7 +57,7 @@ impl MakerData { let trade_uuid = order.trade_uuid; let data_path = dir_path.as_ref().join(format!("{}-maker.json", trade_uuid)); - let mut store = MakerDataStore { + let store = MakerDataStore { order, relay_urls: HashSet::new(), order_event_id: None, @@ -125,6 +125,7 @@ impl MakerData { self.read_store().order.to_owned() } + #[allow(dead_code)] pub(crate) fn relay_urls(&self) -> HashSet { self.read_store().relay_urls.to_owned() } @@ -141,10 +142,12 @@ impl MakerData { self.read_store().accepted_offer_event_id.to_owned() } + #[allow(dead_code)] pub(crate) fn trade_rsp(&self) -> Option { self.read_store().trade_rsp.to_owned() } + #[allow(dead_code)] pub(crate) fn trade_rsp_event_id(&self) -> Option { self.read_store().trade_rsp_event_id.to_owned() } diff --git a/src/manager.rs b/src/manager.rs index 97ec541..fd55714 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -19,7 +19,6 @@ use crate::taker::{Taker, TakerAccess}; // At the moment we only support a single Trade Engine at a time. // Might need to change to a dyn Trait if mulitple is to be supported at a time pub struct Manager { - trade_engine_name: String, manager_dir_path: PathBuf, comms: Comms, comms_accessor: CommsAccess, @@ -43,7 +42,7 @@ impl Manager { let data_dir_path = root_dir_path.as_ref().join(DATA_DIR_PATH_STR); // This will always create a new Comms with a randomly generated key pair let comms = Comms::new(trade_engine_name.as_ref(), &data_dir_path).await; - Self::new_with_comms(comms, trade_engine_name, &data_dir_path).await + Self::new_with_comms(comms, &data_dir_path).await } pub async fn new_with_key( @@ -54,14 +53,10 @@ impl Manager { let data_dir_path = root_dir_path.as_ref().join(DATA_DIR_PATH_STR); // Will try to look for Comms data that matches the pubkey and restore relays if found. New Comms is created otherwise let comms = Comms::new_with_key(key, trade_engine_name.as_ref(), &data_dir_path).await; - Self::new_with_comms(comms, trade_engine_name, &data_dir_path).await + Self::new_with_comms(comms, &data_dir_path).await } - async fn new_with_comms( - comms: Comms, - trade_engine_name: impl AsRef, - data_dir_path: impl AsRef, - ) -> Manager { + async fn new_with_comms(comms: Comms, data_dir_path: impl AsRef) -> Manager { let comms_accessor = comms.new_accessor(); let pubkey = comms_accessor.get_pubkey().await; let manager_dir_path = data_dir_path.as_ref().join(pubkey.to_string()); @@ -79,7 +74,6 @@ impl Manager { } Manager { - trade_engine_name: trade_engine_name.as_ref().to_string(), manager_dir_path, comms, comms_accessor, diff --git a/tests/test_restore_buy.rs b/tests/test_restore_buy.rs index 43be9d2..fdb3545 100644 --- a/tests/test_restore_buy.rs +++ b/tests/test_restore_buy.rs @@ -27,7 +27,7 @@ mod tests { #[tokio::test] async fn test_restore_buy() { - logger_setup(); + // logger_setup(); // Set up the initial state if let Some(error) = fs::remove_dir_all("n3xb_data/").await.err() { diff --git a/tests/test_restore_sell.rs b/tests/test_restore_sell.rs index 9274f8d..f53fe81 100644 --- a/tests/test_restore_sell.rs +++ b/tests/test_restore_sell.rs @@ -28,7 +28,7 @@ mod tests { #[tokio::test] async fn test_restore_sell() { - //logger_setup(); + // logger_setup(); // Setup the initial state if let Some(error) = fs::remove_dir_all("n3xb_data/").await.err() {