mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Store completed transactions in the SQL database, indexed by accounts
affected and ledger seq.
This commit is contained in:
@@ -654,6 +654,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
Log(lsDEBUG) << "Previous LCL " << mPreviousLedger->getHash().GetHex();
|
||||
|
||||
Ledger::pointer newLCL = boost::make_shared<Ledger>(false, boost::ref(*mPreviousLedger));
|
||||
uint32 newLedgerSeq = newLCL->getLedgerSeq();
|
||||
|
||||
#ifdef DEBUG
|
||||
Json::StyledStreamWriter ssw;
|
||||
@@ -707,6 +708,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, failedTransactions);
|
||||
theApp->getMasterLedger().pushLedger(newLCL, newOL);
|
||||
mState = lcsACCEPTED;
|
||||
sl.unlock();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (1)
|
||||
@@ -718,8 +720,6 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
}
|
||||
#endif
|
||||
|
||||
sl.unlock();
|
||||
|
||||
SerializedValidation v(newLCLHash, mOurPosition->peekKey(), true);
|
||||
std::vector<unsigned char> validation = v.getSigned();
|
||||
newcoin::TMValidation val;
|
||||
@@ -727,6 +727,34 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
theApp->getConnectionPool().relayMessage(NULL, boost::make_shared<PackedMessage>(val, newcoin::mtVALIDATION));
|
||||
Log(lsINFO) << "Validation sent " << newLCL->getHash().GetHex();
|
||||
statusChange(newcoin::neACCEPTED_LEDGER, newOL);
|
||||
|
||||
// Insert the transactions in set into the AcctTxn database
|
||||
Database *db = theApp->getAcctTxnDB()->getDB();
|
||||
ScopedLock dbLock = theApp->getAcctTxnDB()->getDBLock();
|
||||
db->executeSQL("BEGIN TRANSACTION");
|
||||
for (SHAMapItem::pointer item = set->peekFirstItem(); !!item; item = set->peekNextItem(item->getTag()))
|
||||
{
|
||||
SerializerIterator sit(item->peekSerializer());
|
||||
SerializedTransaction txn(sit);
|
||||
std::vector<NewcoinAddress> accts = txn.getAffectedAccounts();
|
||||
|
||||
std::string sql = "INSERT INTO AccountTransactions (TransID,Account,LedgerSeq) VALUES ";
|
||||
bool first = true;
|
||||
for (std::vector<NewcoinAddress>::iterator it = accts.begin(), end = accts.end(); it != end; ++it)
|
||||
{
|
||||
if (!first) sql += ", (";
|
||||
else sql += "(";
|
||||
sql += txn.getTransactionID().GetHex();
|
||||
sql += ",";
|
||||
sql += it->humanAccountID();
|
||||
sql += ",";
|
||||
sql += boost::lexical_cast<std::string>(newLedgerSeq);
|
||||
sql += ")";
|
||||
}
|
||||
sql += ";";
|
||||
db->executeSQL(sql);
|
||||
}
|
||||
db->executeSQL("COMMIT TRANSACTION");
|
||||
}
|
||||
|
||||
void LedgerConsensus::endConsensus()
|
||||
|
||||
Reference in New Issue
Block a user