Peer.hs: handle HaveMsg
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 27 Feb 2016 09:27:35 +0000 (14:57 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 27 Feb 2016 09:27:35 +0000 (14:57 +0530)
src/FuncTorrent/Peer.hs

index 05ecc3c961351ddff93b24de9e863f38cb25b749..300101895f7f692f7ca4d99afd615be9db579378 100644 (file)
@@ -151,7 +151,11 @@ msgLoop pieceStatus msgchannel = do
           msgLoop pieceStatus msgchannel
         PortMsg _ ->
           msgLoop pieceStatus msgchannel
-        -- handle RequestMsg, HaveMsg. No need to handle PieceMsg here.
+        HaveMsg idx -> do
+          p <- gets peer
+          let pieceStatus' = updatePieceAvailability pieceStatus p [idx]
+          msgLoop pieceStatus' msgchannel
+        -- handle RequestMsg. No need to handle PieceMsg here.
         -- also BitFieldMsg