Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: dnprock on January 24, 2021, 01:36:06 AM



Title: Why check for pchMessageStart in blocks?
Post by: dnprock on January 24, 2021, 01:36:06 AM
I notice there's a check for message_start in the function ReadRawBlockFromDisk.

https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1207

If I understand correctly, message_start is used to identify Bitcoin Core clients.

https://bitcointalk.org/index.php?topic=2997687.0

Why does the function ReadRawBlockFromDisk check for message_start? Does that mean message_start is also written into blocks?

Thanks.


Title: Re: Why check for pchMessageStart in blocks?
Post by: ranochigo on January 24, 2021, 03:36:41 AM
The magic bytes are prepended at the start of the blocks on the disk and are in a sense delimiters for the blocks represented on the disk. The magic bytes are not related to the block itself but it's included with every block in the blk.dat[1]. They are not a component in the blocks itself, per se.

It doesn't mean that the magic bytes can only appear at the start of the block though, they could also appear in the middle of the blocks as some arbitrary data.

[1] https://en.bitcoin.it/wiki/Block#Block_structure


Title: Re: Why check for pchMessageStart in blocks?
Post by: dnprock on January 24, 2021, 06:32:37 AM
ranochigo, thanks for the quick response and link.