From b3b594039d97cf58e58b3800e22f104ad7d190aa Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 10 Jan 2014 18:38:44 -0700 Subject: [PATCH] added nouce calculation --- src/main.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9f70191c1a..fae601b53b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ CTxMemPool mempool; unsigned int nTransactionsUpdated = 0; map mapBlockIndex; -uint256 hashGenesisBlock("0x61a8e2e4a21ff79a135f0928e958ef3e9d8031f52a977ac0f49cfd9cecb33cf6"); +uint256 hashGenesisBlock("0xa8f2c5db0ff04ecc771dc58964473b5d565902628b05b13130f157dab27701ba"); static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // Xcoin: starting difficulty is 1 / 2^12 CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; @@ -2770,7 +2770,7 @@ bool InitBlockIndex() { block.nVersion = 1; block.nTime = 1389401959; block.nBits = 0x1e0ffff0; - block.nNonce = 1084524493; + block.nNonce = 17355177984; if (fTestNet) { @@ -2778,6 +2778,36 @@ bool InitBlockIndex() { block.nNonce = 385270584; } + 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()); + } + //// debug print uint256 hash = block.GetHash(); printf("%s\n", hash.ToString().c_str());