How does the difficulty target affect the time to complete the block? So, I'm currently doing a personal project where I'm creating my own crypto blockchain (just for fun). I'm currently coding the Difficulty Target part of the Blockchain, but I'm not entirely sure how the difficulty part affects the process for completing the block? I know that with Bitcoin, the difficulty adjusts every 2016 blocks based on how long it took to complete the 2016 blocks, but what is the difficulty applied to and how does it make subsequent blocks harder/easier to complete?
Thanks.
Have you read this? It is sort of technical, and goes into How is difficulty calculated? and How is difficulty stored in blocks?
https://en.bitcoin.it/wiki/Difficulty
re your comment about nonces: The nonce is not the difficulty. In the example below, I'm trying to find a sha256 that starts with 0. On my imaginary blockchain, a proof-of-work that starts with a single 0 is good enough. Notice that I don't change anything but the number after foo. The number after foo can be thought of as the nonce. It's just some thing I change to get a new proof-of-work.
[I] ➜  ~ echo -n &quot;foo&quot; | shasum -a 256
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -
[I] ➜  ~ echo -n &quot;foo1&quot; | shasum -a 256
bb4eca334f61af3b67b5d528907d30285151610200539302f4c8cabe66225b53  -
[I] ➜  ~ echo -n &quot;foo2&quot; | shasum -a 256
4963bd713a7eb1bce458868b0c8472bdc8bc5929a7892a92dd24344aea92093d  -
[I] ➜  ~ echo -n &quot;foo19&quot; | shasum -a 256
06651ba147df6422edcd47690fd3d68795bc59636f37f10b67a94fa70fe1fdbb  - yay

Compare that with miners on the bitcoin blockchain. Currently they have to find a sha256 hash that starts with 19 0's. e.g: 00000000000000000006d31a10b4190a8f86c93189debe87a4d1fff54fbd5b23