mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
More work on account_tx command.
This commit is contained in:
@@ -528,11 +528,30 @@ void NetworkOPs::setMode(OperatingMode om)
|
||||
mMode = om;
|
||||
}
|
||||
|
||||
std::vector< std::pair<uint32, SerializedLedgerEntry::pointer> >
|
||||
#define SQL_FOREACH(_db, _strQuery) \
|
||||
if ((_db)->executeSQL(_strQuery)) \
|
||||
for (bool _bMore = (db)->startIterRows(); _bMore; _bMore = (_db)->getNextRow())
|
||||
|
||||
std::vector< std::pair<uint32, uint256> >
|
||||
NetworkOPs::getAffectedAccounts(const NewcoinAddress& account, uint32 minLedger, uint32 maxLedger)
|
||||
{
|
||||
// WRITEME
|
||||
std::vector< std::pair<uint32, SerializedLedgerEntry::pointer> > affectedAccounts;
|
||||
std::vector< std::pair<uint32, uint256> > affectedAccounts;
|
||||
|
||||
std::string sql =
|
||||
str(boost::format("SELECT LedgerSeq,TransID FROM AccountTransactions INDEXED BY AcctTxIndex "
|
||||
" WHERE Account = % AND LedgerSeq <= % AND LedgerSeq >= % ORDER BY LedgerSeq LIMIT 1000")
|
||||
% account.humanAccountID() % minLedger % maxLedger);
|
||||
|
||||
Database *db = theApp->getAcctTxnDB()->getDB();
|
||||
ScopedLock dbLock = theApp->getAcctTxnDB()->getDBLock();
|
||||
|
||||
SQL_FOREACH(db, sql)
|
||||
{
|
||||
std::string txID;
|
||||
db->getStr("TransID", txID);
|
||||
affectedAccounts.push_back(std::make_pair<uint32, uint256>(db->getInt("LedgerSeq"), uint256(txID)));
|
||||
}
|
||||
|
||||
return affectedAccounts;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
void setStateTimer(int seconds);
|
||||
|
||||
// client information retrieval functions
|
||||
std::vector< std::pair<uint32, SerializedLedgerEntry::pointer> >
|
||||
std::vector< std::pair<uint32, uint256> >
|
||||
getAffectedAccounts(const NewcoinAddress& account, uint32 minLedger, uint32 maxLedger);
|
||||
};
|
||||
|
||||
|
||||
@@ -1496,19 +1496,38 @@ Json::Value RPCServer::doAccountTransactions(Json::Value& params)
|
||||
|
||||
try
|
||||
{
|
||||
std::vector< std::pair<uint32, SerializedLedgerEntry::pointer> > txns =
|
||||
std::vector< std::pair<uint32, uint256> > txns =
|
||||
mNetOps->getAffectedAccounts(account, minLedger, maxLedger);
|
||||
Json::Value ret(Json::objectValue);
|
||||
ret["Account"] = account.humanAccountID();
|
||||
Json::Value jtxns(Json::arrayValue);
|
||||
for (std::vector< std::pair<uint32, SerializedLedgerEntry::pointer> >::iterator it = txns.begin(),
|
||||
Json::Value ledgers(Json::arrayValue);
|
||||
|
||||
uint32 currentLedger = 0;
|
||||
Json::Value ledger, jtxns;
|
||||
for (std::vector< std::pair<uint32, uint256> >::iterator it = txns.begin(),
|
||||
end = txns.end(); it != end; ++it)
|
||||
{
|
||||
Json::Value txn = it->second->getJson(0);
|
||||
txn["InLedger"] = it->first;
|
||||
jtxns.append(txn);
|
||||
if (it->first != currentLedger)
|
||||
{ // new ledger
|
||||
if (currentLedger != 0) // add old ledger
|
||||
{
|
||||
ledger["Transactions"] = jtxns;
|
||||
ledgers.append(ledger);
|
||||
ledger = Json::objectValue;
|
||||
}
|
||||
currentLedger = it->first;
|
||||
ledger["ID"] = currentLedger;
|
||||
jtxns = Json::arrayValue;
|
||||
}
|
||||
jtxns.append(it->second.GetHex());
|
||||
}
|
||||
ret["Transactions"] = jtxns;
|
||||
if (currentLedger != 0)
|
||||
{
|
||||
ledger["Transactions"] = jtxns;
|
||||
ledgers.append(ledger);
|
||||
}
|
||||
|
||||
ret["Ledgers"] = ledgers;
|
||||
return ret;
|
||||
}
|
||||
catch (...)
|
||||
|
||||
Reference in New Issue
Block a user