summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent/DHT.hs28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs
index 71803ccf..77bb9da9 100644
--- a/src/Network/BitTorrent/DHT.hs
+++ b/src/Network/BitTorrent/DHT.hs
@@ -21,7 +21,13 @@ module Network.BitTorrent.DHT
21 ( -- * Distributed Hash Table 21 ( -- * Distributed Hash Table
22 DHT 22 DHT
23 , dht 23 , dht
24 , Network.BitTorrent.DHT.bootstrap 24
25 -- * Initialization
26 , bootstrap
27 , snapshot
28 , restore
29
30 -- * Operations
25 , Network.BitTorrent.DHT.lookup 31 , Network.BitTorrent.DHT.lookup
26 , Network.BitTorrent.DHT.insert 32 , Network.BitTorrent.DHT.insert
27 , Network.BitTorrent.DHT.delete 33 , Network.BitTorrent.DHT.delete
@@ -30,6 +36,7 @@ module Network.BitTorrent.DHT
30import Control.Applicative 36import Control.Applicative
31import Control.Monad.Logger 37import Control.Monad.Logger
32import Control.Monad.Trans 38import Control.Monad.Trans
39import Data.ByteString as BS
33import Data.Conduit as C 40import Data.Conduit as C
34import Data.Conduit.List as C 41import Data.Conduit.List as C
35import Network.Socket (PortNumber) 42import Network.Socket (PortNumber)
@@ -66,6 +73,20 @@ bootstrap startNodes = do
66-- unless (full t) $ do 73-- unless (full t) $ do
67-- nid <- getNodeId 74-- nid <- getNodeId
68 75
76-- | Load previous session. (corrupted - exception/ignore ?)
77--
78-- This is blocking operation, use
79-- 'Control.Concurrent.Async.Lifted.async' if needed.
80restore :: ByteString -> DHT ip ()
81restore = error "DHT.restore: not implemented"
82
83-- | Serialize current DHT session to byte string.
84--
85-- This is blocking operation, use
86-- 'Control.Concurrent.Async.Lifted.async' if needed.
87snapshot :: DHT ip ByteString
88snapshot = error "DHT.snapshot: not implemented"
89
69-- | Get list of peers which downloading this torrent. 90-- | Get list of peers which downloading this torrent.
70-- 91--
71-- This operation is incremental and do block. 92-- This operation is incremental and do block.
@@ -76,7 +97,8 @@ lookup topic = do -- TODO retry getClosest if bucket is empty
76 sourceList [closest] $= search topic (getPeersQ topic) 97 sourceList [closest] $= search topic (getPeersQ topic)
77 98
78-- | Announce that /this/ peer may have some pieces of the specified 99-- | Announce that /this/ peer may have some pieces of the specified
79-- torrent. 100-- torrent. DHT will reannounce this data periodically using
101-- 'optReannounce' interval.
80-- 102--
81-- This operation is synchronous and do block, use 103-- This operation is synchronous and do block, use
82-- 'Control.Concurrent.Async.Lifted.async' if needed. 104-- 'Control.Concurrent.Async.Lifted.async' if needed.
@@ -92,4 +114,4 @@ insert ih p = do
92-- 114--
93delete :: Address ip => InfoHash -> PortNumber -> DHT ip () 115delete :: Address ip => InfoHash -> PortNumber -> DHT ip ()
94delete = deleteTopic 116delete = deleteTopic
95{-# INLINE delete #-} \ No newline at end of file 117{-# INLINE delete #-}