From 56be9082c33cc95d795dfc16186f04f0ec072f11 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 3 Jan 2024 08:20:03 -0500 Subject: [PATCH] refactor: add custom type to use in maps MultihashCode --- multihash/multihash.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/multihash/multihash.go b/multihash/multihash.go index 7648877..c459ce4 100644 --- a/multihash/multihash.go +++ b/multihash/multihash.go @@ -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 +