From 837ec2b69db46bb4c6b54f0fc885f1d50cbb9e6f Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sat, 23 Mar 2013 14:36:07 -0700 Subject: [PATCH] Remove limits on RPC account_tx for admins. --- src/cpp/ripple/NetworkOPs.cpp | 14 +++++++------- src/cpp/ripple/NetworkOPs.h | 4 ++-- src/cpp/ripple/RPCHandler.cpp | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 26a8da1bf..41de7ec1f 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1060,16 +1060,16 @@ void NetworkOPs::setMode(OperatingMode om) std::vector< std::pair > - NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger) + NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin) { // can be called with no locks std::vector< std::pair > ret; std::string sql = - str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM " + boost::str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID " "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' " - "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 200;") - % account.humanAccountID() % maxLedger % minLedger); + "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;") + % account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 200")); { Database* db = theApp->getTxnDB()->getDB(); @@ -1098,15 +1098,15 @@ std::vector< std::pair > } std::vector NetworkOPs::getAccountTxsB( - const RippleAddress& account, uint32 minLedger, uint32 maxLedger) + const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin) { // can be called with no locks std::vector< txnMetaLedgerType> ret; std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM " "AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID " "WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' " - "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 500;") - % account.humanAccountID() % maxLedger % minLedger); + "ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;") + % account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 500")); { Database* db = theApp->getTxnDB()->getDB(); diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index 99daf9483..a7207d7de 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -294,11 +294,11 @@ public: // client information retrieval functions std::vector< std::pair > - getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger); + getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin); typedef boost::tuple txnMetaLedgerType; std::vector - getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL); + getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL, bool bAdmin); std::vector getLedgerAffectedAccounts(uint32 ledgerSeq); std::vector getLedgerTransactions(uint32 ledgerSeq); diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index cc0a84f7e..0f25bddcc 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -1706,7 +1706,8 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost) if (jvRequest.isMember("binary") && jvRequest["binary"].asBool()) { std::vector txns = - mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger); + mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger, mRole == ADMIN); + for (std::vector::const_iterator it = txns.begin(), end = txns.end(); it != end; ++it) { @@ -1723,7 +1724,7 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost) } else { - std::vector< std::pair > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger); + std::vector< std::pair > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger, mRole == ADMIN); for (std::vector< std::pair >::iterator it = txns.begin(), end = txns.end(); it != end; ++it) { Json::Value obj(Json::objectValue);