diff options
-rw-r--r-- | src/Network/BitTorrent/Tracker.hs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/Network/BitTorrent/Tracker.hs b/src/Network/BitTorrent/Tracker.hs index 01e61025..56def0ed 100644 --- a/src/Network/BitTorrent/Tracker.hs +++ b/src/Network/BitTorrent/Tracker.hs | |||
@@ -48,11 +48,12 @@ import Data.BEncode | |||
48 | import Data.ByteString (ByteString) | 48 | import Data.ByteString (ByteString) |
49 | import qualified Data.ByteString as B | 49 | import qualified Data.ByteString as B |
50 | import qualified Data.ByteString.Char8 as BC | 50 | import qualified Data.ByteString.Char8 as BC |
51 | import Data.List as L | 51 | import Data.List as L |
52 | import Data.Map (Map) | 52 | import Data.Map (Map) |
53 | import qualified Data.Map as M | 53 | import qualified Data.Map as M |
54 | import Data.Monoid | 54 | import Data.Monoid |
55 | import Data.IORef | 55 | import Data.IORef |
56 | import Data.Text (Text) | ||
56 | 57 | ||
57 | import Network | 58 | import Network |
58 | import Network.HTTP | 59 | import Network.HTTP |
@@ -260,26 +261,29 @@ withTracker initProgress conn action = bracket start end (action . fst) | |||
260 | 261 | ||
261 | -- | Information about particular torrent. | 262 | -- | Information about particular torrent. |
262 | data ScrapeInfo = ScrapeInfo { | 263 | data ScrapeInfo = ScrapeInfo { |
263 | siComplete :: Int | 264 | -- | Number of seeders - peers with the entire file. |
264 | -- ^ Number of seeders - peers with the entire file. | 265 | siComplete :: !Int |
265 | , siDownloaded :: Int | 266 | |
266 | -- ^ Total number of times the tracker has registered a completion. | 267 | -- | Total number of times the tracker has registered a completion. |
267 | , siIncomplete :: Int | 268 | , siDownloaded :: !Int |
268 | -- ^ Number of leechers. | 269 | |
269 | , siName :: Maybe ByteString | 270 | -- | Number of leechers. |
270 | -- ^ Name of the torrent file, as specified by the "name" | 271 | , siIncomplete :: !Int |
272 | |||
273 | -- | Name of the torrent file, as specified by the "name" | ||
271 | -- file in the info section of the .torrent file. | 274 | -- file in the info section of the .torrent file. |
275 | , siName :: !(Maybe Text) | ||
272 | } deriving (Show, Eq) | 276 | } deriving (Show, Eq) |
273 | 277 | ||
274 | -- | Scrape info about a set of torrents. | 278 | -- | Scrape info about a set of torrents. |
275 | type Scrape = Map InfoHash ScrapeInfo | 279 | type Scrape = Map InfoHash ScrapeInfo |
276 | 280 | ||
277 | instance BEncodable ScrapeInfo where | 281 | instance BEncodable ScrapeInfo where |
278 | toBEncode si = fromAssocs | 282 | toBEncode ScrapeInfo {..} = fromAssocs |
279 | [ "complete" --> siComplete si | 283 | [ "complete" --> siComplete |
280 | , "downloaded" --> siDownloaded si | 284 | , "downloaded" --> siDownloaded |
281 | , "incomplete" --> siIncomplete si | 285 | , "incomplete" --> siIncomplete |
282 | , "name" -->? siName si | 286 | , "name" -->? siName |
283 | ] | 287 | ] |
284 | 288 | ||
285 | fromBEncode (BDict d) = | 289 | fromBEncode (BDict d) = |