diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-11 08:49:40 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-11 08:49:40 +0400 |
commit | b8f976b3df0af5d27f926022d7c7624609fc1072 (patch) | |
tree | 0d6b4d23d9ae87aacb4991dac0f7e4607738f551 /src/Network/BitTorrent/DHT/Session.hs | |
parent | 353c25a17d4100afd23127fc32d96995a9c70388 (diff) |
Add documentation to peer store section
Diffstat (limited to 'src/Network/BitTorrent/DHT/Session.hs')
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 9 |
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. | ||
357 | insertPeer :: Eq ip => InfoHash -> PeerAddr ip -> DHT ip () | 359 | insertPeer :: Eq ip => InfoHash -> PeerAddr ip -> DHT ip () |
358 | insertPeer ih addr = do | 360 | insertPeer 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. | ||
362 | lookupPeers :: InfoHash -> DHT ip [PeerAddr ip] | 365 | lookupPeers :: InfoHash -> DHT ip [PeerAddr ip] |
363 | lookupPeers ih = do | 366 | lookupPeers 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 | ||
367 | type 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 | -- |
373 | getPeerList :: Eq ip => InfoHash -> DHT ip (PeerList ip) | 374 | getPeerList :: Eq ip => InfoHash -> DHT ip (PeerList ip) |
374 | getPeerList ih = do | 375 | getPeerList ih = do |