From 55e4ea0277f2ba55073881d989eb5df647f4a931 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 28 Mar 2023 11:40:43 +0200 Subject: [PATCH] API: added sidechain diff and height to pool stats --- src/p2pool.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p2pool.cpp b/src/p2pool.cpp index ff61887..4b2ae7f 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -1252,7 +1252,8 @@ void p2pool::api_update_pool_stats() } uint64_t t; - const difficulty_type& diff = m_sideChain->difficulty(); + const difficulty_type diff = m_sideChain->difficulty(); + const uint64_t height = m_sideChain->chainTip() ? m_sideChain->chainTip()->m_sidechainHeight : 0; const uint64_t hashrate = udiv128(diff.hi, diff.lo, m_sideChain->block_time(), &t); const uint64_t miners = std::max(m_sideChain->miner_count(), m_p2pServer ? m_p2pServer->peer_list_size() : 0U); const difficulty_type total_hashes = m_sideChain->total_hashes(); @@ -1274,7 +1275,7 @@ void p2pool::api_update_pool_stats() } m_api->set(p2pool_api::Category::POOL, "stats", - [hashrate, miners, &total_hashes, last_block_found_time, last_block_found_height, total_blocks_found, &pplns_weight](log::Stream& s) + [hashrate, miners, &total_hashes, last_block_found_time, last_block_found_height, total_blocks_found, &pplns_weight, diff, height](log::Stream& s) { s << "{\"pool_list\":[\"pplns\"],\"pool_statistics\":{\"hashRate\":" << hashrate << ",\"miners\":" << miners @@ -1283,6 +1284,8 @@ void p2pool::api_update_pool_stats() << ",\"lastBlockFound\":" << last_block_found_height << ",\"totalBlocksFound\":" << total_blocks_found << ",\"pplnsWeight\":" << pplns_weight + << ",\"sidechainDifficulty\":" << diff + << ",\"sidechainHeight\":" << height << "}}"; });