Skip to content

Commit

Permalink
Removed all 'unused' / 'dead code' warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu-maeda committed Jan 31, 2024
1 parent 87bbf39 commit a360773
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/comms/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -318,10 +319,12 @@ pub(super) enum CommsRequest {
trade_uuid: Uuid,
rsp_tx: oneshot::Sender<Result<(), N3xbError>>,
},
#[allow(dead_code)]
RegisterFallbackTx {
tx: mpsc::Sender<PeerEnvelope>,
rsp_tx: oneshot::Sender<Result<(), N3xbError>>,
},
#[allow(dead_code)]
UnregisterFallbackTx {
rsp_tx: oneshot::Sender<Result<(), N3xbError>>,
},
Expand Down Expand Up @@ -936,6 +939,7 @@ impl CommsActor {
.collect()
}

#[allow(dead_code)]
async fn handle_resync_events(&mut self, events: Vec<Event>) {
for event in events {
// Get relays this event is seen in
Expand Down
5 changes: 4 additions & 1 deletion src/maker/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -125,6 +125,7 @@ impl MakerData {
self.read_store().order.to_owned()
}

#[allow(dead_code)]
pub(crate) fn relay_urls(&self) -> HashSet<Url> {
self.read_store().relay_urls.to_owned()
}
Expand All @@ -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<TradeResponse> {
self.read_store().trade_rsp.to_owned()
}

#[allow(dead_code)]
pub(crate) fn trade_rsp_event_id(&self) -> Option<EventIdString> {
self.read_store().trade_rsp_event_id.to_owned()
}
Expand Down
12 changes: 3 additions & 9 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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<str>,
data_dir_path: impl AsRef<Path>,
) -> Manager {
async fn new_with_comms(comms: Comms, data_dir_path: impl AsRef<Path>) -> 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());
Expand All @@ -79,7 +74,6 @@ impl Manager {
}

Manager {
trade_engine_name: trade_engine_name.as_ref().to_string(),
manager_dir_path,
comms,
comms_accessor,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_restore_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_restore_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a360773

Please sign in to comment.