3 ms·
How does the network raise the difficulty? How do the nodes agree on a "next difficulty". It's somewhat surprising to me that the next difficulty level isn't a
by acchow 13y ago
How does the network raise the difficulty? How do the nodes agree on a "next difficulty".
It's somewhat surprising to me that the next difficulty level isn't an input the hash function. H(B, random number, next difficulty level).
Edit: How does the network agree on clock? How does it handle rogues?
- jadeddrag 13y agoSince the difficulty is the proportion to the amount of time over or under two weeks the previous 2016 blocks took to find, it's a deterministic calculation that other nodes use to accept and validate each new block. And since it's in the best interest of nodes to keep the longest chain of blocks, it's not in their interest to break this rule. (or they will end up on an abandoned blockchain fork)
- oleganza 13y agoEach block has a timestamp. Each 2016 blocks difficulty is adjusted so that next 2016 blocks are produced closer to 10 minute interval between the blocks. Nodes do not tolerate timestamps 2 hours in the future relative to their own timestamps: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2039 https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#... Since difficulty is adjusted based on a simple median, if the hashrate is always growing (like for the past 8 months), average time between blocks is always below the target 10 minutes (it was around 7-8 minutes on average).
- jiggy2011 13y agoBy looking at how long it took to mine the last set of blocks. The rate is supposed to be 1 block per 10 minutes so you can estimate the hashing power of the network by looking at the time taken to solve the last X blocks. If it's too fast, difficulty goes up, too slow and it goes down. The nodes can "agree" without needing to communicate , because they all use the same formula (and share the blockchain) they should all agree on the same answer for what the difficulty of the next set of blocks should be.
- maaku 13y agoThe difficulty is in the block header, B.