0

I'm parsing the binary data from the bitcoin core blockchain blkxxxxx.dat files. If I read out the magic number I get this:

\xf9\xbe\xb4\xd9\

Why isn't it stored the other way around, as the magic number is d9b4bef9? Is this just the way bytes are stored in memory?

I'm aware this is a complete noob question, but could anybody help me understand this. Thanks.

2

See little-endian and big-endian.

The choice made by Bitcoin authors for data transmitted over the network is somewhat arbitrary. I think the reference implementation (Bitcoin core) chooses to store the data on disk verbatim as received from the network.

The standard for the Internet is called network order and is big-endian. The Intel x86 family of processors are little endian. The early software developers of Bitcoin didn't convert native order to network order when constructing packets. At least, not entirely.

Your Answer

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.