diff options
-rw-r--r-- | src/Network/BitTorrent/Tracker.hs | 12 |
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 #-} |
11 | module Network.BitTorrent.Tracker | 11 | module 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 | -- |
184 | data TSession = TSession { | 187 | data 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 | ||
194 | tsession :: Torrent -> PeerID -> PortNumber -> TSession | ||
195 | tsession 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 | -- |
195 | data Progress = Progress { | 203 | data 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 | ||
209 | startProgress :: Integer -> Progress | ||
210 | startProgress = Progress 0 0 | ||
211 | |||
212 | |||
201 | -- | used to avoid boilerplate; do NOT export me | 213 | -- | used to avoid boilerplate; do NOT export me |
202 | genericReq :: TSession -> Progress -> TRequest | 214 | genericReq :: TSession -> Progress -> TRequest |
203 | genericReq ses pr = TRequest { | 215 | genericReq ses pr = TRequest { |