aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/types.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/types.go b/common/types.go
index 495b10d..0a78111 100644
--- a/common/types.go
+++ b/common/types.go
@@ -18,6 +18,7 @@
package common
import (
+ "bytes"
"encoding/hex"
)
@@ -50,3 +51,10 @@ func (h *Hash) UnmarshalText(text []byte) error {
_, err := hex.Decode(h[:], text)
return err
}
+
+// Hashes is for sorting hashes.
+type Hashes []Hash
+
+func (hs Hashes) Len() int { return len(hs) }
+func (hs Hashes) Less(i, j int) bool { return bytes.Compare(hs[i][:], hs[j][:]) < 0 }
+func (hs Hashes) Swap(i, j int) { hs[i], hs[j] = hs[j], hs[i] }