mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
A better fix for countAccountTxs.
This commit is contained in:
@@ -1215,7 +1215,20 @@ NetworkOPs::transactionsSQL (std::string selection, const RippleAddress& account
|
|||||||
if (minLedger != -1)
|
if (minLedger != -1)
|
||||||
minClause = boost::str (boost::format ("AND AccountTransactions.LedgerSeq >= '%u'") % minLedger);
|
minClause = boost::str (boost::format ("AND AccountTransactions.LedgerSeq >= '%u'") % minLedger);
|
||||||
|
|
||||||
std::string sql =
|
std::string sql;
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
sql =
|
||||||
|
boost::str (boost::format ("SELECT %s FROM AccountTransactions WHERE Account = '%s' %s %s LIMIT %u %u;")
|
||||||
|
% selection
|
||||||
|
% account.humanAccountID ()
|
||||||
|
% maxClause
|
||||||
|
% minClause
|
||||||
|
% lexicalCastThrow <std::string> (offset)
|
||||||
|
% lexicalCastThrow <std::string> (numberOfResults)
|
||||||
|
);
|
||||||
|
else
|
||||||
|
sql =
|
||||||
boost::str (boost::format ("SELECT %s FROM "
|
boost::str (boost::format ("SELECT %s FROM "
|
||||||
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
|
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
|
||||||
"WHERE Account = '%s' %s %s "
|
"WHERE Account = '%s' %s %s "
|
||||||
@@ -1335,7 +1348,7 @@ NetworkOPs::countAccountTxs (const RippleAddress& account, int32 minLedger, int3
|
|||||||
{
|
{
|
||||||
// can be called with no locks
|
// can be called with no locks
|
||||||
uint32 ret = 0;
|
uint32 ret = 0;
|
||||||
std::string sql = NetworkOPs::transactionsSQL ("COUNT(*) AS 'TransactionCount'", account,
|
std::string sql = NetworkOPs::transactionsSQL ("COUNT(DISCTINCT TransID) AS 'TransactionCount'", account,
|
||||||
minLedger, maxLedger, false, 0, -1, true, true, true);
|
minLedger, maxLedger, false, 0, -1, true, true, true);
|
||||||
|
|
||||||
Database* db = getApp().getTxnDB ()->getDB ();
|
Database* db = getApp().getTxnDB ()->getDB ();
|
||||||
|
|||||||
Reference in New Issue
Block a user