diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-13 12:05:07 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-13 12:05:07 +0400 |
commit | 5dcc00c1efe95b2adce82e0b19c29ffe9346482b (patch) | |
tree | 43c460782fcec3f5d1259bebd93e6e93af7a68f7 | |
parent | 84486e1bed75ae3ece0217fb330c6ca648931bb3 (diff) |
Add stubs for DHT session serialization
-rw-r--r-- | src/Network/BitTorrent/DHT.hs | 28 |
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 | |||
30 | import Control.Applicative | 36 | import Control.Applicative |
31 | import Control.Monad.Logger | 37 | import Control.Monad.Logger |
32 | import Control.Monad.Trans | 38 | import Control.Monad.Trans |
39 | import Data.ByteString as BS | ||
33 | import Data.Conduit as C | 40 | import Data.Conduit as C |
34 | import Data.Conduit.List as C | 41 | import Data.Conduit.List as C |
35 | import Network.Socket (PortNumber) | 42 | import 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. | ||
80 | restore :: ByteString -> DHT ip () | ||
81 | restore = 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. | ||
87 | snapshot :: DHT ip ByteString | ||
88 | snapshot = 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 | -- |
93 | delete :: Address ip => InfoHash -> PortNumber -> DHT ip () | 115 | delete :: Address ip => InfoHash -> PortNumber -> DHT ip () |
94 | delete = deleteTopic | 116 | delete = deleteTopic |
95 | {-# INLINE delete #-} \ No newline at end of file | 117 | {-# INLINE delete #-} |