Bitcoin Forum
July 17, 2024, 05:18:24 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why check for pchMessageStart in blocks?  (Read 85 times)
dnprock (OP)
Member
**
Offline Offline

Activity: 324
Merit: 17

Bitflate developer


View Profile WWW
January 24, 2021, 01:36:06 AM
 #1

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.
ranochigo
Legendary
*
Offline Offline

Activity: 2996
Merit: 4200



View Profile
January 24, 2021, 03:36:41 AM
 #2

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

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
dnprock (OP)
Member
**
Offline Offline

Activity: 324
Merit: 17

Bitflate developer


View Profile WWW
January 24, 2021, 06:32:37 AM
 #3

ranochigo, thanks for the quick response and link.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!