From 172f5f8efdc3f2c9c01e56f628521e3aa22ef883 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 12 Dec 2013 05:58:31 +0400 Subject: Move metadata exchange default limits to Message.hs --- src/Network/BitTorrent/Exchange/Message.hs | 18 ++++++++++++++++++ src/Network/BitTorrent/Exchange/Wire.hs | 11 ----------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/Network/BitTorrent/Exchange') diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index fee3ad36..0adb8299 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs @@ -81,6 +81,8 @@ module Network.BitTorrent.Exchange.Message -- *** Metadata , ExtendedMetadata (..) , metadataPieceSize + , defaultMetadataFactor + , defaultMaxInfoDictSize ) where import Control.Applicative @@ -882,6 +884,22 @@ putMetadata msg | Just bs <- getMetadataPayload msg = BE.encode msg <> BL.fromStrict bs | otherwise = BE.encode msg +-- | Allows a requesting peer to send 2 'MetadataRequest's for the +-- each piece. +-- +-- See 'Network.BitTorrent.Wire.Options.metadataFactor' for +-- explanation why do we need this limit. +defaultMetadataFactor :: Int +defaultMetadataFactor = 2 + +-- | Usually torrent size do not exceed 1MB. This value limit torrent +-- /content/ size to about 8TB. +-- +-- See 'Network.BitTorrent.Wire.Options.maxInfoDictSize' for +-- explanation why do we need this limit. +defaultMaxInfoDictSize :: Int +defaultMaxInfoDictSize = 10 * 1024 * 1024 + {----------------------------------------------------------------------- -- Extension protocol messages -----------------------------------------------------------------------} diff --git a/src/Network/BitTorrent/Exchange/Wire.hs b/src/Network/BitTorrent/Exchange/Wire.hs index ef53032e..f61e59fa 100644 --- a/src/Network/BitTorrent/Exchange/Wire.hs +++ b/src/Network/BitTorrent/Exchange/Wire.hs @@ -410,17 +410,6 @@ data Options = Options , maxInfoDictSize :: {-# UNPACK #-} !Int } deriving Show --- | Allows a requesting peer to send 2 'MetadataRequest's for the --- each piece. -defaultMetadataFactor :: Int -defaultMetadataFactor = 2 - --- | Usually torrent size do not exceed 1MB. This value limit torrent --- /content/ size to about 8TB. See 'maxInfoDictSize' for explanation --- why do we need this limit. -defaultMaxInfoDictSize :: Int -defaultMaxInfoDictSize = 10 * 1024 * 1024 - -- | Permissive default parameters, most likely you don't need to -- change them. instance Default Options where -- cgit v1.2.3