Must wait for previous batch to finish before starting new one

This commit is contained in:
Howard Chu 2017-01-14 11:28:17 -08:00 committed by Howard Chu
parent c903c5541e
commit eaf8470b29
No known key found for this signature in database
GPG Key ID: FD2A70B44AB11BA7
1 changed files with 6 additions and 1 deletions

View File

@ -3544,12 +3544,17 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
{ {
LOG_PRINT_YELLOW("Blockchain::" << __func__, LOG_LEVEL_3); LOG_PRINT_YELLOW("Blockchain::" << __func__, LOG_LEVEL_3);
TIME_MEASURE_START(prepare); TIME_MEASURE_START(prepare);
bool stop_batch;
CRITICAL_REGION_LOCAL(m_blockchain_lock); CRITICAL_REGION_LOCAL(m_blockchain_lock);
if(blocks_entry.size() == 0) if(blocks_entry.size() == 0)
return false; return false;
m_db->batch_start(blocks_entry.size()); while (!(stop_batch = m_db->batch_start(blocks_entry.size()))) {
m_blockchain_lock.unlock();
epee::misc_utils::sleep_no_w(1000);
m_blockchain_lock.lock();
}
if ((m_db->height() + blocks_entry.size()) < m_blocks_hash_check.size()) if ((m_db->height() + blocks_entry.size()) < m_blocks_hash_check.size())
return true; return true;