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?

2 Answers 2


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: bitcoin.stackexchange.com/questions/37273/…, which claims there is not a score, but a series of rules set out in CBlockIndexWorkComparator. Commented Mar 6, 2017 at 1:09
  • This answer only elaborates on the first criterion in CBlockIndexWorkComparator. The others are just for tie-breaking. Commented Jan 3, 2018 at 11:01
  • Why isn't the block hash used to calculate work done?
    – JBaczuk
    Commented Aug 28, 2018 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. Commented Aug 28, 2018 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.

  • 2
    This is what the paper said and this is what the original Satoshi code did, but this is no longer correct. If you always pick the longest chain then there are some relatively easy attacks that work by making long and easy chains. In 2016 the bitcoin core code switched to using the "most work" chain, which is not necessarily the longest. Here is the commit... github.com/bitcoin/bitcoin/commit/…
    – bigjosh
    Commented Jan 23, 2021 at 0:48

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.