aboutsummaryrefslogtreecommitdiff
path: root/src/dbwrapper.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-05-12 15:19:19 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-05-26 13:33:39 -0700
commitc3aa0c11947dfd82702df276d39bb7f748dd83a1 (patch)
tree56b0c561bee4a5fcf9f6c54b85c9d1200569d718 /src/dbwrapper.h
parentd342424301013ec47dc146a4beb49d5c9319d80a (diff)
Report on-disk size in gettxoutsetinfo
Diffstat (limited to 'src/dbwrapper.h')
-rw-r--r--src/dbwrapper.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/dbwrapper.h b/src/dbwrapper.h
index 442f37b420..24ef71bfbf 100644
--- a/src/dbwrapper.h
+++ b/src/dbwrapper.h
@@ -305,7 +305,22 @@ public:
* Return true if the database managed by this class contains no entries.
*/
bool IsEmpty();
+
+ template<typename K>
+ size_t EstimateSize(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());
+ uint64_t size = 0;
+ leveldb::Range range(slKey1, slKey2);
+ pdb->GetApproximateSizes(&range, 1, &size);
+ return size;
+ }
};
#endif // BITCOIN_DBWRAPPER_H
-