Last active
January 3, 2016 11:29
-
-
Save somegeekintn/8456847 to your computer and use it in GitHub Desktop.
Proposal for new dogecoin GetBlockValue function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kSubsidyRange 1220703125 | |
#define kMinSubsidy 1000 | |
#define SUBSIDY_METHOD 1 | |
int64 static GetBlockValue(int nHeight, int64 nFees, uint256 prevHash) | |
{ | |
std::string cseed_str = prevHash.ToString().substr(7,7); | |
const char *cseed = cseed_str.c_str(); | |
long seed = hex2long(cseed); | |
int64 nSubsidy; | |
if (nHeight < 200000) { | |
int rand = generateMTRandom(seed, 999999); | |
if (nHeight < 100000) { | |
nSubsidy = (1 + rand) * COIN; | |
} | |
else { | |
rand = generateMTRandom(seed, 499999); | |
nSubsidy = (1 + rand) * COIN; | |
} | |
nSubsidy += nFees; | |
} | |
else { | |
int64 rand64 = generateMTRandom(seed, kSubsidyRange); | |
int shiftAmount = (nHeight - 200000) / 200000; | |
rand64 <<= 14; // range: 0.00016384 to 200000.00000000 | |
rand64 >>= shiftAmount; | |
nSubsidy = rand64; | |
nSubsidy += nFees; | |
#if SUBSIDY_METHOD | |
if (nSubsidy < kMinSubsidy) | |
nSubsidy = kMinSubsidy; | |
#else | |
nSubsidy += kMinSubsidy; | |
#endif | |
} | |
return nSubsidy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment