From 91e5d79e47612f3a3c4009e46405297a2296e6a0 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Wed, 15 Mar 2017 00:19:25 -0500 Subject: [PATCH] Up to 16 concurrent connections and don't establish new connections once we're done with the pull phase. --- rai/node/bootstrap.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/rai/node/bootstrap.cpp b/rai/node/bootstrap.cpp index 03553a94..88a790f7 100755 --- a/rai/node/bootstrap.cpp +++ b/rai/node/bootstrap.cpp @@ -756,17 +756,26 @@ void rai::bootstrap_attempt::populate_connections () { std::weak_ptr this_w (shared_from_this ()); std::lock_guard lock (mutex); - if (connecting.size () + active.size () + idle.size () < 4) + if (connecting.size () + active.size () + idle.size () < 16) { start_connection (node->peers.bootstrap_peer ()); } - node->alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (1), [this_w] () + switch (state) { - if (auto this_l = this_w.lock ()) - { - this_l->populate_connections (); - } - }); + case rai::attempt_state::starting: + case rai::attempt_state::requesting_frontiers: + case rai::attempt_state::requesting_pulls: + node->alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (1), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + this_l->populate_connections (); + } + }); + break; + default: + break; + } } void rai::bootstrap_attempt::add_connection (rai::endpoint const & endpoint_a)