hmm, i may start digging into this
maybe create my own maxcoin clone to test it? on a lan only environment
just need to sift through the src folder and see what things do
EDIT:ok then so the gensis block code is pretty simple
main.cppuint256 hashGenesisBlock("0x0000002d0f86558a6e737a3a351043ee73906fe077692dfaa3c9328aaca21964");
static const unsigned int timeGenesisBlock = 1390822264;
static const unsigned int nNonceGenesisBlock = 11548217;
so you have to generate a random hash for the genesis block for release, enter it, enter the starting time of the coin
for the above the launch time is 1/27/2014 11:31:04 AM GMT+0
unsure on the Nonce yet
maximum coin number is easy aswell
main.hstatic const int64 MAX_MONEY = 250000000 * COIN; // 250 million
main.cppstatic const int64 nBlockRewardStartCoin = 96 * COIN;
static const int64 nTargetSpacing = 30; // 30 seconds
nSubsidy >>= (nHeight / 1051200);
time between blocks and block reward, easily changed
and also how often the reward should halve
doesnt seem to hard to change the algorithm
hash.hinline uint256 HashKeccak(const T1 pbegin, const T1 pend)
{
sph_keccak256_context ctx_keccak;
static unsigned char pblank[1];
uint256 hash;
sph_keccak256_init(&ctx_keccak);
sph_keccak256 (&ctx_keccak, (pbegin == pend ? pblank : static_cast(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
sph_keccak256_close(&ctx_keccak, static_cast(&hash));
return hash;
}
hashRand = HashKeccak(BEGIN(hashRand), END(hashRand));
Heres the code for the difficulty calculations, in this case the Kimoto Gravity Well
unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBlockHeader *pblock, uint64 TargetBlocksSpacingSeconds, uint64 PastBlocksMin, uint64 PastBlocksMax) {
/* current difficulty formula, megacoin - kimoto gravity well */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
const CBlockHeader *BlockCreating = pblock;
BlockCreating = BlockCreating;
uint64 PastBlocksMass = 0;
int64 PastRateActualSeconds = 0;
int64 PastRateTargetSeconds = 0;
double PastRateAdjustmentRatio = double(1);
CBigNum PastDifficultyAverage;
CBigNum PastDifficultyAveragePrev;
double EventHorizonDeviation;
double EventHorizonDeviationFast;
double EventHorizonDeviationSlow;
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || (uint64)BlockLastSolved->nHeight < PastBlocksMin) { return bnProofOfWorkLimit.GetCompact(); }
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
if (PastBlocksMax > 0 && i > PastBlocksMax) { break; }
PastBlocksMass++;
if (i == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); }
else { PastDifficultyAverage = ((CBigNum().SetCompact(BlockReading->nBits) - PastDifficultyAveragePrev) / i) + PastDifficultyAveragePrev; }
PastDifficultyAveragePrev = PastDifficultyAverage;
PastRateActualSeconds = BlockLastSolved->GetBlockTime() - BlockReading->GetBlockTime();
PastRateTargetSeconds = TargetBlocksSpacingSeconds * PastBlocksMass;
PastRateAdjustmentRatio = double(1);
if (PastRateActualSeconds < 0) { PastRateActualSeconds = 0; }
if (PastRateActualSeconds != 0 && PastRateTargetSeconds != 0) {
PastRateAdjustmentRatio = double(PastRateTargetSeconds) / double(PastRateActualSeconds);
}
EventHorizonDeviation = 1 + (0.7084 * pow((double(PastBlocksMass)/double(28.2)), -1.228));
EventHorizonDeviationFast = EventHorizonDeviation;
EventHorizonDeviationSlow = 1 / EventHorizonDeviation;
if (PastBlocksMass >= PastBlocksMin) {
if ((PastRateAdjustmentRatio <= EventHorizonDeviationSlow) || (PastRateAdjustmentRatio >= EventHorizonDeviationFast)) { assert(BlockReading); break; }
}
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
BlockReading = BlockReading->pprev;
}
CBigNum bnNew(PastDifficultyAverage);
if (PastRateActualSeconds != 0 && PastRateTargetSeconds != 0) {
bnNew *= PastRateActualSeconds;
bnNew /= PastRateTargetSeconds;
}
if (bnNew > bnProofOfWorkLimit) { bnNew = bnProofOfWorkLimit; }
return bnNew.GetCompact();
}