summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/Core/Node.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Core/Node.hs b/src/Network/BitTorrent/Core/Node.hs
index 5098d260..c629df08 100644
--- a/src/Network/BitTorrent/Core/Node.hs
+++ b/src/Network/BitTorrent/Core/Node.hs
@@ -20,6 +20,7 @@ import Data.Aeson.TH
20import Data.Bits 20import Data.Bits
21import Data.ByteString as BS 21import Data.ByteString as BS
22import Data.BEncode as BE 22import Data.BEncode as BE
23import Data.Ord
23import Data.Serialize as S 24import Data.Serialize as S
24import Data.Word 25import Data.Word
25import Network 26import Network
@@ -70,7 +71,7 @@ genNodeId = NodeId <$> getEntropy nodeIdSize
70data NodeAddr a = NodeAddr 71data NodeAddr a = NodeAddr
71 { nodeHost :: !a 72 { nodeHost :: !a
72 , nodePort :: {-# UNPACK #-} !PortNumber 73 , nodePort :: {-# UNPACK #-} !PortNumber
73 } deriving (Show, Eq, Ord) 74 } deriving (Show, Eq)
74 75
75$(deriveJSON omitRecordPrefix ''NodeAddr) 76$(deriveJSON omitRecordPrefix ''NodeAddr)
76 77
@@ -93,10 +94,13 @@ instance BEncode a => BEncode (NodeAddr a) where
93data NodeInfo a = NodeInfo 94data NodeInfo a = NodeInfo
94 { nodeId :: !NodeId 95 { nodeId :: !NodeId
95 , nodeAddr :: !(NodeAddr a) 96 , nodeAddr :: !(NodeAddr a)
96 } deriving (Show, Eq, Ord) 97 } deriving (Show, Eq)
97 98
98$(deriveJSON omitRecordPrefix ''NodeInfo) 99$(deriveJSON omitRecordPrefix ''NodeInfo)
99 100
101instance Eq a => Ord (NodeInfo a) where
102 compare = comparing nodeId
103
100-- | KRPC 'compact list' compatible encoding. 104-- | KRPC 'compact list' compatible encoding.
101instance Serialize a => Serialize (NodeInfo a) where 105instance Serialize a => Serialize (NodeInfo a) where
102 get = NodeInfo <$> get <*> get 106 get = NodeInfo <$> get <*> get