From 9463d1b359415e82e044931f06d42b8fb03ad5ba Mon Sep 17 00:00:00 2001 From: Sergey Kroshnin Date: Wed, 22 Apr 2020 21:12:59 +0300 Subject: [PATCH] Remove confirmation requests for a new representative (#2721) Because it's done in request loop quite frequent --- nano/core_test/active_transactions.cpp | 26 ++++++++++++++++++++++++++ nano/node/repcrawler.cpp | 10 ---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 11f57876e5..3a05bb025b 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -999,3 +999,29 @@ TEST (active_transactions, election_difficulty_update_fork) auto multiplier_receive_updated = node.active.roots.begin ()->multiplier; ASSERT_GT (multiplier_receive_updated, multiplier_receive); } + +TEST (active_transactions, confirm_new) +{ + nano::system system (1); + auto & node1 = *system.nodes[0]; + nano::genesis genesis; + auto send (std::make_shared (genesis.hash (), nano::public_key (), nano::genesis_amount - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (genesis.hash ()))); + node1.process_active (send); + node1.block_processor.flush (); + ASSERT_EQ (1, node1.active.size ()); + auto & node2 = *system.add_node (); + // Add key to node2 + system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv); + system.deadline_set (5s); + // Let node2 know about the block + while (node2.block (send->hash ()) == nullptr) + { + ASSERT_NO_ERROR (system.poll ()); + } + system.deadline_set (5s); + // Wait confirmation + while (node1.ledger.cache.cemented_count < 2 || node2.ledger.cache.cemented_count < 2) + { + ASSERT_NO_ERROR (system.poll ()); + } +} diff --git a/nano/node/repcrawler.cpp b/nano/node/repcrawler.cpp index 55ac9dadbd..f4a5bed75e 100644 --- a/nano/node/repcrawler.cpp +++ b/nano/node/repcrawler.cpp @@ -69,16 +69,6 @@ void nano::rep_crawler::validate () if (updated_or_inserted) { node.logger.try_log (boost::str (boost::format ("Found a representative at %1%") % channel->to_string ())); - // Rebroadcasting all active votes to new representative - auto blocks (node.active.list_blocks ()); - for (auto i (blocks.begin ()), n (blocks.end ()); i != n; ++i) - { - if (*i != nullptr) - { - nano::confirm_req req (*i); - channel->send (req); - } - } } } // This tries to assist rep nodes that have lost track of their highest sequence number by replaying our highest known vote back to them