mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
LevelDB is now mandatory
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
#include "leveldb/cache.h"
|
#include "leveldb/cache.h"
|
||||||
#include "leveldb/filter_policy.h"
|
#include "leveldb/filter_policy.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "AcceptedLedger.h"
|
#include "AcceptedLedger.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
@@ -56,10 +54,7 @@ Application::Application() :
|
|||||||
mFeatureTable(2 * 7 * 24 * 60 * 60, 200), // two weeks, 200/256
|
mFeatureTable(2 * 7 * 24 * 60 * 60, 200), // two weeks, 200/256
|
||||||
|
|
||||||
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
|
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
|
||||||
mNetNodeDB(NULL), mPathFindDB(NULL), mHashNodeDB(NULL),
|
mNetNodeDB(NULL), mPathFindDB(NULL), mHashNodeDB(NULL), mHashNodeLDB(NULL),
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
mHashNodeLDB(NULL),
|
|
||||||
#endif
|
|
||||||
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL), mWSPublicDoor(NULL), mWSPrivateDoor(NULL),
|
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL), mWSPublicDoor(NULL), mWSPrivateDoor(NULL),
|
||||||
mSweepTimer(mAuxService), mShutdown(false)
|
mSweepTimer(mAuxService), mShutdown(false)
|
||||||
{
|
{
|
||||||
@@ -84,10 +79,8 @@ void Application::stop()
|
|||||||
mAuxService.stop();
|
mAuxService.stop();
|
||||||
mJobQueue.shutdown();
|
mJobQueue.shutdown();
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
delete mHashNodeLDB;
|
delete mHashNodeLDB;
|
||||||
mHashNodeLDB = NULL;
|
mHashNodeLDB = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped();
|
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped();
|
||||||
Instance::shutdown();
|
Instance::shutdown();
|
||||||
@@ -164,7 +157,6 @@ void Application::setup()
|
|||||||
boost::thread t7(boost::bind(&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount));
|
boost::thread t7(boost::bind(&InitDB, &mPathFindDB, "pathfind.db", PathFindDBInit, PathFindDBCount));
|
||||||
t4.join(); t6.join(); t7.join();
|
t4.join(); t6.join(); t7.join();
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
if (mHashedObjectStore.isLevelDB())
|
if (mHashedObjectStore.isLevelDB())
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, Application) << "LevelDB used for nodes";
|
WriteLog (lsINFO, Application) << "LevelDB used for nodes";
|
||||||
@@ -186,7 +178,6 @@ void Application::setup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, Application) << "SQLite used for nodes";
|
WriteLog (lsINFO, Application) << "SQLite used for nodes";
|
||||||
boost::thread t5(boost::bind(&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
|
boost::thread t5(boost::bind(&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
|
||||||
@@ -246,9 +237,7 @@ void Application::setup()
|
|||||||
|
|
||||||
mLedgerMaster.setMinValidations(theConfig.VALIDATION_QUORUM);
|
mLedgerMaster.setMinValidations(theConfig.VALIDATION_QUORUM);
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
if (!mHashedObjectStore.isLevelDB())
|
if (!mHashedObjectStore.isLevelDB())
|
||||||
#endif
|
|
||||||
theApp->getHashNodeDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") %
|
theApp->getHashNodeDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") %
|
||||||
(theConfig.getSize(siHashNodeDBCache) * 1024)));
|
(theConfig.getSize(siHashNodeDBCache) * 1024)));
|
||||||
|
|
||||||
@@ -414,9 +403,7 @@ Application::~Application()
|
|||||||
delete mHashNodeDB;
|
delete mHashNodeDB;
|
||||||
delete mNetNodeDB;
|
delete mNetNodeDB;
|
||||||
delete mPathFindDB;
|
delete mPathFindDB;
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
delete mHashNodeLDB;
|
delete mHashNodeLDB;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::startNewLedger()
|
void Application::startNewLedger()
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#ifndef __APPLICATION__
|
#ifndef __APPLICATION__
|
||||||
#define __APPLICATION__
|
#define __APPLICATION__
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
#include "leveldb/db.h"
|
#include "leveldb/db.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
@@ -83,9 +81,7 @@ class Application
|
|||||||
|
|
||||||
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
|
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
leveldb::DB *mHashNodeLDB;
|
leveldb::DB *mHashNodeLDB;
|
||||||
#endif
|
|
||||||
|
|
||||||
ConnectionPool mConnectionPool;
|
ConnectionPool mConnectionPool;
|
||||||
PeerDoor* mPeerDoor;
|
PeerDoor* mPeerDoor;
|
||||||
@@ -156,9 +152,7 @@ public:
|
|||||||
DatabaseCon* getPathFindDB() { return mPathFindDB; }
|
DatabaseCon* getPathFindDB() { return mPathFindDB; }
|
||||||
DatabaseCon* getHashNodeDB() { return mHashNodeDB; }
|
DatabaseCon* getHashNodeDB() { return mHashNodeDB; }
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
|
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
|
||||||
#endif
|
|
||||||
|
|
||||||
uint256 getNonce256() { return mNonce256; }
|
uint256 getNonce256() { return mNonce256; }
|
||||||
std::size_t getNonceST() { return mNonceST; }
|
std::size_t getNonceST() { return mNonceST; }
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#include "HashedObject.h"
|
#include "HashedObject.h"
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
#include "leveldb/db.h"
|
#include "leveldb/db.h"
|
||||||
#include "leveldb/write_batch.h"
|
#include "leveldb/write_batch.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@@ -31,14 +29,6 @@ HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) :
|
|||||||
WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
|
WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
|
||||||
assert(false);
|
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)
|
void HashedObjectStore::tune(int size, int age)
|
||||||
@@ -61,8 +51,6 @@ int HashedObjectStore::getWriteLoad()
|
|||||||
return std::max(mWriteLoad, static_cast<int>(mWriteSet.size()));
|
return std::max(mWriteLoad, static_cast<int>(mWriteSet.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
|
|
||||||
bool HashedObjectStore::storeLevelDB(HashedObjectType type, uint32 index,
|
bool HashedObjectStore::storeLevelDB(HashedObjectType type, uint32 index,
|
||||||
const std::vector<unsigned char>& data, const uint256& hash)
|
const std::vector<unsigned char>& data, const uint256& hash)
|
||||||
{ // return: false = already in cache, true = added to cache
|
{ // return: false = already in cache, true = added to cache
|
||||||
@@ -177,8 +165,6 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB(const uint256& hash)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
|
bool HashedObjectStore::storeSQLite(HashedObjectType type, uint32 index,
|
||||||
const std::vector<unsigned char>& data, const uint256& hash)
|
const std::vector<unsigned char>& data, const uint256& hash)
|
||||||
{ // return: false = already in cache, true = added to cache
|
{ // return: false = already in cache, true = added to cache
|
||||||
@@ -405,8 +391,6 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite(const uint256& hash)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
|
|
||||||
int HashedObjectStore::import(const std::string& file)
|
int HashedObjectStore::import(const std::string& file)
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, HashedObject) << "Hashed object import from \"" << file << "\".";
|
WriteLog (lsWARNING, HashedObject) << "Hashed object import from \"" << file << "\".";
|
||||||
@@ -476,6 +460,4 @@ int HashedObjectStore::import(const std::string& file)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -82,19 +82,15 @@ public:
|
|||||||
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
||||||
const uint256& hash)
|
const uint256& hash)
|
||||||
{
|
{
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
if (mLevelDB)
|
if (mLevelDB)
|
||||||
return storeLevelDB(type, index, data, hash);
|
return storeLevelDB(type, index, data, hash);
|
||||||
#endif
|
|
||||||
return storeSQLite(type, index, data, hash);
|
return storeSQLite(type, index, data, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::pointer retrieve(const uint256& hash)
|
HashedObject::pointer retrieve(const uint256& hash)
|
||||||
{
|
{
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
if (mLevelDB)
|
if (mLevelDB)
|
||||||
return retrieveLevelDB(hash);
|
return retrieveLevelDB(hash);
|
||||||
#endif
|
|
||||||
return retrieveSQLite(hash);
|
return retrieveSQLite(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,12 +99,10 @@ public:
|
|||||||
HashedObject::pointer retrieveSQLite(const uint256& hash);
|
HashedObject::pointer retrieveSQLite(const uint256& hash);
|
||||||
void bulkWriteSQLite(Job&);
|
void bulkWriteSQLite(Job&);
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
||||||
const uint256& hash);
|
const uint256& hash);
|
||||||
HashedObject::pointer retrieveLevelDB(const uint256& hash);
|
HashedObject::pointer retrieveLevelDB(const uint256& hash);
|
||||||
void bulkWriteLevelDB(Job&);
|
void bulkWriteLevelDB(Job&);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void waitWrite();
|
void waitWrite();
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ void Application::updateTables(bool ldbImport)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
if (theApp->getHashedObjectStore().isLevelDB())
|
if (theApp->getHashedObjectStore().isLevelDB())
|
||||||
{
|
{
|
||||||
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
|
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
|
||||||
@@ -134,5 +133,4 @@ void Application::updateTables(bool ldbImport)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,9 +150,7 @@ int main(int argc, char* argv[])
|
|||||||
("start", "Start from a fresh Ledger.")
|
("start", "Start from a fresh Ledger.")
|
||||||
("net", "Get the initial ledger from the network.")
|
("net", "Get the initial ledger from the network.")
|
||||||
("fg", "Run in the foreground.")
|
("fg", "Run in the foreground.")
|
||||||
#ifdef USE_LEVELDB
|
|
||||||
("import", "Import SQLite node DB into LevelDB.")
|
("import", "Import SQLite node DB into LevelDB.")
|
||||||
#endif
|
|
||||||
;
|
;
|
||||||
|
|
||||||
// Interpret positional arguments as --parameters.
|
// Interpret positional arguments as --parameters.
|
||||||
|
|||||||
Reference in New Issue
Block a user