From daf79506ba6ac9fa6b795ad2a19684288b367a92 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 17 Apr 2017 12:07:02 -0400 Subject: add Rejected and tag hashes by type Need a way for the user to indicate when an Activity Entered is Rejected. Changed hashing to include type tags, so Acticity Entered and Activity Seen can never hash to the same hash. Got debug-me.hs to compile after these changes, but currently it's buggy after Activity Entered is Rejected. Started protocol.txt documentation. This commit was sponsored by Francois Marier on Patreon. --- Types.hs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Types.hs') diff --git a/Types.hs b/Types.hs index 7837f71..b7c5f32 100644 --- a/Types.hs +++ b/Types.hs @@ -37,12 +37,25 @@ data Entered = Entered instance ToJSON Entered instance FromJSON Entered --- | An activity (either Entered or Seen) with a pointer +-- | High level protocol. +data Proto a + = Proto a + -- ^ either Entered or Seen + | Rejected (Activity Entered) + -- ^ sent by user to indicate when an Entered value was rejected. + deriving (Show, Generic) + +instance ToJSON (Proto Seen) +instance FromJSON (Proto Seen) +instance ToJSON (Proto Entered) +instance FromJSON (Proto Entered) + +-- | A Proto activity (either Entered or Seen) with a pointer -- to the Activity before this one. -- -- The Signature is over both the data in the activity, and its pointer. data Activity a = Activity - { activity :: a + { activity :: Proto a , prevActivity :: (Maybe Hash) , signature :: Signature } @@ -53,14 +66,14 @@ instance FromJSON (Activity Seen) instance ToJSON (Activity Entered) instance FromJSON (Activity Entered) --- | A log of Activity both Entered and Seen. +-- | A log of Activity both Entered and Seen, which can be recorded to +-- prove what happened in a debug-me session. data ActivityLog = ActivitySeen { activitySeen :: (Activity Seen, Hash) } | ActivityEntered - { activityEnteredAccepted :: Bool - , activityEntered :: (Activity Entered, Hash) + { activityEntered :: (Activity Entered, Hash) } deriving (Show, Generic) -- cgit v1.2.3