summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Address.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Address.hs')
-rw-r--r--src/Network/BitTorrent/Address.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Address.hs b/src/Network/BitTorrent/Address.hs
index b4ce96b0..381ff50b 100644
--- a/src/Network/BitTorrent/Address.hs
+++ b/src/Network/BitTorrent/Address.hs
@@ -58,7 +58,8 @@ module Network.BitTorrent.Address
58 58
59 -- * Node 59 -- * Node
60 -- ** Id 60 -- ** Id
61 , NodeId(..) 61 , NodeId
62 , asNodeId
62 , nodeIdSize 63 , nodeIdSize
63 , testIdBit 64 , testIdBit
64 , NodeDistance 65 , NodeDistance
@@ -646,6 +647,9 @@ newtype NodeId = NodeId ByteString
646nodeIdSize :: Int 647nodeIdSize :: Int
647nodeIdSize = 20 648nodeIdSize = 20
648 649
650asNodeId :: ByteString -> NodeId
651asNodeId bs = NodeId $ BS.take nodeIdSize bs
652
649-- | Meaningless node id, for testing purposes only. 653-- | Meaningless node id, for testing purposes only.
650instance Default NodeId where 654instance Default NodeId where
651 def = NodeId (BS.replicate nodeIdSize 0) 655 def = NodeId (BS.replicate nodeIdSize 0)
@@ -801,6 +805,7 @@ data NodeInfo a = NodeInfo
801 , nodeAddr :: !(NodeAddr a) 805 , nodeAddr :: !(NodeAddr a)
802 } deriving (Show, Eq, Functor, Foldable, Traversable) 806 } deriving (Show, Eq, Functor, Foldable, Traversable)
803 807
808
804instance Eq a => Ord (NodeInfo a) where 809instance Eq a => Ord (NodeInfo a) where
805 compare = comparing nodeId 810 compare = comparing nodeId
806 811