4 ms·
Neat. Just browsing through the source, is there a reason that: calculateBlockHash (Block i p t b _) = concatMap hashString [show i, p, show t, b] is not
by eemax 9y ago
Neat. Just browsing through the source, is there a reason that:
calculateBlockHash (Block i p t b _) = concatMap hashString [show i, p, show t, b]
is not
calculateBlockHash (Block i p t b _) = hashString $ concat [show i, p, show t, b]
i.e. why is a block hash a concatenation of 4 SHA-256 hashes instead of just 1? Is there some security benefit of doing it one way vs. the other?
edit: thinking about it a little more, option 2 seems better because in option 1 you can calculate 3/4 of a block hash without knowing the previous block's hash. Maybe that's not a problem in this context though?
- aviaviavi 9y agoYou're correct, it really should be the 2nd way. The current form isn't really a problem per se, mostly just that the generated hashes are really long and make the output harder to read. I'll get that updated, great catch. EDIT: code updated.