diff options
Diffstat (limited to 'src/Network/BitTorrent/Client/Handle.hs')
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index a1fe7b9e..258af3fb 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs | |||
@@ -82,10 +82,10 @@ openTorrent rootPath t @ Torrent {..} = do | |||
82 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) | 82 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) |
83 | rootPath tInfoDict | 83 | rootPath tInfoDict |
84 | return $ Handle | 84 | return $ Handle |
85 | { topic = ih | 85 | { handleTopic = ih |
86 | , private = idPrivate tInfoDict | 86 | , handlePrivate = idPrivate tInfoDict |
87 | , trackers = tses | 87 | , handleTrackers = tses |
88 | , exchange = eses | 88 | , handleExchange = eses |
89 | } | 89 | } |
90 | 90 | ||
91 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. | 91 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. |
@@ -97,10 +97,10 @@ openMagnet rootPath uri @ Magnet {..} = do | |||
97 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) | 97 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) |
98 | rootPath (error "openMagnet" exactTopic) | 98 | rootPath (error "openMagnet" exactTopic) |
99 | return $ Handle | 99 | return $ Handle |
100 | { topic = exactTopic | 100 | { handleTopic = exactTopic |
101 | , private = False | 101 | , handlePrivate = False |
102 | , trackers = tses | 102 | , handleTrackers = tses |
103 | , exchange = eses | 103 | , handleExchange = eses |
104 | } | 104 | } |
105 | 105 | ||
106 | -- | Stop torrent and destroy all sessions. You don't need to close | 106 | -- | Stop torrent and destroy all sessions. You don't need to close |
@@ -109,10 +109,10 @@ openMagnet rootPath uri @ Magnet {..} = do | |||
109 | -- may block. | 109 | -- may block. |
110 | closeHandle :: Handle -> BitTorrent () | 110 | closeHandle :: Handle -> BitTorrent () |
111 | closeHandle h @ Handle {..} = do | 111 | closeHandle h @ Handle {..} = do |
112 | freeHandle topic $ do | 112 | freeHandle handleTopic $ do |
113 | stop h | 113 | stop h |
114 | liftIO $ Exchange.closeSession exchange | 114 | liftIO $ Exchange.closeSession handleExchange |
115 | liftIO $ Tracker.closeSession trackers | 115 | liftIO $ Tracker.closeSession handleTrackers |
116 | 116 | ||
117 | {----------------------------------------------------------------------- | 117 | {----------------------------------------------------------------------- |
118 | -- Control | 118 | -- Control |
@@ -125,14 +125,14 @@ closeHandle h @ Handle {..} = do | |||
125 | start :: Handle -> BitTorrent () | 125 | start :: Handle -> BitTorrent () |
126 | start Handle {..} = do | 126 | start Handle {..} = do |
127 | Client {..} <- getClient | 127 | Client {..} <- getClient |
128 | liftIO $ Tracker.notify trackerManager trackers Tracker.Started | 128 | liftIO $ Tracker.notify trackerManager handleTrackers Tracker.Started |
129 | unless private $ do | 129 | unless handlePrivate $ do |
130 | liftDHT $ DHT.insert topic (error "start") | 130 | liftDHT $ DHT.insert handleTopic (error "start") |
131 | liftIO $ do | 131 | liftIO $ do |
132 | peers <- askPeers trackerManager trackers | 132 | peers <- askPeers trackerManager handleTrackers |
133 | print $ "got: " ++ show (L.length peers) ++ " peers" | 133 | print $ "got: " ++ show (L.length peers) ++ " peers" |
134 | forM_ peers $ \ peer -> do | 134 | forM_ peers $ \ peer -> do |
135 | Exchange.connect peer exchange | 135 | Exchange.connect peer handleExchange |
136 | 136 | ||
137 | -- | Stop downloading this torrent. | 137 | -- | Stop downloading this torrent. |
138 | pause :: Handle -> BitTorrent () | 138 | pause :: Handle -> BitTorrent () |
@@ -142,9 +142,9 @@ pause _ = return () | |||
142 | stop :: Handle -> BitTorrent () | 142 | stop :: Handle -> BitTorrent () |
143 | stop Handle {..} = do | 143 | stop Handle {..} = do |
144 | Client {..} <- getClient | 144 | Client {..} <- getClient |
145 | unless private $ do | 145 | unless handlePrivate $ do |
146 | liftDHT $ DHT.delete topic (error "stop") | 146 | liftDHT $ DHT.delete handleTopic (error "stop") |
147 | liftIO $ Tracker.notify trackerManager trackers Tracker.Stopped | 147 | liftIO $ Tracker.notify trackerManager handleTrackers Tracker.Stopped |
148 | 148 | ||
149 | {----------------------------------------------------------------------- | 149 | {----------------------------------------------------------------------- |
150 | -- Query | 150 | -- Query |