refactor: add custom type to use in maps MultihashCode
This commit is contained in:
parent
93e0ce02f5
commit
56be9082c3
|
@ -14,6 +14,8 @@ var (
|
||||||
errorNotBase64Url = errors.New("not a base64url string")
|
errorNotBase64Url = errors.New("not a base64url string")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type MultihashCode = int
|
||||||
|
|
||||||
type Multihash struct {
|
type Multihash struct {
|
||||||
FullBytes []byte
|
FullBytes []byte
|
||||||
}
|
}
|
||||||
|
@ -64,7 +66,7 @@ func (m *Multihash) Equals(other *Multihash) bool {
|
||||||
return bytes.Equal(m.FullBytes, other.FullBytes)
|
return bytes.Equal(m.FullBytes, other.FullBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Multihash) HashCode() int {
|
func (m *Multihash) HashCode() MultihashCode {
|
||||||
return int(m.FullBytes[0]) +
|
return int(m.FullBytes[0]) +
|
||||||
int(m.FullBytes[1])<<8 +
|
int(m.FullBytes[1])<<8 +
|
||||||
int(m.FullBytes[2])<<16 +
|
int(m.FullBytes[2])<<16 +
|
||||||
|
|
Loading…
Reference in New Issue