msgLoop :: PeerState -> PieceMap -> IO ()
msgLoop state pieceStatus | meInterested state == False &&
heChoking state == True = do
- -- if meInterested and he NOT Choking, pick a piece to download
- -- and send a requestmsg.
+ -- if me NOT Interested and she is Choking, tell her that
+ -- I am interested.
let h = handle state
sendMsg h InterestedMsg
putStrLn $ "--> InterestedMsg to peer: " ++ show (peer state)
msgLoop (state { meInterested = True }) pieceStatus
| meInterested state == True &&
heChoking state == False =
+ -- if me Interested and she not Choking, send her a request
+ -- for a piece.
case pickPiece pieceStatus of
Nothing -> putStrLn "Nothing to download"
Just workPiece -> do