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

Add humanize bytes utility #189

Merged
merged 4 commits into from Apr 28, 2020

Conversation

pipermerriam
Copy link
Member

@pipermerriam pipermerriam commented Apr 28, 2020

What was wrong?

The humanize_hash function was useful for things that are consistently 32 bytes long but it didn't work well for variable length byte strings since 1) the input value is typed as Hash32 and 2) it doesn't work correctly for short byte strings..

How was it fixed?

Added a humanize_bytes that is more general case and handles short byte strings appropriately.

To-Do

Cute Animal Picture

maxresdefault

@pipermerriam
Copy link
Member Author

There are a small number of linting changes that black made (new black version). I segregated them into their own commit and included them here.

@pipermerriam pipermerriam changed the title Piper/add humanize bytes Add humanize bytes utility Apr 28, 2020
Copy link
Contributor

@njgheorghita njgheorghita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple typos - looks good otherwise!


Returns the provided byte string in a human readable format.

If the value is 5 bytes or shorted it is returned in full in its hexidecimal representation (without a ``0x`` prefix)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorted => shorter


If the value is 5 bytes or shorted it is returned in full in its hexidecimal representation (without a ``0x`` prefix)

If the value is longer that 5 bytes it is returne in its hexidecimal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returne => returned

@pipermerriam pipermerriam merged commit e70791d into ethereum:master Apr 28, 2020
@pipermerriam pipermerriam deleted the piper/add-humanize-bytes branch April 28, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants