Remove random items from the uniquer sets (#1473)
This commit is contained in:
		
					parent
					
						
							
								5294beaa31
							
						
					
				
			
			
				commit
				
					
						e5e87bb2bb
					
				
			
		
					 2 changed files with 8 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
#include <rai/lib/blocks.hpp>
 | 
			
		||||
#include <rai/lib/numbers.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/endian/conversion.hpp>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1564,11 +1565,10 @@ std::shared_ptr<rai::block> rai::block_uniquer::unique (std::shared_ptr<rai::blo
 | 
			
		|||
		{
 | 
			
		||||
			existing = block_a;
 | 
			
		||||
		}
 | 
			
		||||
		for (auto i (0); i < cleanup_count; ++i)
 | 
			
		||||
		for (auto i (0); i < cleanup_count && blocks.size () > 0; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			rai::uint256_union random;
 | 
			
		||||
			rai::random_pool.GenerateBlock (random.bytes.data (), random.bytes.size ());
 | 
			
		||||
			auto existing (blocks.find (random));
 | 
			
		||||
			auto random_offset (rai::random_pool.GenerateWord32 (0, blocks.size () - 1));
 | 
			
		||||
			auto existing (std::next (blocks.begin (), random_offset));
 | 
			
		||||
			if (existing == blocks.end ())
 | 
			
		||||
			{
 | 
			
		||||
				existing = blocks.begin ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#include <rai/secure/common.hpp>
 | 
			
		||||
 | 
			
		||||
#include <rai/lib/interface.h>
 | 
			
		||||
#include <rai/lib/numbers.hpp>
 | 
			
		||||
#include <rai/node/common.hpp>
 | 
			
		||||
#include <rai/secure/blockstore.hpp>
 | 
			
		||||
#include <rai/secure/versioning.hpp>
 | 
			
		||||
| 
						 | 
				
			
			@ -673,11 +674,10 @@ std::shared_ptr<rai::vote> rai::vote_uniquer::unique (std::shared_ptr<rai::vote>
 | 
			
		|||
		{
 | 
			
		||||
			existing = vote_a;
 | 
			
		||||
		}
 | 
			
		||||
		for (auto i (0); i < cleanup_count; ++i)
 | 
			
		||||
		for (auto i (0); i < cleanup_count && votes.size () > 0; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			rai::uint256_union random;
 | 
			
		||||
			rai::random_pool.GenerateBlock (random.bytes.data (), random.bytes.size ());
 | 
			
		||||
			auto existing (votes.find (random));
 | 
			
		||||
			auto random_offset (rai::random_pool.GenerateWord32 (0, votes.size () - 1));
 | 
			
		||||
			auto existing (std::next (votes.begin (), random_offset));
 | 
			
		||||
			if (existing == votes.end ())
 | 
			
		||||
			{
 | 
			
		||||
				existing = votes.begin ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue