Handle an edge case.

This commit is contained in:
JoelKatz
2013-01-17 21:08:23 -08:00
parent 0055122176
commit 8feb9d6c29

View File

@@ -415,29 +415,34 @@ void Ledger::saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer event)
if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex()))) if (!SQL_EXISTS(db, boost::str(AcctTransExists % item->getTag().GetHex())))
{ {
// Transaction not in AccountTransactions // Transaction not in AccountTransactions
std::vector<RippleAddress> accts = meta.getAffectedAccounts(); const std::vector<RippleAddress> accts = meta.getAffectedAccounts();
if (!accts.empty())
std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES ";
bool first = true;
for (std::vector<RippleAddress>::iterator it = accts.begin(), end = accts.end(); it != end; ++it)
{ {
if (!first)
sql += ", ('"; std::string sql = "INSERT INTO AccountTransactions (TransID, Account, LedgerSeq) VALUES ";
else bool first = true;
for (std::vector<RippleAddress>::const_iterator it = accts.begin(), end = accts.end(); it != end; ++it)
{ {
sql += "('"; if (!first)
first = false; sql += ", ('";
else
{
sql += "('";
first = false;
}
sql += txn.getTransactionID().GetHex();
sql += "','";
sql += it->humanAccountID();
sql += "',";
sql += boost::lexical_cast<std::string>(getLedgerSeq());
sql += ")";
} }
sql += txn.getTransactionID().GetHex(); sql += ";";
sql += "','"; Log(lsTRACE) << "ActTx: " << sql;
sql += it->humanAccountID(); db->executeSQL(sql); // may already be in there
sql += "',";
sql += boost::lexical_cast<std::string>(getLedgerSeq());
sql += ")";
} }
sql += ";"; else
Log(lsTRACE) << "ActTx: " << sql; cLog(lsWARNING) << "Transaaction in ledger " << mLedgerSeq << " affects not accounts";
db->executeSQL(sql); // may already be in there
} }
if (SQL_EXISTS(db, boost::str(transExists % txn.getTransactionID().GetHex()))) if (SQL_EXISTS(db, boost::str(transExists % txn.getTransactionID().GetHex())))