Skip to content

Commit

Permalink
Maintain compatibility for forwarded RPC responses:
Browse files Browse the repository at this point in the history
Typically, an RPC response contains a `result` field, which
contains details about the operation performed. For ease of
parsing, forwarded responses must look like a non-forwarded
response.

In some instances the response was incorrectly composed, so
that the actual `result` object would be encapsulated by an
outer `result` object, breaking existing code.

This commit, addresses this issue and correctly "folds" the
`result` field, ensuring a consistent schema for responses.
  • Loading branch information
CJ Cobb authored and nbougalis committed Apr 1, 2021
1 parent 9c8cadd commit 8579eb0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ripple/rpc/impl/ServerHandlerImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,17 @@ ServerHandlerImp::processRequest(
reply.append(std::move(r));
else
reply = std::move(r);

if (reply.isMember(jss::result) &&
reply[jss::result].isMember(jss::result))
{
reply = reply[jss::result];
if (reply.isMember(jss::status))
{
reply[jss::result][jss::status] = reply[jss::status];
reply.removeMember(jss::status);
}
}
}
auto response = to_string(reply);

Expand Down

0 comments on commit 8579eb0

Please sign in to comment.