summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/Tracker/Protocol.hs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker/Protocol.hs b/src/Network/BitTorrent/Tracker/Protocol.hs
index 7a5039cf..23bbe498 100644
--- a/src/Network/BitTorrent/Tracker/Protocol.hs
+++ b/src/Network/BitTorrent/Tracker/Protocol.hs
@@ -319,13 +319,13 @@ type ScrapeQuery = [InfoHash]
319-- | Overall information about particular torrent. 319-- | Overall information about particular torrent.
320data ScrapeInfo = ScrapeInfo { 320data ScrapeInfo = ScrapeInfo {
321 -- | Number of seeders - peers with the entire file. 321 -- | Number of seeders - peers with the entire file.
322 siComplete :: !Int 322 siComplete :: {-# UNPACK #-} !Int
323 323
324 -- | Total number of times the tracker has registered a completion. 324 -- | Total number of times the tracker has registered a completion.
325 , siDownloaded :: !Int 325 , siDownloaded :: {-# UNPACK #-} !Int
326 326
327 -- | Number of leechers. 327 -- | Number of leechers.
328 , siIncomplete :: !Int 328 , siIncomplete :: {-# UNPACK #-} !Int
329 329
330 -- | Name of the torrent file, as specified by the "name" 330 -- | Name of the torrent file, as specified by the "name"
331 -- file in the info section of the .torrent file. 331 -- file in the info section of the .torrent file.
@@ -349,6 +349,24 @@ instance BEncodable ScrapeInfo where
349 <*> d >--? "name" 349 <*> d >--? "name"
350 fromBEncode _ = decodingError "ScrapeInfo" 350 fromBEncode _ = decodingError "ScrapeInfo"
351 351
352instance Serialize ScrapeInfo where
353 put ScrapeInfo {..} = do
354 putWord32be $ fromIntegral siComplete
355 putWord32be $ fromIntegral siDownloaded
356 putWord32be $ fromIntegral siIncomplete
357
358 get = do
359 seeders <- getWord32be
360 downTimes <- getWord32be
361 leechers <- getWord32be
362
363 return $ ScrapeInfo {
364 siComplete = fromIntegral seeders
365 , siDownloaded = fromIntegral downTimes
366 , siIncomplete = fromIntegral leechers
367 , siName = Nothing
368 }
369
352{----------------------------------------------------------------------- 370{-----------------------------------------------------------------------
353 Tracker 371 Tracker
354-----------------------------------------------------------------------} 372-----------------------------------------------------------------------}