From 2c7eb149a09df0349137dc518569310d8dea1461 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Mon, 24 Feb 2014 14:23:58 +0400 Subject: Simplify exchange manager handler --- src/Network/BitTorrent/Client.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Network/BitTorrent/Client.hs') diff --git a/src/Network/BitTorrent/Client.hs b/src/Network/BitTorrent/Client.hs index bd4993ba..fce8cfe2 100644 --- a/src/Network/BitTorrent/Client.hs +++ b/src/Network/BitTorrent/Client.hs @@ -84,7 +84,11 @@ exchangeOptions pid Options {..} = Exchange.Options } connHandler :: MVar (HashMap InfoHash Handle) -> Exchange.Handler -connHandler _tmap = undefined +connHandler tmap ih = do + m <- readMVar tmap + case HM.lookup ih m of + Nothing -> error "torrent not found" + Just (Handle {..}) -> return exchange initClient :: Options -> LogFun -> ResIO Client initClient opts @ Options {..} logFun = do -- cgit v1.2.3