summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/DHT')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs4
-rw-r--r--src/Network/BitTorrent/DHT/Routing.hs4
-rw-r--r--src/Network/BitTorrent/DHT/Session.hs12
3 files changed, 10 insertions, 10 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index f7657490..ac53bd91 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -53,7 +53,7 @@ import Data.Monoid
53import Data.Text as T 53import Data.Text as T
54import Network 54import Network
55import Text.PrettyPrint as PP hiding ((<>), ($$)) 55import Text.PrettyPrint as PP hiding ((<>), ($$))
56import Text.PrettyPrint.Class 56import Text.PrettyPrint.HughesPJClass hiding ((<>),($$))
57 57
58import Network.KRPC hiding (Options, def) 58import Network.KRPC hiding (Options, def)
59import Data.Torrent 59import Data.Torrent
@@ -132,7 +132,7 @@ getPeersQ topic NodeInfo {..} = do
132 GotPeers {..} <- GetPeers topic <@> nodeAddr 132 GotPeers {..} <- GetPeers topic <@> nodeAddr
133 let dist = distance (toNodeId topic) nodeId 133 let dist = distance (toNodeId topic) nodeId
134 $(logInfoS) "getPeersQ" $ T.pack 134 $(logInfoS) "getPeersQ" $ T.pack
135 $ "distance: " <> render (pretty dist) <> " , result: " 135 $ "distance: " <> render (pPrint dist) <> " , result: "
136 <> case peers of { Left _ -> "NODES"; Right _ -> "PEERS" } 136 <> case peers of { Left _ -> "NODES"; Right _ -> "PEERS" }
137 return peers 137 return peers
138 138
diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs
index ee295125..cb3cf273 100644
--- a/src/Network/BitTorrent/DHT/Routing.hs
+++ b/src/Network/BitTorrent/DHT/Routing.hs
@@ -71,7 +71,7 @@ import Data.Time.Clock.POSIX
71import Data.Word 71import Data.Word
72import GHC.Generics 72import GHC.Generics
73import Text.PrettyPrint as PP hiding ((<>)) 73import Text.PrettyPrint as PP hiding ((<>))
74import Text.PrettyPrint.Class 74import Text.PrettyPrint.HughesPJClass hiding ((<>),($$))
75 75
76import Data.Torrent 76import Data.Torrent
77import Network.BitTorrent.Address 77import Network.BitTorrent.Address
@@ -325,7 +325,7 @@ instance (Eq ip, Serialize ip) => Serialize (Table ip)
325 325
326-- | Shape of the table. 326-- | Shape of the table.
327instance Pretty (Table ip) where 327instance Pretty (Table ip) where
328 pretty t 328 pPrint t
329 | bucketCount < 6 = hcat $ punctuate ", " $ L.map PP.int ss 329 | bucketCount < 6 = hcat $ punctuate ", " $ L.map PP.int ss
330 | otherwise = brackets $ 330 | otherwise = brackets $
331 PP.int (L.sum ss) <> " nodes, " <> 331 PP.int (L.sum ss) <> " nodes, " <>
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs
index 208f8ec8..0c806db2 100644
--- a/src/Network/BitTorrent/DHT/Session.hs
+++ b/src/Network/BitTorrent/DHT/Session.hs
@@ -90,7 +90,7 @@ import Network (PortNumber)
90import System.Log.FastLogger 90import System.Log.FastLogger
91import System.Random (randomIO) 91import System.Random (randomIO)
92import Text.PrettyPrint as PP hiding ((<>), ($$)) 92import Text.PrettyPrint as PP hiding ((<>), ($$))
93import Text.PrettyPrint.Class 93import Text.PrettyPrint.HughesPJClass hiding ((<>),($$))
94 94
95import Data.Torrent as Torrent 95import Data.Torrent as Torrent
96import Network.KRPC hiding (Options, def) 96import Network.KRPC hiding (Options, def)
@@ -340,7 +340,7 @@ routing = runRouting probeNode refreshNodes getTimestamp
340 340
341probeNode :: Address ip => NodeAddr ip -> DHT ip Bool 341probeNode :: Address ip => NodeAddr ip -> DHT ip Bool
342probeNode addr = do 342probeNode addr = do
343 $(logDebugS) "routing.questionable_node" (T.pack (render (pretty addr))) 343 $(logDebugS) "routing.questionable_node" (T.pack (render (pPrint addr)))
344 result <- try $ Ping <@> addr 344 result <- try $ Ping <@> addr
345 let _ = result :: Either SomeException Ping 345 let _ = result :: Either SomeException Ping
346 return $ either (const False) (const True) result 346 return $ either (const False) (const True) result
@@ -351,7 +351,7 @@ probeNode addr = do
351-- FIXME do not use getClosest sinse we should /refresh/ them 351-- FIXME do not use getClosest sinse we should /refresh/ them
352refreshNodes :: Address ip => NodeId -> DHT ip [NodeInfo ip] 352refreshNodes :: Address ip => NodeId -> DHT ip [NodeInfo ip]
353refreshNodes nid = do 353refreshNodes nid = do
354 $(logDebugS) "routing.refresh_bucket" (T.pack (render (pretty nid))) 354 $(logDebugS) "routing.refresh_bucket" (T.pack (render (pPrint nid)))
355 nodes <- getClosest nid 355 nodes <- getClosest nid
356 nss <- forM (nodeAddr <$> nodes) $ \ addr -> do 356 nss <- forM (nodeAddr <$> nodes) $ \ addr -> do
357 NodeFound ns <- FindNode nid <@> addr 357 NodeFound ns <- FindNode nid <@> addr
@@ -361,7 +361,7 @@ refreshNodes nid = do
361getTimestamp :: DHT ip Timestamp 361getTimestamp :: DHT ip Timestamp
362getTimestamp = do 362getTimestamp = do
363 utcTime <- liftIO $ getCurrentTime 363 utcTime <- liftIO $ getCurrentTime
364 $(logDebugS) "routing.make_timestamp" (T.pack (render (pretty utcTime))) 364 $(logDebugS) "routing.make_timestamp" (T.pack (render (pPrint utcTime)))
365 return $ utcTimeToPOSIXSeconds utcTime 365 return $ utcTimeToPOSIXSeconds utcTime
366 366
367{----------------------------------------------------------------------- 367{-----------------------------------------------------------------------
@@ -419,11 +419,11 @@ insertNode info = fork $ do
419 case result of 419 case result of
420 Nothing -> do 420 Nothing -> do
421 $(logDebugS) "insertNode" $ "Routing table is full: " 421 $(logDebugS) "insertNode" $ "Routing table is full: "
422 <> T.pack (show (pretty t)) 422 <> T.pack (show (pPrint t))
423 return t 423 return t
424 Just t' -> do 424 Just t' -> do
425 let logMsg = "Routing table updated: " 425 let logMsg = "Routing table updated: "
426 <> pretty t <> " -> " <> pretty t' 426 <> pPrint t <> " -> " <> pPrint t'
427 $(logDebugS) "insertNode" (T.pack (render logMsg)) 427 $(logDebugS) "insertNode" (T.pack (render logMsg))
428 return t' 428 return t'
429 429