API: added sidechain diff and height to pool stats

pull/253/head
SChernykh 2023-03-28 11:40:43 +02:00
parent bb80fe12a0
commit 55e4ea0277
1 changed files with 5 additions and 2 deletions

View File

@ -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<uint64_t>(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
<< "}}";
});