diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-27 12:58:17 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-27 12:58:17 +0400 |
commit | 1e22d4d33ad6b7da93f7fd1fd757f10d74d98309 (patch) | |
tree | 5a95c01d10ecb44d49af6e698ae42920218eedf9 /src/Network/BitTorrent/Core/Node.hs | |
parent | 12c32c9b6c25c9768b01cca583061f19908d7151 (diff) |
Add naive session tokens implementation
Diffstat (limited to 'src/Network/BitTorrent/Core/Node.hs')
-rw-r--r-- | src/Network/BitTorrent/Core/Node.hs | 8 |
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 | |||
39 | import Data.ByteString as BS | 39 | import Data.ByteString as BS |
40 | import Data.BEncode as BE | 40 | import Data.BEncode as BE |
41 | import Data.Default | 41 | import Data.Default |
42 | import Data.Hashable | ||
42 | import Data.IP | 43 | import Data.IP |
43 | import Data.List as L | 44 | import Data.List as L |
44 | import Data.Ord | 45 | import 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 | ||
130 | instance 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 | |||
160 | instance Serialize a => Serialize (NodeInfo a) where | 165 | instance 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 | {- | |
164 | type CompactInfo = ByteString | 169 | type CompactInfo = ByteString |
165 | 170 | ||
166 | data NodeList a = CompactNodeList [NodeInfo a] | 171 | data 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 | ||