summaryrefslogtreecommitdiff
path: root/dht
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-12-05 13:34:03 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 23:22:52 -0500
commitaf60f0551f7ed51669422234ad0916c71ba42e71 (patch)
tree47f3999b52f7206cb38bb12e996de7fd6bf0fb6f /dht
parent917abe95273afedd9d6b8e57ea34c0f8e55509e8 (diff)
Marshall AnnounceKey as raw ByteString.
Diffstat (limited to 'dht')
-rw-r--r--dht/Announcer.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/dht/Announcer.hs b/dht/Announcer.hs
index 41f86f24..98fcdf94 100644
--- a/dht/Announcer.hs
+++ b/dht/Announcer.hs
@@ -13,6 +13,8 @@ module Announcer
13 , scheduleToList 13 , scheduleToList
14 , packAnnounceKey 14 , packAnnounceKey
15 , unpackAnnounceKey 15 , unpackAnnounceKey
16 , encodeAnnounceKey
17 , decodeAnnounceKey
16 , forkAnnouncer 18 , forkAnnouncer
17 , stopAnnouncer 19 , stopAnnouncer
18 , cancel 20 , cancel
@@ -44,15 +46,18 @@ import qualified GHC.Generics as Generics
44newtype AnnounceKey = AnnounceKey ByteString 46newtype AnnounceKey = AnnounceKey ByteString
45 deriving (Hashable,Ord,Eq) 47 deriving (Hashable,Ord,Eq)
46 48
47-- instance Show AnnounceKey where
48-- show (AnnounceKey bs) = "AnnounceKey " ++ show (Char8.unpack bs)
49
50packAnnounceKey :: Announcer -> String -> AnnounceKey 49packAnnounceKey :: Announcer -> String -> AnnounceKey
51packAnnounceKey _ = AnnounceKey . Char8.pack 50packAnnounceKey _ = AnnounceKey . Char8.pack
52 51
53unpackAnnounceKey :: Announcer -> AnnounceKey -> String 52unpackAnnounceKey :: Announcer -> AnnounceKey -> String
54unpackAnnounceKey _ (AnnounceKey bs) = Char8.unpack bs 53unpackAnnounceKey _ (AnnounceKey bs) = Char8.unpack bs
55 54
55encodeAnnounceKey :: Announcer -> AnnounceKey -> ByteString
56encodeAnnounceKey _ (AnnounceKey k) = k
57
58decodeAnnounceKey :: Announcer -> ByteString -> AnnounceKey
59decodeAnnounceKey _ k = AnnounceKey k
60
56-- | Actions that can be scheduled to occur at some particular time in the 61-- | Actions that can be scheduled to occur at some particular time in the
57-- future. Since periodic event handlers are responsible for re-scheduling 62-- future. Since periodic event handlers are responsible for re-scheduling
58-- themselves, they are typically bootstrapped using 'scheduleImmediately' with 63-- themselves, they are typically bootstrapped using 'scheduleImmediately' with