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.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/DHT/Routing.hs b/src/Network/BitTorrent/DHT/Routing.hs
index fee52380..68edef56 100644
--- a/src/Network/BitTorrent/DHT/Routing.hs
+++ b/src/Network/BitTorrent/DHT/Routing.hs
@@ -46,6 +46,7 @@ module Network.BitTorrent.DHT.Routing
46 -- * Construction 46 -- * Construction
47 , Network.BitTorrent.DHT.Routing.nullTable 47 , Network.BitTorrent.DHT.Routing.nullTable
48 , Network.BitTorrent.DHT.Routing.insert 48 , Network.BitTorrent.DHT.Routing.insert
49 , Network.BitTorrent.DHT.Routing.merge
49 50
50 -- * Conversion 51 -- * Conversion
51 , Network.BitTorrent.DHT.Routing.TableEntry 52 , Network.BitTorrent.DHT.Routing.TableEntry
@@ -457,3 +458,10 @@ toBucketList (One b t) = b : toBucketList t
457 458
458toList :: Eq ip => Table ip -> [[TableEntry ip]] 459toList :: Eq ip => Table ip -> [[TableEntry ip]]
459toList = L.map (L.map tableEntry . PSQ.toList) . toBucketList 460toList = L.map (L.map tableEntry . PSQ.toList) . toBucketList
461
462merge :: Eq ip => Table ip -> Table ip -> Routing ip (Table ip)
463merge a b = do
464 let ns = concatMap PSQ.toList $ toBucketList a
465 -- TODO: merge timestamps as well and let refresh take care of ping.
466 as <- filterM (needPing . nodeAddr . PSQ.key) ns
467 foldM (flip $ Network.BitTorrent.DHT.Routing.insert) b $ map PSQ.key as