From 07f318c125be9095eaade94e684db0b9f4251936 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sun, 21 Apr 2013 07:51:41 +0400 Subject: + Add exports. --- src/Network/BitTorrent/Tracker.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Network/BitTorrent/Tracker.hs') 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 @@ {-# LANGUAGE OverloadedStrings #-} module Network.BitTorrent.Tracker ( module Network.BitTorrent.Tracker.Scrape + , Progress(..), TSession(..) + , tsession, startProgress -- * Requests , Event(..), TRequest(..) @@ -179,6 +181,7 @@ defaultNumWant = 25 -- | 'TSession' (shorthand for Tracker session) combines tracker request -- fields neccessary for tracker, torrent and client identification. +-- -- This data is considered as static within one session. -- data TSession = TSession { @@ -188,8 +191,13 @@ data TSession = TSession { , tsesPort :: PortNumber -- ^ The port number the client is listenning on. } deriving Show +tsession :: Torrent -> PeerID -> PortNumber -> TSession +tsession t = TSession (tAnnounce t) (tInfoHash t) + + -- | 'Progress' contains upload/download/left stats about -- current client state. +-- -- This data is considered as dynamic within one session. -- data Progress = Progress { @@ -198,6 +206,10 @@ data Progress = Progress { , prLeft :: Integer -- ^ Total amount of bytes left. } deriving Show +startProgress :: Integer -> Progress +startProgress = Progress 0 0 + + -- | used to avoid boilerplate; do NOT export me genericReq :: TSession -> Progress -> TRequest genericReq ses pr = TRequest { -- cgit v1.2.3