From b4dedc225b719b58505eed20039680d21c3334e7 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 26 Feb 2014 17:33:32 +0400 Subject: Document udp tracker options --- src/Network/BitTorrent/Tracker/RPC/UDP.hs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/Network/BitTorrent/Tracker') diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs index db9c32b3..76188eaf 100644 --- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs @@ -72,22 +72,39 @@ defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec defMultiplier :: Int defMultiplier = 2 --- announce request packet defMaxPacketSize :: Int defMaxPacketSize = 98 +-- | Manager configuration. data Options = Options - { optMaxPacketSize :: {-# UNPACK #-} !Int - - -- | in seconds. + { -- | Max size of a /response/ packet. + -- + -- 'optMaxPacketSize' /must/ be a positive value. + -- + optMaxPacketSize :: {-# UNPACK #-} !Int + + -- | Starting timeout interval. If a response is not received + -- after 'optMinTimeout' then 'Manager' repeat RPC with timeout + -- interval multiplied by 'optMultiplier' and so on until + -- timeout interval reach 'optMaxTimeout'. + -- + -- 'optMinTimeout' /must/ be a positive value. + -- , optMinTimeout :: {-# UNPACK #-} !Int - -- | in seconds. + -- | After 'optMaxTimeout' reached and tracker still not + -- responding both 'announce' and 'scrape' functions will throw + -- 'TimeoutExpired' exception. + -- + -- 'optMaxTimeout' /must/ be greater than 'optMinTimeout'. + -- , optMaxTimeout :: {-# UNPACK #-} !Int + -- | 'optMultiplier' must a positive value. , optMultiplier :: {-# UNPACK #-} !Int } deriving (Show, Eq) +-- | Options suitable for bittorrent client. instance Default Options where def = Options { optMaxPacketSize = defMaxPacketSize -- cgit v1.2.3 From 6dfbb3d98510cb5d043c1b5828f2a42089da3546 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 26 Feb 2014 17:55:29 +0400 Subject: Comment udp tracker constants --- src/Network/BitTorrent/Tracker/RPC/UDP.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Network/BitTorrent/Tracker') diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs index 76188eaf..b0f44ec6 100644 --- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs @@ -60,18 +60,23 @@ import Network.BitTorrent.Tracker.Message -- Options -----------------------------------------------------------------------} +-- | 'System.Timeout.timeout' specific. sec :: Int sec = 1000000 +-- | See defMinTimeout :: Int defMinTimeout = 15 * sec +-- | See defMaxTimeout :: Int defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec +-- | See: defMultiplier :: Int defMultiplier = 2 +-- TODO why 98? defMaxPacketSize :: Int defMaxPacketSize = 98 -- cgit v1.2.3