mirror of
https://github.com/monero-project/monero.git
synced 2026-01-18 15:46:59 -08:00
Merge pull request #1506
3ff54bddCheck for correct thread before ending batch transaction (Howard Chu)eaf8470bMust wait for previous batch to finish before starting new one (Howard Chu)c903c554Don't cache block height, always get from DB (Howard Chu)eb1fb601Tweak default db-sync-mode to fast:async:1 (Howard Chu)0693cff9Use batch transactions when syncing (Howard Chu)
This commit is contained in:
@@ -3381,9 +3381,10 @@ bool Blockchain::add_new_block(const block& bl_, block_verification_context& bvc
|
||||
void Blockchain::check_against_checkpoints(const checkpoints& points, bool enforce)
|
||||
{
|
||||
const auto& pts = points.get_points();
|
||||
bool stop_batch;
|
||||
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
m_db->batch_start();
|
||||
stop_batch = m_db->batch_start();
|
||||
for (const auto& pt : pts)
|
||||
{
|
||||
// if the checkpoint is for a block we don't have yet, move on
|
||||
@@ -3407,7 +3408,8 @@ void Blockchain::check_against_checkpoints(const checkpoints& points, bool enfor
|
||||
}
|
||||
}
|
||||
}
|
||||
m_db->batch_stop();
|
||||
if (stop_batch)
|
||||
m_db->batch_stop();
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
// returns false if any of the checkpoints loading returns false.
|
||||
@@ -3481,6 +3483,7 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync)
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
TIME_MEASURE_START(t1);
|
||||
|
||||
m_db->batch_stop();
|
||||
if (m_sync_counter > 0)
|
||||
{
|
||||
if (force_sync)
|
||||
@@ -3545,11 +3548,18 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
|
||||
{
|
||||
LOG_PRINT_YELLOW("Blockchain::" << __func__, LOG_LEVEL_3);
|
||||
TIME_MEASURE_START(prepare);
|
||||
bool stop_batch;
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
|
||||
if(blocks_entry.size() == 0)
|
||||
return false;
|
||||
|
||||
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())
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user