summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Client
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Client')
-rw-r--r--src/Network/BitTorrent/Client/Handle.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs
index 7aaaf5aa..f539d53a 100644
--- a/src/Network/BitTorrent/Client/Handle.hs
+++ b/src/Network/BitTorrent/Client/Handle.hs
@@ -22,6 +22,7 @@ import Control.Applicative
22import Control.Concurrent 22import Control.Concurrent
23import Control.Monad 23import Control.Monad
24import Control.Monad.Trans 24import Control.Monad.Trans
25import Data.List as L
25import Data.HashMap.Strict as HM 26import Data.HashMap.Strict as HM
26 27
27import Data.Torrent 28import Data.Torrent
@@ -77,7 +78,8 @@ openTorrent rootPath t @ Torrent {..} = do
77 allocHandle ih $ do 78 allocHandle ih $ do
78 c @ Client {..} <- getClient 79 c @ Client {..} <- getClient
79 tses <- liftIO $ Tracker.newSession ih (trackerList t) 80 tses <- liftIO $ Tracker.newSession ih (trackerList t)
80 eses <- liftIO $ Exchange.newSession (externalAddr c) rootPath tInfoDict 81 eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) rootPath
82 tInfoDict
81 return $ Handle ih (idPrivate tInfoDict) tses eses 83 return $ Handle ih (idPrivate tInfoDict) tses eses
82 84
83-- | Use 'nullMagnet' to open handle from 'InfoHash'. 85-- | Use 'nullMagnet' to open handle from 'InfoHash'.
@@ -109,9 +111,11 @@ start Handle {..} = do
109 liftIO $ Tracker.notify trackerManager trackers Tracker.Started 111 liftIO $ Tracker.notify trackerManager trackers Tracker.Started
110 unless private $ do 112 unless private $ do
111 liftDHT $ DHT.insert topic undefined 113 liftDHT $ DHT.insert topic undefined
112 peers <- liftIO $ askPeers trackerManager trackers 114 liftIO $ do
113 forM_ peers $ \ peer -> do 115 peers <- askPeers trackerManager trackers
114 liftIO $ Exchange.insert peer exchange 116 print $ "got: " ++ show (L.length peers) ++ " peers"
117 forM_ peers $ \ peer -> do
118 Exchange.insert peer exchange
115 119
116-- | Stop downloading this torrent. 120-- | Stop downloading this torrent.
117pause :: Handle -> BitTorrent () 121pause :: Handle -> BitTorrent ()