diff options
author | joe <joe@jerkface.net> | 2017-07-29 00:58:52 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-29 01:03:35 -0400 |
commit | f876da224f503542394b3d7614fcc161106ebbb4 (patch) | |
tree | 411d1c94ac482a94dcaeb6ff17175673bce0939b /Kademlia.hs | |
parent | d0ff6c3ac977035f3493b679978da73517550028 (diff) |
Detect a global ipv6 address via "ip" command.
Diffstat (limited to 'Kademlia.hs')
-rw-r--r-- | Kademlia.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Kademlia.hs b/Kademlia.hs index ef5c6a48..017209a7 100644 --- a/Kademlia.hs +++ b/Kademlia.hs | |||
@@ -267,10 +267,11 @@ forkPollForRefresh interval psq refresh = do | |||
267 | 267 | ||
268 | refreshBucket :: forall nid tok ni addr. | 268 | refreshBucket :: forall nid tok ni addr. |
269 | ( Show nid, FiniteBits nid, Serialize nid, Ord nid, Ord ni, Hashable nid, Hashable ni, Ord addr ) => | 269 | ( Show nid, FiniteBits nid, Serialize nid, Ord nid, Ord ni, Hashable nid, Hashable ni, Ord addr ) => |
270 | Search nid addr tok ni ni -> TVar (BucketList ni) -> nid -> Int -> IO Int | 270 | Search nid addr tok ni ni -> TVar (BucketList ni) -> Int -> IO Int |
271 | refreshBucket sch var nid n = do | 271 | refreshBucket sch var n = do |
272 | tbl <- atomically (readTVar var) | 272 | tbl <- atomically (readTVar var) |
273 | let count = bktCount tbl | 273 | let count = bktCount tbl |
274 | nid = kademliaLocation (searchSpace sch) (thisNode tbl) | ||
274 | sample <- if n+1 >= count -- Is this the last bucket? | 275 | sample <- if n+1 >= count -- Is this the last bucket? |
275 | then return nid -- Yes? Search our own id. | 276 | then return nid -- Yes? Search our own id. |
276 | else genBucketSample nid -- No? Generate a random id. | 277 | else genBucketSample nid -- No? Generate a random id. |
@@ -362,7 +363,6 @@ bootstrap sch var ping ns ns0 = do | |||
362 | hPutStrLn stderr | 363 | hPutStrLn stderr |
363 | $ "Not enough buckets, refresh " ++ show (R.defaultBucketCount - 1) | 364 | $ "Not enough buckets, refresh " ++ show (R.defaultBucketCount - 1) |
364 | cnt <- refreshBucket sch var | 365 | cnt <- refreshBucket sch var |
365 | (kademliaLocation (searchSpace sch) (thisNode tbl)) | ||
366 | (R.defaultBucketCount - 1) | 366 | (R.defaultBucketCount - 1) |
367 | again cnt | 367 | again cnt |
368 | (size,num):_ -> do | 368 | (size,num):_ -> do |
@@ -371,5 +371,5 @@ bootstrap sch var ping ns ns0 = do | |||
371 | let num' | bktCount tbl < R.defaultBucketCount = R.defaultBucketCount - 1 | 371 | let num' | bktCount tbl < R.defaultBucketCount = R.defaultBucketCount - 1 |
372 | | otherwise = num | 372 | | otherwise = num |
373 | hPutStrLn stderr $ "Bucket too small, refresh "++ show (num',(size,num),shp) | 373 | hPutStrLn stderr $ "Bucket too small, refresh "++ show (num',(size,num),shp) |
374 | cnt <- refreshBucket sch var (kademliaLocation (searchSpace sch) (thisNode tbl)) num' | 374 | cnt <- refreshBucket sch var num' |
375 | again cnt | 375 | again cnt |