MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / BitcoinCalculateNextWorkRequired

Function BitcoinCalculateNextWorkRequired

src/pow.cpp:220–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220unsigned int BitcoinCalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
221{
222 if (params.fPowNoRetargeting)
223 return pindexLast->nBits;
224
225 // Limit adjustment step
226 int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
227 if (nActualTimespan < params.nPowTargetTimespanLegacy/4)
228 nActualTimespan = params.nPowTargetTimespanLegacy/4;
229 if (nActualTimespan > params.nPowTargetTimespanLegacy*4)
230 nActualTimespan = params.nPowTargetTimespanLegacy*4;
231
232 // Retarget
233 const arith_uint256 bnPowLimit = UintToArith256(params.PowLimit(false));
234 arith_uint256 bnNew;
235 bnNew.SetCompact(pindexLast->nBits);
236 bnNew *= nActualTimespan;
237 bnNew /= params.nPowTargetTimespanLegacy;
238
239 if (bnNew > bnPowLimit)
240 bnNew = bnPowLimit;
241
242 return bnNew.GetCompact();
243}
244
245bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& params)
246{

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 3

UintToArith256Function · 0.85
GetCompactMethod · 0.80
GetBlockTimeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68