summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-07-13 22:10:23 +0400
committerSam T <pxqr.sta@gmail.com>2013-07-13 22:10:23 +0400
commit07fb54d4844a7667dcef10527d0d3c010f851768 (patch)
tree5c981334f35cb12ab972ca43851af9fd88ccde2b /src/Network/BitTorrent
parentad4d96b1850fea7d6f40a48a085ed8d18ba4fd8a (diff)
~ Remove import Internal from Storage.
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r--src/Network/BitTorrent/Internal.lhs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Network/BitTorrent/Internal.lhs b/src/Network/BitTorrent/Internal.lhs
index 5f6ad458..d30057f7 100644
--- a/src/Network/BitTorrent/Internal.lhs
+++ b/src/Network/BitTorrent/Internal.lhs
@@ -59,8 +59,6 @@
59> , waitVacancy 59> , waitVacancy
60> , forkThrottle 60> , forkThrottle
61> 61>
62> , pieceLength
63>
64> -- * Peer 62> -- * Peer
65> , PeerSession( PeerSession, connectedPeerAddr 63> , PeerSession( PeerSession, connectedPeerAddr
66> , swarmSession, enabledExtensions 64> , swarmSession, enabledExtensions
@@ -125,6 +123,7 @@
125> import Network.BitTorrent.Exchange.Protocol as BT 123> import Network.BitTorrent.Exchange.Protocol as BT
126> import Network.BitTorrent.Tracker.Protocol as BT 124> import Network.BitTorrent.Tracker.Protocol as BT
127> import Network.BitTorrent.DHT.Protocol as BT 125> import Network.BitTorrent.DHT.Protocol as BT
126> import System.Torrent.Storage
128 127
129Progress 128Progress
130------------------------------------------------------------------------ 129------------------------------------------------------------------------
@@ -499,6 +498,8 @@ Modify this carefully always updating global progress.
499 498
500> , clientBitfield :: !(TVar Bitfield) 499> , clientBitfield :: !(TVar Bitfield)
501 500
501-- > , storage :: Storage
502
502We keep set of the all connected peers for the each particular torrent 503We keep set of the all connected peers for the each particular torrent
503to prevent duplicated and therefore reduntant TCP connections. For 504to prevent duplicated and therefore reduntant TCP connections. For
504example consider the following very simle and realistic scenario: 505example consider the following very simle and realistic scenario:
@@ -576,10 +577,6 @@ INVARIANT: max_sessions_count - sizeof connectedPeers = value vacantPeers
576> getClientBitfield :: SwarmSession -> IO Bitfield 577> getClientBitfield :: SwarmSession -> IO Bitfield
577> getClientBitfield = readTVarIO . clientBitfield 578> getClientBitfield = readTVarIO . clientBitfield
578 579
579> pieceLength :: SwarmSession -> Int
580> pieceLength = ciPieceLength . tInfo . torrentMeta
581> {-# INLINE pieceLength #-}
582
583> swarmHandshake :: SwarmSession -> Handshake 580> swarmHandshake :: SwarmSession -> Handshake
584> swarmHandshake SwarmSession {..} = Handshake { 581> swarmHandshake SwarmSession {..} = Handshake {
585> hsProtocol = defaultBTProtocol 582> hsProtocol = defaultBTProtocol
@@ -857,7 +854,8 @@ messages & events we should send.
857> mark >> atomically broadcast 854> mark >> atomically broadcast
858> where 855> where
859> mark = do 856> mark = do
860> let bytes = pieceLength se * BF.haveCount bf 857> let piLen = ciPieceLength $ tInfo $ torrentMeta
858> let bytes = piLen * BF.haveCount bf
861> atomically $ do 859> atomically $ do
862> modifyTVar' clientBitfield (BF.union bf) 860> modifyTVar' clientBitfield (BF.union bf)
863> modifyTVar' (currentProgress clientSession) (downloadedProgress bytes) 861> modifyTVar' (currentProgress clientSession) (downloadedProgress bytes)