You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
kishansagathiya
changed the title
Replace common.NewHash with common.BytesToHash
Replace common.NewHash and common.Hash() with common.BytesToHashMar 15, 2022
kishansagathiya
changed the title
Replace common.NewHash and common.Hash() with common.BytesToHash
Replace common.NewHash and common.Hash() with common.BytesToHashMar 15, 2022
Issue summary
common.BytesToHash
,common.NewHash
andcommon.Hash
changes bytes to hash (does not hash, just converts). Both of these functions are used interchangeably, butcommon.BytesToHash
puts 0 bytes in the front andcommon.NewHash
puts 0 bytes in the back.Say
[]byte
argument is0x44102080304545b0b6579496e736964656368696c6414766f696c61
common.BytesToHash
will give hash like0x00000000044102080304545b0b6579496e736964656368696c6414766f696c61
andcommon.NewHash
will give a hash like0x44102080304545b0b6579496e736964656368696c6414766f696c61000000000
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
The text was updated successfully, but these errors were encountered: