From 7e6d3f9edb55d686391b10386d917ef474f36c84 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 21 Jan 2014 01:43:01 +0400 Subject: Add askOptions function --- src/Network/BitTorrent/DHT/Session.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index b3688a37..9455c465 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs @@ -17,6 +17,7 @@ module Network.BitTorrent.DHT.Session -- * Session , DHT , runDHT + , askOption -- * Tokens , grantToken @@ -295,6 +296,11 @@ runDHT hs opts naddr action = runResourceT $ do <*> pure logger runReaderT (unDHT (listen >> action)) node + +askOption :: (Options -> a) -> DHT ip a +askOption f = asks (f . options) +{-# INLINE askOption #-} + {----------------------------------------------------------------------- -- Routing -----------------------------------------------------------------------} @@ -435,11 +441,6 @@ deleteTopic ih p = do var <- asks announceInfo liftIO $ atomically $ modifyTVar' var (S.delete (ih, p)) -republish :: DHT ip ThreadId -republish = fork $ do - i <- asks (optReannounce . options) - error "DHT.republish: not implemented" - {----------------------------------------------------------------------- -- Messaging -----------------------------------------------------------------------} @@ -541,6 +542,11 @@ publish ih p = do _ <- sourceList [nodes] $= search ih (announceQ ih p) $$ C.take r return () +republish :: DHT ip ThreadId +republish = fork $ do + i <- askOption optReannounce + error "DHT.republish: not implemented" + {----------------------------------------------------------------------- -- Handlers -----------------------------------------------------------------------} -- cgit v1.2.3