diff options
Diffstat (limited to 'src/Network/BitTorrent/DHT.hs')
-rw-r--r-- | src/Network/BitTorrent/DHT.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs index bb9be560..dbedf801 100644 --- a/src/Network/BitTorrent/DHT.hs +++ b/src/Network/BitTorrent/DHT.hs | |||
@@ -60,6 +60,7 @@ import Control.Exception | |||
60 | import Data.ByteString as BS | 60 | import Data.ByteString as BS |
61 | import Data.Conduit as C | 61 | import Data.Conduit as C |
62 | import Data.Conduit.List as C | 62 | import Data.Conduit.List as C |
63 | import Data.Serialize | ||
63 | import Network.Socket | 64 | import Network.Socket |
64 | 65 | ||
65 | import Data.Torrent | 66 | import Data.Torrent |
@@ -182,15 +183,21 @@ isBootstrapped = T.full <$> getTable | |||
182 | -- | 183 | -- |
183 | -- This is blocking operation, use | 184 | -- This is blocking operation, use |
184 | -- 'Control.Concurrent.Async.Lifted.async' if needed. | 185 | -- 'Control.Concurrent.Async.Lifted.async' if needed. |
185 | restore :: ByteString -> IO (Node ip) | 186 | restore :: Address ip => ByteString -> DHT ip () |
186 | restore = error "DHT.restore: not implemented" | 187 | restore bs = do |
188 | tblvar <- asks routingTable | ||
189 | case decode bs of | ||
190 | Right tbl -> restoreTable tbl | ||
191 | Left _ -> return () | ||
187 | 192 | ||
188 | -- | Serialize current DHT session to byte string. | 193 | -- | Serialize current DHT session to byte string. |
189 | -- | 194 | -- |
190 | -- This is blocking operation, use | 195 | -- This is blocking operation, use |
191 | -- 'Control.Concurrent.Async.Lifted.async' if needed. | 196 | -- 'Control.Concurrent.Async.Lifted.async' if needed. |
192 | snapshot :: DHT ip ByteString | 197 | snapshot :: Address ip => DHT ip ByteString |
193 | snapshot = error "DHT.snapshot: not implemented" | 198 | snapshot = do |
199 | tbl <- getTable | ||
200 | return $ encode tbl | ||
194 | 201 | ||
195 | {----------------------------------------------------------------------- | 202 | {----------------------------------------------------------------------- |
196 | -- Operations | 203 | -- Operations |