diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Data/Torrent/Block.hs | 6 | ||||
-rw-r--r-- | src/Data/Torrent/Piece.hs | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/Data/Torrent/Block.hs b/src/Data/Torrent/Block.hs index 8aba4a6e..fa6fe8bd 100644 --- a/src/Data/Torrent/Block.hs +++ b/src/Data/Torrent/Block.hs | |||
@@ -3,6 +3,7 @@ module Data.Torrent.Block | |||
3 | ( -- * Block attribytes | 3 | ( -- * Block attribytes |
4 | BlockLIx | 4 | BlockLIx |
5 | , PieceLIx | 5 | , PieceLIx |
6 | , defaultBlockSize -- TODO use data-default | ||
6 | 7 | ||
7 | -- * Block index | 8 | -- * Block index |
8 | , BlockIx(..) | 9 | , BlockIx(..) |
@@ -33,6 +34,11 @@ import Data.Serialize as S | |||
33 | 34 | ||
34 | import Text.PrettyPrint | 35 | import Text.PrettyPrint |
35 | 36 | ||
37 | |||
38 | -- | Widely used semi-official block size. | ||
39 | defaultBlockSize :: Int | ||
40 | defaultBlockSize = 16 * 1024 | ||
41 | |||
36 | {----------------------------------------------------------------------- | 42 | {----------------------------------------------------------------------- |
37 | Block Index | 43 | Block Index |
38 | -----------------------------------------------------------------------} | 44 | -----------------------------------------------------------------------} |
diff --git a/src/Data/Torrent/Piece.hs b/src/Data/Torrent/Piece.hs index bff6f948..341c3d6b 100644 --- a/src/Data/Torrent/Piece.hs +++ b/src/Data/Torrent/Piece.hs | |||
@@ -5,6 +5,8 @@ | |||
5 | -- Stability : experimental | 5 | -- Stability : experimental |
6 | -- Portability : portable | 6 | -- Portability : portable |
7 | -- | 7 | -- |
8 | -- Torrent content validation. | ||
9 | -- | ||
8 | {-# LANGUAGE TemplateHaskell #-} | 10 | {-# LANGUAGE TemplateHaskell #-} |
9 | {-# LANGUAGE DeriveDataTypeable #-} | 11 | {-# LANGUAGE DeriveDataTypeable #-} |
10 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | 12 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
@@ -12,9 +14,8 @@ module Data.Torrent.Piece | |||
12 | ( -- * Piece attributes | 14 | ( -- * Piece attributes |
13 | -- ** Piece size | 15 | -- ** Piece size |
14 | PieceSize (..) | 16 | PieceSize (..) |
15 | , defaultBlockSize -- TODO use data-default | ||
16 | , optimalPieceCount | 17 | , optimalPieceCount |
17 | , defaultPieceSize -- TODO use data-default | 18 | , defaultPieceSize |
18 | 19 | ||
19 | -- ** Piece index | 20 | -- ** Piece index |
20 | , PieceIx | 21 | , PieceIx |
@@ -57,6 +58,8 @@ import Data.Text.Encoding as T | |||
57 | import Data.Typeable | 58 | import Data.Typeable |
58 | import Text.PrettyPrint | 59 | import Text.PrettyPrint |
59 | 60 | ||
61 | import Data.Torrent.Block | ||
62 | |||
60 | 63 | ||
61 | class Lint a where | 64 | class Lint a where |
62 | lint :: a -> Either String a | 65 | lint :: a -> Either String a |
@@ -74,10 +77,6 @@ newtype PieceSize = PieceSize Int | |||
74 | , BEncode, ToJSON, FromJSON | 77 | , BEncode, ToJSON, FromJSON |
75 | ) | 78 | ) |
76 | 79 | ||
77 | -- | Widely used semi-official block size. | ||
78 | defaultBlockSize :: Int | ||
79 | defaultBlockSize = 16 * 1024 | ||
80 | |||
81 | maxPieceSize :: Int | 80 | maxPieceSize :: Int |
82 | maxPieceSize = 4 * 1024 * 1024 | 81 | maxPieceSize = 4 * 1024 * 1024 |
83 | {-# INLINE maxPieceSize #-} | 82 | {-# INLINE maxPieceSize #-} |