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

@@ -90,14 +90,13 @@ doAccountChannels(Context const& context)
return Status{Error::rpcINVALID_PARAMS, "limitNotPositive"};
}
ripple::uint256 marker;
std::optional<std::string> marker = {};
if (request.contains("marker"))
{
if (!request.at("marker").is_string())
return Status{Error::rpcINVALID_PARAMS, "markerNotString"};
if (!marker.parseHex(request.at("marker").as_string().c_str()))
return Status{Error::rpcINVALID_PARAMS, "malformedCursor"};
marker = request.at("marker").as_string().c_str();
}
response["account"] = ripple::to_string(*accountID);
@@ -121,18 +120,25 @@ doAccountChannels(Context const& context)
return true;
};
auto nextCursor = traverseOwnedNodes(
auto next = traverseOwnedNodes(
*context.backend,
*accountID,
lgrInfo.seq,
limit,
marker,
context.yield,
addToResponse);
response["ledger_hash"] = ripple::strHex(lgrInfo.hash);
response["ledger_index"] = lgrInfo.seq;
if (nextCursor)
response["marker"] = ripple::strHex(*nextCursor);
if (auto status = std::get_if<RPC::Status>(&next))
return *status;
auto nextCursor = std::get<RPC::AccountCursor>(next);
if (nextCursor.isNonZero())
response["marker"] = nextCursor.toString();
return response;
}