Remove allow(dead_code) on code that is now in use

This commit is contained in:
Mike Dilger 2022-12-21 08:40:48 +13:00
parent f9b54572e3
commit 7c2e0b0c73
13 changed files with 0 additions and 37 deletions

View File

@ -17,7 +17,6 @@ pub struct DbEvent {
}
impl DbEvent {
#[allow(dead_code)]
pub async fn fetch(criteria: Option<&str>) -> Result<Vec<DbEvent>, Error> {
let sql = "SELECT id, raw, pubkey, created_at, kind, content, ots FROM event".to_owned();
let sql = match criteria {
@ -53,7 +52,6 @@ impl DbEvent {
output
}
#[allow(dead_code)]
pub async fn insert(event: DbEvent) -> Result<(), Error> {
let sql = "INSERT OR IGNORE INTO event (id, raw, pubkey, created_at, kind, content, ots) \
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)";
@ -111,7 +109,6 @@ impl DbEvent {
.await?
}
#[allow(dead_code)]
pub async fn save_nostr_event(event: &Event, seen_on: Option<Url>) -> Result<(), Error> {
// Convert a nostr Event into a DbEvent
let db_event = DbEvent {

View File

@ -43,7 +43,6 @@ impl DbEventSeen {
output
}
#[allow(dead_code)]
pub async fn replace(event_seen: DbEventSeen) -> Result<(), Error> {
let sql = "REPLACE INTO event_seen (event, relay, when_seen) \
VALUES (?1, ?2, ?3)";

View File

@ -52,7 +52,6 @@ impl DbEventTag {
output
}
#[allow(dead_code)]
pub async fn insert(event_tag: DbEventTag) -> Result<(), Error> {
let sql =
"INSERT OR IGNORE INTO event_tag (event, seq, label, field0, field1, field2, field3) \

View File

@ -29,7 +29,6 @@ use std::fs;
use tracing::info;
// This sets up the database
#[allow(dead_code)]
#[allow(clippy::or_fun_call)]
pub async fn setup_database() -> Result<(), Error> {
let mut data_dir = dirs::data_dir()
@ -62,7 +61,6 @@ pub async fn setup_database() -> Result<(), Error> {
Ok(())
}
#[allow(dead_code)]
async fn check_and_upgrade() -> Result<(), Error> {
let maybe_db = GLOBALS.db.lock().await;
let db = maybe_db.as_ref().unwrap();
@ -98,7 +96,6 @@ macro_rules! apply_sql {
}};
}
#[allow(dead_code)]
fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
apply_sql!(db, version, 1, "schema1.sql");

View File

@ -18,7 +18,6 @@ pub struct DbPerson {
}
impl DbPerson {
#[allow(dead_code)]
pub fn new(pubkey: PublicKeyHex) -> DbPerson {
DbPerson {
pubkey,
@ -33,7 +32,6 @@ impl DbPerson {
}
}
#[allow(dead_code)]
pub async fn fetch(criteria: Option<&str>) -> Result<Vec<DbPerson>, Error> {
let sql =
"SELECT pubkey, name, about, picture, dns_id, dns_id_valid, dns_id_last_checked, metadata_at, followed FROM person".to_owned();
@ -72,7 +70,6 @@ impl DbPerson {
output
}
#[allow(dead_code)]
pub async fn fetch_one(pubkey: PublicKeyHex) -> Result<Option<DbPerson>, Error> {
let people = DbPerson::fetch(Some(&format!("pubkey='{}'", pubkey))).await?;
@ -83,7 +80,6 @@ impl DbPerson {
}
}
#[allow(dead_code)]
pub async fn insert(person: DbPerson) -> Result<(), Error> {
let sql =
"INSERT OR IGNORE INTO person (pubkey, name, about, picture, dns_id, dns_id_valid, dns_id_last_checked, metadata_at, followed) \
@ -112,7 +108,6 @@ impl DbPerson {
Ok(())
}
#[allow(dead_code)]
pub async fn update(person: DbPerson) -> Result<(), Error> {
let sql =
"UPDATE person SET name=?, about=?, picture=?, dns_id=?, dns_id_valid=?, dns_id_last_checked=?, metadata_at=?, followed=? WHERE pubkey=?";
@ -155,7 +150,6 @@ impl DbPerson {
Ok(())
}
#[allow(dead_code)]
pub async fn populate_new_people(follow_everybody: bool) -> Result<(), Error> {
let sql = if follow_everybody {
"INSERT or IGNORE INTO person (pubkey, followed) SELECT DISTINCT pubkey, 1 FROM EVENT"

View File

@ -47,7 +47,6 @@ impl DbPersonRelay {
}
/// Fetch records matching the given public keys, ordered from highest to lowest rank
#[allow(dead_code)]
pub async fn fetch_for_pubkeys(pubkeys: &[PublicKeyHex]) -> Result<Vec<DbPersonRelay>, Error> {
if pubkeys.is_empty() {
return Ok(vec![]);
@ -89,7 +88,6 @@ impl DbPersonRelay {
}
/// Fetch oldest last_fetched among a set of public keys for a relay
#[allow(dead_code)]
pub async fn fetch_oldest_last_fetched(
pubkeys: &[PublicKeyHex],
relay: &str,
@ -124,7 +122,6 @@ impl DbPersonRelay {
output
}
#[allow(dead_code)]
pub async fn insert(person_relay: DbPersonRelay) -> Result<(), Error> {
let sql = "INSERT OR IGNORE INTO person_relay (person, relay, recommended, last_fetched) \
VALUES (?1, ?2, ?3, ?4)";
@ -147,7 +144,6 @@ impl DbPersonRelay {
Ok(())
}
#[allow(dead_code)]
pub async fn update_last_fetched(relay: String, last_fetched: u64) -> Result<(), Error> {
let sql = "UPDATE person_relay SET last_fetched=? where relay=?";

View File

@ -13,7 +13,6 @@ pub struct DbRelay {
}
impl DbRelay {
#[allow(dead_code)]
pub fn new(url: String) -> DbRelay {
DbRelay {
url,
@ -23,7 +22,6 @@ impl DbRelay {
}
}
#[allow(dead_code)]
pub async fn fetch(criteria: Option<&str>) -> Result<Vec<DbRelay>, Error> {
let sql = "SELECT url, success_count, failure_count, rank FROM relay".to_owned();
let sql = match criteria {
@ -56,7 +54,6 @@ impl DbRelay {
output
}
#[allow(dead_code)]
pub async fn fetch_one(url: &Url) -> Result<Option<DbRelay>, Error> {
let relays = DbRelay::fetch(Some(&format!("url='{}'", url))).await?;
@ -67,7 +64,6 @@ impl DbRelay {
}
}
#[allow(dead_code)]
pub async fn insert(relay: DbRelay) -> Result<(), Error> {
let sql = "INSERT OR IGNORE INTO relay (url, success_count, failure_count, rank) \
VALUES (?1, ?2, ?3, ?4)";
@ -90,7 +86,6 @@ impl DbRelay {
Ok(())
}
#[allow(dead_code)]
pub async fn update(relay: DbRelay) -> Result<(), Error> {
let sql = "UPDATE relay SET success_count=?, failure_count=?, rank=? WHERE url=?";
@ -127,7 +122,6 @@ impl DbRelay {
Ok(())
}
#[allow(dead_code)]
pub async fn populate_new_relays() -> Result<(), Error> {
let sql =
"INSERT OR IGNORE INTO relay (url, rank) SELECT DISTINCT relay, 3 FROM person_relay";

View File

@ -11,7 +11,6 @@ pub struct DbSetting {
}
impl DbSetting {
#[allow(dead_code)]
pub async fn fetch(criteria: Option<&str>) -> Result<Vec<DbSetting>, Error> {
let sql = "SELECT key, value FROM settings".to_owned();
let sql = match criteria {
@ -64,7 +63,6 @@ impl DbSetting {
}
}
#[allow(dead_code)]
pub async fn fetch_setting_u64_or_default(key: &str, default: u64) -> Result<u64, Error> {
let db_settings = DbSetting::fetch(Some(&format!("key='{}'", key))).await?;
@ -110,7 +108,6 @@ impl DbSetting {
Ok(())
}
#[allow(dead_code)]
pub async fn update<T: ToSql + Send + 'static>(key: String, value: T) -> Result<(), Error> {
let sql = "UPDATE settings SET value=? WHERE key=?";

View File

@ -29,7 +29,6 @@ pub struct EventRelated {
}
impl EventRelated {
#[allow(dead_code)]
pub fn new(id: Id) -> EventRelated {
EventRelated {
id,

View File

@ -92,7 +92,6 @@ pub fn blocking_get_feed() -> Vec<Id> {
feed.iter().map(|e| e.id).collect()
}
#[allow(dead_code)]
pub async fn add_event(event: &Event) -> Result<(), Error> {
// Insert the event
insert_event(event).await;
@ -208,13 +207,11 @@ pub async fn add_event(event: &Event) -> Result<(), Error> {
Ok(())
}
#[allow(dead_code)]
async fn insert_event(event: &Event) {
let mut events = GLOBALS.events.lock().await;
events.insert(event.id, event.clone());
}
#[allow(dead_code)]
async fn update_event_related<F>(id: Id, mut f: F)
where
F: FnMut(&mut EventRelated),

View File

@ -18,7 +18,6 @@ use tracing::{error, info};
pub struct Overlord {
settings: Settings,
to_minions: Sender<BusMessage>,
#[allow(dead_code)]
from_minions: UnboundedReceiver<BusMessage>,
minions: task::JoinSet<()>,
minions_task_url: HashMap<task::Id, Url>,

View File

@ -4,7 +4,6 @@ use nostr_proto::PublicKeyHex;
use tracing::info;
/// See RelayPicker::best()
#[allow(dead_code)]
pub struct RelayPicker {
pub relays: Vec<DbRelay>,
pub pubkeys: Vec<PublicKeyHex>,
@ -12,7 +11,6 @@ pub struct RelayPicker {
}
impl RelayPicker {
#[allow(dead_code)]
pub fn is_degenerate(&self) -> bool {
self.relays.is_empty() || self.pubkeys.is_empty() || self.person_relays.is_empty()
}
@ -22,7 +20,6 @@ impl RelayPicker {
/// BestRelay structure which includes the best relay to listen to and
/// the public keys such a relay will cover. It also outpus a new RelayPicker
/// that contains only the remaining relays and public keys.
#[allow(dead_code)]
pub fn best(mut self) -> Result<(BestRelay, RelayPicker), Error> {
if self.pubkeys.is_empty() {
return Err(Error::General(
@ -103,7 +100,6 @@ pub struct BestRelay {
}
impl BestRelay {
#[allow(dead_code)]
pub fn is_degenerate(&self) -> bool {
self.pubkeys.is_empty() || self.relay.rank == Some(0)
}

View File

@ -24,7 +24,6 @@ impl Default for Settings {
}
impl Settings {
#[allow(dead_code)]
pub async fn load() -> Result<Settings, Error> {
let feed_chunk =
DbSetting::fetch_setting_u64_or_default("feed_chunk", DEFAULT_FEED_CHUNK).await?;