diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Session/Metadata.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Exchange/Session/Metadata.hs b/src/Network/BitTorrent/Exchange/Session/Metadata.hs index 174550fa..5d72172a 100644 --- a/src/Network/BitTorrent/Exchange/Session/Metadata.hs +++ b/src/Network/BitTorrent/Exchange/Session/Metadata.hs | |||
@@ -21,6 +21,7 @@ import Control.Monad.State | |||
21 | import Data.ByteString as BS | 21 | import Data.ByteString as BS |
22 | import Data.ByteString.Lazy as BL | 22 | import Data.ByteString.Lazy as BL |
23 | import Data.List as L | 23 | import Data.List as L |
24 | import Data.Tuple | ||
24 | 25 | ||
25 | import Data.BEncode as BE | 26 | import Data.BEncode as BE |
26 | import Data.Torrent | 27 | import Data.Torrent |
@@ -45,7 +46,7 @@ nullStatus ps = Status [] (Block.empty ps) | |||
45 | type Updates a = State Status a | 46 | type Updates a = State Status a |
46 | 47 | ||
47 | runUpdates :: MVar Status -> Updates a -> IO a | 48 | runUpdates :: MVar Status -> Updates a -> IO a |
48 | runUpdates v m = undefined | 49 | runUpdates v m = modifyMVar v (return . swap . runState m) |
49 | 50 | ||
50 | scheduleBlock :: PeerAddr IP -> Updates (Maybe PieceIx) | 51 | scheduleBlock :: PeerAddr IP -> Updates (Maybe PieceIx) |
51 | scheduleBlock addr = do | 52 | scheduleBlock addr = do |
@@ -53,7 +54,7 @@ scheduleBlock addr = do | |||
53 | case spans metadataPieceSize bkt of | 54 | case spans metadataPieceSize bkt of |
54 | [] -> return Nothing | 55 | [] -> return Nothing |
55 | ((off, _ ) : _) -> do | 56 | ((off, _ ) : _) -> do |
56 | let pix = undefined | 57 | let pix = off `div` metadataPieceSize |
57 | pending %= ((addr, pix) :) | 58 | pending %= ((addr, pix) :) |
58 | return (Just pix) | 59 | return (Just pix) |
59 | 60 | ||