diff options
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/Internal.lhs | 12 |
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 | ||
129 | Progress | 128 | Progress |
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 | |||
502 | We keep set of the all connected peers for the each particular torrent | 503 | We keep set of the all connected peers for the each particular torrent |
503 | to prevent duplicated and therefore reduntant TCP connections. For | 504 | to prevent duplicated and therefore reduntant TCP connections. For |
504 | example consider the following very simle and realistic scenario: | 505 | example 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) |