mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Improve account_tx. Better performance, identify fully-validated transactions.
This commit is contained in:
@@ -1567,18 +1567,26 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
int vl = theApp->getOPs().getValidatedSeq();
|
||||||
|
ScopedUnlock su(theApp->getMasterLock());
|
||||||
|
|
||||||
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger);
|
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger);
|
||||||
Json::Value ret(Json::objectValue);
|
Json::Value ret(Json::objectValue);
|
||||||
ret["account"] = raAccount.humanAccountID();
|
ret["account"] = raAccount.humanAccountID();
|
||||||
Json::Value ledgers(Json::arrayValue);
|
Json::Value ledgers(Json::arrayValue);
|
||||||
|
|
||||||
// uint32 currentLedger = 0;
|
|
||||||
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
|
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
Json::Value obj(Json::objectValue);
|
Json::Value obj(Json::objectValue);
|
||||||
|
|
||||||
if (it->first) obj["tx"] = it->first->getJson(1);
|
if (it->first)
|
||||||
if (it->second) obj["meta"] = it->second->getJson(0);
|
obj["tx"] = it->first->getJson(1);
|
||||||
|
if (it->second)
|
||||||
|
{
|
||||||
|
obj["meta"] = it->second->getJson(0);
|
||||||
|
uint32 s = it->second->getLgrSeq();
|
||||||
|
obj["validated"] = (s <= vl) && theApp->getOPs().haveLedger(s);
|
||||||
|
}
|
||||||
|
|
||||||
ret["transactions"].append(obj);
|
ret["transactions"].append(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user