mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 02:25:52 +00:00
Bring some constants into RPC::Tuning.h.
This commit is contained in:
committed by
Edward Hennis
parent
4eb6020813
commit
849e1ce5f4
@@ -23,6 +23,7 @@
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/rpc/impl/LookupLedger.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/Context.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
@@ -40,9 +41,6 @@ namespace ripple {
|
||||
// marker: resume point, if any
|
||||
Json::Value doLedgerData (RPC::Context& context)
|
||||
{
|
||||
static int const BINARY_PAGE_LENGTH = 2048;
|
||||
static int const JSON_PAGE_LENGTH = 256;
|
||||
|
||||
std::shared_ptr<ReadView const> lpLedger;
|
||||
auto const& params = context.params;
|
||||
|
||||
@@ -61,8 +59,6 @@ Json::Value doLedgerData (RPC::Context& context)
|
||||
bool isBinary = params[jss::binary].asBool();
|
||||
|
||||
int limit = -1;
|
||||
int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH;
|
||||
|
||||
if (params.isMember (jss::limit))
|
||||
{
|
||||
Json::Value const& jLimit = params[jss::limit];
|
||||
@@ -72,6 +68,7 @@ Json::Value doLedgerData (RPC::Context& context)
|
||||
limit = jLimit.asInt ();
|
||||
}
|
||||
|
||||
auto maxLimit = RPC::Tuning::pageLength(isBinary);
|
||||
if ((limit < 0) || ((limit > maxLimit) && (context.role != Role::ADMIN)))
|
||||
limit = maxLimit;
|
||||
|
||||
|
||||
@@ -47,12 +47,24 @@ static LimitRange const bookOffers = {0, 0, 400};
|
||||
/** Limits for the no_ripple_check command. */
|
||||
static LimitRange const noRippleCheck = {10, 300, 400};
|
||||
|
||||
static int const defaultAutoFillFeeMultiplier (10);
|
||||
static int const maxPathfindsInProgress (2);
|
||||
static int const maxPathfindJobCount (50);
|
||||
static int const maxJobQueueClients (500);
|
||||
static int const maxValidatedLedgerAge (120);
|
||||
static int const maxRequestSize (1000000);
|
||||
static int const defaultAutoFillFeeMultiplier = 10;
|
||||
static int const maxPathfindsInProgress = 2;
|
||||
static int const maxPathfindJobCount = 50;
|
||||
static int const maxJobQueueClients = 500;
|
||||
static int const maxValidatedLedgerAge = 120;
|
||||
static int const maxRequestSize = 1000000;
|
||||
|
||||
/** Maximum number of pages in one response from a binary LedgerData request. */
|
||||
static int const binaryPageLength = 2048;
|
||||
|
||||
/** Maximum number of pages in one response from a Json LedgerData request. */
|
||||
static int const jsonPageLength = 256;
|
||||
|
||||
/** Maximum number of pages in a LedgerData response. */
|
||||
inline int pageLength(bool isBinary)
|
||||
{
|
||||
return isBinary ? binaryPageLength : jsonPageLength;
|
||||
}
|
||||
|
||||
} // Tuning
|
||||
/** @} */
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <ripple/resource/ResourceManager.h>
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/rpc/Coroutine.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <beast/crypto/base64.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||
@@ -237,7 +238,7 @@ ServerHandlerImp::processRequest (
|
||||
Json::Value jsonRPC;
|
||||
{
|
||||
Json::Reader reader;
|
||||
if ((request.size () > 1000000) ||
|
||||
if ((request.size () > RPC::Tuning::maxRequestSize) ||
|
||||
! reader.parse (request, jsonRPC) ||
|
||||
! jsonRPC ||
|
||||
! jsonRPC.isObject ())
|
||||
|
||||
Reference in New Issue
Block a user