Skip to content

Commit 76f215b

Browse files
committed
Getters shouldn't need to be pointer receiver
1 parent 0dd9ac3 commit 76f215b

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎common/types.go‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package common
22

3-
type (
4-
Hash [32]byte
5-
Address [20]byte
6-
)
3+
type Hash [32]byte
74

85
var (
96
zeroHash Hash
@@ -27,7 +24,7 @@ func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) }
2724
// Don't use the default 'String' method in case we want to overwrite
2825

2926
// Get the string representation of the underlying hash
30-
func (h *Hash) Str() string {
27+
func (h Hash) Str() string {
3128
return string(h[:])
3229
}
3330

@@ -53,13 +50,15 @@ func (h *Hash) Set(other Hash) {
5350
}
5451
}
5552

53+
type Address [20]byte
54+
5655
// Get the string representation of the underlying address
5756
func (a Address) Str() string {
5857
return string(a[:])
5958
}
6059

6160
// Sets the address to the value of b. If b is larger than len(a) it will panic
62-
func (a Address) SetBytes(b []byte) {
61+
func (a *Address) SetBytes(b []byte) {
6362
if len(b) > len(a) {
6463
panic("unable to set bytes. too big")
6564
}
@@ -71,10 +70,10 @@ func (a Address) SetBytes(b []byte) {
7170
}
7271

7372
// Set string `s` to a. If s is larger than len(a) it will panic
74-
func (a Address) SetString(s string) { a.SetBytes([]byte(s)) }
73+
func (a *Address) SetString(s string) { a.SetBytes([]byte(s)) }
7574

7675
// Sets a to other
77-
func (a Address) Set(other Address) {
76+
func (a *Address) Set(other Address) {
7877
for i, v := range other {
7978
a[i] = v
8079
}

0 commit comments

Comments
 (0)