cryptonote: avoid double parsing blocks when syncing

This commit is contained in:
moneromooo-monero
2018-11-23 13:05:48 +00:00
parent 9feda0eeba
commit 88c85c18e0
7 changed files with 39 additions and 22 deletions
+11 -2
View File
@@ -1331,7 +1331,12 @@ namespace cryptonote
return false;
}
std::vector<block> pblocks;
prepare_handle_incoming_blocks(blocks, pblocks);
if (!prepare_handle_incoming_blocks(blocks, pblocks))
{
MERROR("Block found, but failed to prepare to add");
m_miner.resume();
return false;
}
m_blockchain_storage.add_new_block(b, bvc);
cleanup_handle_incoming_blocks(true);
//anyway - update miner template
@@ -1385,7 +1390,11 @@ namespace cryptonote
bool core::prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks)
{
m_incoming_tx_lock.lock();
m_blockchain_storage.prepare_handle_incoming_blocks(blocks_entry, blocks);
if (!m_blockchain_storage.prepare_handle_incoming_blocks(blocks_entry, blocks))
{
cleanup_handle_incoming_blocks(false);
return false;
}
return true;
}