summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/Node.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-27 12:58:17 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-27 12:58:17 +0400
commit1e22d4d33ad6b7da93f7fd1fd757f10d74d98309 (patch)
tree5a95c01d10ecb44d49af6e698ae42920218eedf9 /src/Network/BitTorrent/Core/Node.hs
parent12c32c9b6c25c9768b01cca583061f19908d7151 (diff)
Add naive session tokens implementation
Diffstat (limited to 'src/Network/BitTorrent/Core/Node.hs')
-rw-r--r--src/Network/BitTorrent/Core/Node.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Core/Node.hs b/src/Network/BitTorrent/Core/Node.hs
index f6ab7d82..f163a895 100644
--- a/src/Network/BitTorrent/Core/Node.hs
+++ b/src/Network/BitTorrent/Core/Node.hs
@@ -39,6 +39,7 @@ import Data.Bits
39import Data.ByteString as BS 39import Data.ByteString as BS
40import Data.BEncode as BE 40import Data.BEncode as BE
41import Data.Default 41import Data.Default
42import Data.Hashable
42import Data.IP 43import Data.IP
43import Data.List as L 44import Data.List as L
44import Data.Ord 45import Data.Ord
@@ -126,6 +127,10 @@ instance BEncode a => BEncode (NodeAddr a) where
126 fromBEncode b = uncurry NodeAddr <$> fromBEncode b 127 fromBEncode b = uncurry NodeAddr <$> fromBEncode b
127 {-# INLINE fromBEncode #-} 128 {-# INLINE fromBEncode #-}
128 129
130instance Hashable a => Hashable (NodeAddr a) where
131 hashWithSalt s NodeAddr {..} = hashWithSalt s (nodeHost, nodePort)
132 {-# INLINE hashWithSalt #-}
133
129-- | Example: 134-- | Example:
130-- 135--
131-- @nodePort \"127.0.0.1:6881\" == 6881@ 136-- @nodePort \"127.0.0.1:6881\" == 6881@
@@ -160,7 +165,7 @@ instance Eq a => Ord (NodeInfo a) where
160instance Serialize a => Serialize (NodeInfo a) where 165instance Serialize a => Serialize (NodeInfo a) where
161 get = NodeInfo <$> get <*> get 166 get = NodeInfo <$> get <*> get
162 put NodeInfo {..} = put nodeId >> put nodeAddr 167 put NodeInfo {..} = put nodeId >> put nodeAddr
163 168{-
164type CompactInfo = ByteString 169type CompactInfo = ByteString
165 170
166data NodeList a = CompactNodeList [NodeInfo a] 171data NodeList a = CompactNodeList [NodeInfo a]
@@ -176,3 +181,4 @@ encodeCompact = S.runPut . mapM_ put
176 181
177--encodePeerList :: [PeerAddr] -> [BEncode] 182--encodePeerList :: [PeerAddr] -> [BEncode]
178--encodePeerList = undefined 183--encodePeerList = undefined
184-} \ No newline at end of file