Is it only the block height or is it the effort that went into the forks? In other words: does this decision account for different difficulties?

up vote 22 down vote accepted

Gary's answer is not entirely correct. When comparing two chains, their total "scores" are compared. Each block counts as (2^256 / block_target); this is the expected/average number of attempts that were necessary to create it.

Obviously, within one series of 2016 blocks, the difficulties are all equal, so for most small reorganizations, the score will tell you the same thing as just counting the number of blocks. However, as an attacker may well try to rewrite blocks that cross the multiple-of-2016-boundary, you need to take this into account. The actual rule always favors the chains which required the most "work".

  • Thanks Peter. I was confused as I initially read your answer as "this is the expected divided by average..." That is a minor point tho. Your answer seems to be at odds with @NickOdells answer here:…, which claims there is not a score, but a series of rules set out in CBlockIndexWorkComparator. – Alex Millar Mar 6 '17 at 1:09
  • This answer only elaborates on the first criterion in CBlockIndexWorkComparator. The others are just for tie-breaking. – Pieter Wuille Jan 3 at 11:01
  • Why isn't the block hash used to calculate work done? – JBaczuk Aug 28 at 14:43
  • 1
    @JBaczuk Because among the set of acceptable hashes, every hash is equally likely. Counting some as more than others would simply introduce additional variance (where one branch, without merit, randomly would count more than another). The only practical effect would be seeing far more forks, and needing more confirmations to be sure a transaction made it in. – Pieter Wuille Aug 28 at 15:13

According to the Satoshi paper, the following applies:

The steps to run the network are as follows:

1) New transactions are broadcast to all nodes.

2) Each node collects new transactions into a block.

3) Each node works on finding a difficult proof-of-work for its block.

4) When a node finds a proof-of-work, it broadcasts the block to all nodes.

5) Nodes accept the block only if all transactions in it are valid and not already spent.

6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proofof- work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one.

That pretty much sums it up. If you have more valid blocks, you win until someone comes along with more valid blocks.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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