<p>A blockchain is an abstract datastructure that contains a chain of blocks, consisting of hash-linked he headers and transactions.</p>

<p>If you're talking about a parser, I assume you're talking about files on disk... perhaps the blk*.dat files in Bitcoin Core's data directory. Those are just one way to represent the blockchain, and it's an implementation specific one that can change between releases.</p>

<p>Assuming you're indeed asking about the disk representation of blocks in Bitcoin Core (or similar software):</p>

<ul>
<li>Every valid block starts with the magic sequence plus the size.</li>
<li>The magic sequence is allowed to appear inside the middle of blocks.</li>
<li>There may be gaps between blocks that are filled with garbage, including byte sequences from block data, which may in fact also contain the magic sequence.</li>
</ul>

<p>Furthermore, the term 'blockchain' is often interchangably used for both the tree of all blocks produced/known, or for the longest path through it. The block files on disk contain all blocks Bitcoin Core has ever seen, including blocks that are not part of the main chain ("orphan blocks") and were stale or reorganized out.</p>

CC BY-SA 3.0
2017-01-12T15:04:46.033Z
Sorry that my question was unclear. You guessed well, I'm talking about disk representation of blocks in bitcoin core. Thank you for your detailed answer.
JSM
CC BY-SA 3.0
2017-01-12T13:09:59.397Z
2017-01-12T13:09:59.397Z
Pieter Wuille
<p>For a blockchain parser, is it correct to say that "for X magicbytes sequences, we have X blocks in blockchain" ?</p>

<p>In other words, may blocks in blockchain accidentally contain magicbytes sequences ? </p>

<blockchain><bitcoin-core>
Is magicbytes sequence a valid delimiter for blocks in blockchains?
JSM
# Is magicbytes sequence a valid delimiter for blocks in blockchains?

(Asked by: username_0 on 2017-01-12)

For a blockchain parser, is it correct to say that "for X magicbytes sequences, we have X blocks in blockchain" ?

In other words, may blocks in blockchain accidentally contain magicbytes sequences ?

**Tags:** blockchain, bitcoin-core


---

## 1 answers

### Answer by username_1 on 2017-01-12. Score: 0 | Accepted answer

A blockchain is an abstract datastructure that contains a chain of blocks, consisting of hash-linked he headers and transactions.

If you're talking about a parser, I assume you're talking about files on disk... perhaps the blk\*.dat files in Bitcoin Core's data directory. Those are just one way to represent the blockchain, and it's an implementation specific one that can change between releases.

Assuming you're indeed asking about the disk representation of blocks in Bitcoin Core (or similar software):

* Every valid block starts with the magic sequence plus the size.
* The magic sequence is allowed to appear inside the middle of blocks.
* There may be gaps between blocks that are filled with garbage, including byte sequences from block data, which may in fact also contain the magic sequence.

Furthermore, the term 'blockchain' is often interchangably used for both the tree of all blocks produced/known, or for the longest path through it. The block files on disk contain all blocks Bitcoin Core has ever seen, including blocks that are not part of the main chain ("orphan blocks") and were stale or reorganized out.

> **Comments:**
> **username_0**: Sorry that my question was unclear. You guessed well, I'm talking about disk representation of blocks in bitcoin core. Thank you for your detailed answer.  

---

