mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user