mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-03 17:29:24 +00:00
Show hashrate estimate in status
This commit is contained in:
parent
8f2493edfc
commit
336349e189
4 changed files with 28 additions and 8 deletions
|
@ -51,6 +51,7 @@ BlockTemplate::BlockTemplate(p2pool* pool)
|
||||||
, m_seedHash{}
|
, m_seedHash{}
|
||||||
, m_timestamp(0)
|
, m_timestamp(0)
|
||||||
, m_poolBlockTemplate(new PoolBlock())
|
, m_poolBlockTemplate(new PoolBlock())
|
||||||
|
, m_finalReward(0)
|
||||||
, m_nextPayout(0)
|
, m_nextPayout(0)
|
||||||
{
|
{
|
||||||
uv_rwlock_init_checked(&m_lock);
|
uv_rwlock_init_checked(&m_lock);
|
||||||
|
@ -121,6 +122,7 @@ BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b)
|
||||||
m_txkeyPub = b.m_txkeyPub;
|
m_txkeyPub = b.m_txkeyPub;
|
||||||
m_txkeySec = b.m_txkeySec;
|
m_txkeySec = b.m_txkeySec;
|
||||||
*m_poolBlockTemplate = *b.m_poolBlockTemplate;
|
*m_poolBlockTemplate = *b.m_poolBlockTemplate;
|
||||||
|
m_finalReward = b.m_finalReward;
|
||||||
m_nextPayout = b.m_nextPayout;
|
m_nextPayout = b.m_nextPayout;
|
||||||
|
|
||||||
m_minerTx.clear();
|
m_minerTx.clear();
|
||||||
|
@ -414,6 +416,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_finalReward = final_reward;
|
||||||
m_nextPayout = 0;
|
m_nextPayout = 0;
|
||||||
for (size_t i = 0, n = m_shares.size(); i < n; ++i) {
|
for (size_t i = 0, n = m_shares.size(); i < n; ++i) {
|
||||||
if (*m_shares[i].m_wallet == m_pool->params().m_wallet) {
|
if (*m_shares[i].m_wallet == m_pool->params().m_wallet) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
|
|
||||||
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||||
|
|
||||||
|
FORCEINLINE uint64_t final_reward() const { return m_finalReward; }
|
||||||
FORCEINLINE uint64_t next_payout() const { return m_nextPayout; }
|
FORCEINLINE uint64_t next_payout() const { return m_nextPayout; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -95,6 +96,7 @@ private:
|
||||||
|
|
||||||
BlockTemplate* m_oldTemplates[4] = {};
|
BlockTemplate* m_oldTemplates[4] = {};
|
||||||
|
|
||||||
|
uint64_t m_finalReward;
|
||||||
uint64_t m_nextPayout;
|
uint64_t m_nextPayout;
|
||||||
|
|
||||||
// Temp vectors, will be cleaned up after use and skipped in copy constructor/assignment operators
|
// Temp vectors, will be cleaned up after use and skipped in copy constructor/assignment operators
|
||||||
|
|
11
src/log.h
11
src/log.h
|
@ -308,6 +308,12 @@ template<> struct log::Stream::Entry<Hashrate>
|
||||||
|
|
||||||
static constexpr const char* units[] = { "H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s", "EH/s" };
|
static constexpr const char* units[] = { "H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s", "EH/s" };
|
||||||
|
|
||||||
|
int n;
|
||||||
|
char buf[32];
|
||||||
|
if (value.m_data < 1000) {
|
||||||
|
n = snprintf(buf, sizeof(buf), "%u %s", static_cast<uint32_t>(value.m_data), units[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
size_t k = 0;
|
size_t k = 0;
|
||||||
double magnitude = 1.0;
|
double magnitude = 1.0;
|
||||||
|
|
||||||
|
@ -316,8 +322,9 @@ template<> struct log::Stream::Entry<Hashrate>
|
||||||
++k;
|
++k;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[32];
|
n = snprintf(buf, sizeof(buf), "%.3f %s", x / magnitude, units[k]);
|
||||||
int n = snprintf(buf, sizeof(buf), "%.3f %s", x / magnitude, units[k]);
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
if (n > static_cast<int>(sizeof(buf)) - 1) {
|
if (n > static_cast<int>(sizeof(buf)) - 1) {
|
||||||
n = static_cast<int>(sizeof(buf)) - 1;
|
n = static_cast<int>(sizeof(buf)) - 1;
|
||||||
|
|
|
@ -615,14 +615,22 @@ void SideChain::print_status()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint64_t block_reward = m_pool->block_template().final_reward();
|
||||||
|
const uint64_t next_payout = m_pool->block_template().next_payout();
|
||||||
|
|
||||||
|
uint64_t product[2];
|
||||||
|
product[0] = umul128(pool_hashrate, next_payout, &product[1]);
|
||||||
|
const uint64_t hashrate_est = udiv128(product[1], product[0], block_reward, &rem);
|
||||||
|
|
||||||
LOGINFO(0, "status" <<
|
LOGINFO(0, "status" <<
|
||||||
"\nMain chain height = " << m_pool->block_template().height() <<
|
"\nMain chain height = " << m_pool->block_template().height() <<
|
||||||
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
|
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
|
||||||
"\nSide chain height = " << tip_height + 1 <<
|
"\nSide chain height = " << tip_height + 1 <<
|
||||||
"\nSide chain hashrate = " << log::Hashrate(pool_hashrate) <<
|
"\nSide chain hashrate = " << log::Hashrate(pool_hashrate) <<
|
||||||
|
"\nYour hashrate (est) = " << log::Hashrate(hashrate_est) <<
|
||||||
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)"
|
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)"
|
||||||
"\nYour shares = " << our_blocks_in_window << " blocks (+" << our_uncles_in_window << " uncles, " << our_orphans << " orphans)"
|
"\nYour shares = " << our_blocks_in_window << " blocks (+" << our_uncles_in_window << " uncles, " << our_orphans << " orphans)"
|
||||||
"\nNext payout = " << log::XMRAmount(m_pool->block_template().next_payout())
|
"\nNext payout = " << log::XMRAmount(next_payout)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue