From 63e442dffdf6437a9f4931b6b00eea8b8cf7446f Mon Sep 17 00:00:00 2001 From: SChernykh Date: Wed, 25 Aug 2021 18:52:09 +0200 Subject: [PATCH] print_status: fixed next payout display --- src/block_template.cpp | 9 --------- src/block_template.h | 2 -- src/side_chain.cpp | 14 +++++++++++++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/block_template.cpp b/src/block_template.cpp index fb1aa9a..e6ec746 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -52,7 +52,6 @@ BlockTemplate::BlockTemplate(p2pool* pool) , m_timestamp(0) , m_poolBlockTemplate(new PoolBlock()) , m_finalReward(0) - , m_nextPayout(0) { uv_rwlock_init_checked(&m_lock); @@ -123,7 +122,6 @@ BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b) m_txkeySec = b.m_txkeySec; *m_poolBlockTemplate = *b.m_poolBlockTemplate; m_finalReward = b.m_finalReward; - m_nextPayout = b.m_nextPayout; m_minerTx.clear(); m_blockHeader.clear(); @@ -417,13 +415,6 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet } 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) { - m_nextPayout = m_rewards[i]; - break; - } - } if (!create_miner_tx(data, m_shares, max_reward_amounts_weight, false)) { return; diff --git a/src/block_template.h b/src/block_template.h index 1a8f890..730d0c2 100644 --- a/src/block_template.h +++ b/src/block_template.h @@ -55,7 +55,6 @@ 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: p2pool* m_pool; @@ -97,7 +96,6 @@ 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 std::vector m_minerTx; diff --git a/src/side_chain.cpp b/src/side_chain.cpp index 19f4bfb..bbe0b6d 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -616,7 +616,19 @@ 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 next_payout = 0; + if (m_chainTip) { + Wallet w = m_pool->params().m_wallet; + hash eph_public_key; + for (size_t i = 0, n = m_chainTip->m_outputs.size(); i < n; ++i) { + w.get_eph_public_key(m_chainTip->m_txkeySec, i, eph_public_key); + if (m_chainTip->m_outputs[i].m_ephPublicKey == eph_public_key) { + next_payout = m_chainTip->m_outputs[i].m_reward; + break; + } + } + } uint64_t product[2]; product[0] = umul128(pool_hashrate, next_payout, &product[1]);