import Prelude hiding (lookup, splitAt)
import Control.Concurrent (threadDelay)
-import Control.Concurrent.MVar (MVar, newEmptyMVar, newMVar, readMVar, putMVar, takeMVar)
-import Control.Monad.State
+import Control.Concurrent.MVar (MVar, newEmptyMVar, newMVar, readMVar, putMVar)
import Data.ByteString (ByteString)
import Data.ByteString.Char8 as BC (pack, unpack, splitAt)
import Data.Char (chr)
trackerLoop :: PortNumber -> String -> Metainfo -> TState -> IO ByteString
trackerLoop port peerId m st = do
- up <- liftIO $ readMVar $ uploaded st
- down <- liftIO $ readMVar $ downloaded st
- resp <- liftIO $ sendGetRequest (head . announceList $ m) $ mkArgs port peerId up down m
+ up <- readMVar $ uploaded st
+ down <- readMVar $ downloaded st
+ resp <- sendGetRequest (head . announceList $ m) $ mkArgs port peerId up down m
case decode resp of
Left e -> return $ pack (show e)
Right trackerInfo ->