Skip to content

Commit

Permalink
Rename leveldb.{h,cpp} to leveldbwrapper.{h,cpp}.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandondahler committed Nov 9, 2013
1 parent 995cb28 commit b64187d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DIST_SUBDIRS = . qt test
BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
bitcoinrpc.h bloom.h chainparams.h checkpoints.h checkqueue.h \
clientversion.h compat.h core.h crypter.h db.h hash.h init.h \
key.h keystore.h leveldb.h limitedmap.h main.h miner.h mruset.h \
key.h keystore.h leveldbwrapper.h limitedmap.h main.h miner.h mruset.h \
netbase.h net.h protocol.h script.h serialize.h sync.h threadsafety.h \
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h

Expand All @@ -33,7 +33,7 @@ version.o: obj/build.h

libbitcoin_a_SOURCES = addrman.cpp alert.cpp allocators.cpp bitcoinrpc.cpp bloom.cpp \
chainparams.cpp checkpoints.cpp core.cpp crypter.cpp db.cpp hash.cpp \
init.cpp key.cpp keystore.cpp leveldb.cpp main.cpp miner.cpp \
init.cpp key.cpp keystore.cpp leveldbwrapper.cpp main.cpp miner.cpp \
netbase.cpp net.cpp noui.cpp protocol.cpp rpcblockchain.cpp rpcdump.cpp \
rpcmining.cpp rpcnet.cpp rpcrawtransaction.cpp rpcwallet.cpp script.cpp \
sync.cpp txdb.cpp txmempool.cpp util.cpp version.cpp wallet.cpp walletdb.cpp $(JSON_H) \
Expand Down
10 changes: 5 additions & 5 deletions src/leveldb.cpp → src/leveldbwrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2012 The Bitcoin developers
// Copyright (c) 2012-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "leveldb.h"
#include "leveldbwrapper.h"
#include "util.h"

#include <leveldb/env.h>
Expand Down Expand Up @@ -35,7 +35,7 @@ static leveldb::Options GetOptions(size_t nCacheSize) {
return options;
}

CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) {
CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) {
penv = NULL;
readoptions.verify_checksums = true;
iteroptions.verify_checksums = true;
Expand All @@ -59,7 +59,7 @@ CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool
LogPrintf("Opened LevelDB successfully\n");
}

CLevelDB::~CLevelDB() {
CLevelDBWrapper::~CLevelDBWrapper() {
delete pdb;
pdb = NULL;
delete options.filter_policy;
Expand All @@ -70,7 +70,7 @@ CLevelDB::~CLevelDB() {
options.env = NULL;
}

bool CLevelDB::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) {
bool CLevelDBWrapper::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) {
leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch);
HandleError(status);
return true;
Expand Down
19 changes: 10 additions & 9 deletions src/leveldb.h → src/leveldbwrapper.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) 2012 The Bitcoin developers
// Copyright (c) 2012-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_LEVELDB_H
#define BITCOIN_LEVELDB_H

#ifndef BITCOIN_LEVELDBWRAPPER_H
#define BITCOIN_LEVELDBWRAPPER_H

#include "serialize.h"
#include "util.h"
Expand All @@ -20,10 +21,10 @@ class leveldb_error : public std::runtime_error

void HandleError(const leveldb::Status &status) throw(leveldb_error);

// Batch of changes queued to be written to a CLevelDB
// Batch of changes queued to be written to a CLevelDBWrapper
class CLevelDBBatch
{
friend class CLevelDB;
friend class CLevelDBWrapper;

private:
leveldb::WriteBatch batch;
Expand Down Expand Up @@ -53,7 +54,7 @@ class CLevelDBBatch
}
};

class CLevelDB
class CLevelDBWrapper
{
private:
// custom environment this database is using (may be NULL in case of default environment)
Expand All @@ -78,8 +79,8 @@ class CLevelDB
leveldb::DB *pdb;

public:
CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
~CLevelDB();
CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
~CLevelDBWrapper();

template<typename K, typename V> bool Read(const K& key, V& value) throw(leveldb_error) {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
Expand Down Expand Up @@ -151,4 +152,4 @@ class CLevelDB
}
};

#endif // BITCOIN_LEVELDB_H
#endif // BITCOIN_LEVELDBWRAPPER_H
2 changes: 1 addition & 1 deletion src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool CCoinsViewDB::BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockI
return db.WriteBatch(batch);
}

CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CLevelDB(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CLevelDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
}

bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
Expand Down
6 changes: 3 additions & 3 deletions src/txdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#define BITCOIN_TXDB_LEVELDB_H

#include "main.h"
#include "leveldb.h"
#include "leveldbwrapper.h"

/** CCoinsView backed by the LevelDB coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView
{
protected:
CLevelDB db;
CLevelDBWrapper db;
public:
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);

Expand All @@ -26,7 +26,7 @@ class CCoinsViewDB : public CCoinsView
};

/** Access to the block database (blocks/index/) */
class CBlockTreeDB : public CLevelDB
class CBlockTreeDB : public CLevelDBWrapper
{
public:
CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
Expand Down

0 comments on commit b64187d

Please sign in to comment.