When generating a new block, how is the nbits field in block header calculated? Is nbits calculated for every new block like:

nbits=nbits of last block * (timstamp of lastblock-timestamp of (lastblocknum-2016))/20160 

Or, nbits is only updated every 2016 blocks like:

    nbits=nbits of last block * (timstamp of lastblock-timestamp of (lastblocknum-2016))/20160 
    nbits=nbits of lastblock

And when a node receives a new block, it will calculate the correct nbits itself for the new block (instead of using the nbits in the received block) before verifying the hash result, right?

I have not read the source code of bitcoin, and am confused by the introduction of nbits in some books.

1 Answer 1


Difficulty is only recalculated/updated once every 2016 blocks. The node itself should only calculate the difficulty once every 2016 blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.