Don't insert a block in to the processing queue if it's already marked as active which implies it's already been added to the queue.
This commit is contained in:
parent
7eb3bd599a
commit
34c7fbd33e
4 changed files with 15 additions and 13 deletions
|
@ -1824,8 +1824,10 @@ void rai::network::confirm_send (rai::confirm_ack const & confirm_a, std::shared
|
|||
|
||||
void rai::node::process_active (std::shared_ptr<rai::block> incoming)
|
||||
{
|
||||
block_arrival.add (incoming->hash ());
|
||||
block_processor.add (incoming);
|
||||
if (!block_arrival.add (incoming->hash ()))
|
||||
{
|
||||
block_processor.add (incoming);
|
||||
}
|
||||
}
|
||||
|
||||
rai::process_return rai::node::process (rai::block const & block_a)
|
||||
|
@ -2589,11 +2591,13 @@ rai::endpoint rai::network::endpoint ()
|
|||
return rai::endpoint (boost::asio::ip::address_v6::loopback (), port);
|
||||
}
|
||||
|
||||
void rai::block_arrival::add (rai::block_hash const & hash_a)
|
||||
bool rai::block_arrival::add (rai::block_hash const & hash_a)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
auto now (std::chrono::steady_clock::now ());
|
||||
arrival.insert (rai::block_arrival_info{ now, hash_a });
|
||||
auto inserted (arrival.insert (rai::block_arrival_info{ now, hash_a }));
|
||||
auto result (!inserted.second);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rai::block_arrival::recent (rai::block_hash const & hash_a)
|
||||
|
|
|
@ -298,7 +298,8 @@ public:
|
|||
class block_arrival
|
||||
{
|
||||
public:
|
||||
void add (rai::block_hash const &);
|
||||
// Return `true' to indicated an error if the block has already been inserted
|
||||
bool add (rai::block_hash const &);
|
||||
bool recent (rai::block_hash const &);
|
||||
boost::multi_index_container<
|
||||
rai::block_arrival_info,
|
||||
|
|
|
@ -2594,7 +2594,7 @@ void rai::rpc_handler::process ()
|
|||
boost::property_tree::ptree block_l;
|
||||
std::stringstream block_stream (block_text);
|
||||
boost::property_tree::read_json (block_stream, block_l);
|
||||
auto block (rai::deserialize_block_json (block_l));
|
||||
std::shared_ptr<rai::block> block (rai::deserialize_block_json (block_l));
|
||||
if (block != nullptr)
|
||||
{
|
||||
if (!rai::work_validate (*block))
|
||||
|
@ -2604,7 +2604,7 @@ void rai::rpc_handler::process ()
|
|||
rai::process_return result;
|
||||
{
|
||||
rai::transaction transaction (node.store.environment, nullptr, true);
|
||||
result = node.block_processor.process_receive_one (transaction, std::move (block));
|
||||
result = node.block_processor.process_receive_one (transaction, block);
|
||||
}
|
||||
switch (result.code)
|
||||
{
|
||||
|
|
|
@ -914,8 +914,7 @@ std::shared_ptr<rai::block> rai::wallet::receive_action (rai::block const & send
|
|||
{
|
||||
node.work_generate_blocking (*block);
|
||||
}
|
||||
node.block_arrival.add (block->hash ());
|
||||
node.block_processor.add (block);
|
||||
node.process_active (block);
|
||||
node.block_processor.flush ();
|
||||
if (generate_work_a)
|
||||
{
|
||||
|
@ -960,8 +959,7 @@ std::shared_ptr<rai::block> rai::wallet::change_action (rai::account const & sou
|
|||
{
|
||||
node.work_generate_blocking (*block);
|
||||
}
|
||||
node.block_arrival.add (block->hash ());
|
||||
node.block_processor.add (block);
|
||||
node.process_active (block);
|
||||
node.block_processor.flush ();
|
||||
if (generate_work_a)
|
||||
{
|
||||
|
@ -1050,8 +1048,7 @@ std::shared_ptr<rai::block> rai::wallet::send_action (rai::account const & sourc
|
|||
{
|
||||
node.work_generate_blocking (*block);
|
||||
}
|
||||
node.block_arrival.add (block->hash ());
|
||||
node.block_processor.add (block);
|
||||
node.process_active (block);
|
||||
node.block_processor.flush ();
|
||||
if (generate_work_a)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue