Introduce g_fuzzing global for fuzzing checks

This commit is contained in:
dergoegge
2024-10-15 12:10:36 +01:00
parent b95adf057a
commit 9f243cd7fa
5 changed files with 9 additions and 10 deletions

View File

@@ -9,6 +9,7 @@
#include <chain.h>
#include <primitives/block.h>
#include <uint256.h>
#include <util/check.h>
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
{
@@ -138,11 +139,8 @@ bool PermittedDifficultyTransition(const Consensus::Params& params, int64_t heig
// the most signficant bit of the last byte of the hash is set.
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
{
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return (hash.data()[31] & 0x80) == 0;
#else
if (g_fuzzing) return (hash.data()[31] & 0x80) == 0;
return CheckProofOfWorkImpl(hash, nBits, params);
#endif
}
bool CheckProofOfWorkImpl(uint256 hash, unsigned int nBits, const Consensus::Params& params)