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

Function DigishieldGetNextWorkRequired

src/pow.cpp:124–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124unsigned int DigishieldGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock,
125 const Consensus::Params& params)
126{
127 assert(pindexLast != nullptr);
128 unsigned int nProofOfWorkLimit = UintToArith256(params.PowLimit(true)).GetCompact(); // Always postfork.
129
130 const CBlockIndex* pindexFirst = pindexLast;
131 arith_uint256 bnTot {0};
132 for (int i = 0; pindexFirst && i < params.nDigishieldAveragingWindow; i++) {
133 arith_uint256 bnTmp;
134 bnTmp.SetCompact(pindexFirst->nBits);
135 bnTot += bnTmp;
136 pindexFirst = pindexFirst->pprev;
137 }
138
139 if (pindexFirst == NULL)
140 return nProofOfWorkLimit;
141
142 arith_uint256 bnAvg {bnTot / params.nDigishieldAveragingWindow};
143 return DigishieldCalculateNextWorkRequired(bnAvg, pindexLast, pindexFirst, params);
144}
145
146unsigned int DigishieldCalculateNextWorkRequired(arith_uint256 bnAvg, const CBlockIndex* pindexLast, const CBlockIndex* pindexFirst, const Consensus::Params& params)
147{

Callers 1

GetNextWorkRequiredFunction · 0.85

Calls 3

UintToArith256Function · 0.85
GetCompactMethod · 0.80

Tested by

no test coverage detected