Where is the nonce incremented in Bitcoin source code?

0

Where is the nonce incremented in Bitcoin source code? I found where the extra nonce is incremented, but not the regular nonce?

newbie newbie

Posted 2017-11-11T05:03:51.943

Reputation: 1

Answers

1

Line 132 in src/mining.cpp in the generateBlocks method.

while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus())) {
    ++pblock->nNonce;
    --nMaxTries;
}

Update: Given @MeshCollider's answer I guess this is now only relevant on the regtest network.

sipwiz

Posted 2017-11-11T05:03:51.943

Reputation: 685

Oh yes, there is still a miner for regtest, forgot about that :)MeshCollider 2017-11-11T06:37:00.367

0

The internal miner was removed from Bitcoin Core in version 0.13.0, in this PR: https://github.com/bitcoin/bitcoin/pull/7507

It used to be incremented in ScanHash(), but as of the removal, there is nowhere which increments the nonce, that would be done by mining software.

MeshCollider

Posted 2017-11-11T05:03:51.943

Reputation: 8 735