diff --git a/src/Application.cpp b/src/Application.cpp index 37ca4f3952..5b27580c97 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -20,7 +20,7 @@ Application* theApp = NULL; DatabaseCon::DatabaseCon(const std::string& name, const char *initStrings[], int initCount) { std::string path=strprintf("%s%s", theConfig.DATA_DIR.c_str(), name.c_str()); - mDatabase=new SqliteDatabase(path.c_str()); + mDatabase = new SqliteDatabase(path.c_str()); mDatabase->connect(); for(int i = 0; i < initCount; ++i) mDatabase->executeSQL(initStrings[i], true); @@ -35,15 +35,16 @@ DatabaseCon::~DatabaseCon() Application::Application() : mUNL(mIOService), mNetOps(mIOService, &mMasterLedger), mNodeCache(16384, 600), - mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL), + mTxnDB(NULL), mAcctTxnDB(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(&mNonceST), sizeof(mNonceST)); } -extern const char *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[]; -extern int TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount, NetNodeDBCount; +extern const char *AcctTxnDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], + *HashNodeDBInit[], *NetNodeDBInit[]; +extern int TxnDBCount, AcctTxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount, NetNodeDBCount; void Application::stop() { @@ -59,11 +60,12 @@ void Application::run() // // Construct databases. // - mTxnDB=new DatabaseCon("transaction.db", TxnDBInit, TxnDBCount); - mLedgerDB=new DatabaseCon("ledger.db", LedgerDBInit, LedgerDBCount); - mWalletDB=new DatabaseCon("wallet.db", WalletDBInit, WalletDBCount); - mHashNodeDB=new DatabaseCon("hashnode.db", HashNodeDBInit, HashNodeDBCount); - mNetNodeDB=new DatabaseCon("netnode.db", NetNodeDBInit, NetNodeDBCount); + mTxnDB = new DatabaseCon("transaction.db", TxnDBInit, TxnDBCount); + mAcctTxnDB = new DatabaseCon("transacct.db", AcctTxnDBInit, AcctTxnDBCount); + mLedgerDB = new DatabaseCon("ledger.db", LedgerDBInit, LedgerDBCount); + mWalletDB = new DatabaseCon("wallet.db", WalletDBInit, WalletDBCount); + mHashNodeDB = new DatabaseCon("hashnode.db", HashNodeDBInit, HashNodeDBCount); + mNetNodeDB = new DatabaseCon("netnode.db", NetNodeDBInit, NetNodeDBCount); // // Begin validation and ip maintenance. @@ -76,7 +78,7 @@ void Application::run() // if(!theConfig.PEER_IP.empty() && theConfig.PEER_PORT) { - mPeerDoor=new PeerDoor(mIOService); + mPeerDoor = new PeerDoor(mIOService); } else { @@ -88,7 +90,7 @@ void Application::run() // if(!theConfig.RPC_IP.empty() && theConfig.RPC_PORT) { - mRPCDoor=new RPCDoor(mIOService); + mRPCDoor = new RPCDoor(mIOService); } else { @@ -138,6 +140,7 @@ void Application::run() Application::~Application() { delete mTxnDB; + delete mAcctTxnDB; delete mLedgerDB; delete mWalletDB; delete mHashNodeDB; diff --git a/src/Application.h b/src/Application.h index 2c1fd6c006..546d0aad51 100644 --- a/src/Application.h +++ b/src/Application.h @@ -45,7 +45,7 @@ class Application NetworkOPs mNetOps; NodeCache mNodeCache; - DatabaseCon* mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB; + DatabaseCon *mTxnDB, *mAcctTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB; ConnectionPool mConnectionPool; PeerDoor* mPeerDoor; @@ -76,6 +76,7 @@ public: NodeCache& getNodeCache() { return mNodeCache; } DatabaseCon* getTxnDB() { return mTxnDB; } + DatabaseCon* getAcctTxnDB() { return mAcctTxnDB; } DatabaseCon* getLedgerDB() { return mLedgerDB; } DatabaseCon* getWalletDB() { return mWalletDB; } DatabaseCon* getHashNodeDB() { return mHashNodeDB; } diff --git a/src/DBInit.cpp b/src/DBInit.cpp index 9f1f3a92a8..470d28fb31 100644 --- a/src/DBInit.cpp +++ b/src/DBInit.cpp @@ -20,7 +20,21 @@ const char *TxnDBInit[] = { );" }; -int TxnDBCount=sizeof(TxnDBInit)/sizeof(const char *); +int TxnDBCount = sizeof(TxnDBInit) / sizeof(const char *); + +const char *AcctTxnDBInit[] = { + "CREATE TABLE AccountTransactions ( \ + TransID CHARACTER964) PRIMARY KEY \ + Account CHARACTER(64), \ + LedgerSeq BIGINT UNSIGNED, \ + );", + "CREATE INDEX AcctTxindex ON \ + AccountTransactions(Account), \ + AccountTransactions(LedgerSeq), \ + AccountTransactions(TransID);" +}; + +int AcctTxnDBCount = sizeof(AcctTxnDBInit) / sizeof(const char *); // Ledger database holds ledgers and ledger confirmations const char *LedgerDBInit[] = { @@ -46,7 +60,7 @@ const char *LedgerDBInit[] = { #endif }; -int LedgerDBCount=sizeof(LedgerDBInit)/sizeof(const char *); +int LedgerDBCount = sizeof(LedgerDBInit) / sizeof(const char *); // Wallet database holds local accounts and trusted nodes const char *WalletDBInit[] = { @@ -212,7 +226,7 @@ const char *WalletDBInit[] = { PeerIps(ScanNext);" }; -int WalletDBCount=sizeof(WalletDBInit)/sizeof(const char *); +int WalletDBCount = sizeof(WalletDBInit) / sizeof(const char *); // Hash node database holds nodes indexed by hash const char *HashNodeDBInit[] = { @@ -227,7 +241,7 @@ const char *HashNodeDBInit[] = { CommittedObjects(LedgerIndex, ObjType);" }; -int HashNodeDBCount=sizeof(HashNodeDBInit)/sizeof(const char *); +int HashNodeDBCount = sizeof(HashNodeDBInit) / sizeof(const char *); // Net node database holds nodes seen on the network // XXX Not really used needs replacement. @@ -241,6 +255,6 @@ const char *NetNodeDBInit[] = { }; -int NetNodeDBCount=sizeof(NetNodeDBInit)/sizeof(const char *); +int NetNodeDBCount = sizeof(NetNodeDBInit) / sizeof(const char *); // vim:ts=4