good morning!!!!

Skip to content
Snippets Groups Projects
Commit fc87bc5f authored by Martin Holst Swende's avatar Martin Holst Swende Committed by Felix Lange
Browse files

common: improve documentation of Hash.SetBytes (#15062)

Fixes #15004
parent c1740e45
No related branches found
No related tags found
No related merge requests found
...@@ -88,7 +88,7 @@ func (h Hash) MarshalText() ([]byte, error) { ...@@ -88,7 +88,7 @@ func (h Hash) MarshalText() ([]byte, error) {
return hexutil.Bytes(h[:]).MarshalText() return hexutil.Bytes(h[:]).MarshalText()
} }
// Sets the hash to the value of b. If b is larger than len(h) it will panic // Sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).
func (h *Hash) SetBytes(b []byte) { func (h *Hash) SetBytes(b []byte) {
if len(b) > len(h) { if len(b) > len(h) {
b = b[len(b)-HashLength:] b = b[len(b)-HashLength:]
...@@ -97,7 +97,7 @@ func (h *Hash) SetBytes(b []byte) { ...@@ -97,7 +97,7 @@ func (h *Hash) SetBytes(b []byte) {
copy(h[HashLength-len(b):], b) copy(h[HashLength-len(b):], b)
} }
// Set string `s` to h. If s is larger than len(h) it will panic // Set string `s` to h. If s is larger than len(h) s will be cropped (from left) to fit.
func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) } func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) }
// Sets h to other // Sets h to other
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment