diff --git a/p2p/src/store.rs b/p2p/src/store.rs index 91d77e08a..c120f12d4 100644 --- a/p2p/src/store.rs +++ b/p2p/src/store.rs @@ -94,6 +94,11 @@ impl PeerStore { } pub fn save_peer(&self, p: &PeerData) -> Result<(), Error> { + // we want to ignore any peer without a well-defined ip + let ip = p.addr.ip(); + if ip.is_unspecified() || ip.is_loopback() { + return Ok(()); + } self.db.put_ser( &to_key(PEER_PREFIX, &mut format!("{}", p.addr).into_bytes())[..], p, @@ -133,11 +138,11 @@ impl PeerStore { pub fn all_peers(&self) -> Vec { let peers_iter = self.db .iter::(&to_key(PEER_PREFIX, &mut "".to_string().into_bytes())); - let mut peers = vec![]; - for p in peers_iter { - peers.push(p); - } - peers + let mut peers = vec![]; + for p in peers_iter { + peers.push(p); + } + peers } /// Convenience method to load a peer data, update its status and save it