From e9106060a1493f98c88917e9b91f1ae28dbf86f4 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Fri, 24 Jul 2015 13:52:36 +0530
Subject: [PATCH] bug: if I am uninterested and he is choking, send interested
 msg

---
 src/FuncTorrent/Peer.hs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs
index 6a47a35..2130ffe 100644
--- a/src/FuncTorrent/Peer.hs
+++ b/src/FuncTorrent/Peer.hs
@@ -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
 
-- 
2.45.2