summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Client/Handle.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Client/Handle.hs')
-rw-r--r--src/Network/BitTorrent/Client/Handle.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs
index 97ffc637..9601e691 100644
--- a/src/Network/BitTorrent/Client/Handle.hs
+++ b/src/Network/BitTorrent/Client/Handle.hs
@@ -71,16 +71,19 @@ lookupHandle ih = do
71-- Initialization 71-- Initialization
72-----------------------------------------------------------------------} 72-----------------------------------------------------------------------}
73 73
74newExchangeSession :: FilePath -> InfoDict -> BitTorrent Exchange.Session
75newExchangeSession rootPath dict = do
76 c @ Client {..} <- getClient
77 liftIO $ Exchange.newSession clientLogger (externalAddr c) rootPath dict
78
74-- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open 79-- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open
75-- handle from 'InfoDict'. This operation do not block. 80-- handle from 'InfoDict'. This operation do not block.
76openTorrent :: FilePath -> Torrent -> BitTorrent Handle 81openTorrent :: FilePath -> Torrent -> BitTorrent Handle
77openTorrent rootPath t @ Torrent {..} = do 82openTorrent rootPath t @ Torrent {..} = do
78 let ih = idInfoHash tInfoDict 83 let ih = idInfoHash tInfoDict
79 allocHandle ih $ do 84 allocHandle ih $ do
80 c @ Client {..} <- getClient
81 tses <- liftIO $ Tracker.newSession ih (trackerList t) 85 tses <- liftIO $ Tracker.newSession ih (trackerList t)
82 eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) 86 eses <- newExchangeSession rootPath tInfoDict
83 rootPath tInfoDict
84 return $ Handle 87 return $ Handle
85 { handleTopic = ih 88 { handleTopic = ih
86 , handlePrivate = idPrivate tInfoDict 89 , handlePrivate = idPrivate tInfoDict
@@ -92,10 +95,8 @@ openTorrent rootPath t @ Torrent {..} = do
92openMagnet :: FilePath -> Magnet -> BitTorrent Handle 95openMagnet :: FilePath -> Magnet -> BitTorrent Handle
93openMagnet rootPath uri @ Magnet {..} = do 96openMagnet rootPath uri @ Magnet {..} = do
94 allocHandle exactTopic $ do 97 allocHandle exactTopic $ do
95 c @ Client {..} <- getClient
96 tses <- liftIO $ Tracker.newSession exactTopic def 98 tses <- liftIO $ Tracker.newSession exactTopic def
97 eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) 99 eses <- newExchangeSession rootPath (error "openMagnet" exactTopic)
98 rootPath (error "openMagnet" exactTopic)
99 return $ Handle 100 return $ Handle
100 { handleTopic = exactTopic 101 { handleTopic = exactTopic
101 , handlePrivate = False 102 , handlePrivate = False