From 5656a5ce55509de371d1b89edf3263fb5fa39e74 Mon Sep 17 00:00:00 2001 From: Sam T Date: Wed, 17 Apr 2013 11:22:16 +0400 Subject: ~ Move the Peer datatype to PeerID module. We need this to escape recursive module dependencies. --- src/Network/Torrent/PeerID.hs | 11 ++++++++++- 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 @@ -- though this module exports some other goodies for custom generation. -- module Network.Torrent.PeerID - ( PeerID (getPeerID) + ( Peer(..), PeerID (getPeerID) -- * Encoding styles , azureusStyle, shadowStyle -- * Defaults @@ -30,12 +30,21 @@ import Data.Version (Version(Version), versionBranch) import Data.Time.Clock (getCurrentTime) import Data.Time.Format (formatTime) import System.Locale (defaultTimeLocale) +import Network +import Network.Socket + -- TODO we have linker error here, so manual hardcoded version for a while. -- import Paths_network_bittorrent (version) version :: Version version = Version [0, 10, 0, 0] [] +data Peer = Peer { + peerID :: Maybe PeerID + , peerIP :: HostAddress + , peerPort :: PortNumber + } deriving Show + -- | Peer identifier is exactly 20 bytes long bytestring. newtype PeerID = PeerID { getPeerID :: ByteString } 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 @@ {-# LANGUAGE OverloadedStrings #-} module Network.Torrent.Tracker ( module Network.Torrent.Tracker.Scrape - , Peer(..), Event(..), TRequest(..), TResponse(..) + , Event(..), TRequest(..), TResponse(..) , defaultRequest, defaultPorts , sendRequest ) @@ -31,12 +31,6 @@ import Network.URI import Network.Torrent.PeerID -data Peer = Peer { - peerID :: Maybe PeerID - , peerIP :: HostAddress - , peerPort :: PortNumber - } deriving Show - data Event = Started -- ^ For first request. | Stopped -- ^ Sent when the peer is shutting down. | Completed -- ^ To be sent when the peer completes a download. -- cgit v1.2.3