aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authorHoward Chu <highlandsun@gmail.com>2016-12-26 14:29:46 -0800
committerHoward Chu <hyc@symas.com>2017-01-14 22:43:06 +0000
commit0693cff9251f91a05dd96b2f8910faea29cb29ce (patch)
tree51bc874f688229a4a1b582134521aaa674caf6a6 /src/cryptonote_core/blockchain.cpp
parentadd tx hash to time stats (diff)
downloadmonero-0693cff9251f91a05dd96b2f8910faea29cb29ce.tar.xz
Use batch transactions when syncing
Faster throughput while avoiding corruption. I.e., makes running with --db-sync-mode safe more tolerable.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 42279184a..b4ed06bc0 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -3377,9 +3377,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
@@ -3403,7 +3404,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.
@@ -3477,6 +3479,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)
@@ -3546,6 +3549,8 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
if(blocks_entry.size() == 0)
return false;
+ m_db->batch_start(blocks_entry.size());
+
if ((m_db->height() + blocks_entry.size()) < m_blocks_hash_check.size())
return true;