diff options
Diffstat (limited to 'src/Network/BitTorrent/DHT')
-rw-r--r-- | src/Network/BitTorrent/DHT/Query.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT/Routing.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 12 |
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 | |||
53 | import Data.Text as T | 53 | import Data.Text as T |
54 | import Network | 54 | import Network |
55 | import Text.PrettyPrint as PP hiding ((<>), ($$)) | 55 | import Text.PrettyPrint as PP hiding ((<>), ($$)) |
56 | import Text.PrettyPrint.Class | 56 | import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) |
57 | 57 | ||
58 | import Network.KRPC hiding (Options, def) | 58 | import Network.KRPC hiding (Options, def) |
59 | import Data.Torrent | 59 | import 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 | |||
71 | import Data.Word | 71 | import Data.Word |
72 | import GHC.Generics | 72 | import GHC.Generics |
73 | import Text.PrettyPrint as PP hiding ((<>)) | 73 | import Text.PrettyPrint as PP hiding ((<>)) |
74 | import Text.PrettyPrint.Class | 74 | import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) |
75 | 75 | ||
76 | import Data.Torrent | 76 | import Data.Torrent |
77 | import Network.BitTorrent.Address | 77 | import 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. |
327 | instance Pretty (Table ip) where | 327 | instance 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) | |||
90 | import System.Log.FastLogger | 90 | import System.Log.FastLogger |
91 | import System.Random (randomIO) | 91 | import System.Random (randomIO) |
92 | import Text.PrettyPrint as PP hiding ((<>), ($$)) | 92 | import Text.PrettyPrint as PP hiding ((<>), ($$)) |
93 | import Text.PrettyPrint.Class | 93 | import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) |
94 | 94 | ||
95 | import Data.Torrent as Torrent | 95 | import Data.Torrent as Torrent |
96 | import Network.KRPC hiding (Options, def) | 96 | import Network.KRPC hiding (Options, def) |
@@ -340,7 +340,7 @@ routing = runRouting probeNode refreshNodes getTimestamp | |||
340 | 340 | ||
341 | probeNode :: Address ip => NodeAddr ip -> DHT ip Bool | 341 | probeNode :: Address ip => NodeAddr ip -> DHT ip Bool |
342 | probeNode addr = do | 342 | probeNode 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 |
352 | refreshNodes :: Address ip => NodeId -> DHT ip [NodeInfo ip] | 352 | refreshNodes :: Address ip => NodeId -> DHT ip [NodeInfo ip] |
353 | refreshNodes nid = do | 353 | refreshNodes 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 | |||
361 | getTimestamp :: DHT ip Timestamp | 361 | getTimestamp :: DHT ip Timestamp |
362 | getTimestamp = do | 362 | getTimestamp = 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 | ||