diff options
author | joe <joe@jerkface.net> | 2017-09-20 20:43:33 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-09-20 20:43:33 -0400 |
commit | c769bd0c05e0812ebbaec36e3e2644b57ad8361e (patch) | |
tree | 9a9816b72835afeeb93b26aadd57cbc1f37ec96c /src | |
parent | 57aa0df02d52e7018d85a2b38689d3bc127252f3 (diff) |
Refresh tweak. Search own-id only for refreshing the last bucket.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Kademlia.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Network/Kademlia.hs b/src/Network/Kademlia.hs index 873fc8c0..f1ffda19 100644 --- a/src/Network/Kademlia.hs +++ b/src/Network/Kademlia.hs | |||
@@ -277,7 +277,13 @@ forkPollForRefresh interval psq refresh = do | |||
277 | again | 277 | again |
278 | 278 | ||
279 | refreshBucket :: forall nid tok ni addr. | 279 | refreshBucket :: forall nid tok ni addr. |
280 | ( Show nid, Serialize nid, Ord nid, Ord ni, Hashable nid, Hashable ni, Ord addr ) => | 280 | ( Show nid |
281 | , Serialize nid | ||
282 | , Ord nid | ||
283 | , Ord ni | ||
284 | , Ord addr | ||
285 | , Hashable nid | ||
286 | , Hashable ni ) => | ||
281 | Search nid addr tok ni ni -> TVar (BucketList ni) -> Int -> IO Int | 287 | Search nid addr tok ni ni -> TVar (BucketList ni) -> Int -> IO Int |
282 | refreshBucket sch var n = do | 288 | refreshBucket sch var n = do |
283 | tbl <- atomically (readTVar var) | 289 | tbl <- atomically (readTVar var) |
@@ -379,10 +385,6 @@ bootstrap sch var ping ns ns0 = do | |||
379 | (R.defaultBucketCount - 1) | 385 | (R.defaultBucketCount - 1) |
380 | again cnt | 386 | again cnt |
381 | (size,num):_ -> do | 387 | (size,num):_ -> do |
382 | -- If we don't yet have enough buckets, we need to search our own id. | 388 | hPutStrLn stderr $ "Bucket too small, refresh "++ show (size,num,shp) |
383 | -- We indicate that by setting the bucket number to the target. | 389 | cnt <- refreshBucket sch var num |
384 | let num' | bktCount tbl < R.defaultBucketCount = R.defaultBucketCount - 1 | ||
385 | | otherwise = num | ||
386 | hPutStrLn stderr $ "Bucket too small, refresh "++ show (num',(size,num),shp) | ||
387 | cnt <- refreshBucket sch var num' | ||
388 | again cnt | 390 | again cnt |