aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-06-02 17:52:37 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-07-27 21:07:19 -0700
commitefeb273305e3e4d2c42e1e153de83c1cb6f0a28c (patch)
treeb4a27f9835aa26209d8e8f4c77928539674300fd /src/txdb.cpp
parent0c70e845aa9277a4ceb8307f0ad8f1bf7511e3c8 (diff)
downloadbitcoin-efeb273305e3e4d2c42e1e153de83c1cb6f0a28c.tar.xz
Force on-the-fly compaction during pertxout upgrade
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index aa0b73a417..fd730c368a 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<unsigned char, uint256> key;
+ std::pair<unsigned char, uint256> prev_key = {DB_COINS, uint256()};
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
if (ShutdownRequested()) {
break;
}
- std::pair<unsigned char, uint256> 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<void(void)>());
LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE");
return true;