From ff34abe6c599f40b06a95d2ecc0f95055a6c0d7c Mon Sep 17 00:00:00 2001 From: Capri Date: Sat, 12 Sep 2026 21:47:08 +0000 Subject: [PATCH] Make block template algorithm-aware --- src/miner.cpp | 5 +++-- src/miner.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 83bf383..e6be985 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void BlockAssembler::resetBlock() nFees = 0; } -std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn) +std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, int algo) { int64_t nTimeStart = GetTimeMicros(); @@ -171,8 +171,9 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); + pblock->SetAlgo(algo); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus(), ALGO_SHA256D); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus(), algo); pblock->nNonce = 0; pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]); diff --git a/src/miner.h b/src/miner.h index 6a0ec2e..465ce2b 100644 --- a/src/miner.h +++ b/src/miner.h @@ -160,7 +160,7 @@ public: explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const CChainParams& params, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn */ - std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn); + std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn, int algo = ALGO_SHA256D); inline static std::optional m_last_block_num_txs{}; inline static std::optional m_last_block_weight{};