aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol/cryptonote_protocol_handler.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-11-23 11:15:04 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-05 11:58:13 +0000
commit238401d4e950dad6a243fb895027dd26d2992ee6 (patch)
treeace8c69b75f6e6db2d2bdad69456ce346348b48c /src/cryptonote_protocol/cryptonote_protocol_handler.inl
parentblockchain: avoid unneeded block copy (diff)
downloadmonero-238401d4e950dad6a243fb895027dd26d2992ee6.tar.xz
core: avoid double parsing blocks after hoh
Diffstat (limited to 'src/cryptonote_protocol/cryptonote_protocol_handler.inl')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 8fada4e3c..9c2e1df88 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -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