diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-02 17:52:37 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-07-27 21:07:19 -0700 |
commit | efeb273305e3e4d2c42e1e153de83c1cb6f0a28c (patch) | |
tree | b4a27f9835aa26209d8e8f4c77928539674300fd /src/dbwrapper.h | |
parent | 0c70e845aa9277a4ceb8307f0ad8f1bf7511e3c8 (diff) |
Force on-the-fly compaction during pertxout upgrade
Diffstat (limited to 'src/dbwrapper.h')
-rw-r--r-- | src/dbwrapper.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 24ef71bfbf..d36188652a 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -321,6 +321,23 @@ public: pdb->GetApproximateSizes(&range, 1, &size); return size; } + + /** + * Compact a certain range of keys in the database. + */ + template<typename K> + void CompactRange(const K& key_begin, const K& key_end) const + { + CDataStream ssKey1(SER_DISK, CLIENT_VERSION), ssKey2(SER_DISK, CLIENT_VERSION); + ssKey1.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); + ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); + ssKey1 << key_begin; + ssKey2 << key_end; + leveldb::Slice slKey1(ssKey1.data(), ssKey1.size()); + leveldb::Slice slKey2(ssKey2.data(), ssKey2.size()); + pdb->CompactRange(&slKey1, &slKey2); + } + }; #endif // BITCOIN_DBWRAPPER_H |