diff --git a/rai/node/node.cpp b/rai/node/node.cpp index f824cd76..05b23cc3 100755 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -168,6 +168,7 @@ bool confirm_broadcast (rai::node & node_a, T & list_a, std::unique_ptr clone ()); rai::confirm_ack confirm (vote); @@ -178,8 +179,7 @@ bool confirm_broadcast (rai::node & node_a, T & list_a, std::unique_ptr endpoint); - result = true; + node_a.network.confirm_block (confirm, bytes, *j); } }); } @@ -189,25 +189,10 @@ bool confirm_broadcast (rai::node & node_a, T & list_a, std::unique_ptr bool confirm_broadcast (rai::node & node_a, rai::endpoint & peer_a, std::unique_ptr block_a) { - bool result (false); - if (node_a.config.enable_voting) - { - rai::transaction transaction (node_a.store.environment, nullptr, true); - node_a.wallets.foreach_representative (transaction, [&result, &block_a, &peer_a, &node_a, &transaction] (rai::public_key const & pub_a, rai::raw_key const & prv_a) - { - auto sequence (node_a.store.sequence_atomic_inc (transaction, pub_a)); - rai::vote vote (pub_a, prv_a, sequence, block_a->clone ()); - rai::confirm_ack confirm (vote); - std::shared_ptr > bytes (new std::vector ); - { - rai::vectorstream stream (*bytes); - confirm.serialize (stream); - } - node_a.network.confirm_block (confirm, bytes, peer_a); - result = true; - }); - } - return result; + std::array endpoints; + endpoints [0] = peer_a; + auto result (confirm_broadcast (node_a, endpoints, std::move (block_a))); + return result; } void rai::network::republish_block (rai::block & block) @@ -249,7 +234,7 @@ void rai::network::broadcast_confirm_req (rai::block const & block_a) auto list (node.peers.list ()); for (auto i (list.begin ()), j (list.end ()); i != j; ++i) { - node.network.send_confirm_req (i->endpoint, block_a); + node.network.send_confirm_req (*i, block_a); } if (node.config.logging.network_logging ()) { @@ -1419,14 +1404,14 @@ std::vector rai::peer_container::list_sqrt () return result; } -std::vector rai::peer_container::list () +std::vector rai::peer_container::list () { - std::vector result; + std::vector result; std::lock_guard lock (mutex); result.reserve (peers.size ()); for (auto i (peers.begin ()), j (peers.end ()); i != j; ++i) { - result.push_back (*i); + result.push_back (i->endpoint); } std::random_shuffle (result.begin (), result.end ()); return result; diff --git a/rai/node/node.hpp b/rai/node/node.hpp index ca43e52c..c0952ea9 100644 --- a/rai/node/node.hpp +++ b/rai/node/node.hpp @@ -182,7 +182,7 @@ public: // Request a list of the top known representatives std::vector representatives (size_t); // List of all peers - std::vector list (); + std::vector list (); // A list of random peers with size the square root of total peer count std::vector list_sqrt (); // Get the next peer for attempting bootstrap diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 63104d79..1c7f1d86 100755 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -893,7 +893,7 @@ void rai::rpc_handler::peers () { boost::property_tree::ptree entry; std::stringstream text; - text << i->endpoint; + text << *i; entry.put ("", text.str ()); peers_l.push_back (std::make_pair ("", entry)); }