<ol>
<li>It only considers valid chains. If either chain has an invalid block in it, it is excluded from consideration.</li>
<li>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.</li>
<li>If there are still multiple candidates, the one whose full block data of the tip was received first is considered active.</li>
</ol>

CC BY-SA 4.0
2021-07-21T23:08:55.100Z
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
CC BY-SA 4.0
2021-07-21T23:40:47.360Z
No, it won't. Only the active chain is relayed.
Pieter Wuille
CC BY-SA 4.0
2021-07-21T22:51:52.200Z
2021-07-21T22:51:52.200Z
Pieter Wuille
<p>If a node observes a fork in the bitcoin chain, then the node will choose the chain that has the highest difficulty (sum of <code>difficulty</code> in each block of the chain).</p>
<p>But the <code>difficulty</code> changes only once every 2016 blocks. So, if a fork occurs somewhere in between, then the <code>difficulty</code> is the same for both the side chains right? How does the node pick the main chain then? Just randomly?</p>

<blockchain-fork><difficulty>
Choosing main chain based on difficulty
satya
# Choosing main chain based on difficulty

(Asked by: username_0 on 2021-07-21)

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?

**Tags:** blockchain-fork, difficulty


---

## 1 answers

### Answer by username_1 on 2021-07-21. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: No, it won't. Only the active chain is relayed.  

---

