summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Exchange/Session.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Session.hs')
-rw-r--r--src/Network/BitTorrent/Exchange/Session.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs
index 8cbce4e3..6e5d94d6 100644
--- a/src/Network/BitTorrent/Exchange/Session.hs
+++ b/src/Network/BitTorrent/Exchange/Session.hs
@@ -259,7 +259,8 @@ withStatusUpdates m = do
259withMetadataUpdates :: Updates a -> Connected Session a 259withMetadataUpdates :: Updates a -> Connected Session a
260withMetadataUpdates m = do 260withMetadataUpdates m = do
261 Session {..} <- asks connSession 261 Session {..} <- asks connSession
262 liftIO $ runUpdates metadata m 262 addr <- asks connRemoteAddr
263 liftIO $ runUpdates metadata addr m
263 264
264getThisBitfield :: Wire Session Bitfield 265getThisBitfield :: Wire Session Bitfield
265getThisBitfield = do 266getThisBitfield = do
@@ -381,8 +382,7 @@ handleTransfer (Cancel bix) = filterQueue (not . (transferResponse bix))
381 382
382tryRequestMetadataBlock :: Wire Session () 383tryRequestMetadataBlock :: Wire Session ()
383tryRequestMetadataBlock = do 384tryRequestMetadataBlock = do
384 addr <- asks connRemoteAddr 385 mpix <- lift $ withMetadataUpdates Metadata.scheduleBlock
385 mpix <- lift $ withMetadataUpdates (Metadata.scheduleBlock addr)
386 case mpix of 386 case mpix of
387 Nothing -> undefined 387 Nothing -> undefined
388 Just pix -> sendMessage (MetadataRequest pix) 388 Just pix -> sendMessage (MetadataRequest pix)
@@ -395,9 +395,8 @@ handleMetadata (MetadataRequest pix) =
395 mkResponse (Just (piece, total)) = MetadataData piece total 395 mkResponse (Just (piece, total)) = MetadataData piece total
396 396
397handleMetadata (MetadataData {..}) = do 397handleMetadata (MetadataData {..}) = do
398 addr <- asks connRemoteAddr
399 ih <- asks connTopic 398 ih <- asks connTopic
400 lift $ withMetadataUpdates (Metadata.pushBlock addr piece ih) 399 lift $ withMetadataUpdates (Metadata.pushBlock piece ih)
401 tryRequestMetadataBlock 400 tryRequestMetadataBlock
402 401
403handleMetadata (MetadataReject pix) = do 402handleMetadata (MetadataReject pix) = do