summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Tracker.hs
diff options
context:
space:
mode:
authorSam T <sta.cs.vsu@gmail.com>2013-04-21 07:51:41 +0400
committerSam T <sta.cs.vsu@gmail.com>2013-04-21 07:51:41 +0400
commit07f318c125be9095eaade94e684db0b9f4251936 (patch)
tree04e14652cf8f7604493e1a50845a62622d09669c /src/Network/BitTorrent/Tracker.hs
parent3c32f381afea629e06e8f069e0a3fefc72c8732e (diff)
+ Add exports.
Diffstat (limited to 'src/Network/BitTorrent/Tracker.hs')
-rw-r--r--src/Network/BitTorrent/Tracker.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Tracker.hs b/src/Network/BitTorrent/Tracker.hs
index 3cafbe1d..4275e5fe 100644
--- a/src/Network/BitTorrent/Tracker.hs
+++ b/src/Network/BitTorrent/Tracker.hs
@@ -10,6 +10,8 @@
10{-# LANGUAGE OverloadedStrings #-} 10{-# LANGUAGE OverloadedStrings #-}
11module Network.BitTorrent.Tracker 11module Network.BitTorrent.Tracker
12 ( module Network.BitTorrent.Tracker.Scrape 12 ( module Network.BitTorrent.Tracker.Scrape
13 , Progress(..), TSession(..)
14 , tsession, startProgress
13 15
14 -- * Requests 16 -- * Requests
15 , Event(..), TRequest(..) 17 , Event(..), TRequest(..)
@@ -179,6 +181,7 @@ defaultNumWant = 25
179 181
180-- | 'TSession' (shorthand for Tracker session) combines tracker request 182-- | 'TSession' (shorthand for Tracker session) combines tracker request
181-- fields neccessary for tracker, torrent and client identification. 183-- fields neccessary for tracker, torrent and client identification.
184--
182-- This data is considered as static within one session. 185-- This data is considered as static within one session.
183-- 186--
184data TSession = TSession { 187data TSession = TSession {
@@ -188,8 +191,13 @@ data TSession = TSession {
188 , tsesPort :: PortNumber -- ^ The port number the client is listenning on. 191 , tsesPort :: PortNumber -- ^ The port number the client is listenning on.
189 } deriving Show 192 } deriving Show
190 193
194tsession :: Torrent -> PeerID -> PortNumber -> TSession
195tsession t = TSession (tAnnounce t) (tInfoHash t)
196
197
191-- | 'Progress' contains upload/download/left stats about 198-- | 'Progress' contains upload/download/left stats about
192-- current client state. 199-- current client state.
200--
193-- This data is considered as dynamic within one session. 201-- This data is considered as dynamic within one session.
194-- 202--
195data Progress = Progress { 203data Progress = Progress {
@@ -198,6 +206,10 @@ data Progress = Progress {
198 , prLeft :: Integer -- ^ Total amount of bytes left. 206 , prLeft :: Integer -- ^ Total amount of bytes left.
199 } deriving Show 207 } deriving Show
200 208
209startProgress :: Integer -> Progress
210startProgress = Progress 0 0
211
212
201-- | used to avoid boilerplate; do NOT export me 213-- | used to avoid boilerplate; do NOT export me
202genericReq :: TSession -> Progress -> TRequest 214genericReq :: TSession -> Progress -> TRequest
203genericReq ses pr = TRequest { 215genericReq ses pr = TRequest {