diff options
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/Tracker/List.hs | 5 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker/Session.hs | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/Tracker/List.hs b/src/Network/BitTorrent/Tracker/List.hs index d92dd4ba..0eb11641 100644 --- a/src/Network/BitTorrent/Tracker/List.hs +++ b/src/Network/BitTorrent/Tracker/List.hs | |||
@@ -19,6 +19,7 @@ module Network.BitTorrent.Tracker.List | |||
19 | , trackerList | 19 | , trackerList |
20 | , shuffleTiers | 20 | , shuffleTiers |
21 | , mapWithURI | 21 | , mapWithURI |
22 | , Network.BitTorrent.Tracker.List.toList | ||
22 | 23 | ||
23 | -- * Traversals | 24 | -- * Traversals |
24 | , traverseAll | 25 | , traverseAll |
@@ -138,6 +139,10 @@ mapWithURI f (TierList xs ) = TierList (L.map (L.map mapEntry) xs) | |||
138 | where | 139 | where |
139 | mapEntry (uri, a) = (uri, f uri a) | 140 | mapEntry (uri, a) = (uri, f uri a) |
140 | 141 | ||
142 | toList :: TrackerList a -> [[TierEntry a]] | ||
143 | toList (Announce e) = [[e]] | ||
144 | toList (TierList xxs) = xxs | ||
145 | |||
141 | {----------------------------------------------------------------------- | 146 | {----------------------------------------------------------------------- |
142 | -- Special traversals (suppressed RPC exceptions) | 147 | -- Special traversals (suppressed RPC exceptions) |
143 | -----------------------------------------------------------------------} | 148 | -----------------------------------------------------------------------} |
diff --git a/src/Network/BitTorrent/Tracker/Session.hs b/src/Network/BitTorrent/Tracker/Session.hs index 74d854c5..e82501dd 100644 --- a/src/Network/BitTorrent/Tracker/Session.hs +++ b/src/Network/BitTorrent/Tracker/Session.hs | |||
@@ -66,7 +66,7 @@ import Data.Torrent.InfoHash | |||
66 | import Data.Torrent.JSON | 66 | import Data.Torrent.JSON |
67 | import Network.BitTorrent.Core | 67 | import Network.BitTorrent.Core |
68 | import Network.BitTorrent.Internal.Cache | 68 | import Network.BitTorrent.Internal.Cache |
69 | import Network.BitTorrent.Tracker.List | 69 | import Network.BitTorrent.Tracker.List as TL |
70 | import Network.BitTorrent.Tracker.Message | 70 | import Network.BitTorrent.Tracker.Message |
71 | import Network.BitTorrent.Tracker.RPC as RPC | 71 | import Network.BitTorrent.Tracker.RPC as RPC |
72 | 72 | ||
@@ -248,8 +248,8 @@ withSession m ih uris = bracket (newSession ih uris) (closeSession m) | |||
248 | getStatus :: Session -> IO Status | 248 | getStatus :: Session -> IO Status |
249 | getStatus Session {..} = readIORef sessionStatus | 249 | getStatus Session {..} = readIORef sessionStatus |
250 | 250 | ||
251 | getSessionState :: Session -> IO (TrackerList TrackerSession) | 251 | getSessionState :: Session -> IO [[TierEntry TrackerSession]] |
252 | getSessionState Session {..} = readMVar sessionTrackers | 252 | getSessionState Session {..} = TL.toList <$> readMVar sessionTrackers |
253 | 253 | ||
254 | -- | Do we need to sent this event to a first working tracker or to | 254 | -- | Do we need to sent this event to a first working tracker or to |
255 | -- the all known good trackers? | 255 | -- the all known good trackers? |
@@ -287,7 +287,7 @@ askPeers _mgr ses = do | |||
287 | L.concat <$> collect (tryTakeData . trackerPeers) list | 287 | L.concat <$> collect (tryTakeData . trackerPeers) list |
288 | 288 | ||
289 | collect :: (a -> IO (Maybe b)) -> TrackerList a -> IO [b] | 289 | collect :: (a -> IO (Maybe b)) -> TrackerList a -> IO [b] |
290 | collect f lst =(catMaybes . toList) <$> traverse f lst | 290 | collect f lst = (catMaybes . F.toList) <$> traverse f lst |
291 | 291 | ||
292 | --sourcePeers :: Session -> Source (PeerAddr IP) | 292 | --sourcePeers :: Session -> Source (PeerAddr IP) |
293 | --sourcePeers | 293 | --sourcePeers |