Fix max limit for account tx (#723)

Fixes #724
This commit is contained in:
cyan317
2023-07-03 10:56:43 +01:00
committed by GitHub
parent aadd9e50f0
commit ef62718a27
4 changed files with 9 additions and 7 deletions

View File

@@ -76,12 +76,12 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
// if forward, start at minIndex - 1, because the SQL query is exclusive, we need to include the 0 transaction
// index of minIndex
if (input.forward)
cursor = {minIndex - 1, INT32_MAX};
cursor = {minIndex - 1, std::numeric_limits<int32_t>::max()};
else
cursor = {maxIndex, INT32_MAX};
cursor = {maxIndex, std::numeric_limits<int32_t>::max()};
}
static auto constexpr limitDefault = 50;
static auto constexpr limitDefault = 200;
auto const limit = input.limit.value_or(limitDefault);
auto const accountID = accountFromStringStrict(input.account);
auto const [txnsAndCursor, timeDiff] = util::timed([&]() {

View File

@@ -91,7 +91,7 @@ public:
{JS(ledger_index_max), validation::Type<int32_t>{}},
{JS(binary), validation::Type<bool>{}},
{JS(forward), validation::Type<bool>{}},
{JS(limit), validation::Type<uint32_t>{}, validation::Between{1, 100}},
{JS(limit), validation::Type<uint32_t>{}, validation::Between{1, std::numeric_limits<int32_t>::max()}},
{JS(marker),
validation::WithCustomError{
validation::Type<boost::json::object>{},

View File

@@ -20,6 +20,8 @@
#include <rpc/handlers/NFTHistory.h>
#include <util/Profiler.h>
#include <limits>
namespace RPC {
// TODO: this is currently very similar to account_tx but its own copy for time
@@ -76,7 +78,7 @@ NFTHistoryHandler::process(NFTHistoryHandler::Input input, Context const& ctx) c
if (input.forward)
cursor = {minIndex, 0};
else
cursor = {maxIndex, INT32_MAX};
cursor = {maxIndex, std::numeric_limits<int32_t>::max()};
}
static auto constexpr limitDefault = 50;

View File

@@ -107,8 +107,8 @@ generateTestValuesForParametersTest()
"invalidParams",
"Invalid parameters."},
AccountTxParamTestCaseBundle{
"limitOverRange",
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": 101})",
"limitNotInRange",
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": 0})",
"invalidParams",
"Invalid parameters."},
AccountTxParamTestCaseBundle{