diff options
author | James O'Beirne <james.obeirne@gmail.com> | 2015-10-08 00:44:10 -0700 |
---|---|---|
committer | James O'Beirne <james.obeirne@gmail.com> | 2015-10-08 09:32:27 -0700 |
commit | 0fdf8c80ee322ab747321d61faf9c72af4a51445 (patch) | |
tree | b9e94a6249b05fa597d9f3926316215c74710c60 /src/leveldbwrapper.h | |
parent | 3499ce1e1ad87a86598d00b7124072c91ddad833 (diff) |
Handle obfuscation in CLevelDBIterator
Diffstat (limited to 'src/leveldbwrapper.h')
-rw-r--r-- | src/leveldbwrapper.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h index ece4e49694..891381c5f2 100644 --- a/src/leveldbwrapper.h +++ b/src/leveldbwrapper.h @@ -73,9 +73,16 @@ class CLevelDBIterator { private: leveldb::Iterator *piter; + const std::vector<unsigned char> obfuscate_key; public: - CLevelDBIterator(leveldb::Iterator *piterIn) : piter(piterIn) {} + + /** + * @param[in] piterIn The original leveldb iterator. + * @param[in] obfuscate_key If passed, XOR data with this key. + */ + CLevelDBIterator(leveldb::Iterator *piterIn, const std::vector<unsigned char>& obfuscate_key) : + piter(piterIn), obfuscate_key(obfuscate_key) { }; ~CLevelDBIterator(); bool Valid(); @@ -113,7 +120,7 @@ public: leveldb::Slice slValue = piter->value(); try { CDataStream ssValue(slValue.data(), slValue.data() + slValue.size(), SER_DISK, CLIENT_VERSION); - ssValue.Xor(db.GetObfuscateKey()); + ssValue.Xor(obfuscate_key); ssValue >> value; } catch(std::exception &e) { return false; @@ -251,8 +258,8 @@ public: CLevelDBIterator *NewIterator() { - return new CLevelDBIterator(pdb->NewIterator(iteroptions)); - { + return new CLevelDBIterator(pdb->NewIterator(iteroptions), obfuscate_key); + } /** * Return true if the database managed by this class contains no entries. |