* 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
* chore: housekeeping
* refactor: store peer info objects in shared_ptr
* refactor: minimise insert/erase operations to the peer info pool
* refactor: unify `on_got_port()` exit point to simplify cleanup
* fix: use `std::unordered_map` as a stand-in for `small::map`
* refactor: use small maps but with `std::vector` as base
* fix: suppress goto warning
* refactor: use `small::map`
* fix: remove constexpr
* 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: remove tr_address_compare()
* refactor: remove tr_address_to_string()
* refactor: remove NUM_TR_AF_INET_TYPES
* refactor: replace tr_sessionGetPublicAddress with tr_session::getPublicAddress()
* refactor: tr_peerIo() takes tr_address by value
* refactor: replace tr_sessionIsAddressBlocked with tr_session::isAddressBlocked()
* refactor: tr_peerMgrAddIncoming now takes tr_address by value
* refactor: replace tr_address_is_valid_for_peers() with tr_address.isValidForPeers()
* refactor: tr_netOpenPeerSocket takes tr_address by value
* refactor: remove tr_generateAllowedSet()
* refactor: setup_sockaddr takes a tr_address by value
* refactor: tr_netBindTCP() takes a tr_address by value
* refactor: tr_dhtAddNode() takes a tr_address by value
* refactor: remove tr_address_from_string()
* refactor: rename tr_address.isValidForPeers() to .isValidPeerAddress()
* refactor: replace tr_address_from_sockaddr_storage() with tr_address::fromSockaddrStorage()
* refactor: minor cleanup to tr_address::readable()
* 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: make tr_peerIo a class
No behavioral changes.
Use `new` and `delete` and change `struct` references to `class`.
* refactor: make some tr_peerIo fields const
* refactor: reorganize tr_peerIo fields to remove padding holes
* refactor: remove redundant field tr_peerIo.isIncoming
* refactor: make tr_peerIo.inbuf, .outbuf fields const*
* 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>
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).
The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
1. add the option the code to be used under GPLv2 or GPLv3; previously only GPLv2 was allowed
2. add the "proxy option" as described in GPLv3 so we can add future licenses without having to bulk-edit everything again :)
3. remove the awkward "exception for MIT code in Mac client" clause; it was unnecessary and confusing.