API for stratum server statistics.

Users can pass `--stratum-api` to command line to enable a file called `local/stats` in `--data-api` directory. `local/stats` contains statistics that `StratumServer status` provides but in JSON format. It is currently setup that `local/stats` is updated each time a new job is sent to a worker.
This commit is contained in:
Thomas Clarke
2021-10-02 00:09:42 +01:00
parent 2a3cd13b19
commit 7742d163f7
9 changed files with 110 additions and 8 deletions
+7 -1
View File
@@ -28,7 +28,7 @@ static constexpr char log_category_prefix[] = "P2Pool API ";
namespace p2pool {
p2pool_api::p2pool_api(const std::string& api_path) : m_apiPath(api_path)
p2pool_api::p2pool_api(const std::string& api_path, const bool local_stats): m_apiPath(api_path)
{
if (m_apiPath.empty()) {
LOGERR(1, "api path is empty");
@@ -60,9 +60,14 @@ p2pool_api::p2pool_api(const std::string& api_path) : m_apiPath(api_path)
m_networkPath = m_apiPath + "network/";
m_poolPath = m_apiPath + "pool/";
m_localPath = m_apiPath + "local/";
create_dir(m_networkPath);
create_dir(m_poolPath);
if (local_stats) {
create_dir(m_localPath);
}
}
p2pool_api::~p2pool_api()
@@ -109,6 +114,7 @@ void p2pool_api::dump_to_file_async_internal(const Category& category, const cha
case Category::GLOBAL: path = m_apiPath + filename; break;
case Category::NETWORK: path = m_networkPath + filename; break;
case Category::POOL: path = m_poolPath + filename; break;
case Category::LOCAL: path = m_localPath + filename; break;
}
{