Rep crawler should track local representatives (#4858)
This commit is contained in:
		
					parent
					
						
							
								2c7c736f8a
							
						
					
				
			
			
				commit
				
					
						50a7e30867
					
				
			
		
					 3 changed files with 13 additions and 22 deletions
				
			
		| 
						 | 
				
			
			@ -250,6 +250,18 @@ TEST (rep_crawler, rep_connection_close)
 | 
			
		|||
	ASSERT_TIMELY_EQ (10s, node1.rep_crawler.representative_count (), 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST (rep_crawler, rep_local)
 | 
			
		||||
{
 | 
			
		||||
	nano::test::system system;
 | 
			
		||||
	auto & node = *system.add_node ();
 | 
			
		||||
	ASSERT_EQ (0, node.online_reps.online ());
 | 
			
		||||
	system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
 | 
			
		||||
	ASSERT_TIMELY_EQ (5s, node.rep_crawler.representative_count (), 1);
 | 
			
		||||
	auto reps = node.rep_crawler.representatives ();
 | 
			
		||||
	ASSERT_EQ (1, reps.size ());
 | 
			
		||||
	ASSERT_EQ (nano::dev::genesis_key.pub, reps[0].account);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// This test checks that if a block is in the recently_confirmed list then the repcrawler will not send a request for it.
 | 
			
		||||
// The behaviour of this test previously was the opposite, that the repcrawler eventually send out such a block and deleted the block
 | 
			
		||||
// from the recently confirmed list to try to make ammends for sending it, which is bad behaviour.
 | 
			
		||||
| 
						 | 
				
			
			@ -270,18 +282,6 @@ TEST (rep_crawler, DISABLED_recently_confirmed)
 | 
			
		|||
	ASSERT_ALWAYS_EQ (0.5s, node1.rep_crawler.representative_count (), 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Votes from local channels should be ignored
 | 
			
		||||
TEST (rep_crawler, ignore_local)
 | 
			
		||||
{
 | 
			
		||||
	nano::test::system system;
 | 
			
		||||
	nano::node_flags flags;
 | 
			
		||||
	auto & node = *system.add_node (flags);
 | 
			
		||||
	auto loopback = std::make_shared<nano::transport::inproc::channel> (node, node);
 | 
			
		||||
	auto vote = std::make_shared<nano::vote> (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, 0, std::vector{ nano::dev::genesis->hash () });
 | 
			
		||||
	node.rep_crawler.force_process (vote, loopback);
 | 
			
		||||
	ASSERT_ALWAYS_EQ (0.5s, node.rep_crawler.representative_count (), 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Test that nodes can track PRs when multiple PRs are inside one node
 | 
			
		||||
TEST (rep_crawler, two_reps_one_node)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,13 +86,6 @@ void nano::rep_crawler::validate_and_process (nano::unique_lock<nano::mutex> & l
 | 
			
		|||
		release_assert (vote != nullptr);
 | 
			
		||||
		release_assert (channel != nullptr);
 | 
			
		||||
 | 
			
		||||
		if (channel->get_type () == nano::transport::transport_type::loopback)
 | 
			
		||||
		{
 | 
			
		||||
			logger.debug (nano::log::type::rep_crawler, "Ignoring vote from loopback channel: {}", channel->to_string ());
 | 
			
		||||
 | 
			
		||||
			continue; // Skip this vote
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		nano::uint128_t const rep_weight = node.ledger.weight (vote->account);
 | 
			
		||||
		if (rep_weight < minimum)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <nano/lib/locks.hpp>
 | 
			
		||||
#include <nano/node/fwd.hpp>
 | 
			
		||||
#include <nano/node/transport/channel.hpp>
 | 
			
		||||
#include <nano/node/transport/transport.hpp>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,9 +24,6 @@ namespace mi = boost::multi_index;
 | 
			
		|||
 | 
			
		||||
namespace nano
 | 
			
		||||
{
 | 
			
		||||
class node;
 | 
			
		||||
class active_elections;
 | 
			
		||||
 | 
			
		||||
struct representative
 | 
			
		||||
{
 | 
			
		||||
	nano::account account;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue