refactor: add custom type to use in maps MultihashCode

This commit is contained in:
Derrick Hammer 2024-01-03 08:20:03 -05:00
parent 93e0ce02f5
commit 56be9082c3
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,8 @@ var (
errorNotBase64Url = errors.New("not a base64url string")
)
type MultihashCode = int
type Multihash struct {
FullBytes []byte
}
@ -64,7 +66,7 @@ func (m *Multihash) Equals(other *Multihash) bool {
return bytes.Equal(m.FullBytes, other.FullBytes)
}
func (m *Multihash) HashCode() int {
func (m *Multihash) HashCode() MultihashCode {
return int(m.FullBytes[0]) +
int(m.FullBytes[1])<<8 +
int(m.FullBytes[2])<<16 +