From c11d5c8fcb220bce097e3204e57cb18b071839e3 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Fri, 4 May 2018 18:33:46 +0100 Subject: [PATCH] Push missing blocks back to the peer we requested frontiers from since this is the node missing the blocks. (#844) --- rai/node/bootstrap.cpp | 40 +++++++++++++++------------------------- rai/node/bootstrap.hpp | 2 +- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/rai/node/bootstrap.cpp b/rai/node/bootstrap.cpp index b4686a1a..d228a8fe 100644 --- a/rai/node/bootstrap.cpp +++ b/rai/node/bootstrap.cpp @@ -775,32 +775,27 @@ void rai::bootstrap_attempt::request_pull (std::unique_lock & lock_a } } -bool rai::bootstrap_attempt::request_push (std::unique_lock & lock_a) +void rai::bootstrap_attempt::request_push (std::unique_lock & lock_a) { - auto result (true); - auto connection_l (connection (lock_a)); - if (connection_l) + bool error (false); + if (auto connection_shared = connection_frontier_request.lock ()) { - std::future future; - { - auto client (std::make_shared (connection_l)); - client->start (); - push = client; - future = client->promise.get_future (); - } + auto client (std::make_shared (connection_shared)); + client->start (); + push = client; + auto future (client->promise.get_future ()); lock_a.unlock (); - result = consume_future (future); + error = consume_future (future); lock_a.lock (); - if (node->config.logging.network_logging ()) + } + if (node->config.logging.network_logging ()) + { + BOOST_LOG (node->log) << "Exiting bulk push client"; + if (error) { - BOOST_LOG (node->log) << "Exiting bulk push client"; - if (result) - { - BOOST_LOG (node->log) << "Bulk push client failed"; - } + BOOST_LOG (node->log) << "Bulk push client failed"; } } - return result; } bool rai::bootstrap_attempt::still_pulling () @@ -851,11 +846,7 @@ void rai::bootstrap_attempt::run () { BOOST_LOG (node->log) << "Completed pulls"; } - auto push_failure (true); - while (!stopped && push_failure) - { - push_failure = request_push (lock); - } + request_push (lock); stopped = true; condition.notify_all (); idle.clear (); @@ -1117,7 +1108,6 @@ void rai::bootstrap_attempt::requeue_pull (rai::pull_info const & pull_a) std::lock_guard lock (mutex); if (auto connection_shared = connection_frontier_request.lock ()) { - auto size (pulls.size ()); node->background ([connection_shared, pull]() { auto client (std::make_shared (connection_shared, pull)); client->request (); diff --git a/rai/node/bootstrap.hpp b/rai/node/bootstrap.hpp index 83e6328c..16a8e35b 100644 --- a/rai/node/bootstrap.hpp +++ b/rai/node/bootstrap.hpp @@ -65,7 +65,7 @@ public: void populate_connections (); bool request_frontier (std::unique_lock &); void request_pull (std::unique_lock &); - bool request_push (std::unique_lock &); + void request_push (std::unique_lock &); void add_connection (rai::endpoint const &); void pool_connection (std::shared_ptr); void stop ();