LevelDB is now mandatory

This commit is contained in:
JoelKatz
2013-06-05 09:37:26 -07:00
parent 3d65ae7784
commit cc0b9ad01c
6 changed files with 1 additions and 48 deletions

View File

@@ -1,10 +1,8 @@
#include "Application.h"
#ifdef USE_LEVELDB
#include "leveldb/cache.h"
#include "leveldb/filter_policy.h"
#endif
#include "AcceptedLedger.h"
#include "Config.h"
@@ -56,10 +54,7 @@ Application::Application() :
mFeatureTable(2 * 7 * 24 * 60 * 60, 200), // two weeks, 200/256
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
mNetNodeDB(NULL), mPathFindDB(NULL), mHashNodeDB(NULL),
#ifdef USE_LEVELDB
mHashNodeLDB(NULL),
#endif
mNetNodeDB(NULL), mPathFindDB(NULL), mHashNodeDB(NULL), mHashNodeLDB(NULL),
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL), mWSPublicDoor(NULL), mWSPrivateDoor(NULL),
mSweepTimer(mAuxService), mShutdown(false)
{
@@ -84,10 +79,8 @@ void Application::stop()
mAuxService.stop();
mJobQueue.shutdown();
#ifdef USE_LEVELDB
delete mHashNodeLDB;
mHashNodeLDB = NULL;
#endif
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped();
Instance::shutdown();
@@ -164,7 +157,6 @@ void Application::setup()
boost::thread t7(boost::bind(&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount));
t4.join(); t6.join(); t7.join();
#ifdef USE_LEVELDB
if (mHashedObjectStore.isLevelDB())
{
WriteLog (lsINFO, Application) << "LevelDB used for nodes";
@@ -186,7 +178,6 @@ void Application::setup()
}
}
else
#endif
{
WriteLog (lsINFO, Application) << "SQLite used for nodes";
boost::thread t5(boost::bind(&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
@@ -246,9 +237,7 @@ void Application::setup()
mLedgerMaster.setMinValidations(theConfig.VALIDATION_QUORUM);
#ifdef USE_LEVELDB
if (!mHashedObjectStore.isLevelDB())
#endif
theApp->getHashNodeDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") %
(theConfig.getSize(siHashNodeDBCache) * 1024)));
@@ -414,9 +403,7 @@ Application::~Application()
delete mHashNodeDB;
delete mNetNodeDB;
delete mPathFindDB;
#ifdef USE_LEVELDB
delete mHashNodeLDB;
#endif
}
void Application::startNewLedger()

View File

@@ -1,9 +1,7 @@
#ifndef __APPLICATION__
#define __APPLICATION__
#ifdef USE_LEVELDB
#include "leveldb/db.h"
#endif
#include <boost/asio.hpp>
@@ -83,9 +81,7 @@ class Application
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
#ifdef USE_LEVELDB
leveldb::DB *mHashNodeLDB;
#endif
ConnectionPool mConnectionPool;
PeerDoor* mPeerDoor;
@@ -156,9 +152,7 @@ public:
DatabaseCon* getPathFindDB() { return mPathFindDB; }
DatabaseCon* getHashNodeDB() { return mHashNodeDB; }
#ifdef USE_LEVELDB
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
#endif
uint256 getNonce256() { return mNonce256; }
std::size_t getNonceST() { return mNonceST; }

View File

@@ -1,9 +1,7 @@
#include "HashedObject.h"
#ifdef USE_LEVELDB
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
#endif
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
@@ -31,14 +29,6 @@ HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) :
WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
assert(false);
}
#ifndef USE_LEVELDB
if (mLevelDB)
{
WriteLog (lsFATAL) << "LevelDB has been selected but not compiled";
assert(false);
}
#endif
}
void HashedObjectStore::tune(int size, int age)
@@ -61,8 +51,6 @@ int HashedObjectStore::getWriteLoad()
return std::max(mWriteLoad, static_cast<int>(mWriteSet.size()));
}
#ifdef USE_LEVELDB
bool HashedObjectStore::storeLevelDB(HashedObjectType type, uint32 index,
const std::vector<unsigned char>& data, const uint256& hash)
{ // return: false = already in cache, true = added to cache
@@ -177,8 +165,6 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB(const uint256& hash)
return obj;
}
#endif
bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
const std::vector<unsigned char>& data, const uint256& hash)
{ // return: false = already in cache, true = added to cache
@@ -405,8 +391,6 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
return obj;
}
#ifdef USE_LEVELDB
int HashedObjectStore::import(const std::string& file)
{
WriteLog (lsWARNING, HashedObject) << "Hashed object import from \"" << file << "\".";
@@ -476,6 +460,4 @@ int HashedObjectStore::import(const std::string& file)
return count;
}
#endif
// vim:ts=4

View File

@@ -82,19 +82,15 @@ public:
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash)
{
#ifdef USE_LEVELDB
if (mLevelDB)
return storeLevelDB(type, index, data, hash);
#endif
return storeSQLite(type, index, data, hash);
}
HashedObject::pointer retrieve(const uint256& hash)
{
#ifdef USE_LEVELDB
if (mLevelDB)
return retrieveLevelDB(hash);
#endif
return retrieveSQLite(hash);
}
@@ -103,12 +99,10 @@ public:
HashedObject::pointer retrieveSQLite(const uint256& hash);
void bulkWriteSQLite(Job&);
#ifdef USE_LEVELDB
bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash);
HashedObject::pointer retrieveLevelDB(const uint256& hash);
void bulkWriteLevelDB(Job&);
#endif
void waitWrite();

View File

@@ -113,7 +113,6 @@ void Application::updateTables(bool ldbImport)
exit(1);
}
#ifdef USE_LEVELDB
if (theApp->getHashedObjectStore().isLevelDB())
{
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
@@ -134,5 +133,4 @@ void Application::updateTables(bool ldbImport)
}
}
}
#endif
}

View File

@@ -150,9 +150,7 @@ int main(int argc, char* argv[])
("start", "Start from a fresh Ledger.")
("net", "Get the initial ledger from the network.")
("fg", "Run in the foreground.")
#ifdef USE_LEVELDB
("import", "Import SQLite node DB into LevelDB.")
#endif
;
// Interpret positional arguments as --parameters.