summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/Fingerprint.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-05 04:58:26 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-05 04:58:26 +0400
commitfda80933f98f6998ac872ab617026ecf06e4768c (patch)
tree60da38644cd3ce07884db666af1d8f105986a927 /src/Network/BitTorrent/Core/Fingerprint.hs
parent3399beaf2f38d19ed615655f865f3bc8b0cb9309 (diff)
Rename ClientInfo datatype to Fingerprint
Diffstat (limited to 'src/Network/BitTorrent/Core/Fingerprint.hs')
-rw-r--r--src/Network/BitTorrent/Core/Fingerprint.hs32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/Network/BitTorrent/Core/Fingerprint.hs b/src/Network/BitTorrent/Core/Fingerprint.hs
index e2fbb777..a81edd8b 100644
--- a/src/Network/BitTorrent/Core/Fingerprint.hs
+++ b/src/Network/BitTorrent/Core/Fingerprint.hs
@@ -5,7 +5,7 @@
5-- Stability : experimental 5-- Stability : experimental
6-- Portability : portable 6-- Portability : portable
7-- 7--
8-- 'ClientInfo' is used to identify the client implementation and 8-- 'Fingerprint' is used to identify the client implementation and
9-- version which also contained in 'Peer'. For exsample first 6 9-- version which also contained in 'Peer'. For exsample first 6
10-- bytes of peer id of this this library are @-HS0100-@ while for 10-- bytes of peer id of this this library are @-HS0100-@ while for
11-- mainline we have @M4-3-6--@. We could extract this info and 11-- mainline we have @M4-3-6--@. We could extract this info and
@@ -23,8 +23,8 @@
23{-# OPTIONS -fno-warn-orphans #-} 23{-# OPTIONS -fno-warn-orphans #-}
24module Network.BitTorrent.Core.Fingerprint 24module Network.BitTorrent.Core.Fingerprint
25 ( ClientImpl (..) 25 ( ClientImpl (..)
26 , ClientInfo (..) 26 , Fingerprint (..)
27 , libClientInfo 27 , libFingerprint
28 ) where 28 ) where
29 29
30import Data.Default 30import Data.Default
@@ -162,33 +162,33 @@ instance Pretty Version where
162 162
163-- | The all sensible infomation that can be obtained from a peer 163-- | The all sensible infomation that can be obtained from a peer
164-- identifier or torrent /createdBy/ field. 164-- identifier or torrent /createdBy/ field.
165data ClientInfo = ClientInfo { 165data Fingerprint = Fingerprint
166 ciImpl :: ClientImpl 166 { ciImpl :: ClientImpl
167 , ciVersion :: Version 167 , ciVersion :: Version
168 } deriving (Show, Eq, Ord) 168 } deriving (Show, Eq, Ord)
169 169
170-- | Unrecognized client implementation. 170-- | Unrecognized client implementation.
171instance Default ClientInfo where 171instance Default Fingerprint where
172 def = ClientInfo def def 172 def = Fingerprint def def
173 {-# INLINE def #-} 173 {-# INLINE def #-}
174 174
175-- | Example: @\"BitComet-1.2\" == ClientInfo IBitComet (Version [1, 2] [])@ 175-- | Example: @\"BitComet-1.2\" == ClientInfo IBitComet (Version [1, 2] [])@
176instance IsString ClientInfo where 176instance IsString Fingerprint where
177 fromString str 177 fromString str
178 | _ : ver <- _ver = ClientInfo (fromString impl) (fromString ver) 178 | _ : ver <- _ver = Fingerprint (fromString impl) (fromString ver)
179 | otherwise = error $ "fromString: invalid client info string" ++ str 179 | otherwise = error $ "fromString: invalid client info string" ++ str
180 where 180 where
181 (impl, _ver) = L.span ((/=) '-') str 181 (impl, _ver) = L.span ((/=) '-') str
182 182
183instance Pretty ClientInfo where 183instance Pretty Fingerprint where
184 pretty ClientInfo {..} = pretty ciImpl <+> "version" <+> pretty ciVersion 184 pretty Fingerprint {..} = pretty ciImpl <+> "version" <+> pretty ciVersion
185 185
186-- | Client info of this (the bittorrent library) package. Normally, 186-- | Fingerprint of this (the bittorrent library) package. Normally,
187-- applications should introduce its own idenitifiers, otherwise they 187-- applications should introduce its own fingerprints, otherwise they
188-- can use 'libClientInfo' value. 188-- can use 'libFingerprint' value.
189-- 189--
190libClientInfo :: ClientInfo 190libFingerprint :: Fingerprint
191libClientInfo = ClientInfo IlibHSbittorrent version 191libFingerprint = Fingerprint IlibHSbittorrent version
192 192
193{----------------------------------------------------------------------- 193{-----------------------------------------------------------------------
194-- For torrent file 194-- For torrent file