core: avoid double parsing blocks after hoh

This commit is contained in:
moneromooo-monero 2018-11-23 11:15:04 +00:00
parent dc5a76095c
commit 238401d4e9
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
6 changed files with 50 additions and 25 deletions

View file

@ -418,7 +418,8 @@ namespace cryptonote
m_core.pause_mine();
std::vector<block_complete_entry> blocks;
blocks.push_back(arg.b);
m_core.prepare_handle_incoming_blocks(blocks);
std::vector<block> pblocks;
m_core.prepare_handle_incoming_blocks(blocks, pblocks);
for(auto tx_blob_it = arg.b.txs.begin(); tx_blob_it!=arg.b.txs.end();tx_blob_it++)
{
cryptonote::tx_verification_context tvc = AUTO_VAL_INIT(tvc);
@ -434,7 +435,7 @@ namespace cryptonote
}
block_verification_context bvc = boost::value_initialized<block_verification_context>();
m_core.handle_incoming_block(arg.b.block, bvc); // got block from handle_notify_new_block
m_core.handle_incoming_block(arg.b.block, pblocks.empty() ? NULL : &pblocks[0], bvc); // got block from handle_notify_new_block
if (!m_core.cleanup_handle_incoming_blocks(true))
{
LOG_PRINT_CCONTEXT_L0("Failure in cleanup_handle_incoming_blocks");
@ -697,10 +698,11 @@ namespace cryptonote
std::vector<block_complete_entry> blocks;
blocks.push_back(b);
m_core.prepare_handle_incoming_blocks(blocks);
std::vector<block> pblocks;
m_core.prepare_handle_incoming_blocks(blocks, pblocks);
block_verification_context bvc = boost::value_initialized<block_verification_context>();
m_core.handle_incoming_block(arg.b.block, bvc); // got block from handle_notify_new_block
m_core.handle_incoming_block(arg.b.block, pblocks.empty() ? NULL : &pblocks[0], bvc); // got block from handle_notify_new_block
if (!m_core.cleanup_handle_incoming_blocks(true))
{
LOG_PRINT_CCONTEXT_L0("Failure in cleanup_handle_incoming_blocks");
@ -1174,10 +1176,17 @@ namespace cryptonote
}
}
m_core.prepare_handle_incoming_blocks(blocks);
std::vector<block> pblocks;
m_core.prepare_handle_incoming_blocks(blocks, pblocks);
if (!pblocks.empty() && pblocks.size() != blocks.size())
{
m_core.cleanup_handle_incoming_blocks();
LOG_ERROR_CCONTEXT("Internal error: blocks.size() != block_entry.txs.size()");
return 1;
}
uint64_t block_process_time_full = 0, transactions_process_time_full = 0;
size_t num_txs = 0;
size_t num_txs = 0, blockidx = 0;
for(const block_complete_entry& block_entry: blocks)
{
if (m_stopping)
@ -1229,7 +1238,7 @@ namespace cryptonote
TIME_MEASURE_START(block_process_time);
block_verification_context bvc = boost::value_initialized<block_verification_context>();
m_core.handle_incoming_block(block_entry.block, bvc, false); // <--- process block
m_core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx], bvc, false); // <--- process block
if(bvc.m_verifivation_failed)
{
@ -1272,6 +1281,7 @@ namespace cryptonote
TIME_MEASURE_FINISH(block_process_time);
block_process_time_full += block_process_time;
++blockidx;
} // each download block