Skip to content

Commit

Permalink
f: fixed clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ksedgwic committed Nov 14, 2024
1 parent d85b198 commit 9812446
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/account_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl AccountManager {
}

pub fn send_initial_filters(&mut self, pool: &mut RelayPool, relay_url: &str) {
for (_pubkey, data) in &self.account_data {
for data in self.account_data.values() {
pool.send_to(
&ClientMessage::req(data.relay.subid.clone(), vec![data.relay.filter.clone()]),
relay_url,
Expand All @@ -254,26 +254,26 @@ impl AccountManager {
let mut added = Vec::new();
for pubkey in self.accounts.iter().map(|a| a.pubkey.bytes()) {
if !self.account_data.contains_key(pubkey) {
added.push(pubkey.clone());
added.push(*pubkey);
}
}
let mut removed = Vec::new();
for pubkey in self.account_data.keys() {
if !self.has_account_pubkey(&pubkey) {
removed.push(pubkey.clone());
if !self.has_account_pubkey(pubkey) {
removed.push(*pubkey);
}
}
(added, removed)
}

// standardize the format (ie, trailing slashes) to avoid dups
pub fn canonicalize_url(url: &String) -> String {
match Url::parse(&url) {
pub fn canonicalize_url(url: &str) -> String {
match Url::parse(url) {
Ok(parsed_url) => parsed_url.to_string(),
Err(_) => url.clone(), // If parsing fails, return the original URL.
Err(_) => url.to_owned(), // If parsing fails, return the original URL.
}
}
fn harvest_nip65_relays(ndb: &Ndb, txn: &Transaction, nks: &Vec<NoteKey>) -> Vec<String> {
fn harvest_nip65_relays(ndb: &Ndb, txn: &Transaction, nks: &[NoteKey]) -> Vec<String> {
nks.iter()
.filter_map(|nk| ndb.get_note_by_key(txn, *nk).ok())
.flat_map(|n| {
Expand Down Expand Up @@ -307,7 +307,7 @@ impl AccountManager {
.expect("query user relays results")
.iter()
.map(|qr| qr.note_key)
.collect();
.collect::<Vec<NoteKey>>();
let relays = Self::harvest_nip65_relays(ndb, &txn, &nks);
debug!(
"pubkey {}: initial relays {:#?}",
Expand All @@ -328,7 +328,7 @@ impl AccountManager {
advertised: relays.into_iter().collect(),
},
};
self.account_data.insert(pubkey.clone(), new_account_data);
self.account_data.insert(*pubkey, new_account_data);
}

fn handle_removed_account(&mut self, pubkey: &[u8; 32]) {
Expand Down Expand Up @@ -369,7 +369,7 @@ impl AccountManager {

// Compose the desired relay lists from the accounts
if desired_relays.is_empty() {
for (_pk, data) in &self.account_data {
for data in self.account_data.values() {
desired_relays.extend(data.relay.local.iter().cloned());
desired_relays.extend(data.relay.advertised.iter().cloned());
}
Expand Down

0 comments on commit 9812446

Please sign in to comment.