From a745563d283cd7917661caef93b3ce853eeae542 Mon Sep 17 00:00:00 2001 From: Capri Date: Sat, 12 Sep 2026 21:00:26 +0000 Subject: [PATCH] Restore per-algo block lookup helper --- src/pow.cpp | 17 +++++++++++++++++ src/pow.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/pow.cpp b/src/pow.cpp index 228696b..2625f0d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -196,6 +196,23 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead return bnNew.GetCompact(); } +const CBlockIndex* GetLastBlockIndexForAlgoFast(const CBlockIndex* pindex, int algo) +{ + if (algo < 0 || algo >= NUM_ALGOS_IMPL) { + return nullptr; + } + + while (pindex) { + if (pindex->GetAlgo() == algo) { + return pindex; + } + + pindex = pindex->lastAlgoBlocks[algo]; + } + + return nullptr; +} + bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { bool fNegative; diff --git a/src/pow.h b/src/pow.h index ffa5bbd..fc92de0 100644 --- a/src/pow.h +++ b/src/pow.h @@ -20,5 +20,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&); +const CBlockIndex* GetLastBlockIndexForAlgoFast(const CBlockIndex* pindex, int algo); #endif // DIGIBYTE_POW_H