diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index 81e2e4578..72ae3d5a1 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -455,9 +455,9 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) const std::vector& accts = vt.second.getAffected(); if (!accts.empty()) { - std::string sql = "INSERT OR REPLACE INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES "; + std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES "; bool first = true; - for (std::vector::const_iterator it = accts.begin(), end = accts.end(); it != end; ++it) + for (std::vector::const_iterator it = accts.begin(), end = accts.end(); it != end; ++it) { if (!first) sql += ", ('"; @@ -475,27 +475,13 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) } sql += ";"; cLog(lsTRACE) << "ActTx: " << sql; - db->executeSQL(sql); // may already be in there + db->executeSQL(sql); } else cLog(lsWARNING) << "Transaction in ledger " << mLedgerSeq << " affects no accounts"; - if (SQL_EXISTS(db, boost::str(transExists % txID.GetHex()))) - { - // In Transactions, update LedgerSeq, metadata and Status. - db->executeSQL(boost::str(updateTx - % getLedgerSeq() - % TXN_SQL_VALIDATED - % vt.second.getEscMeta() - % txID.GetHex())); - } - else - { - // Not in Transactions, insert the whole thing.. - db->executeSQL( - SerializedTransaction::getMetaSQLInsertHeader() + - vt.second.getTxn()->getMetaSQL(getLedgerSeq(), vt.second.getEscMeta()) + ";"); - } + db->executeSQL(SerializedTransaction::getMetaSQLInsertReplaceHeader() + + vt.second.getTxn()->getMetaSQL(getLedgerSeq(), vt.second.getEscMeta()) + ";"); } db->executeSQL("COMMIT TRANSACTION;"); } @@ -505,8 +491,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus) theApp->getLedgerDB()->getDB()->executeSQL(boost::str(addLedger % getHash().GetHex() % mLedgerSeq % mParentHash.GetHex() % boost::lexical_cast(mTotCoins) % mCloseTime % mParentCloseTime % - mCloseResolution % mCloseFlags % - mAccountHash.GetHex() % mTransHash.GetHex())); + mCloseResolution % mCloseFlags % mAccountHash.GetHex() % mTransHash.GetHex())); } #if 0 diff --git a/src/cpp/ripple/SerializedTransaction.cpp b/src/cpp/ripple/SerializedTransaction.cpp index 7486e0329..c5a1d1445 100644 --- a/src/cpp/ripple/SerializedTransaction.cpp +++ b/src/cpp/ripple/SerializedTransaction.cpp @@ -236,6 +236,11 @@ std::string SerializedTransaction::getMetaSQLInsertHeader() return "INSERT INTO Transactions " + getMetaSQLValueHeader() + " VALUES "; } +std::string SerializedTransaction::getMetaSQLInsertReplaceHeader() +{ + return "INSERT OR REPLACE INTO Transactions " + getMetaSQLValueHeader() + " VALUES "; +} + std::string SerializedTransaction::getSQL(uint32 inLedger, char status) const { Serializer s; diff --git a/src/cpp/ripple/SerializedTransaction.h b/src/cpp/ripple/SerializedTransaction.h index 8727f19be..5dfc24f27 100644 --- a/src/cpp/ripple/SerializedTransaction.h +++ b/src/cpp/ripple/SerializedTransaction.h @@ -82,6 +82,7 @@ public: // SQL Functions with metadata static std::string getMetaSQLValueHeader(); static std::string getMetaSQLInsertHeader(); + static std::string getMetaSQLInsertReplaceHeader(); std::string getMetaSQL(uint32 inLedger, const std::string& escapedMetaData) const; std::string getMetaSQL(Serializer rawTxn, uint32 inLedger, char status, const std::string& escapedMetaData) const;