From ddb32ffb75bc78ce1004a7ddedc1ed2c54eccadb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 12 Apr 2017 16:14:47 -0400 Subject: fix bug Forgot to include the most recent backlog when checking echoData --- debug-me.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'debug-me.hs') diff --git a/debug-me.hs b/debug-me.hs index a0d7476..bd80f01 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -15,6 +15,7 @@ import System.Exit import qualified Data.ByteString as B import Data.List.NonEmpty (NonEmpty(..), toList) import Data.Monoid +import Debug.Trace main :: IO () main = do @@ -199,10 +200,11 @@ truncateBacklog (Backlog bl) _ = Backlog bl -- concatenation of all activities after that one, up to the most recent -- Seen activity. isLegal :: Activity Entered -> Backlog -> Bool -isLegal (Activity entered hp sig) (Backlog ((lastseenhash, _lastseen) :| bl)) +isLegal (Activity entered hp sig) (Backlog (last@(lastseenhash, _lastseen) :| bl)) | lastseenhash == hp = True + | B.null (echoData entered) = False -- optimisation | any (== hp) (map fst bl) = - let sincehp = reverse (takeWhile (\(h, _) -> h /= hp) bl) + let sincehp = reverse (last : takeWhile (\(h, _) -> h /= hp) bl) in echoData entered == mconcat (map (seenData . activityContent . snd) sincehp) | otherwise = False isLegal _ _ = False -- cgit v1.2.3