Add (non-standard) 'daemon_status' endpoint to REST API (#124)

This commit is contained in:
Lee *!* Clagett
2024-08-06 19:04:55 -04:00
committed by Lee *!* Clagett
parent 79564f714f
commit 8fad87a0fe
3 changed files with 122 additions and 2 deletions

View File

@@ -40,6 +40,7 @@
#include "ringct/rctOps.h" // monero/src
#include "span.h" // monero/contrib/epee/include
#include "util/random_outputs.h"
#include "wire.h"
#include "wire/adapted/crypto.h"
#include "wire/error.h"
#include "wire/json.h"
@@ -195,6 +196,29 @@ namespace lws
convert_address(address, self.address);
}
namespace rpc
{
namespace
{
constexpr const char* map_daemon_state[] = {"ok", "no_connections", "synchronizing", "unavailable"};
constexpr const char* map_network_type[] = {"main", "test", "stage", "fake"};
}
WIRE_DEFINE_ENUM(daemon_state, map_daemon_state);
WIRE_DEFINE_ENUM(network_type, map_network_type);
}
void rpc::write_bytes(wire::json_writer& dest, const daemon_status_response& self)
{
wire::object(dest,
WIRE_FIELD(outgoing_connections_count),
WIRE_FIELD(incoming_connections_count),
WIRE_FIELD(height),
WIRE_FIELD(target_height),
WIRE_FIELD(network),
WIRE_FIELD(state)
);
}
void rpc::write_bytes(wire::json_writer& dest, const new_subaddrs_response& self)
{
wire::object(dest, WIRE_FIELD(new_subaddrs), WIRE_FIELD(all_subaddrs));