move version specifier to Build.h

This commit is contained in:
Nathan Nichols
2022-05-25 16:05:09 -05:00
committed by Michael Legleux
parent af575b1bcf
commit 458fac776c
12 changed files with 142 additions and 6 deletions

View File

@@ -106,6 +106,14 @@ make_error(Error err)
boost::json::object
make_error(Status const& status)
{
if (status.error == ripple::rpcUNKNOWN)
{
return {
{"error", status.message},
{"type", "response"},
{"status", "error"}};
}
boost::json::object json;
ripple::RPC::ErrorInfo const& info(
ripple::RPC::get_error_info(status.error));

View File

@@ -103,6 +103,14 @@ struct Status
Status(Error error_) : error(error_){};
// HACK. Some rippled handlers explicitly specify errors.
// This means that we have to be able to duplicate this
// functionality.
Status(std::string const& message_)
: error(ripple::rpcUNKNOWN), message(message_)
{
}
Status(Error error_, std::string message_)
: error(error_), message(message_)
{

View File

@@ -357,7 +357,7 @@ doLedgerEntry(Context const& context)
auto end = std::chrono::system_clock::now();
if (!dbResponse or dbResponse->size() == 0)
return Status{Error::rpcOBJECT_NOT_FOUND, "entryNotFound"};
return Status{"entryNotFound"};
response[JS(index)] = ripple::strHex(key);
response[JS(ledger_hash)] = ripple::strHex(lgrInfo.hash);

View File

@@ -2,6 +2,7 @@
#include <backend/BackendInterface.h>
#include <etl/ETLSource.h>
#include <etl/ReportingETL.h>
#include <main/Build.h>
#include <rpc/RPCHelpers.h>
namespace RPC {
@@ -49,6 +50,7 @@ doServerInfo(Context const& context)
{{"counters", "server_info"}}, context.clientIp, context.yield);
info[JS(load_factor)] = 1;
info["clio_version"] = Build::getClioVersionString();
if (serverInfoRippled && !serverInfoRippled->contains(JS(error)))
{
try
@@ -57,6 +59,7 @@ doServerInfo(Context const& context)
auto& rippledInfo = rippledResult.at(JS(info)).as_object();
info[JS(load_factor)] = rippledInfo[JS(load_factor)];
info[JS(validation_quorum)] = rippledInfo[JS(validation_quorum)];
info["rippled_version"] = rippledInfo[JS(build_version)];
}
catch (std::exception const&)
{