diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-21 01:43:01 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-21 01:43:01 +0400 |
commit | 7e6d3f9edb55d686391b10386d917ef474f36c84 (patch) | |
tree | d263eeae485d3899092f92a787a4715ec056d8d1 /src/Network/BitTorrent | |
parent | 745340c84cab6740f773a6a93629a72ef36a64b0 (diff) |
Add askOptions function
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 16 |
1 files 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 | |||
17 | -- * Session | 17 | -- * Session |
18 | , DHT | 18 | , DHT |
19 | , runDHT | 19 | , runDHT |
20 | , askOption | ||
20 | 21 | ||
21 | -- * Tokens | 22 | -- * Tokens |
22 | , grantToken | 23 | , grantToken |
@@ -295,6 +296,11 @@ runDHT hs opts naddr action = runResourceT $ do | |||
295 | <*> pure logger | 296 | <*> pure logger |
296 | runReaderT (unDHT (listen >> action)) node | 297 | runReaderT (unDHT (listen >> action)) node |
297 | 298 | ||
299 | |||
300 | askOption :: (Options -> a) -> DHT ip a | ||
301 | askOption f = asks (f . options) | ||
302 | {-# INLINE askOption #-} | ||
303 | |||
298 | {----------------------------------------------------------------------- | 304 | {----------------------------------------------------------------------- |
299 | -- Routing | 305 | -- Routing |
300 | -----------------------------------------------------------------------} | 306 | -----------------------------------------------------------------------} |
@@ -435,11 +441,6 @@ deleteTopic ih p = do | |||
435 | var <- asks announceInfo | 441 | var <- asks announceInfo |
436 | liftIO $ atomically $ modifyTVar' var (S.delete (ih, p)) | 442 | liftIO $ atomically $ modifyTVar' var (S.delete (ih, p)) |
437 | 443 | ||
438 | republish :: DHT ip ThreadId | ||
439 | republish = fork $ do | ||
440 | i <- asks (optReannounce . options) | ||
441 | error "DHT.republish: not implemented" | ||
442 | |||
443 | {----------------------------------------------------------------------- | 444 | {----------------------------------------------------------------------- |
444 | -- Messaging | 445 | -- Messaging |
445 | -----------------------------------------------------------------------} | 446 | -----------------------------------------------------------------------} |
@@ -541,6 +542,11 @@ publish ih p = do | |||
541 | _ <- sourceList [nodes] $= search ih (announceQ ih p) $$ C.take r | 542 | _ <- sourceList [nodes] $= search ih (announceQ ih p) $$ C.take r |
542 | return () | 543 | return () |
543 | 544 | ||
545 | republish :: DHT ip ThreadId | ||
546 | republish = fork $ do | ||
547 | i <- askOption optReannounce | ||
548 | error "DHT.republish: not implemented" | ||
549 | |||
544 | {----------------------------------------------------------------------- | 550 | {----------------------------------------------------------------------- |
545 | -- Handlers | 551 | -- Handlers |
546 | -----------------------------------------------------------------------} | 552 | -----------------------------------------------------------------------} |