4

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?

New contributor
ardabro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

6

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.

Your Answer

ardabro is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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