Browse Source

leveldbwrapper: Remove unused .Prev(), .SeekToLast() methods

Also, trim trailing whitespace.
0.13
Jeff Garzik 9 years ago committed by Jeff Garzik
parent
commit
6ec4b7eb20
  1. 20
      src/leveldbwrapper.cpp
  2. 12
      src/leveldbwrapper.h

20
src/leveldbwrapper.cpp

@ -76,7 +76,7 @@ CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCa
bool key_exists = Read(OBFUSCATE_KEY_KEY, obfuscate_key); bool key_exists = Read(OBFUSCATE_KEY_KEY, obfuscate_key);
if (!key_exists && obfuscate && IsEmpty()) { if (!key_exists && obfuscate && IsEmpty()) {
// Initialize non-degenerate obfuscation if it won't upset // Initialize non-degenerate obfuscation if it won't upset
// existing, non-obfuscated data. // existing, non-obfuscated data.
std::vector<unsigned char> new_key = CreateObfuscateKey(); std::vector<unsigned char> new_key = CreateObfuscateKey();
@ -118,10 +118,10 @@ const std::string CLevelDBWrapper::OBFUSCATE_KEY_KEY("\000obfuscate_key", 14);
const unsigned int CLevelDBWrapper::OBFUSCATE_KEY_NUM_BYTES = 8; const unsigned int CLevelDBWrapper::OBFUSCATE_KEY_NUM_BYTES = 8;
/** /**
* Returns a string (consisting of 8 random bytes) suitable for use as an * Returns a string (consisting of 8 random bytes) suitable for use as an
* obfuscating XOR key. * obfuscating XOR key.
*/ */
std::vector<unsigned char> CLevelDBWrapper::CreateObfuscateKey() const std::vector<unsigned char> CLevelDBWrapper::CreateObfuscateKey() const
{ {
unsigned char buff[OBFUSCATE_KEY_NUM_BYTES]; unsigned char buff[OBFUSCATE_KEY_NUM_BYTES];
GetRandBytes(buff, OBFUSCATE_KEY_NUM_BYTES); GetRandBytes(buff, OBFUSCATE_KEY_NUM_BYTES);
@ -136,19 +136,17 @@ bool CLevelDBWrapper::IsEmpty()
return !(it->Valid()); return !(it->Valid());
} }
const std::vector<unsigned char>& CLevelDBWrapper::GetObfuscateKey() const const std::vector<unsigned char>& CLevelDBWrapper::GetObfuscateKey() const
{ {
return obfuscate_key; return obfuscate_key;
} }
std::string CLevelDBWrapper::GetObfuscateKeyHex() const std::string CLevelDBWrapper::GetObfuscateKeyHex() const
{ {
return HexStr(obfuscate_key); return HexStr(obfuscate_key);
} }
CLevelDBIterator::~CLevelDBIterator() { delete piter; } CLevelDBIterator::~CLevelDBIterator() { delete piter; }
bool CLevelDBIterator::Valid() { return piter->Valid(); } bool CLevelDBIterator::Valid() { return piter->Valid(); }
void CLevelDBIterator::SeekToFirst() { piter->SeekToFirst(); } void CLevelDBIterator::SeekToFirst() { piter->SeekToFirst(); }
void CLevelDBIterator::SeekToLast() { piter->SeekToLast(); }
void CLevelDBIterator::Next() { piter->Next(); } void CLevelDBIterator::Next() { piter->Next(); }
void CLevelDBIterator::Prev() { piter->Prev(); }

12
src/leveldbwrapper.h

@ -68,7 +68,7 @@ public:
batch.Delete(slKey); batch.Delete(slKey);
} }
}; };
class CLevelDBIterator class CLevelDBIterator
{ {
private: private:
@ -88,7 +88,6 @@ public:
bool Valid(); bool Valid();
void SeekToFirst(); void SeekToFirst();
void SeekToLast();
template<typename K> void Seek(const K& key) { template<typename K> void Seek(const K& key) {
CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssKey(SER_DISK, CLIENT_VERSION);
@ -99,7 +98,6 @@ public:
} }
void Next(); void Next();
void Prev();
template<typename K> bool GetKey(K& key) { template<typename K> bool GetKey(K& key) {
leveldb::Slice slKey = piter->key(); leveldb::Slice slKey = piter->key();
@ -133,7 +131,7 @@ public:
} }
}; };
class CLevelDBWrapper class CLevelDBWrapper
{ {
private: private:
@ -163,10 +161,10 @@ private:
//! the key under which the obfuscation key is stored //! the key under which the obfuscation key is stored
static const std::string OBFUSCATE_KEY_KEY; static const std::string OBFUSCATE_KEY_KEY;
//! the length of the obfuscate key in number of bytes //! the length of the obfuscate key in number of bytes
static const unsigned int OBFUSCATE_KEY_NUM_BYTES; static const unsigned int OBFUSCATE_KEY_NUM_BYTES;
std::vector<unsigned char> CreateObfuscateKey() const; std::vector<unsigned char> CreateObfuscateKey() const;
public: public:
@ -256,7 +254,7 @@ public:
return WriteBatch(batch, true); return WriteBatch(batch, true);
} }
CLevelDBIterator *NewIterator() CLevelDBIterator *NewIterator()
{ {
return new CLevelDBIterator(pdb->NewIterator(iteroptions), &obfuscate_key); return new CLevelDBIterator(pdb->NewIterator(iteroptions), &obfuscate_key);
} }

Loading…
Cancel
Save