newtype MapLog

Noticed that Semigroup instance of Map is not suitable to use
for MapLog. For example, it behaved like this:

ghci>  parseTrustLog "foo 1 timestamp=10\nfoo 2 timestamp=11" <> parseTrustLog "foo X timestamp=12"
fromList [(UUID "foo",LogEntry {changed = VectorClock 11s, value = SemiTrusted})]

Which was wrong, it lost the newer DeadTrusted value.

Luckily, nothing used that Semigroup when operating on a MapLog. And this
provides a safe instance.

Sponsored-by: Graham Spencer on Patreon
This commit is contained in:
Joey Hess 2023-11-13 14:16:55 -04:00
parent 5d8b8a8ad0
commit 38b9ebc5fd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
8 changed files with 74 additions and 44 deletions

View file

@ -73,7 +73,7 @@ start (Expire expire) noact actlog descs u =
trustSet u DeadTrusted
next $ return True
where
lastact = changed <$> M.lookup u actlog
lastact = changed <$> M.lookup u (fromMapLog actlog)
whenactive = case lastact of
Just (VectorClock c) -> do
d <- liftIO $ durationSince $ posixSecondsToUTCTime c