Bitcoin ABC
0.24.11
P2P Digital Currency

Go to the source code of this file.
Functions  
static arith_uint256  ComputeTarget (const CBlockIndex *pindexFirst, const CBlockIndex *pindexLast, const Consensus::Params ¶ms) 
Compute a target based on the work done between 2 blocks and the time required to produce that work. More...  
static const CBlockIndex *  GetSuitableBlock (const CBlockIndex *pindex) 
To reduce the impact of timestamp manipulation, we select the block we are basing our computation on via a median of 3. More...  
uint32_t  GetNextDAAWorkRequired (const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params ¶ms) 
Compute the next required proof of work using a weighted average of the estimated hashrate per block. More...  

static 
Compute a target based on the work done between 2 blocks and the time required to produce that work.
From the total work done and the time it took to produce that much work, we can deduce how much work we expect to be produced in the targeted time between blocks.
We need to compute T = (2^256 / W)  1 but 2^256 doesn't fit in 256 bits. By expressing 1 as W / W, we get (2^256  W) / W, and we can compute 2^256  W as the complement of W.
Definition at line 15 of file daa.cpp.
uint32_t GetNextDAAWorkRequired  (  const CBlockIndex *  pindexPrev, 
const CBlockHeader *  pblock,  
const Consensus::Params &  params  
) 
Compute the next required proof of work using a weighted average of the estimated hashrate per block.
Using a weighted average ensure that the timestamp parameter cancels out in most of the calculation  except for the timestamp of the first and last block. Because timestamps are the least trustworthy information we have as input, this ensures the algorithm is more resistant to malicious inputs.
Definition at line 91 of file daa.cpp.

static 
To reduce the impact of timestamp manipulation, we select the block we are basing our computation on via a median of 3.
In order to avoid a block with a very skewed timestamp having too much influence, we select the median of the 3 top most blocks as a starting point.
Definition at line 52 of file daa.cpp.