diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-12 05:54:27 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-12 05:54:27 +0400 |
commit | 83f1ae21c639dcc21b5ce160804ac77587b1db16 (patch) | |
tree | 5cca9be9afa63a4a0047d9337f965de293154b1a /src/Network | |
parent | 72b5356bd146dc2cc55fb8b7770044a26c423e0d (diff) |
Add default instance for Block
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Block.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange/Block.hs b/src/Network/BitTorrent/Exchange/Block.hs index d06fe727..8e3ef91f 100644 --- a/src/Network/BitTorrent/Exchange/Block.hs +++ b/src/Network/BitTorrent/Exchange/Block.hs | |||
@@ -35,6 +35,7 @@ import Control.Applicative | |||
35 | import Data.Aeson.TH | 35 | import Data.Aeson.TH |
36 | import Data.ByteString.Lazy as BL | 36 | import Data.ByteString.Lazy as BL |
37 | import Data.Char | 37 | import Data.Char |
38 | import Data.Default | ||
38 | import Data.List as L | 39 | import Data.List as L |
39 | import Data.Serialize as S | 40 | import Data.Serialize as S |
40 | import Data.Typeable | 41 | import Data.Typeable |
@@ -87,6 +88,10 @@ data BlockIx = BlockIx { | |||
87 | 88 | ||
88 | $(deriveJSON omitRecordPrefix ''BlockIx) | 89 | $(deriveJSON omitRecordPrefix ''BlockIx) |
89 | 90 | ||
91 | -- | First block in torrent. Useful for debugging. | ||
92 | instance Default BlockIx where | ||
93 | def = BlockIx 0 0 defaultTransferSize | ||
94 | |||
90 | getInt :: S.Get Int | 95 | getInt :: S.Get Int |
91 | getInt = fromIntegral <$> S.getWord32be | 96 | getInt = fromIntegral <$> S.getWord32be |
92 | {-# INLINE getInt #-} | 97 | {-# INLINE getInt #-} |