Bitcoin Forum
June 20, 2019, 12:33:01 PM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Little endian values in Block-header  (Read 98 times)
mechanikalk
Member
**
Offline Offline

Activity: 84
Merit: 13


View Profile WWW
November 18, 2018, 09:39:56 PM
Merited by malevolent (2), 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?
1561033981
Hero Member
*
Offline Offline

Posts: 1561033981

View Profile Personal Message (Offline)

Ignore
1561033981
Reply with quote  #2

1561033981
Report to moderator
1561033981
Hero Member
*
Offline Offline

Posts: 1561033981

View Profile Personal Message (Offline)

Ignore
1561033981
Reply with quote  #2

1561033981
Report to moderator
1561033981
Hero Member
*
Offline Offline

Posts: 1561033981

View Profile Personal Message (Offline)

Ignore
1561033981
Reply with quote  #2

1561033981
Report to moderator
NEW GAME FORMAT
JACKPOT UP TO $50000+
Guess The Symbols Of a Real Ethereum Hash
PLAY NOW
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1561033981
Hero Member
*
Offline Offline

Posts: 1561033981

View Profile Personal Message (Offline)

Ignore
1561033981
Reply with quote  #2

1561033981
Report to moderator
theymos
Administrator
Legendary
*
Offline Offline

Activity: 3416
Merit: 5929


View Profile
November 18, 2018, 11:11:59 PM
 #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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!