Bitcoin Forum
June 22, 2024, 09:21:16 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: pchMessageStart - what is for? (in BC 0.8)  (Read 321 times)
Many Coins (OP)
Member
**
Offline Offline

Activity: 266
Merit: 11

Lord Shiva


View Profile
February 22, 2018, 12:56:55 PM
Merited by ABCbits (1)
 #1

Hello!

Tell me please, what is for:

Code:
pchMessageStart[0] = 0xfc;

and

Code:
pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb };

What does it do?

Thank you!

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
February 22, 2018, 04:12:54 PM
Merited by ABCbits (1)
 #2

Those are the magic bytes. They prepend every single network message so that the message can be identified as being a Bitcoin message.

Many Coins (OP)
Member
**
Offline Offline

Activity: 266
Merit: 11

Lord Shiva


View Profile
February 23, 2018, 06:38:11 AM
 #3

Those are the magic bytes. They prepend every single network message so that the message can be identified as being a Bitcoin message.

Is it different from, for example, litecoin? But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.

And are these values ​​arbitrary? Or are there any rules for choosing them?
Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
February 23, 2018, 07:31:03 AM
 #4

Is it different from, for example, litecoin? But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
Apparently Litecoin and Viacoin (the only 2 bitcoin code forks I checked) have the same magic bytes:
Code:
pchMessageStart[0] = 0xfb;
        pchMessageStart[1] = 0xc0;
        pchMessageStart[2] = 0xb6;
        pchMessageStart[3] = 0xdb;
https://github.com/litecoin-project/litecoin/blob/master/src/chainparams.cpp
Quote
And are these values ​​arbitrary? Or are there any rules for choosing them?
The same file linked above has this comment:
Code:
The message start string is designed to be unlikely to occur in normal data.
         * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
         * a large 32-bit integer with any alignment.
Many Coins (OP)
Member
**
Offline Offline

Activity: 266
Merit: 11

Lord Shiva


View Profile
February 23, 2018, 07:28:45 PM
 #5


Apparently Litecoin and Viacoin (the only 2 bitcoin code forks I checked) have the same magic bytes:


why not  Smiley
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
February 24, 2018, 04:17:40 AM
Merited by ABCbits (2)
 #6

Is it different from, for example, litecoin?
Yes.

But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
To make sure that there's no crosstalk or confusion in the first place as figuring out that they have different genesis blocks still costs bandwidth and computing power.

And are these values ​​arbitrary? Or are there any rules for choosing them?
They're arbitrary. The common recommendation for new altcoins is to just randomly generate new magic bytes.

Many Coins (OP)
Member
**
Offline Offline

Activity: 266
Merit: 11

Lord Shiva


View Profile
February 24, 2018, 10:41:40 AM
 #7

But why? Because they have different genesis blocks and seed-nodes, they will not be confused in any way.
To make sure that there's no crosstalk or confusion in the first place as figuring out that they have different genesis blocks still costs bandwidth and computing power.

And are these values ​​arbitrary? Or are there any rules for choosing them?
They're arbitrary. The common recommendation for new altcoins is to just randomly generate new magic bytes.

Thank you!

It is clear now.
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!