mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-19 19:25:53 +00:00
include searched_all in error response of tx (#407)
This commit is contained in:
@@ -106,7 +106,7 @@ makeError(Status const& status)
|
||||
return str.empty() ? nullopt : make_optional(str);
|
||||
};
|
||||
|
||||
return visit(
|
||||
auto res = visit(
|
||||
overloadSet{
|
||||
[&status, &wrapOptional](RippledError err) {
|
||||
if (err == ripple::rpcUNKNOWN)
|
||||
@@ -130,6 +130,14 @@ makeError(Status const& status)
|
||||
},
|
||||
},
|
||||
status.code);
|
||||
if (status.extraInfo)
|
||||
{
|
||||
for (auto& [key, value] : status.extraInfo.value())
|
||||
{
|
||||
res[key] = value;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
|
||||
@@ -50,9 +50,12 @@ struct Status
|
||||
CombinedError code = RippledError::rpcSUCCESS;
|
||||
std::string error = "";
|
||||
std::string message = "";
|
||||
std::optional<boost::json::object> extraInfo;
|
||||
|
||||
Status() = default;
|
||||
/* implicit */ Status(CombinedError code) : code(code){};
|
||||
Status(CombinedError code, boost::json::object&& extraInfo)
|
||||
: code(code), extraInfo(std::move(extraInfo)){};
|
||||
|
||||
// HACK. Some rippled handlers explicitly specify errors.
|
||||
// This means that we have to be able to duplicate this
|
||||
|
||||
@@ -31,6 +31,17 @@ doTx(Context const& context)
|
||||
|
||||
binary = request.at(JS(binary)).as_bool();
|
||||
}
|
||||
auto minLedger = getUInt(request, JS(min_ledger));
|
||||
auto maxLedger = getUInt(request, JS(max_ledger));
|
||||
bool rangeSupplied = minLedger && maxLedger;
|
||||
|
||||
if (rangeSupplied)
|
||||
{
|
||||
if (*minLedger > *maxLedger)
|
||||
return Status{RippledError::rpcINVALID_LGR_RANGE};
|
||||
if (*maxLedger - *minLedger > 1000)
|
||||
return Status{RippledError::rpcEXCESSIVE_LGR_RANGE};
|
||||
}
|
||||
|
||||
auto range = context.backend->fetchLedgerRange();
|
||||
if (!range)
|
||||
@@ -38,7 +49,17 @@ doTx(Context const& context)
|
||||
|
||||
auto dbResponse = context.backend->fetchTransaction(hash, context.yield);
|
||||
if (!dbResponse)
|
||||
{
|
||||
if (rangeSupplied)
|
||||
{
|
||||
bool searchedAll = range->maxSequence >= *maxLedger &&
|
||||
range->minSequence <= *minLedger;
|
||||
boost::json::object extra;
|
||||
extra["searched_all"] = searchedAll;
|
||||
return Status{RippledError::rpcTXN_NOT_FOUND, std::move(extra)};
|
||||
}
|
||||
return Status{RippledError::rpcTXN_NOT_FOUND};
|
||||
}
|
||||
|
||||
if (!binary)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user