3
The next difficulty to solve a block is determined from how fast blocks were solved before it. In addition, the difficulty only changes once every two weeks or so.
So, couldn't every node keep track of the expected difficulty and not need to have it in each block header? Or is there a reason nodes need to be communicating the current difficulty in each block? Not that it would be a major savings, or anything, it just seems strange that this is included when it's just a function of all the other pieces of a chain.
Maybe it's because calculating nBits would take a long time eventually if you had to go through all the block headers every time you wanted to calculate the next difficulty?
so there's technically not much need to store past headersWhat about unconfirmed transactions? You need to look into past blocks to confirm that their inputs are valid. – Nick ODell – 2014-12-23T22:16:19.667An essential part of verifying inputs are valid is ensuring that the input (previous output) hasn't been spent yet on the block chain. SPV clients are incapable of doing that since they don't process the complete block chain. SPV clients can only verify the unspentness of inputs for which they control the private keys (wallet transactions), so they're completely dependent on their full node peers for information about unconfirmed non-wallet transactions---if all their peers lie, the SPV client can be fooled. – David A. Harding – 2014-12-23T23:08:58.833
Added a new paragraph to my answer describing how a partial headers chain can be superior security to not storing a headers chain, and why this still means nBits is useful. – David A. Harding – 2014-12-23T23:17:21.963
doc says a spv client downloads the headers of blocks, but not full blocks; if they download block headers then they can calculate difficulty by themselves; i still dont see why it should be included as a block header field; and nothing mentions how to validate that field; – Cyker – 2018-11-07T17:58:01.183
A small update: for clients that follow headers-first synchronization (introduced in Bitcoin Core 0.10), the
nBitsvalue in headers isn't actually useful anymore (it's always known before a header or block is received already). – Pieter Wuille – 2018-11-08T09:09:29.440