git-annex/Logs/Multicast.hs
Joey Hess bfc9039ead
convert git-annex branch access to ByteStrings and Builders
Most of the individual logs are not converted yet, only presense logs
have an efficient ByteString Builder implemented so far. The rest
convert to and from String.
2019-01-03 13:21:48 -04:00

31 lines
798 B
Haskell

{- git-annex multicast fingerprint log
-
- Copyright 2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Logs.Multicast (
Fingerprint(..),
recordFingerprint,
knownFingerPrints,
) where
import Annex.Common
import qualified Annex.Branch
import Logs
import Logs.UUIDBased
import qualified Data.Map as M
newtype Fingerprint = Fingerprint String
deriving (Eq, Read, Show)
recordFingerprint :: Fingerprint -> UUID -> Annex ()
recordFingerprint fp uuid = do
c <- liftIO currentVectorClock
Annex.Branch.change multicastLog $
encodeBL . showLog show . changeLog c uuid fp . parseLog readish . decodeBL
knownFingerPrints :: Annex (M.Map UUID Fingerprint)
knownFingerPrints = simpleMap . parseLog readish . decodeBL <$> Annex.Branch.get activityLog