summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent/DHT/Routing.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs
index 8a6849a1..d64e415e 100644
--- a/src/Network/BitTorrent/DHT/Routing.hs
+++ b/src/Network/BitTorrent/DHT/Routing.hs
@@ -529,11 +529,11 @@ splitTip nid n i bucket
529-- k nodes in them. Which subtrees I mean is illustrated in Fig 1. of Kademlia 529-- k nodes in them. Which subtrees I mean is illustrated in Fig 1. of Kademlia
530-- paper. The rule requiring additional splits is in section 2.4. 530-- paper. The rule requiring additional splits is in section 2.4.
531modifyBucket 531modifyBucket
532 :: forall f ip xs. (Alternative f, Eq ip) => 532 :: forall ip xs. (Eq ip) =>
533 NodeId -> (Bucket ip -> f (xs, Bucket ip)) -> Table ip -> f (xs,Table ip) 533 NodeId -> (Bucket ip -> Maybe (xs, Bucket ip)) -> Table ip -> Maybe (xs,Table ip)
534modifyBucket nodeId f = go (0 :: BitIx) 534modifyBucket nodeId f = go (0 :: BitIx)
535 where 535 where
536 go :: BitIx -> Table ip -> f (xs, Table ip) 536 go :: BitIx -> Table ip -> Maybe (xs, Table ip)
537 go i (Zero table bucket) 537 go i (Zero table bucket)
538 | testIdBit nodeId i = second (Zero table) <$> f bucket 538 | testIdBit nodeId i = second (Zero table) <$> f bucket
539 | otherwise = second (`Zero` bucket) <$> go (succ i) table 539 | otherwise = second (`Zero` bucket) <$> go (succ i) table
@@ -562,8 +562,8 @@ data CheckPing ip = CheckPing [NodeInfo ip]
562 562
563 563
564-- | Atomic 'Table' update 564-- | Atomic 'Table' update
565insert :: (Alternative m, Eq ip) => Timestamp -> Event ip -> Table ip -> m ([CheckPing ip], Table ip) 565insert :: (Eq ip, Applicative m) => Timestamp -> Event ip -> Table ip -> m ([CheckPing ip], Table ip)
566insert tm event = modifyBucket (eventId event) (insertBucket tm event) 566insert tm event tbl = pure $ fromMaybe ([],tbl) $ modifyBucket (eventId event) (insertBucket tm event) tbl
567 567
568 568
569{----------------------------------------------------------------------- 569{-----------------------------------------------------------------------