mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +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_timestamp(0)
|
||||
, m_poolBlockTemplate(new PoolBlock())
|
||||
, m_finalReward(0)
|
||||
, m_nextPayout(0)
|
||||
{
|
||||
uv_rwlock_init_checked(&m_lock);
|
||||
|
@ -121,6 +122,7 @@ BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b)
|
|||
m_txkeyPub = b.m_txkeyPub;
|
||||
m_txkeySec = b.m_txkeySec;
|
||||
*m_poolBlockTemplate = *b.m_poolBlockTemplate;
|
||||
m_finalReward = b.m_finalReward;
|
||||
m_nextPayout = b.m_nextPayout;
|
||||
|
||||
m_minerTx.clear();
|
||||
|
@ -414,6 +416,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
|||
return;
|
||||
}
|
||||
|
||||
m_finalReward = final_reward;
|
||||
m_nextPayout = 0;
|
||||
for (size_t i = 0, n = m_shares.size(); i < n; ++i) {
|
||||
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);
|
||||
|
||||
FORCEINLINE uint64_t final_reward() const { return m_finalReward; }
|
||||
FORCEINLINE uint64_t next_payout() const { return m_nextPayout; }
|
||||
|
||||
private:
|
||||
|
@ -95,6 +96,7 @@ private:
|
|||
|
||||
BlockTemplate* m_oldTemplates[4] = {};
|
||||
|
||||
uint64_t m_finalReward;
|
||||
uint64_t m_nextPayout;
|
||||
|
||||
// Temp vectors, will be cleaned up after use and skipped in copy constructor/assignment operators
|
||||
|
|
21
src/log.h
21
src/log.h
|
@ -308,16 +308,23 @@ 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" };
|
||||
|
||||
size_t k = 0;
|
||||
double magnitude = 1.0;
|
||||
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;
|
||||
double magnitude = 1.0;
|
||||
|
||||
while ((x >= magnitude * 1e3) && (k < array_size(units) - 1)) {
|
||||
magnitude *= 1e3;
|
||||
++k;
|
||||
while ((x >= magnitude * 1e3) && (k < array_size(units) - 1)) {
|
||||
magnitude *= 1e3;
|
||||
++k;
|
||||
}
|
||||
|
||||
n = snprintf(buf, sizeof(buf), "%.3f %s", x / magnitude, units[k]);
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
int n = snprintf(buf, sizeof(buf), "%.3f %s", x / magnitude, units[k]);
|
||||
if (n > 0) {
|
||||
if (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" <<
|
||||
"\nMain chain height = " << m_pool->block_template().height() <<
|
||||
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
|
||||
"\nSide chain height = " << tip_height + 1 <<
|
||||
"\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)"
|
||||
"\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