]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Peer.hs
keep hlint happy
[functorrent.git] / src / FuncTorrent / Peer.hs
index 490f08014f14344b046173d982fccebbb4d49390..54761211d38eaa98fe1c7ee58bd97465df7a8ac7 100644 (file)
@@ -28,10 +28,10 @@ type IP = String
 type Port = Integer
 
 data PeerState = PeerState { handle :: Handle
-                           , am_choking :: Bool
-                           , am_interested :: Bool
-                           , peer_choking :: Bool
-                           , peer_interested :: Bool}
+                           , amChoking :: Bool
+                           , amInterested :: Bool
+                           , peerChoking :: Bool
+                           , peerInterested :: Bool}
 
 -- Maintain info on every piece and the current state of it.
 -- should probably be a TVar.
@@ -173,14 +173,14 @@ bitfieldToList :: [Word8] -> [Integer]
 bitfieldToList bs = go bs 0
   where go [] _ = []
         go (b:bs') pos =
-          let setBits = [pos*8 + (toInteger i) | i <- [0..8], testBit b i]
+          let setBits = [pos*8 + toInteger i | i <- [0..8], testBit b i]
           in
-           setBits ++ (go bs' (pos + 1))
+           setBits ++ go bs' (pos + 1)
 
 -- downloadPiece :: Integer -> Handle -> IO ()
 
 createDummyFile :: FilePath -> Int -> IO ()
-createDummyFile path size = do
+createDummyFile path size =
   writeFile path (BC.replicate size '\0')
 
 -- loop1 :: shake hands with all peers, find out the pieces they have, form PieceData.
@@ -196,13 +196,13 @@ msgLoop h pieceHash =
      case msg of
       BitFieldMsg bss -> do
         let pieceList = bitfieldToList (unpack bss)
-        putStrLn (show pieceList)
+        print pieceList
         -- download each of the piece in order
-      _ -> putStrLn (show msg)
+      _ -> print msg
 
 handlePeerMsgs :: Peer -> Metainfo -> String -> (String -> IO ()) -> IO ()
 handlePeerMsgs p m peerId logFn = do
   h <- handShake p (infoHash m) peerId
-  logFn "handShake"
+  logFn "handShake"
   msgLoop h (pieces (info m))