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

Replace common.NewHash and common.Hash() with common.BytesToHash #2356

Open
kishansagathiya opened this issue Mar 8, 2022 · 0 comments
Open

Comments

@kishansagathiya
Copy link
Contributor

kishansagathiya commented Mar 8, 2022

Issue summary

  • common.BytesToHash, common.NewHash and common.Hash changes bytes to hash (does not hash, just converts). Both of these functions are used interchangeably, but common.BytesToHash puts 0 bytes in the front and common.NewHash puts 0 bytes in the back.

  • Say []byte argument is 0x44102080304545b0b6579496e736964656368696c6414766f696c61
    common.BytesToHash will give hash like 0x00000000044102080304545b0b6579496e736964656368696c6414766f696c61 and common.NewHash will give a hash like 0x44102080304545b0b6579496e736964656368696c6414766f696c61000000000

  • We should pick one of them and use it across the project to avoid any mismatching in the value of hash. I have gone with common.BytesToHash so far.

Other information and links

@kishansagathiya kishansagathiya changed the title Replace common.NewHash with common.BytesToHash Replace common.NewHash and common.Hash() with common.BytesToHash Mar 15, 2022
@kishansagathiya kishansagathiya changed the title Replace common.NewHash and common.Hash() with common.BytesToHash Replace common.NewHash and common.Hash() with common.BytesToHash Mar 15, 2022
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

No branches or pull requests

3 participants