Skip to content

Commit 1d7ff5f

Browse files
committed
f Iterate less
1 parent b7350b1 commit 1d7ff5f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
18371837

18381838
// First add all connected peers, preferring to list the connected address if available.
18391839
let connected_peers = self.peer_manager.get_peer_node_ids();
1840+
let connected_peers_len = connected_peers.len();
18401841
for (node_id, con_addr_opt) in connected_peers {
18411842
let stored_peer = self.peer_store.get_peer(&node_id);
18421843
let stored_addr_opt = stored_peer.as_ref().map(|p| p.address.clone());
@@ -1854,7 +1855,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
18541855

18551856
// Now add all known-but-offline peers, too.
18561857
for p in self.peer_store.list_peers() {
1857-
if peers.iter().find(|d| d.node_id == p.node_id).is_some() {
1858+
if peers.iter().take(connected_peers_len).find(|d| d.node_id == p.node_id).is_some() {
18581859
continue;
18591860
}
18601861

0 commit comments

Comments
 (0)