From 2ce4ce4309d39ebbc99c03f8b96d8d897f5272f0 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 26 Nov 2013 19:52:39 -0800 Subject: [PATCH] Begin deprecating the old account_tx interface. --- src/ripple_app/misc/NetworkOPs.cpp | 19 ------------------- src/ripple_app/misc/NetworkOPs.h | 3 --- src/ripple_app/rpc/RPCHandler.cpp | 11 ++++++++++- src/ripple_net/rpc/RPCErr.cpp | 1 + src/ripple_net/rpc/RPCErr.h | 1 + 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/ripple_app/misc/NetworkOPs.cpp b/src/ripple_app/misc/NetworkOPs.cpp index 43779f3bb..74127d69f 100644 --- a/src/ripple_app/misc/NetworkOPs.cpp +++ b/src/ripple_app/misc/NetworkOPs.cpp @@ -336,7 +336,6 @@ public: getTxsAccountB (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin); std::vector getLedgerAffectedAccounts (uint32 ledgerSeq); - uint32 countAccountTxs (const RippleAddress& account, int32 minLedger, int32 maxLedger); // // Monitoring: publisher side @@ -1837,24 +1836,6 @@ std::vector NetworkOPsImp::getAccountTxsB ( } -uint32 -NetworkOPsImp::countAccountTxs (const RippleAddress& account, int32 minLedger, int32 maxLedger) -{ - // can be called with no locks - uint32 ret = 0; - std::string sql = NetworkOPsImp::transactionsSQL ("COUNT(DISTINCT TransID) AS 'TransactionCount'", account, - minLedger, maxLedger, false, 0, -1, true, true, true); - - Database* db = getApp().getTxnDB ()->getDB (); - DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ()); - SQL_FOREACH (db, sql) - { - ret = db->getInt ("TransactionCount"); - } - - return ret; -} - std::vector< std::pair > NetworkOPsImp::getTxsAccount (const RippleAddress& account, int32 minLedger, int32 maxLedger, bool forward, Json::Value& token, int limit, bool bAdmin) { diff --git a/src/ripple_app/misc/NetworkOPs.h b/src/ripple_app/misc/NetworkOPs.h index e8fbdb889..f69eefc28 100644 --- a/src/ripple_app/misc/NetworkOPs.h +++ b/src/ripple_app/misc/NetworkOPs.h @@ -298,9 +298,6 @@ public: virtual std::vector getLedgerAffectedAccounts (uint32 ledgerSeq) = 0; - virtual uint32 countAccountTxs (const RippleAddress& account, - int32 minLedger, int32 maxLedger) = 0; - //-------------------------------------------------------------------------- // // Monitoring: publisher side diff --git a/src/ripple_app/rpc/RPCHandler.cpp b/src/ripple_app/rpc/RPCHandler.cpp index db0cafa48..497350878 100644 --- a/src/ripple_app/rpc/RPCHandler.cpp +++ b/src/ripple_app/rpc/RPCHandler.cpp @@ -2113,6 +2113,9 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo if (!raAccount.setAccountID (params["account"].asString ())) return rpcError (rpcACT_MALFORMED); + if (offset > 3000) + return rpcError (rpcATX_DEPRECATED); + loadType = Resource::feeHighBurdenRPC; // DEPRECATED @@ -2159,6 +2162,8 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo uLedgerMin = uLedgerMax = l->getLedgerSeq (); } + int count = 0; + #ifndef BEAST_DEBUG try @@ -2179,6 +2184,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo for (std::vector::const_iterator it = txns.begin (), end = txns.end (); it != end; ++it) { + ++count; Json::Value& jvObj = jvTxns.append (Json::objectValue); uint32 uLedgerIndex = it->get<2> (); @@ -2195,6 +2201,7 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo for (std::vector< std::pair >::iterator it = txns.begin (), end = txns.end (); it != end; ++it) { + ++count; Json::Value& jvObj = jvTxns.append (Json::objectValue); if (it->first) @@ -2217,8 +2224,10 @@ Json::Value RPCHandler::doAccountTxOld (Json::Value params, Resource::Charge& lo ret["validated"] = bValidated && uValidatedMin <= uLedgerMin && uValidatedMax >= uLedgerMax; ret["offset"] = offset; + // We no longer return the full count but only the count of returned transactions + // Computing this count was two expensive and this API is deprecated anyway if (bCount) - ret["count"] = mNetOps->countAccountTxs (raAccount, uLedgerMin, uLedgerMax); + ret["count"] = count; if (params.isMember ("limit")) ret["limit"] = limit; diff --git a/src/ripple_net/rpc/RPCErr.cpp b/src/ripple_net/rpc/RPCErr.cpp index 868649397..3d4e91f53 100644 --- a/src/ripple_net/rpc/RPCErr.cpp +++ b/src/ripple_net/rpc/RPCErr.cpp @@ -91,6 +91,7 @@ Json::Value rpcError (int iError, Json::Value jvResult) { rpcWRONG_SEED, "wrongSeed", "The regular key does not point as the master key." }, { rpcTOO_BUSY, "tooBusy", "The server is too busy to help you now." }, { rpcSLOW_DOWN, "slowDown", "You are placing too much load on the server." }, + { rpcATX_DEPRECATED, "deprecated", "Use the new API or specify a ledger range." }, }; int i; diff --git a/src/ripple_net/rpc/RPCErr.h b/src/ripple_net/rpc/RPCErr.h index fb3a266f6..c08ea3632 100644 --- a/src/ripple_net/rpc/RPCErr.h +++ b/src/ripple_net/rpc/RPCErr.h @@ -94,6 +94,7 @@ enum rpcSRC_AMT_MALFORMED, rpcSRC_CUR_MALFORMED, rpcSRC_ISR_MALFORMED, + rpcATX_DEPRECATED, // Internal error (should never happen) rpcINTERNAL, // Generic internal error.