summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-06-08 03:07:13 -0400
committerjoe <joe@jerkface.net>2017-06-08 03:07:13 -0400
commit8c33deac14ca92ef67afc7fbcd3f67bc19317f88 (patch)
treee7636f38ae91ff0ef7c84091ccc65048cc45fea5 /examples/dhtd.hs
parentd6fac9a8df0ce872ede54d6a71ca6d6c750eadc9 (diff)
WIP: Adapting DHT to Tox network (part 6).
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index c58b75e1..f81e7131 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -5,6 +5,7 @@
5{-# LANGUAGE ScopedTypeVariables #-} 5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TupleSections #-} 6{-# LANGUAGE TupleSections #-}
7{-# LANGUAGE RecordWildCards #-} 7{-# LANGUAGE RecordWildCards #-}
8{-# LANGUAGE PartialTypeSignatures #-}
8{-# LANGUAGE CPP #-} 9{-# LANGUAGE CPP #-}
9 10
10import Control.Arrow 11import Control.Arrow
@@ -118,7 +119,7 @@ resume = do
118 restore_attempt 119 restore_attempt
119 return saved_nodes 120 return saved_nodes
120 121
121godht :: String -> (NodeAddr IPv4 -> NodeId -> DHT IPv4 b) -> IO b 122godht :: String -> (NodeAddr IPv4 -> NodeId _ -> DHT IPv4 b) -> IO b
122godht p f = do 123godht p f = do
123 a <- btBindAddr p False 124 a <- btBindAddr p False
124 dht def { optTimeout = 5 } a noDebugPrints $ do 125 dht def { optTimeout = 5 } a noDebugPrints $ do
@@ -314,10 +315,10 @@ consip' (ReflectedIP ip) xs = ("to", show ip) : xs
314 315
315reportPong (info,myip) = maybe id consip myip [show $ pPrint info] 316reportPong (info,myip) = maybe id consip myip [show $ pPrint info]
316 317
317reportNodes :: (NodeId, NodeFound IPv4, Maybe ReflectedIP) -> [String] 318reportNodes :: (NodeId _, NodeFound IPv4, Maybe ReflectedIP) -> [String]
318reportNodes (nid,NodeFound ns,myip) = maybe id consip myip $ show (pPrint nid) : map (show . pPrint) ns 319reportNodes (nid,NodeFound ns,myip) = maybe id consip myip $ show (pPrint nid) : map (show . pPrint) ns
319 320
320reportPeers :: (NodeId, GotPeers IPv4, Maybe ReflectedIP) -> [(String,String)] 321reportPeers :: (NodeId _, GotPeers IPv4, Maybe ReflectedIP) -> [(String,String)]
321reportPeers (nid,GotPeers r tok,myip) 322reportPeers (nid,GotPeers r tok,myip)
322 = maybe id consip' myip $ ("from", show (pPrint nid)) 323 = maybe id consip' myip $ ("from", show (pPrint nid))
323 : ("token", show tok) 324 : ("token", show tok)