Also add addresses from incoming connections
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
677c471548
commit
12fb3516c0
1 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::{hash_map::Entry::Vacant, HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::atomic::{self, AtomicU64};
|
use std::sync::atomic::{self, AtomicU64};
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
@ -512,12 +512,14 @@ impl FullMeshPeeringStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_connected(self: Arc<Self>, id: NodeID, addr: SocketAddr, is_incoming: bool) {
|
fn on_connected(self: Arc<Self>, id: NodeID, addr: SocketAddr, is_incoming: bool) {
|
||||||
|
let mut known_hosts = self.known_hosts.write().unwrap();
|
||||||
if is_incoming {
|
if is_incoming {
|
||||||
let mut known_hosts = self.known_hosts.write().unwrap();
|
if let Some(host) = known_hosts.list.get_mut(&id) {
|
||||||
if let Vacant(entry) = known_hosts.list.entry(id) {
|
if !host.all_addrs.contains(&addr) {
|
||||||
entry.insert(self.new_peer(&id, addr));
|
host.all_addrs.push(addr);
|
||||||
known_hosts.update_hash();
|
}
|
||||||
self.update_public_peer_list(&known_hosts);
|
} else {
|
||||||
|
known_hosts.list.insert(id, self.new_peer(&id, addr));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
|
@ -525,7 +527,6 @@ impl FullMeshPeeringStrategy {
|
||||||
hex::encode(&id[..8]),
|
hex::encode(&id[..8]),
|
||||||
addr
|
addr
|
||||||
);
|
);
|
||||||
let mut known_hosts = self.known_hosts.write().unwrap();
|
|
||||||
if let Some(host) = known_hosts.list.get_mut(&id) {
|
if let Some(host) = known_hosts.list.get_mut(&id) {
|
||||||
host.state = PeerConnState::Connected;
|
host.state = PeerConnState::Connected;
|
||||||
host.addr = addr;
|
host.addr = addr;
|
||||||
|
@ -545,9 +546,9 @@ impl FullMeshPeeringStrategy {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
known_hosts.update_hash();
|
|
||||||
self.update_public_peer_list(&known_hosts);
|
|
||||||
}
|
}
|
||||||
|
known_hosts.update_hash();
|
||||||
|
self.update_public_peer_list(&known_hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_disconnected(self: Arc<Self>, id: NodeID, is_incoming: bool) {
|
fn on_disconnected(self: Arc<Self>, id: NodeID, is_incoming: bool) {
|
||||||
|
|
Loading…
Reference in a new issue