I just checked the code and the rewards look good. I can see there is a max reward of 2662 coins hard coded so I know we're good there. The only part I don't understand is how the reward calculation works and why were they set up that way? I mean this is kinda crazy right:
int64_t GetBlockValue(int nBits, int nHeight, int64_t nFees)
{
double dDiff = (double)0x0000ffff (double)(nBits & 0x00ffffff);
/* fixed bug caused diff to not be correctly calculated */
if(nHeight > 3 || TestNet()) dDiff = ConvertBitsToDouble(nBits);
int64_t nSubsidy = 0;
/ if(nHeight >= 5465) {
/ if((nHeight >= 17000 && dDiff > 75) || nHeight >= 24000)
{/ GPU/ASIC difficulty calc
// 222222222/(((x+2600)/9)^2)
nSubsidy = (222222222.0 (pow((dDiff+2600.0)/9.0,2.0)));
if (nSubsidy > 2662) nSubsidy = 2662;
if (nSubsidy < 1) nSubsidy = 1;
}/else {/ CPU mining calc
/ nSubsidy = (11111.0 (pow((dDiff+51.0)/6.0,2.0)));
// if (nSubsidy > 500) nSubsidy = 500;
/ if (nSubsidy < 25) nSubsidy = 25;
/ }
/ } else {
// nSubsidy = (1111.0 (pow((dDiff+1.0),2.0)));
// if (nSubsidy > 500) nSubsidy = 500;
// if (nSubsidy < 1) nSubsidy = 1;
// }
// LogPrintf("height %u diff %4.2f reward %i \n", nHeight, dDiff, nSubsidy);
nSubsidy *= COIN;
if(TestNet()){
for(int i = 46200; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
} else {
// yearly decline of production by 7.1% per year, projected 21.3M coins max by year 2050.
for(int i = 210240; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
}
return nSubsidy + nFees;
}
Again, code looks good nothing malicious (although I did not do a thorough check elsewhere in the code). I would just like a simple explanation of how that calculation works when you have time. I assume its something like if the diff is high there are either more or less rewards given? It seems right now the blocks are consistently close to the max. Thanks
The block reward are based on 222222222/(((diff+2600)/9)^2) where diff is from the previous block
If you look at block
13813 the diff is 12.84847464
Then you run 222222222/(((12,84847464+2600)/9)^2) and the result is 2636.59883177 so the next block reward should be 2636
And the block reward on
13814 is 2636.
Then if you look at block
7669 the diff was 480.96324752
222222222/(((480,96324752+2600)/9)^2) = 1896.26692151
So at block
7670 the reward was only 1896