If a node observes a fork in the bitcoin chain, then the node will choose the chain that has the highest difficulty (sum of difficulty in each block of the chain).

But the difficulty changes only once every 2016 blocks. So, if a fork occurs somewhere in between, then the difficulty is the same for both the side chains right? How does the node pick the main chain then? Just randomly?

1 Answer 1

  1. It only considers valid chains. If either chain has an invalid block in it, it is excluded from consideration.
  2. If the chainwork (sum of the inverses of the targets of the blocks in the chain, approximately proportional to the sum of the difficulties) differs, chains with less than the maximum chainwork are excluded from consideration.
  3. If there are still multiple candidates, the one whose full block data of the tip was received first is considered active.
  • Thanks a lot for the wonderful answer. Suppose a node receives a block and observes there's a fork. The node determines the main chain as per the above logic. After that, will the node propagate the blocks in the non-main chain to its peers?
    – satya
    Jul 21, 2021 at 23:08
  • 1
    No, it won't. Only the active chain is relayed. Jul 21, 2021 at 23:40

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.