From b17f718f94d8a7064aef7d306331ab267d1d04de Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sun, 22 Jan 2023 19:42:15 +1300 Subject: [PATCH] dead code cleanup --- src/db/event.rs | 6 ++++-- src/db/event_seen.rs | 1 - src/db/person_relay.rs | 5 ++--- src/events.rs | 5 ++--- src/feed.rs | 12 ------------ src/fetcher.rs | 1 - src/nip05.rs | 1 - src/overlord/minion/mod.rs | 2 -- src/people.rs | 4 ++-- src/relationship.rs | 3 +-- src/signer.rs | 3 --- src/ui/mod.rs | 8 +------- 12 files changed, 12 insertions(+), 39 deletions(-) diff --git a/src/db/event.rs b/src/db/event.rs index 2a76c1fe..a1eeef8c 100644 --- a/src/db/event.rs +++ b/src/db/event.rs @@ -101,7 +101,7 @@ impl DbEvent { output } - #[allow(dead_code)] + /* pub async fn fetch_by_ids(ids: Vec) -> Result, Error> { if ids.is_empty() { return Ok(vec![]); @@ -141,6 +141,7 @@ impl DbEvent { output } + */ pub async fn fetch_latest_metadata() -> Result, Error> { // THIS SQL MIGHT WORK, NEEDS REVIEW @@ -234,7 +235,7 @@ impl DbEvent { */ } -#[allow(dead_code)] +/* fn repeat_vars(count: usize) -> String { assert_ne!(count, 0); let mut s = "?,".repeat(count); @@ -242,3 +243,4 @@ fn repeat_vars(count: usize) -> String { s.pop(); s } +*/ diff --git a/src/db/event_seen.rs b/src/db/event_seen.rs index 55e28671..6257f41d 100644 --- a/src/db/event_seen.rs +++ b/src/db/event_seen.rs @@ -45,7 +45,6 @@ impl DbEventSeen { } */ - #[allow(dead_code)] pub async fn get_relays_for_event(id: Id) -> Result, Error> { let sql = "SELECT relay FROM event_seen WHERE event=?"; diff --git a/src/db/person_relay.rs b/src/db/person_relay.rs index 33361555..7369d80c 100644 --- a/src/db/person_relay.rs +++ b/src/db/person_relay.rs @@ -192,7 +192,6 @@ impl DbPersonRelay { Ok(()) } - #[allow(dead_code)] pub async fn upsert_last_suggested_kind3( person: String, relay: String, @@ -273,7 +272,7 @@ impl DbPersonRelay { Ok(()) } - #[allow(dead_code)] + /* pub async fn fetch_matching( people: Vec, relays: Vec, @@ -331,8 +330,8 @@ impl DbPersonRelay { output } + */ - #[allow(dead_code)] pub async fn get_best_relays(pubkey: PublicKeyHex) -> Result, Error> { // This is the ranking we are using. There might be reasons // for ranking differently: diff --git a/src/events.rs b/src/events.rs index ce96ccde..64ff71ec 100644 --- a/src/events.rs +++ b/src/events.rs @@ -23,17 +23,17 @@ impl Events { let _ = self.events.insert(event.id, event); } - #[allow(dead_code)] + /* pub fn contains_key(&self, id: &Id) -> bool { self.events.contains_key(id) } + */ pub fn get(&self, id: &Id) -> Option { self.events.get(id).map(|e| e.value().to_owned()) } /// Get the event from memory, and also try the database - #[allow(dead_code)] pub async fn get_local(&self, id: Id) -> Result, Error> { if let Some(e) = self.get(&id) { return Ok(Some(e)); @@ -64,7 +64,6 @@ impl Events { } } - #[allow(dead_code)] #[async_recursion] pub async fn get_highest_local_parent(&self, id: &Id) -> Result, Error> { if let Some(event) = self.get_local(*id).await? { diff --git a/src/feed.rs b/src/feed.rs index 3737da2b..794cd615 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -120,18 +120,6 @@ impl Feed { events.iter().map(|e| e.id).collect() } - #[allow(dead_code)] - pub fn get_my_event_ids(&self) -> Vec { - // we assume the main get() happens fast enough to recompute for us. - self.my_event_ids.read().clone() - } - - #[allow(dead_code)] - pub fn get_followed_event_ids(&self) -> Vec { - // we assume the main get() happens fast enough to recompute for us. - self.followed_event_ids.read().clone() - } - pub fn get_thread_parent(&self) -> Option { self.maybe_recompute(); *self.thread_parent.read() diff --git a/src/fetcher.rs b/src/fetcher.rs index adea39ee..90552fb2 100644 --- a/src/fetcher.rs +++ b/src/fetcher.rs @@ -72,7 +72,6 @@ impl Fetcher { cache_file } - #[allow(dead_code)] pub fn try_get(&self, url: Url) -> Result>, Error> { // Error if we are dead if let Some(reason) = &self.dead { diff --git a/src/nip05.rs b/src/nip05.rs index 1f6717d0..a84ba3e8 100644 --- a/src/nip05.rs +++ b/src/nip05.rs @@ -6,7 +6,6 @@ use nostr_types::{Metadata, Nip05, PublicKeyHex, Unixtime, Url}; use std::collections::hash_map::Entry; // This updates the people map and the database with the result -#[allow(dead_code)] pub async fn validate_nip05(person: DbPerson) -> Result<(), Error> { let now = Unixtime::now().unwrap(); diff --git a/src/overlord/minion/mod.rs b/src/overlord/minion/mod.rs index 6dc2e64a..59ae8eec 100644 --- a/src/overlord/minion/mod.rs +++ b/src/overlord/minion/mod.rs @@ -702,7 +702,6 @@ impl Minion { Ok(()) } - #[allow(dead_code)] async fn subscribe(&mut self, filters: Vec, handle: &str) -> Result<(), Error> { let req_message = if self.subscriptions.has(handle) { let sub = self.subscriptions.get_mut(handle).unwrap(); @@ -719,7 +718,6 @@ impl Minion { Ok(()) } - #[allow(dead_code)] async fn unsubscribe(&mut self, handle: &str) -> Result<(), Error> { if !self.subscriptions.has(handle) { return Ok(()); diff --git a/src/people.rs b/src/people.rs index 3f170553..4af94d7d 100644 --- a/src/people.rs +++ b/src/people.rs @@ -501,7 +501,6 @@ impl People { Ok(()) } - #[allow(dead_code)] pub async fn generate_contact_list_event(&self) -> Result { let mut p_tags: Vec = Vec::new(); @@ -820,7 +819,7 @@ impl People { output } - #[allow(dead_code)] + /* async fn insert(person: DbPerson) -> Result<(), Error> { let sql = "INSERT OR IGNORE INTO person (pubkey, metadata, metadata_at, \ nip05_valid, nip05_last_checked, followed, followed_last_updated) \ @@ -852,6 +851,7 @@ impl People { Ok(()) } + */ /* pub async fn delete(criteria: &str) -> Result<(), Error> { diff --git a/src/relationship.rs b/src/relationship.rs index 34a51afc..61b69289 100644 --- a/src/relationship.rs +++ b/src/relationship.rs @@ -2,8 +2,7 @@ #[derive(Clone, Debug, PartialEq, Eq)] pub enum Relationship { Reply, - #[allow(dead_code)] - Quote, + //Mention, Reaction(String), Deletion(String), } diff --git a/src/signer.rs b/src/signer.rs index 1866f1cc..fbda814b 100644 --- a/src/signer.rs +++ b/src/signer.rs @@ -29,7 +29,6 @@ impl Signer { settings.save().await } - #[allow(dead_code)] pub fn set_public_key(&mut self, pk: PublicKey) { if self.private.is_some() { *GLOBALS.status_message.blocking_write() = @@ -39,7 +38,6 @@ impl Signer { } } - #[allow(dead_code)] pub fn clear_public_key(&mut self) { if self.private.is_some() { *GLOBALS.status_message.blocking_write() = @@ -49,7 +47,6 @@ impl Signer { } } - #[allow(dead_code)] pub fn set_encrypted_private_key(&mut self, epk: EncryptedPrivateKey) { if self.private.is_some() && self.encrypted.is_some() { // ignore, epk supercedes diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 5d1fe5fb..aac400ef 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -19,7 +19,7 @@ use egui::{ ColorImage, Context, ImageData, Label, RichText, SelectableLabel, Sense, TextStyle, TextureHandle, TextureOptions, Ui, }; -use nostr_types::{Id, IdHex, Metadata, PublicKey, PublicKeyHex}; +use nostr_types::{Id, IdHex, Metadata, PublicKeyHex}; use std::collections::HashMap; use std::sync::atomic::Ordering; use std::time::{Duration, Instant}; @@ -378,12 +378,6 @@ impl GossipUi { idhex.0[0..8].to_string() } - #[allow(dead_code)] - pub fn pubkey_long(pubkey: &PublicKey) -> String { - let hex: PublicKeyHex = (*pubkey).into(); - hex.0 - } - pub fn render_person_name_line(ui: &mut Ui, maybe_person: Option<&DbPerson>) { ui.horizontal_wrapped(|ui| { if let Some(person) = maybe_person {