diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-17 11:22:16 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-17 11:22:16 +0400 |
commit | 5656a5ce55509de371d1b89edf3263fb5fa39e74 (patch) | |
tree | 6067f3a8019c615f1e9b67954353bd12f895315c /src | |
parent | e8dd39b3c49e38a8ec7d0e1b474bf8e8170ec51c (diff) |
~ Move the Peer datatype to PeerID module.
We need this to escape recursive module dependencies.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Torrent/PeerID.hs | 11 | ||||
-rw-r--r-- | src/Network/Torrent/Tracker.hs | 8 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/Network/Torrent/PeerID.hs b/src/Network/Torrent/PeerID.hs index d0687f59..6298cb87 100644 --- a/src/Network/Torrent/PeerID.hs +++ b/src/Network/Torrent/PeerID.hs | |||
@@ -4,7 +4,7 @@ | |||
4 | -- though this module exports some other goodies for custom generation. | 4 | -- though this module exports some other goodies for custom generation. |
5 | -- | 5 | -- |
6 | module Network.Torrent.PeerID | 6 | module Network.Torrent.PeerID |
7 | ( PeerID (getPeerID) | 7 | ( Peer(..), PeerID (getPeerID) |
8 | -- * Encoding styles | 8 | -- * Encoding styles |
9 | , azureusStyle, shadowStyle | 9 | , azureusStyle, shadowStyle |
10 | -- * Defaults | 10 | -- * Defaults |
@@ -30,12 +30,21 @@ import Data.Version (Version(Version), versionBranch) | |||
30 | import Data.Time.Clock (getCurrentTime) | 30 | import Data.Time.Clock (getCurrentTime) |
31 | import Data.Time.Format (formatTime) | 31 | import Data.Time.Format (formatTime) |
32 | import System.Locale (defaultTimeLocale) | 32 | import System.Locale (defaultTimeLocale) |
33 | import Network | ||
34 | import Network.Socket | ||
35 | |||
33 | 36 | ||
34 | -- TODO we have linker error here, so manual hardcoded version for a while. | 37 | -- TODO we have linker error here, so manual hardcoded version for a while. |
35 | -- import Paths_network_bittorrent (version) | 38 | -- import Paths_network_bittorrent (version) |
36 | version :: Version | 39 | version :: Version |
37 | version = Version [0, 10, 0, 0] [] | 40 | version = Version [0, 10, 0, 0] [] |
38 | 41 | ||
42 | data Peer = Peer { | ||
43 | peerID :: Maybe PeerID | ||
44 | , peerIP :: HostAddress | ||
45 | , peerPort :: PortNumber | ||
46 | } deriving Show | ||
47 | |||
39 | -- | Peer identifier is exactly 20 bytes long bytestring. | 48 | -- | Peer identifier is exactly 20 bytes long bytestring. |
40 | newtype PeerID = PeerID { getPeerID :: ByteString } | 49 | newtype PeerID = PeerID { getPeerID :: ByteString } |
41 | deriving (Show, Eq, Ord, BEncodable) | 50 | deriving (Show, Eq, Ord, BEncodable) |
diff --git a/src/Network/Torrent/Tracker.hs b/src/Network/Torrent/Tracker.hs index ef2413f6..20cdb2fc 100644 --- a/src/Network/Torrent/Tracker.hs +++ b/src/Network/Torrent/Tracker.hs | |||
@@ -2,7 +2,7 @@ | |||
2 | {-# LANGUAGE OverloadedStrings #-} | 2 | {-# LANGUAGE OverloadedStrings #-} |
3 | module Network.Torrent.Tracker | 3 | module Network.Torrent.Tracker |
4 | ( module Network.Torrent.Tracker.Scrape | 4 | ( module Network.Torrent.Tracker.Scrape |
5 | , Peer(..), Event(..), TRequest(..), TResponse(..) | 5 | , Event(..), TRequest(..), TResponse(..) |
6 | , defaultRequest, defaultPorts | 6 | , defaultRequest, defaultPorts |
7 | , sendRequest | 7 | , sendRequest |
8 | ) | 8 | ) |
@@ -31,12 +31,6 @@ import Network.URI | |||
31 | import Network.Torrent.PeerID | 31 | import Network.Torrent.PeerID |
32 | 32 | ||
33 | 33 | ||
34 | data Peer = Peer { | ||
35 | peerID :: Maybe PeerID | ||
36 | , peerIP :: HostAddress | ||
37 | , peerPort :: PortNumber | ||
38 | } deriving Show | ||
39 | |||
40 | data Event = Started -- ^ For first request. | 34 | data Event = Started -- ^ For first request. |
41 | | Stopped -- ^ Sent when the peer is shutting down. | 35 | | Stopped -- ^ Sent when the peer is shutting down. |
42 | | Completed -- ^ To be sent when the peer completes a download. | 36 | | Completed -- ^ To be sent when the peer completes a download. |