Permalink
Browse files

Add ability to generate genesis block.

Add ability to generate genesis block.
  • Loading branch information...
HowToCloneAnAltcoin
HowToCloneAnAltcoin committed Nov 6, 2014
1 parent 92e520e commit 8b2e543c6f9c6dde0ebb8a7b73fd06c6d7de18ec
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/main.cpp
View
@@ -2818,6 +2818,36 @@ bool InitBlockIndex() {
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", block.hashMerkleRoot.ToString().c_str());
assert(block.hashMerkleRoot == uint256("0x"));
if (true && block.GetHash() != hashGenesisBlock)
{
printf("Searching for genesis block...\n");
// This will figure out a valid hash and Nonce if you're
// creating a different genesis block:
uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
uint256 thash;
char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
loop
{
scrypt_1024_1_1_256_sp(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
if (thash <= hashTarget)
break;
if ((block.nNonce & 0xFFF) == 0)
{
printf("nonce %08X: hash = %s (target = %s)\n", block.nNonce, thash.ToString().c_str(), hashTarget.ToString().c_str());
}
++block.nNonce;
if (block.nNonce == 0)
{
printf("NONCE WRAPPED, incrementing time\n");
++block.nTime;
}
}
printf("block.nTime = %u \n", block.nTime);
printf("block.nNonce = %u \n", block.nNonce);
printf("block.GetHash = %s\n", block.GetHash().ToString().c_str());
}
block.print();
assert(hash == hashGenesisBlock);

0 comments on commit 8b2e543

Please sign in to comment.