From 5e81ebbd1a6f8911acd537923f2f3c1df4971bbc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Apr 2017 11:32:49 -0400 Subject: fix backlog truncation bug That I was stuck on for hours yesterday, oops! This commit was sponsored by Bruno BEAUFILS on Patreon. --- debug-me.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'debug-me.hs') diff --git a/debug-me.hs b/debug-me.hs index 9332270..7a9f527 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -278,19 +278,26 @@ sendPtyInput ichan ochan p backlog logger = go go -- | Truncate the Backlog to remove entries older than the one --- that the Activity refers to. +-- that the Activity Entered refers to, but only if the referred +-- to Activity is an Activity Seen. -- --- If the activity refers to an item not in the backlog, no truncation is +-- Once the developer has referred to a given Activity Seen in +-- their Activity Entered, they cannot refer backwards to anything +-- that came before it. +-- +-- If the Activity refers to an item not in the backlog, no truncation is -- done. truncateBacklog :: Backlog -> Activity Entered -> Backlog truncateBacklog (Backlog (b :| l)) (Activity _ hp _) - | Just (activityLogHash b) == hp = Backlog (b :| []) + | truncationpoint b = Backlog (b :| []) | otherwise = Backlog (b :| go [] l) where go c [] = reverse c go c (x:xs) - | Just (activityLogHash x) == hp = reverse (x:c) + | truncationpoint x = reverse (x:c) | otherwise = go (x:c) xs + truncationpoint x@(ActivitySeen {}) = Just (activityLogHash x) == hp + truncationpoint _ = False -- | Entered activity is legal when it points to the last Seen activvity, -- because this guarantees that the person who entered it saw -- cgit v1.2.3