Restore per-algo block lookup helper

This commit is contained in:
Capri 2026-09-12 21:00:26 +00:00
commit a745563d28
Signed by: VextaProject
SSH key fingerprint: SHA256:739BZv8LvIDY2tR7lXLy/IQ6MaGTQtYcG9GNvCjmpVM
2 changed files with 18 additions and 0 deletions

View file

@ -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;

View file

@ -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