From 76ef96ac3d5ad8d8ac3921fb0683a8e192e54090 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Fri, 21 Feb 2014 02:48:58 +0400 Subject: Rename startNode to newNode --- src/Network/BitTorrent/Client.hs | 4 ++-- src/Network/BitTorrent/DHT.hs | 6 +++--- src/Network/BitTorrent/DHT/Session.hs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/Client.hs b/src/Network/BitTorrent/Client.hs index 905d3384..bd4993ba 100644 --- a/src/Network/BitTorrent/Client.hs +++ b/src/Network/BitTorrent/Client.hs @@ -98,8 +98,8 @@ initClient opts @ Options {..} logFun = do let mkEx = Exchange.newManager (exchangeOptions pid opts) (connHandler tmap) (_, emgr) <- allocate mkEx Exchange.closeManager - let mkNode = startNode defaultHandlers def optNodeAddr logFun - (_, node) <- allocate mkNode stopNode + let mkNode = DHT.newNode defaultHandlers def optNodeAddr logFun + (_, node) <- allocate mkNode DHT.closeNode resourceMap <- getInternalState return Client diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs index ed42363f..44c55128 100644 --- a/src/Network/BitTorrent/DHT.hs +++ b/src/Network/BitTorrent/DHT.hs @@ -44,8 +44,8 @@ module Network.BitTorrent.DHT , LogFun , Node , defaultHandlers - , startNode - , stopNode + , newNode + , closeNode -- ** Monad , MonadDHT (..) @@ -86,7 +86,7 @@ dht :: Address ip -> IO a -- ^ result. dht opts addr action = do runStderrLoggingT $ LoggingT $ \ logger -> do - bracket (startNode defaultHandlers opts addr logger) stopNode $ + bracket (newNode defaultHandlers opts addr logger) closeNode $ \ node -> runDHT node action {-# INLINE dht #-} diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index 69970918..43bd65e5 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs @@ -33,8 +33,8 @@ module Network.BitTorrent.DHT.Session -- ** Initialization , LogFun , NodeHandler - , startNode - , stopNode + , newNode + , closeNode -- * DHT -- | Use @asks options@ to get options passed to 'startNode' @@ -294,13 +294,13 @@ type NodeHandler ip = Handler (DHT ip) -- | Run DHT session. You /must/ properly close session using -- 'stopNode' function, otherwise socket or other scarce resources may -- leak. -startNode :: Address ip +newNode :: Address ip => [NodeHandler ip] -- ^ handlers to run on accepted queries; -> Options -- ^ various dht options; -> NodeAddr ip -- ^ node address to bind; -> LogFun -- ^ -> IO (Node ip) -- ^ a new DHT node running at given address. -startNode hs opts naddr logger = do +newNode hs opts naddr logger = do s <- createInternalState runInternalState initNode s `onException` closeInternalState s @@ -323,8 +323,8 @@ startNode hs opts naddr logger = do -- | Some resources like listener thread may live for -- some short period of time right after this DHT session closed. -stopNode :: Node ip -> IO () -stopNode Node {..} = closeInternalState resources +closeNode :: Node ip -> IO () +closeNode Node {..} = closeInternalState resources -- | Run DHT operation on the given session. runDHT :: Node ip -> DHT ip a -> IO a -- cgit v1.2.3