From 6f7cf857b408401abdc4477c888495b4f13162c7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Apr 2017 17:30:32 -0400 Subject: 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. --- Hash.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'Hash.hs') 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) -- cgit v1.2.3