summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/Tracker.hs36
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
48import Data.ByteString (ByteString) 48import Data.ByteString (ByteString)
49import qualified Data.ByteString as B 49import qualified Data.ByteString as B
50import qualified Data.ByteString.Char8 as BC 50import qualified Data.ByteString.Char8 as BC
51import Data.List as L 51import Data.List as L
52import Data.Map (Map) 52import Data.Map (Map)
53import qualified Data.Map as M 53import qualified Data.Map as M
54import Data.Monoid 54import Data.Monoid
55import Data.IORef 55import Data.IORef
56import Data.Text (Text)
56 57
57import Network 58import Network
58import Network.HTTP 59import 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.
262data ScrapeInfo = ScrapeInfo { 263data 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.
275type Scrape = Map InfoHash ScrapeInfo 279type Scrape = Map InfoHash ScrapeInfo
276 280
277instance BEncodable ScrapeInfo where 281instance 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) =