Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TUI] block hashes in TUI will need to be larger than first 8 chars for mainnet #2314

Closed
antiochp opened this issue Jan 8, 2019 · 8 comments
Labels
enhancement must-have Required for the associated milestone
Milestone

Comments

@antiochp
Copy link
Member

antiochp commented Jan 8, 2019

John Tromp @tromp 15:30
btw, the TUI only shows 8 hex digits of hash

jaspervdm @jaspervdm 15:31
or 5 even

John Tromp @tromp 15:31
that won't cut it on mainnet, where most will be 0

@antiochp antiochp added enhancement must-have Required for the associated milestone labels Jan 8, 2019
@antiochp antiochp added this to the Mainnet milestone Jan 8, 2019
@antiochp
Copy link
Member Author

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?

@tromp
Copy link
Contributor

tromp commented Jan 10, 2019

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

@antiochp
Copy link
Member Author

Is there an option 3 here as well - just strip off the 0 prefix and show the first 8 useful digits?

@antiochp
Copy link
Member Author

If we implement whatever logic we go with here -

impl fmt::Debug for Hash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for i in self.0[..4].iter() {
write!(f, "{:02x}", i)?;
}
Ok(())
}
}
impl fmt::Display for Hash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}

Then we should be able to simply print block.hash() directly everywhere and have it do the right thing.

@tromp
Copy link
Contributor

tromp commented Jan 10, 2019

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.

@eupn
Copy link
Contributor

eupn commented Jan 10, 2019

@tromp how about this? Show twice as less starting zeroes and some digits from the end.

@antiochp
Copy link
Member Author

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.

@tromp
Copy link
Contributor

tromp commented Jan 10, 2019

@eupn that is more than 12 chars in total and harder to cut and paste, as double-clicking will not select across the dots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement must-have Required for the associated milestone
Projects
None yet
Development

No branches or pull requests

3 participants