Bitcoin Forum
February 06, 2023, 05:13:40 PM *
News: Latest Bitcoin Core release: 24.0.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Little endian values in Block-header  (Read 163 times)
mechanikalk (OP)
Member
**
Offline Offline

Activity: 91
Merit: 72


View Profile WWW
November 18, 2018, 09:39:56 PM
Merited by malevolent (2), ETFbitcoin (1), bones261 (1)
 #1

Does anyone have any idea why Satoshi made all values in the block-header stored as little endian in byte code except for the Merkle root?  It is a frustrating thing when working with code and I can't figure out why it would have been done this way?  Any guesses or thoughts or reasonings for this?
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1675703620
Hero Member
*
Offline Offline

Posts: 1675703620

View Profile Personal Message (Offline)

Ignore
1675703620
Reply with quote  #2

1675703620
Report to moderator
1675703620
Hero Member
*
Offline Offline

Posts: 1675703620

View Profile Personal Message (Offline)

Ignore
1675703620
Reply with quote  #2

1675703620
Report to moderator
1675703620
Hero Member
*
Offline Offline

Posts: 1675703620

View Profile Personal Message (Offline)

Ignore
1675703620
Reply with quote  #2

1675703620
Report to moderator
theymos
Administrator
Legendary
*
Offline Offline

Activity: 4746
Merit: 10837


View Profile
November 18, 2018, 11:11:59 PM
Merited by ETFbitcoin (1)
 #2

The Merkle root is also little-endian...

As to why, it's because the fields are read/written directly between memory and the socket, and that's how the data is ordered in memory. Integers are little-endian in memory because that's how the supported architectures do things. It's a little weird that hashes are stored little-endian, but Satoshi put most hashes in a uint256 type which behaved how you'd expect a 256-bit integer to behave on eg. x86, including little-endianness.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
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!