diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-16 23:44:27 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-16 23:44:27 +0800 |
commit | 76f215b0feca1fc56890fe5f9ec1acbed79cb701 (patch) | |
tree | a5cce160869adf0f5c4f15afb0cd861b5776169c /common | |
parent | 0dd9ac375b20fc597e205225db819e8847bcf971 (diff) | |
download | go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar.gz go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar.bz2 go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar.lz go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar.xz go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.tar.zst go-tangerine-76f215b0feca1fc56890fe5f9ec1acbed79cb701.zip |
Getters shouldn't need to be pointer receiver
Diffstat (limited to 'common')
-rw-r--r-- | common/types.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/common/types.go b/common/types.go index 1fe31657b..8f0e8fd26 100644 --- a/common/types.go +++ b/common/types.go @@ -1,9 +1,6 @@ package common -type ( - Hash [32]byte - Address [20]byte -) +type Hash [32]byte var ( zeroHash Hash @@ -27,7 +24,7 @@ func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) } // Don't use the default 'String' method in case we want to overwrite // Get the string representation of the underlying hash -func (h *Hash) Str() string { +func (h Hash) Str() string { return string(h[:]) } @@ -53,13 +50,15 @@ func (h *Hash) Set(other Hash) { } } +type Address [20]byte + // Get the string representation of the underlying address func (a Address) Str() string { return string(a[:]) } // Sets the address to the value of b. If b is larger than len(a) it will panic -func (a Address) SetBytes(b []byte) { +func (a *Address) SetBytes(b []byte) { if len(b) > len(a) { panic("unable to set bytes. too big") } @@ -71,10 +70,10 @@ func (a Address) SetBytes(b []byte) { } // Set string `s` to a. If s is larger than len(a) it will panic -func (a Address) SetString(s string) { a.SetBytes([]byte(s)) } +func (a *Address) SetString(s string) { a.SetBytes([]byte(s)) } // Sets a to other -func (a Address) Set(other Address) { +func (a *Address) Set(other Address) { for i, v := range other { a[i] = v } |