Change functions of Key from pointer to value reference

This commit is contained in:
Jerry 2022-11-14 15:29:31 -08:00
parent da74f8c7e4
commit 3a87233a9c

View file

@ -20,27 +20,27 @@ const KeyLength = common.AddressLength + common.HashLength + 2
type Key [KeyLength]byte type Key [KeyLength]byte
func (k *Key) IsAddress() bool { func (k Key) IsAddress() bool {
return k[KeyLength-1] == addressType return k[KeyLength-1] == addressType
} }
func (k *Key) IsState() bool { func (k Key) IsState() bool {
return k[KeyLength-1] == stateType return k[KeyLength-1] == stateType
} }
func (k *Key) IsSubpath() bool { func (k Key) IsSubpath() bool {
return k[KeyLength-1] == subpathType return k[KeyLength-1] == subpathType
} }
func (k *Key) GetAddress() common.Address { func (k Key) GetAddress() common.Address {
return common.BytesToAddress(k[:common.AddressLength]) return common.BytesToAddress(k[:common.AddressLength])
} }
func (k *Key) GetStateKey() common.Hash { func (k Key) GetStateKey() common.Hash {
return common.BytesToHash(k[common.AddressLength : KeyLength-2]) return common.BytesToHash(k[common.AddressLength : KeyLength-2])
} }
func (k *Key) GetSubpath() byte { func (k Key) GetSubpath() byte {
return k[KeyLength-2] return k[KeyLength-2]
} }