From efeb273305e3e4d2c42e1e153de83c1cb6f0a28c Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 2 Jun 2017 17:52:37 -0700 Subject: Force on-the-fly compaction during pertxout upgrade --- src/txdb.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/txdb.cpp') diff --git a/src/txdb.cpp b/src/txdb.cpp index aa0b73a41..fd730c368 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -375,12 +375,13 @@ bool CCoinsViewDB::Upgrade() { CDBBatch batch(db); uiInterface.SetProgressBreakAction(StartShutdown); int reportDone = 0; + std::pair key; + std::pair prev_key = {DB_COINS, uint256()}; while (pcursor->Valid()) { boost::this_thread::interruption_point(); if (ShutdownRequested()) { break; } - std::pair key; if (pcursor->GetKey(key) && key.first == DB_COINS) { if (count++ % 256 == 0) { uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1); @@ -409,6 +410,8 @@ bool CCoinsViewDB::Upgrade() { if (batch.SizeEstimate() > batch_size) { db.WriteBatch(batch); batch.Clear(); + db.CompactRange(prev_key, key); + prev_key = key; } pcursor->Next(); } else { @@ -416,6 +419,7 @@ bool CCoinsViewDB::Upgrade() { } } db.WriteBatch(batch); + db.CompactRange({DB_COINS, uint256()}, key); uiInterface.SetProgressBreakAction(std::function()); LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE"); return true; -- cgit v1.2.3