diff --git a/dht-cache/src/cache.rs b/dht-cache/src/cache.rs index 02b3c4c..fddfe17 100644 --- a/dht-cache/src/cache.rs +++ b/dht-cache/src/cache.rs @@ -129,15 +129,11 @@ impl PeersState { if desync { CacheState::Desynced { - is_leader: self - .list - .values() - .find(|data| { - data.cache_hash == hash - && data.peer_id.as_str() < peer_id - && data.publication_timestamp > cur_ts - }) - .is_none(), + is_leader: !self.list.values().any(|data| { + data.cache_hash == hash + && data.peer_id.as_str() < peer_id + && data.publication_timestamp > cur_ts + }), } } else { CacheState::Synced diff --git a/dht-cache/src/dht.rs b/dht-cache/src/dht.rs index f947ad7..8111bc2 100644 --- a/dht-cache/src/dht.rs +++ b/dht-cache/src/dht.rs @@ -151,7 +151,7 @@ pub fn dht_channel( JoinHandle>, ) { let (cmd_send, mut cmd_recv) = mpsc::unbounded_channel(); - let (mut ev_send, ev_recv) = mpsc::unbounded_channel(); + let (ev_send, ev_recv) = mpsc::unbounded_channel(); let handle = tokio::task::spawn(async move { loop { @@ -164,7 +164,7 @@ pub fn dht_channel( } } ev = swarm.select_next_some() => { - if handle_swarm_event(&mut swarm, ev, &mut ev_send).is_err() { + if handle_swarm_event(&mut swarm, ev, &ev_send).is_err() { log::debug!("Exiting ev"); return swarm }