diff options
-rw-r--r-- | src/Network/BitTorrent/Internal.lhs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/Network/BitTorrent/Internal.lhs b/src/Network/BitTorrent/Internal.lhs index 8936f507..08e10e71 100644 --- a/src/Network/BitTorrent/Internal.lhs +++ b/src/Network/BitTorrent/Internal.lhs | |||
@@ -114,7 +114,7 @@ | |||
114 | > import Network.BitTorrent.Exchange.Protocol as BT | 114 | > import Network.BitTorrent.Exchange.Protocol as BT |
115 | > import Network.BitTorrent.Tracker.Protocol as BT | 115 | > import Network.BitTorrent.Tracker.Protocol as BT |
116 | 116 | ||
117 | Progress | 117 | Progress |
118 | ------------------------------------------------------------------------ | 118 | ------------------------------------------------------------------------ |
119 | 119 | ||
120 | > -- | 'Progress' contains upload/download/left stats about | 120 | > -- | 'Progress' contains upload/download/left stats about |
@@ -133,9 +133,9 @@ | |||
133 | > | 133 | > |
134 | > $(makeLenses ''Progress) | 134 | > $(makeLenses ''Progress) |
135 | 135 | ||
136 | TODO use Word64? | 136 | **TODO:** Use Word64? |
137 | TODO use atomic bits? | ||
138 | 137 | ||
138 | **TODO:** Use atomic bits? | ||
139 | 139 | ||
140 | Please note that tracker might penalize client some way if the do | 140 | Please note that tracker might penalize client some way if the do |
141 | not accumulate progress. If possible and save 'Progress' between | 141 | not accumulate progress. If possible and save 'Progress' between |
@@ -169,7 +169,7 @@ client sessions to avoid that. | |||
169 | > {-# INLINE dequeuedProgress #-} | 169 | > {-# INLINE dequeuedProgress #-} |
170 | 170 | ||
171 | 171 | ||
172 | Thread layout | 172 | Thread layout |
173 | ------------------------------------------------------------------------ | 173 | ------------------------------------------------------------------------ |
174 | 174 | ||
175 | When client session created 2 new threads appear: | 175 | When client session created 2 new threads appear: |
@@ -196,7 +196,7 @@ So for e.g., in order to obtain our first block we need to run at | |||
196 | least 7 threads: main thread, 2 client session threads, 3 swarm session | 196 | least 7 threads: main thread, 2 client session threads, 3 swarm session |
197 | threads and PeerSession thread. | 197 | threads and PeerSession thread. |
198 | 198 | ||
199 | Thread throttling | 199 | Thread throttling |
200 | ------------------------------------------------------------------------ | 200 | ------------------------------------------------------------------------ |
201 | 201 | ||
202 | If we will not restrict number of threads we could end up | 202 | If we will not restrict number of threads we could end up |
@@ -217,7 +217,7 @@ than seeder threads. | |||
217 | > defaultThreadCount :: ThreadCount | 217 | > defaultThreadCount :: ThreadCount |
218 | > defaultThreadCount = 1000 | 218 | > defaultThreadCount = 1000 |
219 | 219 | ||
220 | Torrent Map | 220 | Torrent Map |
221 | ------------------------------------------------------------------------ | 221 | ------------------------------------------------------------------------ |
222 | 222 | ||
223 | Keeping all seeding torrent metafiles in memory is a _bad_ idea: for | 223 | Keeping all seeding torrent metafiles in memory is a _bad_ idea: for |
@@ -262,7 +262,7 @@ back. | |||
262 | > validateTorrent :: TorrentLoc -> IO () | 262 | > validateTorrent :: TorrentLoc -> IO () |
263 | > validateTorrent = error "validateTorrent: not implemented" | 263 | > validateTorrent = error "validateTorrent: not implemented" |
264 | 264 | ||
265 | Client session | 265 | Client session |
266 | ------------------------------------------------------------------------ | 266 | ------------------------------------------------------------------------ |
267 | 267 | ||
268 | Basically, client session should contain options which user | 268 | Basically, client session should contain options which user |
@@ -375,9 +375,8 @@ and different enabled extensions at the same time. | |||
375 | > unregisterTorrent ClientSession {..} ih = do | 375 | > unregisterTorrent ClientSession {..} ih = do |
376 | > modifyTVar' torrentMap $ HM.delete ih | 376 | > modifyTVar' torrentMap $ HM.delete ih |
377 | 377 | ||
378 | > {----------------------------------------------------------------------- | 378 | Swarm session |
379 | > Swarm session | 379 | ------------------------------------------------------------------------ |
380 | > -----------------------------------------------------------------------} | ||
381 | 380 | ||
382 | > {- NOTE: If client is a leecher then there is NO particular reason to | 381 | > {- NOTE: If client is a leecher then there is NO particular reason to |
383 | > set max sessions count more than the_number_of_unchoke_slots * k: | 382 | > set max sessions count more than the_number_of_unchoke_slots * k: |
@@ -497,9 +496,8 @@ and different enabled extensions at the same time. | |||
497 | > pieceLength = ciPieceLength . tInfo . torrentMeta | 496 | > pieceLength = ciPieceLength . tInfo . torrentMeta |
498 | > {-# INLINE pieceLength #-} | 497 | > {-# INLINE pieceLength #-} |
499 | 498 | ||
500 | > {----------------------------------------------------------------------- | 499 | Peer session |
501 | > Peer session | 500 | ------------------------------------------------------------------------ |
502 | > -----------------------------------------------------------------------} | ||
503 | 501 | ||
504 | > -- | Peer session contain all data necessary for peer to peer | 502 | > -- | Peer session contain all data necessary for peer to peer |
505 | > -- communication. | 503 | > -- communication. |
@@ -621,9 +619,8 @@ and different enabled extensions at the same time. | |||
621 | > findPieceCount :: PeerSession -> PieceCount | 619 | > findPieceCount :: PeerSession -> PieceCount |
622 | > findPieceCount = pieceCount . tInfo . torrentMeta . swarmSession | 620 | > findPieceCount = pieceCount . tInfo . torrentMeta . swarmSession |
623 | 621 | ||
624 | > {----------------------------------------------------------------------- | 622 | Broadcasting: Have, Cancel, Bitfield, SuggestPiece |
625 | > Broadcasting: Have, Cancel, Bitfield, SuggestPiece | 623 | ------------------------------------------------------------------------ |
626 | > -----------------------------------------------------------------------} | ||
627 | 624 | ||
628 | > -- here we should enqueue broadcast messages and keep in mind that: | 625 | > -- here we should enqueue broadcast messages and keep in mind that: |
629 | > -- | 626 | > -- |
@@ -673,9 +670,8 @@ and different enabled extensions at the same time. | |||
673 | > Just a -> (:) <$> pure a <*> readAvail chan | 670 | > Just a -> (:) <$> pure a <*> readAvail chan |
674 | > Nothing -> return [] | 671 | > Nothing -> return [] |
675 | 672 | ||
676 | > {----------------------------------------------------------------------- | 673 | Timeouts |
677 | > Timeouts | 674 | ----------------------------------------------------------------------- |
678 | > -----------------------------------------------------------------------} | ||
679 | 675 | ||
680 | > -- for internal use only | 676 | > -- for internal use only |
681 | 677 | ||