Browse Source

Merge pull request #3211

b64187d Rename leveldb.{h,cpp} to leveldbwrapper.{h,cpp}. (Brandon Dahler)
0.10
Pieter Wuille 11 years ago
parent
commit
7c4c207be8
No known key found for this signature in database
GPG Key ID: 8F653255C87992E0
  1. 4
      src/Makefile.am
  2. 10
      src/leveldbwrapper.cpp
  3. 19
      src/leveldbwrapper.h
  4. 2
      src/txdb.cpp
  5. 6
      src/txdb.h

4
src/Makefile.am

@ -15,7 +15,7 @@ DIST_SUBDIRS = . qt test @@ -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
@ -33,7 +33,7 @@ version.o: obj/build.h @@ -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) \

10
src/leveldb.cpp → src/leveldbwrapper.cpp

@ -1,8 +1,8 @@ @@ -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>
@ -35,7 +35,7 @@ static leveldb::Options GetOptions(size_t nCacheSize) { @@ -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;
@ -59,7 +59,7 @@ CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool @@ -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;
@ -70,7 +70,7 @@ CLevelDB::~CLevelDB() { @@ -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;

19
src/leveldb.h → src/leveldbwrapper.h

@ -1,8 +1,9 @@ @@ -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"
@ -20,10 +21,10 @@ public: @@ -20,10 +21,10 @@ public:
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;
@ -53,7 +54,7 @@ public: @@ -53,7 +54,7 @@ public:
}
};
class CLevelDB
class CLevelDBWrapper
{
private:
// custom environment this database is using (may be NULL in case of default environment)
@ -78,8 +79,8 @@ private: @@ -78,8 +79,8 @@ private:
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);
@ -151,4 +152,4 @@ public: @@ -151,4 +152,4 @@ public:
}
};
#endif // BITCOIN_LEVELDB_H
#endif // BITCOIN_LEVELDBWRAPPER_H

2
src/txdb.cpp

@ -66,7 +66,7 @@ bool CCoinsViewDB::BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockI @@ -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)

6
src/txdb.h

@ -6,13 +6,13 @@ @@ -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);
@ -26,7 +26,7 @@ public: @@ -26,7 +26,7 @@ public:
};
/** 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);

Loading…
Cancel
Save