From 469b2c84af865863a852bda5137640a2463c9a8b Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 2 Jan 2014 22:27:28 +0400 Subject: Add bucket count option --- src/Network/BitTorrent/DHT/Routing.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Network/BitTorrent/DHT/Routing.hs') diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs index 4897a22e..f6926cb1 100644 --- a/src/Network/BitTorrent/DHT/Routing.hs +++ b/src/Network/BitTorrent/DHT/Routing.hs @@ -325,8 +325,10 @@ instance Pretty (Table ip) where ss = shape t -- | Empty table with specified /spine/ node id. -nullTable :: Eq ip => NodeId -> Table ip -nullTable nid = Tip nid defaultBucketCount PSQ.empty +nullTable :: Eq ip => NodeId -> BucketCount -> Table ip +nullTable nid n = Tip nid (bucketCount (pred n)) PSQ.empty + where + bucketCount x = max 0 (min 160 x) -- | Get the /spine/ node id. thisId :: Table ip -> NodeId -- cgit v1.2.3