diff options
-rw-r--r-- | src/Network/BitTorrent/Core/Node.hs | 8 |
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 | |||
20 | import Data.Bits | 20 | import Data.Bits |
21 | import Data.ByteString as BS | 21 | import Data.ByteString as BS |
22 | import Data.BEncode as BE | 22 | import Data.BEncode as BE |
23 | import Data.Ord | ||
23 | import Data.Serialize as S | 24 | import Data.Serialize as S |
24 | import Data.Word | 25 | import Data.Word |
25 | import Network | 26 | import Network |
@@ -70,7 +71,7 @@ genNodeId = NodeId <$> getEntropy nodeIdSize | |||
70 | data NodeAddr a = NodeAddr | 71 | data 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 | |||
93 | data NodeInfo a = NodeInfo | 94 | data 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 | ||
101 | instance Eq a => Ord (NodeInfo a) where | ||
102 | compare = comparing nodeId | ||
103 | |||
100 | -- | KRPC 'compact list' compatible encoding. | 104 | -- | KRPC 'compact list' compatible encoding. |
101 | instance Serialize a => Serialize (NodeInfo a) where | 105 | instance Serialize a => Serialize (NodeInfo a) where |
102 | get = NodeInfo <$> get <*> get | 106 | get = NodeInfo <$> get <*> get |