diff options
author | joe <joe@jerkface.net> | 2017-07-01 12:05:31 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-01 12:05:31 -0400 |
commit | 12cbcd87e7d36f8211d6556d8bf4e60ebec07c0e (patch) | |
tree | 016817985431f4c0efac0a157365d1ca7f14d2ac | |
parent | 8cbc9b28b4d2923dfc1502d66af20dc8d06c7bda (diff) |
Implemented instance Pretty (NodeInfo ...).
-rw-r--r-- | examples/dhtd.hs | 2 | ||||
-rw-r--r-- | src/Network/DatagramServer/Mainline.hs | 6 | ||||
-rw-r--r-- | src/Network/DatagramServer/Types.hs | 7 |
3 files changed, 7 insertions, 8 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 52ff3c98..15369ede 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -231,8 +231,6 @@ instance Kademlia Tox.Message where | |||
231 | 231 | ||
232 | instance Pretty (NodeId Tox.Message) where pPrint (Tox.NodeId nid) = encodeHexDoc nid | 232 | instance Pretty (NodeId Tox.Message) where pPrint (Tox.NodeId nid) = encodeHexDoc nid |
233 | 233 | ||
234 | instance Pretty (NodeInfo Tox.Message IPv4 ()) where | ||
235 | instance Pretty (NodeInfo Tox.Message IPv4 Bool) where -- TODO | ||
236 | instance Read (NodeId KMessageOf) where | 234 | instance Read (NodeId KMessageOf) where |
237 | readsPrec d s = map (\(ih,s) -> (toNodeId (ih::InfoHash),s)) $ readsPrec d s | 235 | readsPrec d s = map (\(ih,s) -> (toNodeId (ih::InfoHash),s)) $ readsPrec d s |
238 | instance Read (NodeId Tox.Message) where -- TODO | 236 | instance Read (NodeId Tox.Message) where -- TODO |
diff --git a/src/Network/DatagramServer/Mainline.hs b/src/Network/DatagramServer/Mainline.hs index c2333a42..c127c07b 100644 --- a/src/Network/DatagramServer/Mainline.hs +++ b/src/Network/DatagramServer/Mainline.hs | |||
@@ -318,12 +318,6 @@ instance Serialize a => Serialize (NodeInfo KMessageOf a ()) where | |||
318 | get = (\a b -> NodeInfo a b ()) <$> get <*> get | 318 | get = (\a b -> NodeInfo a b ()) <$> get <*> get |
319 | put NodeInfo {..} = put nodeId >> put nodeAddr | 319 | put NodeInfo {..} = put nodeId >> put nodeAddr |
320 | 320 | ||
321 | instance Pretty ip => Pretty (NodeInfo KMessageOf ip ()) where | ||
322 | pPrint NodeInfo {..} = pPrint nodeId <> "@(" <> pPrint nodeAddr <> ")" | ||
323 | |||
324 | instance Pretty ip => Pretty [NodeInfo KMessageOf ip ()] where | ||
325 | pPrint = PP.vcat . PP.punctuate "," . map pPrint | ||
326 | |||
327 | 321 | ||
328 | #ifdef VERSION_bencoding | 322 | #ifdef VERSION_bencoding |
329 | instance BEncode ErrorCode where | 323 | instance BEncode ErrorCode where |
diff --git a/src/Network/DatagramServer/Types.hs b/src/Network/DatagramServer/Types.hs index dd915fdb..ea38d46e 100644 --- a/src/Network/DatagramServer/Types.hs +++ b/src/Network/DatagramServer/Types.hs | |||
@@ -341,3 +341,10 @@ instance (Serialize a, Serialize b) => Serialize (LargeKey a b) where | |||
341 | put (LargeKey lo hi) = put hi >> put lo | 341 | put (LargeKey lo hi) = put hi >> put lo |
342 | get = flip LargeKey <$> get <*> get | 342 | get = flip LargeKey <$> get <*> get |
343 | 343 | ||
344 | instance (Pretty ip, Pretty (NodeId dht)) => Pretty (NodeInfo dht ip u) where | ||
345 | pPrint NodeInfo {..} = pPrint nodeId <> "@(" <> pPrint nodeAddr <> ")" | ||
346 | |||
347 | instance (Pretty ip, Pretty (NodeId dht)) => Pretty [NodeInfo dht ip u] where | ||
348 | pPrint = PP.vcat . PP.punctuate "," . map pPrint | ||
349 | |||
350 | |||