* perf: initialise blame bitfield by piece count
* refactor: set blame for all peers
* refactor: make `tr_swarm::add_strike()` work for all peers
* refactor: move `tr_peer::do_purge` to `tr_peerMsgs`
* fix: limit number of bad pieces to accept from a webseed
* refactor: update bep links
* chore: use more appropriate data types
* chore: checkpoint
* refactor: split `can_request()` into each of their own different signature
* chore: checkpoint
* refactor: convert tr_peerMsgsImpl functions to methods
* chore: checkpoint
* refactor: store peer info as reference
* refactor: convert all member variables to private
* chore: re-arrange methods
* refactor: optimise tmp vector default size in `send_ut_pex()`
* chore: housekeeping
* chore: housekeeping
* refactor: avoid `dynamic_cast` when sending cancel
* fix: restore `blocks_sent_to_peer` stat
regression e91af26923
* fix: choke first then reject
* refactor: convert `tr_peerMsgsNew()` to static factory function
* refactor: store `tr_torrent` reference instead of pointer
* Revert "refactor: store peer info as reference"
This reverts commit bb419bf2
---------
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: simplify tr_swarmGetStats()
* refactor: make addStrike() a tr_swarm member function
* refactor: make updateEndgame() a tr_swarm member function
* refactor: limit scope of some constexpr values
* refactor: make tr_swarm.is_endgame private
* refactor: make tr_swarm.isAllSeeds() a member function
* refactor: add tr_peerMsgs.percentDone()
This moves the `progress` and `have` fields from the `tr_peer` parent
class down into BitTorrent peer subclass, since webseeds by definition
are seeds and have everything.
* refactor: use preferred naming for class members
snake_case for variables, camelCase for methods
* fix: invalid tr_peerMsgsImpl::prefetchCount value
This count could get corrupted due to imprecise bookkeeping when
processing peers' cancel messages. This PR replaces the field with
a `prefetched` flag in the struct that represents a peer request.
This approach has simpler code, simpler logic, and is harder to break.
* refactor: encapsulate request tracking in a class
Introduces a new class to peer-mgr, `ClientRequests`, which tracks what
active requests we've got pending: which blocks, when the requests were
sent, and who they were sent to.
This shouldn't change peer-mgr behavior. Its goal is to carve out some
of peer-mgr's data structures and encapsulte them behind an API that's
simpler to understand.
* refactor: move ActiveRequests to its own file
* perf: avoid duplicate call to tr_cpMissingBlocksInPiece
* Modernize bitfield.cc: Grouped member functions into the struct; C++ construction
* Modernize bitfield.cc: Naming style similar to qt/ C++ source
* Modernize bitfield.cc: Bitfield test updated to new API
* Modernize bitfield.cc: Renames for private functions
* Modernize bitfield.cc: Formatting
* Modernize bitfield.cc: Remove struct in 'struct Bitfield' and update commented code too
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Port libtransmission to C++. This PR doesn't refactor everything to c++.
Its code changes are only what was necessary to compile and link as c++.
See libtransmission/README.md for details on how to submit modernization
patches!
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>