From f061e4aff630e6f4793b962f99c42e70c337c46f Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 18 Dec 2013 22:06:14 +0400 Subject: Use only NodeId in comparing operation --- src/Network/BitTorrent/Core/Node.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Network/BitTorrent/Core') 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 import Data.Bits import Data.ByteString as BS import Data.BEncode as BE +import Data.Ord import Data.Serialize as S import Data.Word import Network @@ -70,7 +71,7 @@ genNodeId = NodeId <$> getEntropy nodeIdSize data NodeAddr a = NodeAddr { nodeHost :: !a , nodePort :: {-# UNPACK #-} !PortNumber - } deriving (Show, Eq, Ord) + } deriving (Show, Eq) $(deriveJSON omitRecordPrefix ''NodeAddr) @@ -93,10 +94,13 @@ instance BEncode a => BEncode (NodeAddr a) where data NodeInfo a = NodeInfo { nodeId :: !NodeId , nodeAddr :: !(NodeAddr a) - } deriving (Show, Eq, Ord) + } deriving (Show, Eq) $(deriveJSON omitRecordPrefix ''NodeInfo) +instance Eq a => Ord (NodeInfo a) where + compare = comparing nodeId + -- | KRPC 'compact list' compatible encoding. instance Serialize a => Serialize (NodeInfo a) where get = NodeInfo <$> get <*> get -- cgit v1.2.3