MCPcopy Create free account
hub / github.com/ElementsProject/elements / CheckProofOfWork

Function CheckProofOfWork

src/pow.cpp:74–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
75{
76 bool fNegative;
77 bool fOverflow;
78 arith_uint256 bnTarget;
79
80 bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
81
82 // Check range
83 if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit))
84 return false;
85
86 // Check proof of work matches claimed amount
87 if (UintToArith256(hash) > bnTarget)
88 return false;
89
90 return true;
91}

Callers 12

CheckProofFunction · 0.85
CreateBlockMethod · 0.85
BuildBlockTestCaseFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FinalizeBlockMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
CreateBlockChainFunction · 0.85
MineBlockFunction · 0.85
CreateBlockMethod · 0.85
GenerateBlockFunction · 0.85

Calls 1

UintToArith256Function · 0.85

Tested by 10

CreateBlockMethod · 0.68
BuildBlockTestCaseFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
FinalizeBlockMethod · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68
CreateBlockChainFunction · 0.68
MineBlockFunction · 0.68
CreateBlockMethod · 0.68