]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Tracker.hs
hlint fixes
[functorrent.git] / src / FuncTorrent / Tracker.hs
index 5e059f75c0dda0fb4896ec3941a95869e3013d9f..7ad3997ffe1010ef6c4a7ee4c197119072d2b2ff 100644 (file)
@@ -58,11 +58,6 @@ parseUrl url = TrackerUrl proto host port path
         port = getPort url
         path = getPath url
 
-getTrackerType :: String -> TrackerProtocol
-getTrackerType url | isPrefixOf "http://" url = Http
-                   | isPrefixOf "udp://" url  = Udp
-                   | otherwise                = UnknownProtocol
-
 getHostname :: String -> String
 getHostname url = takeWhile (/= ':') $ drop 2 $ dropWhile (/= '/') url
 
@@ -92,6 +87,12 @@ runTracker msgChannel fsChan infohash port peerId announceList sz = do
     _ ->
       error "Tracker Protocol unimplemented"
 
+getTrackerType :: String -> TrackerProtocol
+getTrackerType url | "http://" `isPrefixOf` url = Http
+                   | "udp://" `isPrefixOf` url  = Udp
+                   | otherwise                = UnknownProtocol
+
+
 msgHandler :: MsgChannel -> StateT TState IO ()
 msgHandler c = forever $ do
   st <- get
@@ -102,14 +103,13 @@ msgHandler c = forever $ do
       recvMsg = readChan c
       sendResponse msg peers =
         case msg of
-          GetConnectedPeersMsg var -> do
+          GetConnectedPeersMsg var ->
             putMVar var peers
-          _ -> do
+          _ ->
             putStrLn "Unhandled Tracker Msg"
 
 getConnectedPeers :: MsgChannel -> IO [Peer]
 getConnectedPeers c = do
   v <- newEmptyMVar
   writeChan c (GetConnectedPeersMsg v)
-  ps <- readMVar v
-  return ps
+  readMVar v