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, 9 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs
index 467d5745..39d8393a 100644
--- a/src/Network/BitTorrent/Client/Handle.hs
+++ b/src/Network/BitTorrent/Client/Handle.hs
@@ -28,8 +28,9 @@ import Data.Torrent
28import Data.Torrent.InfoHash 28import Data.Torrent.InfoHash
29import Data.Torrent.Magnet 29import Data.Torrent.Magnet
30import Network.BitTorrent.Client.Types 30import Network.BitTorrent.Client.Types
31import Network.BitTorrent.DHT as DHT 31import Network.BitTorrent.DHT as DHT
32import Network.BitTorrent.Tracker as Tracker 32import Network.BitTorrent.Exchange as Exchange
33import Network.BitTorrent.Tracker as Tracker
33 34
34{----------------------------------------------------------------------- 35{-----------------------------------------------------------------------
35-- Safe handle set manupulation 36-- Safe handle set manupulation
@@ -74,8 +75,9 @@ openTorrent :: Torrent -> BitTorrent Handle
74openTorrent t @ Torrent {..} = do 75openTorrent t @ Torrent {..} = do
75 let ih = idInfoHash tInfoDict 76 let ih = idInfoHash tInfoDict
76 allocHandle ih $ do 77 allocHandle ih $ do
77 ses <- liftIO (Tracker.newSession ih (trackerList t)) 78 tses <- liftIO $ Tracker.newSession ih (trackerList t)
78 return $ Handle ih (idPrivate tInfoDict) ses 79 eses <- liftIO $ Exchange.newSession undefined undefined undefined
80 return $ Handle ih (idPrivate tInfoDict) tses eses
79 81
80-- | Use 'nullMagnet' to open handle from 'InfoHash'. 82-- | Use 'nullMagnet' to open handle from 'InfoHash'.
81openMagnet :: Magnet -> BitTorrent Handle 83openMagnet :: Magnet -> BitTorrent Handle
@@ -105,6 +107,9 @@ start Handle {..} = do
105 liftIO $ Tracker.notify trackerManager trackers Tracker.Started 107 liftIO $ Tracker.notify trackerManager trackers Tracker.Started
106 unless private $ do 108 unless private $ do
107 liftDHT $ DHT.insert topic undefined 109 liftDHT $ DHT.insert topic undefined
110 peers <- liftIO $ askPeers trackerManager trackers
111 forM_ peers $ \ peer -> do
112 liftIO $ Exchange.insert peer exchange
108 113
109-- | Stop downloading this torrent. 114-- | Stop downloading this torrent.
110pause :: Handle -> BitTorrent () 115pause :: Handle -> BitTorrent ()