diff options
Diffstat (limited to 'src/System/Torrent')
-rw-r--r-- | src/System/Torrent/Storage.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs index 955c1746..363f94ef 100644 --- a/src/System/Torrent/Storage.hs +++ b/src/System/Torrent/Storage.hs | |||
@@ -143,9 +143,7 @@ putBlk blk @ Block {..} st @ Storage {..} | |||
143 | -- let blkIx = undefined | 143 | -- let blkIx = undefined |
144 | -- bm <- readTVarIO blocks | 144 | -- bm <- readTVarIO blocks |
145 | -- unless (member blkIx bm) $ do | 145 | -- unless (member blkIx bm) $ do |
146 | writeBytes (blkInterval (pieceLength session) blk) | 146 | writeBytes (blkInterval (pieceLength session) blk) blkData payload |
147 | (Lazy.fromChunks [blkData]) | ||
148 | payload | ||
149 | 147 | ||
150 | markBlock blk st | 148 | markBlock blk st |
151 | validatePiece blkPiece st | 149 | validatePiece blkPiece st |
@@ -166,7 +164,7 @@ getBlk ix @ BlockIx {..} st @ Storage {..} | |||
166 | = liftIO $ {-# SCC getBlk #-} do | 164 | = liftIO $ {-# SCC getBlk #-} do |
167 | -- TODO check if __piece__ is available | 165 | -- TODO check if __piece__ is available |
168 | bs <- readBytes (ixInterval (pieceLength session) ix) payload | 166 | bs <- readBytes (ixInterval (pieceLength session) ix) payload |
169 | return $ Block ixPiece ixOffset (Lazy.toStrict bs) | 167 | return $ Block ixPiece ixOffset bs |
170 | 168 | ||
171 | getPiece :: PieceIx -> Storage -> IO ByteString | 169 | getPiece :: PieceIx -> Storage -> IO ByteString |
172 | getPiece pix st @ Storage {..} = {-# SCC getPiece #-} do | 170 | getPiece pix st @ Storage {..} = {-# SCC getPiece #-} do |
@@ -220,4 +218,5 @@ ixInterval pieceSize BlockIx {..} = | |||
220 | 218 | ||
221 | blkInterval :: Int -> Block -> FixedInterval | 219 | blkInterval :: Int -> Block -> FixedInterval |
222 | blkInterval pieceSize Block {..} = | 220 | blkInterval pieceSize Block {..} = |
223 | Fixed.interval (blkPiece * pieceSize + blkOffset) (B.length blkData) \ No newline at end of file | 221 | Fixed.interval (blkPiece * pieceSize + blkOffset) |
222 | (fromIntegral (Lazy.length blkData)) \ No newline at end of file | ||