mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Move RPC data_* commands data to db/rpc.db.
This commit is contained in:
@@ -38,15 +38,15 @@ DatabaseCon::~DatabaseCon()
|
||||
Application::Application() :
|
||||
mUNL(mIOService),
|
||||
mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300),
|
||||
mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
|
||||
mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
|
||||
mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL)
|
||||
{
|
||||
RAND_bytes(mNonce256.begin(), mNonce256.size());
|
||||
RAND_bytes(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
|
||||
}
|
||||
|
||||
extern const char *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[];
|
||||
extern int TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount, NetNodeDBCount;
|
||||
extern const char *RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[];
|
||||
extern int RpcDBCount, TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount, NetNodeDBCount;
|
||||
|
||||
void Application::stop()
|
||||
{
|
||||
@@ -70,12 +70,13 @@ void Application::run()
|
||||
//
|
||||
// Construct databases.
|
||||
//
|
||||
boost::thread t1(boost::bind(&InitDB, &mTxnDB, "transaction.db", TxnDBInit, TxnDBCount));
|
||||
boost::thread t2(boost::bind(&InitDB, &mLedgerDB, "ledger.db", LedgerDBInit, LedgerDBCount));
|
||||
boost::thread t3(boost::bind(&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount));
|
||||
boost::thread t4(boost::bind(&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
|
||||
boost::thread t5(boost::bind(&InitDB, &mNetNodeDB, "netnode.db", NetNodeDBInit, NetNodeDBCount));
|
||||
t1.join(); t2.join(); t3.join(); t4.join(); t5.join();
|
||||
boost::thread t1(boost::bind(&InitDB, &mRpcDB, "rpc.db", RpcDBInit, RpcDBCount));
|
||||
boost::thread t2(boost::bind(&InitDB, &mTxnDB, "transaction.db", TxnDBInit, TxnDBCount));
|
||||
boost::thread t3(boost::bind(&InitDB, &mLedgerDB, "ledger.db", LedgerDBInit, LedgerDBCount));
|
||||
boost::thread t4(boost::bind(&InitDB, &mWalletDB, "wallet.db", WalletDBInit, WalletDBCount));
|
||||
boost::thread t5(boost::bind(&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
|
||||
boost::thread t6(boost::bind(&InitDB, &mNetNodeDB, "netnode.db", NetNodeDBInit, NetNodeDBCount));
|
||||
t1.join(); t2.join(); t3.join(); t4.join(); t5.join(); t6.join();
|
||||
|
||||
//
|
||||
// Begin validation and ip maintenance.
|
||||
|
||||
@@ -51,7 +51,7 @@ class Application
|
||||
SuppressionTable mSuppressions;
|
||||
HashedObjectStore mHashedObjectStore;
|
||||
|
||||
DatabaseCon *mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB;
|
||||
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB;
|
||||
|
||||
ConnectionPool mConnectionPool;
|
||||
PeerDoor* mPeerDoor;
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
bool isNew(const uint160& s) { return mSuppressions.addSuppression(s); }
|
||||
bool running() { return mTxnDB != NULL; }
|
||||
|
||||
DatabaseCon* getRpcDB() { return mRpcDB; }
|
||||
DatabaseCon* getTxnDB() { return mTxnDB; }
|
||||
DatabaseCon* getLedgerDB() { return mLedgerDB; }
|
||||
DatabaseCon* getWalletDB() { return mWalletDB; }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
// Transaction database holds transactions and public keys
|
||||
@@ -30,7 +32,7 @@ const char *TxnDBInit[] = {
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int TxnDBCount = sizeof(TxnDBInit) / sizeof(const char *);
|
||||
int TxnDBCount = NUMBER(TxnDBInit);
|
||||
|
||||
// Ledger database holds ledgers and ledger confirmations
|
||||
const char *LedgerDBInit[] = {
|
||||
@@ -59,7 +61,19 @@ const char *LedgerDBInit[] = {
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int LedgerDBCount = sizeof(LedgerDBInit) / sizeof(const char *);
|
||||
int LedgerDBCount = NUMBER(LedgerDBInit);
|
||||
|
||||
// RPC database holds persistent data for RPC clients.
|
||||
const char *RpcDBInit[] = {
|
||||
|
||||
// Local persistence of the RPC client
|
||||
"CREATE TABLE RPCData ( \
|
||||
Key TEXT PRIMARY Key, \
|
||||
Value TEXT \
|
||||
);",
|
||||
};
|
||||
|
||||
int RpcDBCount = NUMBER(RpcDBInit);
|
||||
|
||||
// Wallet database holds local accounts and trusted nodes
|
||||
const char *WalletDBInit[] = {
|
||||
@@ -73,12 +87,6 @@ const char *WalletDBInit[] = {
|
||||
Dh1024 TEXT \
|
||||
);",
|
||||
|
||||
// Local persistence of the RPC client
|
||||
"CREATE TABLE RPCData ( \
|
||||
Key TEXT PRIMARY Key, \
|
||||
Value TEXT \
|
||||
);",
|
||||
|
||||
// Miscellaneous persistent information
|
||||
// Integer: 1 : Used to simplify SQL.
|
||||
// ScoreUpdated: when scores was last updated.
|
||||
@@ -237,7 +245,7 @@ const char *WalletDBInit[] = {
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int WalletDBCount = sizeof(WalletDBInit) / sizeof(const char *);
|
||||
int WalletDBCount = NUMBER(WalletDBInit);
|
||||
|
||||
// Hash node database holds nodes indexed by hash
|
||||
const char *HashNodeDBInit[] = {
|
||||
@@ -256,7 +264,7 @@ const char *HashNodeDBInit[] = {
|
||||
"END TRANSACTION;"
|
||||
};
|
||||
|
||||
int HashNodeDBCount = sizeof(HashNodeDBInit) / sizeof(const char *);
|
||||
int HashNodeDBCount = NUMBER(HashNodeDBInit);
|
||||
|
||||
// Net node database holds nodes seen on the network
|
||||
// XXX Not really used needs replacement.
|
||||
@@ -270,6 +278,6 @@ const char *NetNodeDBInit[] = {
|
||||
};
|
||||
|
||||
|
||||
int NetNodeDBCount = sizeof(NetNodeDBInit) / sizeof(const char *);
|
||||
int NetNodeDBCount = NUMBER(NetNodeDBInit);
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -117,9 +117,9 @@ bool Wallet::nodeIdentityCreate() {
|
||||
|
||||
bool Wallet::dataDelete(const std::string& strKey)
|
||||
{
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
Database* db = theApp->getRpcDB()->getDB();
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
ScopedLock sl(theApp->getRpcDB()->getDBLock());
|
||||
|
||||
return db->executeSQL(str(boost::format("DELETE FROM RPCData WHERE Key=%s;")
|
||||
% db->escape(strKey)));
|
||||
@@ -127,9 +127,9 @@ bool Wallet::dataDelete(const std::string& strKey)
|
||||
|
||||
bool Wallet::dataFetch(const std::string& strKey, std::string& strValue)
|
||||
{
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
Database* db = theApp->getRpcDB()->getDB();
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
ScopedLock sl(theApp->getRpcDB()->getDBLock());
|
||||
|
||||
bool bSuccess = false;
|
||||
|
||||
@@ -151,9 +151,9 @@ bool Wallet::dataFetch(const std::string& strKey, std::string& strValue)
|
||||
|
||||
bool Wallet::dataStore(const std::string& strKey, const std::string& strValue)
|
||||
{
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
Database* db = theApp->getRpcDB()->getDB();
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
ScopedLock sl(theApp->getRpcDB()->getDBLock());
|
||||
|
||||
bool bSuccess = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user