mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 23:45:51 +00:00
Add account_lines paging (RIPD-343)
This commit is contained in:
committed by
Nik Bougalis
parent
f81b084448
commit
cd1bd18a49
@@ -3234,6 +3234,8 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\TransactionSign.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\Tuning.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\InternalHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Manager.h">
|
||||
@@ -3244,8 +3246,6 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCServerHandler.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Tuning.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\sitefiles\api\Listener.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\sitefiles\api\Manager.h">
|
||||
|
||||
@@ -4437,6 +4437,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\TransactionSign.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\Tuning.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\InternalHandler.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
@@ -4452,9 +4455,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCServerHandler.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Tuning.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\sitefiles\api\Listener.h">
|
||||
<Filter>ripple\sitefiles\api</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -800,7 +800,7 @@ public:
|
||||
// - To modify the method, provide a new method in the request.
|
||||
{ "account_currencies", &RPCParser::parseAccountCurrencies, 1, 2 },
|
||||
{ "account_info", &RPCParser::parseAccountItems, 1, 2 },
|
||||
{ "account_lines", &RPCParser::parseAccountLines, 1, 3 },
|
||||
{ "account_lines", &RPCParser::parseAccountLines, 1, 5 },
|
||||
{ "account_offers", &RPCParser::parseAccountItems, 1, 2 },
|
||||
{ "account_tx", &RPCParser::parseAccountTransactions, 1, 8 },
|
||||
{ "book_offers", &RPCParser::parseBookOffers, 2, 7 },
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_TUNING_H
|
||||
#define RIPPLE_RPC_TUNING_H
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
const int DEFAULT_AUTO_FILL_FEE_MULTIPLIER = 10;
|
||||
const int MAX_PATHFINDS_IN_PROGRESS = 2;
|
||||
const int MAX_PATHFIND_JOB_COUNT = 50;
|
||||
const int MAX_JOB_QUEUE_CLIENTS = 500;
|
||||
const int MAX_VALIDATED_LEDGER_AGE = 120;
|
||||
const int MAX_REQUEST_SIZE = 1000000;
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -25,6 +26,8 @@ namespace ripple {
|
||||
// account_index: <number> // optional, defaults to 0.
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// limit: integer // optional
|
||||
// marker: opaque // optional, resume previous query
|
||||
// }
|
||||
Json::Value doAccountLines (RPC::Context& context)
|
||||
{
|
||||
@@ -73,53 +76,93 @@ Json::Value doAccountLines (RPC::Context& context)
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int limit;
|
||||
if (params.isMember (jss::limit))
|
||||
{
|
||||
limit = std::max (RPC::Tuning::minLinesPerRequest,
|
||||
std::min (params[jss::limit].asUInt (),
|
||||
RPC::Tuning::maxLinesPerRequest));
|
||||
}
|
||||
else
|
||||
{
|
||||
limit = RPC::Tuning::defaultLinesPerRequest;
|
||||
}
|
||||
|
||||
RippleAddress resumeAddress;
|
||||
if (params.isMember (jss::marker))
|
||||
{
|
||||
if (!resumeAddress.setAccountID (params[jss::marker].asString ()))
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
}
|
||||
|
||||
if (ledger->hasAccount (raAccount))
|
||||
{
|
||||
result[jss::account] = raAccount.humanAccountID ();
|
||||
Json::Value& jsonLines = (result[jss::lines] = Json::arrayValue);
|
||||
|
||||
bool resume (! resumeAddress.isValid ());
|
||||
unsigned int i (0);
|
||||
|
||||
for (auto const& item : getRippleStateItems (raAccount.getAccountID (), ledger))
|
||||
{
|
||||
RippleState* line = (RippleState*)item.get ();
|
||||
RippleState const& line (*item.get ());
|
||||
Account const& lineAccount (line.getAccountIDPeer ());
|
||||
|
||||
if (! resume && resumeAddress.getAccountID () == lineAccount)
|
||||
resume = true;
|
||||
|
||||
if (!raPeer.isValid () ||
|
||||
raPeer.getAccountID () == line->getAccountIDPeer ())
|
||||
if (resume &&
|
||||
(!raPeer.isValid () || raPeer.getAccountID () == lineAccount))
|
||||
{
|
||||
STAmount const& saBalance = line->getBalance ();
|
||||
STAmount const& saLimit = line->getLimit ();
|
||||
STAmount const& saLimitPeer = line->getLimitPeer ();
|
||||
if (i < limit)
|
||||
{
|
||||
STAmount const& saBalance = line.getBalance ();
|
||||
STAmount const& saLimit = line.getLimit ();
|
||||
STAmount const& saLimitPeer = line.getLimitPeer ();
|
||||
|
||||
Json::Value& jPeer = jsonLines.append (Json::objectValue);
|
||||
Json::Value& jPeer = jsonLines.append (Json::objectValue);
|
||||
|
||||
jPeer[jss::account] = to_string (line->getAccountIDPeer ());
|
||||
// Amount reported is positive if current account holds other
|
||||
// account's IOUs.
|
||||
//
|
||||
// Amount reported is negative if other account holds current
|
||||
// account's IOUs.
|
||||
jPeer[jss::balance] = saBalance.getText ();
|
||||
jPeer[jss::currency] = saBalance.getHumanCurrency ();
|
||||
jPeer[jss::limit] = saLimit.getText ();
|
||||
jPeer[jss::limit_peer] = saLimitPeer.getText ();
|
||||
jPeer[jss::quality_in]
|
||||
= static_cast<Json::UInt> (line->getQualityIn ());
|
||||
jPeer[jss::quality_out]
|
||||
= static_cast<Json::UInt> (line->getQualityOut ());
|
||||
if (line->getAuth())
|
||||
jPeer[jss::authorized] = true;
|
||||
if (line->getAuthPeer())
|
||||
jPeer[jss::peer_authorized] = true;
|
||||
if (line->getNoRipple())
|
||||
jPeer[jss::no_ripple] = true;
|
||||
if (line->getNoRipplePeer())
|
||||
jPeer[jss::no_ripple_peer] = true;
|
||||
if (line->getFreeze())
|
||||
jPeer[jss::freeze] = true;
|
||||
if (line->getFreezePeer())
|
||||
jPeer[jss::freeze_peer] = true;
|
||||
jPeer[jss::account] = to_string (lineAccount);
|
||||
// Amount reported is positive if current account holds other
|
||||
// account's IOUs.
|
||||
//
|
||||
// Amount reported is negative if other account holds current
|
||||
// account's IOUs.
|
||||
jPeer[jss::balance] = saBalance.getText ();
|
||||
jPeer[jss::currency] = saBalance.getHumanCurrency ();
|
||||
jPeer[jss::limit] = saLimit.getText ();
|
||||
jPeer[jss::limit_peer] = saLimitPeer.getText ();
|
||||
jPeer[jss::quality_in]
|
||||
= static_cast<Json::UInt> (line.getQualityIn ());
|
||||
jPeer[jss::quality_out]
|
||||
= static_cast<Json::UInt> (line.getQualityOut ());
|
||||
if (line.getAuth ())
|
||||
jPeer[jss::authorized] = true;
|
||||
if (line.getAuthPeer ())
|
||||
jPeer[jss::peer_authorized] = true;
|
||||
if (line.getNoRipple ())
|
||||
jPeer[jss::no_ripple] = true;
|
||||
if (line.getNoRipplePeer ())
|
||||
jPeer[jss::no_ripple_peer] = true;
|
||||
if (line.getFreeze ())
|
||||
jPeer[jss::freeze] = true;
|
||||
if (line.getFreezePeer ())
|
||||
jPeer[jss::freeze_peer] = true;
|
||||
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[jss::limit] = limit;
|
||||
result[jss::marker] = to_string (lineAccount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! resume)
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/rpc/Tuning.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/impl/LegacyPathFind.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -34,13 +34,13 @@ LegacyPathFind::LegacyPathFind (bool isAdmin) : m_isOk (false)
|
||||
|
||||
auto& app = getApp();
|
||||
auto const& jobCount = app.getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
if (jobCount > MAX_PATHFIND_JOB_COUNT || app.getFeeTrack().isLoadedLocal ())
|
||||
if (jobCount > Tuning::maxPathfindJobCount || app.getFeeTrack().isLoadedLocal ())
|
||||
return;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int prevVal = inProgress.load();
|
||||
if (prevVal >= MAX_PATHFINDS_IN_PROGRESS)
|
||||
if (prevVal >= Tuning::maxPathfindsInProgress)
|
||||
return;
|
||||
|
||||
if (inProgress.compare_exchange_strong (
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <ripple/app/main/RPCHTTPServer.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/RPCServerHandler.h>
|
||||
#include <ripple/rpc/Tuning.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/impl/Context.h>
|
||||
#include <ripple/rpc/impl/Handler.h>
|
||||
|
||||
@@ -85,7 +85,7 @@ Json::Value RPCHandler::doCommand (
|
||||
// VFALCO NOTE Should we also add up the jtRPC jobs?
|
||||
//
|
||||
int jc = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
if (jc > RPC::MAX_JOB_QUEUE_CLIENTS)
|
||||
if (jc > RPC::Tuning::maxJobQueueClients)
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "Too busy for command: " << jc;
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
@@ -123,7 +123,7 @@ Json::Value RPCHandler::doCommand (
|
||||
if (!getConfig ().RUN_STANDALONE
|
||||
&& (handler->condition_ & RPC::NEEDS_CURRENT_LEDGER)
|
||||
&& (getApp().getLedgerMaster().getValidatedLedgerAge() >
|
||||
RPC::MAX_VALIDATED_LEDGER_AGE))
|
||||
RPC::Tuning::maxValidatedLedgerAge))
|
||||
{
|
||||
return rpcError (rpcNO_CURRENT);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/RPCServerHandler.h>
|
||||
#include <ripple/rpc/Tuning.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -55,7 +55,7 @@ std::string RPCServerHandler::processRequest (
|
||||
{
|
||||
Json::Reader reader;
|
||||
|
||||
if ((request.size() > RPC::MAX_REQUEST_SIZE) ||
|
||||
if ((request.size() > ripple::RPC::Tuning::maxRequestSize) ||
|
||||
! reader.parse (request, jsonRequest) ||
|
||||
jsonRequest.isNull () ||
|
||||
! jsonRequest.isObject ())
|
||||
|
||||
@@ -58,7 +58,7 @@ static void autofill_fee (
|
||||
if (tx.isMember ("Fee"))
|
||||
return;
|
||||
|
||||
int mult = DEFAULT_AUTO_FILL_FEE_MULTIPLIER;
|
||||
int mult = Tuning::defaultAutoFillFeeMultiplier;
|
||||
if (request.isMember ("fee_mult_max"))
|
||||
{
|
||||
if (request["fee_mult_max"].isNumeric ())
|
||||
|
||||
73
src/ripple/rpc/impl/Tuning.h
Normal file
73
src/ripple/rpc/impl/Tuning.h
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_TUNING_H_INCLUDED
|
||||
#define RIPPLE_RPC_TUNING_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
/** Tuned constants. */
|
||||
/** @{ */
|
||||
namespace Tuning {
|
||||
|
||||
/** Default account lines return per request to the
|
||||
account_lines command when no limit param is specified
|
||||
*/
|
||||
unsigned int const defaultLinesPerRequest (200);
|
||||
|
||||
/** Minimum account lines return per request to the
|
||||
account_lines command. Specified in the limit param.
|
||||
*/
|
||||
unsigned int const minLinesPerRequest (10);
|
||||
|
||||
/** Maximum account lines return per request to the
|
||||
account_lines command. Specified in the limit param.
|
||||
*/
|
||||
unsigned int const maxLinesPerRequest (400);
|
||||
|
||||
/** Default offers return per request to the account_offers command
|
||||
when no limit param is specified
|
||||
*/
|
||||
unsigned int const defaultOffersPerRequest (200);
|
||||
|
||||
/** Minimum offers return per request to the account_offers command.
|
||||
Specified in the limit param.
|
||||
*/
|
||||
unsigned int const minOffersPerRequest (10);
|
||||
|
||||
/** Maximum offers return per request to the account_lines command.
|
||||
Specified in the limit param.
|
||||
*/
|
||||
unsigned int const maxOffersPerRequest (400);
|
||||
|
||||
int const defaultAutoFillFeeMultiplier (10);
|
||||
int const maxPathfindsInProgress (2);
|
||||
int const maxPathfindJobCount (50);
|
||||
int const maxJobQueueClients (500);
|
||||
int const maxValidatedLedgerAge (120);
|
||||
int const maxRequestSize (1000000);
|
||||
|
||||
} // Tuning
|
||||
/** @} */
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user