mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-21 23:51:00 +00:00
[net-fixes] netapp peer exchange: send only currently connected address
This commit is contained in:
parent
961b4f9af3
commit
3844110cd0
1 changed files with 13 additions and 13 deletions
|
@ -43,7 +43,7 @@ impl Message for PingMessage {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct PeerListMessage {
|
struct PeerListMessage {
|
||||||
pub list: Vec<(NodeID, Vec<SocketAddr>)>,
|
pub list: Vec<(NodeID, SocketAddr)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message for PeerListMessage {
|
impl Message for PeerListMessage {
|
||||||
|
@ -185,11 +185,13 @@ impl KnownHosts {
|
||||||
}
|
}
|
||||||
self.hash = hash_state.finalize();
|
self.hash = hash_state.finalize();
|
||||||
}
|
}
|
||||||
fn connected_peers_vec(&self) -> Vec<(NodeID, Vec<SocketAddr>)> {
|
fn connected_peers_vec(&self) -> Vec<(NodeID, SocketAddr)> {
|
||||||
self.list
|
self.list
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, peer)| peer.state.is_up())
|
.filter_map(|(id, peer)| match peer.state {
|
||||||
.map(|(id, peer)| (*id, peer.known_addrs.clone()))
|
PeerConnState::Connected { addr } => Some((*id, addr)),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,12 +470,11 @@ impl PeeringManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_peer_list(&self, list: &[(NodeID, Vec<SocketAddr>)]) {
|
fn handle_peer_list(&self, list: &[(NodeID, SocketAddr)]) {
|
||||||
let mut known_hosts = self.known_hosts.write().unwrap();
|
let mut known_hosts = self.known_hosts.write().unwrap();
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (id, addrs) in list.iter() {
|
for (id, addr) in list.iter() {
|
||||||
for addr in addrs.iter() {
|
|
||||||
if let Some(kh) = known_hosts.list.get_mut(id) {
|
if let Some(kh) = known_hosts.list.get_mut(id) {
|
||||||
if kh.add_addr(*addr) {
|
if kh.add_addr(*addr) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -483,7 +484,6 @@ impl PeeringManager {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if changed {
|
if changed {
|
||||||
known_hosts.update_hash();
|
known_hosts.update_hash();
|
||||||
|
|
Loading…
Reference in a new issue