summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Internal.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Internal.lhs')
-rw-r--r--src/Network/BitTorrent/Internal.lhs28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/Network/BitTorrent/Internal.lhs b/src/Network/BitTorrent/Internal.lhs
index e3fe3dac..475c5e32 100644
--- a/src/Network/BitTorrent/Internal.lhs
+++ b/src/Network/BitTorrent/Internal.lhs
@@ -257,25 +257,17 @@ so we need to do this on demand: if a peer asks for a block, we
257validate corresponding piece and only after read and send the block 257validate corresponding piece and only after read and send the block
258back. 258back.
259 259
260> -- | Used to check torrent location before register torrent. 260> registerTorrent :: TVar TorrentMap -> InfoHash -> TorrentLoc -> IO ()
261> validateTorrent :: TorrentLoc -> IO Torrent 261> registerTorrent = error "registerTorrent"
262> validateTorrent TorrentLoc {..} = do 262> {-
263> t <- fromFile metafilePath
264> exists <- doesDirectoryExist dataDirPath
265> unless exists $ do
266> throw undefined
267> return t
268
269> registerTorrent :: TVar TorrentMap -> TorrentLoc -> IO (Maybe Torrent)
270> registerTorrent ClientSession {..} tl = do
271> Torrent {..} <- validateTorrent tl 263> Torrent {..} <- validateTorrent tl
272> atomically $ modifyTVar' torrentMap $ HM.insert tInfoHash tl 264> atomically $ modifyTVar' torrentMap $ HM.insert tInfoHash tl
273> return (Just t) 265> return (Just t)
274> 266> -}
275 267
276> unregisterTorrent :: TVar TorrentMap -> InfoHash -> IO () 268> unregisterTorrent :: TVar TorrentMap -> InfoHash -> IO ()
277> unregisterTorrent ClientSession {..} ih = do 269> unregisterTorrent = error "unregisterTorrent"
278> modifyTVar' torrentMap $ HM.delete ih 270> -- modifyTVar' torrentMap $ HM.delete ih
279 271
280Client session 272Client session
281------------------------------------------------------------------------ 273------------------------------------------------------------------------
@@ -374,7 +366,7 @@ and different enabled extensions at the same time.
374> ClientSession 366> ClientSession
375> <$> newPeerId 367> <$> newPeerId
376> <*> pure exts 368> <*> pure exts
377> <*> forkListener (error "listener") 369> <*> pure 10 -- forkListener (error "listener")
378> <*> MSem.new n 370> <*> MSem.new n
379> <*> pure n 371> <*> pure n
380> <*> newTVarIO S.empty 372> <*> newTVarIO S.empty
@@ -382,6 +374,12 @@ and different enabled extensions at the same time.
382> <*> newTVarIO (startProgress 0) 374> <*> newTVarIO (startProgress 0)
383> <*> newTVarIO HM.empty 375> <*> newTVarIO HM.empty
384 376
377data TorrentStatus = Active SwarmSession
378 | Registered TorrentLoc
379 | Unknown
380lookupTorrent :: ClientSession -> InfoHash -> IO TorrentStatus
381lookupTorrent ses ih =
382
385Swarm session 383Swarm session
386------------------------------------------------------------------------ 384------------------------------------------------------------------------
387 385