I love this:

//

// Search

//

uint256 hashTarget = (~uint256(0) >> pblock->nBits);

uint256 hash;

while (nTransactionsUpdated == nTransactionsUpdatedLast)

{

BlockSHA256(&tmp.block, nBlocks0, &tmp.hash1);

BlockSHA256(&tmp.hash1, nBlocks1, &hash);

if (hash <= hashTarget)

{

pblock->nNonce = tmp.block.nNonce;

assert(hash == pblock->GetHash());

//// debug print

printf("BitcoinMiner:\n");

printf("supercoin found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());

pblock->print();

// Process this block the same as if we had received it from another node

if (!ProcessBlock(NULL, pblock.release()))

printf("ERROR in BitcoinMiner, ProcessBlock, block not accepted\n");

break;

}

// Update nTime every few seconds

if ((++tmp.block.nNonce & 0xfffff) == 0)

{

if (tmp.block.nNonce == 0)

break;

tmp.block.nTime = pblock->nTime = max(blockPrev.nTime+1, (unsigned int)GetAdjustedTime());

}

}

Reply to this note

Please Login to reply.

Discussion

No replies yet.