Closed antiochp closed 5 years ago
Commented on #2325 but commenting here as well -
We should scope this beyond the tui to include everywhere we display a block hash - api, logs etc.
i.e. We should probably modify the default formatter for Hash
.
Having a big bunch of 0s prefixing a block hash is a real pain for display purposes...
Random thought (ignoring the fact we are 6 days from mainnet) -
If a block hash is effectively -
hash(pow)
Would it be possible to reference blocks via -
hash(hash(pow))
Is there any reason this wouldn't work or would make things significantly more complex?
there's no need to hash twice. the options are either to show
1) around 10 to 13 hex digits, of which the first 5 would normally be 0, leaving 5 to 8 useful ones. 2) the show the last 8 hex digits
Is there an option 3 here as well - just strip off the 0 prefix and show the first 8 useful digits?
If we implement whatever logic we go with here -
Then we should be able to simply print block.hash()
directly everywhere and have it do the right thing.
Stripping off all leading zeroes is an option, but feels like a hack to me. My preference is for option 1 with 12 hex digits, i.e. the first 48 bits of hash. The 5 leading 0s is like a sanity check that you're dealing with a blockhash.
@tromp how about this? Show twice as less starting zeroes and some digits from the end.
OK I vote for what @tromp suggested as option 1 - keep it really simple and show the first 12 digits.
I like the idea of the sanity check. I also prefer seeing the first digits (vs. the last digits) as its easier to compare visually against full block hashes displayed elsewhere, like block explorers in the browser etc.
@eupn that is more than 12 chars in total and harder to cut and paste, as double-clicking will not select across the dots.