summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/DHT.hs')
-rw-r--r--src/Network/BitTorrent/DHT.hs15
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
60import Data.ByteString as BS 60import Data.ByteString as BS
61import Data.Conduit as C 61import Data.Conduit as C
62import Data.Conduit.List as C 62import Data.Conduit.List as C
63import Data.Serialize
63import Network.Socket 64import Network.Socket
64 65
65import Data.Torrent 66import 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.
185restore :: ByteString -> IO (Node ip) 186restore :: Address ip => ByteString -> DHT ip ()
186restore = error "DHT.restore: not implemented" 187restore 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.
192snapshot :: DHT ip ByteString 197snapshot :: Address ip => DHT ip ByteString
193snapshot = error "DHT.snapshot: not implemented" 198snapshot = do
199 tbl <- getTable
200 return $ encode tbl
194 201
195{----------------------------------------------------------------------- 202{-----------------------------------------------------------------------
196-- Operations 203-- Operations