From: Ramakrishnan Muthukrishnan Date: Mon, 13 Jun 2016 15:04:46 +0000 (+0530) Subject: hlint fixes X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/simplejson/__init__.py.html?a=commitdiff_plain;h=b9971fa8982fb919c1557ffdbc95fde660859376;p=functorrent.git hlint fixes --- diff --git a/src/FuncTorrent/Tracker.hs b/src/FuncTorrent/Tracker.hs index 5e059f7..7ad3997 100644 --- a/src/FuncTorrent/Tracker.hs +++ b/src/FuncTorrent/Tracker.hs @@ -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 diff --git a/src/FuncTorrent/Tracker/Http.hs b/src/FuncTorrent/Tracker/Http.hs index fe1f3e1..840b758 100644 --- a/src/FuncTorrent/Tracker/Http.hs +++ b/src/FuncTorrent/Tracker/Http.hs @@ -81,7 +81,7 @@ trackerLoop url port peerId infohash fschan tstate = forever $ do down = FS.bytesWritten st resp <- sendGetRequest url $ mkArgs port peerId up down (left tstate) infohash case Benc.decode resp of - Left e -> do + Left e -> return () -- $ pack (show e) Right trackerInfo -> case parseTrackerResponse trackerInfo of