]> git.rkrishnan.org Git - functorrent.git/commitdiff
bug: if I am uninterested and he is choking, send interested msg
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 24 Jul 2015 08:22:36 +0000 (13:52 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 24 Jul 2015 08:22:36 +0000 (13:52 +0530)
src/FuncTorrent/Peer.hs

index 6a47a35cd658926e1d85d60a9bac3aa98b3f9cc9..2130ffe3d506596fa440f3fb627e39da9c95623a 100644 (file)
@@ -199,13 +199,13 @@ msgLoop state pieceStatus = do
   -- and send a requestmsg.
   let isMeInterested = meInterested state
       isHeChoking = heChoking state
-  if (isMeInterested && isHeChoking)
+  if (not isMeInterested && isHeChoking)
     then
     do
       let h = handle state
       sendMsg h InterestedMsg
       putStrLn $ "--> InterestedMsg to peer: " ++ show (peer state)
-      msgLoop state pieceStatus
+      msgLoop (state { meInterested = True }) pieceStatus
     else
     do
       msg <- getMsg (handle state)
@@ -223,7 +223,7 @@ msgLoop state pieceStatus = do
          -- download each of the piece in order
          msgLoop state pieceStatus'
        UnChokeMsg -> do
-         msgLoop (state {heChoking = False}) pieceStatus
+         msgLoop (state { heChoking = False }) pieceStatus
        _ -> do
          msgLoop state pieceStatus