leveldbwrapper symbol rename: Remove "Level" from class, etc. names
This commit is contained in:
parent
7249ee6d7c
commit
f345c41ec4
|
@ -20,12 +20,12 @@ void HandleError(const leveldb::Status& status)
|
|||
return;
|
||||
LogPrintf("%s\n", status.ToString());
|
||||
if (status.IsCorruption())
|
||||
throw leveldb_error("Database corrupted");
|
||||
throw dbwrapper_error("Database corrupted");
|
||||
if (status.IsIOError())
|
||||
throw leveldb_error("Database I/O error");
|
||||
throw dbwrapper_error("Database I/O error");
|
||||
if (status.IsNotFound())
|
||||
throw leveldb_error("Database entry missing");
|
||||
throw leveldb_error("Unknown database error");
|
||||
throw dbwrapper_error("Database entry missing");
|
||||
throw dbwrapper_error("Unknown database error");
|
||||
}
|
||||
|
||||
static leveldb::Options GetOptions(size_t nCacheSize)
|
||||
|
@ -44,7 +44,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)
|
|||
return options;
|
||||
}
|
||||
|
||||
CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe)
|
||||
CDBWrapper::CDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe)
|
||||
{
|
||||
penv = NULL;
|
||||
readoptions.verify_checksums = true;
|
||||
|
@ -70,7 +70,7 @@ CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCa
|
|||
LogPrintf("Opened LevelDB successfully\n");
|
||||
}
|
||||
|
||||
CLevelDBWrapper::~CLevelDBWrapper()
|
||||
CDBWrapper::~CDBWrapper()
|
||||
{
|
||||
delete pdb;
|
||||
pdb = NULL;
|
||||
|
@ -82,21 +82,21 @@ CLevelDBWrapper::~CLevelDBWrapper()
|
|||
options.env = NULL;
|
||||
}
|
||||
|
||||
bool CLevelDBWrapper::WriteBatch(CLevelDBBatch& batch, bool fSync)
|
||||
bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
|
||||
{
|
||||
leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch);
|
||||
HandleError(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLevelDBWrapper::IsEmpty()
|
||||
bool CDBWrapper::IsEmpty()
|
||||
{
|
||||
boost::scoped_ptr<CLevelDBIterator> it(NewIterator());
|
||||
boost::scoped_ptr<CDBIterator> it(NewIterator());
|
||||
it->SeekToFirst();
|
||||
return !(it->Valid());
|
||||
}
|
||||
|
||||
CLevelDBIterator::~CLevelDBIterator() { delete piter; }
|
||||
bool CLevelDBIterator::Valid() { return piter->Valid(); }
|
||||
void CLevelDBIterator::SeekToFirst() { piter->SeekToFirst(); }
|
||||
void CLevelDBIterator::Next() { piter->Next(); }
|
||||
CDBIterator::~CDBIterator() { delete piter; }
|
||||
bool CDBIterator::Valid() { return piter->Valid(); }
|
||||
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }
|
||||
void CDBIterator::Next() { piter->Next(); }
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
#include <leveldb/db.h>
|
||||
#include <leveldb/write_batch.h>
|
||||
|
||||
class leveldb_error : public std::runtime_error
|
||||
class dbwrapper_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
leveldb_error(const std::string& msg) : std::runtime_error(msg) {}
|
||||
dbwrapper_error(const std::string& msg) : std::runtime_error(msg) {}
|
||||
};
|
||||
|
||||
void HandleError(const leveldb::Status& status);
|
||||
|
||||
/** Batch of changes queued to be written to a CLevelDBWrapper */
|
||||
class CLevelDBBatch
|
||||
/** Batch of changes queued to be written to a CDBWrapper */
|
||||
class CDBBatch
|
||||
{
|
||||
friend class CLevelDBWrapper;
|
||||
friend class CDBWrapper;
|
||||
|
||||
private:
|
||||
leveldb::WriteBatch batch;
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class CLevelDBIterator
|
||||
class CDBIterator
|
||||
{
|
||||
private:
|
||||
leveldb::Iterator *piter;
|
||||
|
@ -71,9 +71,9 @@ public:
|
|||
/**
|
||||
* @param[in] piterIn The original leveldb iterator.
|
||||
*/
|
||||
CLevelDBIterator(leveldb::Iterator *piterIn) :
|
||||
CDBIterator(leveldb::Iterator *piterIn) :
|
||||
piter(piterIn) { };
|
||||
~CLevelDBIterator();
|
||||
~CDBIterator();
|
||||
|
||||
bool Valid();
|
||||
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class CLevelDBWrapper
|
||||
class CDBWrapper
|
||||
{
|
||||
private:
|
||||
//! custom environment this database is using (may be NULL in case of default environment)
|
||||
|
@ -152,8 +152,8 @@ public:
|
|||
* @param[in] fMemory If true, use leveldb's memory environment.
|
||||
* @param[in] fWipe If true, remove all existing data.
|
||||
*/
|
||||
CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||
~CLevelDBWrapper();
|
||||
CDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||
~CDBWrapper();
|
||||
|
||||
template <typename K, typename V>
|
||||
bool Read(const K& key, V& value) const
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
template <typename K, typename V>
|
||||
bool Write(const K& key, const V& value, bool fSync = false)
|
||||
{
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
batch.Write(key, value);
|
||||
return WriteBatch(batch, fSync);
|
||||
}
|
||||
|
@ -210,12 +210,12 @@ public:
|
|||
template <typename K>
|
||||
bool Erase(const K& key, bool fSync = false)
|
||||
{
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
batch.Erase(key);
|
||||
return WriteBatch(batch, fSync);
|
||||
}
|
||||
|
||||
bool WriteBatch(CLevelDBBatch& batch, bool fSync = false);
|
||||
bool WriteBatch(CDBBatch& batch, bool fSync = false);
|
||||
|
||||
// not available for LevelDB; provide for compatibility with BDB
|
||||
bool Flush()
|
||||
|
@ -225,13 +225,13 @@ public:
|
|||
|
||||
bool Sync()
|
||||
{
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
return WriteBatch(batch, true);
|
||||
}
|
||||
|
||||
CLevelDBIterator *NewIterator()
|
||||
CDBIterator *NewIterator()
|
||||
{
|
||||
return new CLevelDBIterator(pdb->NewIterator(iteroptions));
|
||||
return new CDBIterator(pdb->NewIterator(iteroptions));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,13 +25,13 @@ bool is_null_key(const vector<unsigned char>& key) {
|
|||
return isnull;
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(leveldbwrapper_tests, BasicTestingSetup)
|
||||
BOOST_FIXTURE_TEST_SUITE(dbwrapper_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(leveldbwrapper)
|
||||
BOOST_AUTO_TEST_CASE(dbwrapper)
|
||||
{
|
||||
{
|
||||
path ph = temp_directory_path() / unique_path();
|
||||
CLevelDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
char key = 'k';
|
||||
uint256 in = GetRandHash();
|
||||
uint256 res;
|
||||
|
@ -43,11 +43,11 @@ BOOST_AUTO_TEST_CASE(leveldbwrapper)
|
|||
}
|
||||
|
||||
// Test batch operations
|
||||
BOOST_AUTO_TEST_CASE(leveldbwrapper_batch)
|
||||
BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
||||
{
|
||||
{
|
||||
path ph = temp_directory_path() / unique_path();
|
||||
CLevelDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
|
||||
char key = 'i';
|
||||
uint256 in = GetRandHash();
|
||||
|
@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(leveldbwrapper_batch)
|
|||
uint256 in3 = GetRandHash();
|
||||
|
||||
uint256 res;
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
|
||||
batch.Write(key, in);
|
||||
batch.Write(key2, in2);
|
||||
|
@ -78,11 +78,11 @@ BOOST_AUTO_TEST_CASE(leveldbwrapper_batch)
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(leveldbwrapper_iterator)
|
||||
BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
{
|
||||
{
|
||||
path ph = temp_directory_path() / unique_path();
|
||||
CLevelDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false);
|
||||
|
||||
// The two keys are intentionally chosen for ordering
|
||||
char key = 'j';
|
||||
|
@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(leveldbwrapper_iterator)
|
|||
uint256 in2 = GetRandHash();
|
||||
BOOST_CHECK(dbw.Write(key2, in2));
|
||||
|
||||
boost::scoped_ptr<CLevelDBIterator> it(const_cast<CLevelDBWrapper*>(&dbw)->NewIterator());
|
||||
boost::scoped_ptr<CDBIterator> it(const_cast<CDBWrapper*>(&dbw)->NewIterator());
|
||||
|
||||
// Be sure to seek past any earlier key (if it exists)
|
||||
it->Seek(key);
|
||||
|
|
12
src/txdb.cpp
12
src/txdb.cpp
|
@ -85,7 +85,7 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
|||
const uint256 &hashAnchor,
|
||||
CAnchorsMap &mapAnchors,
|
||||
CNullifiersMap &mapNullifiers) {
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
size_t count = 0;
|
||||
size_t changed = 0;
|
||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
|
||||
|
@ -135,7 +135,7 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
|||
return db.WriteBatch(batch);
|
||||
}
|
||||
|
||||
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CLevelDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
|
||||
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
|
||||
|
@ -162,7 +162,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
|
|||
/* It seems that there are no "const iterators" for LevelDB. Since we
|
||||
only need read operations on it, use a const-cast to get around
|
||||
that restriction. */
|
||||
boost::scoped_ptr<CLevelDBIterator> pcursor(const_cast<CLevelDBWrapper*>(&db)->NewIterator());
|
||||
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&db)->NewIterator());
|
||||
pcursor->Seek(DB_COINS);
|
||||
|
||||
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
@ -205,7 +205,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
|
|||
}
|
||||
|
||||
bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
for (std::vector<std::pair<int, const CBlockFileInfo*> >::const_iterator it=fileInfo.begin(); it != fileInfo.end(); it++) {
|
||||
batch.Write(make_pair(DB_BLOCK_FILES, it->first), *it->second);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) {
|
|||
}
|
||||
|
||||
bool CBlockTreeDB::WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> >&vect) {
|
||||
CLevelDBBatch batch;
|
||||
CDBBatch batch;
|
||||
for (std::vector<std::pair<uint256,CDiskTxPos> >::const_iterator it=vect.begin(); it!=vect.end(); it++)
|
||||
batch.Write(make_pair(DB_TXINDEX, it->first), it->second);
|
||||
return WriteBatch(batch);
|
||||
|
@ -249,7 +249,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
|
|||
|
||||
bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
{
|
||||
boost::scoped_ptr<CLevelDBIterator> pcursor(NewIterator());
|
||||
boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
pcursor->Seek(make_pair(DB_BLOCK_INDEX, uint256()));
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
|
|||
//! min. -dbcache in (MiB)
|
||||
static const int64_t nMinDbCache = 4;
|
||||
|
||||
/** CCoinsView backed by the LevelDB coin database (chainstate/) */
|
||||
/** CCoinsView backed by the coin database (chainstate/) */
|
||||
class CCoinsViewDB : public CCoinsView
|
||||
{
|
||||
protected:
|
||||
CLevelDBWrapper db;
|
||||
CDBWrapper db;
|
||||
CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||
public:
|
||||
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
};
|
||||
|
||||
/** Access to the block database (blocks/index/) */
|
||||
class CBlockTreeDB : public CLevelDBWrapper
|
||||
class CBlockTreeDB : public CDBWrapper
|
||||
{
|
||||
public:
|
||||
CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||
|
|
Loading…
Reference in New Issue