From 7441b02aff1958badde344c32497ab3ab39cc986 Mon Sep 17 00:00:00 2001 From: Matt Hess Date: Wed, 17 Dec 2025 05:28:30 +0000 Subject: [PATCH] added donation state tracking, proper entering and exiting message, every 720 blocks on mainchain or 0.139% --- src/block_template.cpp | 9 ++++++++- src/block_template.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/block_template.cpp b/src/block_template.cpp index 9de1222..99dd59f 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -55,6 +55,7 @@ BlockTemplate::BlockTemplate(SideChain* sidechain, RandomX_Hasher_Base* hasher) , m_auxDifficulty{} , m_seedHash{} , m_timestamp(0) + , m_lastWasDonation(false) , m_poolBlockTemplate(new PoolBlock()) , m_finalReward(0) , m_minerTxKeccakState{} @@ -138,6 +139,7 @@ BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b) m_auxDifficulty = b.m_auxDifficulty; m_seedHash = b.m_seedHash; m_timestamp = b.m_timestamp; + m_lastWasDonation = b.m_lastWasDonation; *m_poolBlockTemplate = *b.m_poolBlockTemplate; m_finalReward = b.m_finalReward.load(); @@ -297,7 +299,12 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const } m_shares.clear(); m_shares.emplace_back(total_weight, ¶ms->m_devWallet); - LOGINFO(4, "Donation mode: entire block reward goes to dev wallet"); + LOGINFO(3, "Entering donation mode at height " << data.height << ": share reward is donated to developer"); + m_lastWasDonation = true; + } + else if (m_lastWasDonation) { + LOGINFO(3, "Exiting donation mode at height " << data.height << ": resuming normal mining"); + m_lastWasDonation = false; } // Pre-calculate outputs to speed up miner tx generation diff --git a/src/block_template.h b/src/block_template.h index a5d2392..65e797b 100644 --- a/src/block_template.h +++ b/src/block_template.h @@ -109,6 +109,8 @@ private: uint64_t m_timestamp; + bool m_lastWasDonation; + PoolBlock* m_poolBlockTemplate; #ifdef P2POOL_UNIT_TESTS