Revert "Improve checking for p2p connection limits (#2985)"

This reverts commit 24f0a52437.
This commit is contained in:
antiochp
2019-08-21 15:02:10 +01:00
parent 24f0a52437
commit 17dddeeb0d
6 changed files with 58 additions and 133 deletions
+6 -12
View File
@@ -185,12 +185,9 @@ fn monitor_peers(
);
// maintenance step first, clean up p2p server peers
peers.clean_peers(
config.peer_max_inbound_count() as usize,
config.peer_max_outbound_count() as usize,
);
peers.clean_peers(config.peer_max_count() as usize);
if peers.enough_outbound_peers() {
if peers.healthy_peers_mix() {
return;
}
@@ -233,7 +230,7 @@ fn monitor_peers(
let new_peers = peers.find_peers(
p2p::State::Healthy,
p2p::Capabilities::UNKNOWN,
config.peer_max_outbound_count() as usize,
config.peer_max_count() as usize,
);
for p in new_peers.iter().filter(|p| !peers.is_known(p.addr)) {
@@ -299,18 +296,15 @@ fn listen_for_addrs(
let addrs: Vec<PeerAddr> = rx.try_iter().collect();
// If we have a healthy number of outbound peers then we are done here.
if peers.enough_outbound_peers() {
if peers.peer_count() > peers.peer_outbound_count() && peers.healthy_peers_mix() {
return;
}
// Try to connect to (up to max outbound peers) peer addresses.
// Try to connect to (up to max peers) peer addresses.
// Note: We drained the rx queue earlier to keep it under control.
// Even if there are many addresses to try we will only try a bounded number of them.
let connect_min_interval = 30;
for addr in addrs
.into_iter()
.take(p2p.config.peer_max_outbound_count() as usize)
{
for addr in addrs.into_iter().take(p2p.config.peer_max_count() as usize) {
// ignore the duplicate connecting to same peer within 30 seconds
let now = Utc::now();
if let Some(last_connect_time) = connecting_history.get(&addr) {
+1 -1
View File
@@ -86,7 +86,7 @@ impl SyncRunner {
// * timeout
if wp > MIN_PEERS
|| (wp == 0
&& self.peers.enough_outbound_peers()
&& self.peers.enough_peers()
&& head.total_difficulty > Difficulty::zero())
|| n > wait_secs
{