summaryrefslogtreecommitdiffhomepage
path: root/Hash.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-19 17:30:32 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-19 17:45:14 -0400
commit6f7cf857b408401abdc4477c888495b4f13162c7 (patch)
tree5b746c171df6e68864b2bbaacf2e833587832367 /Hash.hs
parent951d165bc27b9397174af1d826366e39cdbd53dd (diff)
downloaddebug-me-6f7cf857b408401abdc4477c888495b4f13162c7.tar.gz
reorganized message types
Make Control messages be out-of-band async messages, without a pointer to a previous message. And then followed the type change through the code for hours.. This commit was sponsored by Nick Daly on Patreon.
Diffstat (limited to 'Hash.hs')
-rw-r--r--Hash.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/Hash.hs b/Hash.hs
index 2577c6b..e22abf3 100644
--- a/Hash.hs
+++ b/Hash.hs
@@ -38,10 +38,6 @@ instance Hashable a => Hashable (Activity a) where
hash (Activity a mp s) = hash $ Tagged "Activity"
[hash a, hash mp, hash s]
-instance Hashable a => Hashable (Proto a) where
- hash (Proto a) = hash $ Tagged "Proto" a
- hash (Rejected a) = hash $ Tagged "Rejected" (hash a)
-
instance Hashable Entered where
hash v = hash $ Tagged "Entered"
[hash (enteredData v), hash (echoData v)]
@@ -50,8 +46,15 @@ instance Hashable Seen where
hash v = hash $ Tagged "Seen" [hash (seenData v)]
instance Hashable Signature where
- hash (Ed25519 s) = hash $ Tagged "Ed25519" s
- hash Unsigned = hash $ Tagged "Unsigned" (mempty :: B.ByteString)
+ hash (Ed25519Signature s) = hash $ Tagged "Ed25519Signature" s
+ hash (OtherSignature s) = hash $ Tagged "OtherSignature" s
+
+instance Hashable PublicKey where
+ hash (PublicKey v gpgsig) = hash $ Tagged "PublicKey"
+ [hash v, hash gpgsig]
+
+instance Hashable GpgSig where
+ hash (GpgSig v) = hash $ Tagged "GpgSig" v
-- | Hash a list of hashes by hashing the concacenation of the hashes.
instance Hashable [Hash] where
@@ -59,5 +62,8 @@ instance Hashable [Hash] where
-- | Hash empty string for Nothing
instance Hashable v => Hashable (Maybe v) where
- hash Nothing = hash (mempty :: B.ByteString)
+ hash Nothing = hash ()
hash (Just v) = hash v
+
+instance Hashable () where
+ hash () = hash (mempty :: B.ByteString)