Why does the Bitcoin use the litte-endian notation? It is less common than big-endian notation, thus when programming low-level applications working with Bitcoin protocol, one quite often has to create custom operations for handling the endianness switching. Is there some specific reason why this notation was chosen?
feedback
|
|
Most likely it is a small design error, but there is big argument about it at bitcointalk.org:What would you change about the Bitcoin protocol?. | |||
|
feedback
|
|
Modern computers almost always use little-endian internally, so this choice improves speed. If Bitcoin used network byte order, then order conversions would be necessary for every message sent or received. Hashes are defined by the standards as being big-endian, and crypto libraries deal with them in that form, so hashes are transmitted in big-endian. Bitcoin displays hashes in little-endian because Bitcoin sometimes considers hashes to be little-endian integers instead of strings. | |||
|
feedback
|
|
Modern CPUs also typically have byte-swapping load and store instructions, or at least a byte swap register instruction, so that effective programmers (and optimizing compilers) may eliminate, or nearly eliminate, the overhead of endianness compensation. This "small design error" may be a simple case of "premature optimization". | |||||
feedback
|