summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/Routing.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/DHT/Routing.hs')
-rw-r--r--src/Network/BitTorrent/DHT/Routing.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs
index 3c2e30aa..5c9788dc 100644
--- a/src/Network/BitTorrent/DHT/Routing.hs
+++ b/src/Network/BitTorrent/DHT/Routing.hs
@@ -14,6 +14,7 @@
14-- <http://www.bittorrent.org/beps/bep_0005.html#routing-table> 14-- <http://www.bittorrent.org/beps/bep_0005.html#routing-table>
15-- 15--
16{-# LANGUAGE RecordWildCards #-} 16{-# LANGUAGE RecordWildCards #-}
17{-# LANGUAGE BangPatterns #-}
17{-# LANGUAGE ViewPatterns #-} 18{-# LANGUAGE ViewPatterns #-}
18{-# LANGUAGE TypeOperators #-} 19{-# LANGUAGE TypeOperators #-}
19{-# LANGUAGE DeriveGeneric #-} 20{-# LANGUAGE DeriveGeneric #-}
@@ -231,8 +232,8 @@ bucketQ = seqQ
231-- very unlikely that all nodes in bucket fail within an hour of 232-- very unlikely that all nodes in bucket fail within an hour of
232-- each other. 233-- each other.
233-- 234--
234data Bucket ip = Bucket { bktNodes :: PSQ (NodeInfo ip) Timestamp 235data Bucket ip = Bucket { bktNodes :: !(PSQ (NodeInfo ip) Timestamp)
235 , bktQ :: BucketQueue ip 236 , bktQ :: !(BucketQueue ip)
236 } deriving (Show,Generic) 237 } deriving (Show,Generic)
237 238
238instance (Eq ip, Serialize ip) => Serialize (Bucket ip) where 239instance (Eq ip, Serialize ip) => Serialize (Bucket ip) where
@@ -531,13 +532,13 @@ modifyBucket
531modifyBucket nodeId f = go (0 :: BitIx) 532modifyBucket nodeId f = go (0 :: BitIx)
532 where 533 where
533 go :: BitIx -> Table ip -> Maybe (xs, Table ip) 534 go :: BitIx -> Table ip -> Maybe (xs, Table ip)
534 go i (Zero table bucket) 535 go !i (Zero table bucket)
535 | testIdBit nodeId i = second (Zero table) <$> f bucket 536 | testIdBit nodeId i = second (Zero table) <$> f bucket
536 | otherwise = second (`Zero` bucket) <$> go (succ i) table 537 | otherwise = second (`Zero` bucket) <$> go (succ i) table
537 go i (One bucket table ) 538 go !i (One bucket table )
538 | testIdBit nodeId i = second (One bucket) <$> go (succ i) table 539 | testIdBit nodeId i = second (One bucket) <$> go (succ i) table
539 | otherwise = second (`One` table) <$> f bucket 540 | otherwise = second (`One` table) <$> f bucket
540 go i (Tip nid n bucket) 541 go !i (Tip nid n bucket)
541 | n == 0 = second (Tip nid n) <$> f bucket 542 | n == 0 = second (Tip nid n) <$> f bucket
542 | otherwise = second (Tip nid n) <$> f bucket 543 | otherwise = second (Tip nid n) <$> f bucket
543 <|> go i (splitTip nid n i bucket) 544 <|> go i (splitTip nid n i bucket)