From: Ramakrishnan Muthukrishnan Date: Tue, 5 May 2015 16:54:48 +0000 (+0530) Subject: rename shadowing identifiers X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/bcase//%22%3C?a=commitdiff_plain;h=23d19e4d65d1935e233e8afcd53c31d0a7a75555;p=functorrent.git rename shadowing identifiers --- diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs index 83cefb4..c2268e8 100644 --- a/src/FuncTorrent/Peer.hs +++ b/src/FuncTorrent/Peer.hs @@ -66,13 +66,13 @@ genHandShakeMsg infoHash peer_id = concat [pstrlen, pstr, reserved, infoHash, pe handShake :: Peer -> ByteString -> String -> IO Handle handShake (Peer _ ip port) infoHash peerid = do let hs = genHandShakeMsg infoHash peerid - handle <- connectTo ip (PortNumber (fromIntegral port)) - hSetBuffering handle LineBuffering - hPut handle hs - rlenBS <- hGet handle 1 + h <- connectTo ip (PortNumber (fromIntegral port)) + hSetBuffering h LineBuffering + hPut h hs + rlenBS <- hGet h 1 let rlen = fromIntegral $ (unpack rlenBS) !! 0 - hGet handle rlen - return handle + hGet h rlen + return h instance Binary PeerMsg where put msg = case msg of @@ -85,9 +85,9 @@ instance Binary PeerMsg where putWord8 2 NotInterestedMsg -> do putWord32be 1 putWord8 3 - HaveMsg index -> do putWord32be 5 - putWord8 4 - putWord32be (fromIntegral index) + HaveMsg i -> do putWord32be 5 + putWord8 4 + putWord32be (fromIntegral i) BitFieldMsg bf -> do putWord32be $ fromIntegral (1 + bfListLen) putWord8 5 mapM_ putWord8 bfList @@ -115,8 +115,8 @@ instance Binary PeerMsg where putWord16be (fromIntegral p) get = do l <- getWord32be - id <- getWord8 - case id of + msgid <- getWord8 + case msgid of 0 -> return ChokeMsg 1 -> return UnChokeMsg 2 -> return InterestedMsg