Um... don't we have buggy code still? Let me post what's in there right now:
int64 GetProofOfWorkReward( int nHeight, uint256 prevHash)
{
// microCoin block size.
int64 nSubsidy = 1 * COIN;
if(nHeight < 10000)
{
nSubsidy = 0.0001 * COIN; // Premining 1 coin. (10000 blocks * 0.0001 coins) = Total 1 coin. ** For network security purpose. (Needed with the fair launch).
}
else if(nHeight >= 10000 && nHeight < 160000) // Launch start. Increasing block size on every blocks +1. ** Blocks: 1001 - 160000
{
nSubsidy = nHeight * COIN;
}
else if (nHeight >= 310000 && nHeight <= 315000) // 310,000 block rewards, decreasing 0.01 on every block
{
nSubsidy = (310000 - ((nHeight - 310000) * 0.01)) * COIN;
}
else if (nHeight <= 318000) // 0.01 block rewards (wrong logic as coin spec, but we need to keep it because it's already happened)
{
nSubsidy = (3100 - ((nHeight * 0.01) - 310000)) - 300000;
}
else
{
nSubsidy = (10000 - ((nHeight - 318000) * 0.01)) * COIN;
if (nSubsidy <= 1000 * COIN) nSubsidy = 1000 * COIN; // Rest of blocks are 1000 coins. Then network working forever with stake blocks.
}
return nSubsidy;
}
It seems we're missing the case of the block number being 160000-310000 with rewards going from 160000 back to 10000. Doesn't that matter? Actually, right now blocks 160000-310000 would be in the category of <= 318000, which would mean blocks 160000-310000 and 315000-318000 would be worth the wrong values. Anyone grabbing a new wallet and downloading the block chain would get all sorts of problems, wouldn't they? If I'm reading that correctly and understand the code (which I may not!), then the correct code should be as follows (with a bit of modified formatting for readability because the indentations were off):
int64 GetProofOfWorkReward( int nHeight, uint256 prevHash)
{
// microCoin block reward amount.
int64 nSubsidy = 1 * COIN;
// Premining 1 coin. (10000 blocks * 0.0001 coins) = Total 1 coin. ** For network security purpose. (Needed with the fair launch).
if(nHeight < 10000)
{
nSubsidy = 0.0001 * COIN;
}
// Launch start. Increasing block size on every blocks +1. ** Blocks: 1001 - 160000
else if(nHeight >= 10000 && nHeight < 160000)
{
nSubsidy = nHeight * COIN;
}
// Count back down from 160K to 10K block rewards.
else if (nHeight >= 160000 && nHeight < 310000)
{
nSubsidy = (320000 - nHeight) * COIN;
}
// Erroneous 310,000-309,950 block rewards, decreasing 0.01 on every block (this already happened so we keep it)
else if (nHeight >= 310000 && nHeight <= 315000)
{
nSubsidy = (310000 - ((nHeight - 310000) * 0.01)) * COIN;
}
// Erroneous 0.01 block rewards (wrong logic again, but we need to keep it because it's already happened)
else if (nHeight <= 318000)
{
nSubsidy = (3100 - ((nHeight * 0.01) - 310000)) - 300000;
// NOTE: Seriously!? Who came up with this code as the "fix"? It's the same as:
// nSubsidy = 13100 - nHeight * 0.01;
// That's so utterly wrong and confusing to begin with, it's no wonder things broke.
}
// Rewards decrease from 10000 to 10000 in 0.01 steps; minimum reward is 1000 coins.
else
{
nSubsidy = (10000 - ((nHeight - 318000) * 0.01)) * COIN;
// The remaining blocks are 1000 coins each, with network continuing forever with stake blocks.
if (nSubsidy <= 1000 * COIN) nSubsidy = 1000 * COIN;
}
return nSubsidy;
}
This is insane, people. As someone that studied computer science 20 years back, I can't believe the sort of hack-job coding we're seeing. Let me give you some advise: properly commented code is important, and obfuscating code with behind-the-scenes math is a bad idea.
MRC donations for my awesome code (which will be worth squat very soon at this rate): 14LADSmN8FkX7kfsAkvgvmPH8ZGJUdABLV