diff options
Diffstat (limited to 'src/Network/BitTorrent/Client/Swarm.hs')
-rw-r--r-- | src/Network/BitTorrent/Client/Swarm.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Client/Swarm.hs b/src/Network/BitTorrent/Client/Swarm.hs index 7fdd1f2f..bd48f8a4 100644 --- a/src/Network/BitTorrent/Client/Swarm.hs +++ b/src/Network/BitTorrent/Client/Swarm.hs | |||
@@ -5,6 +5,7 @@ module Network.BitTorrent.Client.Swarm | |||
5 | ) where | 5 | ) where |
6 | 6 | ||
7 | import Data.Default | 7 | import Data.Default |
8 | import Data.Maybe | ||
8 | import Network | 9 | import Network |
9 | 10 | ||
10 | import Data.Torrent | 11 | import Data.Torrent |
@@ -18,18 +19,14 @@ data Swarm = Swarm | |||
18 | { swarmTopic :: InfoHash | 19 | { swarmTopic :: InfoHash |
19 | , thisPeerId :: PeerId | 20 | , thisPeerId :: PeerId |
20 | , listenerPort :: PortNumber | 21 | , listenerPort :: PortNumber |
21 | , trackerConn :: Tracker | ||
22 | -- , infoDict :: | ||
23 | } | 22 | } |
24 | 23 | ||
25 | newLeecher :: PeerId -> PortNumber -> Torrent -> IO Swarm | 24 | newLeecher :: PeerId -> PortNumber -> Torrent -> IO Swarm |
26 | newLeecher pid port Torrent {..} = do | 25 | newLeecher pid port Torrent {..} = do |
27 | tracker <- connect undefined | ||
28 | return Swarm | 26 | return Swarm |
29 | { swarmTopic = idInfoHash tInfoDict | 27 | { swarmTopic = idInfoHash tInfoDict |
30 | , thisPeerId = pid | 28 | , thisPeerId = pid |
31 | , listenerPort = port | 29 | , listenerPort = port |
32 | , trackerConn = tracker | ||
33 | } | 30 | } |
34 | 31 | ||
35 | getAnnounceQuery :: Swarm -> AnnounceQuery | 32 | getAnnounceQuery :: Swarm -> AnnounceQuery |
@@ -45,5 +42,11 @@ getAnnounceQuery Swarm {..} = AnnounceQuery | |||
45 | 42 | ||
46 | askPeers :: Swarm -> IO [PeerAddr IP] | 43 | askPeers :: Swarm -> IO [PeerAddr IP] |
47 | askPeers s @ Swarm {..} = do | 44 | askPeers s @ Swarm {..} = do |
48 | AnnounceInfo {..} <- RPC.announce (getAnnounceQuery s) trackerConn | 45 | -- AnnounceInfo {..} <- RPC.announce (getAnnounceQuery s) trackerConn |
49 | return (getPeerList respPeers) | 46 | return [] -- (getPeerList respPeers) |
47 | |||
48 | --reannounce :: HTracker -> IO () | ||
49 | --reannounce = undefined | ||
50 | |||
51 | --forceReannounce :: HTracker -> IO () | ||
52 | --forceReannounce = undefined | ||