We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6457c32 commit 40e437eCopy full SHA for 40e437e
1 file changed
network-libp2p/src/discovery/peer_contacts.rs
@@ -512,20 +512,12 @@ impl PeerContactBook {
512
pub fn known_peers(&self) -> Vec<(PeerId, PeerInfo)> {
513
self.peer_contacts
514
.iter()
515
- .map(|(peer_id, contact)| {
516
- (
+ .filter_map(|(peer_id, contact)| {
+ let address = contact.contact.inner.addresses.first()?.clone();
517
+ Some((
518
*peer_id,
- PeerInfo::new(
519
- contact
520
- .contact
521
- .inner
522
- .addresses
523
- .first()
524
- .expect("every peer should have at least one address")
525
- .clone(),
526
- contact.contact.inner.services,
527
- ),
528
- )
+ PeerInfo::new(address, contact.contact.inner.services),
+ ))
529
})
530
.collect()
531
}
0 commit comments