From 72adfd3126500501484b1675541b94671a759440 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 18 Apr 2023 17:01:00 +0200 Subject: [PATCH] Console: added local api --- src/console_commands.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/console_commands.cpp b/src/console_commands.cpp index 93a26b6..fc312c6 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -25,6 +25,8 @@ #include "miner.h" #endif #include "side_chain.h" +#include "p2pool_api.h" +#include "params.h" static constexpr char log_category_prefix[] = "ConsoleCommands "; @@ -99,6 +101,16 @@ ConsoleCommands::ConsoleCommands(p2pool* pool) LOGERR(1, "uv_read_start failed, error " << uv_err_name(err)); throw std::exception(); } + + if (m_pool->api() && m_pool->params().m_localStats) { + m_pool->api()->set(p2pool_api::Category::LOCAL, "console", + [stdin_type, this](log::Stream& s) + { + s << "{\"mode\":" << ((stdin_type == UV_TTY) ? "\"tty\"" : "\"pipe\"") + << ",\"tcp_port\":" << m_listenPort + << "}"; + }); + } } ConsoleCommands::~ConsoleCommands()