diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-29 18:37:42 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-29 18:37:42 +0400 |
commit | 88b590239ad66f8624723beefefa8b0ef56942e1 (patch) | |
tree | c5e2e3afcb0ca97d469b371cbfada675a462442c /src/Data/Torrent/Block.hs | |
parent | c689257a818c0a7581666f4bdfd4549e52dbd075 (diff) |
More safiety in InfoHash convertions
Diffstat (limited to 'src/Data/Torrent/Block.hs')
-rw-r--r-- | src/Data/Torrent/Block.hs | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/src/Data/Torrent/Block.hs b/src/Data/Torrent/Block.hs index 987de653..37889a7a 100644 --- a/src/Data/Torrent/Block.hs +++ b/src/Data/Torrent/Block.hs | |||
@@ -37,9 +37,6 @@ import Data.Aeson.TH | |||
37 | import qualified Data.ByteString.Lazy as Lazy | 37 | import qualified Data.ByteString.Lazy as Lazy |
38 | import Data.Char | 38 | import Data.Char |
39 | import Data.List as L | 39 | import Data.List as L |
40 | import Data.Binary as B | ||
41 | import Data.Binary.Get as B | ||
42 | import Data.Binary.Put as B | ||
43 | import Data.Serialize as S | 40 | import Data.Serialize as S |
44 | import Text.PrettyPrint | 41 | import Text.PrettyPrint |
45 | import Text.PrettyPrint.Class | 42 | import Text.PrettyPrint.Class |
@@ -110,14 +107,6 @@ putInt :: S.Putter Int | |||
110 | putInt = S.putWord32be . fromIntegral | 107 | putInt = S.putWord32be . fromIntegral |
111 | {-# INLINE putInt #-} | 108 | {-# INLINE putInt #-} |
112 | 109 | ||
113 | getIntB :: B.Get Int | ||
114 | getIntB = fromIntegral <$> B.getWord32be | ||
115 | {-# INLINE getIntB #-} | ||
116 | |||
117 | putIntB :: Int -> B.Put | ||
118 | putIntB = B.putWord32be . fromIntegral | ||
119 | {-# INLINE putIntB #-} | ||
120 | |||
121 | instance Serialize BlockIx where | 110 | instance Serialize BlockIx where |
122 | {-# SPECIALIZE instance Serialize BlockIx #-} | 111 | {-# SPECIALIZE instance Serialize BlockIx #-} |
123 | get = BlockIx <$> getInt | 112 | get = BlockIx <$> getInt |
@@ -131,18 +120,6 @@ instance Serialize BlockIx where | |||
131 | putInt ixLength | 120 | putInt ixLength |
132 | {-# INLINE put #-} | 121 | {-# INLINE put #-} |
133 | 122 | ||
134 | instance Binary BlockIx where | ||
135 | {-# SPECIALIZE instance Binary BlockIx #-} | ||
136 | get = BlockIx <$> getIntB | ||
137 | <*> getIntB | ||
138 | <*> getIntB | ||
139 | {-# INLINE get #-} | ||
140 | |||
141 | put BlockIx {..} = do | ||
142 | putIntB ixPiece | ||
143 | putIntB ixOffset | ||
144 | putIntB ixLength | ||
145 | |||
146 | instance Pretty BlockIx where | 123 | instance Pretty BlockIx where |
147 | pretty BlockIx {..} = | 124 | pretty BlockIx {..} = |
148 | "piece = " <> int ixPiece <> "," <+> | 125 | "piece = " <> int ixPiece <> "," <+> |