From: Ramakrishnan Muthukrishnan Date: Fri, 2 Oct 2015 10:57:57 +0000 (+0530) Subject: Peer: rename identifiers that are shadowing already defined identifiers X-Git-Url: https://git.rkrishnan.org/?p=functorrent.git;a=commitdiff_plain;h=f2d028e653430ec10a59b79da8929d8229ffa659 Peer: rename identifiers that are shadowing already defined identifiers --- diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs index b4ed107..c6629a4 100644 --- a/src/FuncTorrent/Peer.hs +++ b/src/FuncTorrent/Peer.hs @@ -82,27 +82,27 @@ connectToPeer (Peer _ ip port) = do return h doHandshake :: Bool -> Handle -> Peer -> ByteString -> String -> IO () -doHandshake True h peer infoHash peerid = do - let hs = genHandshakeMsg infoHash peerid +doHandshake True h p infohash peerid = do + let hs = genHandshakeMsg infohash peerid hPut h hs - putStrLn $ "--> handhake to peer: " ++ show peer + putStrLn $ "--> handhake to peer: " ++ show p _ <- hGet h (length (unpack hs)) - putStrLn $ "<-- handshake from peer: " ++ show peer + putStrLn $ "<-- handshake from peer: " ++ show p return () -doHandshake False h peer infoHash peerid = do - let hs = genHandshakeMsg infoHash peerid +doHandshake False h p infohash peerid = do + let hs = genHandshakeMsg infohash peerid putStrLn "waiting for a handshake" hsMsg <- hGet h (length (unpack hs)) - putStrLn $ "<-- handshake from peer: " ++ show peer + putStrLn $ "<-- handshake from peer: " ++ show p let rxInfoHash = take 20 $ drop 28 hsMsg - if rxInfoHash /= infoHash + if rxInfoHash /= infohash then do putStrLn "infoHashes does not match" hClose h return () else do _ <- hPut h hs - putStrLn $ "--> handhake to peer: " ++ show peer + putStrLn $ "--> handhake to peer: " ++ show p return () bitfieldToList :: [Word8] -> [Integer] @@ -162,7 +162,7 @@ msgLoop pieceStatus file = do PState { meInterested = False, heChoking = True } -> do liftIO $ sendMsg h InterestedMsg gets peer >>= (\p -> liftIO $ putStrLn $ "--> InterestedMsg to peer: " ++ show p) - modify (\st -> st { meInterested = True }) + modify (\st' -> st' { meInterested = True }) msgLoop pieceStatus file PState { meInterested = True, heChoking = False } -> case pickPiece pieceStatus of @@ -197,16 +197,16 @@ msgLoop pieceStatus file = do -- download each of the piece in order msgLoop pieceStatus' file UnChokeMsg -> do - modify (\st -> st {heChoking = False }) + modify (\st' -> st' {heChoking = False }) msgLoop pieceStatus file ChokeMsg -> do - modify (\st -> st {heChoking = True }) + modify (\st' -> st' {heChoking = True }) msgLoop pieceStatus file InterestedMsg -> do - modify (\st -> st {heInterested = True}) + modify (\st' -> st' {heInterested = True}) msgLoop pieceStatus file NotInterestedMsg -> do - modify (\st -> st {heInterested = False}) + modify (\st' -> st' {heInterested = False}) msgLoop pieceStatus file CancelMsg _ _ _ -> -- check if valid index, begin, length msgLoop pieceStatus file