Make Clio RPCs more consistent with rippled (#110)

* parse ledger_index as number

* allow websocket to use "command" or "method"

* mark all non-forwarded responses as validated

* dont mark forwarded errors as successful

* reduce forwarding Websocket expiration 30->3 seconds

* fix merge conflict in test.py

* adds ledger_current and ledger_closed

* deserialize `taker_gets_funded` into amount json

* limit account RPCs by number of objects traversed

* assign result correctly
This commit is contained in:
Nathan Nichols
2022-03-21 18:28:03 -05:00
committed by GitHub
parent 945222840b
commit 1d5c482d9c
17 changed files with 394 additions and 113 deletions

View File

@@ -18,10 +18,16 @@ make_WsContext(
Counters& counters,
std::string const& clientIp)
{
if (!request.contains("command"))
boost::json::value commandValue = nullptr;
if (!request.contains("command") && request.contains("method"))
commandValue = request.at("method");
else if (request.contains("command") && !request.contains("method"))
commandValue = request.at("command");
if (!commandValue.is_string())
return {};
std::string command = request.at("command").as_string().c_str();
std::string command = commandValue.as_string().c_str();
return Context{
yc,
@@ -142,10 +148,17 @@ static std::unordered_set<std::string> forwardCommands{
"submit",
"submit_multisigned",
"fee",
"path_find",
"ledger_closed",
"ledger_current",
"ripple_path_find",
"manifest"};
bool
validHandler(std::string const& method)
{
return handlerTable.contains(method) || forwardCommands.contains(method);
}
bool
shouldForwardToRippled(Context const& ctx)
{
@@ -203,7 +216,12 @@ buildResponse(Context const& ctx)
try
{
return method(ctx);
auto v = method(ctx);
if (auto object = std::get_if<boost::json::object>(&v))
(*object)["validated"] = true;
return v;
}
catch (InvalidParamsError const& err)
{