summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-30 18:58:31 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-30 18:58:31 +0400
commitd7b276585a4faccc7d78baafb7ea011f3135856a (patch)
treef78c3bc59fd5e6e7e3d28490c6f74f0741204271 /src/Network
parentb6b992d5594daa9405e6a5259e161d65af815a88 (diff)
~ Keep track left progress bytes.
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent.hs2
-rw-r--r--src/Network/BitTorrent/Internal.hs14
2 files changed, 9 insertions, 7 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs
index 30735023..b6e2eadf 100644
--- a/src/Network/BitTorrent.hs
+++ b/src/Network/BitTorrent.hs
@@ -154,4 +154,4 @@ exchange storage = awaitEvent >>= handler
154 offer <- peerOffer 154 offer <- peerOffer
155 if BF.null offer 155 if BF.null offer
156 then return () 156 then return ()
157 else handler (Available offer) \ No newline at end of file 157 else handler (Available offer)
diff --git a/src/Network/BitTorrent/Internal.hs b/src/Network/BitTorrent/Internal.hs
index bf47b87b..eaeb04e8 100644
--- a/src/Network/BitTorrent/Internal.hs
+++ b/src/Network/BitTorrent/Internal.hs
@@ -153,14 +153,14 @@ uploadedProgress (fromIntegral -> amount) = uploaded +~ amount
153{-# INLINE uploadedProgress #-} 153{-# INLINE uploadedProgress #-}
154 154
155-- | Used when leecher join client session. 155-- | Used when leecher join client session.
156enqueuedProgress :: Int -> Progress -> Progress 156enqueuedProgress :: Integer -> Progress -> Progress
157enqueuedProgress (fromIntegral -> amount) = left +~ amount 157enqueuedProgress amount = left +~ amount
158{-# INLINE enqueuedProgress #-} 158{-# INLINE enqueuedProgress #-}
159 159
160-- | Used when leecher leave client session. 160-- | Used when leecher leave client session.
161-- (e.g. user deletes not completed torrent) 161-- (e.g. user deletes not completed torrent)
162dequeuedProgress :: Int -> Progress -> Progress 162dequeuedProgress :: Integer -> Progress -> Progress
163dequeuedProgress (fromIntegral -> amount) = left -~ amount 163dequeuedProgress amount = left -~ amount
164{-# INLINE dequeuedProgress #-} 164{-# INLINE dequeuedProgress #-}
165 165
166{----------------------------------------------------------------------- 166{-----------------------------------------------------------------------
@@ -349,8 +349,10 @@ newSeeder cs t @ Torrent {..}
349 349
350-- | New swarm in which the client allowed both download and upload. 350-- | New swarm in which the client allowed both download and upload.
351newLeecher :: ClientSession -> Torrent -> IO SwarmSession 351newLeecher :: ClientSession -> Torrent -> IO SwarmSession
352newLeecher cs t @ Torrent {..} 352newLeecher cs t @ Torrent {..} = do
353 = newSwarmSession defLeacherConns (haveNone (pieceCount tInfo)) cs t 353 se <- newSwarmSession defLeacherConns (haveNone (pieceCount tInfo)) cs t
354 atomically $ modifyTVar' (currentProgress cs) (enqueuedProgress (contentLength tInfo))
355 return se
354 356
355--isLeacher :: SwarmSession -> IO Bool 357--isLeacher :: SwarmSession -> IO Bool
356--isLeacher = undefined 358--isLeacher = undefined