good morning!!!!

Skip to content
Snippets Groups Projects
Commit dc864ee3 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Added ToString methods

parent f486c0ae
Branches
Tags
No related merge requests found
...@@ -24,19 +24,22 @@ func (h Hash) SetBytes(b []byte) { ...@@ -24,19 +24,22 @@ func (h Hash) SetBytes(b []byte) {
} }
} }
func (h Hash) SetString(s string) { h.SetBytes([]byte(s)) }
// Get the string representation of the underlying address // Get the string representation of the underlying address
func (a Address) Str() string { func (a Address) Str() string {
return string(a[:]) return string(a[:])
} }
// Sets the address to the value of b. If b is larger than len(a) it will panic // Sets the address to the value of b. If b is larger than len(a) it will panic
func (h Address) SetBytes(b []byte) { func (a Address) SetBytes(b []byte) {
if len(b) > len(h) { if len(b) > len(a) {
panic("unable to set bytes. too big") panic("unable to set bytes. too big")
} }
// reverse loop // reverse loop
for i := len(b); i >= 0; i-- { for i := len(b); i >= 0; i-- {
h[i] = b[i] a[i] = b[i]
} }
} }
func (a Address) SetString(s string) { h.SetBytes([]byte(a)) }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment