summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/Session.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-01-11 08:49:40 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-01-11 08:49:40 +0400
commitb8f976b3df0af5d27f926022d7c7624609fc1072 (patch)
tree0d6b4d23d9ae87aacb4991dac0f7e4607738f551 /src/Network/BitTorrent/DHT/Session.hs
parent353c25a17d4100afd23127fc32d96995a9c70388 (diff)
Add documentation to peer store section
Diffstat (limited to 'src/Network/BitTorrent/DHT/Session.hs')
-rw-r--r--src/Network/BitTorrent/DHT/Session.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs
index 5ceca4a3..f08d85c6 100644
--- a/src/Network/BitTorrent/DHT/Session.hs
+++ b/src/Network/BitTorrent/DHT/Session.hs
@@ -354,21 +354,22 @@ insertNode info = fork $ do
354-----------------------------------------------------------------------} 354-----------------------------------------------------------------------}
355 355
356-- TODO limit dht peer store in size (probably by removing oldest peers) 356-- TODO limit dht peer store in size (probably by removing oldest peers)
357
358-- | Insert peer to peer store. Used to handle announce requests.
357insertPeer :: Eq ip => InfoHash -> PeerAddr ip -> DHT ip () 359insertPeer :: Eq ip => InfoHash -> PeerAddr ip -> DHT ip ()
358insertPeer ih addr = do 360insertPeer ih addr = do
359 var <- asks contactInfo 361 var <- asks contactInfo
360 liftIO $ atomically $ modifyTVar' var (P.insert ih addr) 362 liftIO $ atomically $ modifyTVar' var (P.insert ih addr)
361 363
364-- | Get peer set for specific swarm.
362lookupPeers :: InfoHash -> DHT ip [PeerAddr ip] 365lookupPeers :: InfoHash -> DHT ip [PeerAddr ip]
363lookupPeers ih = do 366lookupPeers ih = do
364 var <- asks contactInfo 367 var <- asks contactInfo
365 liftIO $ P.lookup ih <$> readTVarIO var 368 liftIO $ P.lookup ih <$> readTVarIO var
366 369
367type PeerList ip = Either [NodeInfo ip] [PeerAddr ip] 370-- | Prepare result for 'get_peers' query.
368
369-- |
370-- 371--
371-- This operation used 'getClosest' as failback. 372-- This operation use 'getClosest' as failback so it may block.
372-- 373--
373getPeerList :: Eq ip => InfoHash -> DHT ip (PeerList ip) 374getPeerList :: Eq ip => InfoHash -> DHT ip (PeerList ip)
374getPeerList ih = do 375getPeerList ih = do