diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Session.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Session.hs | 9 |
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 | |||
259 | withMetadataUpdates :: Updates a -> Connected Session a | 259 | withMetadataUpdates :: Updates a -> Connected Session a |
260 | withMetadataUpdates m = do | 260 | withMetadataUpdates 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 | ||
264 | getThisBitfield :: Wire Session Bitfield | 265 | getThisBitfield :: Wire Session Bitfield |
265 | getThisBitfield = do | 266 | getThisBitfield = do |
@@ -381,8 +382,7 @@ handleTransfer (Cancel bix) = filterQueue (not . (transferResponse bix)) | |||
381 | 382 | ||
382 | tryRequestMetadataBlock :: Wire Session () | 383 | tryRequestMetadataBlock :: Wire Session () |
383 | tryRequestMetadataBlock = do | 384 | tryRequestMetadataBlock = 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 | ||
397 | handleMetadata (MetadataData {..}) = do | 397 | handleMetadata (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 | ||
403 | handleMetadata (MetadataReject pix) = do | 402 | handleMetadata (MetadataReject pix) = do |