Unwrap result when forwarding (#78)

* fix error formatting for forwarded responses

* unwrap result when forwarding successful responses
This commit is contained in:
Nathan Nichols
2022-01-05 14:06:47 -06:00
committed by GitHub
parent 49c7c9989f
commit c3c248734f
2 changed files with 9 additions and 2 deletions

View File

@@ -166,12 +166,19 @@ buildResponse(Context const& ctx)
{
if (shouldForwardToRippled(ctx))
{
auto res = ctx.balancer->forwardToRippled(ctx.params, ctx.clientIp);
boost::json::object toForward = ctx.params;
toForward["command"] = ctx.method;
auto res = ctx.balancer->forwardToRippled(toForward, ctx.clientIp);
ctx.counters.rpcForwarded(ctx.method);
if (!res)
return Status{Error::rpcFAILED_TO_FORWARD};
if (res->contains("result") && res->at("result").is_object())
return res->at("result").as_object();
return *res;
}