<blockquote>
<p>When my node realizes that the given block needs to be abandoned - does it leave it in the database or replace the block with a valid one?</p>
</blockquote>
<p>It remains on disk along with its entry in the block index database.</p>
<blockquote>
<p>And if &quot;invalid&quot; block remains: is it somehow marked as invalid?</p>
</blockquote>
<p>Yes. The block index database contains an entry for each block which contains flags that indicate the state of the block. This includes various states of validity and invalidity (that indicate where it passed or failed certain checks).</p>
<blockquote>
<p>If I meet two blocks with the same parent in the blockchain - how could I know which branch should I follow?</p>
</blockquote>
<p>Your node will follow the valid chain with the most cumulative work. At a given difficulty, this is the longest chain, but that is not always the case. If there are two blocks that have the same cumulative work, the node chooses the one it saw first. Eventually there will be a resolution as one of those blocks will be mined on and so have a greater cumulative work.</p>

CC BY-SA 4.0
2022-06-20T03:07:18.543Z
2022-06-20T03:07:18.543Z
Ava Chow
<p>When my node realizes that the given block needs to be abandoned - does it leave it in the database or replace the block with a valid one? And if &quot;invalid&quot; block remains: is it somehow marked as invalid? If I meet two blocks with the same parent in the blockchain - how could I know which branch should I follow?</p>

<blockchain><block><blockchain-fork><best-chain><stale-block>
Does local blockchain database (blkXXXXX.dat) contain abandoned forks forever?
ardabro
# Does local blockchain database (blkXXXXX.dat) contain abandoned forks forever?

(Asked by: username_0 on 2022-06-19)

When my node realizes that the given block needs to be abandoned - does it leave it in the database or replace the block with a valid one? And if "invalid" block remains: is it somehow marked as invalid? If I meet two blocks with the same parent in the blockchain - how could I know which branch should I follow?

**Tags:** blockchain, block, blockchain-fork, best-chain, stale-block


---

## 1 answers

### Answer by username_1 on 2022-06-20. Score: 6 | Accepted answer

> When my node realizes that the given block needs to be abandoned - does it leave it in the database or replace the block with a valid one?

It remains on disk along with its entry in the block index database.

> And if "invalid" block remains: is it somehow marked as invalid?

Yes. The block index database contains an entry for each block which contains flags that indicate the state of the block. This includes various states of validity and invalidity (that indicate where it passed or failed certain checks).

> If I meet two blocks with the same parent in the blockchain - how could I know which branch should I follow?

Your node will follow the valid chain with the most cumulative work. At a given difficulty, this is the longest chain, but that is not always the case. If there are two blocks that have the same cumulative work, the node chooses the one it saw first. Eventually there will be a resolution as one of those blocks will be mined on and so have a greater cumulative work.


---

