--- /srv/rebuilderd/tmp/rebuilderd4VMFa8/inputs/libtorrent-rasterbar-doc_2.1.1-1_all.deb +++ /srv/rebuilderd/tmp/rebuilderd4VMFa8/out/libtorrent-rasterbar-doc_2.1.1-1_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2026-08-10 15:36:09.000000 debian-binary │ --rw-r--r-- 0 0 0 3712 2026-08-10 15:36:09.000000 control.tar.xz │ --rw-r--r-- 0 0 0 1716716 2026-08-10 15:36:09.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 3708 2026-08-10 15:36:09.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 1719712 2026-08-10 15:36:09.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./control │ │ │ @@ -1,13 +1,13 @@ │ │ │ Package: libtorrent-rasterbar-doc │ │ │ Source: libtorrent-rasterbar │ │ │ Version: 2.1.1-1 │ │ │ Architecture: all │ │ │ Maintainer: Christian Marillat │ │ │ -Installed-Size: 6083 │ │ │ +Installed-Size: 6254 │ │ │ Section: doc │ │ │ Priority: optional │ │ │ Multi-Arch: foreign │ │ │ Homepage: https://libtorrent.org/ │ │ │ Description: Documentation for libtorrent-rasterbar │ │ │ Bittorrent library by Rasterbar Software (Arvid Norberg). │ │ │ libtorrent-rasterbar is a C++ library that aims to be a good alternative to │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -84,37 +84,37 @@ │ │ │ -rw-r--r-- 0 root (0) root (0) 23659 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/python_binding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 38189 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Add_Torrent.html │ │ │ -rw-r--r-- 0 root (0) root (0) 255022 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Alerts.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27781 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25890 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 94758 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Core.html │ │ │ -rw-r--r-- 0 root (0) root (0) 51641 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ --rw-r--r-- 0 root (0) root (0) 66108 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 153593 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27745 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ -rw-r--r-- 0 root (0) root (0) 49936 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ -rw-r--r-- 0 root (0) root (0) 13278 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Filter.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12819 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-PeerClass.html │ │ │ -rw-r--r-- 0 root (0) root (0) 99978 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Plugins.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10894 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html │ │ │ -rw-r--r-- 0 root (0) root (0) 103628 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ -rw-r--r-- 0 root (0) root (0) 177843 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12839 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Stats.html │ │ │ --rw-r--r-- 0 root (0) root (0) 79643 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ --rw-r--r-- 0 root (0) root (0) 137177 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ --rw-r--r-- 0 root (0) root (0) 33234 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 79635 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 137169 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 33226 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ -rw-r--r-- 0 root (0) root (0) 49668 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Status.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16903 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ -rw-r--r-- 0 root (0) root (0) 26549 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9128 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-ed25519.html │ │ │ -rw-r--r-- 0 root (0) root (0) 35480 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │ -rw-r--r-- 0 root (0) root (0) 29242 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/security-audit.html │ │ │ --rw-r--r-- 0 root (0) root (0) 1366882 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 1454343 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10120 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/streaming.html │ │ │ -rw-r--r-- 0 root (0) root (0) 8807 2026-08-10 13:53:00.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/style.css │ │ │ --rw-r--r-- 0 root (0) root (0) 547579 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 547582 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ -rw-r--r-- 0 root (0) root (0) 3022 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/troubleshooting.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25164 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tuning-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 132629 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tutorial-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16383 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/udp_tracker_protocol.html │ │ │ -rw-r--r-- 0 root (0) root (0) 18162 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_1.2-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 34652 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_2.0-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 20295 2026-08-10 15:36:09.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_2.1-ref.html │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/manual-ref.html │ │ │ @@ -100,15 +100,15 @@ │ │ │ the session, it contains the main loop that serves all torrents.

│ │ │

The basic usage is as follows:

│ │ │ │ │ │ │ │ │

The overloads of these functions that accept an error_code parameter │ │ │ will not throw exceptions for I/O, general bdecode, or parsing errors. │ │ │ However, they may still throw std::bad_alloc if memory allocation │ │ │ fails.

│ │ │ +[report issue] │ │ │ +
│ │ │ +

truncate_files()

│ │ │ +

Declared in "libtorrent/truncate.hpp"

│ │ │ +
│ │ │ +void truncate_files (file_storage const& fs, std::string const& save_path, storage_error& ec);
│ │ │ +
│ │ │ +

Truncates files larger than specified in the file_storage, saved under │ │ │ +the specified save_path.

│ │ │ [report issue]
│ │ │
│ │ │

make_magnet_uri()

│ │ │

Declared in "libtorrent/magnet_uri.hpp"

│ │ │
│ │ │  std::string make_magnet_uri (add_torrent_params const& atp);
│ │ │  
│ │ │ @@ -840,31 +849,22 @@ │ │ │

For more information about magnet links, see magnet links.

│ │ │ [report issue]
│ │ │
│ │ │

parse_magnet_uri()

│ │ │

Declared in "libtorrent/magnet_uri.hpp"

│ │ │
│ │ │  add_torrent_params parse_magnet_uri (string_view uri);
│ │ │ -add_torrent_params parse_magnet_uri (string_view uri, error_code& ec);
│ │ │  void parse_magnet_uri (string_view uri, add_torrent_params& p, error_code& ec);
│ │ │ +add_torrent_params parse_magnet_uri (string_view uri, error_code& ec);
│ │ │  
│ │ │

This function parses out information from the magnet link and populates the │ │ │ add_torrent_params object. The overload that does not take an │ │ │ error_code reference will throw a system_error on error │ │ │ The overload taking an add_torrent_params reference will fill in the │ │ │ fields specified in the magnet URI.

│ │ │ -[report issue]
│ │ │ -
│ │ │ -

truncate_files()

│ │ │ -

Declared in "libtorrent/truncate.hpp"

│ │ │ -
│ │ │ -void truncate_files (file_storage const& fs, std::string const& save_path, storage_error& ec);
│ │ │ -
│ │ │ -

Truncates files larger than specified in the file_storage, saved under │ │ │ -the specified save_path.

│ │ │ [report issue]
│ │ │
│ │ │

pread_disk_io_constructor()

│ │ │

Declared in "libtorrent/pread_disk_io.hpp"

│ │ │
│ │ │  std::unique_ptr<disk_interface> pread_disk_io_constructor (
│ │ │     io_context& ios, settings_interface const&, counters& cnt);
│ │ │ @@ -886,73 +886,14 @@
│ │ │  
│ │ │  std::shared_ptr<torrent_plugin> create_i2p_pex_plugin (torrent_handle const&, client_data_t);
│ │ │  
│ │ │

The i2p_pex extension gossips i2p peer addresses, only on i2p torrents. │ │ │ The extension will not activate for non-i2p torrents.

│ │ │

This can either be passed in the add_torrent_params::extensions field, or │ │ │ via torrent_handle::add_extension().

│ │ │ -[report issue]
│ │ │ -
│ │ │ -

enum socket_type_t

│ │ │ -

Declared in "libtorrent/socket_type.hpp"

│ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
namevaluedescription
tcp0 
socks51 
http2 
utp3 
i2p4 
rtc5 
tcp_ssl6 
socks5_ssl7 
http_ssl8 
utp_ssl9 
│ │ │ [report issue]
│ │ │
│ │ │

enum protocol_version

│ │ │

Declared in "libtorrent/info_hash.hpp"

│ │ │ │ │ │ │ │ │ │ │ │ @@ -1104,14 +1045,89 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
http_seed2BEP 17 web seed (no longer supported)
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

enum socket_type_t

│ │ │ +

Declared in "libtorrent/socket_type.hpp"

│ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
namevaluedescription
tcp0 
socks51 
http2 
utp3 
i2p4 
rtc5 
tcp_ssl6 
socks5_ssl7 
http_ssl8 
utp_ssl9 
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

int

│ │ │ +

Declared in "libtorrent/version.hpp"

│ │ │ +
│ │ │ +
version_major
│ │ │ +
the major, minor and tiny versions of libtorrent
│ │ │ +
│ │ │ +
│ │ │ +
version_minor
│ │ │ +
the major, minor and tiny versions of libtorrent
│ │ │ +
│ │ │ +
│ │ │ +
version_tiny
│ │ │ +
the major, minor and tiny versions of libtorrent
│ │ │ +
│ │ │ [report issue]
│ │ │
│ │ │

download_priority_t

│ │ │

Declared in "libtorrent/download_priority.hpp"

│ │ │
│ │ │
dont_download
│ │ │
Don't download the file or piece. Partial pieces may still be downloaded when │ │ │ @@ -1125,46 +1141,14 @@ │ │ │
low_priority
│ │ │
The lowest priority for files and pieces.
│ │ │
│ │ │
│ │ │
top_priority
│ │ │
The highest priority for files and pieces.
│ │ │
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

int

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_major
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -
│ │ │ -
version_minor
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -
│ │ │ -
version_tiny
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

char const*

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_str
│ │ │ -
the libtorrent version in string form
│ │ │ -
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

std::uint64_t

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_revision
│ │ │ -
the git commit of this libtorrent version
│ │ │ -
│ │ │ [report issue]
│ │ │
│ │ │

pex_flags_t

│ │ │

Declared in "libtorrent/pex_flags.hpp"

│ │ │
│ │ │
pex_encryption
│ │ │
the peer supports protocol encryption
│ │ │ @@ -1184,14 +1168,30 @@ │ │ │ the peer fail │ │ │
│ │ │
│ │ │
pex_lt_v2
│ │ │
protocol v2 │ │ │ this is not a standard flag, it is only used internally
│ │ │
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

char const*

│ │ │ +

Declared in "libtorrent/version.hpp"

│ │ │ +
│ │ │ +
version_str
│ │ │ +
the libtorrent version in string form
│ │ │ +
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

std::uint64_t

│ │ │ +

Declared in "libtorrent/version.hpp"

│ │ │ +
│ │ │ +
version_revision
│ │ │ +
the git commit of this libtorrent version
│ │ │ +
│ │ │ [report issue]
│ │ │
│ │ │

torrent_flags_t

│ │ │

Declared in "libtorrent/torrent_flags.hpp"

│ │ │
│ │ │
seed_mode
│ │ │

If seed_mode is set, libtorrent will assume that all files │ │ │ ├── html2text {} │ │ │ │ @@ -1,47 +1,201 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.1 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ - * _p_e_e_r___i_n_f_o │ │ │ │ - o _r_e_m_o_t_e___e_n_d_p_o_i_n_t_(_) │ │ │ │ - o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_) │ │ │ │ - o _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_) │ │ │ │ - * _i_n_f_o___h_a_s_h___t │ │ │ │ - o _i_n_f_o___h_a_s_h___t_(_) │ │ │ │ - o _h_a_s___v_1_(_)_ _h_a_s_(_)_ _h_a_s___v_2_(_) │ │ │ │ - o _g_e_t_(_) │ │ │ │ - o _g_e_t___b_e_s_t_(_) │ │ │ │ * _w_e_b___s_e_e_d___e_n_t_r_y │ │ │ │ o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ o _o_p_e_r_a_t_o_r_<_(_) │ │ │ │ * _p_i_e_c_e___b_l_o_c_k │ │ │ │ + * _i_n_f_o___h_a_s_h___t │ │ │ │ + o _i_n_f_o___h_a_s_h___t_(_) │ │ │ │ + o _h_a_s___v_2_(_)_ _h_a_s___v_1_(_)_ _h_a_s_(_) │ │ │ │ + o _g_e_t_(_) │ │ │ │ + o _g_e_t___b_e_s_t_(_) │ │ │ │ * _p_e_e_r___r_e_q_u_e_s_t │ │ │ │ o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ - * _l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_)_ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_)_ _l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_) │ │ │ │ + * _p_e_e_r___i_n_f_o │ │ │ │ + o _r_e_m_o_t_e___e_n_d_p_o_i_n_t_(_) │ │ │ │ + o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_) │ │ │ │ + o _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_) │ │ │ │ + * _l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_)_ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_)_ _l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ + * _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) │ │ │ │ * _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ * _p_a_r_s_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ - * _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) │ │ │ │ * _p_r_e_a_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _v_e_r_s_i_o_n_(_) │ │ │ │ * _c_r_e_a_t_e___i_2_p___p_e_x___p_l_u_g_i_n_(_) │ │ │ │ - * _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ * _e_n_u_m_ _p_r_o_t_o_c_o_l___v_e_r_s_i_o_n │ │ │ │ * _e_n_u_m_ _p_o_r_t_m_a_p___t_r_a_n_s_p_o_r_t │ │ │ │ * _e_n_u_m_ _p_o_r_t_m_a_p___p_r_o_t_o_c_o_l │ │ │ │ * _e_n_u_m_ _e_v_e_n_t___t │ │ │ │ * _e_n_u_m_ _c_o_n_n_e_c_t_i_o_n___t_y_p_e │ │ │ │ - * _d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t │ │ │ │ + * _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ * _i_n_t │ │ │ │ + * _d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t │ │ │ │ + * _p_e_x___f_l_a_g_s___t │ │ │ │ * _c_h_a_r_ _c_o_n_s_t_* │ │ │ │ * _s_t_d_:_:_u_i_n_t_6_4___t │ │ │ │ - * _p_e_x___f_l_a_g_s___t │ │ │ │ * _t_o_r_r_e_n_t___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ wweebb__sseeeedd__eennttrryy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_e_b___s_e_e_d___e_n_t_r_y_._h_p_p" │ │ │ │ +the _w_e_b___s_e_e_d___e_n_t_r_y holds information about a web seed (also known as URL seed │ │ │ │ +or HTTP seed). It is essentially a URL with some state associated with it. For │ │ │ │ +more information, see _B_E_P_ _1_7 and _B_E_P_ _1_9. │ │ │ │ +struct web_seed_entry │ │ │ │ +{ │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ + bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ + bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ + │ │ │ │ + std::string url; │ │ │ │ + std::string auth; │ │ │ │ + headers_t extra_headers; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ +URL and type comparison │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr<<(()) ********** │ │ │ │ +bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ +URL and type less-than comparison │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + url │ │ │ │ + The URL of the web seed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + auth │ │ │ │ + Optional authentication. If set, this string is sent verbatim as the │ │ │ │ + value of the HTTP Authorization header, and it overrides any credentials │ │ │ │ + embedded in the URL. It is not transformed in any way, so it must be the │ │ │ │ + complete header value. For HTTP basic authentication that means "Basic " │ │ │ │ + followed by the base64 encoding of username:password. For security, this │ │ │ │ + value (as well as any credentials embedded in the URL as "username: │ │ │ │ + password@host") is only sent to the origin of the web seed URL. If the │ │ │ │ + web seed responds with a redirect to a different origin (a different │ │ │ │ + scheme, host or port), it is nnoott forwarded to the new origin. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + extra_headers │ │ │ │ + Any extra HTTP headers that need to be passed to the web seed. Warning: │ │ │ │ + unlike auth, these headers are sent verbatim with every request, │ │ │ │ + including requests to a different origin that the web seed may redirect │ │ │ │ + to. Do not put sensitive credentials (such as an Authorization or Cookie │ │ │ │ + header) here unless you trust every host the web seed might redirect to. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppiieeccee__bblloocckk ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_i_e_c_e___b_l_o_c_k_._h_p_p" │ │ │ │ +identifies a single block within a torrent. piece_index is the piece the block │ │ │ │ +is part of and block_index is the index of the block within the piece. Blocks │ │ │ │ +are normally 16 KiB. │ │ │ │ +struct piece_block │ │ │ │ +{ │ │ │ │ + ppiieeccee__bblloocckk (piece_index_t p_index, int b_index); │ │ │ │ + ppiieeccee__bblloocckk () = default; │ │ │ │ + bool ooppeerraattoorr<< (piece_block const& b) const; │ │ │ │ + bool ooppeerraattoorr==== (piece_block const& b) const; │ │ │ │ + bool ooppeerraattoorr!!== (piece_block const& b) const; │ │ │ │ + │ │ │ │ + static const piece_block invalid; │ │ │ │ + piece_index_t piece_index {0}; │ │ │ │ + int bblloocckk__iinnddeexx = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + invalid piece_index block_index │ │ │ │ + sentinel value representing "no block". Compares unequal to any real │ │ │ │ + block. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinnffoo__hhaasshh__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ +class holding the info-hash of a torrent. It can hold a v1 info-hash (SHA-1) or │ │ │ │ +a v2 info-hash (SHA-256) or both. │ │ │ │ +Note │ │ │ │ +If has_v2() is false then the v1 hash might actually be a truncated v2 hash │ │ │ │ +struct info_hash_t │ │ │ │ +{ │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ + iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ + iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ + bool hhaass__vv11 () const; │ │ │ │ + bool hhaass__vv22 () const; │ │ │ │ + bool hhaass (protocol_version v) const; │ │ │ │ + sha1_hash ggeett (protocol_version v) const; │ │ │ │ + sha1_hash ggeett__bbeesstt () const; │ │ │ │ + friend bool ooppeerraattoorr!!== (info_hash_t const& lhs, info_hash_t const& rhs); │ │ │ │ + friend bool ooppeerraattoorr==== (info_hash_t const& lhs, info_hash_t const& rhs) │ │ │ │ +noexcept; │ │ │ │ + bool ooppeerraattoorr<< (info_hash_t const& o) const; │ │ │ │ + friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih); │ │ │ │ + │ │ │ │ + sha1_hash v1; │ │ │ │ + sha256_hash v2; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iinnffoo__hhaasshh__tt(()) ********** │ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ +iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ +iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ +The default constructor creates an object that has neither a v1 or v2 hash. │ │ │ │ +For backwards compatibility, make it possible to construct directly from a v1 │ │ │ │ +hash. This constructor allows iimmpplliicciitt conversion from a v1 hash, but the │ │ │ │ +implicitness is deprecated. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaass__vv22(()) hhaass__vv11(()) hhaass(()) ********** │ │ │ │ +bool hhaass__vv11 () const; │ │ │ │ +bool hhaass__vv22 () const; │ │ │ │ +bool hhaass (protocol_version v) const; │ │ │ │ +returns true if the corresponding info hash is present in this object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett(()) ********** │ │ │ │ +sha1_hash ggeett (protocol_version v) const; │ │ │ │ +returns the has for the specified protocol version │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett__bbeesstt(()) ********** │ │ │ │ +sha1_hash ggeett__bbeesstt () const; │ │ │ │ +returns the v2 (truncated) info-hash, if there is one, otherwise returns the v1 │ │ │ │ +info-hash │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + v1 v2 │ │ │ │ + the v1 (SHA-1) info-hash and the v2 (SHA-256) info-hash. For a hybrid │ │ │ │ + torrent both are populated. For a pure v1 or pure v2 torrent, the unused │ │ │ │ + field is the all-zero hash. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__rreeqquueesstt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___r_e_q_u_e_s_t_._h_p_p" │ │ │ │ +represents a byte range within a piece. Internally this is is used for incoming │ │ │ │ +piece requests. │ │ │ │ +struct peer_request │ │ │ │ +{ │ │ │ │ + bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ + │ │ │ │ + piece_index_t piece; │ │ │ │ + int start; │ │ │ │ + int length; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ +returns true if the right hand side _p_e_e_r___r_e_q_u_e_s_t refers to the same range as │ │ │ │ +this does. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + piece │ │ │ │ + The index of the piece in which the range starts. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + start │ │ │ │ + The byte offset within that piece where the range starts. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + length │ │ │ │ + The size of the range, in bytes. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppeeeerr__iinnffoo ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___i_n_f_o_._h_p_p" │ │ │ │ holds information and statistics about one peer that libtorrent is connected to │ │ │ │ struct peer_info │ │ │ │ { │ │ │ │ _t_c_p_:_:_e_n_d_p_o_i_n_t rreemmoottee__eennddppooiinntt () const; │ │ │ │ _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const; │ │ │ │ @@ -407,201 +561,54 @@ │ │ │ │ to disk before downloading more. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ read_state write_state │ │ │ │ bitmasks indicating what state this peer is in with regards to sending │ │ │ │ and receiving data. The states are defined as independent flags of type │ │ │ │ bandwidth_state_flags_t, in this class. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinnffoo__hhaasshh__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ -class holding the info-hash of a torrent. It can hold a v1 info-hash (SHA-1) or │ │ │ │ -a v2 info-hash (SHA-256) or both. │ │ │ │ -Note │ │ │ │ -If has_v2() is false then the v1 hash might actually be a truncated v2 hash │ │ │ │ -struct info_hash_t │ │ │ │ -{ │ │ │ │ - iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ - iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ - bool hhaass__vv22 () const; │ │ │ │ - bool hhaass (protocol_version v) const; │ │ │ │ - bool hhaass__vv11 () const; │ │ │ │ - sha1_hash ggeett (protocol_version v) const; │ │ │ │ - sha1_hash ggeett__bbeesstt () const; │ │ │ │ - friend bool ooppeerraattoorr!!== (info_hash_t const& lhs, info_hash_t const& rhs); │ │ │ │ - friend bool ooppeerraattoorr==== (info_hash_t const& lhs, info_hash_t const& rhs) │ │ │ │ -noexcept; │ │ │ │ - bool ooppeerraattoorr<< (info_hash_t const& o) const; │ │ │ │ - friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih); │ │ │ │ - │ │ │ │ - sha1_hash v1; │ │ │ │ - sha256_hash v2; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__hhaasshh__tt(()) ********** │ │ │ │ -iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ -iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ -The default constructor creates an object that has neither a v1 or v2 hash. │ │ │ │ -For backwards compatibility, make it possible to construct directly from a v1 │ │ │ │ -hash. This constructor allows iimmpplliicciitt conversion from a v1 hash, but the │ │ │ │ -implicitness is deprecated. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__vv11(()) hhaass(()) hhaass__vv22(()) ********** │ │ │ │ -bool hhaass__vv22 () const; │ │ │ │ -bool hhaass (protocol_version v) const; │ │ │ │ -bool hhaass__vv11 () const; │ │ │ │ -returns true if the corresponding info hash is present in this object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett(()) ********** │ │ │ │ -sha1_hash ggeett (protocol_version v) const; │ │ │ │ -returns the has for the specified protocol version │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__bbeesstt(()) ********** │ │ │ │ -sha1_hash ggeett__bbeesstt () const; │ │ │ │ -returns the v2 (truncated) info-hash, if there is one, otherwise returns the v1 │ │ │ │ -info-hash │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1 v2 │ │ │ │ - the v1 (SHA-1) info-hash and the v2 (SHA-256) info-hash. For a hybrid │ │ │ │ - torrent both are populated. For a pure v1 or pure v2 torrent, the unused │ │ │ │ - field is the all-zero hash. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ wweebb__sseeeedd__eennttrryy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_e_b___s_e_e_d___e_n_t_r_y_._h_p_p" │ │ │ │ -the _w_e_b___s_e_e_d___e_n_t_r_y holds information about a web seed (also known as URL seed │ │ │ │ -or HTTP seed). It is essentially a URL with some state associated with it. For │ │ │ │ -more information, see _B_E_P_ _1_7 and _B_E_P_ _1_9. │ │ │ │ -struct web_seed_entry │ │ │ │ -{ │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ - web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ - web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ - bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ - bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ - │ │ │ │ - std::string url; │ │ │ │ - std::string auth; │ │ │ │ - headers_t extra_headers; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr====(()) ********** │ │ │ │ -bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ -URL and type comparison │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr<<(()) ********** │ │ │ │ -bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ -URL and type less-than comparison │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - url │ │ │ │ - The URL of the web seed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - auth │ │ │ │ - Optional authentication. If set, this string is sent verbatim as the │ │ │ │ - value of the HTTP Authorization header, and it overrides any credentials │ │ │ │ - embedded in the URL. It is not transformed in any way, so it must be the │ │ │ │ - complete header value. For HTTP basic authentication that means "Basic " │ │ │ │ - followed by the base64 encoding of username:password. For security, this │ │ │ │ - value (as well as any credentials embedded in the URL as "username: │ │ │ │ - password@host") is only sent to the origin of the web seed URL. If the │ │ │ │ - web seed responds with a redirect to a different origin (a different │ │ │ │ - scheme, host or port), it is nnoott forwarded to the new origin. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - extra_headers │ │ │ │ - Any extra HTTP headers that need to be passed to the web seed. Warning: │ │ │ │ - unlike auth, these headers are sent verbatim with every request, │ │ │ │ - including requests to a different origin that the web seed may redirect │ │ │ │ - to. Do not put sensitive credentials (such as an Authorization or Cookie │ │ │ │ - header) here unless you trust every host the web seed might redirect to. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppiieeccee__bblloocckk ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_i_e_c_e___b_l_o_c_k_._h_p_p" │ │ │ │ -identifies a single block within a torrent. piece_index is the piece the block │ │ │ │ -is part of and block_index is the index of the block within the piece. Blocks │ │ │ │ -are normally 16 KiB. │ │ │ │ -struct piece_block │ │ │ │ -{ │ │ │ │ - ppiieeccee__bblloocckk () = default; │ │ │ │ - ppiieeccee__bblloocckk (piece_index_t p_index, int b_index); │ │ │ │ - bool ooppeerraattoorr<< (piece_block const& b) const; │ │ │ │ - bool ooppeerraattoorr==== (piece_block const& b) const; │ │ │ │ - bool ooppeerraattoorr!!== (piece_block const& b) const; │ │ │ │ - │ │ │ │ - static const piece_block invalid; │ │ │ │ - piece_index_t piece_index {0}; │ │ │ │ - int bblloocckk__iinnddeexx = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - invalid piece_index block_index │ │ │ │ - sentinel value representing "no block". Compares unequal to any real │ │ │ │ - block. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__rreeqquueesstt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___r_e_q_u_e_s_t_._h_p_p" │ │ │ │ -represents a byte range within a piece. Internally this is is used for incoming │ │ │ │ -piece requests. │ │ │ │ -struct peer_request │ │ │ │ -{ │ │ │ │ - bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ - │ │ │ │ - piece_index_t piece; │ │ │ │ - int start; │ │ │ │ - int length; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr====(()) ********** │ │ │ │ -bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ -returns true if the right hand side _p_e_e_r___r_e_q_u_e_s_t refers to the same range as │ │ │ │ -this does. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece │ │ │ │ - The index of the piece in which the range starts. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - start │ │ │ │ - The byte offset within that piece where the range starts. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - length │ │ │ │ - The size of the range, in bytes. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ llooaadd__ttoorrrreenntt__ffiillee(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) ************ │ │ │ │ +************ llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) llooaadd__ttoorrrreenntt__ffiillee(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_l_o_a_d___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ - std::string const& filename); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ - bdecode_node const& torrent_file, load_torrent_limits const& cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ - span buffer, error_code& ec, load_torrent_limits const& cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ - std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ - span buffer, load_torrent_limits const& cfg); │ │ │ │ + bdecode_node const& torrent_file, error_code& ec, load_torrent_limits const& │ │ │ │ +cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ bdecode_node const& torrent_file); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ std::string const& filename, error_code& ec, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ + std::string const& filename); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ span buffer); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ + span buffer, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ + span buffer, error_code& ec, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ + std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ - bdecode_node const& torrent_file, error_code& ec, load_torrent_limits const& │ │ │ │ -cfg); │ │ │ │ + bdecode_node const& torrent_file, load_torrent_limits const& cfg); │ │ │ │ These functions load the content of a .torrent file into an _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ object. The immutable part of a torrent file (the info-dictionary) is stored in │ │ │ │ the ti field in the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object (as a _t_o_r_r_e_n_t___i_n_f_o object). The │ │ │ │ returned object is suitable to be: │ │ │ │ * added to a _s_e_s_s_i_o_n via _a_d_d___t_o_r_r_e_n_t_(_) or _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ * saved as a .torrent_file via _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ * turned into a magnet link via _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ The overloads of these functions that accept anerror_codeparameter will not │ │ │ │ throw exceptions for I/O, general bdecode, or parsing errors. However, they may │ │ │ │ still throwstd::bad_allocif memory allocation fails. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrruunnccaattee__ffiilleess(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_r_u_n_c_a_t_e_._h_p_p" │ │ │ │ +void ttrruunnccaattee__ffiilleess (file_storage const& fs, std::string const& save_path, │ │ │ │ +storage_error& ec); │ │ │ │ +Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ +specified save_path. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ mmaakkee__mmaaggnneett__uurrii(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_a_g_n_e_t___u_r_i_._h_p_p" │ │ │ │ std::string mmaakkee__mmaaggnneett__uurrii (add_torrent_params const& atp); │ │ │ │ Generates a magnet URI from the specified torrent. │ │ │ │ Several fields from the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s objects are recorded in the magnet │ │ │ │ link. In order to not include them, they have to be cleared before calling │ │ │ │ _m_a_k_e___m_a_g_n_e_t___u_r_i_(_). These fields are used: │ │ │ │ @@ -617,29 +624,22 @@ │ │ │ │ _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_), which will post a _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t containing an │ │ │ │ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. This can then be passed to _m_a_k_e___m_a_g_n_e_t___u_r_i_(_). │ │ │ │ For more information about magnet links, see _m_a_g_n_e_t_ _l_i_n_k_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppaarrssee__mmaaggnneett__uurrii(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_a_g_n_e_t___u_r_i_._h_p_p" │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri); │ │ │ │ -add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri, error_code& ec); │ │ │ │ void ppaarrssee__mmaaggnneett__uurrii (string_view uri, add_torrent_params& p, error_code& ec); │ │ │ │ +add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri, error_code& ec); │ │ │ │ This function parses out information from the magnet link and populates the │ │ │ │ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object. The overload that does not take an error_code │ │ │ │ reference will throw a system_error on error The overload taking an │ │ │ │ add_torrent_params reference will fill in the fields specified in the magnet │ │ │ │ URI. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrruunnccaattee__ffiilleess(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_r_u_n_c_a_t_e_._h_p_p" │ │ │ │ -void ttrruunnccaattee__ffiilleess (file_storage const& fs, std::string const& save_path, │ │ │ │ -storage_error& ec); │ │ │ │ -Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ -specified save_path. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ pprreeaadd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_r_e_a_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ std::unique_ptr pprreeaadd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ constructs a multi-threaded file disk I/O using pread()/pwrite() │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ vveerrssiioonn(()) ************ │ │ │ │ @@ -653,29 +653,14 @@ │ │ │ │ std::shared_ptr ccrreeaattee__ii22pp__ppeexx__pplluuggiinn (torrent_handle const&, │ │ │ │ client_data_t); │ │ │ │ The i2p_pex extension gossips i2p peer addresses, only on i2p torrents. The │ │ │ │ extension will not activate for non-i2p torrents. │ │ │ │ This can either be passed in the add_torrent_params::extensions field, or via │ │ │ │ _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_a_d_d___e_x_t_e_n_s_i_o_n_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ssoocckkeett__ttyyppee__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_e_t___t_y_p_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k_s_5_ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_t_t_p_ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p_ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_t_c_ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_c_p___s_s_l_ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k_s_5___s_s_l_|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_t_t_p___s_s_l_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p___s_s_l_ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ eennuumm pprroottooccooll__vveerrssiioonn ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_V_1_ _ _|_0_ _ _ _ _|_T_h_e_ _o_r_i_g_i_n_a_l_ _B_i_t_T_o_r_r_e_n_t_ _v_e_r_s_i_o_n_,_ _u_s_i_n_g_ _S_H_A_-_1_ _h_a_s_h_e_s_ _ _ _ _ _ _ | │ │ │ │ |_V_2_ _ _|_1_ _ _ _ _|_V_e_r_s_i_o_n_ _2_ _o_f_ _t_h_e_ _B_i_t_T_o_r_r_e_n_t_ _p_r_o_t_o_c_o_l_,_ _u_s_i_n_g_ _S_H_A_-_2_5_6_ _h_a_s_h_e_s| │ │ │ │ |_N_U_M_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ @@ -709,45 +694,50 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_b_i_t_t_o_r_r_e_n_t_|_0_ _ _ _ _|_t_h_i_s_ _i_s_ _a_ _r_e_g_u_l_a_r_ _b_i_t_t_o_r_r_e_n_t_ _p_e_e_r_ _c_o_n_n_e_c_t_i_o_n| │ │ │ │ |_u_r_l___s_e_e_d_ _ _|_1_ _ _ _ _|_B_E_P_ _1_9_ _w_e_b_ _s_e_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_h_t_t_p___s_e_e_d_ _|_2_ _ _ _ _|_B_E_P_ _1_7_ _w_e_b_ _s_e_e_d_ _(_n_o_ _l_o_n_g_e_r_ _s_u_p_p_o_r_t_e_d_)_ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ eennuumm ssoocckkeett__ttyyppee__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_e_t___t_y_p_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k_s_5_ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_t_t_p_ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p_ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_t_c_ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_c_p___s_s_l_ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k_s_5___s_s_l_|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_t_t_p___s_s_l_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p___s_s_l_ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinntt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_major │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ + version_minor │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ + version_tiny │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddoowwnnllooaadd__pprriioorriittyy__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y_._h_p_p" │ │ │ │ dont_download │ │ │ │ Don't download the file or piece. Partial pieces may still be downloaded │ │ │ │ when setting file priorities. │ │ │ │ default_priority │ │ │ │ The default priority for files and pieces. │ │ │ │ low_priority │ │ │ │ The lowest priority for files and pieces. │ │ │ │ top_priority │ │ │ │ The highest priority for files and pieces. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinntt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_major │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ - version_minor │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ - version_tiny │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ cchhaarr ccoonnsstt** ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_str │ │ │ │ - the libtorrent version in string form │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttdd::::uuiinntt6644__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_revision │ │ │ │ - the git commit of this libtorrent version │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppeexx__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_x___f_l_a_g_s_._h_p_p" │ │ │ │ pex_encryption │ │ │ │ the peer supports protocol encryption │ │ │ │ pex_seed │ │ │ │ the peer is a seed │ │ │ │ pex_utp │ │ │ │ @@ -755,14 +745,24 @@ │ │ │ │ pex_holepunch │ │ │ │ the peer supports the holepunch extension If this flag is received from a │ │ │ │ peer, it can be used as a rendezvous point in case direct connections to │ │ │ │ the peer fail │ │ │ │ pex_lt_v2 │ │ │ │ protocol v2 this is not a standard flag, it is only used internally │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ cchhaarr ccoonnsstt** ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_str │ │ │ │ + the libtorrent version in string form │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttdd::::uuiinntt6644__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_revision │ │ │ │ + the git commit of this libtorrent version │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ttoorrrreenntt__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___f_l_a_g_s_._h_p_p" │ │ │ │ seed_mode │ │ │ │ If seed_mode is set, libtorrent will assume that all files are present │ │ │ │ for this torrent and that they all match the hashes in the torrent file. │ │ │ │ Each time a peer requests to download a block, the piece is verified │ │ │ │ against the hash, unless it has been verified already. If a hash fails, │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ @@ -56,15 +56,15 @@ │ │ │

  • piece_range()
  • │ │ │
  • end_file()
  • │ │ │
  • file_range()
  • │ │ │
  • file_at()
  • │ │ │
  • file_piece_range()
  • │ │ │
  • total_size()
  • │ │ │
  • piece_length() piece_size()
  • │ │ │ -
  • add_similar_torrent() add_collection()
  • │ │ │ +
  • add_collection() add_similar_torrent()
  • │ │ │ │ │ │ │ │ │
  • list_files()
  • │ │ │
  • set_piece_hashes()
  • │ │ │ │ │ │
    │ │ │

    This section describes the functions and classes that are used │ │ │ @@ -167,41 +167,41 @@ │ │ │ the torrent. The entry that's returned can then be bencoded into a │ │ │ .torrent file using bencode().

    │ │ │
    │ │ │  struct create_torrent
    │ │ │  {
    │ │ │     explicit create_torrent (std::vector<create_file_entry> files, int piece_size = 0
    │ │ │        , create_flags_t flags = {});
    │ │ │ -   entry generate () const;
    │ │ │     std::vector<char> generate_buf () const;
    │ │ │ +   entry generate () const;
    │ │ │     void set_comment (char const* str);
    │ │ │     void set_creator (char const* str);
    │ │ │     void set_creation_date (std::time_t timestamp);
    │ │ │     void set_hash (piece_index_t index, sha1_hash const& h);
    │ │ │     void set_hash2 (file_index_t file, piece_index_t::diff_type piece, sha256_hash const& h);
    │ │ │     void add_url_seed (string_view url);
    │ │ │     void add_node (std::pair<std::string, int> node);
    │ │ │     void add_tracker (string_view url, int tier = 0);
    │ │ │     void set_root_cert (string_view cert);
    │ │ │ -   void set_priv (bool p);
    │ │ │     bool priv () const;
    │ │ │ +   void set_priv (bool p);
    │ │ │     bool is_v1_only () const;
    │ │ │     bool is_v2_only () const;
    │ │ │     int num_pieces () const;
    │ │ │     piece_index_t end_piece () const;
    │ │ │     index_range<piece_index_t> piece_range () const noexcept;
    │ │ │     file_index_t end_file () const;
    │ │ │     index_range<file_index_t> file_range () const noexcept;
    │ │ │     create_file_entry const& file_at (file_index_t f) const;
    │ │ │     index_range<piece_index_t::diff_type> file_piece_range (file_index_t f);
    │ │ │     std::int64_t total_size () const;
    │ │ │ -   int piece_size (piece_index_t i) const;
    │ │ │     int piece_length () const;
    │ │ │ -   void add_similar_torrent (sha1_hash ih);
    │ │ │ +   int piece_size (piece_index_t i) const;
    │ │ │     void add_collection (string_view c);
    │ │ │ +   void add_similar_torrent (sha1_hash ih);
    │ │ │  
    │ │ │     static inline constexpr create_flags_t modification_time  = 2_bit;
    │ │ │     static inline constexpr create_flags_t symlinks  = 3_bit;
    │ │ │     static inline constexpr create_flags_t v2_only  = 5_bit;
    │ │ │     static inline constexpr create_flags_t v1_only  = 6_bit;
    │ │ │     static inline constexpr create_flags_t canonical_files  = 7_bit;
    │ │ │     static inline constexpr create_flags_t no_attributes  = 8_bit;
    │ │ │ @@ -252,16 +252,16 @@
    │ │ │  entire duration of the create_torrent object.

    │ │ │ │ │ │ │ │ │ [report issue] │ │ │
    │ │ │

    generate_buf() generate()

    │ │ │
    │ │ │ -entry generate () const;
    │ │ │  std::vector<char> generate_buf () const;
    │ │ │ +entry generate () const;
    │ │ │  
    │ │ │

    This function will generate the .torrent file as a bencode tree, or a │ │ │ bencoded into a buffer. │ │ │ In order to encode the entry into a flat file, use the bencode() function.

    │ │ │

    The function returning an entry may be useful to add custom entries │ │ │ to the torrent file before bencoding it and saving it to disk.

    │ │ │

    Whether the resulting torrent object is v1, v2 or hybrid depends on │ │ │ @@ -386,16 +386,16 @@ │ │ │

    The string is not the path to the cert, it's the actual content of the │ │ │ certificate.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    priv() set_priv()

    │ │ │
    │ │ │ -void set_priv (bool p);
    │ │ │  bool priv () const;
    │ │ │ +void set_priv (bool p);
    │ │ │  
    │ │ │

    Sets and queries the private flag of the torrent. │ │ │ Torrents with the private flag set ask the client to not use any other │ │ │ sources than the tracker for peers, and to not use DHT to advertise itself publicly, │ │ │ only the tracker.

    │ │ │ │ │ │ [report issue]
    │ │ │ @@ -472,27 +472,27 @@ │ │ │
    │ │ │

    the total number of bytes of all files and pad files

    │ │ │ │ │ │ [report issue] │ │ │
    │ │ │

    piece_length() piece_size()

    │ │ │
    │ │ │ -int piece_size (piece_index_t i) const;
    │ │ │  int piece_length () const;
    │ │ │ +int piece_size (piece_index_t i) const;
    │ │ │  
    │ │ │

    piece_length() returns the piece size of all pieces but the │ │ │ last one. piece_size() returns the size of the specified piece. │ │ │ these functions are just forwarding to the associated file_storage.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_similar_torrent() add_collection()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_collection() add_similar_torrent()

    │ │ │
    │ │ │ -void add_similar_torrent (sha1_hash ih);
    │ │ │  void add_collection (string_view c);
    │ │ │ +void add_similar_torrent (sha1_hash ih);
    │ │ │  
    │ │ │

    Add similar torrents (by info-hash) or collections of similar torrents. │ │ │ Similar torrents are expected to share some files with this torrent. │ │ │ Torrents sharing a collection name with this torrent are also expected │ │ │ to share files with this torrent. A torrent may have more than one │ │ │ collection and more than one similar torrents. For more information, │ │ │ see BEP 38.

    │ │ │ @@ -580,29 +580,29 @@ │ │ │

    The flags argument should be the same as the flags passed to the create_torrent │ │ │ constructor.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    set_piece_hashes()

    │ │ │

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │
    │ │ │ -void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , settings_pack const& settings, disk_io_constructor_type disk_io
    │ │ │ -   , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
    │ │ │  inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , settings_pack const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f);
    │ │ │ -inline void set_piece_hashes (create_torrent& t, std::string const& p);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , settings_pack const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ +void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , settings_pack const& settings, disk_io_constructor_type disk_io
    │ │ │ +   , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p);
    │ │ │  inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , settings_pack const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ -inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
    │ │ │  
    │ │ │

    This function will assume that the files added to the torrent file exists at path │ │ │ p, read those files and hash the content and set the hashes in the create_torrent │ │ │ object. The optional function f is called in between every hash that is set. f │ │ │ must have the following signature:

    │ │ │
    │ │ │  void Fun(piece_index_t);
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -25,15 +25,15 @@
    │ │ │ │            o _p_i_e_c_e___r_a_n_g_e_(_)
    │ │ │ │            o _e_n_d___f_i_l_e_(_)
    │ │ │ │            o _f_i_l_e___r_a_n_g_e_(_)
    │ │ │ │            o _f_i_l_e___a_t_(_)
    │ │ │ │            o _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)
    │ │ │ │            o _t_o_t_a_l___s_i_z_e_(_)
    │ │ │ │            o _p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___s_i_z_e_(_)
    │ │ │ │ -          o _a_d_d___s_i_m_i_l_a_r___t_o_r_r_e_n_t_(_)_ _a_d_d___c_o_l_l_e_c_t_i_o_n_(_)
    │ │ │ │ +          o _a_d_d___c_o_l_l_e_c_t_i_o_n_(_)_ _a_d_d___s_i_m_i_l_a_r___t_o_r_r_e_n_t_(_)
    │ │ │ │      * _l_i_s_t___f_i_l_e_s_(_)
    │ │ │ │      * _s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_)
    │ │ │ │  This section describes the functions and classes that are used to create
    │ │ │ │  torrent files. It is a layered API with low level classes and higher level
    │ │ │ │  convenience functions. A torrent is created in 4 steps:
    │ │ │ │     1. first the files that will be part of the torrent are determined.
    │ │ │ │     2. the torrent properties are set, such as tracker url, web seeds, DHT nodes
    │ │ │ │ @@ -116,42 +116,42 @@
    │ │ │ │  _e_n_t_r_y that's returned can then be bencoded into a .torrent file using _b_e_n_c_o_d_e
    │ │ │ │  _(_).
    │ │ │ │  struct create_torrent
    │ │ │ │  {
    │ │ │ │     explicit ccrreeaattee__ttoorrrreenntt (std::vector files, int
    │ │ │ │  piece_size = 0
    │ │ │ │        , create_flags_t flags = {});
    │ │ │ │ -   entry ggeenneerraattee () const;
    │ │ │ │     std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │ +   entry ggeenneerraattee () const;
    │ │ │ │     void sseett__ccoommmmeenntt (char const* str);
    │ │ │ │     void sseett__ccrreeaattoorr (char const* str);
    │ │ │ │     void sseett__ccrreeaattiioonn__ddaattee (std::time_t timestamp);
    │ │ │ │     void sseett__hhaasshh (piece_index_t index, sha1_hash const& h);
    │ │ │ │     void sseett__hhaasshh22 (file_index_t file, piece_index_t::diff_type piece,
    │ │ │ │  sha256_hash const& h);
    │ │ │ │     void aadddd__uurrll__sseeeedd (string_view url);
    │ │ │ │     void aadddd__nnooddee (std::pair node);
    │ │ │ │     void aadddd__ttrraacckkeerr (string_view url, int tier = 0);
    │ │ │ │     void sseett__rroooott__cceerrtt (string_view cert);
    │ │ │ │ -   void sseett__pprriivv (bool p);
    │ │ │ │     bool pprriivv () const;
    │ │ │ │ +   void sseett__pprriivv (bool p);
    │ │ │ │     bool iiss__vv11__oonnllyy () const;
    │ │ │ │     bool iiss__vv22__oonnllyy () const;
    │ │ │ │     int nnuumm__ppiieecceess () const;
    │ │ │ │     piece_index_t eenndd__ppiieeccee () const;
    │ │ │ │     index_range ppiieeccee__rraannggee () const noexcept;
    │ │ │ │     file_index_t eenndd__ffiillee () const;
    │ │ │ │     index_range ffiillee__rraannggee () const noexcept;
    │ │ │ │     create_file_entry const& ffiillee__aatt (file_index_t f) const;
    │ │ │ │     index_range ffiillee__ppiieeccee__rraannggee (file_index_t f);
    │ │ │ │     std::int64_t ttoottaall__ssiizzee () const;
    │ │ │ │ -   int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │     int ppiieeccee__lleennggtthh () const;
    │ │ │ │ -   void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │ +   int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │     void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │ +   void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │  
    │ │ │ │     static inline constexpr create_flags_t mmooddiiffiiccaattiioonn__ttiimmee  = 2_bit;
    │ │ │ │     static inline constexpr create_flags_t ssyymmlliinnkkss  = 3_bit;
    │ │ │ │     static inline constexpr create_flags_t vv22__oonnllyy  = 5_bit;
    │ │ │ │     static inline constexpr create_flags_t vv11__oonnllyy  = 6_bit;
    │ │ │ │     static inline constexpr create_flags_t ccaannoonniiccaall__ffiilleess  = 7_bit;
    │ │ │ │     static inline constexpr create_flags_t nnoo__aattttrriibbuutteess  = 8_bit;
    │ │ │ │ @@ -191,16 +191,16 @@
    │ │ │ │  (such as _s_e_t___h_a_s_h_(_)), will have any affect. Instead of using this overload,
    │ │ │ │  consider using _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) instead.
    │ │ │ │  Warning
    │ │ │ │  The _f_i_l_e___s_t_o_r_a_g_e and _t_o_r_r_e_n_t___i_n_f_o objects must stay alive for the entire
    │ │ │ │  duration of the _c_r_e_a_t_e___t_o_r_r_e_n_t object.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ggeenneerraattee__bbuuff(()) ggeenneerraattee(()) **********
    │ │ │ │ -entry ggeenneerraattee () const;
    │ │ │ │  std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │ +entry ggeenneerraattee () const;
    │ │ │ │  This function will generate the .torrent file as a bencode tree, or a bencoded
    │ │ │ │  into a buffer. In order to encode the _e_n_t_r_y into a flat file, use the _b_e_n_c_o_d_e_(_)
    │ │ │ │  function.
    │ │ │ │  The function returning an _e_n_t_r_y may be useful to add custom entries to the
    │ │ │ │  torrent file before bencoding it and saving it to disk.
    │ │ │ │  Whether the resulting torrent object is v1, v2 or hybrid depends on whether any
    │ │ │ │  of the v1_only or v2_only flags were set on the constructor. If neither were
    │ │ │ │ @@ -288,16 +288,16 @@
    │ │ │ │  valid certificate signed by this root certificate. For SSL torrents, all peers
    │ │ │ │  are connecting over SSL connections. For more information, see the section on
    │ │ │ │  _s_s_l_ _t_o_r_r_e_n_t_s.
    │ │ │ │  The string is not the path to the cert, it's the actual content of the
    │ │ │ │  certificate.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** pprriivv(()) sseett__pprriivv(()) **********
    │ │ │ │ -void sseett__pprriivv (bool p);
    │ │ │ │  bool pprriivv () const;
    │ │ │ │ +void sseett__pprriivv (bool p);
    │ │ │ │  Sets and queries the private flag of the torrent. Torrents with the private
    │ │ │ │  flag set ask the client to not use any other sources than the tracker for
    │ │ │ │  peers, and to not use DHT to advertise itself publicly, only the tracker.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** iiss__vv22__oonnllyy(()) iiss__vv11__oonnllyy(()) **********
    │ │ │ │  bool iiss__vv11__oonnllyy () const;
    │ │ │ │  bool iiss__vv22__oonnllyy () const;
    │ │ │ │ @@ -339,23 +339,23 @@
    │ │ │ │  delta from the first piece in the file. i.e. the first index is 0.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttoottaall__ssiizzee(()) **********
    │ │ │ │  std::int64_t ttoottaall__ssiizzee () const;
    │ │ │ │  the total number of bytes of all files and pad files
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ppiieeccee__lleennggtthh(()) ppiieeccee__ssiizzee(()) **********
    │ │ │ │ -int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │  int ppiieeccee__lleennggtthh () const;
    │ │ │ │ +int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │  piece_length() returns the piece size of all pieces but the last one.
    │ │ │ │  piece_size() returns the size of the specified piece. these functions are just
    │ │ │ │  forwarding to the associated _f_i_l_e___s_t_o_r_a_g_e.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__ssiimmiillaarr__ttoorrrreenntt(()) aadddd__ccoolllleeccttiioonn(()) **********
    │ │ │ │ -void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │ +********** aadddd__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) **********
    │ │ │ │  void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │ +void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │  Add similar torrents (by info-hash) or collections of similar torrents. Similar
    │ │ │ │  torrents are expected to share some files with this torrent. Torrents sharing a
    │ │ │ │  collection name with this torrent are also expected to share files with this
    │ │ │ │  torrent. A torrent may have more than one collection and more than one similar
    │ │ │ │  torrents. For more information, see _B_E_P_ _3_8.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │    modification_time
    │ │ │ │ @@ -423,30 +423,30 @@
    │ │ │ │  directories are traversed.
    │ │ │ │  The ".." directory is never traversed.
    │ │ │ │  The flags argument should be the same as the flags passed to the _c_r_e_a_t_e___t_o_r_r_e_n_t
    │ │ │ │  constructor.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ sseett__ppiieeccee__hhaasshheess(()) ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p"
    │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , settings_pack const& settings, disk_io_constructor_type disk_io
    │ │ │ │ -   , std::function const& f, error_code& ec);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p,
    │ │ │ │ +error_code& ec);
    │ │ │ │  inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , settings_pack const& settings
    │ │ │ │     , std::function const& f);
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │     , settings_pack const& settings
    │ │ │ │     , std::function const& f, error_code& ec);
    │ │ │ │ +void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , settings_pack const& settings, disk_io_constructor_type disk_io
    │ │ │ │ +   , std::function const& f, error_code& ec);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p);
    │ │ │ │  inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , settings_pack const& settings
    │ │ │ │     , std::function const& f);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │     , std::function const& f, error_code& ec);
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p,
    │ │ │ │ -error_code& ec);
    │ │ │ │  This function will assume that the files added to the torrent file exists at
    │ │ │ │  path p, read those files and hash the content and set the hashes in the
    │ │ │ │  create_torrent object. The optional function f is called in between every hash
    │ │ │ │  that is set. f must have the following signature:
    │ │ │ │  void Fun(piece_index_t);
    │ │ │ │  The overloads taking a _s_e_t_t_i_n_g_s___p_a_c_k may be used to configure the underlying
    │ │ │ │  disk access. Such as settings_pack::aio_threads.
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html
    │ │ │ @@ -28,92 +28,418 @@
    │ │ │  2.1.1
    │ │ │  
    │ │ │  
    │ │ │  

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
    │ │ │ -

    You have some control over session configuration through the session::apply_settings() │ │ │ -member function. To change one or more configuration options, create a settings_pack │ │ │ -object and fill it with the settings to be set and pass it in to session::apply_settings().

    │ │ │ -

    The settings_pack object is a collection of settings updates that are applied │ │ │ -to the session when passed to session::apply_settings(). It's empty when │ │ │ -constructed.

    │ │ │ -

    You have control over proxy and authorization settings and also the user-agent │ │ │ -that will be sent to the tracker. The user-agent will also be used to identify the │ │ │ -client with other peers.

    │ │ │ -

    Each configuration option is named with an enum value inside the │ │ │ -settings_pack class. These are the available settings:

    │ │ │ -[report issue]
    │ │ │ +

    The disk I/O can be customized in libtorrent. In previous versions, the │ │ │ +customization was at the level of each torrent. Now, the customization point │ │ │ +is at the session level. All torrents added to a session will use the same │ │ │ +disk I/O subsystem, as determined by the disk_io_constructor (in │ │ │ +session_params).

    │ │ │ +

    This allows the disk subsystem to also customize threading and disk job │ │ │ +management.

    │ │ │ +

    To customize the disk subsystem, implement disk_interface and provide a │ │ │ +factory function to the session constructor (via session_params).

    │ │ │ +

    Example use:

    │ │ │ +
    │ │ │ +struct temp_storage
    │ │ │ +{
    │ │ │ +  explicit temp_storage(lt::file_storage const& fs) : m_files(fs) {}
    │ │ │ +
    │ │ │ +  lt::span<char const> readv(lt::peer_request const r, lt::storage_error& ec) const
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(r.piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    if (int(i->second.size()) <= r.start)
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    return { i->second.data() + r.start, std::min(r.length, int(i->second.size()) - r.start) };
    │ │ │ +  }
    │ │ │ +  void writev(lt::span<char const> const b, lt::piece_index_t const piece, int const offset)
    │ │ │ +  {
    │ │ │ +    auto& data = m_file_data[piece];
    │ │ │ +    if (data.empty())
    │ │ │ +    {
    │ │ │ +      // allocate the whole piece, otherwise we'll invalidate the pointers
    │ │ │ +      // we have returned back to libtorrent
    │ │ │ +      int const size = piece_size(piece);
    │ │ │ +      data.resize(std::size_t(size));
    │ │ │ +    }
    │ │ │ +    TORRENT_ASSERT(offset + b.size() <= int(data.size()));
    │ │ │ +    std::memcpy(data.data() + offset, b.data(), std::size_t(b.size()));
    │ │ │ +  }
    │ │ │ +  lt::sha1_hash hash(lt::piece_index_t const piece
    │ │ │ +    , lt::span<lt::sha256_hash> const block_hashes, lt::storage_error& ec) const
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    if (!block_hashes.empty())
    │ │ │ +    {
    │ │ │ +      int const piece_size2 = m_files.piece_size2(piece);
    │ │ │ +      int const blocks_in_piece2 = m_files.blocks_in_piece2(piece);
    │ │ │ +      char const* buf = i->second.data();
    │ │ │ +      std::int64_t offset = 0;
    │ │ │ +      for (int k = 0; k < blocks_in_piece2; ++k)
    │ │ │ +      {
    │ │ │ +        lt::hasher256 h2;
    │ │ │ +        std::ptrdiff_t const len2 = std::min(lt::default_block_size, int(piece_size2 - offset));
    │ │ │ +        h2.update({ buf, len2 });
    │ │ │ +        buf += len2;
    │ │ │ +        offset += len2;
    │ │ │ +        block_hashes[k] = h2.final();
    │ │ │ +      }
    │ │ │ +    }
    │ │ │ +    return lt::hasher(i->second).final();
    │ │ │ +  }
    │ │ │ +  lt::sha256_hash hash2(lt::piece_index_t const piece, int const offset, lt::storage_error& ec)
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +
    │ │ │ +    int const piece_size = m_files.piece_size2(piece);
    │ │ │ +
    │ │ │ +    std::ptrdiff_t const len = std::min(lt::default_block_size, piece_size - offset);
    │ │ │ +
    │ │ │ +    lt::span<char const> b = {i->second.data() + offset, len};
    │ │ │ +    return lt::hasher256(b).final();
    │ │ │ +  }
    │ │ │ +
    │ │ │ +private:
    │ │ │ +  int piece_size(lt::piece_index_t piece) const
    │ │ │ +  {
    │ │ │ +    int const num_pieces = static_cast<int>((m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length());
    │ │ │ +    return static_cast<int>(piece) < num_pieces - 1
    │ │ │ +      ? m_files.piece_length() : static_cast<int>(m_files.total_size() - std::int64_t(num_pieces - 1) * m_files.piece_length());
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  lt::file_storage const& m_files;
    │ │ │ +  std::map<lt::piece_index_t, std::vector<char>> m_file_data;
    │ │ │ +};
    │ │ │ +
    │ │ │ +lt::storage_index_t pop(std::vector<lt::storage_index_t>& q)
    │ │ │ +{
    │ │ │ +  TORRENT_ASSERT(!q.empty());
    │ │ │ +  lt::storage_index_t const ret = q.back();
    │ │ │ +  q.pop_back();
    │ │ │ +  return ret;
    │ │ │ +}
    │ │ │ +
    │ │ │ +struct temp_disk_io final : lt::disk_interface
    │ │ │ +  , lt::buffer_allocator_interface
    │ │ │ +{
    │ │ │ +  explicit temp_disk_io(lt::io_context& ioc): m_ioc(ioc) {}
    │ │ │ +
    │ │ │ +  void settings_updated() override {}
    │ │ │ +
    │ │ │ +  lt::storage_holder new_torrent(lt::storage_params const& params
    │ │ │ +    , std::shared_ptr<void> const&) override
    │ │ │ +  {
    │ │ │ +    lt::storage_index_t const idx = m_free_slots.empty()
    │ │ │ +      ? m_torrents.end_index()
    │ │ │ +      : pop(m_free_slots);
    │ │ │ +    auto storage = std::make_unique<temp_storage>(params.files);
    │ │ │ +    if (idx == m_torrents.end_index()) m_torrents.emplace_back(std::move(storage));
    │ │ │ +    else m_torrents[idx] = std::move(storage);
    │ │ │ +    return lt::storage_holder(idx, *this);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void remove_torrent(lt::storage_index_t const idx) override
    │ │ │ +  {
    │ │ │ +    m_torrents[idx].reset();
    │ │ │ +    m_free_slots.push_back(idx);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void abort(bool) override {}
    │ │ │ +
    │ │ │ +  void async_read(lt::storage_index_t storage, lt::peer_request const& r
    │ │ │ +    , std::function<void(lt::disk_buffer_holder block, lt::storage_error const& se)> handler
    │ │ │ +    , lt::disk_job_flags_t) override
    │ │ │ +  {
    │ │ │ +    // this buffer is owned by the storage. It will remain valid for as
    │ │ │ +    // long as the torrent remains in the session. We don't need any lifetime
    │ │ │ +    // management of it.
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::span<char const> b = m_torrents[storage]->readv(r, error);
    │ │ │ +
    │ │ │ +    post(m_ioc, [handler, error, b, this] {
    │ │ │ +      handler(lt::disk_buffer_holder(*this, const_cast<char*>(b.data())), error);
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  bool async_write(lt::storage_index_t storage, lt::peer_request const& r
    │ │ │ +    , char const* buf, std::shared_ptr<lt::disk_observer>
    │ │ │ +    , std::function<void(lt::storage_error const&)> handler
    │ │ │ +    , lt::disk_job_flags_t) override
    │ │ │ +  {
    │ │ │ +    lt::span<char const> const b = { buf, r.length };
    │ │ │ +
    │ │ │ +    m_torrents[storage]->writev(b, r.piece, r.start);
    │ │ │ +
    │ │ │ +    post(m_ioc, [=]{ handler(lt::storage_error()); });
    │ │ │ +    return false;
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_hash(lt::storage_index_t storage, lt::piece_index_t const piece
    │ │ │ +    , lt::span<lt::sha256_hash> block_hashes, lt::disk_job_flags_t
    │ │ │ +    , std::function<void(lt::piece_index_t, lt::sha1_hash const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::sha1_hash const hash = m_torrents[storage]->hash(piece, block_hashes, error);
    │ │ │ +    post(m_ioc, [=]{ handler(piece, hash, error); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_hash2(lt::storage_index_t storage, lt::piece_index_t const piece
    │ │ │ +    , int const offset, lt::disk_job_flags_t
    │ │ │ +    , std::function<void(lt::piece_index_t, lt::sha256_hash const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::sha256_hash const hash = m_torrents[storage]->hash2(piece, offset, error);
    │ │ │ +    post(m_ioc, [=]{ handler(piece, hash, error); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_move_storage(lt::storage_index_t, std::string p, lt::move_flags_t
    │ │ │ +    , std::function<void(lt::status_t, std::string const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{
    │ │ │ +      handler(lt::disk_status::fatal_disk_error, p
    │ │ │ +        , lt::storage_error(lt::error_code(boost::system::errc::operation_not_supported, lt::system_category())));
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_release_files(lt::storage_index_t, std::function<void()>) override {}
    │ │ │ +
    │ │ │ +  void async_delete_files(lt::storage_index_t, lt::remove_flags_t
    │ │ │ +    , std::function<void(lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_check_files(lt::storage_index_t
    │ │ │ +    , lt::add_torrent_params const*
    │ │ │ +    , lt::aux::vector<std::string, lt::file_index_t>
    │ │ │ +    , std::function<void(lt::status_t, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(lt::status_t{}, lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_rename_file(lt::storage_index_t
    │ │ │ +    , lt::file_index_t const idx
    │ │ │ +    , std::string const name
    │ │ │ +    , std::function<void(std::string const&, lt::file_index_t, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(name, idx, lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_stop_torrent(lt::storage_index_t, std::function<void()> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, handler);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_set_file_priority(lt::storage_index_t
    │ │ │ +    , lt::aux::vector<lt::download_priority_t, lt::file_index_t> prio
    │ │ │ +    , std::function<void(lt::storage_error const&
    │ │ │ +      , lt::aux::vector<lt::download_priority_t, lt::file_index_t>)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{
    │ │ │ +      handler(lt::storage_error(lt::error_code(
    │ │ │ +        boost::system::errc::operation_not_supported, lt::system_category())), std::move(prio));
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_clear_piece(lt::storage_index_t, lt::piece_index_t index
    │ │ │ +    , std::function<void(lt::piece_index_t)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(index); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  // implements buffer_allocator_interface
    │ │ │ +  void free_disk_buffer(char*) override
    │ │ │ +  {
    │ │ │ +    // never free any buffer. We only return buffers owned by the storage
    │ │ │ +    // object
    │ │ │ +  }
    │ │ │ +  void free_multiple_buffers(lt::span<char*>) override
    │ │ │ +  {
    │ │ │ +    // never free any buffer. We only return buffers owned by the storage
    │ │ │ +    // object
    │ │ │ +  }
    │ │ │ +#if TORRENT_DEBUG_BUFFER_POOL
    │ │ │ +  void rename_buffer(char*, char const*) override {}
    │ │ │ +#endif
    │ │ │ +
    │ │ │ +  void update_stats_counters(lt::counters&) const override {}
    │ │ │ +
    │ │ │ +  std::vector<lt::open_file_state> get_status(lt::storage_index_t) const override
    │ │ │ +  { return {}; }
    │ │ │ +
    │ │ │ +  void submit_jobs() override {}
    │ │ │ +
    │ │ │ +private:
    │ │ │ +
    │ │ │ +  lt::aux::vector<std::shared_ptr<temp_storage>, lt::storage_index_t> m_torrents;
    │ │ │ +
    │ │ │ +  // slots that are unused in the m_torrents vector
    │ │ │ +  std::vector<lt::storage_index_t> m_free_slots;
    │ │ │ +
    │ │ │ +  // callbacks are posted on this
    │ │ │ +  lt::io_context& m_ioc;
    │ │ │ +};
    │ │ │ +
    │ │ │ +std::unique_ptr<lt::disk_interface> temp_disk_constructor(
    │ │ │ +  lt::io_context& ioc, lt::settings_interface const&, lt::counters&)
    │ │ │ +{
    │ │ │ +  return std::make_unique<temp_disk_io>(ioc);
    │ │ │ +}
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    settings_interface

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +

    the common interface to settings_pack and the internal representation of │ │ │ +settings.

    │ │ │ +
    │ │ │ +struct settings_interface
    │ │ │ +{
    │ │ │ +   virtual void set_bool (int name, bool val) = 0;
    │ │ │ +   virtual void set_int (int name, int val) = 0;
    │ │ │ +   virtual void set_str (int name, std::string val) = 0;
    │ │ │ +   virtual bool has_val (int name) const = 0;
    │ │ │ +   virtual bool get_bool (int name) const = 0;
    │ │ │ +   virtual std::string const& get_str (int name) const = 0;
    │ │ │ +   virtual int get_int (int name) const = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_int() set_str() set_bool()

    │ │ │ +
    │ │ │ +virtual void set_bool (int name, bool val) = 0;
    │ │ │ +virtual void set_int (int name, int val) = 0;
    │ │ │ +virtual void set_str (int name, std::string val) = 0;
    │ │ │ +
    │ │ │ +

    store the value of a single setting. name is one of the │ │ │ +enum values from settings_pack::string_types, │ │ │ +int_types or bool_types. The setter must match the │ │ │ +type of the setting: set_str() only accepts names from │ │ │ +string_types, set_int() from int_types and │ │ │ +set_bool() from bool_types. Passing a name of the │ │ │ +wrong type asserts in debug builds and is ignored otherwise.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    has_val()

    │ │ │ +
    │ │ │ +virtual bool has_val (int name) const = 0;
    │ │ │ +
    │ │ │ +

    returns true if a value has been explicitly set for the │ │ │ +setting name. If false, reads of that setting return │ │ │ +the default value.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_str() get_int() get_bool()

    │ │ │ +
    │ │ │ +virtual bool get_bool (int name) const = 0;
    │ │ │ +virtual std::string const& get_str (int name) const = 0;
    │ │ │ +virtual int get_int (int name) const = 0;
    │ │ │ +
    │ │ │ +

    retrieve the current value of a single setting. name is │ │ │ +one of the enum values from settings_pack::string_types, │ │ │ +int_types or bool_types. The getter must match the │ │ │ +type of the setting; if no value has been set, the default │ │ │ +value of the setting is returned.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +
    │ │ │

    open_file_state

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │

    this contains information about a file that's currently open by the │ │ │ libtorrent disk I/O subsystem. It's associated with a single torrent.

    │ │ │
    │ │ │  struct open_file_state
    │ │ │  {
    │ │ │ @@ -156,21 +482,21 @@
    │ │ │  the constructor. The callbacks will be run in the network thread.

    │ │ │
    │ │ │  struct disk_interface
    │ │ │  {
    │ │ │     virtual storage_holder new_torrent (storage_params const& p
    │ │ │        , std::shared_ptr<void> const& torrent) = 0;
    │ │ │     virtual void remove_torrent (storage_index_t) = 0;
    │ │ │ -   virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ -      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │     virtual bool async_write (storage_index_t storage, peer_request const& r
    │ │ │        , char const* buf, std::shared_ptr<disk_observer> o
    │ │ │        , std::function<void(storage_error const&)> handler
    │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ +   virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ +      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │     virtual void async_hash (storage_index_t storage, piece_index_t piece, span<sha256_hash> v2
    │ │ │        , disk_job_flags_t flags
    │ │ │        , std::function<void(piece_index_t, sha1_hash const&, storage_error const&)> handler) = 0;
    │ │ │     virtual void async_hash2 (storage_index_t storage, piece_index_t piece, int offset, disk_job_flags_t flags
    │ │ │        , std::function<void(piece_index_t, sha256_hash const&, storage_error const&)> handler) = 0;
    │ │ │     virtual void async_move_storage (storage_index_t storage, std::string p, move_flags_t flags
    │ │ │        , std::function<void(status_t, std::string const&, storage_error const&)> handler) = 0;
    │ │ │ @@ -227,21 +553,21 @@
    │ │ │  delete any files from disk, just to clean up any resources associated
    │ │ │  with the specified storage.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    async_read() async_write()

    │ │ │
    │ │ │ -virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ -      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │  virtual bool async_write (storage_index_t storage, peer_request const& r
    │ │ │        , char const* buf, std::shared_ptr<disk_observer> o
    │ │ │        , std::function<void(storage_error const&)> handler
    │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ +virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ +      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │  
    │ │ │

    perform a read or write operation from/to the specified storage │ │ │ index and the specified request. When the operation completes, call │ │ │ handler possibly with a disk_buffer_holder, holding the buffer with │ │ │ the result. Flags may be set to affect the read operation. See │ │ │ disk_job_flags_t.

    │ │ │

    The disk_observer is a callback to indicate that │ │ │ @@ -496,21 +822,21 @@ │ │ │ for a torrent to the lifetime of the internal torrent object. When a │ │ │ torrent is removed from the session, this holder is destructed and will │ │ │ inform the disk object.

    │ │ │
    │ │ │  struct storage_holder
    │ │ │  {
    │ │ │     storage_holder (storage_index_t idx, disk_interface& disk_io);
    │ │ │ -   ~storage_holder ();
    │ │ │     storage_holder () = default;
    │ │ │ +   ~storage_holder ();
    │ │ │     explicit operator bool () const;
    │ │ │     operator storage_index_t () const;
    │ │ │     void reset ();
    │ │ │ -   storage_holder& operator= (storage_holder const&) = delete;
    │ │ │     storage_holder (storage_holder const&) = delete;
    │ │ │ +   storage_holder& operator= (storage_holder const&) = delete;
    │ │ │     storage_holder (storage_holder&& rhs) noexcept;
    │ │ │     storage_holder& operator= (storage_holder&& rhs) noexcept;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    storage_holder()

    │ │ │
    │ │ │ @@ -673,21 +999,21 @@
    │ │ │  before this goes out of scope. Since it has no allocator, it cannot free the
    │ │ │  buffer itself.

    │ │ │
    │ │ │  struct disk_buffer_ref
    │ │ │  {
    │ │ │     disk_buffer_ref () noexcept = default;
    │ │ │     explicit disk_buffer_ref (disk_buffer_holder&& h) noexcept;
    │ │ │ -   disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │     ~disk_buffer_ref ();
    │ │ │     disk_buffer_ref (disk_buffer_ref&&) noexcept;
    │ │ │     disk_buffer_ref& operator= (disk_buffer_ref const&) = delete;
    │ │ │ +   disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │     disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │ -   char* data () const noexcept;
    │ │ │     explicit operator bool () const noexcept;
    │ │ │ +   char* data () const noexcept;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    disk_buffer_ref()

    │ │ │
    │ │ │  explicit disk_buffer_ref (disk_buffer_holder&& h) noexcept;
    │ │ │  
    │ │ │ @@ -696,16 +1022,16 @@ │ │ │ bulk_free_buffer for release; this type cannot free the │ │ │ buffer itself.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    bool() data()

    │ │ │
    │ │ │ -char* data () const noexcept;
    │ │ │  explicit operator bool () const noexcept;
    │ │ │ +char* data () const noexcept;
    │ │ │  
    │ │ │

    returns a pointer to the held buffer, or nullptr if this │ │ │ reference is empty. operator bool() returns true iff a │ │ │ buffer is held.

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │ @@ -715,16 +1041,16 @@ │ │ │ allocator mutex acquisitions from one per buffer to one per batch. │ │ │ All buffers added must share the same allocator. │ │ │ Freeing happens in the destructor.

    │ │ │
    │ │ │  struct bulk_free_buffer
    │ │ │  {
    │ │ │     explicit bulk_free_buffer (buffer_allocator_interface& alloc);
    │ │ │ -   void add (disk_buffer_ref r);
    │ │ │     ~bulk_free_buffer ();
    │ │ │ +   void add (disk_buffer_ref r);
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bulk_free_buffer()

    │ │ │
    │ │ │  explicit bulk_free_buffer (buffer_allocator_interface& alloc);
    │ │ │  
    │ │ │ @@ -732,77 +1058,18 @@ │ │ │ buffers added via add() must have come from this same │ │ │ allocator. The batch is freed in the destructor.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    add() ~bulk_free_buffer()

    │ │ │
    │ │ │ -void add (disk_buffer_ref r);
    │ │ │  ~bulk_free_buffer ();
    │ │ │ +void add (disk_buffer_ref r);
    │ │ │  
    │ │ │

    transfer ownership of h's buffer into this batch.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    settings_interface

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ -

    the common interface to settings_pack and the internal representation of │ │ │ -settings.

    │ │ │ -
    │ │ │ -struct settings_interface
    │ │ │ -{
    │ │ │ -   virtual void set_int (int name, int val) = 0;
    │ │ │ -   virtual void set_str (int name, std::string val) = 0;
    │ │ │ -   virtual void set_bool (int name, bool val) = 0;
    │ │ │ -   virtual bool has_val (int name) const = 0;
    │ │ │ -   virtual bool get_bool (int name) const = 0;
    │ │ │ -   virtual int get_int (int name) const = 0;
    │ │ │ -   virtual std::string const& get_str (int name) const = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_bool() set_int() set_str()

    │ │ │ -
    │ │ │ -virtual void set_int (int name, int val) = 0;
    │ │ │ -virtual void set_str (int name, std::string val) = 0;
    │ │ │ -virtual void set_bool (int name, bool val) = 0;
    │ │ │ -
    │ │ │ -

    store the value of a single setting. name is one of the │ │ │ -enum values from settings_pack::string_types, │ │ │ -int_types or bool_types. The setter must match the │ │ │ -type of the setting: set_str() only accepts names from │ │ │ -string_types, set_int() from int_types and │ │ │ -set_bool() from bool_types. Passing a name of the │ │ │ -wrong type asserts in debug builds and is ignored otherwise.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    has_val()

    │ │ │ -
    │ │ │ -virtual bool has_val (int name) const = 0;
    │ │ │ -
    │ │ │ -

    returns true if a value has been explicitly set for the │ │ │ -setting name. If false, reads of that setting return │ │ │ -the default value.

    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_int() get_bool() get_str()

    │ │ │ -
    │ │ │ -virtual bool get_bool (int name) const = 0;
    │ │ │ -virtual int get_int (int name) const = 0;
    │ │ │ -virtual std::string const& get_str (int name) const = 0;
    │ │ │ -
    │ │ │ -

    retrieve the current value of a single setting. name is │ │ │ -one of the enum values from settings_pack::string_types, │ │ │ -int_types or bool_types. The getter must match the │ │ │ -type of the setting; if no value has been set, the default │ │ │ -value of the setting is returned.

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    status_t

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │
    │ │ │
    fatal_disk_error
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,12 +1,16 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.1 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ + o _s_e_t___i_n_t_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___b_o_o_l_(_) │ │ │ │ + o _h_a_s___v_a_l_(_) │ │ │ │ + o _g_e_t___s_t_r_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ * _o_p_e_n___f_i_l_e___s_t_a_t_e │ │ │ │ * _d_i_s_k___i_n_t_e_r_f_a_c_e │ │ │ │ o _n_e_w___t_o_r_r_e_n_t_(_) │ │ │ │ o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) │ │ │ │ o _a_s_y_n_c___r_e_a_d_(_)_ _a_s_y_n_c___w_r_i_t_e_(_) │ │ │ │ o _a_s_y_n_c___h_a_s_h_(_) │ │ │ │ o _a_s_y_n_c___h_a_s_h_2_(_) │ │ │ │ @@ -41,32 +45,356 @@ │ │ │ │ o _b_o_o_l_(_) │ │ │ │ * _d_i_s_k___b_u_f_f_e_r___r_e_f │ │ │ │ o _d_i_s_k___b_u_f_f_e_r___r_e_f_(_) │ │ │ │ o _b_o_o_l_(_)_ _d_a_t_a_(_) │ │ │ │ * _b_u_l_k___f_r_e_e___b_u_f_f_e_r │ │ │ │ o _b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ o _a_d_d_(_)_ _~_b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ - * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ - o _s_e_t___b_o_o_l_(_)_ _s_e_t___i_n_t_(_)_ _s_e_t___s_t_r_(_) │ │ │ │ - o _h_a_s___v_a_l_(_) │ │ │ │ - o _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_)_ _g_e_t___s_t_r_(_) │ │ │ │ * _s_t_a_t_u_s___t │ │ │ │ * _f_i_l_e___o_p_e_n___m_o_d_e___t │ │ │ │ -You have some control over _s_e_s_s_i_o_n configuration through the session:: │ │ │ │ -apply_settings() member function. To change one or more configuration options, │ │ │ │ -create a _s_e_t_t_i_n_g_s___p_a_c_k object and fill it with the settings to be set and pass │ │ │ │ -it in to session::apply_settings(). │ │ │ │ -The _s_e_t_t_i_n_g_s___p_a_c_k object is a collection of settings updates that are applied │ │ │ │ -to the _s_e_s_s_i_o_n when passed to session::apply_settings(). It's empty when │ │ │ │ -constructed. │ │ │ │ -You have control over proxy and authorization settings and also the user-agent │ │ │ │ -that will be sent to the tracker. The user-agent will also be used to identify │ │ │ │ -the client with other peers. │ │ │ │ -Each configuration option is named with an enum value inside the _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ -class. These are the available settings: │ │ │ │ +The disk I/O can be customized in libtorrent. In previous versions, the │ │ │ │ +customization was at the level of each torrent. Now, the customization point is │ │ │ │ +at the _s_e_s_s_i_o_n level. All torrents added to a _s_e_s_s_i_o_n will use the same disk I/ │ │ │ │ +O subsystem, as determined by the disk_io_constructor (in _s_e_s_s_i_o_n___p_a_r_a_m_s). │ │ │ │ +This allows the disk subsystem to also customize threading and disk job │ │ │ │ +management. │ │ │ │ +To customize the disk subsystem, implement _d_i_s_k___i_n_t_e_r_f_a_c_e and provide a factory │ │ │ │ +function to the _s_e_s_s_i_o_n constructor (via _s_e_s_s_i_o_n___p_a_r_a_m_s). │ │ │ │ +Example use: │ │ │ │ +struct temp_storage │ │ │ │ +{ │ │ │ │ + explicit temp_storage(lt::file_storage const& fs) : m_files(fs) {} │ │ │ │ + │ │ │ │ + lt::span readv(lt::peer_request const r, lt::storage_error& ec) │ │ │ │ +const │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(r.piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + if (int(i->second.size()) <= r.start) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + return { i->second.data() + r.start, std::min(r.length, int(i->second.size │ │ │ │ +()) - r.start) }; │ │ │ │ + } │ │ │ │ + void writev(lt::span const b, lt::piece_index_t const piece, int │ │ │ │ +const offset) │ │ │ │ + { │ │ │ │ + auto& data = m_file_data[piece]; │ │ │ │ + if (data.empty()) │ │ │ │ + { │ │ │ │ + // allocate the whole piece, otherwise we'll invalidate the pointers │ │ │ │ + // we have returned back to libtorrent │ │ │ │ + int const size = piece_size(piece); │ │ │ │ + data.resize(std::size_t(size)); │ │ │ │ + } │ │ │ │ + TORRENT_ASSERT(offset + b.size() <= int(data.size())); │ │ │ │ + std::memcpy(data.data() + offset, b.data(), std::size_t(b.size())); │ │ │ │ + } │ │ │ │ + lt::sha1_hash hash(lt::piece_index_t const piece │ │ │ │ + , lt::span const block_hashes, lt::storage_error& ec) │ │ │ │ +const │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + if (!block_hashes.empty()) │ │ │ │ + { │ │ │ │ + int const piece_size2 = m_files.piece_size2(piece); │ │ │ │ + int const blocks_in_piece2 = m_files.blocks_in_piece2(piece); │ │ │ │ + char const* buf = i->second.data(); │ │ │ │ + std::int64_t offset = 0; │ │ │ │ + for (int k = 0; k < blocks_in_piece2; ++k) │ │ │ │ + { │ │ │ │ + lt::hasher256 h2; │ │ │ │ + std::ptrdiff_t const len2 = std::min(lt::default_block_size, int │ │ │ │ +(piece_size2 - offset)); │ │ │ │ + h2.update({ buf, len2 }); │ │ │ │ + buf += len2; │ │ │ │ + offset += len2; │ │ │ │ + block_hashes[k] = h2.final(); │ │ │ │ + } │ │ │ │ + } │ │ │ │ + return lt::hasher(i->second).final(); │ │ │ │ + } │ │ │ │ + lt::sha256_hash hash2(lt::piece_index_t const piece, int const offset, lt:: │ │ │ │ +storage_error& ec) │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + │ │ │ │ + int const piece_size = m_files.piece_size2(piece); │ │ │ │ + │ │ │ │ + std::ptrdiff_t const len = std::min(lt::default_block_size, piece_size - │ │ │ │ +offset); │ │ │ │ + │ │ │ │ + lt::span b = {i->second.data() + offset, len}; │ │ │ │ + return lt::hasher256(b).final(); │ │ │ │ + } │ │ │ │ + │ │ │ │ +private: │ │ │ │ + int piece_size(lt::piece_index_t piece) const │ │ │ │ + { │ │ │ │ + int const num_pieces = static_cast((m_files.total_size() + │ │ │ │ +m_files.piece_length() - 1) / m_files.piece_length()); │ │ │ │ + return static_cast(piece) < num_pieces - 1 │ │ │ │ + ? m_files.piece_length() : static_cast(m_files.total_size() - std:: │ │ │ │ +int64_t(num_pieces - 1) * m_files.piece_length()); │ │ │ │ + } │ │ │ │ + │ │ │ │ + lt::file_storage const& m_files; │ │ │ │ + std::map> m_file_data; │ │ │ │ +}; │ │ │ │ + │ │ │ │ +lt::storage_index_t pop(std::vector& q) │ │ │ │ +{ │ │ │ │ + TORRENT_ASSERT(!q.empty()); │ │ │ │ + lt::storage_index_t const ret = q.back(); │ │ │ │ + q.pop_back(); │ │ │ │ + return ret; │ │ │ │ +} │ │ │ │ + │ │ │ │ +struct temp_disk_io final : lt::disk_interface │ │ │ │ + , lt::buffer_allocator_interface │ │ │ │ +{ │ │ │ │ + explicit temp_disk_io(lt::io_context& ioc): m_ioc(ioc) {} │ │ │ │ + │ │ │ │ + void settings_updated() override {} │ │ │ │ + │ │ │ │ + lt::storage_holder new_torrent(lt::storage_params const& params │ │ │ │ + , std::shared_ptr const&) override │ │ │ │ + { │ │ │ │ + lt::storage_index_t const idx = m_free_slots.empty() │ │ │ │ + ? m_torrents.end_index() │ │ │ │ + : pop(m_free_slots); │ │ │ │ + auto storage = std::make_unique(params.files); │ │ │ │ + if (idx == m_torrents.end_index()) m_torrents.emplace_back(std::move │ │ │ │ +(storage)); │ │ │ │ + else m_torrents[idx] = std::move(storage); │ │ │ │ + return lt::storage_holder(idx, *this); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void remove_torrent(lt::storage_index_t const idx) override │ │ │ │ + { │ │ │ │ + m_torrents[idx].reset(); │ │ │ │ + m_free_slots.push_back(idx); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void abort(bool) override {} │ │ │ │ + │ │ │ │ + void async_read(lt::storage_index_t storage, lt::peer_request const& r │ │ │ │ + , std::function handler │ │ │ │ + , lt::disk_job_flags_t) override │ │ │ │ + { │ │ │ │ + // this buffer is owned by the storage. It will remain valid for as │ │ │ │ + // long as the torrent remains in the session. We don't need any lifetime │ │ │ │ + // management of it. │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::span b = m_torrents[storage]->readv(r, error); │ │ │ │ + │ │ │ │ + post(m_ioc, [handler, error, b, this] { │ │ │ │ + handler(lt::disk_buffer_holder(*this, const_cast(b.data())), │ │ │ │ +error); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + bool async_write(lt::storage_index_t storage, lt::peer_request const& r │ │ │ │ + , char const* buf, std::shared_ptr │ │ │ │ + , std::function handler │ │ │ │ + , lt::disk_job_flags_t) override │ │ │ │ + { │ │ │ │ + lt::span const b = { buf, r.length }; │ │ │ │ + │ │ │ │ + m_torrents[storage]->writev(b, r.piece, r.start); │ │ │ │ + │ │ │ │ + post(m_ioc, [=]{ handler(lt::storage_error()); }); │ │ │ │ + return false; │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_hash(lt::storage_index_t storage, lt::piece_index_t const piece │ │ │ │ + , lt::span block_hashes, lt::disk_job_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::sha1_hash const hash = m_torrents[storage]->hash(piece, block_hashes, │ │ │ │ +error); │ │ │ │ + post(m_ioc, [=]{ handler(piece, hash, error); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_hash2(lt::storage_index_t storage, lt::piece_index_t const piece │ │ │ │ + , int const offset, lt::disk_job_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::sha256_hash const hash = m_torrents[storage]->hash2(piece, offset, │ │ │ │ +error); │ │ │ │ + post(m_ioc, [=]{ handler(piece, hash, error); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_move_storage(lt::storage_index_t, std::string p, lt::move_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ │ │ │ │ + handler(lt::disk_status::fatal_disk_error, p │ │ │ │ + , lt::storage_error(lt::error_code(boost::system::errc:: │ │ │ │ +operation_not_supported, lt::system_category()))); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_release_files(lt::storage_index_t, std::function) override │ │ │ │ +{} │ │ │ │ + │ │ │ │ + void async_delete_files(lt::storage_index_t, lt::remove_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_check_files(lt::storage_index_t │ │ │ │ + , lt::add_torrent_params const* │ │ │ │ + , lt::aux::vector │ │ │ │ + , std::function handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(lt::status_t{}, lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_rename_file(lt::storage_index_t │ │ │ │ + , lt::file_index_t const idx │ │ │ │ + , std::string const name │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(name, idx, lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_stop_torrent(lt::storage_index_t, std::function handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, handler); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_set_file_priority(lt::storage_index_t │ │ │ │ + , lt::aux::vector prio │ │ │ │ + , std::function)> handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ │ │ │ │ + handler(lt::storage_error(lt::error_code( │ │ │ │ + boost::system::errc::operation_not_supported, lt::system_category())), │ │ │ │ +std::move(prio)); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_clear_piece(lt::storage_index_t, lt::piece_index_t index │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(index); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + // implements buffer_allocator_interface │ │ │ │ + void free_disk_buffer(char*) override │ │ │ │ + { │ │ │ │ + // never free any buffer. We only return buffers owned by the storage │ │ │ │ + // object │ │ │ │ + } │ │ │ │ + void free_multiple_buffers(lt::span) override │ │ │ │ + { │ │ │ │ + // never free any buffer. We only return buffers owned by the storage │ │ │ │ + // object │ │ │ │ + } │ │ │ │ +#if TORRENT_DEBUG_BUFFER_POOL │ │ │ │ + void rename_buffer(char*, char const*) override {} │ │ │ │ +#endif │ │ │ │ + │ │ │ │ + void update_stats_counters(lt::counters&) const override {} │ │ │ │ + │ │ │ │ + std::vector get_status(lt::storage_index_t) const │ │ │ │ +override │ │ │ │ + { return {}; } │ │ │ │ + │ │ │ │ + void submit_jobs() override {} │ │ │ │ + │ │ │ │ +private: │ │ │ │ + │ │ │ │ + lt::aux::vector, lt::storage_index_t> │ │ │ │ +m_torrents; │ │ │ │ + │ │ │ │ + // slots that are unused in the m_torrents vector │ │ │ │ + std::vector m_free_slots; │ │ │ │ + │ │ │ │ + // callbacks are posted on this │ │ │ │ + lt::io_context& m_ioc; │ │ │ │ +}; │ │ │ │ + │ │ │ │ +std::unique_ptr temp_disk_constructor( │ │ │ │ + lt::io_context& ioc, lt::settings_interface const&, lt::counters&) │ │ │ │ +{ │ │ │ │ + return std::make_unique(ioc); │ │ │ │ +} │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseettttiinnggss__iinntteerrffaaccee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ +the common interface to _s_e_t_t_i_n_g_s___p_a_c_k and the internal representation of │ │ │ │ +settings. │ │ │ │ +struct settings_interface │ │ │ │ +{ │ │ │ │ + virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ + virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ + virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ + virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ + virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ + virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ + virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseett__iinntt(()) sseett__ssttrr(()) sseett__bbooooll(()) ********** │ │ │ │ +virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ +virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ +virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ +store the value of a single setting. name is one of the enum values from │ │ │ │ +settings_pack::string_types, int_types or bool_types. The setter must match the │ │ │ │ +type of the setting: set_str() only accepts names from string_types, set_int() │ │ │ │ +from int_types and set_bool() from bool_types. Passing a name of the wrong type │ │ │ │ +asserts in debug builds and is ignored otherwise. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaass__vvaall(()) ********** │ │ │ │ +virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ +returns true if a value has been explicitly set for the setting name. If false, │ │ │ │ +reads of that setting return the default value. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett__ssttrr(()) ggeett__iinntt(()) ggeett__bbooooll(()) ********** │ │ │ │ +virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ +virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ +retrieve the current value of a single setting. name is one of the enum values │ │ │ │ +from settings_pack::string_types, int_types or bool_types. The getter must │ │ │ │ +match the type of the setting; if no value has been set, the default value of │ │ │ │ +the setting is returned. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ooppeenn__ffiillee__ssttaattee ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ this contains information about a file that's currently open by the libtorrent │ │ │ │ disk I/O subsystem. It's associated with a single torrent. │ │ │ │ struct open_file_state │ │ │ │ { │ │ │ │ @@ -103,21 +431,21 @@ │ │ │ │ thread via the io_context object passed into the constructor. The callbacks │ │ │ │ will be run in the network thread. │ │ │ │ struct disk_interface │ │ │ │ { │ │ │ │ virtual storage_holder nneeww__ttoorrrreenntt (storage_params const& p │ │ │ │ , std::shared_ptr const& torrent) = 0; │ │ │ │ virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0; │ │ │ │ - virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ - , std::function handler │ │ │ │ - , disk_job_flags_t flags = {}) = 0; │ │ │ │ virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r │ │ │ │ , char const* buf, std::shared_ptr o │ │ │ │ , std::function handler │ │ │ │ , disk_job_flags_t flags = {}) = 0; │ │ │ │ + virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ + , std::function handler │ │ │ │ + , disk_job_flags_t flags = {}) = 0; │ │ │ │ virtual void aassyynncc__hhaasshh (storage_index_t storage, piece_index_t piece, │ │ │ │ span v2 │ │ │ │ , disk_job_flags_t flags │ │ │ │ , std::function handler) = 0; │ │ │ │ virtual void aassyynncc__hhaasshh22 (storage_index_t storage, piece_index_t piece, int │ │ │ │ offset, disk_job_flags_t flags │ │ │ │ @@ -173,21 +501,21 @@ │ │ │ │ ********** rreemmoovvee__ttoorrrreenntt(()) ********** │ │ │ │ virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0; │ │ │ │ remove the storage with the specified index. This is not expected to delete any │ │ │ │ files from disk, just to clean up any resources associated with the specified │ │ │ │ storage. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aassyynncc__rreeaadd(()) aassyynncc__wwrriittee(()) ********** │ │ │ │ -virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ - , std::function handler │ │ │ │ - , disk_job_flags_t flags = {}) = 0; │ │ │ │ virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r │ │ │ │ , char const* buf, std::shared_ptr o │ │ │ │ , std::function handler │ │ │ │ , disk_job_flags_t flags = {}) = 0; │ │ │ │ +virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r │ │ │ │ + , std::function handler │ │ │ │ + , disk_job_flags_t flags = {}) = 0; │ │ │ │ perform a read or write operation from/to the specified storage index and the │ │ │ │ specified request. When the operation completes, call handler possibly with a │ │ │ │ _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r, holding the buffer with the result. Flags may be set to │ │ │ │ affect the read operation. See disk_job_flags_t. │ │ │ │ The _d_i_s_k___o_b_s_e_r_v_e_r is a callback to indicate that the store buffer/disk write │ │ │ │ queue is below the watermark to let peers start writing buffers to disk again. │ │ │ │ When async_write() returns true, indicating the write queue is full, the peer │ │ │ │ @@ -378,21 +706,21 @@ │ │ │ │ (class that implements _d_i_s_k___i_n_t_e_r_f_a_c_e). This is held by the internal libtorrent │ │ │ │ torrent object to tie the storage object allocated for a torrent to the │ │ │ │ lifetime of the internal torrent object. When a torrent is removed from the │ │ │ │ _s_e_s_s_i_o_n, this holder is destructed and will inform the disk object. │ │ │ │ struct storage_holder │ │ │ │ { │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ - ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ ssttoorraaggee__hhoollddeerr () = default; │ │ │ │ + ~~ssttoorraaggee__hhoollddeerr (); │ │ │ │ explicit operator bbooooll () const; │ │ │ │ operator ssttoorraaggee__iinnddeexx__tt () const; │ │ │ │ void rreesseett (); │ │ │ │ - storage_holder& ooppeerraattoorr== (storage_holder const&) = delete; │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete; │ │ │ │ + storage_holder& ooppeerraattoorr== (storage_holder const&) = delete; │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_holder&& rhs) noexcept; │ │ │ │ storage_holder& ooppeerraattoorr== (storage_holder&& rhs) noexcept; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ssttoorraaggee__hhoollddeerr(()) ********** │ │ │ │ ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io); │ │ │ │ constructs a storage holder, for storage idx held at disk interface disk_io. │ │ │ │ @@ -501,97 +829,58 @@ │ │ │ │ pointer is null. The buffer must be transferred to a _b_u_l_k___f_r_e_e___b_u_f_f_e_r before │ │ │ │ this goes out of scope. Since it has no allocator, it cannot free the buffer │ │ │ │ itself. │ │ │ │ struct disk_buffer_ref │ │ │ │ { │ │ │ │ ddiisskk__bbuuffffeerr__rreeff () noexcept = default; │ │ │ │ explicit ddiisskk__bbuuffffeerr__rreeff (disk_buffer_holder&& h) noexcept; │ │ │ │ - disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref&&) noexcept; │ │ │ │ disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ + disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ - char* ddaattaa () const noexcept; │ │ │ │ explicit operator bbooooll () const noexcept; │ │ │ │ + char* ddaattaa () const noexcept; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ddiisskk__bbuuffffeerr__rreeff(()) ********** │ │ │ │ explicit ddiisskk__bbuuffffeerr__rreeff (disk_buffer_holder&& h) noexcept; │ │ │ │ take ownership of the buffer held by h, leaving h empty. The buffer must │ │ │ │ subsequently be transferred to a bulk_free_buffer for release; this type cannot │ │ │ │ free the buffer itself. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bbooooll(()) ddaattaa(()) ********** │ │ │ │ -char* ddaattaa () const noexcept; │ │ │ │ explicit operator bbooooll () const noexcept; │ │ │ │ +char* ddaattaa () const noexcept; │ │ │ │ returns a pointer to the held buffer, or nullptr if this reference is empty. │ │ │ │ operator bool() returns true iff a buffer is held. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ bbuullkk__ffrreeee__bbuuffffeerr ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p" │ │ │ │ Accumulates disk buffers to be freed in a single batch call, reducing allocator │ │ │ │ mutex acquisitions from one per buffer to one per batch. All buffers added must │ │ │ │ share the same allocator. Freeing happens in the destructor. │ │ │ │ struct bulk_free_buffer │ │ │ │ { │ │ │ │ explicit bbuullkk__ffrreeee__bbuuffffeerr (buffer_allocator_interface& alloc); │ │ │ │ - void aadddd (disk_buffer_ref r); │ │ │ │ ~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ + void aadddd (disk_buffer_ref r); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ explicit bbuullkk__ffrreeee__bbuuffffeerr (buffer_allocator_interface& alloc); │ │ │ │ construct an empty batch tied to the given allocator. All buffers added via add │ │ │ │ () must have come from this same allocator. The batch is freed in the │ │ │ │ destructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aadddd(()) ~~bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ -void aadddd (disk_buffer_ref r); │ │ │ │ ~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ +void aadddd (disk_buffer_ref r); │ │ │ │ transfer ownership of h's buffer into this batch. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseettttiinnggss__iinntteerrffaaccee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ -the common interface to _s_e_t_t_i_n_g_s___p_a_c_k and the internal representation of │ │ │ │ -settings. │ │ │ │ -struct settings_interface │ │ │ │ -{ │ │ │ │ - virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ - virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ - virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ - virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ - virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ - virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ - virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__bbooooll(()) sseett__iinntt(()) sseett__ssttrr(()) ********** │ │ │ │ -virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ -virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ -virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ -store the value of a single setting. name is one of the enum values from │ │ │ │ -settings_pack::string_types, int_types or bool_types. The setter must match the │ │ │ │ -type of the setting: set_str() only accepts names from string_types, set_int() │ │ │ │ -from int_types and set_bool() from bool_types. Passing a name of the wrong type │ │ │ │ -asserts in debug builds and is ignored otherwise. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__vvaall(()) ********** │ │ │ │ -virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ -returns true if a value has been explicitly set for the setting name. If false, │ │ │ │ -reads of that setting return the default value. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__iinntt(()) ggeett__bbooooll(()) ggeett__ssttrr(()) ********** │ │ │ │ -virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ -virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ -virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ -retrieve the current value of a single setting. name is one of the enum values │ │ │ │ -from settings_pack::string_types, int_types or bool_types. The getter must │ │ │ │ -match the type of the setting; if no value has been set, the default value of │ │ │ │ -the setting is returned. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssttaattuuss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ fatal_disk_error │ │ │ │ the disk operation could not be completed because of an unrecoverable │ │ │ │ error (e.g. failed write). The torrent is paused and a file_error_alert │ │ │ │ is posted. │ │ │ │ need_full_check │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ @@ -50,16 +50,16 @@ │ │ │
  • get_mutable_item()
  • │ │ │
  • put_mutable_item()
  • │ │ │
  • get_infohashes_sample()
  • │ │ │
  • tick()
  • │ │ │
  • counters()
  • │ │ │ │ │ │ │ │ │ -
  • sign_mutable_item()
  • │ │ │ -
  • dht_default_storage_constructor()
  • │ │ │ +
  • dht_default_storage_constructor()
  • │ │ │ +
  • sign_mutable_item()
  • │ │ │
  • announce_flags_t
  • │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    dht_state

    │ │ │

    Declared in "libtorrent/kademlia/dht_state.hpp"

    │ │ │

    This structure helps to store and load the state │ │ │ @@ -341,16 +341,27 @@ │ │ │ [report issue]

    │ │ │
    │ │ │

    counters()

    │ │ │
    │ │ │  virtual dht_storage_counters counters () const = 0;
    │ │ │  
    │ │ │

    return stats counters for the store

    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │
    │ │ │ +
    │ │ │ +

    dht_default_storage_constructor()

    │ │ │ +

    Declared in "libtorrent/kademlia/dht_storage.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<dht_storage_interface> dht_default_storage_constructor (
    │ │ │ +   settings_interface const& settings);
    │ │ │ +
    │ │ │ +

    constructor for the default DHT storage. The DHT storage is responsible │ │ │ +for maintaining peers and mutable and immutable items announced and │ │ │ +stored/put to the DHT node.

    │ │ │ +[report issue]
    │ │ │
    │ │ │

    sign_mutable_item()

    │ │ │

    Declared in "libtorrent/kademlia/item.hpp"

    │ │ │
    │ │ │  signature sign_mutable_item (
    │ │ │     span<char const> v
    │ │ │     , span<char const> salt
    │ │ │ @@ -360,25 +371,14 @@
    │ │ │  
    │ │ │

    given a byte range v and an optional byte range salt, a │ │ │ sequence number, public key pk (must be 32 bytes) and a secret key │ │ │ sk (must be 64 bytes), this function produces a signature which │ │ │ is written into a 64 byte buffer pointed to by sig. The caller │ │ │ is responsible for allocating the destination buffer that's passed in │ │ │ as the sig argument. Typically it would be allocated on the stack.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_default_storage_constructor()

    │ │ │ -

    Declared in "libtorrent/kademlia/dht_storage.hpp"

    │ │ │ -
    │ │ │ -std::unique_ptr<dht_storage_interface> dht_default_storage_constructor (
    │ │ │ -   settings_interface const& settings);
    │ │ │ -
    │ │ │ -

    constructor for the default DHT storage. The DHT storage is responsible │ │ │ -for maintaining peers and mutable and immutable items announced and │ │ │ -stored/put to the DHT node.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    announce_flags_t

    │ │ │

    Declared in "libtorrent/kademlia/announce_flags.hpp"

    │ │ │
    │ │ │
    seed
    │ │ │
    announce to DHT as a seed
    │ │ │ ├── html2text {} │ │ │ │ @@ -15,16 +15,16 @@ │ │ │ │ o _p_u_t___i_m_m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _g_e_t___m_u_t_a_b_l_e___i_t_e_m___s_e_q_(_) │ │ │ │ o _g_e_t___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _p_u_t___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _g_e_t___i_n_f_o_h_a_s_h_e_s___s_a_m_p_l_e_(_) │ │ │ │ o _t_i_c_k_(_) │ │ │ │ o _c_o_u_n_t_e_r_s_(_) │ │ │ │ - * _s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ * _d_h_t___d_e_f_a_u_l_t___s_t_o_r_a_g_e___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ * _a_n_n_o_u_n_c_e___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddhhtt__ssttaattee ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_a_t_e_._h_p_p" │ │ │ │ This structure helps to store and load the state of the dht_tracker. At this │ │ │ │ moment the library is only a dual stack implementation of the DHT. See _B_E_P_ _3_2 │ │ │ │ struct dht_state │ │ │ │ @@ -233,36 +233,36 @@ │ │ │ │ For implementers: Use this functions for expire peers or items or any other │ │ │ │ storage cleanup. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ccoouunntteerrss(()) ********** │ │ │ │ virtual dht_storage_counters ccoouunntteerrss () const = 0; │ │ │ │ return stats _c_o_u_n_t_e_r_s for the store │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +std::unique_ptr ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr ( │ │ │ │ + settings_interface const& settings); │ │ │ │ +constructor for the default DHT storage. The DHT storage is responsible for │ │ │ │ +maintaining peers and mutable and immutable items announced and stored/put to │ │ │ │ +the DHT node. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssiiggnn__mmuuttaabbllee__iitteemm(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_i_t_e_m_._h_p_p" │ │ │ │ signature ssiiggnn__mmuuttaabbllee__iitteemm ( │ │ │ │ span v │ │ │ │ , span salt │ │ │ │ , sequence_number seq │ │ │ │ , public_key const& pk │ │ │ │ , secret_key const& sk); │ │ │ │ given a byte range v and an optional byte range salt, a sequence number, public │ │ │ │ key pk (must be 32 bytes) and a secret key sk (must be 64 bytes), this function │ │ │ │ produces a signature which is written into a 64 byte buffer pointed to by sig. │ │ │ │ The caller is responsible for allocating the destination buffer that's passed │ │ │ │ in as the sig argument. Typically it would be allocated on the stack. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -std::unique_ptr ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr ( │ │ │ │ - settings_interface const& settings); │ │ │ │ -constructor for the default DHT storage. The DHT storage is responsible for │ │ │ │ -maintaining peers and mutable and immutable items announced and stored/put to │ │ │ │ -the DHT node. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_a_n_n_o_u_n_c_e___f_l_a_g_s_._h_p_p" │ │ │ │ seed │ │ │ │ announce to DHT as a seed │ │ │ │ implied_port │ │ │ │ announce to DHT with the implied-port flag set. This tells the network to │ │ │ │ use your source UDP port as your listen port, rather than the one │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ @@ -33,30 +33,30 @@ │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    storage_error

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │

    used by storage to return errors │ │ │ also includes which underlying file the │ │ │ @@ -94,87 +94,496 @@ │ │ │

    the error that occurred
    │ │ │ │ │ │ [report issue]
    │ │ │
    operation
    │ │ │
    A code from operation_t enum, indicating what │ │ │ kind of operation failed.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │ │ │ │ -
    │ │ │ -

    libtorrent_category()

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

    │ │ │ -
    │ │ │ -boost::system::error_category& libtorrent_category ();
    │ │ │ -
    │ │ │ -

    return the instance of the libtorrent_error_category which │ │ │ -maps libtorrent error codes to human readable error messages.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    http_category()

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

    │ │ │ -
    │ │ │ -boost::system::error_category& http_category ();
    │ │ │ -
    │ │ │ -

    returns the error_category for HTTP errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    gzip_category()

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ +
    │ │ │ +

    pcp_category()

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

    │ │ │
    │ │ │ -boost::system::error_category& gzip_category ();
    │ │ │ +boost::system::error_category& pcp_category ();
    │ │ │  
    │ │ │ -

    get the error_category for zip errors

    │ │ │ +

    returns the boost::system::error_category used for │ │ │ +errors::pcp_errors. error_code objects returned by the PCP │ │ │ +(Port Control Protocol) port-mapping code use this category.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    upnp_category()

    │ │ │

    Declared in "libtorrent/upnp.hpp"

    │ │ │
    │ │ │  boost::system::error_category& upnp_category ();
    │ │ │  
    │ │ │

    the boost.system error category for UPnP errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    i2p_category()

    │ │ │ -

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ -
    │ │ │ -boost::system::error_category& i2p_category ();
    │ │ │ -
    │ │ │ -

    returns the error category for I2P errors

    │ │ │ [report issue]
    │ │ │
    │ │ │

    socks_category()

    │ │ │

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │
    │ │ │  boost::system::error_category& socks_category ();
    │ │ │  
    │ │ │

    returns the error_category for SOCKS5 errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    pcp_category()

    │ │ │ -

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    gzip_category()

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │
    │ │ │ -boost::system::error_category& pcp_category ();
    │ │ │ +boost::system::error_category& gzip_category ();
    │ │ │  
    │ │ │ -

    returns the boost::system::error_category used for │ │ │ -errors::pcp_errors. error_code objects returned by the PCP │ │ │ -(Port Control Protocol) port-mapping code use this category.

    │ │ │ +

    get the error_category for zip errors

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    i2p_category()

    │ │ │ +

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& i2p_category ();
    │ │ │ +
    │ │ │ +

    returns the error category for I2P errors

    │ │ │ [report issue]
    │ │ │
    │ │ │

    bdecode_category()

    │ │ │

    Declared in "libtorrent/bdecode.hpp"

    │ │ │
    │ │ │  boost::system::error_category& bdecode_category ();
    │ │ │  
    │ │ │

    returns the boost::system::error_category used for the │ │ │ bdecode_errors::error_code_enum errors. error_code objects │ │ │ produced by bdecode() use this category.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    libtorrent_category()

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& libtorrent_category ();
    │ │ │ +
    │ │ │ +

    return the instance of the libtorrent_error_category which │ │ │ +maps libtorrent error codes to human readable error messages.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    http_category()

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& http_category ();
    │ │ │ +
    │ │ │ +

    returns the error_category for HTTP errors

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum pcp_errors

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    pcp_success0 
    pcp_unsupp_version1 
    pcp_not_authorized2 
    pcp_malformed_request3 
    pcp_unsupp_opcode4 
    pcp_unsupp_option5 
    pcp_malformed_option6 
    pcp_network_failure7 
    pcp_no_resources8 
    pcp_unsupp_protocol9 
    pcp_user_ex_quota10 
    pcp_cannot_provide_external11 
    pcp_address_mismatch12 
    pcp_excessive_remote_peers13 
    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum error_code_enum

    │ │ │ +

    Declared in "libtorrent/upnp.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0No error
    invalid_argument402One of the arguments in the request is invalid
    action_failed501The request failed
    value_not_in_array714The specified value does not exist in the array
    source_ip_cannot_be_wildcarded715The source IP address cannot be wild-carded, but │ │ │ +must be fully specified
    external_port_cannot_be_wildcarded716The external port cannot be a wildcard, but must │ │ │ +be specified
    port_mapping_conflict718The port mapping entry specified conflicts with a │ │ │ +mapping assigned previously to another client
    internal_port_must_match_external724Internal and external port value must be the same
    only_permanent_leases_supported725The NAT implementation only supports permanent │ │ │ +lease times on port mappings
    remote_host_must_be_wildcard726RemoteHost must be a wildcard and cannot be a │ │ │ +specific IP address or DNS name
    external_port_must_be_wildcard727ExternalPort must be a wildcard and cannot be a │ │ │ +specific port
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum socks_error_code

    │ │ │ +

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0 
    unsupported_version1 
    unsupported_authentication_method2 
    unsupported_authentication_version3 
    authentication_error4 
    username_required5 
    general_failure6 
    command_not_supported7 
    no_identd8 
    identd_error9 
    num_errors10 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0Not an error
    invalid_gzip_header1the supplied gzip buffer has invalid header
    inflated_data_too_large2the gzip buffer would inflate to more bytes than the specified │ │ │ +maximum size, and was rejected.
    data_did_not_terminate3available inflate data did not terminate
    space_exhausted4output space exhausted before completing inflate
    invalid_block_type5invalid block type (type == 3)
    invalid_stored_block_length6stored block length did not match one's complement
    too_many_length_or_distance_codes7dynamic block code description: too many length or distance codes
    code_lengths_codes_incomplete8dynamic block code description: code lengths codes incomplete
    repeat_lengths_with_no_first_length9dynamic block code description: repeat lengths with no first length
    repeat_more_than_specified_lengths10dynamic block code description: repeat more than specified lengths
    invalid_literal_length_code_lengths11dynamic block code description: invalid literal/length code lengths
    invalid_distance_code_lengths12dynamic block code description: invalid distance code lengths
    invalid_literal_code_in_block13invalid literal/length or distance code in fixed or dynamic block
    distance_too_far_back_in_block14distance is too far back in fixed or dynamic block
    unknown_gzip_error15an unknown error occurred during gzip inflation
    error_code_max16the number of error codes
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum i2p_error_code

    │ │ │ +

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0 
    parse_failed1 
    cant_reach_peer2 
    i2p_error3 
    invalid_key4 
    invalid_id5 
    timeout6 
    key_not_found7 
    duplicated_id8 
    num_errors9 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │ +

    Declared in "libtorrent/bdecode.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0Not an error
    expected_digit1expected digit in bencoded string
    expected_colon2expected colon in bencoded string
    unexpected_eof3unexpected end of file in bencoded string
    expected_value4expected value (list, dict, int or string) in bencoded string
    depth_exceeded5bencoded recursion depth limit exceeded
    limit_exceeded6bencoded item count limit exceeded
    overflow7integer overflow
    error_code_max8the number of error codes
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1007,423 +1416,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    service_unavailable503 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0Not an error
    invalid_gzip_header1the supplied gzip buffer has invalid header
    inflated_data_too_large2the gzip buffer would inflate to more bytes than the specified │ │ │ -maximum size, and was rejected.
    data_did_not_terminate3available inflate data did not terminate
    space_exhausted4output space exhausted before completing inflate
    invalid_block_type5invalid block type (type == 3)
    invalid_stored_block_length6stored block length did not match one's complement
    too_many_length_or_distance_codes7dynamic block code description: too many length or distance codes
    code_lengths_codes_incomplete8dynamic block code description: code lengths codes incomplete
    repeat_lengths_with_no_first_length9dynamic block code description: repeat lengths with no first length
    repeat_more_than_specified_lengths10dynamic block code description: repeat more than specified lengths
    invalid_literal_length_code_lengths11dynamic block code description: invalid literal/length code lengths
    invalid_distance_code_lengths12dynamic block code description: invalid distance code lengths
    invalid_literal_code_in_block13invalid literal/length or distance code in fixed or dynamic block
    distance_too_far_back_in_block14distance is too far back in fixed or dynamic block
    unknown_gzip_error15an unknown error occurred during gzip inflation
    error_code_max16the number of error codes
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/upnp.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0No error
    invalid_argument402One of the arguments in the request is invalid
    action_failed501The request failed
    value_not_in_array714The specified value does not exist in the array
    source_ip_cannot_be_wildcarded715The source IP address cannot be wild-carded, but │ │ │ -must be fully specified
    external_port_cannot_be_wildcarded716The external port cannot be a wildcard, but must │ │ │ -be specified
    port_mapping_conflict718The port mapping entry specified conflicts with a │ │ │ -mapping assigned previously to another client
    internal_port_must_match_external724Internal and external port value must be the same
    only_permanent_leases_supported725The NAT implementation only supports permanent │ │ │ -lease times on port mappings
    remote_host_must_be_wildcard726RemoteHost must be a wildcard and cannot be a │ │ │ -specific IP address or DNS name
    external_port_must_be_wildcard727ExternalPort must be a wildcard and cannot be a │ │ │ -specific port
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum i2p_error_code

    │ │ │ -

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0 
    parse_failed1 
    cant_reach_peer2 
    i2p_error3 
    invalid_key4 
    invalid_id5 
    timeout6 
    key_not_found7 
    duplicated_id8 
    num_errors9 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum socks_error_code

    │ │ │ -

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0 
    unsupported_version1 
    unsupported_authentication_method2 
    unsupported_authentication_version3 
    authentication_error4 
    username_required5 
    general_failure6 
    command_not_supported7 
    no_identd8 
    identd_error9 
    num_errors10 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum pcp_errors

    │ │ │ -

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    pcp_success0 
    pcp_unsupp_version1 
    pcp_not_authorized2 
    pcp_malformed_request3 
    pcp_unsupp_opcode4 
    pcp_unsupp_option5 
    pcp_malformed_option6 
    pcp_network_failure7 
    pcp_no_resources8 
    pcp_unsupp_protocol9 
    pcp_user_ex_quota10 
    pcp_cannot_provide_external11 
    pcp_address_mismatch12 
    pcp_excessive_remote_peers13 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/bdecode.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0Not an error
    expected_digit1expected digit in bencoded string
    expected_colon2expected colon in bencoded string
    unexpected_eof3unexpected end of file in bencoded string
    expected_value4expected value (list, dict, int or string) in bencoded string
    depth_exceeded5bencoded recursion depth limit exceeded
    limit_exceeded6bencoded item count limit exceeded
    overflow7integer overflow
    error_code_max8the number of error codes
    │ │ │
    │ │ │ │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ │ │ │ -
    │ │ │ -

    on_have_all() on_have() on_request() on_not_interested() on_interested() on_dont_have() on_bitfield() on_unchoke() on_have_none() on_allowed_fast() on_choke()

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_request() on_choke() on_dont_have() on_unchoke() on_have() on_allowed_fast() on_interested() on_have_none() on_have_all() on_not_interested() on_bitfield()

    │ │ │
    │ │ │ -virtual bool on_request (peer_request const&);
    │ │ │ +virtual bool on_unchoke ();
    │ │ │  virtual bool on_not_interested ();
    │ │ │ -virtual bool on_have (piece_index_t);
    │ │ │ -virtual bool on_have_all ();
    │ │ │  virtual bool on_interested ();
    │ │ │ +virtual bool on_have_none ();
    │ │ │  virtual bool on_dont_have (piece_index_t);
    │ │ │ +virtual bool on_have_all ();
    │ │ │  virtual bool on_choke ();
    │ │ │ -virtual bool on_bitfield (bitfield const& /*bitfield*/);
    │ │ │ +virtual bool on_request (peer_request const&);
    │ │ │ +virtual bool on_have (piece_index_t);
    │ │ │  virtual bool on_allowed_fast (piece_index_t);
    │ │ │ -virtual bool on_unchoke ();
    │ │ │ -virtual bool on_have_none ();
    │ │ │ +virtual bool on_bitfield (bitfield const& /*bitfield*/);
    │ │ │  
    │ │ │

    returning true from any of the message handlers │ │ │ indicates that the plugin has handled the message. │ │ │ it will break the plugin chain traversing and not let │ │ │ anyone else handle the message, including the default │ │ │ handler.

    │ │ │ [report issue]
    │ │ │ @@ -657,70 +990,70 @@ │ │ │ │ │ │

    This function is called when the peer connection is receiving │ │ │ a piece. buf points (non-owning pointer) to the data in an │ │ │ internal immutable disk buffer. The length of the data is specified │ │ │ in the length member of the piece parameter. │ │ │ returns true to indicate that the piece is handled and the │ │ │ rest of the logic should be ignored.

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    on_reject() on_suggest() on_cancel()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_suggest() on_cancel() on_reject()

    │ │ │
    │ │ │  virtual bool on_reject (peer_request const&);
    │ │ │ -virtual bool on_cancel (peer_request const&);
    │ │ │  virtual bool on_suggest (piece_index_t);
    │ │ │ +virtual bool on_cancel (peer_request const&);
    │ │ │  
    │ │ │

    called when a CANCEL, REJECT or SUGGEST message is received from the │ │ │ peer. If the extension returns true, the message is not │ │ │ forwarded to the bittorrent engine. It's expected to have been │ │ │ handled by the extension.

    │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    sent_reject_request() sent_have_all() sent_request() sent_suggest() sent_allow_fast() sent_choke() sent_unchoke() sent_not_interested() sent_have_none() sent_piece() sent_have() sent_cancel() sent_interested()

    │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    sent_have_none() sent_suggest() sent_unchoke() sent_have() sent_cancel() sent_interested() sent_request() sent_allow_fast() sent_piece() sent_reject_request() sent_choke() sent_not_interested() sent_have_all()

    │ │ │
    │ │ │ -virtual void sent_choke ();
    │ │ │ -virtual void sent_have (piece_index_t);
    │ │ │ +virtual void sent_not_interested ();
    │ │ │ +virtual void sent_have_all ();
    │ │ │  virtual void sent_have_none ();
    │ │ │  virtual void sent_reject_request (peer_request const&);
    │ │ │ -virtual void sent_cancel (peer_request const&);
    │ │ │ -virtual void sent_unchoke ();
    │ │ │  virtual void sent_suggest (piece_index_t);
    │ │ │ -virtual void sent_request (peer_request const&);
    │ │ │ -virtual void sent_not_interested ();
    │ │ │ +virtual void sent_cancel (peer_request const&);
    │ │ │ +virtual void sent_allow_fast (piece_index_t);
    │ │ │ +virtual void sent_choke ();
    │ │ │  virtual void sent_interested ();
    │ │ │ +virtual void sent_have (piece_index_t);
    │ │ │  virtual void sent_piece (peer_request const&);
    │ │ │ -virtual void sent_have_all ();
    │ │ │ -virtual void sent_allow_fast (piece_index_t);
    │ │ │ +virtual void sent_unchoke ();
    │ │ │ +virtual void sent_request (peer_request const&);
    │ │ │  
    │ │ │

    called after the corresponding message has been sent │ │ │ to the peer.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    sent_payload()

    │ │ │
    │ │ │  virtual void sent_payload (int /* bytes */);
    │ │ │  
    │ │ │

    called after piece data has been sent to the peer │ │ │ this can be used for stats book keeping

    │ │ │ [report issue]
    │ │ │ -
    │ │ │ +
    │ │ │

    can_disconnect()

    │ │ │
    │ │ │  virtual bool can_disconnect (error_code const& /*ec*/);
    │ │ │  
    │ │ │

    called when libtorrent think this peer should be disconnected. │ │ │ if the plugin returns false, the peer will not be disconnected.

    │ │ │ [report issue]
    │ │ │ @@ -744,18 +1077,18 @@ │ │ │
    │ │ │

    on_unknown_message()

    │ │ │
    │ │ │  virtual bool on_unknown_message (int /*length*/, int /*msg*/,
    │ │ │        span<char const> /*body*/);
    │ │ │  
    │ │ │

    this is not called for web seeds

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    on_piece_failed() on_piece_pass()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_piece_pass() on_piece_failed()

    │ │ │
    │ │ │  virtual void on_piece_failed (piece_index_t);
    │ │ │  virtual void on_piece_pass (piece_index_t);
    │ │ │  
    │ │ │

    called when a piece that this peer participated in either │ │ │ fails or passes the hash_check

    │ │ │ [report issue]
    │ │ │ @@ -789,17 +1122,17 @@ │ │ │ { │ │ │ virtual void set_outgoing_key (span<char const> key) = 0; │ │ │ virtual void set_incoming_key (span<char const> key) = 0; │ │ │ encrypt (span<span<char>> /*send_vec*/) = 0; │ │ │ virtual std::tuple<int, int, int> decrypt (span<span<char>> /*receive_vec*/) = 0; │ │ │ }; │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_incoming_key() set_outgoing_key()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_outgoing_key() set_incoming_key()

    │ │ │
    │ │ │  virtual void set_outgoing_key (span<char const> key) = 0;
    │ │ │  virtual void set_incoming_key (span<char const> key) = 0;
    │ │ │  
    │ │ │

    configure the symmetric stream keys used by this plugin. │ │ │ set_incoming_key() provides the key for decrypting bytes │ │ │ received from the peer; set_outgoing_key() the key for │ │ │ @@ -832,347 +1165,14 @@ │ │ │ (consume, produce, packet_size)

    │ │ │

    consume is set to the number of bytes which should be trimmed from the │ │ │ head of the buffers, default is 0

    │ │ │

    produce is set to the number of bytes of payload which are now ready to │ │ │ be sent to the upper layer. default is the number of bytes passed in receive_vec

    │ │ │

    packet_size is set to the minimum number of bytes which must be read to │ │ │ advance the next step of decryption. default is 0

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    peer_connection_handle

    │ │ │ -

    Declared in "libtorrent/peer_connection_handle.hpp"

    │ │ │ -

    the peer_connection_handle class provides a handle to the internal peer │ │ │ -connection object, to be used by plugins. This is a low level interface that │ │ │ -may not be stable across libtorrent versions

    │ │ │ -
    │ │ │ -struct peer_connection_handle
    │ │ │ -{
    │ │ │ -   explicit peer_connection_handle (std::weak_ptr<aux::peer_connection> impl);
    │ │ │ -   connection_type type () const;
    │ │ │ -   peer_plugin const* find_plugin (string_view type) const;
    │ │ │ -   void add_extension (std::shared_ptr<peer_plugin>);
    │ │ │ -   bool is_seed () const;
    │ │ │ -   bool upload_only () const;
    │ │ │ -   bool has_piece (piece_index_t i) const;
    │ │ │ -   peer_id const& pid () const;
    │ │ │ -   bool is_interesting () const;
    │ │ │ -   bool is_choked () const;
    │ │ │ -   bool is_peer_interested () const;
    │ │ │ -   bool has_peer_choked () const;
    │ │ │ -   void maybe_unchoke_this_peer ();
    │ │ │ -   void choke_this_peer ();
    │ │ │ -   void get_peer_info (peer_info& p) const;
    │ │ │ -   torrent_handle associated_torrent () const;
    │ │ │ -   tcp::endpoint const& remote () const;
    │ │ │ -   tcp::endpoint local_endpoint () const;
    │ │ │ -   void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -   bool is_connecting () const;
    │ │ │ -   bool is_outgoing () const;
    │ │ │ -   bool is_disconnecting () const;
    │ │ │ -   bool ignore_unchoke_slots () const;
    │ │ │ -   bool on_local_network () const;
    │ │ │ -   bool failed () const;
    │ │ │ -   bool should_log (peer_log_alert::direction_t direction) const;
    │ │ │ -   void peer_log (peer_log_alert::direction_t direction
    │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
    │ │ │ -   bool can_disconnect (error_code const& ec) const;
    │ │ │ -   bool has_metadata () const;
    │ │ │ -   bool in_handshake () const;
    │ │ │ -   void send_buffer (char const* begin, int size);
    │ │ │ -   std::time_t last_seen_complete () const;
    │ │ │ -   time_point time_of_last_unchoke () const;
    │ │ │ -   bool operator!= (peer_connection_handle const& o) const;
    │ │ │ -   bool operator< (peer_connection_handle const& o) const;
    │ │ │ -   bool operator== (peer_connection_handle const& o) const;
    │ │ │ -   std::shared_ptr<aux::peer_connection> native_handle () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    peer_connection_handle()

    │ │ │ -
    │ │ │ -explicit peer_connection_handle (std::weak_ptr<aux::peer_connection> impl);
    │ │ │ -
    │ │ │ -

    construct a handle wrapping the given internal peer_connection. │ │ │ -Typically created by libtorrent and passed to plugins; not │ │ │ -intended to be constructed by user code.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    type()

    │ │ │ -
    │ │ │ -connection_type type () const;
    │ │ │ -
    │ │ │ -

    the protocol type of this connection (bittorrent, url_seed, │ │ │ -http_seed)

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    find_plugin() add_extension()

    │ │ │ -
    │ │ │ -peer_plugin const* find_plugin (string_view type) const;
    │ │ │ -void add_extension (std::shared_ptr<peer_plugin>);
    │ │ │ -
    │ │ │ -

    attach a peer_plugin to this connection. find_plugin() looks │ │ │ -up an attached plugin by its type() string and returns nullptr │ │ │ -if none is registered.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    is_seed()

    │ │ │ -
    │ │ │ -bool is_seed () const;
    │ │ │ -
    │ │ │ -

    returns true if the remote peer is a seed

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    upload_only()

    │ │ │ -
    │ │ │ -bool upload_only () const;
    │ │ │ -
    │ │ │ -

    returns true if the remote peer has indicated upload-only (it │ │ │ -is a seed or has chosen not to download anything more from us)

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    pid() has_piece()

    │ │ │ -
    │ │ │ -bool has_piece (piece_index_t i) const;
    │ │ │ -peer_id const& pid () const;
    │ │ │ -
    │ │ │ -

    the peer id reported by the remote during handshake. │ │ │ -has_piece(i) returns true if the remote peer has piece i.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    is_choked() is_interesting()

    │ │ │ -
    │ │ │ -bool is_interesting () const;
    │ │ │ -bool is_choked () const;
    │ │ │ -
    │ │ │ -

    is_interesting() returns true if we are interested in the peer │ │ │ -(it has pieces we want). is_choked() returns true if we have │ │ │ -choked the peer (we are not currently sending data to it).

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    is_peer_interested() has_peer_choked()

    │ │ │ -
    │ │ │ -bool is_peer_interested () const;
    │ │ │ -bool has_peer_choked () const;
    │ │ │ -
    │ │ │ -

    is_peer_interested() returns true if the peer has indicated it │ │ │ -is interested in us. has_peer_choked() returns true if the peer │ │ │ -is choking us.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    choke_this_peer() maybe_unchoke_this_peer()

    │ │ │ -
    │ │ │ -void maybe_unchoke_this_peer ();
    │ │ │ -void choke_this_peer ();
    │ │ │ -
    │ │ │ -

    choke or possibly unchoke this peer immediately, bypassing the │ │ │ -regular unchoke selection. maybe_unchoke_this_peer() only │ │ │ -unchokes if there is an unchoke slot available.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_peer_info()

    │ │ │ -
    │ │ │ -void get_peer_info (peer_info& p) const;
    │ │ │ -
    │ │ │ -

    fills in p with statistics and state for this connection, │ │ │ -equivalent to the corresponding entry returned by │ │ │ -torrent_handle::get_peer_info().

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    associated_torrent()

    │ │ │ -
    │ │ │ -torrent_handle associated_torrent () const;
    │ │ │ -
    │ │ │ -

    the torrent this peer is associated with. Returns an invalid │ │ │ -handle if the peer is not yet associated with a torrent.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    local_endpoint() remote()

    │ │ │ -
    │ │ │ -tcp::endpoint const& remote () const;
    │ │ │ -tcp::endpoint local_endpoint () const;
    │ │ │ -
    │ │ │ -

    the remote peer's address and port, and the local endpoint of │ │ │ -the socket on our side.

    │ │ │ - │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    is_outgoing() is_connecting() disconnect() is_disconnecting()

    │ │ │ -
    │ │ │ -void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -bool is_connecting () const;
    │ │ │ -bool is_outgoing () const;
    │ │ │ -bool is_disconnecting () const;
    │ │ │ -
    │ │ │ -

    drop the connection with the given error code and operation │ │ │ -type. The disconnect is asynchronous; is_disconnecting() │ │ │ -becomes true immediately and the actual socket close happens │ │ │ -later. is_connecting() reports whether the outgoing socket │ │ │ -is still in the connect phase; is_outgoing() whether the │ │ │ -connection was initiated by us.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    ignore_unchoke_slots() on_local_network()

    │ │ │ -
    │ │ │ -bool ignore_unchoke_slots () const;
    │ │ │ -bool on_local_network () const;
    │ │ │ -
    │ │ │ -

    returns true if the peer's address is on the same local network │ │ │ -as us. ignore_unchoke_slots() returns true if this peer is │ │ │ -excluded from regular unchoke slot accounting.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    failed()

    │ │ │ -
    │ │ │ -bool failed () const;
    │ │ │ -
    │ │ │ -

    returns true if the connection has been closed because of an │ │ │ -error (rather than because of a normal disconnect)

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    peer_log() should_log()

    │ │ │ -
    │ │ │ -bool should_log (peer_log_alert::direction_t direction) const;
    │ │ │ -void peer_log (peer_log_alert::direction_t direction
    │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
    │ │ │ -
    │ │ │ -

    should_log() returns true if peer logging is enabled in the │ │ │ -given direction. peer_log() emits a peer_log_alert for this │ │ │ -connection, with printf-style formatting.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    can_disconnect()

    │ │ │ -
    │ │ │ -bool can_disconnect (error_code const& ec) const;
    │ │ │ -
    │ │ │ -

    returns true if a disconnect with error ec would be │ │ │ -permitted at this point (some errors are suppressed during │ │ │ -startup).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    has_metadata()

    │ │ │ -
    │ │ │ -bool has_metadata () const;
    │ │ │ -
    │ │ │ -

    returns true if we have received the metadata (info dict) for │ │ │ -this torrent from the peer or otherwise

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    in_handshake()

    │ │ │ -
    │ │ │ -bool in_handshake () const;
    │ │ │ -
    │ │ │ -

    returns true if the connection is still in the BitTorrent │ │ │ -handshake phase

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    send_buffer()

    │ │ │ -
    │ │ │ -void send_buffer (char const* begin, int size);
    │ │ │ -
    │ │ │ -

    queue size bytes of data to be sent to the peer. The data │ │ │ -is copied; the buffer does not need to outlive the call.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    time_of_last_unchoke() last_seen_complete()

    │ │ │ -
    │ │ │ -std::time_t last_seen_complete () const;
    │ │ │ -time_point time_of_last_unchoke () const;
    │ │ │ -
    │ │ │ -

    the most recent time_of_completion reported by the peer │ │ │ -(BEP 21), and the wall-clock time when we last unchoked it.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    native_handle()

    │ │ │ -
    │ │ │ -std::shared_ptr<aux::peer_connection> native_handle () const;
    │ │ │ -
    │ │ │ -

    returns a shared_ptr to the underlying peer_connection. The │ │ │ -pointer may be null if the connection has already been │ │ │ -destroyed.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    bt_peer_connection_handle

    │ │ │ -

    Declared in "libtorrent/peer_connection_handle.hpp"

    │ │ │ -

    The bt_peer_connection_handle provides a handle to the internal bittorrent │ │ │ -peer connection object to plugins. It's low level and may not be a stable API │ │ │ -across libtorrent versions.

    │ │ │ -
    │ │ │ -struct bt_peer_connection_handle : peer_connection_handle
    │ │ │ -{
    │ │ │ -   explicit bt_peer_connection_handle (peer_connection_handle pc);
    │ │ │ -   bool support_extensions () const;
    │ │ │ -   bool packet_finished () const;
    │ │ │ -   bool supports_encryption () const;
    │ │ │ -   void switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -   void switch_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -   std::shared_ptr<aux::bt_peer_connection> native_handle () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    bt_peer_connection_handle()

    │ │ │ -
    │ │ │ -explicit bt_peer_connection_handle (peer_connection_handle pc);
    │ │ │ -
    │ │ │ -

    construct from a generic peer_connection_handle. Behavior │ │ │ -is undefined if the underlying connection is not actually a │ │ │ -bittorrent peer connection.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    support_extensions() packet_finished()

    │ │ │ -
    │ │ │ -bool support_extensions () const;
    │ │ │ -bool packet_finished () const;
    │ │ │ -
    │ │ │ -

    packet_finished() returns true if the receive buffer holds a │ │ │ -complete BitTorrent message. support_extensions() returns true │ │ │ -if the remote peer announced support for the LTEP extension │ │ │ -protocol (BEP 10).

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    supports_encryption()

    │ │ │ -
    │ │ │ -bool supports_encryption () const;
    │ │ │ -
    │ │ │ -

    returns true if MSE (Message Stream Encryption) is in use on │ │ │ -this connection

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    switch_send_crypto() switch_recv_crypto()

    │ │ │ -
    │ │ │ -void switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -void switch_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -
    │ │ │ -

    install a custom crypto_plugin on the send or receive path. │ │ │ -Used to inject MSE / PE-style stream cipher into the peer │ │ │ -connection.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    native_handle()

    │ │ │ -
    │ │ │ -std::shared_ptr<aux::bt_peer_connection> native_handle () const;
    │ │ │ -
    │ │ │ -

    returns a shared_ptr to the underlying bt_peer_connection. May │ │ │ -be null if the connection has been destroyed.

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    create_ut_pex_plugin()

    │ │ │

    Declared in "libtorrent/extensions/ut_pex.hpp"

    │ │ │
    │ │ │  std::shared_ptr<torrent_plugin> create_ut_pex_plugin (torrent_handle const&, client_data_t);
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -2,90 +2,90 @@
    │ │ │ │  _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
    │ │ │ │  VVeerrssiioonn:: 2.1.1
    │ │ │ │  _h_o_m_e
    │ │ │ │  Table of contents
    │ │ │ │      * _a_ _w_o_r_d_ _o_f_ _c_a_u_t_i_o_n
    │ │ │ │      * _p_l_u_g_i_n_-_i_n_t_e_r_f_a_c_e
    │ │ │ │      * _c_u_s_t_o_m_ _a_l_e_r_t_s
    │ │ │ │ +    * _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ +          o _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ +          o _t_y_p_e_(_)
    │ │ │ │ +          o _f_i_n_d___p_l_u_g_i_n_(_)_ _a_d_d___e_x_t_e_n_s_i_o_n_(_)
    │ │ │ │ +          o _i_s___s_e_e_d_(_)
    │ │ │ │ +          o _u_p_l_o_a_d___o_n_l_y_(_)
    │ │ │ │ +          o _p_i_d_(_)_ _h_a_s___p_i_e_c_e_(_)
    │ │ │ │ +          o _i_s___i_n_t_e_r_e_s_t_i_n_g_(_)_ _i_s___c_h_o_k_e_d_(_)
    │ │ │ │ +          o _i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_)_ _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)
    │ │ │ │ +          o _m_a_y_b_e___u_n_c_h_o_k_e___t_h_i_s___p_e_e_r_(_)_ _c_h_o_k_e___t_h_i_s___p_e_e_r_(_)
    │ │ │ │ +          o _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ +          o _a_s_s_o_c_i_a_t_e_d___t_o_r_r_e_n_t_(_)
    │ │ │ │ +          o _r_e_m_o_t_e_(_)_ _l_o_c_a_l___e_n_d_p_o_i_n_t_(_)
    │ │ │ │ +          o _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)_ _i_s___o_u_t_g_o_i_n_g_(_)_ _i_s___c_o_n_n_e_c_t_i_n_g_(_)
    │ │ │ │ +          o _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)_ _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_)
    │ │ │ │ +          o _f_a_i_l_e_d_(_)
    │ │ │ │ +          o _s_h_o_u_l_d___l_o_g_(_)_ _p_e_e_r___l_o_g_(_)
    │ │ │ │ +          o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │ +          o _h_a_s___m_e_t_a_d_a_t_a_(_)
    │ │ │ │ +          o _i_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ +          o _s_e_n_d___b_u_f_f_e_r_(_)
    │ │ │ │ +          o _t_i_m_e___o_f___l_a_s_t___u_n_c_h_o_k_e_(_)_ _l_a_s_t___s_e_e_n___c_o_m_p_l_e_t_e_(_)
    │ │ │ │ +          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │ +    * _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ +          o _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ +          o _p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_)_ _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_)
    │ │ │ │ +          o _s_u_p_p_o_r_t_s___e_n_c_r_y_p_t_i_o_n_(_)
    │ │ │ │ +          o _s_w_i_t_c_h___s_e_n_d___c_r_y_p_t_o_(_)_ _s_w_i_t_c_h___r_e_c_v___c_r_y_p_t_o_(_)
    │ │ │ │ +          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │      * _p_l_u_g_i_n
    │ │ │ │            o _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_)
    │ │ │ │            o _n_e_w___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _a_d_d_e_d_(_)
    │ │ │ │            o _a_b_o_r_t_(_)
    │ │ │ │            o _o_n___d_h_t___r_e_q_u_e_s_t_(_)
    │ │ │ │            o _o_n___a_l_e_r_t_(_)
    │ │ │ │            o _o_n___u_n_k_n_o_w_n___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _o_n___t_i_c_k_(_)
    │ │ │ │            o _g_e_t___u_n_c_h_o_k_e___p_r_i_o_r_i_t_y_(_)
    │ │ │ │            o _s_a_v_e___s_t_a_t_e_(_)
    │ │ │ │            o _l_o_a_d___s_t_a_t_e_(_)
    │ │ │ │      * _t_o_r_r_e_n_t___p_l_u_g_i_n
    │ │ │ │            o _n_e_w___c_o_n_n_e_c_t_i_o_n_(_)
    │ │ │ │ -          o _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)_ _o_n___p_i_e_c_e___p_a_s_s_(_)
    │ │ │ │ +          o _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)
    │ │ │ │            o _t_i_c_k_(_)
    │ │ │ │            o _o_n___p_a_u_s_e_(_)_ _o_n___r_e_s_u_m_e_(_)
    │ │ │ │            o _o_n___f_i_l_e_s___c_h_e_c_k_e_d_(_)
    │ │ │ │            o _o_n___s_t_a_t_e_(_)
    │ │ │ │            o _o_n___a_d_d___p_e_e_r_(_)
    │ │ │ │      * _p_e_e_r___p_l_u_g_i_n
    │ │ │ │            o _t_y_p_e_(_)
    │ │ │ │            o _a_d_d___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │            o _o_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │            o _o_n___c_o_n_n_e_c_t_e_d_(_)
    │ │ │ │            o _o_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │            o _o_n___e_x_t_e_n_s_i_o_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ -          o _o_n___h_a_v_e___a_l_l_(_)_ _o_n___h_a_v_e_(_)_ _o_n___r_e_q_u_e_s_t_(_)_ _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ -            _o_n___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___d_o_n_t___h_a_v_e_(_)_ _o_n___b_i_t_f_i_e_l_d_(_)_ _o_n___u_n_c_h_o_k_e_(_)
    │ │ │ │ -            _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___c_h_o_k_e_(_)
    │ │ │ │ +          o _o_n___r_e_q_u_e_s_t_(_)_ _o_n___c_h_o_k_e_(_)_ _o_n___d_o_n_t___h_a_v_e_(_)_ _o_n___u_n_c_h_o_k_e_(_)_ _o_n___h_a_v_e_(_)
    │ │ │ │ +            _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___h_a_v_e___a_l_l_(_)
    │ │ │ │ +            _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___b_i_t_f_i_e_l_d_(_)
    │ │ │ │            o _o_n___p_i_e_c_e_(_)
    │ │ │ │ -          o _o_n___r_e_j_e_c_t_(_)_ _o_n___s_u_g_g_e_s_t_(_)_ _o_n___c_a_n_c_e_l_(_)
    │ │ │ │ -          o _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)_ _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_)
    │ │ │ │ -            _s_e_n_t___a_l_l_o_w___f_a_s_t_(_)_ _s_e_n_t___c_h_o_k_e_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)_ _s_e_n_t___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ -            _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___p_i_e_c_e_(_)_ _s_e_n_t___h_a_v_e_(_)_ _s_e_n_t___c_a_n_c_e_l_(_)
    │ │ │ │ -            _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ +          o _o_n___s_u_g_g_e_s_t_(_)_ _o_n___c_a_n_c_e_l_(_)_ _o_n___r_e_j_e_c_t_(_)
    │ │ │ │ +          o _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)_ _s_e_n_t___h_a_v_e_(_)
    │ │ │ │ +            _s_e_n_t___c_a_n_c_e_l_(_)_ _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___a_l_l_o_w___f_a_s_t_(_)
    │ │ │ │ +            _s_e_n_t___p_i_e_c_e_(_)_ _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___c_h_o_k_e_(_)_ _s_e_n_t___n_o_t___i_n_t_e_r_e_s_t_e_d
    │ │ │ │ +            _(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)
    │ │ │ │            o _s_e_n_t___p_a_y_l_o_a_d_(_)
    │ │ │ │            o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │            o _o_n___e_x_t_e_n_d_e_d_(_)
    │ │ │ │            o _o_n___u_n_k_n_o_w_n___m_e_s_s_a_g_e_(_)
    │ │ │ │ -          o _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)_ _o_n___p_i_e_c_e___p_a_s_s_(_)
    │ │ │ │ +          o _o_n___p_i_e_c_e___p_a_s_s_(_)_ _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)
    │ │ │ │            o _t_i_c_k_(_)
    │ │ │ │            o _w_r_i_t_e___r_e_q_u_e_s_t_(_)
    │ │ │ │      * _c_r_y_p_t_o___p_l_u_g_i_n
    │ │ │ │ -          o _s_e_t___i_n_c_o_m_i_n_g___k_e_y_(_)_ _s_e_t___o_u_t_g_o_i_n_g___k_e_y_(_)
    │ │ │ │ +          o _s_e_t___o_u_t_g_o_i_n_g___k_e_y_(_)_ _s_e_t___i_n_c_o_m_i_n_g___k_e_y_(_)
    │ │ │ │            o _e_n_c_r_y_p_t_(_)
    │ │ │ │            o _d_e_c_r_y_p_t_(_)
    │ │ │ │ -    * _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ -          o _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ -          o _t_y_p_e_(_)
    │ │ │ │ -          o _f_i_n_d___p_l_u_g_i_n_(_)_ _a_d_d___e_x_t_e_n_s_i_o_n_(_)
    │ │ │ │ -          o _i_s___s_e_e_d_(_)
    │ │ │ │ -          o _u_p_l_o_a_d___o_n_l_y_(_)
    │ │ │ │ -          o _p_i_d_(_)_ _h_a_s___p_i_e_c_e_(_)
    │ │ │ │ -          o _i_s___c_h_o_k_e_d_(_)_ _i_s___i_n_t_e_r_e_s_t_i_n_g_(_)
    │ │ │ │ -          o _i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_)_ _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)
    │ │ │ │ -          o _c_h_o_k_e___t_h_i_s___p_e_e_r_(_)_ _m_a_y_b_e___u_n_c_h_o_k_e___t_h_i_s___p_e_e_r_(_)
    │ │ │ │ -          o _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ -          o _a_s_s_o_c_i_a_t_e_d___t_o_r_r_e_n_t_(_)
    │ │ │ │ -          o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_)_ _r_e_m_o_t_e_(_)
    │ │ │ │ -          o _i_s___o_u_t_g_o_i_n_g_(_)_ _i_s___c_o_n_n_e_c_t_i_n_g_(_)_ _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)
    │ │ │ │ -          o _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)_ _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_)
    │ │ │ │ -          o _f_a_i_l_e_d_(_)
    │ │ │ │ -          o _p_e_e_r___l_o_g_(_)_ _s_h_o_u_l_d___l_o_g_(_)
    │ │ │ │ -          o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │ -          o _h_a_s___m_e_t_a_d_a_t_a_(_)
    │ │ │ │ -          o _i_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ -          o _s_e_n_d___b_u_f_f_e_r_(_)
    │ │ │ │ -          o _t_i_m_e___o_f___l_a_s_t___u_n_c_h_o_k_e_(_)_ _l_a_s_t___s_e_e_n___c_o_m_p_l_e_t_e_(_)
    │ │ │ │ -          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │ -    * _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ -          o _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ -          o _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_)_ _p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_)
    │ │ │ │ -          o _s_u_p_p_o_r_t_s___e_n_c_r_y_p_t_i_o_n_(_)
    │ │ │ │ -          o _s_w_i_t_c_h___s_e_n_d___c_r_y_p_t_o_(_)_ _s_w_i_t_c_h___r_e_c_v___c_r_y_p_t_o_(_)
    │ │ │ │ -          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │      * _c_r_e_a_t_e___u_t___p_e_x___p_l_u_g_i_n_(_)
    │ │ │ │      * _c_r_e_a_t_e___s_m_a_r_t___b_a_n___p_l_u_g_i_n_(_)
    │ │ │ │      * _c_r_e_a_t_e___u_t___m_e_t_a_d_a_t_a___p_l_u_g_i_n_(_)
    │ │ │ │  libtorrent has a _p_l_u_g_i_n interface for implementing extensions to the protocol.
    │ │ │ │  These can be general extensions for transferring metadata or peer exchange
    │ │ │ │  extensions, or it could be used to provide a way to customize the protocol to
    │ │ │ │  fit a particular (closed) network.
    │ │ │ │ @@ -164,14 +164,236 @@
    │ │ │ │  The static category is required for checking whether or not the category for a
    │ │ │ │  specific _a_l_e_r_t is enabled or not, without instantiating the _a_l_e_r_t. The category
    │ │ │ │  virtual function is the run-time equivalence.
    │ │ │ │  The what() virtual function may simply be a string literal of the class name of
    │ │ │ │  your _a_l_e_r_t.
    │ │ │ │  For more information, see the _a_l_e_r_t_ _s_e_c_t_i_o_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +************ ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ +the _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e class provides a handle to the internal peer
    │ │ │ │ +connection object, to be used by plugins. This is a low level interface that
    │ │ │ │ +may not be stable across libtorrent versions
    │ │ │ │ +struct peer_connection_handle
    │ │ │ │ +{
    │ │ │ │ +   explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ +   connection_type ttyyppee () const;
    │ │ │ │ +   peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ +   void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ +   bool iiss__sseeeedd () const;
    │ │ │ │ +   bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ +   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +   peer_id const& ppiidd () const;
    │ │ │ │ +   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ +   bool iiss__cchhookkeedd () const;
    │ │ │ │ +   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ +   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ +   void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +   void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ +   torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ +   _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ +   _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ +   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ +   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +   bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +   bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ +   bool ffaaiilleedd () const;
    │ │ │ │ +   bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ +   void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ +      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ +TORRENT_FORMAT(4,5);
    │ │ │ │ +   bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ +   bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ +   bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ +   void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ +   std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ +   time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ +   bool ooppeerraattoorr<< (peer_connection_handle const& o) const;
    │ │ │ │ +   bool ooppeerraattoorr!!== (peer_connection_handle const& o) const;
    │ │ │ │ +   bool ooppeerraattoorr==== (peer_connection_handle const& o) const;
    │ │ │ │ +   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +};
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ +explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ +construct a handle wrapping the given internal peer_connection. Typically
    │ │ │ │ +created by libtorrent and passed to plugins; not intended to be constructed by
    │ │ │ │ +user code.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ttyyppee(()) **********
    │ │ │ │ +connection_type ttyyppee () const;
    │ │ │ │ +the protocol type of this connection (bittorrent, url_seed, http_seed)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ffiinndd__pplluuggiinn(()) aadddd__eexxtteennssiioonn(()) **********
    │ │ │ │ +peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ +void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ +attach a _p_e_e_r___p_l_u_g_i_n to this connection. find_plugin() looks up an attached
    │ │ │ │ +_p_l_u_g_i_n by its type() string and returns nullptr if none is registered.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__sseeeedd(()) **********
    │ │ │ │ +bool iiss__sseeeedd () const;
    │ │ │ │ +returns true if the remote peer is a seed
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** uuppllooaadd__oonnllyy(()) **********
    │ │ │ │ +bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ +returns true if the remote peer has indicated upload-only (it is a seed or has
    │ │ │ │ +chosen not to download anything more from us)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ppiidd(()) hhaass__ppiieeccee(()) **********
    │ │ │ │ +bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +peer_id const& ppiidd () const;
    │ │ │ │ +the peer id reported by the remote during handshake. has_piece(i) returns true
    │ │ │ │ +if the remote peer has piece i.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__iinntteerreessttiinngg(()) iiss__cchhookkeedd(()) **********
    │ │ │ │ +bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ +bool iiss__cchhookkeedd () const;
    │ │ │ │ +_i_s___i_n_t_e_r_e_s_t_i_n_g_(_) returns true if we are interested in the peer (it has pieces
    │ │ │ │ +we want). _i_s___c_h_o_k_e_d_(_) returns true if we have choked the peer (we are not
    │ │ │ │ +currently sending data to it).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__ppeeeerr__iinntteerreesstteedd(()) hhaass__ppeeeerr__cchhookkeedd(()) **********
    │ │ │ │ +bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ +bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ +_i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_) returns true if the peer has indicated it is interested in
    │ │ │ │ +us. _h_a_s___p_e_e_r___c_h_o_k_e_d_(_) returns true if the peer is choking us.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) cchhookkee__tthhiiss__ppeeeerr(()) **********
    │ │ │ │ +void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +choke or possibly unchoke this peer immediately, bypassing the regular unchoke
    │ │ │ │ +selection. maybe_unchoke_this_peer() only unchokes if there is an unchoke slot
    │ │ │ │ +available.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ +void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ +fills in p with statistics and state for this connection, equivalent to the
    │ │ │ │ +corresponding _e_n_t_r_y returned by _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_g_e_t___p_e_e_r___i_n_f_o_(_).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** aassssoocciiaatteedd__ttoorrrreenntt(()) **********
    │ │ │ │ +torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ +the torrent this peer is associated with. Returns an invalid handle if the peer
    │ │ │ │ +is not yet associated with a torrent.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** rreemmoottee(()) llooccaall__eennddppooiinntt(()) **********
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ +the remote peer's address and port, and the local endpoint of the socket on our
    │ │ │ │ +side.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ddiissccoonnnneecctt(()) iiss__ddiissccoonnnneeccttiinngg(()) iiss__oouuttggooiinngg(()) iiss__ccoonnnneeccttiinngg(()) **********
    │ │ │ │ +bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ +bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +drop the connection with the given error code and operation type. The
    │ │ │ │ +disconnect is asynchronous; is_disconnecting() becomes true immediately and the
    │ │ │ │ +actual socket close happens later. is_connecting() reports whether the outgoing
    │ │ │ │ +socket is still in the connect phase; is_outgoing() whether the connection was
    │ │ │ │ +initiated by us.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiggnnoorree__uunncchhookkee__sslloottss(()) oonn__llooccaall__nneettwwoorrkk(()) **********
    │ │ │ │ +bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ +returns true if the peer's address is on the same local network as us.
    │ │ │ │ +ignore_unchoke_slots() returns true if this peer is excluded from regular
    │ │ │ │ +unchoke slot accounting.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ffaaiilleedd(()) **********
    │ │ │ │ +bool ffaaiilleedd () const;
    │ │ │ │ +returns true if the connection has been closed because of an error (rather than
    │ │ │ │ +because of a normal disconnect)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** sshhoouulldd__lloogg(()) ppeeeerr__lloogg(()) **********
    │ │ │ │ +bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ +void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ +      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ +TORRENT_FORMAT(4,5);
    │ │ │ │ +_s_h_o_u_l_d___l_o_g_(_) returns true if peer logging is enabled in the given direction.
    │ │ │ │ +_p_e_e_r___l_o_g_(_) emits a peer_log_alert for this connection, with printf-style
    │ │ │ │ +formatting.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ccaann__ddiissccoonnnneecctt(()) **********
    │ │ │ │ +bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ +returns true if a disconnect with error ec would be permitted at this point
    │ │ │ │ +(some errors are suppressed during startup).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** hhaass__mmeettaaddaattaa(()) **********
    │ │ │ │ +bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ +returns true if we have received the metadata (info dict) for this torrent from
    │ │ │ │ +the peer or otherwise
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iinn__hhaannddsshhaakkee(()) **********
    │ │ │ │ +bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ +returns true if the connection is still in the BitTorrent handshake phase
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** sseenndd__bbuuffffeerr(()) **********
    │ │ │ │ +void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ +queue size bytes of data to be sent to the peer. The data is copied; the buffer
    │ │ │ │ +does not need to outlive the call.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ttiimmee__ooff__llaasstt__uunncchhookkee(()) llaasstt__sseeeenn__ccoommpplleettee(()) **********
    │ │ │ │ +std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ +time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ +the most recent time_of_completion reported by the peer (BEP 21), and the wall-
    │ │ │ │ +clock time when we last unchoked it.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +returns a shared_ptr to the underlying peer_connection. The pointer may be null
    │ │ │ │ +if the connection has already been destroyed.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +************ bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ +The _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e provides a handle to the internal bittorrent peer
    │ │ │ │ +connection object to plugins. It's low level and may not be a stable API across
    │ │ │ │ +libtorrent versions.
    │ │ │ │ +struct bt_peer_connection_handle : peer_connection_handle
    │ │ │ │ +{
    │ │ │ │ +   explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ +   bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ +   bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ +   bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ +   void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +   void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +};
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ +explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ +construct from a generic peer_connection_handle. Behavior is undefined if the
    │ │ │ │ +underlying connection is not actually a bittorrent peer connection.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ppaacckkeett__ffiinniisshheedd(()) ssuuppppoorrtt__eexxtteennssiioonnss(()) **********
    │ │ │ │ +bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ +bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ +_p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_) returns true if the receive buffer holds a complete
    │ │ │ │ +BitTorrent message. _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_) returns true if the remote peer
    │ │ │ │ +announced support for the LTEP extension protocol (BEP 10).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ssuuppppoorrttss__eennccrryyppttiioonn(()) **********
    │ │ │ │ +bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ +returns true if MSE (Message Stream Encryption) is in use on this connection
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** sswwiittcchh__sseenndd__ccrryyppttoo(()) sswwiittcchh__rreeccvv__ccrryyppttoo(()) **********
    │ │ │ │ +void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +install a custom crypto_plugin on the send or receive path. Used to inject MSE
    │ │ │ │ +/ PE-style stream cipher into the peer connection.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +returns a shared_ptr to the underlying bt_peer_connection. May be null if the
    │ │ │ │ +connection has been destroyed.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ pplluuggiinn ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_._h_p_p"
    │ │ │ │  this is the base class for a _s_e_s_s_i_o_n _p_l_u_g_i_n. One primary feature is that it is
    │ │ │ │  notified of all torrents that are added to the _s_e_s_s_i_o_n, and can add its own
    │ │ │ │  torrent_plugins.
    │ │ │ │  struct plugin
    │ │ │ │  {
    │ │ │ │ @@ -324,15 +546,15 @@
    │ │ │ │  have its hook functions called on event specific to that peer.
    │ │ │ │  The peer_connection_handle will be valid as long as the shared_ptr is being
    │ │ │ │  held by the torrent object. So, it is generally a good idea to not keep a
    │ │ │ │  shared_ptr to your own _p_e_e_r___p_l_u_g_i_n. If you want to keep references to it, use
    │ │ │ │  weak_ptr.
    │ │ │ │  If this function throws an exception, the connection will be closed.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__ppiieeccee__ffaaiilleedd(()) oonn__ppiieeccee__ppaassss(()) **********
    │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) **********
    │ │ │ │  virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │  virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │  These hooks are called when a piece passes the hash check or fails the hash
    │ │ │ │  check, respectively. The index is the piece index that was downloaded. It is
    │ │ │ │  possible to access the list of peers that participated in sending the piece
    │ │ │ │  through the torrent and the piece_picker.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -393,43 +615,43 @@
    │ │ │ │  {
    │ │ │ │     virtual string_view ttyyppee () const;
    │ │ │ │     virtual void aadddd__hhaannddsshhaakkee (entry&);
    │ │ │ │     virtual void oonn__ddiissccoonnnneecctt (error_code const&);
    │ │ │ │     virtual void oonn__ccoonnnneecctteedd ();
    │ │ │ │     virtual bool oonn__hhaannddsshhaakkee (span);
    │ │ │ │     virtual bool oonn__eexxtteennssiioonn__hhaannddsshhaakkee (bdecode_node const&);
    │ │ │ │ -   virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +   virtual bool oonn__uunncchhookkee ();
    │ │ │ │     virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ -   virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ -   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │     virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │     virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │     virtual bool oonn__cchhookkee ();
    │ │ │ │ -   virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ +   virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +   virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │     virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │ -   virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │     virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**//
    │ │ │ │        , span //**bbuuff**//);
    │ │ │ │     virtual bool oonn__rreejjeecctt (peer_request const&);
    │ │ │ │ -   virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │     virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__cchhookkee ();
    │ │ │ │ -   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │     virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │     virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │     virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ +   virtual void sseenntt__cchhookkee ();
    │ │ │ │     virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │     virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │ -   virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ +   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ +   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │     virtual void sseenntt__ppaayyllooaadd (int //** bbyytteess **//);
    │ │ │ │     virtual bool ccaann__ddiissccoonnnneecctt (error_code const& //**eecc**//);
    │ │ │ │     virtual bool oonn__eexxtteennddeedd (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │     virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │     virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │ @@ -465,65 +687,65 @@
    │ │ │ │  ********** oonn__eexxtteennssiioonn__hhaannddsshhaakkee(()) **********
    │ │ │ │  virtual bool oonn__eexxtteennssiioonn__hhaannddsshhaakkee (bdecode_node const&);
    │ │ │ │  called when the extension handshake from the other end is received if this
    │ │ │ │  returns false, it means that this extension isn't supported by this peer. It
    │ │ │ │  will result in this _p_e_e_r___p_l_u_g_i_n being removed from the peer_connection and
    │ │ │ │  destructed. this is not called for web seeds
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__hhaavvee__aallll(()) oonn__hhaavvee(()) oonn__rreeqquueesstt(()) oonn__nnoott__iinntteerreesstteedd(()) oonn__iinntteerreesstteedd(())
    │ │ │ │ -oonn__ddoonntt__hhaavvee(()) oonn__bbiittffiieelldd(()) oonn__uunncchhookkee(()) oonn__hhaavvee__nnoonnee(()) oonn__aalllloowweedd__ffaasstt(())
    │ │ │ │ -oonn__cchhookkee(()) **********
    │ │ │ │ -virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +********** oonn__rreeqquueesstt(()) oonn__cchhookkee(()) oonn__ddoonntt__hhaavvee(()) oonn__uunncchhookkee(()) oonn__hhaavvee(())
    │ │ │ │ +oonn__aalllloowweedd__ffaasstt(()) oonn__iinntteerreesstteedd(()) oonn__hhaavvee__nnoonnee(()) oonn__hhaavvee__aallll(())
    │ │ │ │ +oonn__nnoott__iinntteerreesstteedd(()) oonn__bbiittffiieelldd(()) **********
    │ │ │ │ +virtual bool oonn__uunncchhookkee ();
    │ │ │ │  virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ -virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ -virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │  virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │  virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ +virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │  virtual bool oonn__cchhookkee ();
    │ │ │ │ -virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ +virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │  virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │ -virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │  returning true from any of the message handlers indicates that the _p_l_u_g_i_n has
    │ │ │ │  handled the message. it will break the _p_l_u_g_i_n chain traversing and not let
    │ │ │ │  anyone else handle the message, including the default handler.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** oonn__ppiieeccee(()) **********
    │ │ │ │  virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**//
    │ │ │ │        , span //**bbuuff**//);
    │ │ │ │  This function is called when the peer connection is receiving a piece. buf
    │ │ │ │  points (non-owning pointer) to the data in an internal immutable disk buffer.
    │ │ │ │  The length of the data is specified in the length member of the piece
    │ │ │ │  parameter. returns true to indicate that the piece is handled and the rest of
    │ │ │ │  the logic should be ignored.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__rreejjeecctt(()) oonn__ssuuggggeesstt(()) oonn__ccaanncceell(()) **********
    │ │ │ │ +********** oonn__ssuuggggeesstt(()) oonn__ccaanncceell(()) oonn__rreejjeecctt(()) **********
    │ │ │ │  virtual bool oonn__rreejjeecctt (peer_request const&);
    │ │ │ │ -virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │  virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │ +virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │  called when a CANCEL, REJECT or SUGGEST message is received from the peer. If
    │ │ │ │  the extension returns true, the message is not forwarded to the bittorrent
    │ │ │ │  engine. It's expected to have been handled by the extension.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseenntt__rreejjeecctt__rreeqquueesstt(()) sseenntt__hhaavvee__aallll(()) sseenntt__rreeqquueesstt(()) sseenntt__ssuuggggeesstt(())
    │ │ │ │ -sseenntt__aallllooww__ffaasstt(()) sseenntt__cchhookkee(()) sseenntt__uunncchhookkee(()) sseenntt__nnoott__iinntteerreesstteedd(())
    │ │ │ │ -sseenntt__hhaavvee__nnoonnee(()) sseenntt__ppiieeccee(()) sseenntt__hhaavvee(()) sseenntt__ccaanncceell(()) sseenntt__iinntteerreesstteedd(()) **********
    │ │ │ │ -virtual void sseenntt__cchhookkee ();
    │ │ │ │ -virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ +********** sseenntt__hhaavvee__nnoonnee(()) sseenntt__ssuuggggeesstt(()) sseenntt__uunncchhookkee(()) sseenntt__hhaavvee(()) sseenntt__ccaanncceell(())
    │ │ │ │ +sseenntt__iinntteerreesstteedd(()) sseenntt__rreeqquueesstt(()) sseenntt__aallllooww__ffaasstt(()) sseenntt__ppiieeccee(())
    │ │ │ │ +sseenntt__rreejjeecctt__rreeqquueesstt(()) sseenntt__cchhookkee(()) sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__hhaavvee__aallll(()) **********
    │ │ │ │ +virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │  virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │  virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ -virtual void sseenntt__uunncchhookkee ();
    │ │ │ │  virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ -virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ +virtual void sseenntt__cchhookkee ();
    │ │ │ │  virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │  virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ -virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │ -virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ +virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ +virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │  called after the corresponding message has been sent to the peer.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** sseenntt__ppaayyllooaadd(()) **********
    │ │ │ │  virtual void sseenntt__ppaayyllooaadd (int //** bbyytteess **//);
    │ │ │ │  called after piece data has been sent to the peer this can be used for stats
    │ │ │ │  book keeping
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -546,15 +768,15 @@
    │ │ │ │  receiving large messages.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** oonn__uunnkknnoowwnn__mmeessssaaggee(()) **********
    │ │ │ │  virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │  this is not called for web seeds
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__ppiieeccee__ffaaiilleedd(()) oonn__ppiieeccee__ppaassss(()) **********
    │ │ │ │ +********** oonn__ppiieeccee__ppaassss(()) oonn__ppiieeccee__ffaaiilleedd(()) **********
    │ │ │ │  virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │  virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │  called when a piece that this peer participated in either fails or passes the
    │ │ │ │  hash_check
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttiicckk(()) **********
    │ │ │ │  virtual void ttiicckk ();
    │ │ │ │ @@ -577,15 +799,15 @@
    │ │ │ │     virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │     virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │     eennccrryypptt (span> //**sseenndd__vveecc**//) = 0;
    │ │ │ │     virtual std::tuple ddeeccrryypptt (span> //**rreecceeiivvee__vveecc**//
    │ │ │ │  ) = 0;
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__iinnccoommiinngg__kkeeyy(()) sseett__oouuttggooiinngg__kkeeyy(()) **********
    │ │ │ │ +********** sseett__oouuttggooiinngg__kkeeyy(()) sseett__iinnccoommiinngg__kkeeyy(()) **********
    │ │ │ │  virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │  virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │  configure the symmetric stream keys used by this _p_l_u_g_i_n. set_incoming_key()
    │ │ │ │  provides the key for decrypting bytes received from the peer; set_outgoing_key
    │ │ │ │  () the key for encrypting bytes sent to the peer. Both are called once during
    │ │ │ │  the handshake before any data flows through the _p_l_u_g_i_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -608,236 +830,14 @@
    │ │ │ │  consume is set to the number of bytes which should be trimmed from the head of
    │ │ │ │  the buffers, default is 0
    │ │ │ │  produce is set to the number of bytes of payload which are now ready to be sent
    │ │ │ │  to the upper layer. default is the number of bytes passed in receive_vec
    │ │ │ │  packet_size is set to the minimum number of bytes which must be read to advance
    │ │ │ │  the next step of decryption. default is 0
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -************ ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ -the _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e class provides a handle to the internal peer
    │ │ │ │ -connection object, to be used by plugins. This is a low level interface that
    │ │ │ │ -may not be stable across libtorrent versions
    │ │ │ │ -struct peer_connection_handle
    │ │ │ │ -{
    │ │ │ │ -   explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ -   connection_type ttyyppee () const;
    │ │ │ │ -   peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -   void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -   bool iiss__sseeeedd () const;
    │ │ │ │ -   bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ -   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -   peer_id const& ppiidd () const;
    │ │ │ │ -   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ -   bool iiss__cchhookkeedd () const;
    │ │ │ │ -   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ -   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ -   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -   void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -   void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ -   torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ -   _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ -   _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ -   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -   bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ -   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ -   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -   bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ -   bool ffaaiilleedd () const;
    │ │ │ │ -   bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ -   void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ -TORRENT_FORMAT(4,5);
    │ │ │ │ -   bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ -   bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ -   bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ -   void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ -   std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ -   time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ -   bool ooppeerraattoorr!!== (peer_connection_handle const& o) const;
    │ │ │ │ -   bool ooppeerraattoorr<< (peer_connection_handle const& o) const;
    │ │ │ │ -   bool ooppeerraattoorr==== (peer_connection_handle const& o) const;
    │ │ │ │ -   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -};
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ -explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ -construct a handle wrapping the given internal peer_connection. Typically
    │ │ │ │ -created by libtorrent and passed to plugins; not intended to be constructed by
    │ │ │ │ -user code.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ttyyppee(()) **********
    │ │ │ │ -connection_type ttyyppee () const;
    │ │ │ │ -the protocol type of this connection (bittorrent, url_seed, http_seed)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffiinndd__pplluuggiinn(()) aadddd__eexxtteennssiioonn(()) **********
    │ │ │ │ -peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -attach a _p_e_e_r___p_l_u_g_i_n to this connection. find_plugin() looks up an attached
    │ │ │ │ -_p_l_u_g_i_n by its type() string and returns nullptr if none is registered.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__sseeeedd(()) **********
    │ │ │ │ -bool iiss__sseeeedd () const;
    │ │ │ │ -returns true if the remote peer is a seed
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** uuppllooaadd__oonnllyy(()) **********
    │ │ │ │ -bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ -returns true if the remote peer has indicated upload-only (it is a seed or has
    │ │ │ │ -chosen not to download anything more from us)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppiidd(()) hhaass__ppiieeccee(()) **********
    │ │ │ │ -bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -peer_id const& ppiidd () const;
    │ │ │ │ -the peer id reported by the remote during handshake. has_piece(i) returns true
    │ │ │ │ -if the remote peer has piece i.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__cchhookkeedd(()) iiss__iinntteerreessttiinngg(()) **********
    │ │ │ │ -bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ -bool iiss__cchhookkeedd () const;
    │ │ │ │ -_i_s___i_n_t_e_r_e_s_t_i_n_g_(_) returns true if we are interested in the peer (it has pieces
    │ │ │ │ -we want). _i_s___c_h_o_k_e_d_(_) returns true if we have choked the peer (we are not
    │ │ │ │ -currently sending data to it).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__ppeeeerr__iinntteerreesstteedd(()) hhaass__ppeeeerr__cchhookkeedd(()) **********
    │ │ │ │ -bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ -bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ -_i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_) returns true if the peer has indicated it is interested in
    │ │ │ │ -us. _h_a_s___p_e_e_r___c_h_o_k_e_d_(_) returns true if the peer is choking us.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** cchhookkee__tthhiiss__ppeeeerr(()) mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) **********
    │ │ │ │ -void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -choke or possibly unchoke this peer immediately, bypassing the regular unchoke
    │ │ │ │ -selection. maybe_unchoke_this_peer() only unchokes if there is an unchoke slot
    │ │ │ │ -available.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ -void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ -fills in p with statistics and state for this connection, equivalent to the
    │ │ │ │ -corresponding _e_n_t_r_y returned by _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_g_e_t___p_e_e_r___i_n_f_o_(_).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aassssoocciiaatteedd__ttoorrrreenntt(()) **********
    │ │ │ │ -torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ -the torrent this peer is associated with. Returns an invalid handle if the peer
    │ │ │ │ -is not yet associated with a torrent.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** llooccaall__eennddppooiinntt(()) rreemmoottee(()) **********
    │ │ │ │ -_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ -_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ -the remote peer's address and port, and the local endpoint of the socket on our
    │ │ │ │ -side.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__oouuttggooiinngg(()) iiss__ccoonnnneeccttiinngg(()) ddiissccoonnnneecctt(()) iiss__ddiissccoonnnneeccttiinngg(()) **********
    │ │ │ │ -void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ -bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ -drop the connection with the given error code and operation type. The
    │ │ │ │ -disconnect is asynchronous; is_disconnecting() becomes true immediately and the
    │ │ │ │ -actual socket close happens later. is_connecting() reports whether the outgoing
    │ │ │ │ -socket is still in the connect phase; is_outgoing() whether the connection was
    │ │ │ │ -initiated by us.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiggnnoorree__uunncchhookkee__sslloottss(()) oonn__llooccaall__nneettwwoorrkk(()) **********
    │ │ │ │ -bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ -returns true if the peer's address is on the same local network as us.
    │ │ │ │ -ignore_unchoke_slots() returns true if this peer is excluded from regular
    │ │ │ │ -unchoke slot accounting.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffaaiilleedd(()) **********
    │ │ │ │ -bool ffaaiilleedd () const;
    │ │ │ │ -returns true if the connection has been closed because of an error (rather than
    │ │ │ │ -because of a normal disconnect)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppeeeerr__lloogg(()) sshhoouulldd__lloogg(()) **********
    │ │ │ │ -bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ -void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ -TORRENT_FORMAT(4,5);
    │ │ │ │ -_s_h_o_u_l_d___l_o_g_(_) returns true if peer logging is enabled in the given direction.
    │ │ │ │ -_p_e_e_r___l_o_g_(_) emits a peer_log_alert for this connection, with printf-style
    │ │ │ │ -formatting.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ccaann__ddiissccoonnnneecctt(()) **********
    │ │ │ │ -bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ -returns true if a disconnect with error ec would be permitted at this point
    │ │ │ │ -(some errors are suppressed during startup).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** hhaass__mmeettaaddaattaa(()) **********
    │ │ │ │ -bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ -returns true if we have received the metadata (info dict) for this torrent from
    │ │ │ │ -the peer or otherwise
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iinn__hhaannddsshhaakkee(()) **********
    │ │ │ │ -bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ -returns true if the connection is still in the BitTorrent handshake phase
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseenndd__bbuuffffeerr(()) **********
    │ │ │ │ -void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ -queue size bytes of data to be sent to the peer. The data is copied; the buffer
    │ │ │ │ -does not need to outlive the call.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ttiimmee__ooff__llaasstt__uunncchhookkee(()) llaasstt__sseeeenn__ccoommpplleettee(()) **********
    │ │ │ │ -std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ -time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ -the most recent time_of_completion reported by the peer (BEP 21), and the wall-
    │ │ │ │ -clock time when we last unchoked it.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -returns a shared_ptr to the underlying peer_connection. The pointer may be null
    │ │ │ │ -if the connection has already been destroyed.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -************ bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ -The _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e provides a handle to the internal bittorrent peer
    │ │ │ │ -connection object to plugins. It's low level and may not be a stable API across
    │ │ │ │ -libtorrent versions.
    │ │ │ │ -struct bt_peer_connection_handle : peer_connection_handle
    │ │ │ │ -{
    │ │ │ │ -   explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ -   bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ -   bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ -   bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ -   void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -   void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -};
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ -explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ -construct from a generic peer_connection_handle. Behavior is undefined if the
    │ │ │ │ -underlying connection is not actually a bittorrent peer connection.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ssuuppppoorrtt__eexxtteennssiioonnss(()) ppaacckkeett__ffiinniisshheedd(()) **********
    │ │ │ │ -bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ -bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ -_p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_) returns true if the receive buffer holds a complete
    │ │ │ │ -BitTorrent message. _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_) returns true if the remote peer
    │ │ │ │ -announced support for the LTEP extension protocol (BEP 10).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ssuuppppoorrttss__eennccrryyppttiioonn(()) **********
    │ │ │ │ -bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ -returns true if MSE (Message Stream Encryption) is in use on this connection
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sswwiittcchh__sseenndd__ccrryyppttoo(()) sswwiittcchh__rreeccvv__ccrryyppttoo(()) **********
    │ │ │ │ -void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -install a custom crypto_plugin on the send or receive path. Used to inject MSE
    │ │ │ │ -/ PE-style stream cipher into the peer connection.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -returns a shared_ptr to the underlying bt_peer_connection. May be null if the
    │ │ │ │ -connection has been destroyed.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ ccrreeaattee__uutt__ppeexx__pplluuggiinn(()) ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_/_u_t___p_e_x_._h_p_p"
    │ │ │ │  std::shared_ptr ccrreeaattee__uutt__ppeexx__pplluuggiinn (torrent_handle const&,
    │ │ │ │  client_data_t);
    │ │ │ │  constructor function for the ut_pex extension. The ut_pex extension allows
    │ │ │ │  peers to gossip about their connections, allowing the swarm stay well connected
    │ │ │ │  and peers aware of more peers in the swarm. This extension is enabled by
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html
    │ │ │┄ Ordering differences only
    │ │ │ @@ -38,22 +38,22 @@
    │ │ │  
  • write_torrent_flags_t
  • │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    read_resume_data()

    │ │ │

    Declared in "libtorrent/read_resume_data.hpp"

    │ │ │
    │ │ │ -add_torrent_params read_resume_data (span<char const> buffer
    │ │ │ -   , load_torrent_limits const& cfg = {});
    │ │ │  add_torrent_params read_resume_data (bdecode_node const& rd
    │ │ │     , int piece_limit = 0x200000);
    │ │ │  add_torrent_params read_resume_data (span<char const> buffer
    │ │ │ -   , error_code& ec, load_torrent_limits const& cfg = {});
    │ │ │ +   , load_torrent_limits const& cfg = {});
    │ │ │  add_torrent_params read_resume_data (bdecode_node const& rd
    │ │ │     , error_code& ec, int piece_limit = 0x200000);
    │ │ │ +add_torrent_params read_resume_data (span<char const> buffer
    │ │ │ +   , error_code& ec, load_torrent_limits const& cfg = {});
    │ │ │  
    │ │ │

    these functions are used to parse resume data and populate the appropriate │ │ │ fields in an add_torrent_params object. This object can then be used to add │ │ │ the actual torrent_info object to and pass to session::add_torrent() or │ │ │ session::async_add_torrent().

    │ │ │

    If the client wants to override any field that was loaded from the resume │ │ │ data, e.g. save_path, those fields must be changed after loading resume │ │ │ @@ -97,18 +97,18 @@ │ │ │ into a bencoded structure

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    write_torrent_file_buf() write_torrent_file()

    │ │ │

    Declared in "libtorrent/write_resume_data.hpp"

    │ │ │
    │ │ │ +entry write_torrent_file (add_torrent_params const& atp);
    │ │ │  std::vector<char> write_torrent_file_buf (add_torrent_params const& atp
    │ │ │     , write_torrent_flags_t flags);
    │ │ │  entry write_torrent_file (add_torrent_params const& atp, write_torrent_flags_t flags);
    │ │ │ -entry write_torrent_file (add_torrent_params const& atp);
    │ │ │  
    │ │ │

    writes only the fields to create a .torrent file. This function may fail │ │ │ with a std::system_error exception if:

    │ │ │
    │ │ │ [report issue]
    │ │ │

    session_params

    │ │ │

    Declared in "libtorrent/session_params.hpp"

    │ │ │

    The session_params is a parameters pack for configuring the session │ │ │ before it's started.

    │ │ │
    │ │ │  struct session_params
    │ │ │  {
    │ │ │     session_params (settings_pack const& sp);
    │ │ │     session_params (settings_pack&& sp);
    │ │ │     session_params ();
    │ │ │ -   session_params (settings_pack&& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │     session_params (settings_pack const& sp
    │ │ │        , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +   session_params (settings_pack&& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │  
    │ │ │     settings_pack settings;
    │ │ │     session_flags_t flags {};
    │ │ │     std::vector<std::shared_ptr<plugin>> extensions;
    │ │ │     dht::dht_state dht_state;
    │ │ │     dht::dht_storage_constructor_type dht_storage_constructor;
    │ │ │     disk_io_constructor_type disk_io_constructor;
    │ │ │ @@ -126,18 +126,18 @@
    │ │ │  

    This constructor can be used to start with the default plugins │ │ │ (ut_metadata, ut_pex and smart_ban). Pass a settings_pack to set the │ │ │ initial settings when the session starts.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    session_params()

    │ │ │
    │ │ │ -session_params (settings_pack&& sp
    │ │ │ -      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │  session_params (settings_pack const& sp
    │ │ │        , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │ +session_params (settings_pack&& sp
    │ │ │ +      , std::vector<std::shared_ptr<plugin>> exts);
    │ │ │  
    │ │ │

    This constructor helps to configure the set of initial plugins │ │ │ to be added to the session before it's started.

    │ │ │ [report issue]
    │ │ │
    settings
    │ │ │
    The settings to configure the session with
    │ │ │
    │ │ │ @@ -197,32 +197,32 @@ │ │ │ synchronize the completion of the shutdown. The lifetime of this object │ │ │ may outlive session, causing the session destructor to not block. The │ │ │ session_proxy destructor will block however, until the underlying session │ │ │ is done shutting down.

    │ │ │
    │ │ │  struct session_proxy
    │ │ │  {
    │ │ │ -   session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ -   session_proxy ();
    │ │ │     session_proxy (session_proxy&&) noexcept;
    │ │ │ +   session_proxy ();
    │ │ │     session_proxy (session_proxy const&);
    │ │ │     session_proxy& operator= (session_proxy const&) &;
    │ │ │ +   session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │     ~session_proxy ();
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() ~session_proxy() session_proxy()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    operator=() session_proxy() ~session_proxy()

    │ │ │
    │ │ │ -session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ -session_proxy ();
    │ │ │  session_proxy (session_proxy&&) noexcept;
    │ │ │ +session_proxy ();
    │ │ │  session_proxy (session_proxy const&);
    │ │ │  session_proxy& operator= (session_proxy const&) &;
    │ │ │ +session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │  ~session_proxy ();
    │ │ │  
    │ │ │

    default constructor, does not refer to any session │ │ │ implementation object.

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │ @@ -237,29 +237,29 @@ │ │ │ session_handle::apply_settings() member function. To change one or more │ │ │ configuration options, create a settings_pack. object and fill it with │ │ │ the settings to be set and pass it in to session::apply_settings().

    │ │ │

    see apply_settings().

    │ │ │
    │ │ │  struct session : session_handle
    │ │ │  {
    │ │ │ -   explicit session (session_params&& params);
    │ │ │ -   explicit session (session_params const& params);
    │ │ │     session ();
    │ │ │ +   explicit session (session_params const& params);
    │ │ │ +   explicit session (session_params&& params);
    │ │ │     session (session_params&& params, io_context& ios);
    │ │ │     session (session_params const& params, io_context& ios);
    │ │ │     ~session ();
    │ │ │     session_proxy abort ();
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    session()

    │ │ │
    │ │ │ -explicit session (session_params&& params);
    │ │ │ -explicit session (session_params const& params);
    │ │ │  session ();
    │ │ │ +explicit session (session_params const& params);
    │ │ │ +explicit session (session_params&& params);
    │ │ │  
    │ │ │

    Constructs the session objects which acts as the container of torrents. │ │ │ In order to avoid a race condition between starting the session and │ │ │ configuring it, you can pass in a session_params object. Its settings │ │ │ will take effect before the session starts up.

    │ │ │ [report issue]
    │ │ │
    │ │ │ @@ -317,15 +317,15 @@ │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    session_handle

    │ │ │

    Declared in "libtorrent/session_handle.hpp"

    │ │ │

    this class provides a non-owning handle to a session and a subset of the │ │ │ interface of the session class. If the underlying session is destructed │ │ │ -any handle to it will no longer be valid. is_valid() will return false and │ │ │ +any handle to it will no longer be valid. is_valid() will return false and │ │ │ any operation on it will throw a system_error exception, with error code │ │ │ invalid_session_handle.

    │ │ │
    │ │ │  struct session_handle
    │ │ │  {
    │ │ │     bool is_valid () const;
    │ │ │     session_params session_state (save_state_flags_t flags = save_state_flags_t::all()) const;
    │ │ │ @@ -338,20 +338,20 @@
    │ │ │     void post_session_stats ();
    │ │ │     void post_dht_stats ();
    │ │ │     void set_dht_state (dht::dht_state&& st);
    │ │ │     void set_dht_state (dht::dht_state const& st);
    │ │ │     torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │     std::vector<torrent_handle> get_torrents () const;
    │ │ │     torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │ -   torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │     void async_add_torrent (add_torrent_params&& params);
    │ │ │ -   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │     torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │     torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │     void async_add_torrent (add_torrent_params const& params);
    │ │ │ +   torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │     void pause ();
    │ │ │     bool is_paused () const;
    │ │ │     void resume ();
    │ │ │     bool is_dht_running () const;
    │ │ │     void set_dht_storage (dht::dht_storage_constructor_type sc);
    │ │ │     void add_dht_node (std::pair<std::string, int> const& node);
    │ │ │     void dht_get_item (sha1_hash const& target);
    │ │ │ @@ -366,37 +366,37 @@
    │ │ │     void dht_get_peers (sha1_hash const& info_hash);
    │ │ │     void dht_live_nodes (sha1_hash const& nid);
    │ │ │     void dht_sample_infohashes (udp::endpoint const& ep, sha1_hash const& target);
    │ │ │     void dht_direct_request (udp::endpoint const& ep, entry const& e, client_data_t userdata = {});
    │ │ │     void add_extension (std::function<std::shared_ptr<torrent_plugin>(
    │ │ │        torrent_handle const&, client_data_t)> ext);
    │ │ │     void add_extension (std::shared_ptr<plugin> ext);
    │ │ │ -   void set_ip_filter (ip_filter f);
    │ │ │     ip_filter get_ip_filter () const;
    │ │ │ +   void set_ip_filter (ip_filter f);
    │ │ │     void set_port_filter (port_filter const& f);
    │ │ │ +   bool is_listening () const;
    │ │ │     unsigned short listen_port () const;
    │ │ │     unsigned short ssl_listen_port () const;
    │ │ │ -   bool is_listening () const;
    │ │ │ -   ip_filter get_peer_class_filter () const;
    │ │ │     void set_peer_class_filter (ip_filter const& f);
    │ │ │ -   peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │ +   ip_filter get_peer_class_filter () const;
    │ │ │     void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ +   peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │     peer_class_t create_peer_class (char const* name);
    │ │ │     void delete_peer_class (peer_class_t cid);
    │ │ │ -   peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │     void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ +   peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │     void remove_torrent (const torrent_handle&, remove_flags_t = {});
    │ │ │     settings_pack get_settings () const;
    │ │ │     void apply_settings (settings_pack&&);
    │ │ │     void apply_settings (settings_pack const&);
    │ │ │     void set_alert_notify (std::function<void()> const& fun);
    │ │ │ -   bool wait_for_alert (time_duration max_wait);
    │ │ │     void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ -   void delete_port_mapping (port_mapping_t handle);
    │ │ │ +   bool wait_for_alert (time_duration max_wait);
    │ │ │     std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ +   void delete_port_mapping (port_mapping_t handle);
    │ │ │     void reopen_network_sockets (reopen_network_flags_t options = reopen_map_ports);
    │ │ │     std::shared_ptr<aux::session_impl> native_handle () const;
    │ │ │  
    │ │ │     static inline constexpr save_state_flags_t save_settings  = 0_bit;
    │ │ │     static inline constexpr save_state_flags_t save_dht_state  = 2_bit;
    │ │ │     static inline constexpr save_state_flags_t save_extension_state  = 11_bit;
    │ │ │     static inline constexpr save_state_flags_t save_ip_filter  = 12_bit;
    │ │ │ @@ -515,42 +515,42 @@
    │ │ │  
    │ │ │  void set_dht_state (dht::dht_state&& st);
    │ │ │  void set_dht_state (dht::dht_state const& st);
    │ │ │  
    │ │ │

    set the DHT state for the session. This will be taken into account the │ │ │ next time the DHT is started, as if it had been passed in via the │ │ │ session_params on startup.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    find_torrent() get_torrents()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_torrents() find_torrent()

    │ │ │
    │ │ │  torrent_handle find_torrent (sha1_hash const& info_hash) const;
    │ │ │  std::vector<torrent_handle> get_torrents () const;
    │ │ │  torrent_handle find_torrent (sha256_hash const& info_hash) const;
    │ │ │  
    │ │ │

    find_torrent() looks for a torrent with the given info-hash. In │ │ │ case there is such a torrent in the session, a torrent_handle to that │ │ │ torrent is returned. In case the torrent cannot be found, an invalid │ │ │ torrent_handle is returned.

    │ │ │

    See torrent_handle::is_valid() to know if the torrent was found or │ │ │ not.

    │ │ │

    get_torrents() returns a vector of torrent_handles to all the │ │ │ torrents currently in the session.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_torrent() async_add_torrent()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    async_add_torrent() add_torrent()

    │ │ │
    │ │ │ -torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │  void async_add_torrent (add_torrent_params&& params);
    │ │ │ -torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │  torrent_handle add_torrent (add_torrent_params&& params);
    │ │ │ +torrent_handle add_torrent (add_torrent_params&& params, error_code& ec);
    │ │ │  torrent_handle add_torrent (add_torrent_params const& params);
    │ │ │  void async_add_torrent (add_torrent_params const& params);
    │ │ │ +torrent_handle add_torrent (add_torrent_params const& params, error_code& ec);
    │ │ │  
    │ │ │

    You add torrents through the add_torrent() function where you give an │ │ │ object with all the parameters. The add_torrent() overloads will block │ │ │ until the torrent has been added (or failed to be added) and returns │ │ │ an error code and a torrent_handle. In order to add torrents more │ │ │ efficiently, consider using async_add_torrent() which returns │ │ │ immediately, without waiting for the torrent to add. Notification of │ │ │ @@ -804,16 +804,16 @@ │ │ │ ses.add_extension(&lt::create_smart_ban_plugin); │ │ │ │ │ │ │ │ │ [report issue]

    │ │ │
    │ │ │

    get_ip_filter() set_ip_filter()

    │ │ │
    │ │ │ -void set_ip_filter (ip_filter f);
    │ │ │  ip_filter get_ip_filter () const;
    │ │ │ +void set_ip_filter (ip_filter f);
    │ │ │  
    │ │ │

    Sets a filter that will be used to reject and accept incoming as well │ │ │ as outgoing connections based on their originating ip address. The │ │ │ default filter will allow connections to any ip address. To build a │ │ │ set of rules for which addresses are accepted and not, see ip_filter.

    │ │ │

    Each time a peer is blocked because of the IP filter, a │ │ │ peer_blocked_alert is generated. get_ip_filter() Returns the │ │ │ @@ -824,39 +824,39 @@ │ │ │

    │ │ │  void set_port_filter (port_filter const& f);
    │ │ │  
    │ │ │

    apply port_filter f to incoming and outgoing peers. a port filter │ │ │ will reject making outgoing peer connections to certain remote ports. │ │ │ The main intention is to be able to avoid triggering certain │ │ │ anti-virus software by connecting to SMTP, FTP ports.

    │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    is_listening() ssl_listen_port() listen_port()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    listen_port() ssl_listen_port() is_listening()

    │ │ │
    │ │ │ +bool is_listening () const;
    │ │ │  unsigned short listen_port () const;
    │ │ │  unsigned short ssl_listen_port () const;
    │ │ │ -bool is_listening () const;
    │ │ │  
    │ │ │

    is_listening() will tell you whether or not the session has │ │ │ successfully opened a listening port. If it hasn't, this function will │ │ │ return false, and then you can set a new │ │ │ settings_pack::listen_interfaces to try another interface and port to │ │ │ bind to.

    │ │ │

    listen_port() returns the port we ended up listening on.

    │ │ │

    ssl_listen_port() returns the port used for incoming SSL │ │ │ connections, or 0 if no SSL listen port is open.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    get_peer_class_filter() set_peer_class_filter()

    │ │ │
    │ │ │ -ip_filter get_peer_class_filter () const;
    │ │ │  void set_peer_class_filter (ip_filter const& f);
    │ │ │ +ip_filter get_peer_class_filter () const;
    │ │ │  
    │ │ │

    Sets the peer class filter for this session. All new peer connections │ │ │ will take this into account and be added to the peer classes specified │ │ │ by this filter, based on the peer's IP address.

    │ │ │

    The ip-filter essentially maps an IP -> uint32. Each bit in that 32 │ │ │ bit integer represents a peer class. The least significant bit │ │ │ represents class 0, the next bit class 1 and so on.

    │ │ │ @@ -881,16 +881,16 @@ │ │ │

    The get_peer_class_filter() function returns the current filter.

    │ │ │

    For more information, see peer classes.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    get_peer_class_type_filter() set_peer_class_type_filter()

    │ │ │
    │ │ │ -peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │  void set_peer_class_type_filter (peer_class_type_filter const& f);
    │ │ │ +peer_class_type_filter get_peer_class_type_filter () const;
    │ │ │  
    │ │ │

    Sets and gets the peer class type filter. This is controls automatic │ │ │ peer class assignments to peers based on what kind of socket it is.

    │ │ │

    It does not only support assigning peer classes, it also supports │ │ │ removing peer classes based on socket type.

    │ │ │

    The order of these rules being applied are:

    │ │ │
      │ │ │ @@ -934,16 +934,16 @@ │ │ │ destructs.

      │ │ │

      For more information on peer classes, see peer classes.

      │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    get_peer_class() set_peer_class()

    │ │ │
    │ │ │ -peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │  void set_peer_class (peer_class_t cid, peer_class_info const& pci);
    │ │ │ +peer_class_info get_peer_class (peer_class_t cid) const;
    │ │ │  
    │ │ │

    These functions queries information from a peer class and updates the │ │ │ configuration of a peer class, respectively.

    │ │ │

    cid must refer to an existing peer class. If it does not, the │ │ │ return value of get_peer_class() is undefined.

    │ │ │

    set_peer_class() sets all the information in the │ │ │ peer_class_info object in the specified peer class. There is no │ │ │ @@ -996,22 +996,22 @@ │ │ │ void apply_settings (settings_pack&&); │ │ │ void apply_settings (settings_pack const&); │ │ │ │ │ │

    Applies the settings specified by the settings_pack s. This is an │ │ │ asynchronous operation that will return immediately and actually apply │ │ │ the settings to the main thread of libtorrent some time later.

    │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_alert_notify() wait_for_alert() pop_alerts()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_alert_notify() pop_alerts() wait_for_alert()

    │ │ │
    │ │ │  void set_alert_notify (std::function<void()> const& fun);
    │ │ │ -bool wait_for_alert (time_duration max_wait);
    │ │ │  void pop_alerts (std::vector<alert*>* alerts);
    │ │ │ +bool wait_for_alert (time_duration max_wait);
    │ │ │  
    │ │ │

    Alerts is the main mechanism for libtorrent to report errors and │ │ │ events. pop_alerts fills in the vector passed to it with pointers │ │ │ to new alerts. The session still owns these alerts and they will stay │ │ │ valid until the next time pop_alerts is called. You may not delete │ │ │ the alert objects.

    │ │ │

    It is safe to call pop_alerts from multiple different threads, as │ │ │ @@ -1059,21 +1059,21 @@ │ │ │ message to an HWND or some other main message pump. The actual │ │ │ retrieval of alerts should not be done in the callback. In fact, the │ │ │ callback should not block. It should not perform any expensive work. │ │ │ It really should just notify the main application thread.

    │ │ │

    The type of an alert is returned by the polymorphic function │ │ │ alert::type() but can also be queries from a concrete type via │ │ │ T::alert_type, as a static constant.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_port_mapping() delete_port_mapping()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    delete_port_mapping() add_port_mapping()

    │ │ │
    │ │ │ -void delete_port_mapping (port_mapping_t handle);
    │ │ │  std::vector<port_mapping_t> add_port_mapping (portmap_protocol t, int external_port, int local_port);
    │ │ │ +void delete_port_mapping (port_mapping_t handle);
    │ │ │  
    │ │ │

    add_port_mapping adds one or more port forwards on UPnP and/or NAT-PMP, │ │ │ whichever is enabled. A mapping is created for each listen socket │ │ │ in the session. The return values are all handles referring to the │ │ │ port mappings that were just created. Pass them to delete_port_mapping() │ │ │ to remove them.

    │ │ │ [report issue]
    │ │ │ @@ -1139,26 +1139,26 @@ │ │ │ [report issue]
    │ │ │
    reopen_map_ports
    │ │ │
    This option indicates if the ports are mapped using natpmp │ │ │ and upnp. If mapping was already made, they are deleted and added │ │ │ again. This only works if natpmp and/or upnp are configured to be │ │ │ enable.
    │ │ │
    │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │ │ │ │ -
    │ │ │ -

    write_session_params() write_session_params_buf() read_session_params()

    │ │ │ +
    │ │ │ +

    read_session_params() write_session_params() write_session_params_buf()

    │ │ │

    Declared in "libtorrent/session_params.hpp"

    │ │ │
    │ │ │ -entry write_session_params (session_params const& sp
    │ │ │ -   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  session_params read_session_params (bdecode_node const& e
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ +entry write_session_params (session_params const& sp
    │ │ │ +   , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  std::vector<char> write_session_params_buf (session_params const& sp
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  session_params read_session_params (span<char const> buf
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  
    │ │ │

    These functions serialize and de-serialize a session_params object to and │ │ │ from bencoded form. The session_params object is used to initialize a new │ │ │ ├── html2text {} │ │ │ │ @@ -3,30 +3,30 @@ │ │ │ │ VVeerrssiioonn:: 2.1.1 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ * _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ * _s_e_s_s_i_o_n │ │ │ │ o _s_e_s_s_i_o_n_(_) │ │ │ │ o _s_e_s_s_i_o_n_(_) │ │ │ │ o _~_s_e_s_s_i_o_n_(_) │ │ │ │ o _a_b_o_r_t_(_) │ │ │ │ * _s_e_s_s_i_o_n___h_a_n_d_l_e │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _s_e_s_s_i_o_n___s_t_a_t_e_(_) │ │ │ │ o _g_e_t___t_o_r_r_e_n_t___s_t_a_t_u_s_(_)_ _r_e_f_r_e_s_h___t_o_r_r_e_n_t___s_t_a_t_u_s_(_) │ │ │ │ o _p_o_s_t___t_o_r_r_e_n_t___u_p_d_a_t_e_s_(_) │ │ │ │ o _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) │ │ │ │ o _p_o_s_t___d_h_t___s_t_a_t_s_(_) │ │ │ │ o _s_e_t___d_h_t___s_t_a_t_e_(_) │ │ │ │ - o _f_i_n_d___t_o_r_r_e_n_t_(_)_ _g_e_t___t_o_r_r_e_n_t_s_(_) │ │ │ │ - o _a_d_d___t_o_r_r_e_n_t_(_)_ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ + o _g_e_t___t_o_r_r_e_n_t_s_(_)_ _f_i_n_d___t_o_r_r_e_n_t_(_) │ │ │ │ + o _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_)_ _a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ o _p_a_u_s_e_(_)_ _i_s___p_a_u_s_e_d_(_)_ _r_e_s_u_m_e_(_) │ │ │ │ o _i_s___d_h_t___r_u_n_n_i_n_g_(_) │ │ │ │ o _s_e_t___d_h_t___s_t_o_r_a_g_e_(_) │ │ │ │ o _a_d_d___d_h_t___n_o_d_e_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ @@ -34,41 +34,41 @@ │ │ │ │ o _d_h_t___g_e_t___p_e_e_r_s_(_)_ _d_h_t___a_n_n_o_u_n_c_e_(_) │ │ │ │ o _d_h_t___l_i_v_e___n_o_d_e_s_(_) │ │ │ │ o _d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s_(_) │ │ │ │ o _d_h_t___d_i_r_e_c_t___r_e_q_u_e_s_t_(_) │ │ │ │ o _a_d_d___e_x_t_e_n_s_i_o_n_(_) │ │ │ │ o _g_e_t___i_p___f_i_l_t_e_r_(_)_ _s_e_t___i_p___f_i_l_t_e_r_(_) │ │ │ │ o _s_e_t___p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ - o _i_s___l_i_s_t_e_n_i_n_g_(_)_ _s_s_l___l_i_s_t_e_n___p_o_r_t_(_)_ _l_i_s_t_e_n___p_o_r_t_(_) │ │ │ │ + o _l_i_s_t_e_n___p_o_r_t_(_)_ _s_s_l___l_i_s_t_e_n___p_o_r_t_(_)_ _i_s___l_i_s_t_e_n_i_n_g_(_) │ │ │ │ o _g_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_) │ │ │ │ o _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_) │ │ │ │ o _c_r_e_a_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ o _d_e_l_e_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ o _g_e_t___p_e_e_r___c_l_a_s_s_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) │ │ │ │ o _a_p_p_l_y___s_e_t_t_i_n_g_s_(_)_ _g_e_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ - o _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_)_ _p_o_p___a_l_e_r_t_s_(_) │ │ │ │ - o _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_)_ _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ + o _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_)_ _p_o_p___a_l_e_r_t_s_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_) │ │ │ │ + o _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_)_ _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ o _r_e_o_p_e_n___n_e_t_w_o_r_k___s_o_c_k_e_t_s_(_) │ │ │ │ o _n_a_t_i_v_e___h_a_n_d_l_e_(_) │ │ │ │ - * _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s___b_u_f_(_)_ _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ + * _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s___b_u_f_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ppaarraammss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ The _s_e_s_s_i_o_n___p_a_r_a_m_s is a parameters pack for configuring the _s_e_s_s_i_o_n before it's │ │ │ │ started. │ │ │ │ struct session_params │ │ │ │ { │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ + , std::vector> exts); │ │ │ │ │ │ │ │ settings_pack settings; │ │ │ │ session_flags_t ffllaaggss {}; │ │ │ │ std::vector> extensions; │ │ │ │ dht::dht_state dht_state; │ │ │ │ dht::dht_storage_constructor_type dht_storage_constructor; │ │ │ │ disk_io_constructor_type disk_io_constructor; │ │ │ │ @@ -81,18 +81,18 @@ │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ This constructor can be used to start with the default plugins (ut_metadata, │ │ │ │ ut_pex and smart_ban). Pass a _s_e_t_t_i_n_g_s___p_a_c_k to set the initial settings when │ │ │ │ the _s_e_s_s_i_o_n starts. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ , std::vector> exts); │ │ │ │ +sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ + , std::vector> exts); │ │ │ │ This constructor helps to configure the set of initial plugins to be added to │ │ │ │ the _s_e_s_s_i_o_n before it's started. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ settings │ │ │ │ The settings to configure the _s_e_s_s_i_o_n with │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ flags │ │ │ │ @@ -136,28 +136,28 @@ │ │ │ │ _s_e_s_s_i_o_n destruction is explicitly initiated, this holder is used to synchronize │ │ │ │ the completion of the shutdown. The lifetime of this object may outlive │ │ │ │ _s_e_s_s_i_o_n, causing the _s_e_s_s_i_o_n destructor to not block. The _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ destructor will block however, until the underlying _s_e_s_s_i_o_n is done shutting │ │ │ │ down. │ │ │ │ struct session_proxy │ │ │ │ { │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ - sseessssiioonn__pprrooxxyy (); │ │ │ │ sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ + sseessssiioonn__pprrooxxyy (); │ │ │ │ sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) ~~sseessssiioonn__pprrooxxyy(()) sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ -sseessssiioonn__pprrooxxyy (); │ │ │ │ +********** ooppeerraattoorr==(()) sseessssiioonn__pprrooxxyy(()) ~~sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ +sseessssiioonn__pprrooxxyy (); │ │ │ │ sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ +session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ default constructor, does not refer to any _s_e_s_s_i_o_n implementation object. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ The _s_e_s_s_i_o_n holds all state that spans multiple torrents. Among other things it │ │ │ │ runs the network loop and manages all torrents. Once it's created, the _s_e_s_s_i_o_n │ │ │ │ @@ -166,27 +166,27 @@ │ │ │ │ You have some control over _s_e_s_s_i_o_n configuration through the session_handle:: │ │ │ │ apply_settings() member function. To change one or more configuration options, │ │ │ │ create a _s_e_t_t_i_n_g_s___p_a_c_k. object and fill it with the settings to be set and pass │ │ │ │ it in to session::apply_settings(). │ │ │ │ see _a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ struct session : session_handle │ │ │ │ { │ │ │ │ - explicit sseessssiioonn (session_params&& params); │ │ │ │ - explicit sseessssiioonn (session_params const& params); │ │ │ │ sseessssiioonn (); │ │ │ │ + explicit sseessssiioonn (session_params const& params); │ │ │ │ + explicit sseessssiioonn (session_params&& params); │ │ │ │ sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ ~~sseessssiioonn (); │ │ │ │ session_proxy aabboorrtt (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn(()) ********** │ │ │ │ -explicit sseessssiioonn (session_params&& params); │ │ │ │ -explicit sseessssiioonn (session_params const& params); │ │ │ │ sseessssiioonn (); │ │ │ │ +explicit sseessssiioonn (session_params const& params); │ │ │ │ +explicit sseessssiioonn (session_params&& params); │ │ │ │ Constructs the _s_e_s_s_i_o_n objects which acts as the container of torrents. In │ │ │ │ order to avoid a race condition between starting the _s_e_s_s_i_o_n and configuring │ │ │ │ it, you can pass in a _s_e_s_s_i_o_n___p_a_r_a_m_s object. Its settings will take effect │ │ │ │ before the _s_e_s_s_i_o_n starts up. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn(()) ********** │ │ │ │ sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ @@ -247,21 +247,21 @@ │ │ │ │ void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state&& st); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ -ec); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ +ec); │ │ │ │ void ppaauussee (); │ │ │ │ bool iiss__ppaauusseedd () const; │ │ │ │ void rreessuummee (); │ │ │ │ bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ @@ -279,38 +279,38 @@ │ │ │ │ void ddhhtt__ssaammppllee__iinnffoohhaasshheess (udp::endpoint const& ep, sha1_hash const& │ │ │ │ target); │ │ │ │ void ddhhtt__ddiirreecctt__rreeqquueesstt (udp::endpoint const& ep, entry const& e, │ │ │ │ client_data_t userdata = {}); │ │ │ │ void aadddd__eexxtteennssiioonn (std::function( │ │ │ │ torrent_handle const&, client_data_t)> ext); │ │ │ │ void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ - void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ + void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ + bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ - bool iiss__lliisstteenniinngg () const; │ │ │ │ - ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ - peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ + ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ + peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ - peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ + peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ - bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ - void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ + bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ external_port, int local_port); │ │ │ │ + void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ reopen_map_ports); │ │ │ │ std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ │ │ │ │ static inline constexpr save_state_flags_t ssaavvee__sseettttiinnggss = 0_bit; │ │ │ │ static inline constexpr save_state_flags_t ssaavvee__ddhhtt__ssttaattee = 2_bit; │ │ │ │ static inline constexpr save_state_flags_t ssaavvee__eexxtteennssiioonn__ssttaattee = 11_bit; │ │ │ │ @@ -400,32 +400,32 @@ │ │ │ │ ********** sseett__ddhhtt__ssttaattee(()) ********** │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state&& st); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ set the DHT state for the _s_e_s_s_i_o_n. This will be taken into account the next │ │ │ │ time the DHT is started, as if it had been passed in via the _s_e_s_s_i_o_n___p_a_r_a_m_s on │ │ │ │ startup. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinndd__ttoorrrreenntt(()) ggeett__ttoorrrreennttss(()) ********** │ │ │ │ +********** ggeett__ttoorrrreennttss(()) ffiinndd__ttoorrrreenntt(()) ********** │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ find_torrent() looks for a torrent with the given info-hash. In case there is │ │ │ │ such a torrent in the _s_e_s_s_i_o_n, a _t_o_r_r_e_n_t___h_a_n_d_l_e to that torrent is returned. In │ │ │ │ case the torrent cannot be found, an invalid _t_o_r_r_e_n_t___h_a_n_d_l_e is returned. │ │ │ │ See torrent_handle::is_valid() to know if the torrent was found or not. │ │ │ │ get_torrents() returns a vector of torrent_handles to all the torrents │ │ │ │ currently in the _s_e_s_s_i_o_n. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ttoorrrreenntt(()) aassyynncc__aadddd__ttoorrrreenntt(()) ********** │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ +********** aassyynncc__aadddd__ttoorrrreenntt(()) aadddd__ttoorrrreenntt(()) ********** │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ You add torrents through the _a_d_d___t_o_r_r_e_n_t_(_) function where you give an object │ │ │ │ with all the parameters. The _a_d_d___t_o_r_r_e_n_t_(_) overloads will block until the │ │ │ │ torrent has been added (or failed to be added) and returns an error code and a │ │ │ │ _t_o_r_r_e_n_t___h_a_n_d_l_e. In order to add torrents more efficiently, consider using │ │ │ │ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) which returns immediately, without waiting for the torrent │ │ │ │ to add. Notification of the torrent being added is sent as _a_d_d___t_o_r_r_e_n_t___a_l_e_r_t. │ │ │ │ The save_path field in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s must be set to a valid path where the │ │ │ │ @@ -605,16 +605,16 @@ │ │ │ │ A _p_l_u_g_i_n that, with a small overhead, can ban peers that sends bad data │ │ │ │ with very high accuracy. Should eliminate most problems on poisoned │ │ │ │ torrents. │ │ │ │ #include │ │ │ │ ses.add_extension(<::create_smart_ban_plugin); │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__iipp__ffiilltteerr(()) sseett__iipp__ffiilltteerr(()) ********** │ │ │ │ -void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ +void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ Sets a filter that will be used to reject and accept incoming as well as │ │ │ │ outgoing connections based on their originating ip address. The default filter │ │ │ │ will allow connections to any ip address. To build a set of rules for which │ │ │ │ addresses are accepted and not, see _i_p___f_i_l_t_e_r. │ │ │ │ Each time a peer is blocked because of the IP filter, a _p_e_e_r___b_l_o_c_k_e_d___a_l_e_r_t is │ │ │ │ generated. get_ip_filter() Returns the _i_p___f_i_l_t_e_r currently in the _s_e_s_s_i_o_n. See │ │ │ │ _i_p___f_i_l_t_e_r. │ │ │ │ @@ -622,29 +622,29 @@ │ │ │ │ ********** sseett__ppoorrtt__ffiilltteerr(()) ********** │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ apply _p_o_r_t___f_i_l_t_e_r f to incoming and outgoing peers. a port filter will reject │ │ │ │ making outgoing peer connections to certain remote ports. The main intention is │ │ │ │ to be able to avoid triggering certain anti-virus software by connecting to │ │ │ │ SMTP, FTP ports. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iiss__lliisstteenniinngg(()) ssssll__lliisstteenn__ppoorrtt(()) lliisstteenn__ppoorrtt(()) ********** │ │ │ │ +********** lliisstteenn__ppoorrtt(()) ssssll__lliisstteenn__ppoorrtt(()) iiss__lliisstteenniinngg(()) ********** │ │ │ │ +bool iiss__lliisstteenniinngg () const; │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ -bool iiss__lliisstteenniinngg () const; │ │ │ │ is_listening() will tell you whether or not the _s_e_s_s_i_o_n has successfully opened │ │ │ │ a listening port. If it hasn't, this function will return false, and then you │ │ │ │ can set a new _s_e_t_t_i_n_g_s___p_a_c_k_:_:_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s to try another interface and │ │ │ │ port to bind to. │ │ │ │ listen_port() returns the port we ended up listening on. │ │ │ │ ssl_listen_port() returns the port used for incoming SSL connections, or 0 if │ │ │ │ no SSL listen port is open. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__ppeeeerr__ccllaassss__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ffiilltteerr(()) ********** │ │ │ │ -ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ +ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ Sets the peer class filter for this _s_e_s_s_i_o_n. All new peer connections will take │ │ │ │ this into account and be added to the peer classes specified by this filter, │ │ │ │ based on the peer's IP address. │ │ │ │ The ip-filter essentially maps an IP -> uint32. Each bit in that 32 bit integer │ │ │ │ represents a peer class. The least significant bit represents class 0, the next │ │ │ │ bit class 1 and so on. │ │ │ │ For more info, see _i_p___f_i_l_t_e_r. │ │ │ │ @@ -662,16 +662,16 @@ │ │ │ │ removed from a peer as a result of this call, peer classes are only added. │ │ │ │ The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ peer classes in the peer_class_filter are 32 bits. │ │ │ │ The get_peer_class_filter() function returns the current filter. │ │ │ │ For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ -peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ +peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ Sets and gets the ppeeeerr ccllaassss ttyyppee ffiilltteerr. This is controls automatic peer class │ │ │ │ assignments to peers based on what kind of socket it is. │ │ │ │ It does not only support assigning peer classes, it also supports removing peer │ │ │ │ classes based on socket type. │ │ │ │ The order of these rules being applied are: │ │ │ │ 1. peer-class IP filter │ │ │ │ 2. peer-class type filter, removing classes │ │ │ │ @@ -700,16 +700,16 @@ │ │ │ │ peer class if it's still assigned to torrents or peers. It will however remove │ │ │ │ it once the last peer and torrent drops their references to it. │ │ │ │ There is no need to call this function for custom peer classes. All peer │ │ │ │ classes will be properly destructed when the _s_e_s_s_i_o_n object destructs. │ │ │ │ For more information on peer classes, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__ppeeeerr__ccllaassss(()) sseett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ +peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ These functions queries information from a peer class and updates the │ │ │ │ configuration of a peer class, respectively. │ │ │ │ cid must refer to an existing peer class. If it does not, the return value of │ │ │ │ get_peer_class() is undefined. │ │ │ │ set_peer_class() sets all the information in the _p_e_e_r___c_l_a_s_s___i_n_f_o object in the │ │ │ │ specified peer class. There is no option to only update a single property. │ │ │ │ A peer or torrent belonging to more than one class, the highest priority among │ │ │ │ @@ -747,18 +747,18 @@ │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ Applies the settings specified by the _s_e_t_t_i_n_g_s___p_a_c_k s. This is an asynchronous │ │ │ │ operation that will return immediately and actually apply the settings to the │ │ │ │ main thread of libtorrent some time later. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__aalleerrtt__nnoottiiffyy(()) wwaaiitt__ffoorr__aalleerrtt(()) ppoopp__aalleerrttss(()) ********** │ │ │ │ +********** sseett__aalleerrtt__nnoottiiffyy(()) ppoopp__aalleerrttss(()) wwaaiitt__ffoorr__aalleerrtt(()) ********** │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ -bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ +bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ Alerts is the main mechanism for libtorrent to report errors and events. │ │ │ │ pop_alerts fills in the vector passed to it with pointers to new alerts. The │ │ │ │ _s_e_s_s_i_o_n still owns these alerts and they will stay valid until the next time │ │ │ │ pop_alerts is called. You may not delete the _a_l_e_r_t objects. │ │ │ │ It is safe to call pop_alerts from multiple different threads, as long as the │ │ │ │ alerts themselves are not accessed once another thread calls pop_alerts. Doing │ │ │ │ this requires manual synchronization between the popping threads. │ │ │ │ @@ -798,18 +798,18 @@ │ │ │ │ alerts should not be done in the callback. In fact, the callback should not │ │ │ │ block. It should not perform any expensive work. It really should just notify │ │ │ │ the main application thread. │ │ │ │ The type of an _a_l_e_r_t is returned by the polymorphic function alert::type() but │ │ │ │ can also be queries from a concrete type via T::alert_type, as a static │ │ │ │ constant. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ppoorrtt__mmaappppiinngg(()) ddeelleettee__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ -void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ +********** ddeelleettee__ppoorrtt__mmaappppiinngg(()) aadddd__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ external_port, int local_port); │ │ │ │ +void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ add_port_mapping adds one or more port forwards on UPnP and/or NAT-PMP, │ │ │ │ whichever is enabled. A mapping is created for each listen socket in the │ │ │ │ _s_e_s_s_i_o_n. The return values are all handles referring to the port mappings that │ │ │ │ were just created. Pass them to _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_) to remove them. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** rreeooppeenn__nneettwwoorrkk__ssoocckkeettss(()) ********** │ │ │ │ void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ @@ -855,21 +855,21 @@ │ │ │ │ protocols used by _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ reopen_map_ports │ │ │ │ This option indicates if the ports are mapped using natpmp and upnp. If │ │ │ │ mapping was already made, they are deleted and added again. This only │ │ │ │ works if natpmp and/or upnp are configured to be enable. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ wwrriittee__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) rreeaadd__sseessssiioonn__ppaarraammss(()) │ │ │ │ +************ rreeaadd__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) │ │ │ │ ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ -entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ - , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ +entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ + , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ std::vector wwrriittee__sseessssiioonn__ppaarraammss__bbuuff (session_params const& sp │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ session_params rreeaadd__sseessssiioonn__ppaarraammss (span buf │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ These functions serialize and de-serialize a session_params object to and from │ │ │ │ bencoded form. The _s_e_s_s_i_o_n___p_a_r_a_m_s object is used to initialize a new _s_e_s_s_i_o_n │ │ │ │ using the state from a previous one (or by programmatically configure the │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ @@ -29,35 +29,35 @@ │ │ │ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │

    You have some control over session configuration through the session::apply_settings() │ │ │ member function. To change one or more configuration options, create a settings_pack │ │ │ object and fill it with the settings to be set and pass it in to session::apply_settings().

    │ │ │

    The settings_pack object is a collection of settings updates that are applied │ │ │ to the session when passed to session::apply_settings(). It's empty when │ │ │ @@ -4885,16 +4885,16 @@ │ │ │ void set_int (int name, int val) override; │ │ │ void set_str (int name, std::string val) override; │ │ │ void set_bool (int name, bool val) override; │ │ │ bool has_val (int name) const override; │ │ │ void clear (); │ │ │ void clear (int name); │ │ │ int get_int (int name) const override; │ │ │ - std::string const& get_str (int name) const override; │ │ │ bool get_bool (int name) const override; │ │ │ + std::string const& get_str (int name) const override; │ │ │ │ │ │ enum type_bases │ │ │ { │ │ │ string_type_base, │ │ │ int_type_base, │ │ │ bool_type_base, │ │ │ type_mask, │ │ │ @@ -4963,18 +4963,18 @@ │ │ │ socks5, │ │ │ socks5_pw, │ │ │ http, │ │ │ http_pw, │ │ │ }; │ │ │ }; │ │ │ │ │ │ - │ │ │ │ │ │ -[report issue]

    │ │ │ -

    set_bool() set_int() set_str()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_int() set_str() set_bool()

    │ │ │
    │ │ │  void set_int (int name, int val) override;
    │ │ │  void set_str (int name, std::string val) override;
    │ │ │  void set_bool (int name, bool val) override;
    │ │ │  
    │ │ │

    set a configuration option in the settings_pack. name is one of │ │ │ the enum values from string_types, int_types or bool_types. They must │ │ │ @@ -4998,23 +4998,23 @@ │ │ │ [report issue]

    │ │ │
    │ │ │

    clear()

    │ │ │
    │ │ │  void clear (int name);
    │ │ │  
    │ │ │

    clear a specific setting from the pack

    │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_int() get_bool() get_str()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_str() get_int() get_bool()

    │ │ │
    │ │ │  int get_int (int name) const override;
    │ │ │ -std::string const& get_str (int name) const override;
    │ │ │  bool get_bool (int name) const override;
    │ │ │ +std::string const& get_str (int name) const override;
    │ │ │  
    │ │ │

    queries the current configuration option from the settings_pack. │ │ │ name is one of the enumeration values from string_types, int_types │ │ │ or bool_types. The enum value must match the type of the get_* │ │ │ function. If the specified setting field has not been set, the default │ │ │ value is returned.

    │ │ │ [report issue]
    │ │ │ @@ -5374,16 +5374,64 @@ │ │ │ http_pw │ │ │ 5 │ │ │ The server is assumed to be an HTTP proxy that requires user │ │ │ authorization. The username and password will be sent to the proxy. │ │ │ │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ + │ │ │ +[report issue]
    │ │ │
    │ │ │ +
    │ │ │ +

    setting_by_name() name_for_setting()

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +
    │ │ │ +char const* name_for_setting (int s);
    │ │ │ +int setting_by_name (string_view name);
    │ │ │ +
    │ │ │ +

    converts a setting integer (from the enums string_types, int_types or │ │ │ +bool_types) to a string, and vice versa.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    default_settings()

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +
    │ │ │ +settings_pack default_settings ();
    │ │ │ +
    │ │ │ +

    returns a settings_pack with every setting set to its default value

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    min_memory_usage() high_performance_seed()

    │ │ │ +

    Declared in "libtorrent/session.hpp"

    │ │ │ +
    │ │ │ +settings_pack high_performance_seed ();
    │ │ │ +settings_pack min_memory_usage ();
    │ │ │ +
    │ │ │ +

    The default values of the session settings are set for a regular │ │ │ +bittorrent client running on a desktop system. There are functions that │ │ │ +can set the session settings to pre set settings for other environments. │ │ │ +These can be used for the basis, and should be tweaked to fit your needs │ │ │ +better.

    │ │ │ +

    min_memory_usage returns settings that will use the minimal amount of │ │ │ +RAM, at the potential expense of upload and download performance. It │ │ │ +adjusts the socket buffer sizes, disables the disk cache, lowers the send │ │ │ +buffer watermarks so that each connection only has at most one block in │ │ │ +use at any one time. It lowers the outstanding blocks send to the disk │ │ │ +I/O thread so that connections only have one block waiting to be flushed │ │ │ +to disk at any given time. It lowers the max number of peers in the peer │ │ │ +list for torrents. It performs multiple smaller reads when it hashes │ │ │ +pieces, instead of reading it all into memory before hashing.

    │ │ │ +

    This configuration is intended to be the starting point for embedded │ │ │ +devices. It will significantly reduce memory usage.

    │ │ │ +

    high_performance_seed returns settings optimized for a seed box, │ │ │ +serving many peers and that doesn't do any downloading. It has a 128 MB │ │ │ +disk cache and has a limit of 400 files in its file pool. It support fast │ │ │ +upload rates by allowing large send buffers.

    │ │ │ +[report issue]
    │ │ │
    │ │ │

    generate_fingerprint()

    │ │ │

    Declared in "libtorrent/fingerprint.hpp"

    │ │ │
    │ │ │  std::string generate_fingerprint (std::string name
    │ │ │     , int major, int minor = 0, int revision = 0, int tag = 0);
    │ │ │  
    │ │ │ @@ -5432,62 +5480,14 @@ │ │ │ Tribler │ │ │ │ │ │ │ │ │ │ │ │

    There's an informal directory of client id's here.

    │ │ │

    The major, minor, revision and tag parameters are used to │ │ │ identify the version of your client.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    high_performance_seed() min_memory_usage()

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -
    │ │ │ -settings_pack high_performance_seed ();
    │ │ │ -settings_pack min_memory_usage ();
    │ │ │ -
    │ │ │ -

    The default values of the session settings are set for a regular │ │ │ -bittorrent client running on a desktop system. There are functions that │ │ │ -can set the session settings to pre set settings for other environments. │ │ │ -These can be used for the basis, and should be tweaked to fit your needs │ │ │ -better.

    │ │ │ -

    min_memory_usage returns settings that will use the minimal amount of │ │ │ -RAM, at the potential expense of upload and download performance. It │ │ │ -adjusts the socket buffer sizes, disables the disk cache, lowers the send │ │ │ -buffer watermarks so that each connection only has at most one block in │ │ │ -use at any one time. It lowers the outstanding blocks send to the disk │ │ │ -I/O thread so that connections only have one block waiting to be flushed │ │ │ -to disk at any given time. It lowers the max number of peers in the peer │ │ │ -list for torrents. It performs multiple smaller reads when it hashes │ │ │ -pieces, instead of reading it all into memory before hashing.

    │ │ │ -

    This configuration is intended to be the starting point for embedded │ │ │ -devices. It will significantly reduce memory usage.

    │ │ │ -

    high_performance_seed returns settings optimized for a seed box, │ │ │ -serving many peers and that doesn't do any downloading. It has a 128 MB │ │ │ -disk cache and has a limit of 400 files in its file pool. It support fast │ │ │ -upload rates by allowing large send buffers.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    setting_by_name() name_for_setting()

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ -
    │ │ │ -char const* name_for_setting (int s);
    │ │ │ -int setting_by_name (string_view name);
    │ │ │ -
    │ │ │ -

    converts a setting integer (from the enums string_types, int_types or │ │ │ -bool_types) to a string, and vice versa.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    default_settings()

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ -
    │ │ │ -settings_pack default_settings ();
    │ │ │ -
    │ │ │ -

    returns a settings_pack with every setting set to its default value

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │
    │ │ │ ..view.mo │ │ │ -0003e8e0: 6469 6679 2870 6965 6365 5f69 7465 722c dify(piece_iter, │ │ │ -0003e8f0: 205b 5d28 6361 6368 6564 5f70 6965 6365 [](cached_piece │ │ │ -0003e900: 5f65 6e74 7279 2661 6d70 3b20 6529 207b _entry& e) { │ │ │ -0003e910: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0003e920: 5428 2128 652e 666c 6167 7320 2661 6d70 T(!(e.flags & │ │ │ -0003e930: 3b20 6361 6368 6564 5f70 6965 6365 5f65 ; cached_piece_e │ │ │ -0003e940: 6e74 7279 3a3a 666c 7573 6869 6e67 5f66 ntry::flushing_f │ │ │ -0003e950: 6c61 6729 293b 0a09 0965 2e66 6c61 6773 lag));...e.flags │ │ │ -0003e960: 207c 3d20 6361 6368 6564 5f70 6965 6365 |= cached_piece │ │ │ -0003e970: 5f65 6e74 7279 3a3a 666c 7573 6869 6e67 _entry::flushing │ │ │ -0003e980: 5f66 6c61 673b 0a09 7d29 3b0a 0a09 2f2f _flag;..});...// │ │ │ -0003e990: 2053 6e61 7073 686f 7420 7468 6520 7065 Snapshot the pe │ │ │ -0003e9a0: 6e64 696e 6720 7772 6974 655f 6a6f 6220 nding write_job │ │ │ -0003e9b0: 706f 696e 7465 7220 666f 7220 6561 6368 pointer for each │ │ │ -0003e9c0: 2062 6c6f 636b 2077 6869 6c65 2077 6520 block while we │ │ │ -0003e9d0: 7374 696c 6c0a 092f 2f20 686f 6c64 2074 still..// hold t │ │ │ -0003e9e0: 6865 206d 7574 6578 2e20 666c 7573 6869 he mutex. flushi │ │ │ -0003e9f0: 6e67 5f66 6c61 6720 7072 6576 656e 7473 ng_flag prevents │ │ │ -0003ea00: 206f 7468 6572 2074 6872 6561 6473 2066 other threads f │ │ │ -0003ea10: 726f 6d20 666c 7573 6869 6e67 0a09 2f2f rom flushing..// │ │ │ -0003ea20: 2074 6869 7320 7069 6563 652c 2062 7574 this piece, but │ │ │ -0003ea30: 2064 6973 6b5f 6361 6368 653a 3a69 6e73 disk_cache::ins │ │ │ -0003ea40: 6572 7428 2920 6d61 7920 7374 696c 6c20 ert() may still │ │ │ -0003ea50: 706f 7075 6c61 7465 2070 7265 7669 6f75 populate previou │ │ │ -0003ea60: 736c 790a 092f 2f20 656d 7074 7920 7472 sly..// empty tr │ │ │ -0003ea70: 6169 6c69 6e67 2073 6c6f 7473 2028 696e ailing slots (in │ │ │ -0003ea80: 7365 7274 206f 6e6c 7920 7265 7175 6972 sert only requir │ │ │ -0003ea90: 6573 2062 6c6f 636b 5f69 6478 2026 6774 es block_idx > │ │ │ -0003eaa0: 3b3d 2068 6173 6865 725f 6375 7273 6f72 ;= hasher_cursor │ │ │ -0003eab0: 292e 0a09 2f2f 2052 6561 6469 6e67 2063 )...// Reading c │ │ │ -0003eac0: 6163 6865 645f 626c 6f63 6b5f 656e 7472 ached_block_entr │ │ │ -0003ead0: 793a 3a77 7269 7465 5f73 7461 7465 2066 y::write_state f │ │ │ -0003eae0: 726f 6d20 6f75 7473 6964 6520 7468 6520 rom outside the │ │ │ -0003eaf0: 6c6f 636b 2077 6f75 6c64 0a09 2f2f 2072 lock would..// r │ │ │ -0003eb00: 6163 6520 7769 7468 2074 6861 742e 204f ace with that. O │ │ │ -0003eb10: 6e63 6520 6120 736c 6f74 2068 6f6c 6473 nce a slot holds │ │ │ -0003eb20: 2061 2064 6973 6b5f 6a6f 6220 7468 6520 a disk_job the │ │ │ -0003eb30: 6e65 7477 6f72 6b20 7468 7265 6164 2077 network thread w │ │ │ -0003eb40: 6f6e 2774 0a09 2f2f 2074 6f75 6368 2069 on't..// touch i │ │ │ -0003eb50: 7420 286e 6f72 2074 6865 206a 6f62 2773 t (nor the job's │ │ │ -0003eb60: 2063 6f6e 7465 6e74 7329 2075 6e74 696c contents) until │ │ │ -0003eb70: 2074 6865 2064 6973 6b20 7468 7265 6164 the disk thread │ │ │ -0003eb80: 2074 616b 6573 2069 740a 092f 2f20 6261 takes it..// ba │ │ │ -0003eb90: 636b 2c20 736f 2074 6865 2073 6e61 7073 ck, so the snaps │ │ │ -0003eba0: 686f 7474 6564 2070 6f69 6e74 6572 7320 hotted pointers │ │ │ -0003ebb0: 616e 6420 7468 6520 6275 6666 6572 7320 and the buffers │ │ │ -0003ebc0: 7468 6579 2072 6566 6572 656e 6365 2073 they reference s │ │ │ -0003ebd0: 7461 790a 092f 2f20 7661 6c69 6420 666f tay..// valid fo │ │ │ -0003ebe0: 7220 7468 6520 656e 7469 7265 2075 6e6c r the entire unl │ │ │ -0003ebf0: 6f63 6b65 6420 7265 6769 6f6e 2062 656c ocked region bel │ │ │ -0003ec00: 6f77 2e0a 0954 4f52 5245 4e54 5f41 4c4c ow...TORRENT_ALL │ │ │ -0003ec10: 4f43 4128 736e 6170 7368 6f74 2c20 6469 OCA(snapshot, di │ │ │ -0003ec20: 736b 5f6a 6f62 2a2c 2062 6c6f 636b 732e sk_job*, blocks. │ │ │ -0003ec30: 7369 7a65 2829 293b 0a09 666f 7220 2869 size());..for (i │ │ │ -0003ec40: 6e74 2069 203d 2030 3b20 6920 266c 743b nt i = 0; i < │ │ │ -0003ec50: 2062 6c6f 636b 732e 7369 7a65 2829 3b20 blocks.size(); │ │ │ -0003ec60: 2b2b 6929 0a09 0973 6e61 7073 686f 745b ++i)...snapshot[ │ │ │ -0003ec70: 695d 203d 2062 6c6f 636b 735b 695d 2e67 i] = blocks[i].g │ │ │ -0003ec80: 6574 5f77 7269 7465 5f6a 6f62 2829 3b0a et_write_job();. │ │ │ -0003ec90: 0a09 2f2f 2077 6520 6861 7665 2074 6f20 ..// we have to │ │ │ -0003eca0: 7265 6c65 6173 6520 7468 6520 6c6f 636b release the lock │ │ │ -0003ecb0: 2077 6869 6c65 2066 6c75 7368 696e 672c while flushing, │ │ │ -0003ecc0: 2062 7574 2073 696e 6365 2077 6520 7365 but since we se │ │ │ -0003ecd0: 7420 7468 650a 092f 2f20 2266 6c75 7368 t the..// "flush │ │ │ -0003ece0: 696e 6722 206d 656d 6265 7220 746f 2074 ing" member to t │ │ │ -0003ecf0: 7275 652c 2074 6869 7320 7069 6563 6520 rue, this piece │ │ │ -0003ed00: 6973 2070 696e 6e65 6420 746f 2074 6865 is pinned to the │ │ │ -0003ed10: 2063 6163 6865 0a09 6c2e 756e 6c6f 636b cache..l.unlock │ │ │ -0003ed20: 2829 3b0a 0a09 696e 7420 636f 756e 7420 ();...int count │ │ │ -0003ed30: 3d20 303b 0a09 6269 7466 6965 6c64 2066 = 0;..bitfield f │ │ │ -0003ed40: 6c75 7368 6564 5f62 6c6f 636b 733b 0a09 lushed_blocks;.. │ │ │ -0003ed50: 7b0a 0909 6175 746f 2073 6520 3d20 7363 {...auto se = sc │ │ │ -0003ed60: 6f70 655f 656e 6428 5b26 616d 703b 5d20 ope_end([&] │ │ │ -0003ed70: 7b0a 0909 096c 2e6c 6f63 6b28 293b 0a09 {....l.lock();.. │ │ │ -0003ed80: 0909 626f 6f6c 206e 6f74 6966 7920 3d20 ..bool notify = │ │ │ -0003ed90: 6661 6c73 653b 0a09 0909 7669 6577 2e6d false;....view.m │ │ │ -0003eda0: 6f64 6966 7928 7069 6563 655f 6974 6572 odify(piece_iter │ │ │ -0003edb0: 2c20 5b26 616d 703b 6e6f 7469 6679 5d28 , [&notify]( │ │ │ -0003edc0: 6361 6368 6564 5f70 6965 6365 5f65 6e74 cached_piece_ent │ │ │ -0003edd0: 7279 2661 6d70 3b20 6529 207b 0a3c 2f70 ry& e) {.

    re │ │ │ -0003ee10: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/c │ │ │ -0003ee50: 7075 6964 2e63 7070 3a31 3134 3c2f 613e puid.cpp:114 │ │ │ -0003ee60: 3c2f 7464 3e3c 7464 3e65 6e61 626c 6520 enable │ │ │ -0003ee70: 7768 656e 2061 6172 6368 3634 2069 7320 when aarch64 is │ │ │ -0003ee80: 7265 616c 6c79 2074 6573 7465 643c 2f74 really tested

    enabl │ │ │ -0003eee0: 6520 7768 656e 2061 6172 6368 3634 2069 e when aarch64 i │ │ │ -0003eef0: 7320 7265 616c 6c79 2074 6573 7465 643c s really tested< │ │ │ -0003ef00: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f63 /h2>

    ../src/c │ │ │ -0003ef10: 7075 6964 2e63 7070 3a31 3134 3c2f 6834 puid.cpp:114

    .bool
    │ │ │ -0003ef60: 2073 7570 706f 7274 735f 6d6d 7828 2920   supports_mmx() 
    │ │ │ -0003ef70: 6e6f 6578 6365 7074 0a09 7b0a 2369 6620  noexcept..{.#if 
    │ │ │ -0003ef80: 544f 5252 454e 545f 4841 535f 5353 450a  TORRENT_HAS_SSE.
    │ │ │ -0003ef90: 0909 7374 643a 3a75 696e 7433 325f 7420  ..std::uint32_t 
    │ │ │ -0003efa0: 6370 7569 5b34 5d20 3d20 7b30 7d3b 0a09  cpui[4] = {0};..
    │ │ │ -0003efb0: 0963 7075 6964 2863 7075 692c 2031 293b  .cpuid(cpui, 1);
    │ │ │ -0003efc0: 0a09 0972 6574 7572 6e20 2863 7075 695b  ...return (cpui[
    │ │ │ -0003efd0: 325d 2026 616d 703b 2028 3120 266c 743b  2] & (1 <
    │ │ │ -0003efe0: 266c 743b 2032 3329 2920 213d 2030 3b0a  < 23)) != 0;.
    │ │ │ -0003eff0: 2365 6c73 650a 0909 7265 7475 726e 2066  #else...return f
    │ │ │ -0003f000: 616c 7365 3b0a 2365 6e64 6966 0a09 7d0a  alse;.#endif..}.
    │ │ │ -0003f010: 0a09 626f 6f6c 2073 7570 706f 7274 735f  ..bool supports_
    │ │ │ -0003f020: 6172 6d5f 6e65 6f6e 2829 206e 6f65 7863  arm_neon() noexc
    │ │ │ -0003f030: 6570 740a 097b 0a23 6966 2054 4f52 5245  ept..{.#if TORRE
    │ │ │ -0003f040: 4e54 5f48 4153 5f41 524d 5f4e 454f 4e20  NT_HAS_ARM_NEON 
    │ │ │ -0003f050: 2661 6d70 3b26 616d 703b 2054 4f52 5245  && TORRE
    │ │ │ -0003f060: 4e54 5f48 4153 5f41 5558 560a 2369 6620  NT_HAS_AUXV.#if 
    │ │ │ -0003f070: 6465 6669 6e65 6420 5f5f 6172 6d5f 5f0a  defined __arm__.
    │ │ │ -0003f080: 0909 2f2f 7265 7475 726e 2028 6765 7461  ..//return (geta
    │ │ │ -0003f090: 7578 7661 6c28 4154 5f48 5743 4150 2920  uxval(AT_HWCAP) 
    │ │ │ -0003f0a0: 2661 6d70 3b20 4857 4341 505f 4e45 4f4e  & HWCAP_NEON
    │ │ │ -0003f0b0: 293b 0a09 0972 6574 7572 6e20 2868 656c  );...return (hel
    │ │ │ -0003f0c0: 7065 725f 6765 7461 7578 7661 6c28 3136  per_getauxval(16
    │ │ │ -0003f0d0: 2920 2661 6d70 3b20 2831 2026 6c74 3b26  ) & (1 <&
    │ │ │ -0003f0e0: 6c74 3b20 3132 2929 3b0a 2365 6c69 6620  lt; 12));.#elif 
    │ │ │ -0003f0f0: 6465 6669 6e65 6420 5f5f 6161 7263 6836  defined __aarch6
    │ │ │ -0003f100: 345f 5f0a 0909 2f2f 7265 7475 726e 2028  4__...//return (
    │ │ │ -0003f110: 6765 7461 7578 7661 6c28 4154 5f48 5743  getauxval(AT_HWC
    │ │ │ -0003f120: 4150 2920 2661 6d70 3b20 4857 4341 505f  AP) & HWCAP_
    │ │ │ -0003f130: 4153 494d 4429 3b0a 0909 2f2f 7265 7475  ASIMD);...//retu
    │ │ │ -0003f140: 726e 2028 6765 7461 7578 7661 6c28 3136  rn (getauxval(16
    │ │ │ -0003f150: 2920 2661 6d70 3b20 2831 2026 6c74 3b26  ) & (1 <&
    │ │ │ -0003f160: 6c74 3b20 3129 293b 0a3c 6469 7620 7374  lt; 1));.
    ..return │ │ │ -0003f1a0: 6661 6c73 653b 0a3c 2f64 6976 3e23 656e false;.
    #en │ │ │ -0003f1b0: 6469 660a 2365 6c73 650a 0909 7265 7475 dif.#else...retu │ │ │ -0003f1c0: 726e 2066 616c 7365 3b0a 2365 6e64 6966 rn false;.#endif │ │ │ -0003f1d0: 0a09 7d0a 0a09 626f 6f6c 2073 7570 706f ..}...bool suppo │ │ │ -0003f1e0: 7274 735f 6172 6d5f 6372 6333 3263 2829 rts_arm_crc32c() │ │ │ -0003f1f0: 206e 6f65 7863 6570 740a 097b 0a23 6966 noexcept..{.#if │ │ │ -0003f200: 2054 4f52 5245 4e54 5f48 4153 5f41 524d TORRENT_HAS_ARM │ │ │ -0003f210: 5f43 5243 3332 2026 616d 703b 2661 6d70 _CRC32 && │ │ │ -0003f220: 3b20 544f 5252 454e 545f 4841 535f 4155 ; TORRENT_HAS_AU │ │ │ -0003f230: 5856 0a23 6966 2064 6566 696e 6564 2054 XV.#if defined T │ │ │ -0003f240: 4f52 5245 4e54 5f46 4f52 4345 5f41 524d ORRENT_FORCE_ARM │ │ │ -0003f250: 5f43 5243 3332 0a09 0972 6574 7572 6e20 _CRC32...return │ │ │ -0003f260: 7472 7565 3b0a 2365 6c69 6620 6465 6669 true;.#elif defi │ │ │ -0003f270: 6e65 6420 5f5f 6172 6d5f 5f0a 0909 2f2f ned __arm__...// │ │ │ -0003f280: 7265 7475 726e 2028 6765 7461 7578 7661 return (getauxva │ │ │ -0003f290: 6c28 4154 5f48 5743 4150 3229 2026 616d l(AT_HWCAP2) &am │ │ │ -0003f2a0: 703b 2048 5743 4150 325f 4352 4333 3229 p; HWCAP2_CRC32) │ │ │ -0003f2b0: 3b0a 0909 7265 7475 726e 2028 6865 6c70 ;...return (help │ │ │ -0003f2c0: 6572 5f67 6574 6175 7876 616c 2832 3629 er_getauxval(26) │ │ │ -0003f2d0: 2026 616d 703b 2028 3120 266c 743b 266c & (1 <&l │ │ │ -0003f2e0: 743b 2034 2929 3b0a 2365 6c69 6620 6465 t; 4));.#elif de │ │ │ -0003f2f0: 6669 6e65 6420 5f5f 6161 7263 6836 345f fined __aarch64_ │ │ │ -0003f300: 5f0a 0909 2f2f 7265 7475 726e 2028 6765 _...//return (ge │ │ │ -0003f310: 7461 7578 7661 6c28 4154 5f48 5743 4150 tauxval(AT_HWCAP │ │ │ -0003f320: 2920 2661 6d70 3b20 4857 4341 505f 4352 ) & HWCAP_CR │ │ │ -0003f330: 4333 3229 3b0a 0909 7265 7475 726e 2028 C32);...return ( │ │ │ -0003f340: 6865 6c70 6572 5f67 6574 6175 7876 616c helper_getauxval │ │ │ -0003f350: 2831 3629 2026 616d 703b 2028 3120 266c (16) & (1 &l │ │ │ -0003f360: 743b 266c 743b 2037 2929 3b0a 2365 6e64 t;< 7));.#end │ │ │ -0003f370: 6966 0a23 656c 7365 0a09 0972 6574 7572 if.#else...retur │ │ │ -0003f380: 6e20 6661 6c73 653b 0a23 656e 6469 660a n false;.#endif. │ │ │ -0003f390: 097d 0a0a 2369 6664 6566 205f 5f63 6c61 .}..#ifdef __cla │ │ │ -0003f3a0: 6e67 5f5f 0a23 7072 6167 6d61 2063 6c61 ng__.#pragma cla │ │ │ -0003f3b0: 6e67 2064 6961 676e 6f73 7469 6320 706f ng diagnostic po │ │ │ -0003f3c0: 700a 2365 6e64 6966 0a0a 7d20 2f2f 2061 p.#endif..} // a │ │ │ -0003f3d0: 6e6f 6e79 6d6f 7573 206e 616d 6573 7061 nonymous namespa │ │ │ -0003f3e0: 6365 0a0a 0962 6f6f 6c20 636f 6e73 7420 ce...bool const │ │ │ -0003f3f0: 7373 6534 325f 7375 7070 6f72 7420 3d20 sse42_support = │ │ │ -0003f400: 7375 7070 6f72 7473 5f73 7365 3432 2829 supports_sse42() │ │ │ -0003f410: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -0003f440: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0003f450: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0003f480: 7372 632f 7365 7474 696e 6773 5f70 6163 src/settings_pac │ │ │ -0003f490: 6b2e 6370 703a 3238 373c 2f61 3e3c 2f74 k.cpp:287deprecate │ │ │ -0003f4b0: 7468 6973 3c2f 7464 3e3c 2f74 723e 3c74 thisdeprecate this │ │ │ -0003f510: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0003f520: 7365 7474 696e 6773 5f70 6163 6b2e 6370 settings_pack.cp │ │ │ -0003f530: 703a 3238 373c 2f68 343e 3c70 7265 2073 p:287

    ..SET(outgoi
    │ │ │ -0003f580: 6e67 5f70 6f72 742c 2030 2c20 6e75 6c6c  ng_port, 0, null
    │ │ │ -0003f590: 7074 7229 2c0a 0909 5345 5428 6e75 6d5f  ptr),...SET(num_
    │ │ │ -0003f5a0: 6f75 7467 6f69 6e67 5f70 6f72 7473 2c20  outgoing_ports, 
    │ │ │ -0003f5b0: 302c 206e 756c 6c70 7472 292c 0a09 0953  0, nullptr),...S
    │ │ │ -0003f5c0: 4554 2870 6565 725f 6473 6370 2c20 3078  ET(peer_dscp, 0x
    │ │ │ -0003f5d0: 3031 2c20 2661 6d70 3b73 6573 7369 6f6e  01, &session
    │ │ │ -0003f5e0: 5f69 6d70 6c3a 3a75 7064 6174 655f 7065  _impl::update_pe
    │ │ │ -0003f5f0: 6572 5f64 7363 7029 2c0a 0909 5345 5428  er_dscp),...SET(
    │ │ │ -0003f600: 6163 7469 7665 5f64 6f77 6e6c 6f61 6473  active_downloads
    │ │ │ -0003f610: 2c20 332c 2026 616d 703b 7365 7373 696f  , 3, &sessio
    │ │ │ -0003f620: 6e5f 696d 706c 3a3a 7472 6967 6765 725f  n_impl::trigger_
    │ │ │ -0003f630: 6175 746f 5f6d 616e 6167 6529 2c0a 0909  auto_manage),...
    │ │ │ -0003f640: 5345 5428 6163 7469 7665 5f73 6565 6473  SET(active_seeds
    │ │ │ -0003f650: 2c20 352c 2026 616d 703b 7365 7373 696f  , 5, &sessio
    │ │ │ -0003f660: 6e5f 696d 706c 3a3a 7472 6967 6765 725f  n_impl::trigger_
    │ │ │ -0003f670: 6175 746f 5f6d 616e 6167 6529 2c0a 0909  auto_manage),...
    │ │ │ -0003f680: 5345 5428 6163 7469 7665 5f63 6865 636b  SET(active_check
    │ │ │ -0003f690: 696e 672c 2031 2c20 2661 6d70 3b73 6573  ing, 1, &ses
    │ │ │ -0003f6a0: 7369 6f6e 5f69 6d70 6c3a 3a74 7269 6767  sion_impl::trigg
    │ │ │ -0003f6b0: 6572 5f61 7574 6f5f 6d61 6e61 6765 292c  er_auto_manage),
    │ │ │ -0003f6c0: 0a09 0953 4554 2861 6374 6976 655f 6468  ...SET(active_dh
    │ │ │ -0003f6d0: 745f 6c69 6d69 742c 2038 382c 206e 756c  t_limit, 88, nul
    │ │ │ -0003f6e0: 6c70 7472 292c 0a09 0953 4554 2861 6374  lptr),...SET(act
    │ │ │ -0003f6f0: 6976 655f 7472 6163 6b65 725f 6c69 6d69  ive_tracker_limi
    │ │ │ -0003f700: 742c 2031 3630 302c 206e 756c 6c70 7472  t, 1600, nullptr
    │ │ │ -0003f710: 292c 0a09 0953 4554 2861 6374 6976 655f  ),...SET(active_
    │ │ │ -0003f720: 6c73 645f 6c69 6d69 742c 2036 302c 206e  lsd_limit, 60, n
    │ │ │ -0003f730: 756c 6c70 7472 292c 0a09 0953 4554 2861  ullptr),...SET(a
    │ │ │ -0003f740: 6374 6976 655f 6c69 6d69 742c 2035 3030  ctive_limit, 500
    │ │ │ -0003f750: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69  , &session_i
    │ │ │ -0003f760: 6d70 6c3a 3a74 7269 6767 6572 5f61 7574  mpl::trigger_aut
    │ │ │ -0003f770: 6f5f 6d61 6e61 6765 292c 0a09 0944 4550  o_manage),...DEP
    │ │ │ -0003f780: 5245 4341 5445 445f 5345 5428 6163 7469  RECATED_SET(acti
    │ │ │ -0003f790: 7665 5f6c 6f61 6465 645f 6c69 6d69 742c  ve_loaded_limit,
    │ │ │ -0003f7a0: 2030 2c20 2661 6d70 3b73 6573 7369 6f6e   0, &session
    │ │ │ -0003f7b0: 5f69 6d70 6c3a 3a74 7269 6767 6572 5f61  _impl::trigger_a
    │ │ │ -0003f7c0: 7574 6f5f 6d61 6e61 6765 292c 0a09 0953  uto_manage),...S
    │ │ │ -0003f7d0: 4554 2861 7574 6f5f 6d61 6e61 6765 5f69  ET(auto_manage_i
    │ │ │ -0003f7e0: 6e74 6572 7661 6c2c 2033 302c 206e 756c  nterval, 30, nul
    │ │ │ -0003f7f0: 6c70 7472 292c 0a09 0953 4554 2873 6565  lptr),...SET(see
    │ │ │ -0003f800: 645f 7469 6d65 5f6c 696d 6974 2c20 3234  d_time_limit, 24
    │ │ │ -0003f810: 202a 2036 3020 2a20 3630 2c20 6e75 6c6c   * 60 * 60, null
    │ │ │ -0003f820: 7074 7229 2c0a 0909 5345 5428 6175 746f  ptr),...SET(auto
    │ │ │ -0003f830: 5f73 6372 6170 655f 696e 7465 7276 616c  _scrape_interval
    │ │ │ -0003f840: 2c20 3138 3030 2c20 6e75 6c6c 7074 7229  , 1800, nullptr)
    │ │ │ -0003f850: 2c0a 0909 5345 5428 6175 746f 5f73 6372  ,...SET(auto_scr
    │ │ │ -0003f860: 6170 655f 6d69 6e5f 696e 7465 7276 616c  ape_min_interval
    │ │ │ -0003f870: 2c20 3330 302c 206e 756c 6c70 7472 292c  , 300, nullptr),
    │ │ │ -0003f880: 0a09 0953 4554 286d 6178 5f70 6565 726c  ...SET(max_peerl
    │ │ │ -0003f890: 6973 745f 7369 7a65 2c20 3330 3030 2c20  ist_size, 3000, 
    │ │ │ -0003f8a0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ -0003f8b0: 6d61 785f 7061 7573 6564 5f70 6565 726c  max_paused_peerl
    │ │ │ -0003f8c0: 6973 745f 7369 7a65 2c20 3130 3030 2c20  ist_size, 1000, 
    │ │ │ -0003f8d0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428  nullptr),...SET(
    │ │ │ -0003f8e0: 6d69 6e5f 616e 6e6f 756e 6365 5f69 6e74  min_announce_int
    │ │ │ -0003f8f0: 6572 7661 6c2c 2035 202a 2036 302c 206e  erval, 5 * 60, n
    │ │ │ -0003f900: 756c 6c70 7472 292c 0a09 0953 4554 2861  ullptr),...SET(a
    │ │ │ -0003f910: 7574 6f5f 6d61 6e61 6765 5f73 7461 7274  uto_manage_start
    │ │ │ -0003f920: 7570 2c20 3630 2c20 6e75 6c6c 7074 7229  up, 60, nullptr)
    │ │ │ -0003f930: 2c0a 0909 5345 5428 7365 6564 696e 675f  ,...SET(seeding_
    │ │ │ -0003f940: 7069 6563 655f 7175 6f74 612c 2032 302c  piece_quota, 20,
    │ │ │ -0003f950: 206e 756c 6c70 7472 292c 0a3c 6469 7620   nullptr),.
    ..SET(m │ │ │ -0003f990: 6178 5f72 656a 6563 7473 2c20 3530 2c20 ax_rejects, 50, │ │ │ -0003f9a0: 6e75 6c6c 7074 7229 2c0a 3c2f 6469 763e nullptr),.
    │ │ │ -0003f9b0: 0909 5345 5428 7265 6376 5f73 6f63 6b65 ..SET(recv_socke │ │ │ -0003f9c0: 745f 6275 6666 6572 5f73 697a 652c 2030 t_buffer_size, 0 │ │ │ -0003f9d0: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69 , &session_i │ │ │ -0003f9e0: 6d70 6c3a 3a75 7064 6174 655f 736f 636b mpl::update_sock │ │ │ -0003f9f0: 6574 5f62 7566 6665 725f 7369 7a65 292c et_buffer_size), │ │ │ -0003fa00: 0a09 0953 4554 2873 656e 645f 736f 636b ...SET(send_sock │ │ │ -0003fa10: 6574 5f62 7566 6665 725f 7369 7a65 2c20 et_buffer_size, │ │ │ -0003fa20: 302c 2026 616d 703b 7365 7373 696f 6e5f 0, &session_ │ │ │ -0003fa30: 696d 706c 3a3a 7570 6461 7465 5f73 6f63 impl::update_soc │ │ │ -0003fa40: 6b65 745f 6275 6666 6572 5f73 697a 6529 ket_buffer_size) │ │ │ -0003fa50: 2c0a 0909 5345 5428 6d61 785f 7065 6572 ,...SET(max_peer │ │ │ -0003fa60: 5f72 6563 765f 6275 6666 6572 5f73 697a _recv_buffer_siz │ │ │ -0003fa70: 652c 2032 202a 2031 3032 3420 2a20 3130 e, 2 * 1024 * 10 │ │ │ -0003fa80: 3234 2c20 6e75 6c6c 7074 7229 2c0a 0909 24, nullptr),... │ │ │ -0003fa90: 4445 5052 4543 4154 4544 5f53 4554 2866 DEPRECATED_SET(f │ │ │ -0003faa0: 696c 655f 6368 6563 6b73 5f64 656c 6179 ile_checks_delay │ │ │ -0003fab0: 5f70 6572 5f62 6c6f 636b 2c20 302c 206e _per_block, 0, n │ │ │ -0003fac0: 756c 6c70 7472 292c 0a09 0944 4550 5245 ullptr),...DEPRE │ │ │ -0003fad0: 4341 5445 4432 5f53 4554 2872 6561 645f CATED2_SET(read_ │ │ │ -0003fae0: 6361 6368 655f 6c69 6e65 5f73 697a 652c cache_line_size, │ │ │ -0003faf0: 2033 322c 206e 756c 6c70 7472 292c 0a09 32, nullptr),.. │ │ │ -0003fb00: 0944 4550 5245 4341 5445 4432 5f53 4554 .DEPRECATED2_SET │ │ │ -0003fb10: 2877 7269 7465 5f63 6163 6865 5f6c 696e (write_cache_lin │ │ │ -0003fb20: 655f 7369 7a65 2c20 3136 2c20 6e75 6c6c e_size, 16, null │ │ │ -0003fb30: 7074 7229 2c0a 0909 5345 5428 6f70 7469 ptr),...SET(opti │ │ │ -0003fb40: 6d69 7374 6963 5f64 6973 6b5f 7265 7472 mistic_disk_retr │ │ │ -0003fb50: 792c 2031 3020 2a20 3630 2c20 6e75 6c6c y, 10 * 60, null │ │ │ -0003fb60: 7074 7229 2c0a 0909 5345 5428 6d61 785f ptr),...SET(max_ │ │ │ -0003fb70: 7375 6767 6573 745f 7069 6563 6573 2c20 suggest_pieces, │ │ │ -0003fb80: 3136 2c20 6e75 6c6c 7074 7229 2c0a 0909 16, nullptr),... │ │ │ -0003fb90: 5345 5428 6c6f 6361 6c5f 7365 7276 6963 SET(local_servic │ │ │ -0003fba0: 655f 616e 6e6f 756e 6365 5f69 6e74 6572 e_announce_inter │ │ │ -0003fbb0: 7661 6c2c 2035 202a 2036 302c 206e 756c val, 5 * 60, nul │ │ │ -0003fbc0: 6c70 7472 292c 0a09 0953 4554 2864 6874 lptr),...SET(dht │ │ │ -0003fbd0: 5f61 6e6e 6f75 6e63 655f 696e 7465 7276 _announce_interv │ │ │ -0003fbe0: 616c 2c20 3135 202a 2036 302c 2026 616d al, 15 * 60, &am │ │ │ -0003fbf0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ -0003fc00: 7570 6461 7465 5f64 6874 5f61 6e6e 6f75 update_dht_annou │ │ │ -0003fc10: 6e63 655f 696e 7465 7276 616c 292c 0a09 nce_interval),.. │ │ │ -0003fc20: 0953 4554 2875 6470 5f74 7261 636b 6572 .SET(udp_tracker │ │ │ -0003fc30: 5f74 6f6b 656e 5f65 7870 6972 792c 2036 _token_expiry, 6 │ │ │ -0003fc40: 302c 206e 756c 6c70 7472 292c 0a09 0944 0, nullptr),...D │ │ │ -0003fc50: 4550 5245 4341 5445 445f 5345 5428 6465 EPRECATED_SET(de │ │ │ -0003fc60: 6661 756c 745f 6361 6368 655f 6d69 6e5f fault_cache_min_ │ │ │ -0003fc70: 6167 652c 2031 2c20 6e75 6c6c 7074 7229 age, 1, nullptr) │ │ │ -0003fc80: 2c0a 0909 5345 5428 6e75 6d5f 6f70 7469 ,...SET(num_opti │ │ │ -0003fc90: 6d69 7374 6963 5f75 6e63 686f 6b65 5f73 mistic_unchoke_s │ │ │ -0003fca0: 6c6f 7473 2c20 302c 206e 756c 6c70 7472 lots, 0, nullptr │ │ │ -0003fcb0: 292c 0a09 0944 4550 5245 4341 5445 445f ),...DEPRECATED_ │ │ │ -0003fcc0: 5345 5428 6465 6661 756c 745f 6573 745f SET(default_est_ │ │ │ -0003fcd0: 7265 6369 7072 6f63 6174 696f 6e5f 7261 reciprocation_ra │ │ │ -0003fce0: 7465 2c20 3136 3030 302c 206e 756c 6c70 te, 16000, nullp │ │ │ -0003fcf0: 7472 292c 0a09 0944 4550 5245 4341 5445 tr),...DEPRECATE │ │ │ -0003fd00: 445f 5345 5428 696e 6372 6561 7365 5f65 D_SET(increase_e │ │ │ -0003fd10: 7374 5f72 6563 6970 726f 6361 7469 6f6e st_reciprocation │ │ │ -0003fd20: 5f72 6174 652c 2032 302c 206e 756c 6c70 _rate, 20, nullp │ │ │ -0003fd30: 7472 292c 0a09 0944 4550 5245 4341 5445 tr),...DEPRECATE │ │ │ -0003fd40: 445f 5345 5428 6465 6372 6561 7365 5f65 D_SET(decrease_e │ │ │ -0003fd50: 7374 5f72 6563 6970 726f 6361 7469 6f6e st_reciprocation │ │ │ -0003fd60: 5f72 6174 652c 2033 2c20 6e75 6c6c 7074 _rate, 3, nullpt │ │ │ -0003fd70: 7229 2c0a 0909 5345 5428 6d61 785f 7065 r),...SET(max_pe │ │ │ -0003fd80: 785f 7065 6572 732c 2035 302c 206e 756c x_peers, 50, nul │ │ │ -0003fd90: 6c70 7472 292c 0a09 0953 4554 2874 6963 lptr),...SET(tic │ │ │ -0003fda0: 6b5f 696e 7465 7276 616c 2c20 3530 302c k_interval, 500, │ │ │ -0003fdb0: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ -0003fdc0: 2873 6861 7265 5f6d 6f64 655f 7461 7267 (share_mode_targ │ │ │ -0003fdd0: 6574 2c20 332c 206e 756c 6c70 7472 292c et, 3, nullptr), │ │ │ -0003fde0: 0a09 0953 4554 2875 706c 6f61 645f 7261 ...SET(upload_ra │ │ │ -0003fdf0: 7465 5f6c 696d 6974 2c20 302c 2026 616d te_limit, 0, &am │ │ │ -0003fe00: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ -0003fe10: 7570 6461 7465 5f75 706c 6f61 645f 7261 update_upload_ra │ │ │ -0003fe20: 7465 292c 0a09 0953 4554 2864 6f77 6e6c te),...SET(downl │ │ │ -0003fe30: 6f61 645f 7261 7465 5f6c 696d 6974 2c20 oad_rate_limit, │ │ │ -0003fe40: 302c 2026 616d 703b 7365 7373 696f 6e5f 0, &session_ │ │ │ -0003fe50: 696d 706c 3a3a 7570 6461 7465 5f64 6f77 impl::update_dow │ │ │ -0003fe60: 6e6c 6f61 645f 7261 7465 292c 0a09 0944 nload_rate),...D │ │ │ -0003fe70: 4550 5245 4341 5445 445f 5345 5428 6c6f EPRECATED_SET(lo │ │ │ -0003fe80: 6361 6c5f 7570 6c6f 6164 5f72 6174 655f cal_upload_rate_ │ │ │ -0003fe90: 6c69 6d69 742c 2030 2c20 2661 6d70 3b73 limit, 0, &s │ │ │ -0003fea0: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ -0003feb0: 6174 655f 6c6f 6361 6c5f 7570 6c6f 6164 ate_local_upload │ │ │ -0003fec0: 5f72 6174 6529 2c0a 0909 4445 5052 4543 _rate),...DEPREC │ │ │ -0003fed0: 4154 4544 5f53 4554 286c 6f63 616c 5f64 ATED_SET(local_d │ │ │ -0003fee0: 6f77 6e6c 6f61 645f 7261 7465 5f6c 696d ownload_rate_lim │ │ │ -0003fef0: 6974 2c20 302c 2026 616d 703b 7365 7373 it, 0, &sess │ │ │ -0003ff00: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ -0003ff10: 5f6c 6f63 616c 5f64 6f77 6e6c 6f61 645f _local_download_ │ │ │ -0003ff20: 7261 7465 292c 0a09 0953 4554 2864 6874 rate),...SET(dht │ │ │ -0003ff30: 5f75 706c 6f61 645f 7261 7465 5f6c 696d _upload_rate_lim │ │ │ -0003ff40: 6974 2c20 3830 3030 2c20 2661 6d70 3b73 it, 8000, &s │ │ │ -0003ff50: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ -0003ff60: 6174 655f 6468 745f 7570 6c6f 6164 5f72 ate_dht_upload_r │ │ │ -0003ff70: 6174 655f 6c69 6d69 7429 2c0a 0909 5345 ate_limit),...SE │ │ │ -0003ff80: 5428 756e 6368 6f6b 655f 736c 6f74 735f T(unchoke_slots_ │ │ │ -0003ff90: 6c69 6d69 742c 2038 2c20 2661 6d70 3b73 limit, 8, &s │ │ │ -0003ffa0: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ -0003ffb0: 6174 655f 756e 6368 6f6b 655f 6c69 6d69 ate_unchoke_limi │ │ │ -0003ffc0: 7429 2c0a 0909 4445 5052 4543 4154 4544 t),...DEPRECATED │ │ │ -0003ffd0: 5f53 4554 2868 616c 665f 6f70 656e 5f6c _SET(half_open_l │ │ │ -0003ffe0: 696d 6974 2c20 302c 206e 756c 6c70 7472 imit, 0, nullptr │ │ │ -0003fff0: 292c 0a09 0953 4554 2863 6f6e 6e65 6374 ),...SET(connect │ │ │ -00040000: 696f 6e73 5f6c 696d 6974 2c20 3230 302c ions_limit, 200, │ │ │ -00040010: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ -00040020: 706c 3a3a 7570 6461 7465 5f63 6f6e 6e65 pl::update_conne │ │ │ -00040030: 6374 696f 6e73 5f6c 696d 6974 292c 0a09 ctions_limit),.. │ │ │ -00040040: 0953 4554 2863 6f6e 6e65 6374 696f 6e73 .SET(connections │ │ │ -00040050: 5f73 6c61 636b 2c20 3130 2c20 6e75 6c6c _slack, 10, null │ │ │ -00040060: 7074 7229 2c0a 0909 5345 5428 7574 705f ptr),...SET(utp_ │ │ │ -00040070: 7461 7267 6574 5f64 656c 6179 2c20 3130 target_delay, 10 │ │ │ -00040080: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ -00040090: 4554 2875 7470 5f67 6169 6e5f 6661 6374 ET(utp_gain_fact │ │ │ -000400a0: 6f72 2c20 3330 3030 2c20 6e75 6c6c 7074 or, 3000, nullpt │ │ │ -000400b0: 7229 2c0a 3c2f 7072 653e 3c2f 7464 3e3c r),.
    < │ │ │ -000400c0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -000400f0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00040120: 2e2f 7372 632f 7365 7474 696e 6773 5f70 ./src/settings_p │ │ │ -00040130: 6163 6b2e 6370 703a 3537 373c 2f61 3e3c ack.cpp:577< │ │ │ -00040140: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ -00040150: 2062 6520 6e69 6365 2074 6f20 7265 7365 be nice to rese │ │ │ -00040160: 7276 6528 2920 7468 6573 6520 7665 6374 rve() these vect │ │ │ -00040170: 6f72 7320 7570 2066 726f 6e74 3c2f 7464 ors up front

    it wou │ │ │ -000401d0: 6c64 2062 6520 6e69 6365 2074 6f20 7265 ld be nice to re │ │ │ -000401e0: 7365 7276 6528 2920 7468 6573 6520 7665 serve() these ve │ │ │ -000401f0: 6374 6f72 7320 7570 2066 726f 6e74 3c2f ctors up front

    ../src/se │ │ │ -00040210: 7474 696e 6773 5f70 6163 6b2e 6370 703a ttings_pack.cpp: │ │ │ -00040220: 3537 373c 2f68 343e 3c70 7265 2073 7479 577

    ...s.set_str(s
    │ │ │ -00040270: 6574 7469 6e67 735f 7061 636b 3a3a 7374  ettings_pack::st
    │ │ │ -00040280: 7269 6e67 5f74 7970 655f 6261 7365 207c  ring_type_base |
    │ │ │ -00040290: 2069 2c20 7374 725f 7365 7474 696e 6773   i, str_settings
    │ │ │ -000402a0: 5b69 5d2e 6465 6661 756c 745f 7661 6c75  [i].default_valu
    │ │ │ -000402b0: 6529 3b0a 0909 0954 4f52 5245 4e54 5f41  e);....TORRENT_A
    │ │ │ -000402c0: 5353 4552 5428 732e 6765 745f 7374 7228  SSERT(s.get_str(
    │ │ │ -000402d0: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ -000402e0: 7472 696e 675f 7479 7065 5f62 6173 6520  tring_type_base 
    │ │ │ -000402f0: 2b20 6929 203d 3d20 7374 725f 7365 7474  + i) == str_sett
    │ │ │ -00040300: 696e 6773 5b69 5d2e 6465 6661 756c 745f  ings[i].default_
    │ │ │ -00040310: 7661 6c75 6529 3b0a 0909 7d0a 0a09 0966  value);...}....f
    │ │ │ -00040320: 6f72 2028 696e 7420 6920 3d20 303b 2069  or (int i = 0; i
    │ │ │ -00040330: 2026 6c74 3b20 7365 7474 696e 6773 5f70   < settings_p
    │ │ │ -00040340: 6163 6b3a 3a6e 756d 5f69 6e74 5f73 6574  ack::num_int_set
    │ │ │ -00040350: 7469 6e67 733b 202b 2b69 290a 0909 7b0a  tings; ++i)...{.
    │ │ │ -00040360: 0909 0973 2e73 6574 5f69 6e74 2873 6574  ...s.set_int(set
    │ │ │ -00040370: 7469 6e67 735f 7061 636b 3a3a 696e 745f  tings_pack::int_
    │ │ │ -00040380: 7479 7065 5f62 6173 6520 7c20 692c 2069  type_base | i, i
    │ │ │ -00040390: 6e74 5f73 6574 7469 6e67 735b 695d 2e64  nt_settings[i].d
    │ │ │ -000403a0: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ -000403b0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -000403c0: 2873 2e67 6574 5f69 6e74 2873 6574 7469  (s.get_int(setti
    │ │ │ -000403d0: 6e67 735f 7061 636b 3a3a 696e 745f 7479  ngs_pack::int_ty
    │ │ │ -000403e0: 7065 5f62 6173 6520 2b20 6929 203d 3d20  pe_base + i) == 
    │ │ │ -000403f0: 696e 745f 7365 7474 696e 6773 5b69 5d2e  int_settings[i].
    │ │ │ -00040400: 6465 6661 756c 745f 7661 6c75 6529 3b0a  default_value);.
    │ │ │ -00040410: 0909 7d0a 0a09 0966 6f72 2028 696e 7420  ..}....for (int 
    │ │ │ -00040420: 6920 3d20 303b 2069 2026 6c74 3b20 7365  i = 0; i < se
    │ │ │ -00040430: 7474 696e 6773 5f70 6163 6b3a 3a6e 756d  ttings_pack::num
    │ │ │ -00040440: 5f62 6f6f 6c5f 7365 7474 696e 6773 3b20  _bool_settings; 
    │ │ │ -00040450: 2b2b 6929 0a09 097b 0a09 0909 732e 7365  ++i)...{....s.se
    │ │ │ -00040460: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00040470: 7061 636b 3a3a 626f 6f6c 5f74 7970 655f  pack::bool_type_
    │ │ │ -00040480: 6261 7365 207c 2069 2c20 626f 6f6c 5f73  base | i, bool_s
    │ │ │ -00040490: 6574 7469 6e67 735b 695d 2e64 6566 6175  ettings[i].defau
    │ │ │ -000404a0: 6c74 5f76 616c 7565 293b 0a09 0909 544f  lt_value);....TO
    │ │ │ -000404b0: 5252 454e 545f 4153 5345 5254 2873 2e67  RRENT_ASSERT(s.g
    │ │ │ -000404c0: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ -000404d0: 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 7065  _pack::bool_type
    │ │ │ -000404e0: 5f62 6173 6520 2b20 6929 203d 3d20 626f  _base + i) == bo
    │ │ │ -000404f0: 6f6c 5f73 6574 7469 6e67 735b 695d 2e64  ol_settings[i].d
    │ │ │ -00040500: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ -00040510: 097d 0a09 7d0a 0a09 7365 7474 696e 6773  .}..}...settings
    │ │ │ -00040520: 5f70 6163 6b20 6465 6661 756c 745f 7365  _pack default_se
    │ │ │ -00040530: 7474 696e 6773 2829 0a09 7b0a 0909 7365  ttings()..{...se
    │ │ │ -00040540: 7474 696e 6773 5f70 6163 6b20 7265 743b  ttings_pack ret;
    │ │ │ -00040550: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00040580: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ -00040590: 2069 2026 6c74 3b20 7365 7474 696e 6773 i < settings │ │ │ -000405a0: 5f70 6163 6b3a 3a6e 756d 5f73 7472 696e _pack::num_strin │ │ │ -000405b0: 675f 7365 7474 696e 6773 3b20 2b2b 6929 g_settings; ++i) │ │ │ -000405c0: 0a3c 2f64 6976 3e09 097b 0a09 0909 6966 .
    ..{....if │ │ │ -000405d0: 2028 7374 725f 7365 7474 696e 6773 5b69 (str_settings[i │ │ │ -000405e0: 5d2e 6465 6661 756c 745f 7661 6c75 652e ].default_value. │ │ │ -000405f0: 656d 7074 7928 2929 2063 6f6e 7469 6e75 empty()) continu │ │ │ -00040600: 653b 0a09 0909 7265 742e 7365 745f 7374 e;....ret.set_st │ │ │ -00040610: 7228 7365 7474 696e 6773 5f70 6163 6b3a r(settings_pack: │ │ │ -00040620: 3a73 7472 696e 675f 7479 7065 5f62 6173 :string_type_bas │ │ │ -00040630: 6520 2b20 692c 2073 7472 5f73 6574 7469 e + i, str_setti │ │ │ -00040640: 6e67 735b 695d 2e64 6566 6175 6c74 5f76 ngs[i].default_v │ │ │ -00040650: 616c 7565 293b 0a09 097d 0a0a 0909 666f alue);...}....fo │ │ │ -00040660: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ -00040670: 266c 743b 2073 6574 7469 6e67 735f 7061 < settings_pa │ │ │ -00040680: 636b 3a3a 6e75 6d5f 696e 745f 7365 7474 ck::num_int_sett │ │ │ -00040690: 696e 6773 3b20 2b2b 6929 0a09 097b 0a09 ings; ++i)...{.. │ │ │ -000406a0: 0909 7265 742e 7365 745f 696e 7428 7365 ..ret.set_int(se │ │ │ -000406b0: 7474 696e 6773 5f70 6163 6b3a 3a69 6e74 ttings_pack::int │ │ │ -000406c0: 5f74 7970 655f 6261 7365 202b 2069 2c20 _type_base + i, │ │ │ -000406d0: 696e 745f 7365 7474 696e 6773 5b69 5d2e int_settings[i]. │ │ │ -000406e0: 6465 6661 756c 745f 7661 6c75 6529 3b0a default_value);. │ │ │ -000406f0: 0909 7d0a 0a09 0966 6f72 2028 696e 7420 ..}....for (int │ │ │ -00040700: 6920 3d20 303b 2069 2026 6c74 3b20 7365 i = 0; i < se │ │ │ -00040710: 7474 696e 6773 5f70 6163 6b3a 3a6e 756d ttings_pack::num │ │ │ -00040720: 5f62 6f6f 6c5f 7365 7474 696e 6773 3b20 _bool_settings; │ │ │ -00040730: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ -00040740: 7365 745f 626f 6f6c 2873 6574 7469 6e67 set_bool(setting │ │ │ -00040750: 735f 7061 636b 3a3a 626f 6f6c 5f74 7970 s_pack::bool_typ │ │ │ -00040760: 655f 6261 7365 202b 2069 2c20 626f 6f6c e_base + i, bool │ │ │ -00040770: 5f73 6574 7469 6e67 735b 695d 2e64 6566 _settings[i].def │ │ │ -00040780: 6175 6c74 5f76 616c 7565 293b 0a09 097d ault_value);...} │ │ │ -00040790: 0a09 0972 6574 7572 6e20 7265 743b 0a09 ...return ret;.. │ │ │ -000407a0: 7d0a 0a09 766f 6964 2061 7070 6c79 5f70 }...void apply_p │ │ │ -000407b0: 6163 6b28 7365 7474 696e 6773 5f70 6163 ack(settings_pac │ │ │ -000407c0: 6b20 636f 6e73 742a 2070 6163 6b2c 2061 k const* pack, a │ │ │ -000407d0: 7578 3a3a 7365 7373 696f 6e5f 7365 7474 ux::session_sett │ │ │ -000407e0: 696e 6773 2661 6d70 3b20 7365 7474 0a09 ings& sett.. │ │ │ -000407f0: 092c 2061 7578 3a3a 7365 7373 696f 6e5f ., aux::session_ │ │ │ -00040800: 696d 706c 2a20 7365 7329 0a09 7b0a 0909 impl* ses)..{... │ │ │ -00040810: 7573 696e 6720 6675 6e5f 7420 3d20 766f using fun_t = vo │ │ │ -00040820: 6964 2028 6175 783a 3a73 6573 7369 6f6e id (aux::session │ │ │ -00040830: 5f69 6d70 6c3a 3a2a 2928 293b 0a09 0973 _impl::*)();...s │ │ │ -00040840: 7464 3a3a 7665 6374 6f72 266c 743b 6675 td::vector<fu │ │ │ -00040850: 6e5f 7426 6774 3b20 6361 6c6c 6261 636b n_t> callback │ │ │ -00040860: 733b 0a0a 0909 7365 7474 2e62 756c 6b5f s;....sett.bulk_ │ │ │ -00040870: 7365 7428 5b26 616d 703b 5d28 6175 783a set([&](aux: │ │ │ -00040880: 3a73 6573 7369 6f6e 5f73 6574 7469 6e67 :session_setting │ │ │ -00040890: 735f 7369 6e67 6c65 5f74 6872 6561 6426 s_single_thread& │ │ │ -000408a0: 616d 703b 2073 290a 0909 7b0a 0909 0961 amp; s)...{....a │ │ │ -000408b0: 7070 6c79 5f70 6163 6b5f 696d 706c 2870 pply_pack_impl(p │ │ │ -000408c0: 6163 6b2c 2073 2c20 7365 7320 3f20 2661 ack, s, ses ? &a │ │ │ -000408d0: 6d70 3b63 616c 6c62 6163 6b73 203a 206e mp;callbacks : n │ │ │ -000408e0: 756c 6c70 7472 293b 0a09 097d 293b 0a0a ullptr);...});.. │ │ │ -000408f0: 0909 2f2f 2063 616c 6c20 7468 6520 6361 ..// call the ca │ │ │ -00040900: 6c6c 6261 636b 7320 6f6e 6365 2061 6c6c llbacks once all │ │ │ -00040910: 2074 6865 2073 6574 7469 6e67 7320 6861 the settings ha │ │ │ -00040920: 7665 2062 6565 6e20 6170 706c 6965 642c ve been applied, │ │ │ -00040930: 2061 6e64 0a09 092f 2f20 6f6e 6c79 206f and...// only o │ │ │ -00040940: 6e63 6520 7065 7220 6361 6c6c 6261 636b nce per callback │ │ │ -00040950: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00040990: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -000409c0: 7263 2f77 6562 5f63 6f6e 6e65 6374 696f rc/web_connectio │ │ │ -000409d0: 6e5f 6261 7365 2e63 7070 3a35 303c 2f61 n_base.cpp:50introd │ │ │ -000409f0: 7563 6520 6120 7765 622d 7365 6564 2064 uce a web-seed d │ │ │ -00040a00: 6566 6175 6c74 2063 6c61 7373 2077 6869 efault class whi │ │ │ -00040a10: 6368 2068 6173 2061 206c 6f77 2064 6f77 ch has a low dow │ │ │ -00040a20: 6e6c 6f61 6420 7072 696f 7269 7479 3c2f nload priority

    intr │ │ │ -00040a80: 6f64 7563 6520 6120 7765 622d 7365 6564 oduce a web-seed │ │ │ -00040a90: 2064 6566 6175 6c74 2063 6c61 7373 2077 default class w │ │ │ -00040aa0: 6869 6368 2068 6173 2061 206c 6f77 2064 hich has a low d │ │ │ -00040ab0: 6f77 6e6c 6f61 6420 7072 696f 7269 7479 ownload priority │ │ │ -00040ac0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00040ad0: 7765 625f 636f 6e6e 6563 7469 6f6e 5f62 web_connection_b │ │ │ -00040ae0: 6173 652e 6370 703a 3530 3c2f 6834 3e3c ase.cpp:50

    < │ │ │ -00040af0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00040b00: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00040b10: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00040b20: 7820 2364 6464 3b22 3e09 093a 2070 6565 x #ddd;">..: pee │ │ │ -00040b30: 725f 636f 6e6e 6563 7469 6f6e 2870 6163 r_connection(pac │ │ │ -00040b40: 6b29 0a09 092c 206d 5f66 6972 7374 5f72 k)..., m_first_r │ │ │ -00040b50: 6571 7565 7374 2874 7275 6529 0a09 092c equest(true)..., │ │ │ -00040b60: 206d 5f73 736c 2866 616c 7365 290a 0909 m_ssl(false)... │ │ │ -00040b70: 2c20 6d5f 6578 7465 726e 616c 5f61 7574 , m_external_aut │ │ │ -00040b80: 6828 7765 622e 6175 7468 290a 0909 2c20 h(web.auth)..., │ │ │ -00040b90: 6d5f 6578 7472 615f 6865 6164 6572 7328 m_extra_headers( │ │ │ -00040ba0: 7765 622e 6578 7472 615f 6865 6164 6572 web.extra_header │ │ │ -00040bb0: 7329 0a09 092c 206d 5f70 6172 7365 7228 s)..., m_parser( │ │ │ -00040bc0: 6175 783a 3a68 7474 705f 7061 7273 6572 aux::http_parser │ │ │ -00040bd0: 3a3a 646f 6e74 5f70 6172 7365 5f63 6875 ::dont_parse_chu │ │ │ -00040be0: 6e6b 7329 0a09 092c 206d 5f62 6f64 795f nks)..., m_body_ │ │ │ -00040bf0: 7374 6172 7428 3029 0a09 7b0a 0909 544f start(0)..{...TO │ │ │ -00040c00: 5252 454e 545f 4153 5345 5254 2826 616d RRENT_ASSERT(&am │ │ │ -00040c10: 703b 7765 622e 7065 6572 5f69 6e66 6f20 p;web.peer_info │ │ │ -00040c20: 3d3d 2070 6163 6b2e 7065 6572 696e 666f == pack.peerinfo │ │ │ -00040c30: 293b 0a09 092f 2f20 7768 656e 2067 6f69 );...// when goi │ │ │ -00040c40: 6e67 2074 6872 6f75 6768 2061 2070 726f ng through a pro │ │ │ -00040c50: 7879 2c20 7765 2064 6f6e 2774 206e 6563 xy, we don't nec │ │ │ -00040c60: 6573 7361 7269 6c79 2068 6176 6520 616e essarily have an │ │ │ -00040c70: 2065 6e64 706f 696e 7420 6865 7265 2c0a endpoint here,. │ │ │ -00040c80: 0909 2f2f 2073 696e 6365 2074 6865 2070 ..// since the p │ │ │ -00040c90: 726f 7879 206d 6967 6874 2062 6520 7265 roxy might be re │ │ │ -00040ca0: 736f 6c76 696e 6720 7468 6520 686f 7374 solving the host │ │ │ -00040cb0: 6e61 6d65 2c20 6e6f 7420 7573 0a09 0954 name, not us...T │ │ │ -00040cc0: 4f52 5245 4e54 5f41 5353 4552 5428 7765 ORRENT_ASSERT(we │ │ │ -00040cd0: 622e 656e 6470 6f69 6e74 732e 656d 7074 b.endpoints.empt │ │ │ -00040ce0: 7928 2920 7c7c 2077 6562 2e65 6e64 706f y() || web.endpo │ │ │ -00040cf0: 696e 7473 2e66 726f 6e74 2829 203d 3d20 ints.front() == │ │ │ -00040d00: 7061 636b 2e65 6e64 7029 3b0a 0a09 0949 pack.endp);....I │ │ │ -00040d10: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a NVARIANT_CHECK;. │ │ │ -00040d20: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00040d30: 5428 6973 5f6f 7574 676f 696e 6728 2929 T(is_outgoing()) │ │ │ -00040d40: 3b0a 0a09 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ -00040d50: 4552 5428 216d 5f74 6f72 7265 6e74 2e6c ERT(!m_torrent.l │ │ │ -00040d60: 6f63 6b28 292d 2667 743b 6973 5f75 706c ock()->is_upl │ │ │ -00040d70: 6f61 645f 6f6e 6c79 2829 293b 0a0a 0909 oad_only());.... │ │ │ -00040d80: 2f2f 2077 6520 6f6e 6c79 2077 616e 7420 // we only want │ │ │ -00040d90: 6c65 6674 2d6f 7665 7220 6261 6e64 7769 left-over bandwi │ │ │ -00040da0: 6474 680a 3c64 6976 2073 7479 6c65 3d22 dth.
    .
    ..std:: │ │ │ -00040de0: 7374 7269 6e67 2070 726f 746f 636f 6c3b string protocol; │ │ │ -00040df0: 0a09 0965 7272 6f72 5f63 6f64 6520 6563 ...error_code ec │ │ │ -00040e00: 3b0a 0909 7374 643a 3a74 6965 2870 726f ;...std::tie(pro │ │ │ -00040e10: 746f 636f 6c2c 206d 5f62 6173 6963 5f61 tocol, m_basic_a │ │ │ -00040e20: 7574 682c 206d 5f68 6f73 742c 206d 5f70 uth, m_host, m_p │ │ │ -00040e30: 6f72 742c 206d 5f70 6174 6829 0a09 0909 ort, m_path).... │ │ │ -00040e40: 3d20 7061 7273 655f 7572 6c5f 636f 6d70 = parse_url_comp │ │ │ -00040e50: 6f6e 656e 7473 2877 6562 2e75 726c 2c20 onents(web.url, │ │ │ -00040e60: 6563 293b 0a09 0954 4f52 5245 4e54 5f41 ec);...TORRENT_A │ │ │ -00040e70: 5353 4552 5428 2165 6329 3b0a 0a09 0969 SSERT(!ec);....i │ │ │ -00040e80: 6620 286d 5f70 6f72 7420 3d3d 202d 3120 f (m_port == -1 │ │ │ -00040e90: 2661 6d70 3b26 616d 703b 2070 726f 746f && proto │ │ │ -00040ea0: 636f 6c20 3d3d 2022 6874 7470 2229 0a09 col == "http").. │ │ │ -00040eb0: 0909 6d5f 706f 7274 203d 2038 303b 0a0a ..m_port = 80;.. │ │ │ -00040ec0: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ -00040ed0: 5353 4c0a 0909 6966 2028 7072 6f74 6f63 SSL...if (protoc │ │ │ -00040ee0: 6f6c 203d 3d20 2268 7474 7073 2229 0a09 ol == "https").. │ │ │ -00040ef0: 097b 0a09 0909 6d5f 7373 6c20 3d20 7472 .{....m_ssl = tr │ │ │ -00040f00: 7565 3b0a 0909 0969 6620 286d 5f70 6f72 ue;....if (m_por │ │ │ -00040f10: 7420 3d3d 202d 3129 206d 5f70 6f72 7420 t == -1) m_port │ │ │ -00040f20: 3d20 3434 333b 0a09 097d 0a23 656e 6469 = 443;...}.#endi │ │ │ -00040f30: 660a 0a09 0969 6620 2821 6d5f 6261 7369 f....if (!m_basi │ │ │ -00040f40: 635f 6175 7468 2e65 6d70 7479 2829 290a c_auth.empty()). │ │ │ -00040f50: 0909 096d 5f62 6173 6963 5f61 7574 6820 ...m_basic_auth │ │ │ -00040f60: 3d20 6261 7365 3634 656e 636f 6465 286d = base64encode(m │ │ │ -00040f70: 5f62 6173 6963 5f61 7574 6829 3b0a 0a09 _basic_auth);... │ │ │ -00040f80: 096d 5f73 6572 7665 725f 7374 7269 6e67 .m_server_string │ │ │ -00040f90: 203d 206d 5f68 6f73 743b 0a09 0961 7578 = m_host;...aux │ │ │ -00040fa0: 3a3a 7665 7269 6679 5f65 6e63 6f64 696e ::verify_encodin │ │ │ -00040fb0: 6728 6d5f 7365 7276 6572 5f73 7472 696e g(m_server_strin │ │ │ -00040fc0: 6729 3b0a 097d 0a0a 0969 6e74 2077 6562 g);..}...int web │ │ │ -00040fd0: 5f63 6f6e 6e65 6374 696f 6e5f 6261 7365 _connection_base │ │ │ -00040fe0: 3a3a 7469 6d65 6f75 7428 2920 636f 6e73 ::timeout() cons │ │ │ -00040ff0: 740a 097b 0a09 092f 2f20 7369 6e63 6520 t..{...// since │ │ │ -00041000: 7468 6973 2069 7320 6120 7765 6220 7365 this is a web se │ │ │ -00041010: 6564 2c20 6368 616e 6765 2074 6865 2074 ed, change the t │ │ │ -00041020: 696d 656f 7574 0a09 092f 2f20 6163 636f imeout...// acco │ │ │ -00041030: 7264 696e 6720 746f 2074 6865 2073 6574 rding to the set │ │ │ -00041040: 7469 6e67 732e 0a09 0972 6574 7572 6e20 tings....return │ │ │ -00041050: 6d5f 7365 7474 696e 6773 2e67 6574 5f69 m_settings.get_i │ │ │ -00041060: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ -00041070: 3a3a 7572 6c73 6565 645f 7469 6d65 6f75 ::urlseed_timeou │ │ │ -00041080: 7429 3b0a 097d 0a3c 2f70 7265 3e3c 2f74 t);..}.
    relevanc │ │ │ -000410c0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/part_fi │ │ │ -00041100: 6c65 2e63 7070 3a32 3934 3c2f 613e 3c2f le.cpp:294what do w │ │ │ -00041120: 6520 646f 2069 6620 736f 6d65 6f6e 6520 e do if someone │ │ │ -00041130: 6973 2063 7572 7265 6e74 6c79 2072 6561 is currently rea │ │ │ -00041140: 6469 6e67 2066 726f 6d20 7468 6520 6469 ding from the di │ │ │ -00041150: 736b 2066 726f 6d20 7468 6973 2070 6965 sk from this pie │ │ │ -00041160: 6365 3f20 646f 6573 2069 7420 6d61 7474 ce? does it matt │ │ │ -00041170: 6572 3f20 5369 6e63 6520 7765 2077 6f6e er? Since we won │ │ │ -00041180: 2774 2061 6374 6976 656c 7920 6572 6173 't actively eras │ │ │ -00041190: 6520 7468 6520 6461 7461 2066 726f 6d20 e the data from │ │ │ -000411a0: 6469 736b 2c20 6275 7420 6974 206d 6179 disk, but it may │ │ │ -000411b0: 2062 6520 6f76 6572 7772 6974 7465 6e20 be overwritten │ │ │ -000411c0: 736f 6f6e 2c20 6974 2773 2070 726f 6261 soon, it's proba │ │ │ -000411d0: 626c 7920 6e6f 7420 7468 6174 2062 6967 bly not that big │ │ │ -000411e0: 206f 6620 6120 6465 616c 3c2f 7464 3e3c of a deal< │ │ │ -000411f0: 2f74 723e 3c74 7220 6964 3d22 3136 3122 /tr>

    what do │ │ │ -00041240: 7765 2064 6f20 6966 2073 6f6d 656f 6e65 we do if someone │ │ │ -00041250: 2069 7320 6375 7272 656e 746c 7920 7265 is currently re │ │ │ -00041260: 6164 696e 6720 6672 6f6d 2074 6865 2064 ading from the d │ │ │ -00041270: 6973 6b0a 6672 6f6d 2074 6869 7320 7069 isk.from this pi │ │ │ -00041280: 6563 653f 2064 6f65 7320 6974 206d 6174 ece? does it mat │ │ │ -00041290: 7465 723f 2053 696e 6365 2077 6520 776f ter? Since we wo │ │ │ -000412a0: 6e27 7420 6163 7469 7665 6c79 2065 7261 n't actively era │ │ │ -000412b0: 7365 2074 6865 0a64 6174 6120 6672 6f6d se the.data from │ │ │ -000412c0: 2064 6973 6b2c 2062 7574 2069 7420 6d61 disk, but it ma │ │ │ -000412d0: 7920 6265 206f 7665 7277 7269 7474 656e y be overwritten │ │ │ -000412e0: 2073 6f6f 6e2c 2069 7427 7320 7072 6f62 soon, it's prob │ │ │ -000412f0: 6162 6c79 206e 6f74 2074 6861 740a 6269 ably not that.bi │ │ │ -00041300: 6720 6f66 2061 2064 6561 6c3c 2f68 323e g of a deal

    │ │ │ -00041310: 3c68 343e 2e2e 2f73 7263 2f70 6172 745f

    ../src/part_ │ │ │ -00041320: 6669 6c65 2e63 7070 3a32 3934 3c2f 6834 file.cpp:294

    ....c
    │ │ │ -00041370: 7265 6174 655f 6469 7265 6374 6f72 6965  reate_directorie
    │ │ │ -00041380: 7328 6d5f 7061 7468 2c20 6563 293b 0a09  s(m_path, ec);..
    │ │ │ -00041390: 0909 0969 6620 2865 6329 2072 6574 7572  ...if (ec) retur
    │ │ │ -000413a0: 6e20 7b7d 3b0a 0909 0909 7265 7475 726e  n {};.....return
    │ │ │ -000413b0: 207b 666e 2c20 302c 206d 6f64 657d 3b0a   {fn, 0, mode};.
    │ │ │ -000413c0: 0909 097d 0a09 0909 7265 7475 726e 207b  ...}....return {
    │ │ │ -000413d0: 7d3b 0a09 097d 0a09 7d0a 0963 6174 6368  };...}..}..catch
    │ │ │ -000413e0: 2028 7374 6f72 6167 655f 6572 726f 7220   (storage_error 
    │ │ │ -000413f0: 636f 6e73 7426 616d 703b 2065 290a 097b  const& e)..{
    │ │ │ -00041400: 0a09 0965 6320 3d20 652e 6563 3b0a 0909  ...ec = e.ec;...
    │ │ │ -00041410: 7265 7475 726e 207b 7d3b 0a09 7d0a 0a09  return {};..}...
    │ │ │ -00041420: 766f 6964 2070 6172 745f 6669 6c65 3a3a  void part_file::
    │ │ │ -00041430: 6672 6565 5f70 6965 6365 2870 6965 6365  free_piece(piece
    │ │ │ -00041440: 5f69 6e64 6578 5f74 2063 6f6e 7374 2070  _index_t const p
    │ │ │ -00041450: 6965 6365 290a 097b 0a09 0973 7464 3a3a  iece)..{...std::
    │ │ │ -00041460: 6c6f 636b 5f67 7561 7264 266c 743b 7374  lock_guard<st
    │ │ │ -00041470: 643a 3a6d 7574 6578 2667 743b 206c 286d  d::mutex> l(m
    │ │ │ -00041480: 5f6d 7574 6578 293b 0a0a 0909 6175 746f  _mutex);....auto
    │ │ │ -00041490: 2063 6f6e 7374 2069 203d 206d 5f70 6965   const i = m_pie
    │ │ │ -000414a0: 6365 5f6d 6170 2e66 696e 6428 7069 6563  ce_map.find(piec
    │ │ │ -000414b0: 6529 3b0a 0909 6966 2028 6920 3d3d 206d  e);...if (i == m
    │ │ │ -000414c0: 5f70 6965 6365 5f6d 6170 2e65 6e64 2829  _piece_map.end()
    │ │ │ -000414d0: 2920 7265 7475 726e 3b0a 0a3c 6469 7620  ) return;..
    .
    │ │ │ -00041510: 0909 6d5f 6672 6565 5f73 6c6f 7473 2e70 ..m_free_slots.p │ │ │ -00041520: 7573 685f 6261 636b 2869 2d26 6774 3b73 ush_back(i->s │ │ │ -00041530: 6563 6f6e 6429 3b0a 0909 6d5f 7069 6563 econd);...m_piec │ │ │ -00041540: 655f 6d61 702e 6572 6173 6528 6929 3b0a e_map.erase(i);. │ │ │ -00041550: 0909 6d5f 6469 7274 795f 6d65 7461 6461 ..m_dirty_metada │ │ │ -00041560: 7461 203d 2074 7275 653b 0a09 7d0a 0a09 ta = true;..}... │ │ │ -00041570: 766f 6964 2070 6172 745f 6669 6c65 3a3a void part_file:: │ │ │ -00041580: 6d6f 7665 5f70 6172 7466 696c 6528 7374 move_partfile(st │ │ │ -00041590: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ -000415a0: 616d 703b 2070 6174 682c 2065 7272 6f72 amp; path, error │ │ │ -000415b0: 5f63 6f64 6526 616d 703b 2065 6329 0a09 _code& ec).. │ │ │ -000415c0: 7b0a 0909 7374 643a 3a6c 6f63 6b5f 6775 {...std::lock_gu │ │ │ -000415d0: 6172 6426 6c74 3b73 7464 3a3a 6d75 7465 ard<std::mute │ │ │ -000415e0: 7826 6774 3b20 6c28 6d5f 6d75 7465 7829 x> l(m_mutex) │ │ │ -000415f0: 3b0a 0a09 0966 6c75 7368 5f6d 6574 6164 ;....flush_metad │ │ │ -00041600: 6174 615f 696d 706c 2865 6329 3b0a 0909 ata_impl(ec);... │ │ │ -00041610: 6966 2028 6563 2920 7265 7475 726e 3b0a if (ec) return;. │ │ │ -00041620: 0a09 0969 6620 2821 6d5f 7069 6563 655f ...if (!m_piece_ │ │ │ -00041630: 6d61 702e 656d 7074 7928 2929 0a09 097b map.empty())...{ │ │ │ -00041640: 0a09 0909 7374 643a 3a73 7472 696e 6720 ....std::string │ │ │ -00041650: 6f6c 645f 7061 7468 203d 2063 6f6d 6269 old_path = combi │ │ │ -00041660: 6e65 5f70 6174 6828 6d5f 7061 7468 2c20 ne_path(m_path, │ │ │ -00041670: 6d5f 6e61 6d65 293b 0a09 0909 7374 643a m_name);....std: │ │ │ -00041680: 3a73 7472 696e 6720 6e65 775f 7061 7468 :string new_path │ │ │ -00041690: 203d 2063 6f6d 6269 6e65 5f70 6174 6828 = combine_path( │ │ │ -000416a0: 7061 7468 2c20 6d5f 6e61 6d65 293b 0a0a path, m_name);.. │ │ │ -000416b0: 0909 0972 656e 616d 6528 6f6c 645f 7061 ...rename(old_pa │ │ │ -000416c0: 7468 2c20 6e65 775f 7061 7468 2c20 6563 th, new_path, ec │ │ │ -000416d0: 293b 0a09 0909 6966 2028 6563 203d 3d20 );....if (ec == │ │ │ -000416e0: 626f 6f73 743a 3a73 7973 7465 6d3a 3a65 boost::system::e │ │ │ -000416f0: 7272 633a 3a6e 6f5f 7375 6368 5f66 696c rrc::no_such_fil │ │ │ -00041700: 655f 6f72 5f64 6972 6563 746f 7279 290a e_or_directory). │ │ │ -00041710: 0909 0909 6563 2e63 6c65 6172 2829 3b0a ....ec.clear();. │ │ │ -00041720: 0a09 0909 6966 2028 6563 290a 0909 097b ....if (ec)....{ │ │ │ -00041730: 0a09 0909 0973 746f 7261 6765 5f65 7272 .....storage_err │ │ │ -00041740: 6f72 2073 653b 0a09 0909 0961 7578 3a3a or se;.....aux:: │ │ │ -00041750: 636f 7079 5f66 696c 6528 6f6c 645f 7061 copy_file(old_pa │ │ │ -00041760: 7468 2c20 6e65 775f 7061 7468 2c20 7365 th, new_path, se │ │ │ -00041770: 293b 0a09 0909 0965 6320 3d20 7365 2e65 );.....ec = se.e │ │ │ -00041780: 633b 0a09 0909 0969 6620 2865 6329 2072 c;.....if (ec) r │ │ │ -00041790: 6574 7572 6e3b 0a09 0909 0972 656d 6f76 eturn;.....remov │ │ │ -000417a0: 6528 6f6c 645f 7061 7468 2c20 6563 293b e(old_path, ec); │ │ │ -000417b0: 0a09 0909 7d0a 0909 7d0a 3c2f 7072 653e ....}...}.
    │ │ │ -000417c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000417f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00041800: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/part │ │ │ -00041830: 5f66 696c 652e 6370 703a 3430 353c 2f61 _file.cpp:405instea │ │ │ -00041850: 6420 6f66 2072 6562 7569 6c64 696e 6720 d of rebuilding │ │ │ -00041860: 7468 6520 7768 6f6c 6520 6669 6c65 2068 the whole file h │ │ │ -00041870: 6561 6465 7220 616e 6420 666c 7573 6869 eader and flushi │ │ │ -00041880: 6e67 2069 742c 2075 7064 6174 6520 7468 ng it, update th │ │ │ -00041890: 6520 736c 6f74 2065 6e74 7269 6573 2061 e slot entries a │ │ │ -000418a0: 7320 7765 2067 6f3c 2f74 643e 3c2f 7472 s we go

    instead of │ │ │ -00041900: 7265 6275 696c 6469 6e67 2074 6865 2077 rebuilding the w │ │ │ -00041910: 686f 6c65 2066 696c 6520 6865 6164 6572 hole file header │ │ │ -00041920: 0a61 6e64 2066 6c75 7368 696e 6720 6974 .and flushing it │ │ │ -00041930: 2c20 7570 6461 7465 2074 6865 2073 6c6f , update the slo │ │ │ -00041940: 7420 656e 7472 6965 7320 6173 2077 6520 t entries as we │ │ │ -00041950: 676f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 go

    ../sr │ │ │ -00041960: 632f 7061 7274 5f66 696c 652e 6370 703a c/part_file.cpp: │ │ │ -00041970: 3430 353c 2f68 343e 3c70 7265 2073 7479 405

    ......TORRENT_
    │ │ │ -000419c0: 4153 5345 5254 286a 2d26 6774 3b73 6563  ASSERT(j->sec
    │ │ │ -000419d0: 6f6e 6420 3d3d 2073 6c6f 7429 3b0a 0909  ond == slot);...
    │ │ │ -000419e0: 0909 0909 6d5f 6672 6565 5f73 6c6f 7473  ....m_free_slots
    │ │ │ -000419f0: 2e70 7573 685f 6261 636b 286a 2d26 6774  .push_back(j->
    │ │ │ -00041a00: 3b73 6563 6f6e 6429 3b0a 0909 0909 0909  ;second);.......
    │ │ │ -00041a10: 6d5f 7069 6563 655f 6d61 702e 6572 6173  m_piece_map.eras
    │ │ │ -00041a20: 6528 6a29 3b0a 0909 0909 0909 6d5f 6469  e(j);.......m_di
    │ │ │ -00041a30: 7274 795f 6d65 7461 6461 7461 203d 2074  rty_metadata = t
    │ │ │ -00041a40: 7275 653b 0a09 0909 0909 7d0a 0909 0909  rue;......}.....
    │ │ │ -00041a50: 7d0a 0909 097d 0a09 0909 6669 6c65 5f6f  }....}....file_o
    │ │ │ -00041a60: 6666 7365 7420 2b3d 2062 6c6f 636b 5f74  ffset += block_t
    │ │ │ -00041a70: 6f5f 636f 7079 3b0a 0909 0970 6965 6365  o_copy;....piece
    │ │ │ -00041a80: 5f6f 6666 7365 7420 3d20 303b 0a09 0909  _offset = 0;....
    │ │ │ -00041a90: 7369 7a65 202d 3d20 626c 6f63 6b5f 746f  size -= block_to
    │ │ │ -00041aa0: 5f63 6f70 793b 0a09 097d 0a09 7d0a 0a09  _copy;...}..}...
    │ │ │ -00041ab0: 766f 6964 2070 6172 745f 6669 6c65 3a3a  void part_file::
    │ │ │ -00041ac0: 666c 7573 685f 6d65 7461 6461 7461 2865  flush_metadata(e
    │ │ │ -00041ad0: 7272 6f72 5f63 6f64 6526 616d 703b 2065  rror_code& e
    │ │ │ -00041ae0: 6329 0a09 7b0a 0909 7374 643a 3a6c 6f63  c)..{...std::loc
    │ │ │ -00041af0: 6b5f 6775 6172 6426 6c74 3b73 7464 3a3a  k_guard<std::
    │ │ │ -00041b00: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -00041b10: 7465 7829 3b0a 0a09 0966 6c75 7368 5f6d  tex);....flush_m
    │ │ │ -00041b20: 6574 6164 6174 615f 696d 706c 2865 6329  etadata_impl(ec)
    │ │ │ -00041b30: 3b0a 097d 0a0a 3c64 6976 2073 7479 6c65  ;..}..
    .void part_f │ │ │ -00041b70: 696c 653a 3a66 6c75 7368 5f6d 6574 6164 ile::flush_metad │ │ │ -00041b80: 6174 615f 696d 706c 2865 7272 6f72 5f63 ata_impl(error_c │ │ │ -00041b90: 6f64 6526 616d 703b 2065 6329 0a3c 2f64 ode& ec)..{...// do we │ │ │ -00041bb0: 206e 6565 6420 746f 2066 6c75 7368 2074 need to flush t │ │ │ -00041bc0: 6865 206d 6574 6164 6174 613f 0a09 0969 he metadata?...i │ │ │ -00041bd0: 6620 286d 5f64 6972 7479 5f6d 6574 6164 f (m_dirty_metad │ │ │ -00041be0: 6174 6120 3d3d 2066 616c 7365 2920 7265 ata == false) re │ │ │ -00041bf0: 7475 726e 3b0a 0a09 0969 6620 286d 5f70 turn;....if (m_p │ │ │ -00041c00: 6965 6365 5f6d 6170 2e65 6d70 7479 2829 iece_map.empty() │ │ │ -00041c10: 290a 0909 7b0a 0909 092f 2f20 6966 2077 )...{....// if w │ │ │ -00041c20: 6520 646f 6e27 7420 6861 7665 2061 6e79 e don't have any │ │ │ -00041c30: 2070 6965 6365 7320 6c65 6674 2069 6e20 pieces left in │ │ │ -00041c40: 7468 650a 0909 092f 2f20 7061 7274 2066 the....// part f │ │ │ -00041c50: 696c 652c 2072 656d 6f76 6520 6974 0a09 ile, remove it.. │ │ │ -00041c60: 0909 7374 643a 3a73 7472 696e 6720 636f ..std::string co │ │ │ -00041c70: 6e73 7420 7020 3d20 636f 6d62 696e 655f nst p = combine_ │ │ │ -00041c80: 7061 7468 286d 5f70 6174 682c 206d 5f6e path(m_path, m_n │ │ │ -00041c90: 616d 6529 3b0a 0909 0972 656d 6f76 6528 ame);....remove( │ │ │ -00041ca0: 702c 2065 6329 3b0a 0a09 0909 6966 2028 p, ec);.....if ( │ │ │ -00041cb0: 6563 203d 3d20 626f 6f73 743a 3a73 7973 ec == boost::sys │ │ │ -00041cc0: 7465 6d3a 3a65 7272 633a 3a6e 6f5f 7375 tem::errc::no_su │ │ │ -00041cd0: 6368 5f66 696c 655f 6f72 5f64 6972 6563 ch_file_or_direc │ │ │ -00041ce0: 746f 7279 290a 0909 0909 6563 2e63 6c65 tory).....ec.cle │ │ │ -00041cf0: 6172 2829 3b0a 0909 0972 6574 7572 6e3b ar();....return; │ │ │ -00041d00: 0a09 097d 0a0a 0909 6175 746f 2066 203d ...}....auto f = │ │ │ -00041d10: 206f 7065 6e5f 6669 6c65 2861 7578 3a3a open_file(aux:: │ │ │ -00041d20: 6f70 656e 5f6d 6f64 653a 3a77 7269 7465 open_mode::write │ │ │ -00041d30: 207c 2061 7578 3a3a 6f70 656e 5f6d 6f64 | aux::open_mod │ │ │ -00041d40: 653a 3a68 6964 6465 6e2c 2065 6329 3b0a e::hidden, ec);. │ │ │ -00041d50: 0909 6966 2028 6563 2920 7265 7475 726e ..if (ec) return │ │ │ -00041d60: 3b0a 0a09 0973 7464 3a3a 7665 6374 6f72 ;....std::vector │ │ │ -00041d70: 266c 743b 6368 6172 2667 743b 2068 6561 <char> hea │ │ │ -00041d80: 6465 7228 7374 6174 6963 5f63 6173 7426 der(static_cast& │ │ │ -00041d90: 6c74 3b73 7464 3a3a 7369 7a65 5f74 2667 lt;std::size_t&g │ │ │ -00041da0: 743b 286d 5f68 6561 6465 725f 7369 7a65 t;(m_header_size │ │ │ -00041db0: 2929 3b0a 0a09 0975 7369 6e67 206e 616d ));....using nam │ │ │ -00041dc0: 6573 7061 6365 206c 6962 746f 7272 656e espace libtorren │ │ │ -00041dd0: 743a 3a61 7578 3b0a 0a09 0963 6861 722a t::aux;....char* │ │ │ -00041de0: 2070 7472 203d 2068 6561 6465 722e 6461 ptr = header.da │ │ │ -00041df0: 7461 2829 3b0a 0909 7772 6974 655f 7569 ta();...write_ui │ │ │ -00041e00: 6e74 3332 286d 5f6d 6178 5f70 6965 6365 nt32(m_max_piece │ │ │ -00041e10: 732c 2070 7472 293b 0a09 0977 7269 7465 s, ptr);...write │ │ │ -00041e20: 5f75 696e 7433 3228 6d5f 7069 6563 655f _uint32(m_piece_ │ │ │ -00041e30: 7369 7a65 2c20 7074 7229 3b0a 0a09 0966 size, ptr);....f │ │ │ -00041e40: 6f72 2028 7069 6563 655f 696e 6465 785f or (piece_index_ │ │ │ -00041e50: 7420 7069 6563 6528 3029 3b20 7069 6563 t piece(0); piec │ │ │ -00041e60: 6520 266c 743b 2070 6965 6365 5f69 6e64 e < piece_ind │ │ │ -00041e70: 6578 5f74 286d 5f6d 6178 5f70 6965 6365 ex_t(m_max_piece │ │ │ -00041e80: 7329 3b20 2b2b 7069 6563 6529 0a09 097b s); ++piece)...{ │ │ │ -00041e90: 0a09 0909 6175 746f 2063 6f6e 7374 2069 ....auto const i │ │ │ -00041ea0: 203d 206d 5f70 6965 6365 5f6d 6170 2e66 = m_piece_map.f │ │ │ -00041eb0: 696e 6428 7069 6563 6529 3b0a 3c2f 7072 ind(piece);.rel │ │ │ -00041ef0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ -00041f30: 7272 656e 745f 6861 6e64 6c65 2e63 7070 rrent_handle.cpp │ │ │ -00041f40: 3a35 3534 3c2f 613e 3c2f 7464 3e3c 7464 :554support moving │ │ │ -00041f60: 6669 6c65 7320 696e 746f 2074 6869 7320 files into this │ │ │ -00041f70: 6361 6c6c 3c2f 7464 3e3c 2f74 723e 3c74 callsupport moving │ │ │ -00041fd0: 2066 696c 6573 2069 6e74 6f20 7468 6973 files into this │ │ │ -00041fe0: 2063 616c 6c3c 2f68 323e 3c68 343e 2e2e call

    .. │ │ │ -00041ff0: 2f73 7263 2f74 6f72 7265 6e74 5f68 616e /src/torrent_han │ │ │ -00042000: 646c 652e 6370 703a 3535 343c 2f68 343e dle.cpp:554

    │ │ │ -00042010: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..auto
    │ │ │ -00042050: 2a20 636f 6e73 7420 7265 7470 203d 2026  * const retp = &
    │ │ │ -00042060: 616d 703b 7072 696f 3b0a 0909 7379 6e63  amp;prio;...sync
    │ │ │ -00042070: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a  _call(&aux::
    │ │ │ -00042080: 746f 7272 656e 743a 3a70 6965 6365 5f70  torrent::piece_p
    │ │ │ -00042090: 7269 6f72 6974 6965 732c 2072 6574 7029  riorities, retp)
    │ │ │ -000420a0: 3b0a 0909 7374 643a 3a76 6563 746f 7226  ;...std::vector&
    │ │ │ -000420b0: 6c74 3b69 6e74 2667 743b 2072 6574 3b0a  lt;int> ret;.
    │ │ │ -000420c0: 0909 7265 742e 7265 7365 7276 6528 7072  ..ret.reserve(pr
    │ │ │ -000420d0: 696f 2e73 697a 6528 2929 3b0a 0909 666f  io.size());...fo
    │ │ │ -000420e0: 7220 2861 7574 6f20 7020 3a20 7072 696f  r (auto p : prio
    │ │ │ -000420f0: 290a 0909 0972 6574 2e70 7573 685f 6261  )....ret.push_ba
    │ │ │ -00042100: 636b 2869 6e74 2873 7461 7469 635f 6361  ck(int(static_ca
    │ │ │ -00042110: 7374 266c 743b 7374 643a 3a75 696e 7438  st<std::uint8
    │ │ │ -00042120: 5f74 2667 743b 2870 2929 293b 0a09 0972  _t>(p)));...r
    │ │ │ -00042130: 6574 7572 6e20 7265 743b 0a09 7d0a 2365  eturn ret;..}.#e
    │ │ │ -00042140: 6e64 6966 0a0a 0976 6f69 6420 746f 7272  ndif...void torr
    │ │ │ -00042150: 656e 745f 6861 6e64 6c65 3a3a 6669 6c65  ent_handle::file
    │ │ │ -00042160: 5f70 7269 6f72 6974 7928 6669 6c65 5f69  _priority(file_i
    │ │ │ -00042170: 6e64 6578 5f74 2069 6e64 6578 2c20 646f  ndex_t index, do
    │ │ │ -00042180: 776e 6c6f 6164 5f70 7269 6f72 6974 795f  wnload_priority_
    │ │ │ -00042190: 7420 7072 696f 7269 7479 2920 636f 6e73  t priority) cons
    │ │ │ -000421a0: 740a 097b 0a09 0961 7379 6e63 5f63 616c  t..{...async_cal
    │ │ │ -000421b0: 6c28 2661 6d70 3b61 7578 3a3a 746f 7272  l(&aux::torr
    │ │ │ -000421c0: 656e 743a 3a73 6574 5f66 696c 655f 7072  ent::set_file_pr
    │ │ │ -000421d0: 696f 7269 7479 2c20 696e 6465 782c 2070  iority, index, p
    │ │ │ -000421e0: 7269 6f72 6974 7929 3b0a 097d 0a0a 0964  riority);..}...d
    │ │ │ -000421f0: 6f77 6e6c 6f61 645f 7072 696f 7269 7479  ownload_priority
    │ │ │ -00042200: 5f74 2074 6f72 7265 6e74 5f68 616e 646c  _t torrent_handl
    │ │ │ -00042210: 653a 3a66 696c 655f 7072 696f 7269 7479  e::file_priority
    │ │ │ -00042220: 2866 696c 655f 696e 6465 785f 7420 696e  (file_index_t in
    │ │ │ -00042230: 6465 7829 2063 6f6e 7374 0a09 7b0a 0909  dex) const..{...
    │ │ │ -00042240: 7265 7475 726e 2073 796e 635f 6361 6c6c  return sync_call
    │ │ │ -00042250: 5f72 6574 266c 743b 646f 776e 6c6f 6164  _ret<download
    │ │ │ -00042260: 5f70 7269 6f72 6974 795f 7426 6774 3b28  _priority_t>(
    │ │ │ -00042270: 646f 6e74 5f64 6f77 6e6c 6f61 642c 2026  dont_download, &
    │ │ │ -00042280: 616d 703b 6175 783a 3a74 6f72 7265 6e74  amp;aux::torrent
    │ │ │ -00042290: 3a3a 6669 6c65 5f70 7269 6f72 6974 792c  ::file_priority,
    │ │ │ -000422a0: 2069 6e64 6578 293b 0a09 7d0a 0a3c 6469   index);..}...void
    │ │ │ -000422e0: 2074 6f72 7265 6e74 5f68 616e 646c 653a   torrent_handle:
    │ │ │ -000422f0: 3a70 7269 6f72 6974 697a 655f 6669 6c65  :prioritize_file
    │ │ │ -00042300: 7328 7374 643a 3a76 6563 746f 7226 6c74  s(std::vector<
    │ │ │ -00042310: 3b64 6f77 6e6c 6f61 645f 7072 696f 7269  ;download_priori
    │ │ │ -00042320: 7479 5f74 2667 743b 2063 6f6e 7374 2661  ty_t> const&a
    │ │ │ -00042330: 6d70 3b20 6669 6c65 7329 2063 6f6e 7374  mp; files) const
    │ │ │ -00042340: 0a3c 2f64 6976 3e09 7b0a 0909 6173 796e  .
    .{...asyn │ │ │ -00042350: 635f 6361 6c6c 2826 616d 703b 6175 783a c_call(&aux: │ │ │ -00042360: 3a74 6f72 7265 6e74 3a3a 7072 696f 7269 :torrent::priori │ │ │ -00042370: 7469 7a65 5f66 696c 6573 0a09 0909 2c20 tize_files...., │ │ │ -00042380: 7374 6174 6963 5f63 6173 7426 6c74 3b61 static_cast<a │ │ │ -00042390: 7578 3a3a 7665 6374 6f72 266c 743b 646f ux::vector<do │ │ │ -000423a0: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ -000423b0: 742c 2066 696c 655f 696e 6465 785f 7426 t, file_index_t& │ │ │ -000423c0: 6774 3b20 636f 6e73 7426 616d 703b 2667 gt; const&&g │ │ │ -000423d0: 743b 2866 696c 6573 2929 3b0a 097d 0a0a t;(files));..}.. │ │ │ -000423e0: 0976 6f69 6420 746f 7272 656e 745f 6861 .void torrent_ha │ │ │ -000423f0: 6e64 6c65 3a3a 706f 7374 5f66 696c 655f ndle::post_file_ │ │ │ -00042400: 7072 696f 7269 7469 6573 2829 2063 6f6e priorities() con │ │ │ -00042410: 7374 0a09 7b0a 0909 6173 796e 635f 6361 st..{...async_ca │ │ │ -00042420: 6c6c 2826 616d 703b 6175 783a 3a74 6f72 ll(&aux::tor │ │ │ -00042430: 7265 6e74 3a3a 706f 7374 5f66 696c 655f rent::post_file_ │ │ │ -00042440: 7072 696f 7269 7469 6573 293b 0a09 7d0a priorities);..}. │ │ │ -00042450: 0a09 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ -00042460: 3b64 6f77 6e6c 6f61 645f 7072 696f 7269 ;download_priori │ │ │ -00042470: 7479 5f74 2667 743b 2074 6f72 7265 6e74 ty_t> torrent │ │ │ -00042480: 5f68 616e 646c 653a 3a67 6574 5f66 696c _handle::get_fil │ │ │ -00042490: 655f 7072 696f 7269 7469 6573 2829 2063 e_priorities() c │ │ │ -000424a0: 6f6e 7374 0a09 7b0a 0909 6175 783a 3a76 onst..{...aux::v │ │ │ -000424b0: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ -000424c0: 645f 7072 696f 7269 7479 5f74 2c20 6669 d_priority_t, fi │ │ │ -000424d0: 6c65 5f69 6e64 6578 5f74 2667 743b 2072 le_index_t> r │ │ │ -000424e0: 6574 3b0a 0909 6175 746f 2a20 636f 6e73 et;...auto* cons │ │ │ -000424f0: 7420 7265 7470 203d 2026 616d 703b 7265 t retp = &re │ │ │ -00042500: 743b 0a09 0973 796e 635f 6361 6c6c 2826 t;...sync_call(& │ │ │ -00042510: 616d 703b 6175 783a 3a74 6f72 7265 6e74 amp;aux::torrent │ │ │ -00042520: 3a3a 6669 6c65 5f70 7269 6f72 6974 6965 ::file_prioritie │ │ │ -00042530: 732c 2072 6574 7029 3b0a 0909 7265 7475 s, retp);...retu │ │ │ -00042540: 726e 2054 4f52 5245 4e54 5f52 564f 2872 rn TORRENT_RVO(r │ │ │ -00042550: 6574 293b 0a09 7d0a 0a23 6966 2054 4f52 et);..}..#if TOR │ │ │ -00042560: 5245 4e54 5f41 4249 5f56 4552 5349 4f4e RENT_ABI_VERSION │ │ │ -00042570: 203d 3d20 310a 0a2f 2f20 3d3d 3d3d 3d3d == 1..// ====== │ │ │ -00042580: 3d3d 3d3d 3d3d 2073 7461 7274 2064 6570 ====== start dep │ │ │ -00042590: 7265 6361 7469 6f6e 203d 3d3d 3d3d 3d3d recation ======= │ │ │ -000425a0: 3d3d 3d3d 3d3d 3d3d 0a0a 0976 6f69 6420 ========...void │ │ │ -000425b0: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ -000425c0: 7072 696f 7269 7469 7a65 5f66 696c 6573 prioritize_files │ │ │ -000425d0: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ -000425e0: 696e 7426 6774 3b20 636f 6e73 7426 616d int> const&am │ │ │ -000425f0: 703b 2066 696c 6573 2920 636f 6e73 740a p; files) const. │ │ │ -00042600: 097b 0a09 0961 7578 3a3a 7665 6374 6f72 .{...aux::vector │ │ │ -00042610: 266c 743b 646f 776e 6c6f 6164 5f70 7269 <download_pri │ │ │ -00042620: 6f72 6974 795f 742c 2066 696c 655f 696e ority_t, file_in │ │ │ -00042630: 6465 785f 7426 6774 3b20 6669 6c65 5f70 dex_t> file_p │ │ │ -00042640: 7269 6f3b 0a09 0966 696c 655f 7072 696f rio;...file_prio │ │ │ -00042650: 2e72 6573 6572 7665 2866 696c 6573 2e73 .reserve(files.s │ │ │ -00042660: 697a 6528 2929 3b0a 0909 666f 7220 2861 ize());...for (a │ │ │ -00042670: 7574 6f20 636f 6e73 7420 7020 3a20 6669 uto const p : fi │ │ │ -00042680: 6c65 7329 207b 0a09 0909 6669 6c65 5f70 les) {....file_p │ │ │ -00042690: 7269 6f2e 7075 7368 5f62 6163 6b28 646f rio.push_back(do │ │ │ -000426a0: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ -000426b0: 7428 7374 6174 6963 5f63 6173 7426 6c74 t(static_cast< │ │ │ -000426c0: 3b73 7464 3a3a 7569 6e74 385f 7426 6774 ;std::uint8_t> │ │ │ -000426d0: 3b28 7029 2929 3b0a 0909 7d0a 0909 6173 ;(p)));...}...as │ │ │ -000426e0: 796e 635f 6361 6c6c 2826 616d 703b 6175 ync_call(&au │ │ │ -000426f0: 783a 3a74 6f72 7265 6e74 3a3a 7072 696f x::torrent::prio │ │ │ -00042700: 7269 7469 7a65 5f66 696c 6573 2c20 6669 ritize_files, fi │ │ │ -00042710: 6c65 5f70 7269 6f29 3b0a 3c2f 7072 653e le_prio);.
    │ │ │ -00042720: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00042750: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00042760: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ -00042790: 656e 745f 6861 6e64 6c65 2e63 7070 3a38 ent_handle.cpp:8 │ │ │ -000427a0: 3339 3c2f 613e 3c2f 7464 3e3c 7464 3e64 39d │ │ │ -000427b0: 6570 7265 6361 7465 2074 6865 206f 7665 eprecate the ove │ │ │ -000427c0: 726c 6f61 6420 7468 6174 2074 616b 6573 rload that takes │ │ │ -000427d0: 2061 6e20 696e 6465 783c 2f74 643e 3c2f an index

    deprecate │ │ │ -00042830: 2074 6865 206f 7665 726c 6f61 6420 7468 the overload th │ │ │ -00042840: 6174 2074 616b 6573 2061 6e20 696e 6465 at takes an inde │ │ │ -00042850: 783c 2f68 323e 3c68 343e 2e2e 2f73 7263 x

    ../src │ │ │ -00042860: 2f74 6f72 7265 6e74 5f68 616e 646c 652e /torrent_handle. │ │ │ -00042870: 6370 703a 3833 393c 2f68 343e 3c70 7265 cpp:839

    ...auto t 
    │ │ │ -000428c0: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b  = m_torrent.lock
    │ │ │ -000428d0: 2829 3b0a 0909 6966 2028 2174 207c 7c20  ();...if (!t || 
    │ │ │ -000428e0: 2174 2d26 6774 3b68 6173 5f73 746f 7261  !t->has_stora
    │ │ │ -000428f0: 6765 2829 2920 7265 7475 726e 3b0a 0909  ge()) return;...
    │ │ │ -00042900: 6175 746f 2661 6d70 3b20 7365 7320 3d20  auto& ses = 
    │ │ │ -00042910: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ -00042920: 6573 7369 6f6e 5f69 6d70 6c26 616d 703b  ession_impl&
    │ │ │ -00042930: 2667 743b 2874 2d26 6774 3b73 6573 7369  >(t->sessi
    │ │ │ -00042940: 6f6e 2829 293b 0a09 0973 7461 7475 7320  on());...status 
    │ │ │ -00042950: 3d20 7365 732e 6469 736b 5f74 6872 6561  = ses.disk_threa
    │ │ │ -00042960: 6428 292e 6765 745f 7374 6174 7573 2874  d().get_status(t
    │ │ │ -00042970: 2d26 6774 3b73 746f 7261 6765 2829 293b  ->storage());
    │ │ │ -00042980: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69  ..}.#endif...voi
    │ │ │ -00042990: 6420 746f 7272 656e 745f 6861 6e64 6c65  d torrent_handle
    │ │ │ -000429a0: 3a3a 666f 7263 655f 6468 745f 616e 6e6f  ::force_dht_anno
    │ │ │ -000429b0: 756e 6365 2829 2063 6f6e 7374 0a09 7b0a  unce() const..{.
    │ │ │ -000429c0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -000429d0: 4449 5341 424c 455f 4448 540a 0909 6173  DISABLE_DHT...as
    │ │ │ -000429e0: 796e 635f 6361 6c6c 2826 616d 703b 6175  ync_call(&au
    │ │ │ -000429f0: 783a 3a74 6f72 7265 6e74 3a3a 6468 745f  x::torrent::dht_
    │ │ │ -00042a00: 616e 6e6f 756e 6365 293b 0a23 656e 6469  announce);.#endi
    │ │ │ -00042a10: 660a 097d 0a0a 0976 6f69 6420 746f 7272  f..}...void torr
    │ │ │ -00042a20: 656e 745f 6861 6e64 6c65 3a3a 666f 7263  ent_handle::forc
    │ │ │ -00042a30: 655f 6c73 645f 616e 6e6f 756e 6365 2829  e_lsd_announce()
    │ │ │ -00042a40: 2063 6f6e 7374 0a09 7b0a 0909 6173 796e   const..{...asyn
    │ │ │ -00042a50: 635f 6361 6c6c 2826 616d 703b 6175 783a  c_call(&aux:
    │ │ │ -00042a60: 3a74 6f72 7265 6e74 3a3a 6c73 645f 616e  :torrent::lsd_an
    │ │ │ -00042a70: 6e6f 756e 6365 293b 0a09 7d0a 0a3c 6469  nounce);..}...void
    │ │ │ -00042ab0: 2074 6f72 7265 6e74 5f68 616e 646c 653a   torrent_handle:
    │ │ │ -00042ac0: 3a66 6f72 6365 5f72 6561 6e6e 6f75 6e63  :force_reannounc
    │ │ │ -00042ad0: 6528 696e 7420 636f 6e73 7420 732c 2069  e(int const s, i
    │ │ │ -00042ae0: 6e74 2063 6f6e 7374 2069 6478 2c20 7265  nt const idx, re
    │ │ │ -00042af0: 616e 6e6f 756e 6365 5f66 6c61 6773 5f74  announce_flags_t
    │ │ │ -00042b00: 2063 6f6e 7374 2066 6c61 6773 2920 636f   const flags) co
    │ │ │ -00042b10: 6e73 740a 3c2f 6469 763e 097b 0a09 0961  nst.
    .{...a │ │ │ -00042b20: 7379 6e63 5f63 616c 6c28 2661 6d70 3b61 sync_call(&a │ │ │ -00042b30: 7578 3a3a 746f 7272 656e 743a 3a66 6f72 ux::torrent::for │ │ │ -00042b40: 6365 5f74 7261 636b 6572 5f72 6571 7565 ce_tracker_reque │ │ │ -00042b50: 7374 2c20 6175 783a 3a74 696d 655f 6e6f st, aux::time_no │ │ │ -00042b60: 7728 2920 2b20 7365 636f 6e64 7328 7329 w() + seconds(s) │ │ │ -00042b70: 2c20 6964 782c 2066 6c61 6773 293b 0a09 , idx, flags);.. │ │ │ -00042b80: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ -00042b90: 5f68 616e 646c 653a 3a66 6f72 6365 5f72 _handle::force_r │ │ │ -00042ba0: 6561 6e6e 6f75 6e63 6528 696e 7420 636f eannounce(int co │ │ │ -00042bb0: 6e73 7420 732c 2073 7464 3a3a 7374 7269 nst s, std::stri │ │ │ -00042bc0: 6e67 2063 6f6e 7374 2661 6d70 3b20 7572 ng const& ur │ │ │ -00042bd0: 6c2c 2072 6561 6e6e 6f75 6e63 655f 666c l, reannounce_fl │ │ │ -00042be0: 6167 735f 7420 636f 6e73 7420 666c 6167 ags_t const flag │ │ │ -00042bf0: 7329 2063 6f6e 7374 0a09 7b0a 0909 6173 s) const..{...as │ │ │ -00042c00: 796e 635f 6361 6c6c 2826 616d 703b 6175 ync_call(&au │ │ │ -00042c10: 783a 3a74 6f72 7265 6e74 3a3a 666f 7263 x::torrent::forc │ │ │ -00042c20: 655f 7472 6163 6b65 725f 7265 7175 6573 e_tracker_reques │ │ │ -00042c30: 745f 7572 6c2c 2061 7578 3a3a 7469 6d65 t_url, aux::time │ │ │ -00042c40: 5f6e 6f77 2829 202b 2073 6563 6f6e 6473 _now() + seconds │ │ │ -00042c50: 2873 292c 2075 726c 2c20 666c 6167 7329 (s), url, flags) │ │ │ -00042c60: 3b0a 097d 0a0a 0976 6f69 6420 746f 7272 ;..}...void torr │ │ │ -00042c70: 656e 745f 6861 6e64 6c65 3a3a 666f 7263 ent_handle::forc │ │ │ -00042c80: 655f 7265 616e 6e6f 756e 6365 2869 6e74 e_reannounce(int │ │ │ -00042c90: 2063 6f6e 7374 2073 2c20 7265 616e 6e6f const s, reanno │ │ │ -00042ca0: 756e 6365 5f66 6c61 6773 5f74 2063 6f6e unce_flags_t con │ │ │ -00042cb0: 7374 2066 6c61 6773 2920 636f 6e73 740a st flags) const. │ │ │ -00042cc0: 097b 0a09 0961 7379 6e63 5f63 616c 6c28 .{...async_call( │ │ │ -00042cd0: 2661 6d70 3b61 7578 3a3a 746f 7272 656e &aux::torren │ │ │ -00042ce0: 743a 3a66 6f72 6365 5f74 7261 636b 6572 t::force_tracker │ │ │ -00042cf0: 5f72 6571 7565 7374 2c20 6175 783a 3a74 _request, aux::t │ │ │ -00042d00: 696d 655f 6e6f 7728 2920 2b20 7365 636f ime_now() + seco │ │ │ -00042d10: 6e64 7328 7329 2c20 2d31 2c20 666c 6167 nds(s), -1, flag │ │ │ -00042d20: 7329 3b0a 097d 0a0a 0973 7464 3a3a 7665 s);..}...std::ve │ │ │ -00042d30: 6374 6f72 266c 743b 6f70 656e 5f66 696c ctor<open_fil │ │ │ -00042d40: 655f 7374 6174 6526 6774 3b20 746f 7272 e_state> torr │ │ │ -00042d50: 656e 745f 6861 6e64 6c65 3a3a 6669 6c65 ent_handle::file │ │ │ -00042d60: 5f73 7461 7475 7328 2920 636f 6e73 740a _status() const. │ │ │ -00042d70: 097b 0a09 0961 7574 6f20 7420 3d20 6d5f .{...auto t = m_ │ │ │ -00042d80: 746f 7272 656e 742e 6c6f 636b 2829 3b0a torrent.lock();. │ │ │ -00042d90: 0909 6966 2028 2174 207c 7c20 2174 2d26 ..if (!t || !t-& │ │ │ -00042da0: 6774 3b68 6173 5f73 746f 7261 6765 2829 gt;has_storage() │ │ │ -00042db0: 2920 7265 7475 726e 207b 7d3b 0a09 0961 ) return {};...a │ │ │ -00042dc0: 7574 6f26 616d 703b 2073 6573 203d 2073 uto& ses = s │ │ │ -00042dd0: 7461 7469 635f 6361 7374 266c 743b 7365 tatic_cast<se │ │ │ -00042de0: 7373 696f 6e5f 696d 706c 2661 6d70 3b26 ssion_impl&& │ │ │ -00042df0: 6774 3b28 742d 2667 743b 7365 7373 696f gt;(t->sessio │ │ │ -00042e00: 6e28 2929 3b0a 0909 7265 7475 726e 2073 n());...return s │ │ │ -00042e10: 6573 2e64 6973 6b5f 7468 7265 6164 2829 es.disk_thread() │ │ │ -00042e20: 2e67 6574 5f73 7461 7475 7328 742d 2667 .get_status(t-&g │ │ │ -00042e30: 743b 7374 6f72 6167 6528 2929 3b0a 097d t;storage());..} │ │ │ -00042e40: 0a0a 0976 6f69 6420 746f 7272 656e 745f ...void torrent_ │ │ │ -00042e50: 6861 6e64 6c65 3a3a 706f 7374 5f66 696c handle::post_fil │ │ │ -00042e60: 655f 7374 6174 7573 2829 2063 6f6e 7374 e_status() const │ │ │ -00042e70: 0a09 7b0a 0909 6173 796e 635f 6361 6c6c ..{...async_call │ │ │ -00042e80: 2826 616d 703b 6175 783a 3a74 6f72 7265 (&aux::torre │ │ │ -00042e90: 6e74 3a3a 706f 7374 5f66 696c 655f 7374 nt::post_file_st │ │ │ -00042ea0: 6174 7573 293b 0a09 7d0a 0a09 766f 6964 atus);..}...void │ │ │ -00042eb0: 2074 6f72 7265 6e74 5f68 616e 646c 653a torrent_handle: │ │ │ -00042ec0: 3a73 6372 6170 655f 7472 6163 6b65 7228 :scrape_tracker( │ │ │ -00042ed0: 696e 7420 6964 7829 2063 6f6e 7374 0a09 int idx) const.. │ │ │ -00042ee0: 7b0a 0909 6173 796e 635f 6361 6c6c 2826 {...async_call(& │ │ │ -00042ef0: 616d 703b 6175 783a 3a74 6f72 7265 6e74 amp;aux::torrent │ │ │ -00042f00: 3a3a 7363 7261 7065 5f74 7261 636b 6572 ::scrape_tracker │ │ │ -00042f10: 2c20 6964 782c 2074 7275 6529 3b0a 3c2f , idx, true);.r │ │ │ -00042f50: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00042f60: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00042f90: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ -00042fa0: 3a31 3633 353c 2f61 3e3c 2f74 643e 3c74 :1635collections

    colle │ │ │ -00043010: 6374 696f 6e73 3c2f 6832 3e3c 6834 3e2e ctions

    . │ │ │ -00043020: 2e2f 7372 632f 746f 7272 656e 745f 696e ./src/torrent_in │ │ │ -00043030: 666f 2e63 7070 3a31 3633 353c 2f68 343e fo.cpp:1635

    │ │ │ -00043040: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    
    │ │ │ -00043080: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374  relev
    │ │ │ -000430b0: 616e 6365 266e 6273 703b 303c 2f74 643e  ance 0
    │ │ │ -000430c0: 3c74 643e 3c61 2068 7265 663d 226a 6176  ../src/torr
    │ │ │ -000430f0: 656e 745f 696e 666f 2e63 7070 3a31 3633  ent_info.cpp:163
    │ │ │ -00043100: 363c 2f61 3e3c 2f74 643e 3c74 643e 7369  6si
    │ │ │ -00043110: 6d69 6c61 723c 2f74 643e 3c2f 7472 3e3c  milar<
    │ │ │ -00043120: 7472 2069 643d 2231 3636 2220 7374 796c  tr id="166" styl
    │ │ │ -00043130: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ -00043140: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ -00043150: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ -00043160: 6832 3e73 696d 696c 6172 3c2f 6832 3e3c  h2>similar<
    │ │ │ -00043170: 6834 3e2e 2e2f 7372 632f 746f 7272 656e  h4>../src/torren
    │ │ │ -00043180: 745f 696e 666f 2e63 7070 3a31 3633 363c  t_info.cpp:1636<
    │ │ │ -00043190: 2f68 343e 3c70 7265 2073 7479 6c65 3d22  /h4>
    ..
    │ │ │ -000431d0: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ -000431e0: 2661 6d70 3b20 7572 6c20 3a20 6174 702e  & url : atp.
    │ │ │ -000431f0: 7572 6c5f 7365 6564 7329 0a09 097b 0a09  url_seeds)...{..
    │ │ │ -00043200: 0909 7765 625f 7365 6564 5f65 6e74 7279  ..web_seed_entry
    │ │ │ -00043210: 2065 6e74 2875 726c 293b 0a09 0909 656e   ent(url);....en
    │ │ │ -00043220: 742e 7479 7065 203d 2077 6562 5f73 6565  t.type = web_see
    │ │ │ -00043230: 645f 656e 7472 793a 3a75 726c 5f73 6565  d_entry::url_see
    │ │ │ -00043240: 643b 0a09 0909 6d5f 7765 625f 7365 6564  d;....m_web_seed
    │ │ │ -00043250: 732e 7075 7368 5f62 6163 6b28 7374 643a  s.push_back(std:
    │ │ │ -00043260: 3a6d 6f76 6528 656e 7429 293b 0a09 097d  :move(ent));...}
    │ │ │ -00043270: 0a0a 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ -00043280: 6e73 7426 616d 703b 2075 726c 203a 2061  nst& url : a
    │ │ │ -00043290: 7470 2e68 7474 705f 7365 6564 7329 0a09  tp.http_seeds)..
    │ │ │ -000432a0: 097b 0a09 0909 7765 625f 7365 6564 5f65  .{....web_seed_e
    │ │ │ -000432b0: 6e74 7279 2065 6e74 2875 726c 293b 0a09  ntry ent(url);..
    │ │ │ -000432c0: 0909 656e 742e 7479 7065 203d 2077 6562  ..ent.type = web
    │ │ │ -000432d0: 5f73 6565 645f 656e 7472 793a 3a68 7474  _seed_entry::htt
    │ │ │ -000432e0: 705f 7365 6564 3b0a 0909 096d 5f77 6562  p_seed;....m_web
    │ │ │ -000432f0: 5f73 6565 6473 2e70 7573 685f 6261 636b  _seeds.push_back
    │ │ │ -00043300: 2873 7464 3a3a 6d6f 7665 2865 6e74 2929  (std::move(ent))
    │ │ │ -00043310: 3b0a 0909 7d0a 0a09 0966 6f72 2028 6175  ;...}....for (au
    │ │ │ -00043320: 746f 2063 6f6e 7374 2661 6d70 3b20 6e20  to const& n 
    │ │ │ -00043330: 3a20 6174 702e 6468 745f 6e6f 6465 7329  : atp.dht_nodes)
    │ │ │ -00043340: 0a09 097b 0a09 0909 6d5f 6e6f 6465 732e  ...{....m_nodes.
    │ │ │ -00043350: 656d 706c 6163 655f 6261 636b 286e 293b  emplace_back(n);
    │ │ │ -00043360: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..return tru │ │ │ -000433a0: 653b 0a3c 2f64 6976 3e09 7d0a 0a09 766f e;.
    .}...vo │ │ │ -000433b0: 6964 2074 6f72 7265 6e74 5f69 6e66 6f3a id torrent_info: │ │ │ -000433c0: 3a61 6464 5f74 7261 636b 6572 2873 7464 :add_tracker(std │ │ │ -000433d0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ -000433e0: 6d70 3b20 7572 6c2c 2069 6e74 2063 6f6e mp; url, int con │ │ │ -000433f0: 7374 2074 6965 7229 0a09 7b0a 0909 6164 st tier)..{...ad │ │ │ -00043400: 645f 7472 6163 6b65 7228 7572 6c2c 2074 d_tracker(url, t │ │ │ -00043410: 6965 722c 2061 6e6e 6f75 6e63 655f 656e ier, announce_en │ │ │ -00043420: 7472 793a 3a73 6f75 7263 655f 636c 6965 try::source_clie │ │ │ -00043430: 6e74 293b 0a09 7d0a 0a09 766f 6964 2074 nt);..}...void t │ │ │ -00043440: 6f72 7265 6e74 5f69 6e66 6f3a 3a61 6464 orrent_info::add │ │ │ -00043450: 5f74 7261 636b 6572 2873 7464 3a3a 7374 _tracker(std::st │ │ │ -00043460: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ -00043470: 7572 6c2c 2069 6e74 2063 6f6e 7374 2074 url, int const t │ │ │ -00043480: 6965 720a 0909 2c20 616e 6e6f 756e 6365 ier..., announce │ │ │ -00043490: 5f65 6e74 7279 3a3a 7472 6163 6b65 725f _entry::tracker_ │ │ │ -000434a0: 736f 7572 6365 2063 6f6e 7374 2073 6f75 source const sou │ │ │ -000434b0: 7263 6529 0a09 7b0a 0909 544f 5252 454e rce)..{...TORREN │ │ │ -000434c0: 545f 4153 5345 5254 5f50 5245 434f 4e44 T_ASSERT_PRECOND │ │ │ -000434d0: 2821 7572 6c2e 656d 7074 7928 2929 3b0a (!url.empty());. │ │ │ -000434e0: 0909 6175 746f 2063 6f6e 7374 2069 203d ..auto const i = │ │ │ -000434f0: 2073 7464 3a3a 6669 6e64 5f69 6628 6d5f std::find_if(m_ │ │ │ -00043500: 7572 6c73 2e62 6567 696e 2829 2c20 6d5f urls.begin(), m_ │ │ │ -00043510: 7572 6c73 2e65 6e64 2829 0a09 0909 2c20 urls.end()...., │ │ │ -00043520: 5b26 616d 703b 7572 6c5d 2861 6e6e 6f75 [&url](annou │ │ │ -00043530: 6e63 655f 656e 7472 7920 636f 6e73 7426 nce_entry const& │ │ │ -00043540: 616d 703b 2061 6529 207b 2072 6574 7572 amp; ae) { retur │ │ │ -00043550: 6e20 6165 2e75 726c 203d 3d20 7572 6c3b n ae.url == url; │ │ │ -00043560: 207d 293b 0a09 0969 6620 2869 2021 3d20 });...if (i != │ │ │ -00043570: 6d5f 7572 6c73 2e65 6e64 2829 2920 7265 m_urls.end()) re │ │ │ -00043580: 7475 726e 3b0a 0909 6966 2028 216c 743a turn;...if (!lt: │ │ │ -00043590: 3a61 7578 3a3a 6973 5f76 616c 6964 5f74 :aux::is_valid_t │ │ │ -000435a0: 7261 636b 6572 5f75 726c 2875 726c 2929 racker_url(url)) │ │ │ -000435b0: 2072 6574 7572 6e3b 0a0a 0909 616e 6e6f return;....anno │ │ │ -000435c0: 756e 6365 5f65 6e74 7279 2065 2875 726c unce_entry e(url │ │ │ -000435d0: 293b 0a09 0965 2e74 6965 7220 3d20 7374 );...e.tier = st │ │ │ -000435e0: 643a 3a75 696e 7438 5f74 2874 6965 7229 d::uint8_t(tier) │ │ │ -000435f0: 3b0a 0909 652e 736f 7572 6365 203d 2073 ;...e.source = s │ │ │ -00043600: 6f75 7263 653b 0a09 096d 5f75 726c 732e ource;...m_urls. │ │ │ -00043610: 7075 7368 5f62 6163 6b28 6529 3b0a 0a09 push_back(e);... │ │ │ -00043620: 0973 7464 3a3a 736f 7274 286d 5f75 726c .std::sort(m_url │ │ │ -00043630: 732e 6265 6769 6e28 292c 206d 5f75 726c s.begin(), m_url │ │ │ -00043640: 732e 656e 6428 290a 0909 092c 205b 5d20 s.end()...., [] │ │ │ -00043650: 2861 6e6e 6f75 6e63 655f 656e 7472 7920 (announce_entry │ │ │ -00043660: 636f 6e73 7426 616d 703b 206c 6873 2c20 const& lhs, │ │ │ -00043670: 616e 6e6f 756e 6365 5f65 6e74 7279 2063 announce_entry c │ │ │ -00043680: 6f6e 7374 2661 6d70 3b20 7268 7329 0a09 onst& rhs).. │ │ │ -00043690: 0909 7b20 7265 7475 726e 206c 6873 2e74 ..{ return lhs.t │ │ │ -000436a0: 6965 7220 266c 743b 2072 6873 2e74 6965 ier < rhs.tie │ │ │ -000436b0: 723b 207d 293b 0a09 7d0a 0a09 766f 6964 r; });..}...void │ │ │ -000436c0: 2074 6f72 7265 6e74 5f69 6e66 6f3a 3a63 torrent_info::c │ │ │ -000436d0: 6c65 6172 5f74 7261 636b 6572 7328 290a lear_trackers(). │ │ │ -000436e0: 097b 0a09 096d 5f75 726c 732e 636c 6561 .{...m_urls.clea │ │ │ -000436f0: 7228 293b 0a09 7d0a 3c2f 7072 653e 3c2f r();..}.
    relevan │ │ │ -00043730: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/posix_ │ │ │ -00043770: 7061 7274 5f66 696c 652e 6370 703a 3331 part_file.cpp:31 │ │ │ -00043780: 363c 2f61 3e3c 2f74 643e 3c74 643e 7768 6wh │ │ │ -00043790: 6174 2064 6f20 7765 2064 6f20 6966 2073 at do we do if s │ │ │ -000437a0: 6f6d 656f 6e65 2069 7320 6375 7272 656e omeone is curren │ │ │ -000437b0: 746c 7920 7265 6164 696e 6720 6672 6f6d tly reading from │ │ │ -000437c0: 2074 6865 2064 6973 6b20 6672 6f6d 2074 the disk from t │ │ │ -000437d0: 6869 7320 7069 6563 653f 2064 6f65 7320 his piece? does │ │ │ -000437e0: 6974 206d 6174 7465 723f 2053 696e 6365 it matter? Since │ │ │ -000437f0: 2077 6520 776f 6e27 7420 6163 7469 7665 we won't active │ │ │ -00043800: 6c79 2065 7261 7365 2074 6865 2064 6174 ly erase the dat │ │ │ -00043810: 6120 6672 6f6d 2064 6973 6b2c 2062 7574 a from disk, but │ │ │ -00043820: 2069 7420 6d61 7920 6265 206f 7665 7277 it may be overw │ │ │ -00043830: 7269 7474 656e 2073 6f6f 6e2c 2069 7427 ritten soon, it' │ │ │ -00043840: 7320 7072 6f62 6162 6c79 206e 6f74 2074 s probably not t │ │ │ -00043850: 6861 7420 6269 6720 6f66 2061 2064 6561 hat big of a dea │ │ │ -00043860: 6c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 l

    w │ │ │ -000438b0: 6861 7420 646f 2077 6520 646f 2069 6620 hat do we do if │ │ │ -000438c0: 736f 6d65 6f6e 6520 6973 2063 7572 7265 someone is curre │ │ │ -000438d0: 6e74 6c79 2072 6561 6469 6e67 2066 726f ntly reading fro │ │ │ -000438e0: 6d20 7468 6520 6469 736b 0a66 726f 6d20 m the disk.from │ │ │ -000438f0: 7468 6973 2070 6965 6365 3f20 646f 6573 this piece? does │ │ │ -00043900: 2069 7420 6d61 7474 6572 3f20 5369 6e63 it matter? Sinc │ │ │ -00043910: 6520 7765 2077 6f6e 2774 2061 6374 6976 e we won't activ │ │ │ -00043920: 656c 7920 6572 6173 6520 7468 650a 6461 ely erase the.da │ │ │ -00043930: 7461 2066 726f 6d20 6469 736b 2c20 6275 ta from disk, bu │ │ │ -00043940: 7420 6974 206d 6179 2062 6520 6f76 6572 t it may be over │ │ │ -00043950: 7772 6974 7465 6e20 736f 6f6e 2c20 6974 written soon, it │ │ │ -00043960: 2773 2070 726f 6261 626c 7920 6e6f 7420 's probably not │ │ │ -00043970: 7468 6174 0a62 6967 206f 6620 6120 6465 that.big of a de │ │ │ -00043980: 616c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 al

    ../sr │ │ │ -00043990: 632f 706f 7369 785f 7061 7274 5f66 696c c/posix_part_fil │ │ │ -000439a0: 652e 6370 703a 3331 363c 2f68 343e 3c70 e.cpp:316

    ....if ( │ │ │ -000439f0: 6563 2920 7265 7475 726e 207b 7d3b 0a0a ec) return {};.. │ │ │ -00043a00: 2369 6664 6566 2054 4f52 5245 4e54 5f57 #ifdef TORRENT_W │ │ │ -00043a10: 494e 444f 5753 0a09 0909 7265 7420 3d20 INDOWS....ret = │ │ │ -00043a20: 6669 6c65 5f70 6f69 6e74 6572 283a 3a5f file_pointer(::_ │ │ │ -00043a30: 7766 6f70 656e 2863 6f6e 7665 7274 5f74 wfopen(convert_t │ │ │ -00043a40: 6f5f 6e61 7469 7665 5f70 6174 685f 7374 o_native_path_st │ │ │ -00043a50: 7269 6e67 2866 6e29 2e63 5f73 7472 2829 ring(fn).c_str() │ │ │ -00043a60: 2c20 4c22 7762 2b22 2929 3b0a 2365 6c73 , L"wb+"));.#els │ │ │ -00043a70: 650a 0909 0972 6574 203d 2066 696c 655f e....ret = file_ │ │ │ -00043a80: 706f 696e 7465 7228 3a3a 666f 7065 6e28 pointer(::fopen( │ │ │ -00043a90: 666e 2e63 5f73 7472 2829 2c20 2277 622b fn.c_str(), "wb+ │ │ │ -00043aa0: 2229 293b 0a23 656e 6469 660a 0909 0969 "));.#endif....i │ │ │ -00043ab0: 6620 2872 6574 2e66 696c 6528 2920 3d3d f (ret.file() == │ │ │ -00043ac0: 206e 756c 6c70 7472 290a 0909 0909 6563 nullptr).....ec │ │ │ -00043ad0: 2e61 7373 6967 6e28 6572 726e 6f2c 2067 .assign(errno, g │ │ │ -00043ae0: 656e 6572 6963 5f63 6174 6567 6f72 7928 eneric_category( │ │ │ -00043af0: 2929 3b0a 0909 7d0a 0909 6966 2028 6563 ));...}...if (ec │ │ │ -00043b00: 2920 7265 7475 726e 207b 7d3b 0a09 0972 ) return {};...r │ │ │ -00043b10: 6574 7572 6e20 7265 743b 0a09 7d0a 0a09 eturn ret;..}... │ │ │ -00043b20: 766f 6964 2070 6f73 6978 5f70 6172 745f void posix_part_ │ │ │ -00043b30: 6669 6c65 3a3a 6672 6565 5f70 6965 6365 file::free_piece │ │ │ -00043b40: 2870 6965 6365 5f69 6e64 6578 5f74 2063 (piece_index_t c │ │ │ -00043b50: 6f6e 7374 2070 6965 6365 290a 097b 0a09 onst piece)..{.. │ │ │ -00043b60: 0961 7574 6f20 636f 6e73 7420 6920 3d20 .auto const i = │ │ │ -00043b70: 6d5f 7069 6563 655f 6d61 702e 6669 6e64 m_piece_map.find │ │ │ -00043b80: 2870 6965 6365 293b 0a09 0969 6620 2869 (piece);...if (i │ │ │ -00043b90: 203d 3d20 6d5f 7069 6563 655f 6d61 702e == m_piece_map. │ │ │ -00043ba0: 656e 6428 2929 2072 6574 7572 6e3b 0a0a end()) return;.. │ │ │ -00043bb0: 3c64 6976 2073 7479 6c65 3d22 6261 636b

    .< │ │ │ -00043be0: 2f64 6976 3e09 096d 5f66 7265 655f 736c /div>..m_free_sl │ │ │ -00043bf0: 6f74 732e 7075 7368 5f62 6163 6b28 692d ots.push_back(i- │ │ │ -00043c00: 2667 743b 7365 636f 6e64 293b 0a09 096d >second);...m │ │ │ -00043c10: 5f70 6965 6365 5f6d 6170 2e65 7261 7365 _piece_map.erase │ │ │ -00043c20: 2869 293b 0a09 096d 5f64 6972 7479 5f6d (i);...m_dirty_m │ │ │ -00043c30: 6574 6164 6174 6120 3d20 7472 7565 3b0a etadata = true;. │ │ │ -00043c40: 097d 0a0a 0976 6f69 6420 706f 7369 785f .}...void posix_ │ │ │ -00043c50: 7061 7274 5f66 696c 653a 3a6d 6f76 655f part_file::move_ │ │ │ -00043c60: 7061 7274 6669 6c65 2873 7464 3a3a 7374 partfile(std::st │ │ │ -00043c70: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ -00043c80: 7061 7468 2c20 6572 726f 725f 636f 6465 path, error_code │ │ │ -00043c90: 2661 6d70 3b20 6563 290a 097b 0a09 0966 & ec)..{...f │ │ │ -00043ca0: 6c75 7368 5f6d 6574 6164 6174 615f 696d lush_metadata_im │ │ │ -00043cb0: 706c 2865 6329 3b0a 0909 6966 2028 6563 pl(ec);...if (ec │ │ │ -00043cc0: 2920 7265 7475 726e 3b0a 0a09 0969 6620 ) return;....if │ │ │ -00043cd0: 2821 6d5f 7069 6563 655f 6d61 702e 656d (!m_piece_map.em │ │ │ -00043ce0: 7074 7928 2929 0a09 097b 0a09 0909 7374 pty())...{....st │ │ │ -00043cf0: 643a 3a73 7472 696e 6720 6f6c 645f 7061 d::string old_pa │ │ │ -00043d00: 7468 203d 2063 6f6d 6269 6e65 5f70 6174 th = combine_pat │ │ │ -00043d10: 6828 6d5f 7061 7468 2c20 6d5f 6e61 6d65 h(m_path, m_name │ │ │ -00043d20: 293b 0a09 0909 7374 643a 3a73 7472 696e );....std::strin │ │ │ -00043d30: 6720 6e65 775f 7061 7468 203d 2063 6f6d g new_path = com │ │ │ -00043d40: 6269 6e65 5f70 6174 6828 7061 7468 2c20 bine_path(path, │ │ │ -00043d50: 6d5f 6e61 6d65 293b 0a0a 0909 0972 656e m_name);.....ren │ │ │ -00043d60: 616d 6528 6f6c 645f 7061 7468 2c20 6e65 ame(old_path, ne │ │ │ -00043d70: 775f 7061 7468 2c20 6563 293b 0a09 0909 w_path, ec);.... │ │ │ -00043d80: 6966 2028 6563 203d 3d20 626f 6f73 743a if (ec == boost: │ │ │ -00043d90: 3a73 7973 7465 6d3a 3a65 7272 633a 3a6e :system::errc::n │ │ │ -00043da0: 6f5f 7375 6368 5f66 696c 655f 6f72 5f64 o_such_file_or_d │ │ │ -00043db0: 6972 6563 746f 7279 290a 0909 0909 6563 irectory).....ec │ │ │ -00043dc0: 2e63 6c65 6172 2829 3b0a 0a09 0909 6966 .clear();.....if │ │ │ -00043dd0: 2028 6563 290a 0909 097b 0a09 0909 0973 (ec)....{.....s │ │ │ -00043de0: 746f 7261 6765 5f65 7272 6f72 2073 653b torage_error se; │ │ │ -00043df0: 0a09 0909 0961 7578 3a3a 636f 7079 5f66 .....aux::copy_f │ │ │ -00043e00: 696c 6528 6f6c 645f 7061 7468 2c20 6e65 ile(old_path, ne │ │ │ -00043e10: 775f 7061 7468 2c20 7365 293b 0a09 0909 w_path, se);.... │ │ │ -00043e20: 0965 6320 3d20 7365 2e65 633b 0a09 0909 .ec = se.ec;.... │ │ │ -00043e30: 0969 6620 2865 6329 2072 6574 7572 6e3b .if (ec) return; │ │ │ -00043e40: 0a09 0909 0972 656d 6f76 6528 6f6c 645f .....remove(old_ │ │ │ -00043e50: 7061 7468 2c20 6563 293b 0a09 0909 7d0a path, ec);....}. │ │ │ -00043e60: 0909 7d0a 0909 6d5f 7061 7468 203d 2070 ..}...m_path = p │ │ │ -00043e70: 6174 683b 0a09 7d0a 3c2f 7072 653e 3c2f ath;..}.relevan │ │ │ -00043eb0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/posix_ │ │ │ -00043ef0: 7061 7274 5f66 696c 652e 6370 703a 3430 part_file.cpp:40 │ │ │ -00043f00: 383c 2f61 3e3c 2f74 643e 3c74 643e 696e 8in │ │ │ -00043f10: 7374 6561 6420 6f66 2072 6562 7569 6c64 stead of rebuild │ │ │ -00043f20: 696e 6720 7468 6520 7768 6f6c 6520 6669 ing the whole fi │ │ │ -00043f30: 6c65 2068 6561 6465 7220 616e 6420 666c le header and fl │ │ │ -00043f40: 7573 6869 6e67 2069 742c 2075 7064 6174 ushing it, updat │ │ │ -00043f50: 6520 7468 6520 736c 6f74 2065 6e74 7269 e the slot entri │ │ │ -00043f60: 6573 2061 7320 7765 2067 6f3c 2f74 643e es as we go │ │ │ -00043f70: 3c2f 7472 3e3c 7472 2069 643d 2231 3638

    instead │ │ │ -00043fc0: 206f 6620 7265 6275 696c 6469 6e67 2074 of rebuilding t │ │ │ -00043fd0: 6865 2077 686f 6c65 2066 696c 6520 6865 he whole file he │ │ │ -00043fe0: 6164 6572 0a61 6e64 2066 6c75 7368 696e ader.and flushin │ │ │ -00043ff0: 6720 6974 2c20 7570 6461 7465 2074 6865 g it, update the │ │ │ -00044000: 2073 6c6f 7420 656e 7472 6965 7320 6173 slot entries as │ │ │ -00044010: 2077 6520 676f 3c2f 6832 3e3c 6834 3e2e we go

    . │ │ │ -00044020: 2e2f 7372 632f 706f 7369 785f 7061 7274 ./src/posix_part │ │ │ -00044030: 5f66 696c 652e 6370 703a 3430 383c 2f68 _file.cpp:408
    ....
    │ │ │ -00044080: 0909 6563 2e61 7373 6967 6e28 6572 726e  ..ec.assign(errn
    │ │ │ -00044090: 6f2c 2067 656e 6572 6963 5f63 6174 6567  o, generic_categ
    │ │ │ -000440a0: 6f72 7928 2929 3b0a 0909 0909 0965 6c73  ory());......els
    │ │ │ -000440b0: 650a 0909 0909 0909 6563 2e61 7373 6967  e.......ec.assig
    │ │ │ -000440c0: 6e28 6572 726f 7273 3a3a 6669 6c65 5f74  n(errors::file_t
    │ │ │ -000440d0: 6f6f 5f73 686f 7274 2c20 6c69 6274 6f72  oo_short, libtor
    │ │ │ -000440e0: 7265 6e74 5f63 6174 6567 6f72 7928 2929  rent_category())
    │ │ │ -000440f0: 3b0a 0909 0909 7d0a 0a09 0909 0969 6620  ;.....}......if 
    │ │ │ -00044100: 2865 6329 2072 6574 7572 6e3b 0a0a 0909  (ec) return;....
    │ │ │ -00044110: 0909 6628 6669 6c65 5f6f 6666 7365 742c  ..f(file_offset,
    │ │ │ -00044120: 207b 6275 662e 6765 7428 292c 2062 6c6f   {buf.get(), blo
    │ │ │ -00044130: 636b 5f74 6f5f 636f 7079 7d29 3b0a 0909  ck_to_copy});...
    │ │ │ -00044140: 097d 0a09 0909 6669 6c65 5f6f 6666 7365  .}....file_offse
    │ │ │ -00044150: 7420 2b3d 2062 6c6f 636b 5f74 6f5f 636f  t += block_to_co
    │ │ │ -00044160: 7079 3b0a 0909 0970 6965 6365 5f6f 6666  py;....piece_off
    │ │ │ -00044170: 7365 7420 3d20 303b 0a09 0909 7369 7a65  set = 0;....size
    │ │ │ -00044180: 202d 3d20 626c 6f63 6b5f 746f 5f63 6f70   -= block_to_cop
    │ │ │ -00044190: 793b 0a09 097d 0a09 7d0a 0a09 766f 6964  y;...}..}...void
    │ │ │ -000441a0: 2070 6f73 6978 5f70 6172 745f 6669 6c65   posix_part_file
    │ │ │ -000441b0: 3a3a 666c 7573 685f 6d65 7461 6461 7461  ::flush_metadata
    │ │ │ -000441c0: 2865 7272 6f72 5f63 6f64 6526 616d 703b  (error_code&
    │ │ │ -000441d0: 2065 6329 0a09 7b0a 0909 666c 7573 685f   ec)..{...flush_
    │ │ │ -000441e0: 6d65 7461 6461 7461 5f69 6d70 6c28 6563  metadata_impl(ec
    │ │ │ -000441f0: 293b 0a09 7d0a 0a3c 6469 7620 7374 796c  );..}..
    .void posix │ │ │ -00044230: 5f70 6172 745f 6669 6c65 3a3a 666c 7573 _part_file::flus │ │ │ -00044240: 685f 6d65 7461 6461 7461 5f69 6d70 6c28 h_metadata_impl( │ │ │ -00044250: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ -00044260: 6563 290a 3c2f 6469 763e 097b 0a09 092f ec).
    .{.../ │ │ │ -00044270: 2f20 646f 2077 6520 6e65 6564 2074 6f20 / do we need to │ │ │ -00044280: 666c 7573 6820 7468 6520 6d65 7461 6461 flush the metada │ │ │ -00044290: 7461 3f0a 0909 6966 2028 6d5f 6469 7274 ta?...if (m_dirt │ │ │ -000442a0: 795f 6d65 7461 6461 7461 203d 3d20 6661 y_metadata == fa │ │ │ -000442b0: 6c73 6529 2072 6574 7572 6e3b 0a0a 0909 lse) return;.... │ │ │ -000442c0: 6966 2028 6d5f 7069 6563 655f 6d61 702e if (m_piece_map. │ │ │ -000442d0: 656d 7074 7928 2929 0a09 097b 0a09 0909 empty())...{.... │ │ │ -000442e0: 2f2f 2069 6620 7765 2064 6f6e 2774 2068 // if we don't h │ │ │ -000442f0: 6176 6520 616e 7920 7069 6563 6573 206c ave any pieces l │ │ │ -00044300: 6566 7420 696e 2074 6865 0a09 0909 2f2f eft in the....// │ │ │ -00044310: 2070 6172 7420 6669 6c65 2c20 7265 6d6f part file, remo │ │ │ -00044320: 7665 2069 740a 0909 0973 7464 3a3a 7374 ve it....std::st │ │ │ -00044330: 7269 6e67 2063 6f6e 7374 2070 203d 2063 ring const p = c │ │ │ -00044340: 6f6d 6269 6e65 5f70 6174 6828 6d5f 7061 ombine_path(m_pa │ │ │ -00044350: 7468 2c20 6d5f 6e61 6d65 293b 0a09 0909 th, m_name);.... │ │ │ -00044360: 7265 6d6f 7665 2870 2c20 6563 293b 0a0a remove(p, ec);.. │ │ │ -00044370: 0909 0969 6620 2865 6320 3d3d 2062 6f6f ...if (ec == boo │ │ │ -00044380: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ -00044390: 3a3a 6e6f 5f73 7563 685f 6669 6c65 5f6f ::no_such_file_o │ │ │ -000443a0: 725f 6469 7265 6374 6f72 7929 0a09 0909 r_directory).... │ │ │ -000443b0: 0965 632e 636c 6561 7228 293b 0a09 0909 .ec.clear();.... │ │ │ -000443c0: 7265 7475 726e 3b0a 0909 7d0a 0a09 0961 return;...}....a │ │ │ -000443d0: 7574 6f20 6620 3d20 6f70 656e 5f66 696c uto f = open_fil │ │ │ -000443e0: 6528 6f70 656e 5f6d 6f64 653a 3a72 6561 e(open_mode::rea │ │ │ -000443f0: 645f 7772 6974 652c 2065 6329 3b0a 0909 d_write, ec);... │ │ │ -00044400: 6966 2028 6563 2920 7265 7475 726e 3b0a if (ec) return;. │ │ │ -00044410: 0a09 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ -00044420: 743b 6368 6172 2667 743b 2068 6561 6465 t;char> heade │ │ │ -00044430: 7228 7374 6174 6963 5f63 6173 7426 6c74 r(static_cast< │ │ │ -00044440: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ -00044450: 286d 5f68 6561 6465 725f 7369 7a65 2929 (m_header_size)) │ │ │ -00044460: 3b0a 0a09 0975 7369 6e67 206e 616d 6573 ;....using names │ │ │ -00044470: 7061 6365 206c 6962 746f 7272 656e 743a pace libtorrent: │ │ │ -00044480: 3a61 7578 3b0a 0a09 0963 6861 722a 2070 :aux;....char* p │ │ │ -00044490: 7472 203d 2068 6561 6465 722e 6461 7461 tr = header.data │ │ │ -000444a0: 2829 3b0a 0909 7772 6974 655f 7569 6e74 ();...write_uint │ │ │ -000444b0: 3332 286d 5f6d 6178 5f70 6965 6365 732c 32(m_max_pieces, │ │ │ -000444c0: 2070 7472 293b 0a09 0977 7269 7465 5f75 ptr);...write_u │ │ │ -000444d0: 696e 7433 3228 6d5f 7069 6563 655f 7369 int32(m_piece_si │ │ │ -000444e0: 7a65 2c20 7074 7229 3b0a 0a09 0966 6f72 ze, ptr);....for │ │ │ -000444f0: 2028 7069 6563 655f 696e 6465 785f 7420 (piece_index_t │ │ │ -00044500: 7069 6563 6528 3029 3b20 7069 6563 6520 piece(0); piece │ │ │ -00044510: 266c 743b 2070 6965 6365 5f69 6e64 6578 < piece_index │ │ │ -00044520: 5f74 286d 5f6d 6178 5f70 6965 6365 7329 _t(m_max_pieces) │ │ │ -00044530: 3b20 2b2b 7069 6563 6529 0a09 097b 0a09 ; ++piece)...{.. │ │ │ -00044540: 0909 6175 746f 2063 6f6e 7374 2069 203d ..auto const i = │ │ │ -00044550: 206d 5f70 6965 6365 5f6d 6170 2e66 696e m_piece_map.fin │ │ │ -00044560: 6428 7069 6563 6529 3b0a 3c2f 7072 653e d(piece);.
    │ │ │ -00044570: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000445a0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -000445b0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/file │ │ │ -000445e0: 5f73 746f 7261 6765 2e63 7070 3a31 3239 _storage.cpp:129 │ │ │ -000445f0: 3c2f 613e 3c2f 7464 3e3c 7464 3e61 7420 at │ │ │ -00044600: 6170 7065 6172 7320 7365 745f 6e61 6d65 appears set_name │ │ │ -00044610: 2069 7320 616c 7761 7973 2074 7275 653c is always true< │ │ │ -00044620: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    at │ │ │ -00044670: 6170 7065 6172 7320 7365 745f 6e61 6d65 appears set_name │ │ │ -00044680: 2069 7320 616c 7761 7973 2074 7275 653c is always true< │ │ │ -00044690: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f66 /h2>

    ../src/f │ │ │ -000446a0: 696c 655f 7374 6f72 6167 652e 6370 703a ile_storage.cpp: │ │ │ -000446b0: 3132 393c 2f68 343e 3c70 7265 2073 7479 129

    ..return stati
    │ │ │ -00044700: 635f 6361 7374 266c 743b 696e 7426 6774  c_cast<int>
    │ │ │ -00044710: 3b28 0a09 0909 7374 643a 3a6d 696e 2873  ;(....std::min(s
    │ │ │ -00044720: 7461 7469 635f 6361 7374 266c 743b 7374  tatic_cast<st
    │ │ │ -00044730: 643a 3a75 696e 7436 345f 7426 6774 3b28  d::uint64_t>(
    │ │ │ -00044740: 7069 6563 655f 6c65 6e67 7468 2829 292c  piece_length()),
    │ │ │ -00044750: 2066 696c 655f 6974 6572 2d26 6774 3b6f   file_iter->o
    │ │ │ -00044760: 6666 7365 7420 2d20 7461 7267 6574 2e6f  ffset - target.o
    │ │ │ -00044770: 6666 7365 7429 293b 0a09 7d0a 0a09 696e  ffset));..}...in
    │ │ │ -00044780: 7420 6669 6c65 5f73 746f 7261 6765 3a3a  t file_storage::
    │ │ │ -00044790: 626c 6f63 6b73 5f69 6e5f 7069 6563 6532  blocks_in_piece2
    │ │ │ -000447a0: 2870 6965 6365 5f69 6e64 6578 5f74 2063  (piece_index_t c
    │ │ │ -000447b0: 6f6e 7374 2069 6e64 6578 2920 636f 6e73  onst index) cons
    │ │ │ -000447c0: 740a 097b 0a09 092f 2f20 7468 6520 6e75  t..{...// the nu
    │ │ │ -000447d0: 6d62 6572 206f 6620 6465 6661 756c 745f  mber of default_
    │ │ │ -000447e0: 626c 6f63 6b5f 7369 7a65 2069 6e20 6120  block_size in a 
    │ │ │ -000447f0: 7069 6563 6520 7369 7a65 2c20 726f 756e  piece size, roun
    │ │ │ -00044800: 6469 6e67 2075 700a 0909 7265 7475 726e  ding up...return
    │ │ │ -00044810: 2028 7069 6563 655f 7369 7a65 3228 696e   (piece_size2(in
    │ │ │ -00044820: 6465 7829 202b 2064 6566 6175 6c74 5f62  dex) + default_b
    │ │ │ -00044830: 6c6f 636b 5f73 697a 6520 2d20 3129 202f  lock_size - 1) /
    │ │ │ -00044840: 2064 6566 6175 6c74 5f62 6c6f 636b 5f73   default_block_s
    │ │ │ -00044850: 697a 653b 0a09 7d0a 0a09 696e 7420 6669  ize;..}...int fi
    │ │ │ -00044860: 6c65 5f73 746f 7261 6765 3a3a 626c 6f63  le_storage::bloc
    │ │ │ -00044870: 6b73 5f70 6572 5f70 6965 6365 2829 2063  ks_per_piece() c
    │ │ │ -00044880: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e  onst..{...return
    │ │ │ -00044890: 2028 6d5f 7069 6563 655f 6c65 6e67 7468   (m_piece_length
    │ │ │ -000448a0: 202b 2064 6566 6175 6c74 5f62 6c6f 636b   + default_block
    │ │ │ -000448b0: 5f73 697a 6520 2d20 3129 202f 2064 6566  _size - 1) / def
    │ │ │ -000448c0: 6175 6c74 5f62 6c6f 636b 5f73 697a 653b  ault_block_size;
    │ │ │ -000448d0: 0a09 7d0a 0a09 2f2f 2070 6174 6820 6973  ..}...// path is
    │ │ │ -000448e0: 2073 7570 706f 7365 6420 746f 2069 6e63   supposed to inc
    │ │ │ -000448f0: 6c75 6465 2074 6865 206e 616d 6520 6f66  lude the name of
    │ │ │ -00044900: 2074 6865 2074 6f72 7265 6e74 2069 7473   the torrent its
    │ │ │ -00044910: 656c 662e 0a09 2f2f 206f 7220 616e 2061  elf...// or an a
    │ │ │ -00044920: 6273 6f6c 7574 6520 7061 7468 2c20 746f  bsolute path, to
    │ │ │ -00044930: 206d 6f76 6520 6120 6669 6c65 206f 7574   move a file out
    │ │ │ -00044940: 7369 6465 206f 6620 7468 6520 646f 776e  side of the down
    │ │ │ -00044950: 6c6f 6164 2064 6972 6563 746f 7279 0a09  load directory..
    │ │ │ -00044960: 766f 6964 2066 696c 655f 7374 6f72 6167  void file_storag
    │ │ │ -00044970: 653a 3a75 7064 6174 655f 7061 7468 5f69  e::update_path_i
    │ │ │ -00044980: 6e64 6578 2861 7578 3a3a 6669 6c65 5f65  ndex(aux::file_e
    │ │ │ -00044990: 6e74 7279 2661 6d70 3b20 650a 0909 2c20  ntry& e..., 
    │ │ │ -000449a0: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ -000449b0: 7426 616d 703b 2070 6174 682c 2062 6f6f  t& path, boo
    │ │ │ -000449c0: 6c20 636f 6e73 7420 7365 745f 6e61 6d65  l const set_name
    │ │ │ -000449d0: 290a 097b 0a3c 6469 7620 7374 796c 653d  )..{.
    ..if (is_comp │ │ │ -00044a10: 6c65 7465 2870 6174 6829 290a 3c2f 6469 lete(path))...{....TORRENT │ │ │ -00044a30: 5f41 5353 4552 5428 7365 745f 6e61 6d65 _ASSERT(set_name │ │ │ -00044a40: 293b 0a09 0909 652e 7365 745f 6e61 6d65 );....e.set_name │ │ │ -00044a50: 2870 6174 6829 3b0a 0909 0965 2e70 6174 (path);....e.pat │ │ │ -00044a60: 685f 696e 6465 7820 3d20 6175 783a 3a66 h_index = aux::f │ │ │ -00044a70: 696c 655f 656e 7472 793a 3a70 6174 685f ile_entry::path_ │ │ │ -00044a80: 6973 5f61 6273 6f6c 7574 653b 0a09 0909 is_absolute;.... │ │ │ -00044a90: 7265 7475 726e 3b0a 0909 7d0a 0a09 0954 return;...}....T │ │ │ -00044aa0: 4f52 5245 4e54 5f41 5353 4552 5428 7061 ORRENT_ASSERT(pa │ │ │ -00044ab0: 7468 5b30 5d20 213d 2027 2f27 293b 0a0a th[0] != '/');.. │ │ │ -00044ac0: 0909 2f2f 2073 706c 6974 2074 6865 2073 ..// split the s │ │ │ -00044ad0: 7472 696e 6720 696e 746f 2074 6865 206c tring into the l │ │ │ -00044ae0: 6561 6620 6669 6c65 6e61 6d65 0a09 092f eaf filename.../ │ │ │ -00044af0: 2f20 616e 6420 7468 6520 6272 616e 6368 / and the branch │ │ │ -00044b00: 2070 6174 680a 0909 6175 746f 205b 6272 path...auto [br │ │ │ -00044b10: 616e 6368 5f70 6174 682c 206c 6561 665d anch_path, leaf] │ │ │ -00044b20: 203d 2072 7370 6c69 745f 7061 7468 2870 = rsplit_path(p │ │ │ -00044b30: 6174 6829 3b0a 0a09 0969 6620 2862 7261 ath);....if (bra │ │ │ -00044b40: 6e63 685f 7061 7468 2e65 6d70 7479 2829 nch_path.empty() │ │ │ -00044b50: 290a 0909 7b0a 0909 0969 6620 2873 6574 )...{....if (set │ │ │ -00044b60: 5f6e 616d 6529 2065 2e73 6574 5f6e 616d _name) e.set_nam │ │ │ -00044b70: 6528 6c65 6166 293b 0a09 0909 652e 7061 e(leaf);....e.pa │ │ │ -00044b80: 7468 5f69 6e64 6578 203d 2061 7578 3a3a th_index = aux:: │ │ │ -00044b90: 6669 6c65 5f65 6e74 7279 3a3a 6e6f 5f70 file_entry::no_p │ │ │ -00044ba0: 6174 683b 0a09 0909 7265 7475 726e 3b0a ath;....return;. │ │ │ -00044bb0: 0909 7d0a 0a09 092f 2f20 6966 2074 6865 ..}....// if the │ │ │ -00044bc0: 2070 6174 6820 2a64 6f65 732a 2063 6f6e path *does* con │ │ │ -00044bd0: 7461 696e 2074 6865 206e 616d 6520 6f66 tain the name of │ │ │ -00044be0: 2074 6865 2074 6f72 7265 6e74 2028 6173 the torrent (as │ │ │ -00044bf0: 2077 6520 6578 7065 6374 290a 0909 2f2f we expect)...// │ │ │ -00044c00: 2073 7472 6970 2069 7420 6265 666f 7265 strip it before │ │ │ -00044c10: 2061 6464 696e 6720 6974 2074 6f20 6d5f adding it to m_ │ │ │ -00044c20: 7061 7468 730a 0909 6966 2028 6c73 706c paths...if (lspl │ │ │ -00044c30: 6974 5f70 6174 6828 6272 616e 6368 5f70 it_path(branch_p │ │ │ -00044c40: 6174 6829 2e66 6972 7374 203d 3d20 6d5f ath).first == m_ │ │ │ -00044c50: 6e61 6d65 290a 0909 7b0a 0909 0962 7261 name)...{....bra │ │ │ -00044c60: 6e63 685f 7061 7468 203d 206c 7370 6c69 nch_path = lspli │ │ │ -00044c70: 745f 7061 7468 2862 7261 6e63 685f 7061 t_path(branch_pa │ │ │ -00044c80: 7468 292e 7365 636f 6e64 3b0a 0909 092f th).second;..../ │ │ │ -00044c90: 2f20 7374 7269 7020 6475 706c 6963 6174 / strip duplicat │ │ │ -00044ca0: 6520 7365 7061 7261 746f 7273 0a09 0909 e separators.... │ │ │ -00044cb0: 7768 696c 6520 2821 6272 616e 6368 5f70 while (!branch_p │ │ │ -00044cc0: 6174 682e 656d 7074 7928 2920 2661 6d70 ath.empty() & │ │ │ -00044cd0: 3b26 616d 703b 2028 6272 616e 6368 5f70 ;& (branch_p │ │ │ -00044ce0: 6174 682e 6672 6f6e 7428 2920 3d3d 2054 ath.front() == T │ │ │ -00044cf0: 4f52 5245 4e54 5f53 4550 4152 4154 4f52 ORRENT_SEPARATOR │ │ │ -00044d00: 0a23 6966 2064 6566 696e 6564 2854 4f52 .#if defined(TOR │ │ │ -00044d10: 5245 4e54 5f57 494e 444f 5753 2920 7c7c RENT_WINDOWS) || │ │ │ -00044d20: 2064 6566 696e 6564 2854 4f52 5245 4e54 defined(TORRENT │ │ │ -00044d30: 5f4f 5332 290a 0909 0909 7c7c 2062 7261 _OS2).....|| bra │ │ │ -00044d40: 6e63 685f 7061 7468 2e66 726f 6e74 2829 nch_path.front() │ │ │ -00044d50: 203d 3d20 272f 270a 2365 6e64 6966 0a3c == '/'.#endif.< │ │ │ -00044d60: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00044d70: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00044d80: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00044d90: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00044da0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00044dd0: 2f66 696c 655f 7374 6f72 6167 652e 6370 /file_storage.cp │ │ │ -00044de0: 703a 3536 323c 2f61 3e3c 2f74 643e 3c74 p:562maybe it would │ │ │ -00044e00: 2062 6520 6e69 6365 2074 6f20 6861 7665 be nice to have │ │ │ -00044e10: 2061 2062 6574 7465 7220 696e 6465 7820 a better index │ │ │ -00044e20: 6865 7265 3c2f 7464 3e3c 2f74 723e 3c74 heremaybe it would │ │ │ -00044e80: 2062 6520 6e69 6365 2074 6f20 6861 7665 be nice to have │ │ │ -00044e90: 2061 2062 6574 7465 7220 696e 6465 7820 a better index │ │ │ -00044ea0: 6865 7265 3c2f 6832 3e3c 6834 3e2e 2e2f here

    ../ │ │ │ -00044eb0: 7372 632f 6669 6c65 5f73 746f 7261 6765 src/file_storage │ │ │ -00044ec0: 2e63 7070 3a35 3632 3c2f 6834 3e3c 7072 .cpp:562

    ..auto fi │ │ │ -00044f10: 6c65 5f69 7465 7220 3d20 7374 643a 3a75 le_iter = std::u │ │ │ -00044f20: 7070 6572 5f62 6f75 6e64 280a 0909 096d pper_bound(....m │ │ │ -00044f30: 5f66 696c 6573 2e62 6567 696e 2829 2c20 _files.begin(), │ │ │ -00044f40: 6d5f 6669 6c65 732e 656e 6428 292c 2074 m_files.end(), t │ │ │ -00044f50: 6172 6765 742c 2063 6f6d 7061 7265 5f66 arget, compare_f │ │ │ -00044f60: 696c 655f 6f66 6673 6574 293b 0a0a 0909 ile_offset);.... │ │ │ -00044f70: 544f 5252 454e 545f 4153 5345 5254 2866 TORRENT_ASSERT(f │ │ │ -00044f80: 696c 655f 6974 6572 2021 3d20 6d5f 6669 ile_iter != m_fi │ │ │ -00044f90: 6c65 732e 6265 6769 6e28 2929 3b0a 0909 les.begin());... │ │ │ -00044fa0: 2d2d 6669 6c65 5f69 7465 723b 0a09 0972 --file_iter;...r │ │ │ -00044fb0: 6574 7572 6e20 6669 6c65 5f69 6e64 6578 eturn file_index │ │ │ -00044fc0: 5f74 7b69 6e74 2866 696c 655f 6974 6572 _t{int(file_iter │ │ │ -00044fd0: 202d 206d 5f66 696c 6573 2e62 6567 696e - m_files.begin │ │ │ -00044fe0: 2829 297d 3b0a 097d 0a0a 0966 696c 655f ())};..}...file_ │ │ │ -00044ff0: 696e 6465 785f 7420 6669 6c65 5f73 746f index_t file_sto │ │ │ -00045000: 7261 6765 3a3a 6669 6c65 5f69 6e64 6578 rage::file_index │ │ │ -00045010: 5f61 745f 7069 6563 6528 7069 6563 655f _at_piece(piece_ │ │ │ -00045020: 696e 6465 785f 7420 636f 6e73 7420 7069 index_t const pi │ │ │ -00045030: 6563 6529 2063 6f6e 7374 0a09 7b0a 0909 ece) const..{... │ │ │ -00045040: 7265 7475 726e 2066 696c 655f 696e 6465 return file_inde │ │ │ -00045050: 785f 6174 5f6f 6666 7365 7428 7374 6174 x_at_offset(stat │ │ │ -00045060: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ -00045070: 743b 2870 6965 6365 2920 2a20 7374 643a t;(piece) * std: │ │ │ -00045080: 3a69 6e74 3634 5f74 2870 6965 6365 5f6c :int64_t(piece_l │ │ │ -00045090: 656e 6774 6828 2929 293b 0a09 7d0a 0a09 ength()));..}... │ │ │ -000450a0: 6669 6c65 5f69 6e64 6578 5f74 2066 696c file_index_t fil │ │ │ -000450b0: 655f 7374 6f72 6167 653a 3a6c 6173 745f e_storage::last_ │ │ │ -000450c0: 6669 6c65 5f69 6e64 6578 5f61 745f 7069 file_index_at_pi │ │ │ -000450d0: 6563 6528 7069 6563 655f 696e 6465 785f ece(piece_index_ │ │ │ -000450e0: 7420 636f 6e73 7420 7069 6563 6529 2063 t const piece) c │ │ │ -000450f0: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e onst..{...return │ │ │ -00045100: 2066 696c 655f 696e 6465 785f 6174 5f6f file_index_at_o │ │ │ -00045110: 6666 7365 7428 7374 6174 6963 5f63 6173 ffset(static_cas │ │ │ -00045120: 7426 6c74 3b69 6e74 2667 743b 2870 6965 t<int>(pie │ │ │ -00045130: 6365 2920 2a20 7374 643a 3a69 6e74 3634 ce) * std::int64 │ │ │ -00045140: 5f74 2870 6965 6365 5f6c 656e 6774 6828 _t(piece_length( │ │ │ -00045150: 2929 202b 2070 6965 6365 5f73 697a 6528 )) + piece_size( │ │ │ -00045160: 7069 6563 6529 202d 2031 293b 0a09 7d0a piece) - 1);..}. │ │ │ -00045170: 0a09 6669 6c65 5f69 6e64 6578 5f74 2066 ..file_index_t f │ │ │ -00045180: 696c 655f 7374 6f72 6167 653a 3a66 696c ile_storage::fil │ │ │ -00045190: 655f 696e 6465 785f 666f 725f 726f 6f74 e_index_for_root │ │ │ -000451a0: 2873 6861 3235 365f 6861 7368 2063 6f6e (sha256_hash con │ │ │ -000451b0: 7374 2661 6d70 3b20 726f 6f74 5f68 6173 st& root_has │ │ │ -000451c0: 6829 2063 6f6e 7374 0a09 7b0a 3c64 6976 h) const..{.
    ..for │ │ │ -00045200: 2866 696c 655f 696e 6465 785f 7420 636f (file_index_t co │ │ │ -00045210: 6e73 7420 6920 3a20 6669 6c65 5f72 616e nst i : file_ran │ │ │ -00045220: 6765 2829 290a 3c2f 6469 763e 0909 7b0a ge()).
    ..{. │ │ │ -00045230: 0909 0969 6620 2872 6f6f 7428 6929 203d ...if (root(i) = │ │ │ -00045240: 3d20 726f 6f74 5f68 6173 6829 2072 6574 = root_hash) ret │ │ │ -00045250: 7572 6e20 693b 0a09 097d 0a09 0972 6574 urn i;...}...ret │ │ │ -00045260: 7572 6e20 6669 6c65 5f69 6e64 6578 5f74 urn file_index_t │ │ │ -00045270: 7b2d 317d 3b0a 097d 0a0a 0970 6965 6365 {-1};..}...piece │ │ │ -00045280: 5f69 6e64 6578 5f74 2066 696c 655f 7374 _index_t file_st │ │ │ -00045290: 6f72 6167 653a 3a70 6965 6365 5f69 6e64 orage::piece_ind │ │ │ -000452a0: 6578 5f61 745f 6669 6c65 2866 696c 655f ex_at_file(file_ │ │ │ -000452b0: 696e 6465 785f 7420 6629 2063 6f6e 7374 index_t f) const │ │ │ -000452c0: 0a09 7b0a 0909 7265 7475 726e 2070 6965 ..{...return pie │ │ │ -000452d0: 6365 5f69 6e64 6578 5f74 7b61 7578 3a3a ce_index_t{aux:: │ │ │ -000452e0: 6e75 6d65 7269 635f 6361 7374 266c 743b numeric_cast< │ │ │ -000452f0: 696e 7426 6774 3b28 6669 6c65 5f6f 6666 int>(file_off │ │ │ -00045300: 7365 7428 6629 202f 2070 6965 6365 5f6c set(f) / piece_l │ │ │ -00045310: 656e 6774 6828 2929 7d3b 0a09 7d0a 0a09 ength())};..}... │ │ │ -00045320: 7069 6563 655f 696e 6465 785f 7420 6669 piece_index_t fi │ │ │ -00045330: 6c65 5f73 746f 7261 6765 3a3a 6c61 7374 le_storage::last │ │ │ -00045340: 5f70 6965 6365 5f69 6e64 6578 5f61 745f _piece_index_at_ │ │ │ -00045350: 6669 6c65 2866 696c 655f 696e 6465 785f file(file_index_ │ │ │ -00045360: 7420 6629 2063 6f6e 7374 0a09 7b0a 0909 t f) const..{... │ │ │ -00045370: 7265 7475 726e 2070 6965 6365 5f69 6e64 return piece_ind │ │ │ -00045380: 6578 5f74 7b61 7578 3a3a 6e75 6d65 7269 ex_t{aux::numeri │ │ │ -00045390: 635f 6361 7374 266c 743b 696e 7426 6774 c_cast<int> │ │ │ -000453a0: 3b28 2866 696c 655f 6f66 6673 6574 2866 ;((file_offset(f │ │ │ -000453b0: 2920 2b20 6669 6c65 5f73 697a 6528 6629 ) + file_size(f) │ │ │ -000453c0: 202d 2031 2920 2f20 7069 6563 655f 6c65 - 1) / piece_le │ │ │ -000453d0: 6e67 7468 2829 297d 3b0a 097d 0a0a 2369 ngth())};..}..#i │ │ │ -000453e0: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -000453f0: 5253 494f 4e20 266c 743b 3d20 320a 0963 RSION <= 2..c │ │ │ -00045400: 6861 7220 636f 6e73 742a 2066 696c 655f har const* file_ │ │ │ -00045410: 7374 6f72 6167 653a 3a66 696c 655f 6e61 storage::file_na │ │ │ -00045420: 6d65 5f70 7472 2866 696c 655f 696e 6465 me_ptr(file_inde │ │ │ -00045430: 785f 7420 636f 6e73 7420 696e 6465 7829 x_t const index) │ │ │ -00045440: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475 const..{...retu │ │ │ -00045450: 726e 206d 5f66 696c 6573 5b69 6e64 6578 rn m_files[index │ │ │ -00045460: 5d2e 6e61 6d65 3b0a 097d 0a0a 0969 6e74 ].name;..}...int │ │ │ -00045470: 2066 696c 655f 7374 6f72 6167 653a 3a66 file_storage::f │ │ │ -00045480: 696c 655f 6e61 6d65 5f6c 656e 2866 696c ile_name_len(fil │ │ │ -00045490: 655f 696e 6465 785f 7420 636f 6e73 7420 e_index_t const │ │ │ -000454a0: 696e 6465 7829 2063 6f6e 7374 0a09 7b0a index) const..{. │ │ │ -000454b0: 0909 6966 2028 6d5f 6669 6c65 735b 696e ..if (m_files[in │ │ │ -000454c0: 6465 785d 2e6e 616d 655f 6c65 6e20 3d3d dex].name_len == │ │ │ -000454d0: 2061 7578 3a3a 6669 6c65 5f65 6e74 7279 aux::file_entry │ │ │ -000454e0: 3a3a 6e61 6d65 5f69 735f 6f77 6e65 6429 ::name_is_owned) │ │ │ -000454f0: 0a09 0909 7265 7475 726e 202d 313b 0a09 ....return -1;.. │ │ │ -00045500: 0972 6574 7572 6e20 6d5f 6669 6c65 735b .return m_files[ │ │ │ -00045510: 696e 6465 785d 2e6e 616d 655f 6c65 6e3b index].name_len; │ │ │ -00045520: 0a09 7d0a 2365 6e64 6966 0a0a 3c2f 7072 ..}.#endif..
    rel │ │ │ -00045560: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0
    ../src/fi │ │ │ -000455a0: 6c65 5f73 746f 7261 6765 2e63 7070 3a31 le_storage.cpp:1 │ │ │ -000455b0: 3136 363c 2f61 3e3c 2f74 643e 3c74 643e 166 │ │ │ -000455c0: 646f 2077 6520 7374 696c 6c20 6e65 6564 do we still need │ │ │ -000455d0: 2074 6869 7320 6361 7365 3f3c 2f74 643e this case? │ │ │ -000455e0: 3c2f 7472 3e3c 7472 2069 643d 2231 3731

    do we s │ │ │ -00045630: 7469 6c6c 206e 6565 6420 7468 6973 2063 till need this c │ │ │ -00045640: 6173 653f 3c2f 6832 3e3c 6834 3e2e 2e2f ase?

    ../ │ │ │ -00045650: 7372 632f 6669 6c65 5f73 746f 7261 6765 src/file_storage │ │ │ -00045660: 2e63 7070 3a31 3136 363c 2f68 343e 3c70 .cpp:1166

    ....proc │ │ │ -000456b0: 6573 735f 7374 7269 6e67 5f6c 6f77 6572 ess_string_lower │ │ │ -000456c0: 6361 7365 2863 7263 2c20 7029 3b0a 0909 case(crc, p);... │ │ │ -000456d0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -000456e0: 2870 2e73 697a 6528 2920 2667 743b 2030 (p.size() > 0 │ │ │ -000456f0: 293b 0a09 0909 0954 4f52 5245 4e54 5f41 );.....TORRENT_A │ │ │ -00045700: 5353 4552 5428 705b 702e 7369 7a65 2829 SSERT(p[p.size() │ │ │ -00045710: 202d 2031 5d20 213d 2054 4f52 5245 4e54 - 1] != TORRENT │ │ │ -00045720: 5f53 4550 4152 4154 4f52 293b 0a09 0909 _SEPARATOR);.... │ │ │ -00045730: 0963 7263 2e70 726f 6365 7373 5f62 7974 .crc.process_byt │ │ │ -00045740: 6528 544f 5252 454e 545f 5345 5041 5241 e(TORRENT_SEPARA │ │ │ -00045750: 544f 5229 3b0a 0909 097d 0a09 0909 7072 TOR);....}....pr │ │ │ -00045760: 6f63 6573 735f 7374 7269 6e67 5f6c 6f77 ocess_string_low │ │ │ -00045770: 6572 6361 7365 2863 7263 2c20 6665 2e66 ercase(crc, fe.f │ │ │ -00045780: 696c 656e 616d 6528 2929 3b0a 0909 7d0a ilename());...}. │ │ │ -00045790: 0a09 0972 6574 7572 6e20 6372 632e 6368 ...return crc.ch │ │ │ -000457a0: 6563 6b73 756d 2829 3b0a 097d 0a0a 0973 ecksum();..}...s │ │ │ -000457b0: 7464 3a3a 7374 7269 6e67 2066 696c 655f td::string file_ │ │ │ -000457c0: 7374 6f72 6167 653a 3a66 696c 655f 7061 storage::file_pa │ │ │ -000457d0: 7468 2866 696c 655f 696e 6465 785f 7420 th(file_index_t │ │ │ -000457e0: 636f 6e73 7420 696e 6465 782c 2073 7464 const index, std │ │ │ -000457f0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ -00045800: 6d70 3b20 7361 7665 5f70 6174 6829 2063 mp; save_path) c │ │ │ -00045810: 6f6e 7374 0a09 7b0a 0909 544f 5252 454e onst..{...TORREN │ │ │ -00045820: 545f 4153 5345 5254 5f50 5245 434f 4e44 T_ASSERT_PRECOND │ │ │ -00045830: 2869 6e64 6578 2026 6774 3b3d 2066 696c (index >= fil │ │ │ -00045840: 655f 696e 6465 785f 7428 3029 2026 616d e_index_t(0) &am │ │ │ -00045850: 703b 2661 6d70 3b20 696e 6465 7820 266c p;& index &l │ │ │ -00045860: 743b 2065 6e64 5f66 696c 6528 2929 3b0a t; end_file());. │ │ │ -00045870: 0909 6175 783a 3a66 696c 655f 656e 7472 ..aux::file_entr │ │ │ -00045880: 7920 636f 6e73 7426 616d 703b 2066 6520 y const& fe │ │ │ -00045890: 3d20 6d5f 6669 6c65 735b 696e 6465 785d = m_files[index] │ │ │ -000458a0: 3b0a 0a09 0973 7464 3a3a 7374 7269 6e67 ;....std::string │ │ │ -000458b0: 2072 6574 3b0a 0a09 0969 6620 2866 652e ret;....if (fe. │ │ │ -000458c0: 7061 7468 5f69 6e64 6578 203d 3d20 6175 path_index == au │ │ │ -000458d0: 783a 3a66 696c 655f 656e 7472 793a 3a70 x::file_entry::p │ │ │ -000458e0: 6174 685f 6973 5f61 6273 6f6c 7574 6529 ath_is_absolute) │ │ │ -000458f0: 0a09 097b 0a3c 6469 7620 7374 796c 653d ...{.

    ...ret = fe.f │ │ │ -00045930: 696c 656e 616d 6528 293b 0a3c 2f64 6976 ilename();.
    ..}...else if ( │ │ │ -00045950: 6665 2e70 6174 685f 696e 6465 7820 3d3d fe.path_index == │ │ │ -00045960: 2061 7578 3a3a 6669 6c65 5f65 6e74 7279 aux::file_entry │ │ │ -00045970: 3a3a 6e6f 5f70 6174 6829 0a09 097b 0a09 ::no_path)...{.. │ │ │ -00045980: 0909 7265 742e 7265 7365 7276 6528 7361 ..ret.reserve(sa │ │ │ -00045990: 7665 5f70 6174 682e 7369 7a65 2829 202b ve_path.size() + │ │ │ -000459a0: 2066 652e 6669 6c65 6e61 6d65 2829 2e73 fe.filename().s │ │ │ -000459b0: 697a 6528 2920 2b20 3129 3b0a 0909 0972 ize() + 1);....r │ │ │ -000459c0: 6574 2e61 7373 6967 6e28 7361 7665 5f70 et.assign(save_p │ │ │ -000459d0: 6174 6829 3b0a 0909 0961 7070 656e 645f ath);....append_ │ │ │ -000459e0: 7061 7468 2872 6574 2c20 6665 2e66 696c path(ret, fe.fil │ │ │ -000459f0: 656e 616d 6528 2929 3b0a 0909 7d0a 0909 ename());...}... │ │ │ -00045a00: 656c 7365 2069 6620 2866 652e 6e6f 5f72 else if (fe.no_r │ │ │ -00045a10: 6f6f 745f 6469 7229 0a09 097b 0a09 0909 oot_dir)...{.... │ │ │ -00045a20: 7374 643a 3a73 7472 696e 6720 636f 6e73 std::string cons │ │ │ -00045a30: 7426 616d 703b 2070 203d 206d 5f70 6174 t& p = m_pat │ │ │ -00045a40: 6873 5b66 652e 7061 7468 5f69 6e64 6578 hs[fe.path_index │ │ │ -00045a50: 5d3b 0a0a 0909 0972 6574 2e72 6573 6572 ];.....ret.reser │ │ │ -00045a60: 7665 2873 6176 655f 7061 7468 2e73 697a ve(save_path.siz │ │ │ -00045a70: 6528 2920 2b20 702e 7369 7a65 2829 202b e() + p.size() + │ │ │ -00045a80: 2066 652e 6669 6c65 6e61 6d65 2829 2e73 fe.filename().s │ │ │ -00045a90: 697a 6528 2920 2b20 3229 3b0a 0909 0972 ize() + 2);....r │ │ │ -00045aa0: 6574 2e61 7373 6967 6e28 7361 7665 5f70 et.assign(save_p │ │ │ -00045ab0: 6174 6829 3b0a 0909 0961 7070 656e 645f ath);....append_ │ │ │ -00045ac0: 7061 7468 2872 6574 2c20 7029 3b0a 0909 path(ret, p);... │ │ │ -00045ad0: 0961 7070 656e 645f 7061 7468 2872 6574 .append_path(ret │ │ │ -00045ae0: 2c20 6665 2e66 696c 656e 616d 6528 2929 , fe.filename()) │ │ │ -00045af0: 3b0a 0909 7d0a 0909 656c 7365 0a09 097b ;...}...else...{ │ │ │ -00045b00: 0a09 0909 7374 643a 3a73 7472 696e 6720 ....std::string │ │ │ -00045b10: 636f 6e73 7426 616d 703b 2070 203d 206d const& p = m │ │ │ -00045b20: 5f70 6174 6873 5b66 652e 7061 7468 5f69 _paths[fe.path_i │ │ │ -00045b30: 6e64 6578 5d3b 0a0a 0909 0972 6574 2e72 ndex];.....ret.r │ │ │ -00045b40: 6573 6572 7665 2873 6176 655f 7061 7468 eserve(save_path │ │ │ -00045b50: 2e73 697a 6528 2920 2b20 6d5f 6e61 6d65 .size() + m_name │ │ │ -00045b60: 2e73 697a 6528 2920 2b20 702e 7369 7a65 .size() + p.size │ │ │ -00045b70: 2829 202b 2066 652e 6669 6c65 6e61 6d65 () + fe.filename │ │ │ -00045b80: 2829 2e73 697a 6528 2920 2b20 3329 3b0a ().size() + 3);. │ │ │ -00045b90: 0909 0972 6574 2e61 7373 6967 6e28 7361 ...ret.assign(sa │ │ │ -00045ba0: 7665 5f70 6174 6829 3b0a 0909 0961 7070 ve_path);....app │ │ │ -00045bb0: 656e 645f 7061 7468 2872 6574 2c20 6d5f end_path(ret, m_ │ │ │ -00045bc0: 6e61 6d65 293b 0a09 0909 6170 7065 6e64 name);....append │ │ │ -00045bd0: 5f70 6174 6828 7265 742c 2070 293b 0a09 _path(ret, p);.. │ │ │ -00045be0: 0909 6170 7065 6e64 5f70 6174 6828 7265 ..append_path(re │ │ │ -00045bf0: 742c 2066 652e 6669 6c65 6e61 6d65 2829 t, fe.filename() │ │ │ -00045c00: 293b 0a09 097d 0a0a 0909 2f2f 2061 2073 );...}....// a s │ │ │ -00045c10: 696e 676c 6520 7265 7475 726e 2073 7461 ingle return sta │ │ │ -00045c20: 7465 6d65 6e74 2c20 6a75 7374 2074 6f20 tement, just to │ │ │ -00045c30: 6d61 6b65 204e 5256 4f20 6d6f 7265 206c make NRVO more l │ │ │ -00045c40: 696b 656c 7920 746f 206b 6963 6b20 696e ikely to kick in │ │ │ -00045c50: 0a09 0972 6574 7572 6e20 7265 743b 0a09 ...return ret;.. │ │ │ -00045c60: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -00045c90: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00045ca0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00045cd0: 7372 632f 6669 6c65 5f73 746f 7261 6765 src/file_storage │ │ │ -00045ce0: 2e63 7070 3a31 3330 373c 2f61 3e3c 2f74 .cpp:1307deprecated │ │ │ -00045d00: 2074 6869 732e 2044 6f20 7765 206e 6565 this. Do we nee │ │ │ -00045d10: 6420 6669 6c65 5f73 746f 7261 6765 2074 d file_storage t │ │ │ -00045d20: 6f20 7375 7070 6f72 7420 6162 736f 6c75 o support absolu │ │ │ -00045d30: 7465 2070 6174 6873 3f3c 2f74 643e 3c2f te paths?

    deprecate │ │ │ -00045d90: 6420 7468 6973 2e20 446f 2077 6520 6e65 d this. Do we ne │ │ │ -00045da0: 6564 2066 696c 655f 7374 6f72 6167 6520 ed file_storage │ │ │ -00045db0: 746f 2073 7570 706f 7274 2061 6273 6f6c to support absol │ │ │ -00045dc0: 7574 6520 7061 7468 733f 3c2f 6832 3e3c ute paths?

    < │ │ │ -00045dd0: 6834 3e2e 2e2f 7372 632f 6669 6c65 5f73 h4>../src/file_s │ │ │ -00045de0: 746f 7261 6765 2e63 7070 3a31 3330 373c torage.cpp:1307< │ │ │ -00045df0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .}
    │ │ │ -00045e30: 0a0a 0969 6e74 2066 696c 655f 7374 6f72  ...int file_stor
    │ │ │ -00045e40: 6167 653a 3a66 696c 655f 6669 7273 745f  age::file_first_
    │ │ │ -00045e50: 626c 6f63 6b5f 6e6f 6465 2866 696c 655f  block_node(file_
    │ │ │ -00045e60: 696e 6465 785f 7420 696e 6465 7829 2063  index_t index) c
    │ │ │ -00045e70: 6f6e 7374 0a09 7b0a 0909 544f 5252 454e  onst..{...TORREN
    │ │ │ -00045e80: 545f 4153 5345 5254 5f50 5245 434f 4e44  T_ASSERT_PRECOND
    │ │ │ -00045e90: 2869 6e64 6578 2026 6774 3b3d 2066 696c  (index >= fil
    │ │ │ -00045ea0: 655f 696e 6465 785f 7428 3029 2026 616d  e_index_t(0) &am
    │ │ │ -00045eb0: 703b 2661 6d70 3b20 696e 6465 7820 266c  p;& index &l
    │ │ │ -00045ec0: 743b 2065 6e64 5f66 696c 6528 2929 3b0a  t; end_file());.
    │ │ │ -00045ed0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -00045ee0: 5f50 5245 434f 4e44 286d 5f70 6965 6365  _PRECOND(m_piece
    │ │ │ -00045ef0: 5f6c 656e 6774 6820 2667 743b 2030 293b  _length > 0);
    │ │ │ -00045f00: 0a09 0969 6e74 2063 6f6e 7374 206c 6561  ...int const lea
    │ │ │ -00045f10: 665f 6c61 7965 725f 7369 7a65 203d 206d  f_layer_size = m
    │ │ │ -00045f20: 6572 6b6c 655f 6e75 6d5f 6c65 6166 7328  erkle_num_leafs(
    │ │ │ -00045f30: 6669 6c65 5f6e 756d 5f62 6c6f 636b 7328  file_num_blocks(
    │ │ │ -00045f40: 696e 6465 7829 293b 0a09 0972 6574 7572  index));...retur
    │ │ │ -00045f50: 6e20 6d65 726b 6c65 5f6e 756d 5f6e 6f64  n merkle_num_nod
    │ │ │ -00045f60: 6573 286c 6561 665f 6c61 7965 725f 7369  es(leaf_layer_si
    │ │ │ -00045f70: 7a65 2920 2d20 6c65 6166 5f6c 6179 6572  ze) - leaf_layer
    │ │ │ -00045f80: 5f73 697a 653b 0a09 7d0a 0a09 6669 6c65  _size;..}...file
    │ │ │ -00045f90: 5f66 6c61 6773 5f74 2066 696c 655f 7374  _flags_t file_st
    │ │ │ -00045fa0: 6f72 6167 653a 3a66 696c 655f 666c 6167  orage::file_flag
    │ │ │ -00045fb0: 7328 6669 6c65 5f69 6e64 6578 5f74 2063  s(file_index_t c
    │ │ │ -00045fc0: 6f6e 7374 2069 6e64 6578 2920 636f 6e73  onst index) cons
    │ │ │ -00045fd0: 740a 097b 0a09 0954 4f52 5245 4e54 5f41  t..{...TORRENT_A
    │ │ │ -00045fe0: 5353 4552 545f 5052 4543 4f4e 4428 696e  SSERT_PRECOND(in
    │ │ │ -00045ff0: 6465 7820 2667 743b 3d20 6669 6c65 5f69  dex >= file_i
    │ │ │ -00046000: 6e64 6578 5f74 2830 2920 2661 6d70 3b26  ndex_t(0) &&
    │ │ │ -00046010: 616d 703b 2069 6e64 6578 2026 6c74 3b20  amp; index < 
    │ │ │ -00046020: 656e 645f 6669 6c65 2829 293b 0a09 0961  end_file());...a
    │ │ │ -00046030: 7578 3a3a 6669 6c65 5f65 6e74 7279 2063  ux::file_entry c
    │ │ │ -00046040: 6f6e 7374 2661 6d70 3b20 6665 203d 206d  onst& fe = m
    │ │ │ -00046050: 5f66 696c 6573 5b69 6e64 6578 5d3b 0a09  _files[index];..
    │ │ │ -00046060: 0972 6574 7572 6e20 2866 652e 7061 645f  .return (fe.pad_
    │ │ │ -00046070: 6669 6c65 203f 2066 696c 655f 7374 6f72  file ? file_stor
    │ │ │ -00046080: 6167 653a 3a66 6c61 675f 7061 645f 6669  age::flag_pad_fi
    │ │ │ -00046090: 6c65 203a 2066 696c 655f 666c 6167 735f  le : file_flags_
    │ │ │ -000460a0: 747b 7d29 0a09 0909 7c20 2866 652e 6869  t{})....| (fe.hi
    │ │ │ -000460b0: 6464 656e 5f61 7474 7269 6275 7465 203f  dden_attribute ?
    │ │ │ -000460c0: 2066 696c 655f 7374 6f72 6167 653a 3a66   file_storage::f
    │ │ │ -000460d0: 6c61 675f 6869 6464 656e 203a 2066 696c  lag_hidden : fil
    │ │ │ -000460e0: 655f 666c 6167 735f 747b 7d29 0a09 0909  e_flags_t{})....
    │ │ │ -000460f0: 7c20 2866 652e 6578 6563 7574 6162 6c65  | (fe.executable
    │ │ │ -00046100: 5f61 7474 7269 6275 7465 203f 2066 696c  _attribute ? fil
    │ │ │ -00046110: 655f 7374 6f72 6167 653a 3a66 6c61 675f  e_storage::flag_
    │ │ │ -00046120: 6578 6563 7574 6162 6c65 203a 2066 696c  executable : fil
    │ │ │ -00046130: 655f 666c 6167 735f 747b 7d29 0a09 0909  e_flags_t{})....
    │ │ │ -00046140: 7c20 2866 652e 7379 6d6c 696e 6b5f 6174  | (fe.symlink_at
    │ │ │ -00046150: 7472 6962 7574 6520 3f20 6669 6c65 5f73  tribute ? file_s
    │ │ │ -00046160: 746f 7261 6765 3a3a 666c 6167 5f73 796d  torage::flag_sym
    │ │ │ -00046170: 6c69 6e6b 203a 2066 696c 655f 666c 6167  link : file_flag
    │ │ │ -00046180: 735f 747b 7d29 3b0a 097d 0a0a 3c64 6976  s_t{});..}..
    .bool │ │ │ -000461c0: 6669 6c65 5f73 746f 7261 6765 3a3a 6669 file_storage::fi │ │ │ -000461d0: 6c65 5f61 6273 6f6c 7574 655f 7061 7468 le_absolute_path │ │ │ -000461e0: 2866 696c 655f 696e 6465 785f 7420 636f (file_index_t co │ │ │ -000461f0: 6e73 7420 696e 6465 7829 2063 6f6e 7374 nst index) const │ │ │ -00046200: 0a3c 2f64 6976 3e09 7b0a 0909 544f 5252 .
    .{...TORR │ │ │ -00046210: 454e 545f 4153 5345 5254 5f50 5245 434f ENT_ASSERT_PRECO │ │ │ -00046220: 4e44 2869 6e64 6578 2026 6774 3b3d 2066 ND(index >= f │ │ │ -00046230: 696c 655f 696e 6465 785f 7428 3029 2026 ile_index_t(0) & │ │ │ -00046240: 616d 703b 2661 6d70 3b20 696e 6465 7820 amp;& index │ │ │ -00046250: 266c 743b 2065 6e64 5f66 696c 6528 2929 < end_file()) │ │ │ -00046260: 3b0a 0909 6175 783a 3a66 696c 655f 656e ;...aux::file_en │ │ │ -00046270: 7472 7920 636f 6e73 7426 616d 703b 2066 try const& f │ │ │ -00046280: 6520 3d20 6d5f 6669 6c65 735b 696e 6465 e = m_files[inde │ │ │ -00046290: 785d 3b0a 0909 7265 7475 726e 2066 652e x];...return fe. │ │ │ -000462a0: 7061 7468 5f69 6e64 6578 203d 3d20 6175 path_index == au │ │ │ -000462b0: 783a 3a66 696c 655f 656e 7472 793a 3a70 x::file_entry::p │ │ │ -000462c0: 6174 685f 6973 5f61 6273 6f6c 7574 653b ath_is_absolute; │ │ │ -000462d0: 0a09 7d0a 0a23 6966 2054 4f52 5245 4e54 ..}..#if TORRENT │ │ │ -000462e0: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ -000462f0: 310a 0973 6861 315f 6861 7368 2066 696c 1..sha1_hash fil │ │ │ -00046300: 655f 7374 6f72 6167 653a 3a68 6173 6828 e_storage::hash( │ │ │ -00046310: 6175 783a 3a66 696c 655f 656e 7472 7920 aux::file_entry │ │ │ -00046320: 636f 6e73 7426 616d 703b 2066 6529 2063 const& fe) c │ │ │ -00046330: 6f6e 7374 0a09 7b0a 0909 696e 7420 636f onst..{...int co │ │ │ -00046340: 6e73 7420 696e 6465 7820 3d20 696e 7428 nst index = int( │ │ │ -00046350: 2661 6d70 3b66 6520 2d20 2661 6d70 3b6d &fe - &m │ │ │ -00046360: 5f66 696c 6573 2e66 726f 6e74 2829 293b _files.front()); │ │ │ -00046370: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00046380: 545f 5052 4543 4f4e 4428 696e 6465 7820 T_PRECOND(index │ │ │ -00046390: 2667 743b 3d20 6669 6c65 5f69 6e64 6578 >= file_index │ │ │ -000463a0: 5f74 7b7d 2026 616d 703b 2661 6d70 3b20 _t{} && │ │ │ -000463b0: 696e 6465 7820 266c 743b 2065 6e64 5f66 index < end_f │ │ │ -000463c0: 696c 6528 2929 3b0a 0909 6966 2028 696e ile());...if (in │ │ │ -000463d0: 6465 7820 2667 743b 3d20 696e 7428 6d5f dex >= int(m_ │ │ │ -000463e0: 6669 6c65 5f68 6173 6865 732e 7369 7a65 file_hashes.size │ │ │ -000463f0: 2829 2929 2072 6574 7572 6e20 7368 6131 ())) return sha1 │ │ │ -00046400: 5f68 6173 6828 6e75 6c6c 7074 7229 3b0a _hash(nullptr);. │ │ │ -00046410: 0909 7265 7475 726e 2073 6861 315f 6861 ..return sha1_ha │ │ │ -00046420: 7368 286d 5f66 696c 655f 6861 7368 6573 sh(m_file_hashes │ │ │ -00046430: 5b69 6e64 6578 5d29 3b0a 097d 0a0a 0973 [index]);..}...s │ │ │ -00046440: 7464 3a3a 7374 7269 6e67 2066 696c 655f td::string file_ │ │ │ -00046450: 7374 6f72 6167 653a 3a73 796d 6c69 6e6b storage::symlink │ │ │ -00046460: 2861 7578 3a3a 6669 6c65 5f65 6e74 7279 (aux::file_entry │ │ │ -00046470: 2063 6f6e 7374 2661 6d70 3b20 6665 2920 const& fe) │ │ │ -00046480: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ -00046490: 4e54 5f41 5353 4552 545f 5052 4543 4f4e NT_ASSERT_PRECON │ │ │ -000464a0: 4428 6665 2e73 796d 6c69 6e6b 5f69 6e64 D(fe.symlink_ind │ │ │ -000464b0: 6578 2026 6c74 3b20 696e 7428 6d5f 7379 ex < int(m_sy │ │ │ -000464c0: 6d6c 696e 6b73 2e73 697a 6528 2929 293b mlinks.size())); │ │ │ -000464d0: 0a09 0972 6574 7572 6e20 6d5f 7379 6d6c ...return m_syml │ │ │ -000464e0: 696e 6b73 5b66 652e 7379 6d6c 696e 6b5f inks[fe.symlink_ │ │ │ -000464f0: 696e 6465 785d 3b0a 097d 0a0a 0973 7464 index];..}...std │ │ │ -00046500: 3a3a 7469 6d65 5f74 2066 696c 655f 7374 ::time_t file_st │ │ │ -00046510: 6f72 6167 653a 3a6d 7469 6d65 2861 7578 orage::mtime(aux │ │ │ -00046520: 3a3a 6669 6c65 5f65 6e74 7279 2063 6f6e ::file_entry con │ │ │ -00046530: 7374 2661 6d70 3b20 6665 2920 636f 6e73 st& fe) cons │ │ │ -00046540: 740a 097b 0a09 0969 6e74 2063 6f6e 7374 t..{...int const │ │ │ -00046550: 2069 6e64 6578 203d 2069 6e74 2826 616d index = int(&am │ │ │ -00046560: 703b 6665 202d 2026 616d 703b 6d5f 6669 p;fe - &m_fi │ │ │ -00046570: 6c65 732e 6672 6f6e 7428 2929 3b0a 0909 les.front());... │ │ │ -00046580: 544f 5252 454e 545f 4153 5345 5254 5f50 TORRENT_ASSERT_P │ │ │ -00046590: 5245 434f 4e44 2869 6e64 6578 2026 6774 RECOND(index > │ │ │ -000465a0: 3b3d 2066 696c 655f 696e 6465 785f 747b ;= file_index_t{ │ │ │ -000465b0: 7d20 2661 6d70 3b26 616d 703b 2069 6e64 } && ind │ │ │ -000465c0: 6578 2026 6c74 3b20 656e 645f 6669 6c65 ex < end_file │ │ │ -000465d0: 2829 293b 0a09 0969 6620 2869 6e64 6578 ());...if (index │ │ │ -000465e0: 2026 6774 3b3d 2069 6e74 286d 5f6d 7469 >= int(m_mti │ │ │ -000465f0: 6d65 2e73 697a 6528 2929 2920 7265 7475 me.size())) retu │ │ │ -00046600: 726e 2030 3b0a 0909 7265 7475 726e 206d rn 0;...return m │ │ │ -00046610: 5f6d 7469 6d65 5b69 6e64 6578 5d3b 0a09 _mtime[index];.. │ │ │ -00046620: 7d0a 0a09 696e 7420 6669 6c65 5f73 746f }...int file_sto │ │ │ -00046630: 7261 6765 3a3a 6669 6c65 5f69 6e64 6578 rage::file_index │ │ │ -00046640: 2861 7578 3a3a 6669 6c65 5f65 6e74 7279 (aux::file_entry │ │ │ -00046650: 2063 6f6e 7374 2661 6d70 3b20 6665 2920 const& fe) │ │ │ -00046660: 636f 6e73 740a 3c2f 7072 653e 3c2f 7464 const.
    relevance │ │ │ -000466a0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -000466b0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/file_sto │ │ │ -000466e0: 7261 6765 2e63 7070 3a31 3432 313c 2f61 rage.cpp:1421this w │ │ │ -00046700: 6f75 6c64 2062 6520 6d6f 7265 2065 6666 ould be more eff │ │ │ -00046710: 6963 6965 6e74 2069 6620 6d5f 7061 7468 icient if m_path │ │ │ -00046720: 7320 7761 7320 736f 7274 6564 2066 6972 s was sorted fir │ │ │ -00046730: 7374 2c20 7375 6368 2074 6861 7420 6120 st, such that a │ │ │ -00046740: 6c6f 7765 7220 7061 7468 2069 6e64 6578 lower path index │ │ │ -00046750: 2061 6c77 6179 7320 6d65 616e 7420 736f always meant so │ │ │ -00046760: 7274 6564 2d62 6566 6f72 653c 2f74 643e rted-before │ │ │ -00046770: 3c2f 7472 3e3c 7472 2069 643d 2231 3733

    this wo │ │ │ -000467c0: 756c 6420 6265 206d 6f72 6520 6566 6669 uld be more effi │ │ │ -000467d0: 6369 656e 7420 6966 206d 5f70 6174 6873 cient if m_paths │ │ │ -000467e0: 2077 6173 2073 6f72 7465 6420 6669 7273 was sorted firs │ │ │ -000467f0: 742c 2073 7563 680a 7468 6174 2061 206c t, such.that a l │ │ │ -00046800: 6f77 6572 2070 6174 6820 696e 6465 7820 ower path index │ │ │ -00046810: 616c 7761 7973 206d 6561 6e74 2073 6f72 always meant sor │ │ │ -00046820: 7465 642d 6265 666f 7265 3c2f 6832 3e3c ted-before

    < │ │ │ -00046830: 6834 3e2e 2e2f 7372 632f 6669 6c65 5f73 h4>../src/file_s │ │ │ -00046840: 746f 7261 6765 2e63 7070 3a31 3432 313c torage.cpp:1421< │ │ │ -00046850: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .}
    │ │ │ -00046890: 0a0a 0976 6f69 6420 6669 6c65 5f73 746f  ...void file_sto
    │ │ │ -000468a0: 7261 6765 3a3a 6361 6e6f 6e69 6361 6c69  rage::canonicali
    │ │ │ -000468b0: 7a65 5f69 6d70 6c28 626f 6f6c 2063 6f6e  ze_impl(bool con
    │ │ │ -000468c0: 7374 2062 6163 6b77 6172 6473 5f63 6f6d  st backwards_com
    │ │ │ -000468d0: 7061 7469 626c 6529 0a09 7b0a 0909 544f  patible)..{...TO
    │ │ │ -000468e0: 5252 454e 545f 4153 5345 5254 2870 6965  RRENT_ASSERT(pie
    │ │ │ -000468f0: 6365 5f6c 656e 6774 6828 2920 2667 743b  ce_length() >
    │ │ │ -00046900: 3d20 3136 202a 2031 3032 3429 3b0a 0a09  = 16 * 1024);...
    │ │ │ -00046910: 092f 2f20 7573 6520 7468 6973 2076 6563  .// use this vec
    │ │ │ -00046920: 746f 7220 746f 2074 7261 636b 2074 6865  tor to track the
    │ │ │ -00046930: 206e 6577 206f 7264 6572 696e 6720 6f66   new ordering of
    │ │ │ -00046940: 2066 696c 6573 0a09 092f 2f20 7468 6973   files...// this
    │ │ │ -00046950: 2061 6c6c 6f77 7320 7468 6520 7573 6520   allows the use 
    │ │ │ -00046960: 6f66 2053 544c 2061 6c67 6f72 6974 686d  of STL algorithm
    │ │ │ -00046970: 7320 6465 7370 6974 6520 7468 656d 0a09  s despite them..
    │ │ │ -00046980: 092f 2f20 6e6f 7420 7375 7070 6f72 7469  .// not supporti
    │ │ │ -00046990: 6e67 2061 2063 7573 746f 6d20 7377 6170  ng a custom swap
    │ │ │ -000469a0: 2066 756e 6374 6f72 0a09 0961 7578 3a3a   functor...aux::
    │ │ │ -000469b0: 7665 6374 6f72 266c 743b 6669 6c65 5f69  vector<file_i
    │ │ │ -000469c0: 6e64 6578 5f74 2c20 6669 6c65 5f69 6e64  ndex_t, file_ind
    │ │ │ -000469d0: 6578 5f74 2667 743b 206e 6577 5f6f 7264  ex_t> new_ord
    │ │ │ -000469e0: 6572 2865 6e64 5f66 696c 6528 2929 3b0a  er(end_file());.
    │ │ │ -000469f0: 0909 666f 7220 2861 7574 6f20 6920 3a20  ..for (auto i : 
    │ │ │ -00046a00: 6669 6c65 5f72 616e 6765 2829 290a 0909  file_range())...
    │ │ │ -00046a10: 096e 6577 5f6f 7264 6572 5b69 5d20 3d20  .new_order[i] = 
    │ │ │ -00046a20: 693b 0a0a 0909 2f2f 2072 656d 6f76 6520  i;....// remove 
    │ │ │ -00046a30: 616e 7920 6578 6973 7469 6e67 2070 6164  any existing pad
    │ │ │ -00046a40: 2066 696c 6573 0a09 097b 0a09 0909 6175   files...{....au
    │ │ │ -00046a50: 746f 2070 6164 5f62 6567 696e 203d 2073  to pad_begin = s
    │ │ │ -00046a60: 7464 3a3a 7061 7274 6974 696f 6e28 6e65  td::partition(ne
    │ │ │ -00046a70: 775f 6f72 6465 722e 6265 6769 6e28 292c  w_order.begin(),
    │ │ │ -00046a80: 206e 6577 5f6f 7264 6572 2e65 6e64 2829   new_order.end()
    │ │ │ -00046a90: 0a09 0909 092c 205b 7468 6973 5d28 6669  ....., [this](fi
    │ │ │ -00046aa0: 6c65 5f69 6e64 6578 5f74 2069 2920 7b20  le_index_t i) { 
    │ │ │ -00046ab0: 7265 7475 726e 2021 6d5f 6669 6c65 735b  return !m_files[
    │ │ │ -00046ac0: 695d 2e70 6164 5f66 696c 653b 207d 293b  i].pad_file; });
    │ │ │ -00046ad0: 0a09 0909 6e65 775f 6f72 6465 722e 6572  ....new_order.er
    │ │ │ -00046ae0: 6173 6528 7061 645f 6265 6769 6e2c 206e  ase(pad_begin, n
    │ │ │ -00046af0: 6577 5f6f 7264 6572 2e65 6e64 2829 293b  ew_order.end());
    │ │ │ -00046b00: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    .
    ..// │ │ │ -00046b40: 736f 7274 2066 696c 6573 2062 7920 7061 sort files by pa │ │ │ -00046b50: 7468 2f6e 616d 650a 0909 7374 643a 3a73 th/name...std::s │ │ │ -00046b60: 6f72 7428 6e65 775f 6f72 6465 722e 6265 ort(new_order.be │ │ │ -00046b70: 6769 6e28 292c 206e 6577 5f6f 7264 6572 gin(), new_order │ │ │ -00046b80: 2e65 6e64 2829 0a09 0909 2c20 5b74 6869 .end()...., [thi │ │ │ -00046b90: 735d 2866 696c 655f 696e 6465 785f 7420 s](file_index_t │ │ │ -00046ba0: 6c2c 2066 696c 655f 696e 6465 785f 7420 l, file_index_t │ │ │ -00046bb0: 7229 0a09 097b 0a09 0909 2f2f 2061 7373 r)...{....// ass │ │ │ -00046bc0: 756d 696e 6720 6d5f 7061 7468 7320 6172 uming m_paths ar │ │ │ -00046bd0: 6520 756e 6971 7565 210a 0909 0961 7574 e unique!....aut │ │ │ -00046be0: 6f20 636f 6e73 7426 616d 703b 206c 6620 o const& lf │ │ │ -00046bf0: 3d20 6d5f 6669 6c65 735b 6c5d 3b0a 0909 = m_files[l];... │ │ │ -00046c00: 0961 7574 6f20 636f 6e73 7426 616d 703b .auto const& │ │ │ -00046c10: 2072 6620 3d20 6d5f 6669 6c65 735b 725d rf = m_files[r] │ │ │ -00046c20: 3b0a 0909 0969 6620 286c 662e 7061 7468 ;....if (lf.path │ │ │ -00046c30: 5f69 6e64 6578 2021 3d20 7266 2e70 6174 _index != rf.pat │ │ │ -00046c40: 685f 696e 6465 7829 0a09 0909 7b0a 0909 h_index)....{... │ │ │ -00046c50: 0909 696e 7420 636f 6e73 7420 7265 7420 ..int const ret │ │ │ -00046c60: 3d20 7061 7468 5f63 6f6d 7061 7265 286d = path_compare(m │ │ │ -00046c70: 5f70 6174 6873 5b6c 662e 7061 7468 5f69 _paths[lf.path_i │ │ │ -00046c80: 6e64 6578 5d2c 206c 662e 6669 6c65 6e61 ndex], lf.filena │ │ │ -00046c90: 6d65 2829 0a09 0909 0909 2c20 6d5f 7061 me()......, m_pa │ │ │ -00046ca0: 7468 735b 7266 2e70 6174 685f 696e 6465 ths[rf.path_inde │ │ │ -00046cb0: 785d 2c20 7266 2e66 696c 656e 616d 6528 x], rf.filename( │ │ │ -00046cc0: 2929 3b0a 0909 0909 6966 2028 7265 7420 ));.....if (ret │ │ │ -00046cd0: 213d 2030 2920 7265 7475 726e 2072 6574 != 0) return ret │ │ │ -00046ce0: 2026 6c74 3b20 303b 0a09 0909 7d0a 0909 < 0;....}... │ │ │ -00046cf0: 0972 6574 7572 6e20 6c66 2e66 696c 656e .return lf.filen │ │ │ -00046d00: 616d 6528 2920 266c 743b 2072 662e 6669 ame() < rf.fi │ │ │ -00046d10: 6c65 6e61 6d65 2829 3b0a 0909 7d29 3b0a lename();...});. │ │ │ -00046d20: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ -00046d30: 743b 6175 783a 3a66 696c 655f 656e 7472 t;aux::file_entr │ │ │ -00046d40: 792c 2066 696c 655f 696e 6465 785f 7426 y, file_index_t& │ │ │ -00046d50: 6774 3b20 6e65 775f 6669 6c65 733b 0a09 gt; new_files;.. │ │ │ -00046d60: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ -00046d70: 6368 6172 2063 6f6e 7374 2a2c 2066 696c char const*, fil │ │ │ -00046d80: 655f 696e 6465 785f 7426 6774 3b20 6e65 e_index_t> ne │ │ │ -00046d90: 775f 6669 6c65 5f68 6173 6865 733b 0a09 w_file_hashes;.. │ │ │ -00046da0: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ -00046db0: 7374 643a 3a74 696d 655f 742c 2066 696c std::time_t, fil │ │ │ -00046dc0: 655f 696e 6465 785f 7426 6774 3b20 6e65 e_index_t> ne │ │ │ -00046dd0: 775f 6d74 696d 653b 0a0a 0909 2f2f 2072 w_mtime;....// r │ │ │ -00046de0: 6573 6572 7665 2065 6e6f 7567 6820 7370 eserve enough sp │ │ │ -00046df0: 6163 6520 666f 7220 7468 6520 776f 7273 ace for the wors │ │ │ -00046e00: 7420 6361 7365 2061 6674 6572 2070 6164 t case after pad │ │ │ -00046e10: 6469 6e67 0a09 096e 6577 5f66 696c 6573 ding...new_files │ │ │ -00046e20: 2e72 6573 6572 7665 286e 6577 5f6f 7264 .reserve(new_ord │ │ │ -00046e30: 6572 2e73 697a 6528 2920 2a20 3220 2d20 er.size() * 2 - │ │ │ -00046e40: 3129 3b0a 0909 6966 2028 216d 5f66 696c 1);...if (!m_fil │ │ │ -00046e50: 655f 6861 7368 6573 2e65 6d70 7479 2829 e_hashes.empty() │ │ │ -00046e60: 290a 0909 096e 6577 5f66 696c 655f 6861 )....new_file_ha │ │ │ -00046e70: 7368 6573 2e72 6573 6572 7665 286e 6577 shes.reserve(new │ │ │ -00046e80: 5f6f 7264 6572 2e73 697a 6528 2920 2a20 _order.size() * │ │ │ -00046e90: 3220 2d20 3129 3b0a 0909 6966 2028 216d 2 - 1);...if (!m │ │ │ -00046ea0: 5f6d 7469 6d65 2e65 6d70 7479 2829 290a _mtime.empty()). │ │ │ -00046eb0: 0909 096e 6577 5f6d 7469 6d65 2e72 6573 ...new_mtime.res │ │ │ -00046ec0: 6572 7665 286e 6577 5f6f 7264 6572 2e73 erve(new_order.s │ │ │ -00046ed0: 697a 6528 2920 2a20 3220 2d20 3129 3b0a ize() * 2 - 1);. │ │ │ -00046ee0: 0a09 092f 2f20 7265 2d63 6f6d 7075 7465 ...// re-compute │ │ │ -00046ef0: 206f 6666 7365 7473 2061 6e64 2069 6e73 offsets and ins │ │ │ -00046f00: 6572 7420 7061 6420 6669 6c65 7320 6173 ert pad files as │ │ │ -00046f10: 206e 6563 6573 7361 7279 0a09 0973 7464 necessary...std │ │ │ -00046f20: 3a3a 696e 7436 345f 7420 6f66 6620 3d20 ::int64_t off = │ │ │ -00046f30: 303b 0a09 0973 7464 3a3a 696e 7436 345f 0;...std::int64_ │ │ │ -00046f40: 7420 6f6e 5f64 6973 6b20 3d20 303b 0a3c t on_disk = 0;.< │ │ │ -00046f50: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00046f60: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00046f70: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00046f80: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00046f90: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00046fc0: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ -00046fd0: 3a38 383c 2f61 3e3c 2f74 643e 3c74 643e :88 │ │ │ -00046fe0: 696e 2043 2b2b 3230 2c20 7573 6520 7374 in C++20, use st │ │ │ -00046ff0: 643a 3a69 6465 6e74 6974 793c 2f74 643e d::identity │ │ │ -00047000: 3c2f 7472 3e3c 7472 2069 643d 2231 3734

    in C++2 │ │ │ -00047050: 302c 2075 7365 2073 7464 3a3a 6964 656e 0, use std::iden │ │ │ -00047060: 7469 7479 3c2f 6832 3e3c 6834 3e2e 2e2f tity

    ../ │ │ │ -00047070: 7372 632f 6d65 726b 6c65 5f74 7265 652e src/merkle_tree. │ │ │ -00047080: 6370 703a 3838 3c2f 6834 3e3c 7072 6520 cpp:88

    ..allocate_
    │ │ │ -000470d0: 6675 6c6c 2829 3b0a 0a09 096d 6572 6b6c  full();....merkl
    │ │ │ -000470e0: 655f 7661 6c69 6461 7465 5f63 6f70 7928  e_validate_copy(
    │ │ │ -000470f0: 742c 206d 5f74 7265 652c 2072 6f6f 7428  t, m_tree, root(
    │ │ │ -00047100: 292c 206d 5f62 6c6f 636b 5f76 6572 6966  ), m_block_verif
    │ │ │ -00047110: 6965 6429 3b0a 0a09 096c 6f61 645f 7665  ied);....load_ve
    │ │ │ -00047120: 7269 6669 6564 5f62 6974 7328 7665 7269  rified_bits(veri
    │ │ │ -00047130: 6669 6564 293b 0a0a 0909 6f70 7469 6d69  fied);....optimi
    │ │ │ -00047140: 7a65 5f73 746f 7261 6765 2829 3b0a 0909  ze_storage();...
    │ │ │ -00047150: 6f70 7469 6d69 7a65 5f73 746f 7261 6765  optimize_storage
    │ │ │ -00047160: 5f70 6965 6365 5f6c 6179 6572 2829 3b0a  _piece_layer();.
    │ │ │ -00047170: 097d 0a0a 0976 6f69 6420 6d65 726b 6c65  .}...void merkle
    │ │ │ -00047180: 5f74 7265 653a 3a63 6c65 6172 2829 0a09  _tree::clear()..
    │ │ │ -00047190: 7b0a 0909 6d5f 7472 6565 2e63 6c65 6172  {...m_tree.clear
    │ │ │ -000471a0: 2829 3b0a 0909 6d5f 7472 6565 2e73 6872  ();...m_tree.shr
    │ │ │ -000471b0: 696e 6b5f 746f 5f66 6974 2829 3b0a 0909  ink_to_fit();...
    │ │ │ -000471c0: 6d5f 626c 6f63 6b5f 7665 7269 6669 6564  m_block_verified
    │ │ │ -000471d0: 2e63 6c65 6172 2829 3b0a 0909 6d5f 6d6f  .clear();...m_mo
    │ │ │ -000471e0: 6465 203d 206d 6f64 655f 743a 3a65 6d70  de = mode_t::emp
    │ │ │ -000471f0: 7479 5f74 7265 653b 0a09 7d0a 0a6e 616d  ty_tree;..}..nam
    │ │ │ -00047200: 6573 7061 6365 207b 0a0a 3c64 6976 2073  espace {..
    .struct │ │ │ -00047240: 6964 656e 7469 7479 0a3c 2f64 6976 3e09 identity.
    . │ │ │ -00047250: 7b0a 0909 626f 6f6c 206f 7065 7261 746f {...bool operato │ │ │ -00047260: 7228 2928 626f 6f6c 2062 2920 636f 6e73 r()(bool b) cons │ │ │ -00047270: 7420 7b20 7265 7475 726e 2062 3b20 7d0a t { return b; }. │ │ │ -00047280: 097d 3b0a 7d0a 0a09 766f 6964 206d 6572 .};.}...void mer │ │ │ -00047290: 6b6c 655f 7472 6565 3a3a 6c6f 6164 5f73 kle_tree::load_s │ │ │ -000472a0: 7061 7273 655f 7472 6565 2873 7061 6e26 parse_tree(span& │ │ │ -000472b0: 6c74 3b73 6861 3235 365f 6861 7368 2063 lt;sha256_hash c │ │ │ -000472c0: 6f6e 7374 2667 743b 2074 0a09 092c 2062 onst> t..., b │ │ │ -000472d0: 6974 6669 656c 6420 636f 6e73 7426 616d itfield const&am │ │ │ -000472e0: 703b 206d 6173 6b0a 0909 2c20 6269 7466 p; mask..., bitf │ │ │ -000472f0: 6965 6c64 2063 6f6e 7374 2661 6d70 3b20 ield const& │ │ │ -00047300: 7665 7269 6669 6564 290a 097b 0a09 0949 verified)..{...I │ │ │ -00047310: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a NVARIANT_CHECK;. │ │ │ -00047320: 0a09 092f 2f20 5468 6520 7369 7a65 206f ...// The size o │ │ │ -00047330: 6620 7468 6520 6d61 736b 2073 686f 756c f the mask shoul │ │ │ -00047340: 6420 6e6f 7420 6578 6365 6564 2074 6865 d not exceed the │ │ │ -00047350: 2073 697a 6520 6f66 2074 6865 2074 7265 size of the tre │ │ │ -00047360: 652c 2062 7574 2061 206d 6173 6b20 6c61 e, but a mask la │ │ │ -00047370: 7267 6572 2074 6861 6e0a 0909 2f2f 2074 rger than...// t │ │ │ -00047380: 6865 2074 7265 6520 6361 6e20 6265 2065 he tree can be e │ │ │ -00047390: 6e63 6f75 6e74 6572 6564 2069 6e20 7468 ncountered in th │ │ │ -000473a0: 6520 2272 6573 756d 6520 6461 7461 2220 e "resume data" │ │ │ -000473b0: 666f 7220 736f 6d65 2072 6561 736f 6e2c for some reason, │ │ │ -000473c0: 2070 6572 6861 7073 2074 6865 7265 2069 perhaps there i │ │ │ -000473d0: 730a 0909 2f2f 2061 2062 7567 2069 6e20 s...// a bug in │ │ │ -000473e0: 7468 6520 2272 6573 756d 6520 6461 7461 the "resume data │ │ │ -000473f0: 2220 6765 6e65 7261 7469 6f6e 2061 6c67 " generation alg │ │ │ -00047400: 6f72 6974 686d 2e0a 0909 2f2f 2053 6f20 orithm....// So │ │ │ -00047410: 7765 206a 7573 7420 7072 6f63 6573 7320 we just process │ │ │ -00047420: 6d61 736b 2069 7465 6d73 2063 6f75 6e74 mask items count │ │ │ -00047430: 2075 7020 746f 2074 7265 6520 7369 7a65 up to tree size │ │ │ -00047440: 2e0a 0909 696e 7420 636f 6e73 7420 6d61 ....int const ma │ │ │ -00047450: 736b 5f73 697a 6520 3d20 7374 643a 3a6d sk_size = std::m │ │ │ -00047460: 696e 286d 6173 6b2e 7369 7a65 2829 2c20 in(mask.size(), │ │ │ -00047470: 696e 7428 7369 7a65 2829 2929 3b0a 0a09 int(size()));... │ │ │ -00047480: 0969 6e74 2063 6f6e 7374 2066 6972 7374 .int const first │ │ │ -00047490: 5f62 6c6f 636b 203d 2062 6c6f 636b 5f6c _block = block_l │ │ │ -000474a0: 6179 6572 5f73 7461 7274 2829 3b0a 0909 ayer_start();... │ │ │ -000474b0: 696e 7420 636f 6e73 7420 656e 645f 626c int const end_bl │ │ │ -000474c0: 6f63 6b20 3d20 6669 7273 745f 626c 6f63 ock = first_bloc │ │ │ -000474d0: 6b20 2b20 6d5f 6e75 6d5f 626c 6f63 6b73 k + m_num_blocks │ │ │ -000474e0: 3b0a 0a09 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ -000474f0: 4552 5428 6669 7273 745f 626c 6f63 6b20 ERT(first_block │ │ │ -00047500: 266c 743b 2069 6e74 2873 697a 6528 2929 < int(size()) │ │ │ -00047510: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -00047520: 4552 5428 656e 645f 626c 6f63 6b20 266c ERT(end_block &l │ │ │ -00047530: 743b 3d20 696e 7428 7369 7a65 2829 2929 t;= int(size())) │ │ │ -00047540: 3b0a 0a09 092f 2f20 6966 2074 6865 206d ;....// if the m │ │ │ -00047550: 6173 6b20 636f 7665 7273 2061 6c6c 2062 ask covers all b │ │ │ -00047560: 6c6f 636b 732c 2067 6f20 7374 7261 6967 locks, go straig │ │ │ -00047570: 6874 2074 6f20 626c 6f63 6b5f 6c61 7965 ht to block_laye │ │ │ -00047580: 720a 0909 2f2f 206d 6f64 652c 2061 6e64 r...// mode, and │ │ │ -00047590: 2076 616c 6964 6174 650a 0909 6966 2028 validate...if ( │ │ │ -000475a0: 2866 6972 7374 5f62 6c6f 636b 2026 6c74 (first_block < │ │ │ -000475b0: 3b20 6d61 736b 5f73 697a 6529 2026 616d ; mask_size) &am │ │ │ -000475c0: 703b 2661 6d70 3b20 2865 6e64 5f62 6c6f p;& (end_blo │ │ │ -000475d0: 636b 2026 6c74 3b3d 206d 6173 6b5f 7369 ck <= mask_si │ │ │ -000475e0: 7a65 290a 0909 0926 616d 703b 2661 6d70 ze)....&& │ │ │ -000475f0: 3b20 7374 643a 3a61 6c6c 5f6f 6628 6d61 ; std::all_of(ma │ │ │ -00047600: 736b 2e62 6567 696e 2829 202b 2066 6972 sk.begin() + fir │ │ │ -00047610: 7374 5f62 6c6f 636b 2c20 6d61 736b 2e62 st_block, mask.b │ │ │ -00047620: 6567 696e 2829 202b 2065 6e64 5f62 6c6f egin() + end_blo │ │ │ -00047630: 636b 2c20 6964 656e 7469 7479 2829 2929 ck, identity())) │ │ │ -00047640: 0a09 097b 0a09 0909 2f2f 2074 6865 2069 ...{....// the i │ │ │ -00047650: 6e64 6578 2069 6e20 7420 7468 6174 2070 ndex in t that p │ │ │ -00047660: 6f69 6e74 7320 746f 2066 6972 7374 5f62 oints to first_b │ │ │ -00047670: 6c6f 636b 0a09 0909 6175 746f 2063 6f6e lock....auto con │ │ │ -00047680: 7374 2062 6c6f 636b 5f69 6e64 6578 203d st block_index = │ │ │ -00047690: 2073 7464 3a3a 636f 756e 745f 6966 286d std::count_if(m │ │ │ -000476a0: 6173 6b2e 6265 6769 6e28 292c 206d 6173 ask.begin(), mas │ │ │ -000476b0: 6b2e 6265 6769 6e28 2920 2b20 6669 7273 k.begin() + firs │ │ │ -000476c0: 745f 626c 6f63 6b2c 2069 6465 6e74 6974 t_block, identit │ │ │ -000476d0: 7928 2929 3b0a 3c2f 7072 653e 3c2f 7464 y());.
    relevance │ │ │ -00047710: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00047720: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/merkle_t │ │ │ -00047750: 7265 652e 6370 703a 3330 373c 2f61 3e3c ree.cpp:307< │ │ │ -00047760: 2f74 643e 3c74 643e 7468 6973 2063 616e /td>this can │ │ │ -00047770: 2062 6520 6f70 7469 6d69 7a65 6420 6279 be optimized by │ │ │ -00047780: 2075 7369 6e67 206d 5f74 7265 6520 6173 using m_tree as │ │ │ -00047790: 2073 746f 7261 6765 2074 6f20 6669 6c6c storage to fill │ │ │ -000477a0: 2074 6869 7320 7472 6565 2069 6e74 6f2c this tree into, │ │ │ -000477b0: 2061 6e64 2074 6865 6e20 636c 6561 7220 and then clear │ │ │ -000477c0: 6974 2069 6620 7468 6520 6861 7368 6573 it if the hashes │ │ │ -000477d0: 2066 6169 6c3c 2f74 643e 3c2f 7472 3e3c fail< │ │ │ -000477e0: 7472 2069 643d 2231 3735 2220 7374 796c tr id="175" styl │ │ │ -000477f0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00047800: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00047810: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00047820: 6832 3e74 6869 7320 6361 6e20 6265 206f h2>this can be o │ │ │ -00047830: 7074 696d 697a 6564 2062 7920 7573 696e ptimized by usin │ │ │ -00047840: 6720 6d5f 7472 6565 2061 7320 7374 6f72 g m_tree as stor │ │ │ -00047850: 6167 6520 746f 2066 696c 6c20 7468 6973 age to fill this │ │ │ -00047860: 0a74 7265 6520 696e 746f 2c20 616e 6420 .tree into, and │ │ │ -00047870: 7468 656e 2063 6c65 6172 2069 7420 6966 then clear it if │ │ │ -00047880: 2074 6865 2068 6173 6865 7320 6661 696c the hashes fail │ │ │ -00047890: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -000478a0: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ -000478b0: 3330 373c 2f68 343e 3c70 7265 2073 7479 307

    .{...INVARIANT
    │ │ │ -00047900: 5f43 4845 434b 3b0a 0a09 092f 2f20 6173  _CHECK;....// as
    │ │ │ -00047910: 2077 6520 7365 7420 7468 6520 6861 7368   we set the hash
    │ │ │ -00047920: 6573 206f 6620 696e 7465 7269 6f72 206e  es of interior n
    │ │ │ -00047930: 6f64 6573 2c20 7765 206d 6179 2062 6520  odes, we may be 
    │ │ │ -00047940: 6162 6c65 2074 6f20 7661 6c69 6461 7465  able to validate
    │ │ │ -00047950: 0a09 092f 2f20 626c 6f63 6b20 6861 7368  ...// block hash
    │ │ │ -00047960: 6573 2074 6861 7420 7765 2068 6164 2073  es that we had s
    │ │ │ -00047970: 696e 6365 2065 6172 6c69 6572 2e20 416e  ince earlier. An
    │ │ │ -00047980: 7920 626c 6f63 6b73 2074 6861 7420 6361  y blocks that ca
    │ │ │ -00047990: 6e20 6265 0a09 092f 2f20 7661 6c69 6461  n be...// valida
    │ │ │ -000479a0: 7465 642c 2061 6e64 2066 6169 6c65 642c  ted, and failed,
    │ │ │ -000479b0: 2061 7265 2061 6464 6564 2074 6f20 7468   are added to th
    │ │ │ -000479c0: 6973 206c 6973 740a 0909 6164 645f 6861  is list...add_ha
    │ │ │ -000479d0: 7368 6573 5f72 6573 756c 745f 7420 7265  shes_result_t re
    │ │ │ -000479e0: 743b 0a0a 0909 2f2f 2077 6520 616c 7265  t;....// we alre
    │ │ │ -000479f0: 6164 7920 6861 7665 2061 6c6c 2068 6173  ady have all has
    │ │ │ -00047a00: 6865 730a 0909 6966 2028 6d5f 6d6f 6465  hes...if (m_mode
    │ │ │ -00047a10: 203d 3d20 6d6f 6465 5f74 3a3a 626c 6f63   == mode_t::bloc
    │ │ │ -00047a20: 6b5f 6c61 7965 7229 0a09 097b 0a09 0909  k_layer)...{....
    │ │ │ -00047a30: 2f2f 2073 696e 6365 2077 6527 7265 2061  // since we're a
    │ │ │ -00047a40: 6c72 6561 6479 206f 6e20 7468 6520 626c  lready on the bl
    │ │ │ -00047a50: 6f63 6b20 6c61 7965 7220 6d6f 6465 2c20  ock layer mode, 
    │ │ │ -00047a60: 7765 2068 6176 6520 7468 6520 7768 6f6c  we have the whol
    │ │ │ -00047a70: 650a 0909 092f 2f20 7472 6565 2c20 616e  e....// tree, an
    │ │ │ -00047a80: 6420 7765 2776 6520 616c 7265 6164 7920  d we've already 
    │ │ │ -00047a90: 7265 706f 7274 6564 2061 6e79 2070 6965  reported any pie
    │ │ │ -00047aa0: 6365 7320 6173 2070 6173 7369 6e67 2074  ces as passing t
    │ │ │ -00047ab0: 6861 7420 6d61 790a 0909 092f 2f20 6861  hat may....// ha
    │ │ │ -00047ac0: 7665 2065 7869 7374 6564 2069 6e20 7468  ve existed in th
    │ │ │ -00047ad0: 6520 7472 6565 2077 6865 6e20 7765 2063  e tree when we c
    │ │ │ -00047ae0: 6f6d 706c 6574 6564 2069 742e 2041 7420  ompleted it. At 
    │ │ │ -00047af0: 7468 6973 2070 6f69 6e74 206e 6f0a 0909  this point no...
    │ │ │ -00047b00: 092f 2f20 6d6f 7265 2070 6965 6365 7320  .// more pieces 
    │ │ │ -00047b10: 7368 6f75 6c64 2062 6520 7265 706f 7274  should be report
    │ │ │ -00047b20: 6564 2061 7320 7061 7373 6564 0a09 0909  ed as passed....
    │ │ │ -00047b30: 7265 7475 726e 2072 6574 3b0a 0909 7d0a  return ret;...}.
    │ │ │ -00047b40: 0a09 0961 6c6c 6f63 6174 655f 6675 6c6c  ...allocate_full
    │ │ │ -00047b50: 2829 3b0a 0a3c 6469 7620 7374 796c 653d  ();..
    ..int const l │ │ │ -00047b90: 6561 665f 636f 756e 7420 3d20 6d65 726b eaf_count = merk │ │ │ -00047ba0: 6c65 5f6e 756d 5f6c 6561 6673 2869 6e74 le_num_leafs(int │ │ │ -00047bb0: 2868 6173 6865 732e 7369 7a65 2829 2929 (hashes.size())) │ │ │ -00047bc0: 3b0a 3c2f 6469 763e 0909 6175 783a 3a76 ;.
    ..aux::v │ │ │ -00047bd0: 6563 746f 7226 6c74 3b73 6861 3235 365f ector<sha256_ │ │ │ -00047be0: 6861 7368 2667 743b 2074 7265 6528 6d65 hash> tree(me │ │ │ -00047bf0: 726b 6c65 5f6e 756d 5f6e 6f64 6573 286c rkle_num_nodes(l │ │ │ -00047c00: 6561 665f 636f 756e 7429 293b 0a09 0973 eaf_count));...s │ │ │ -00047c10: 7464 3a3a 636f 7079 2868 6173 6865 732e td::copy(hashes. │ │ │ -00047c20: 6265 6769 6e28 292c 2068 6173 6865 732e begin(), hashes. │ │ │ -00047c30: 656e 6428 292c 2074 7265 652e 656e 6428 end(), tree.end( │ │ │ -00047c40: 2920 2d20 6c65 6166 5f63 6f75 6e74 293b ) - leaf_count); │ │ │ -00047c50: 0a0a 0909 2f2f 2074 6865 2065 6e64 206f ....// the end o │ │ │ -00047c60: 6620 6120 6669 6c65 2069 7320 6120 7370 f a file is a sp │ │ │ -00047c70: 6563 6961 6c20 6361 7365 2c20 7765 206d ecial case, we m │ │ │ -00047c80: 6179 206e 6565 6420 746f 2070 6164 2074 ay need to pad t │ │ │ -00047c90: 6865 206c 6561 6620 6c61 7965 720a 0909 he leaf layer... │ │ │ -00047ca0: 6966 2028 6c65 6166 5f63 6f75 6e74 2026 if (leaf_count & │ │ │ -00047cb0: 6774 3b20 6861 7368 6573 2e73 697a 6528 gt; hashes.size( │ │ │ -00047cc0: 2929 0a09 097b 0a09 0909 696e 7420 636f ))...{....int co │ │ │ -00047cd0: 6e73 7420 6c65 6166 5f6c 6179 6572 5f73 nst leaf_layer_s │ │ │ -00047ce0: 697a 6520 3d20 6e75 6d5f 6c65 6166 7328 ize = num_leafs( │ │ │ -00047cf0: 293b 0a09 0909 2f2f 2061 7373 756d 696e );....// assumin │ │ │ -00047d00: 6720 756e 636c 655f 6861 7368 6573 206c g uncle_hashes l │ │ │ -00047d10: 6561 6420 616c 6c20 7468 6520 7761 7920 ead all the way │ │ │ -00047d20: 746f 2074 6865 2072 6f6f 742c 2074 6865 to the root, the │ │ │ -00047d30: 7920 7465 6c6c 2075 730a 0909 092f 2f20 y tell us....// │ │ │ -00047d40: 686f 7720 6d61 6e79 206c 6179 6572 7320 how many layers │ │ │ -00047d50: 646f 776e 2077 6520 6172 650a 0909 0969 down we are....i │ │ │ -00047d60: 6e74 2063 6f6e 7374 2069 6e73 6572 745f nt const insert_ │ │ │ -00047d70: 6c61 7965 725f 7369 7a65 203d 206c 6561 layer_size = lea │ │ │ -00047d80: 665f 636f 756e 7420 266c 743b 266c 743b f_count << │ │ │ -00047d90: 2075 6e63 6c65 5f68 6173 6865 732e 7369 uncle_hashes.si │ │ │ -00047da0: 7a65 2829 3b0a 0909 0969 6620 286c 6561 ze();....if (lea │ │ │ -00047db0: 665f 6c61 7965 725f 7369 7a65 2021 3d20 f_layer_size != │ │ │ -00047dc0: 696e 7365 7274 5f6c 6179 6572 5f73 697a insert_layer_siz │ │ │ -00047dd0: 6529 0a09 0909 7b0a 0909 0909 7368 6132 e)....{.....sha2 │ │ │ -00047de0: 3536 5f68 6173 6820 636f 6e73 7420 7061 56_hash const pa │ │ │ -00047df0: 645f 6861 7368 203d 206d 6572 6b6c 655f d_hash = merkle_ │ │ │ -00047e00: 7061 6428 6c65 6166 5f6c 6179 6572 5f73 pad(leaf_layer_s │ │ │ -00047e10: 697a 652c 2069 6e73 6572 745f 6c61 7965 ize, insert_laye │ │ │ -00047e20: 725f 7369 7a65 293b 0a09 0909 0966 6f72 r_size);.....for │ │ │ -00047e30: 2028 696e 7420 6920 3d20 696e 7428 6861 (int i = int(ha │ │ │ -00047e40: 7368 6573 2e73 697a 6528 2929 3b20 6920 shes.size()); i │ │ │ -00047e50: 266c 743b 206c 6561 665f 636f 756e 743b < leaf_count; │ │ │ -00047e60: 202b 2b69 290a 0909 0909 0974 7265 655b ++i)......tree[ │ │ │ -00047e70: 7472 6565 2e65 6e64 5f69 6e64 6578 2829 tree.end_index() │ │ │ -00047e80: 202d 206c 6561 665f 636f 756e 7420 2b20 - leaf_count + │ │ │ -00047e90: 695d 203d 2070 6164 5f68 6173 683b 0a09 i] = pad_hash;.. │ │ │ -00047ea0: 0909 7d0a 0909 7d0a 0a09 096d 6572 6b6c ..}...}....merkl │ │ │ -00047eb0: 655f 6669 6c6c 5f74 7265 6528 7472 6565 e_fill_tree(tree │ │ │ -00047ec0: 2c20 6c65 6166 5f63 6f75 6e74 293b 0a0a , leaf_count);.. │ │ │ -00047ed0: 0909 696e 7420 636f 6e73 7420 6261 7365 ..int const base │ │ │ -00047ee0: 5f6e 756d 5f6c 6179 6572 7320 3d20 6d65 _num_layers = me │ │ │ -00047ef0: 726b 6c65 5f6e 756d 5f6c 6179 6572 7328 rkle_num_layers( │ │ │ -00047f00: 6c65 6166 5f63 6f75 6e74 293b 0a0a 0909 leaf_count);.... │ │ │ -00047f10: 2f2f 2074 6869 7320 6973 2074 6865 2069 // this is the i │ │ │ -00047f20: 6e64 6578 206f 6620 7468 6520 6e6f 6465 ndex of the node │ │ │ -00047f30: 2077 6865 7265 2077 6527 6c6c 2069 6e73 where we'll ins │ │ │ -00047f40: 6572 7420 7468 6520 726f 6f74 206f 6620 ert the root of │ │ │ -00047f50: 7468 650a 0909 2f2f 2073 7562 7472 6565 the...// subtree │ │ │ -00047f60: 2028 7472 6565 292e 2049 7427 7320 616c (tree). It's al │ │ │ -00047f70: 736f 2074 6865 2068 6173 6820 7468 6520 so the hash the │ │ │ -00047f80: 756e 636c 655f 6861 7368 6573 2061 7265 uncle_hashes are │ │ │ -00047f90: 2068 6572 6520 746f 2070 726f 7665 0a09 here to prove.. │ │ │ -00047fa0: 092f 2f20 6973 2076 616c 6964 2e0a 0909 .// is valid.... │ │ │ -00047fb0: 696e 7420 636f 6e73 7420 696e 7365 7274 int const insert │ │ │ -00047fc0: 5f72 6f6f 745f 6964 7820 3d20 6465 7374 _root_idx = dest │ │ │ -00047fd0: 5f73 7461 7274 5f69 6478 2026 6774 3b26 _start_idx >& │ │ │ -00047fe0: 6774 3b20 6261 7365 5f6e 756d 5f6c 6179 gt; base_num_lay │ │ │ -00047ff0: 6572 733b 0a0a 0909 2f2f 2073 7461 7274 ers;....// start │ │ │ -00048000: 2077 6974 6820 7661 6c69 6461 7469 6e67 with validating │ │ │ -00048010: 2074 6865 2070 726f 6f66 732c 2061 6e64 the proofs, and │ │ │ -00048020: 2069 6e73 6572 7469 6e67 2074 6865 6d20 inserting them │ │ │ -00048030: 6173 2077 6520 676f 2e0a 0909 6966 2028 as we go....if ( │ │ │ -00048040: 216d 6572 6b6c 655f 7661 6c69 6461 7465 !merkle_validate │ │ │ -00048050: 5f61 6e64 5f69 6e73 6572 745f 7072 6f6f _and_insert_proo │ │ │ -00048060: 6673 286d 5f74 7265 652c 2069 6e73 6572 fs(m_tree, inser │ │ │ -00048070: 745f 726f 6f74 5f69 6478 2c20 7472 6565 t_root_idx, tree │ │ │ -00048080: 5b30 5d2c 2075 6e63 6c65 5f68 6173 6865 [0], uncle_hashe │ │ │ -00048090: 7329 290a 0909 0972 6574 7572 6e20 7b7d s))....return {} │ │ │ -000480a0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -000480d0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000480e0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00048110: 7372 632f 6d65 726b 6c65 5f74 7265 652e src/merkle_tree. │ │ │ -00048120: 6370 703a 3335 353c 2f61 3e3c 2f74 643e cpp:355 │ │ │ -00048130: 3c74 643e 6120 7069 6563 6520 6f75 7473 a piece outs │ │ │ -00048140: 6964 6520 6f66 2074 6869 7320 7261 6e67 ide of this rang │ │ │ -00048150: 6520 6d61 7920 616c 736f 2066 6169 6c2c e may also fail, │ │ │ -00048160: 2069 6620 6f6e 6520 6f66 2074 6865 2075 if one of the u │ │ │ -00048170: 6e63 6c65 2068 6173 6865 7320 6973 2061 ncle hashes is a │ │ │ -00048180: 7420 7468 6520 6c61 7965 7220 7269 6768 t the layer righ │ │ │ -00048190: 7420 6162 6f76 6520 7468 6520 626c 6f63 t above the bloc │ │ │ -000481a0: 6b20 6861 7368 6573 3c2f 7464 3e3c 2f74 k hashes

    a piece ou │ │ │ -00048200: 7473 6964 6520 6f66 2074 6869 7320 7261 tside of this ra │ │ │ -00048210: 6e67 6520 6d61 7920 616c 736f 2066 6169 nge may also fai │ │ │ -00048220: 6c2c 2069 6620 6f6e 6520 6f66 2074 6865 l, if one of the │ │ │ -00048230: 2075 6e63 6c65 0a68 6173 6865 7320 6973 uncle.hashes is │ │ │ -00048240: 2061 7420 7468 6520 6c61 7965 7220 7269 at the layer ri │ │ │ -00048250: 6768 7420 6162 6f76 6520 7468 6520 626c ght above the bl │ │ │ -00048260: 6f63 6b20 6861 7368 6573 3c2f 6832 3e3c ock hashes

    < │ │ │ -00048270: 6834 3e2e 2e2f 7372 632f 6d65 726b 6c65 h4>../src/merkle │ │ │ -00048280: 5f74 7265 652e 6370 703a 3335 353c 2f68 _tree.cpp:355
    ..in
    │ │ │ -000482d0: 7420 636f 6e73 7420 696e 7365 7274 5f72  t const insert_r
    │ │ │ -000482e0: 6f6f 745f 6964 7820 3d20 6465 7374 5f73  oot_idx = dest_s
    │ │ │ -000482f0: 7461 7274 5f69 6478 2026 6774 3b26 6774  tart_idx >>
    │ │ │ -00048300: 3b20 6261 7365 5f6e 756d 5f6c 6179 6572  ; base_num_layer
    │ │ │ -00048310: 733b 0a0a 0909 2f2f 2073 7461 7274 2077  s;....// start w
    │ │ │ -00048320: 6974 6820 7661 6c69 6461 7469 6e67 2074  ith validating t
    │ │ │ -00048330: 6865 2070 726f 6f66 732c 2061 6e64 2069  he proofs, and i
    │ │ │ -00048340: 6e73 6572 7469 6e67 2074 6865 6d20 6173  nserting them as
    │ │ │ -00048350: 2077 6520 676f 2e0a 0909 6966 2028 216d   we go....if (!m
    │ │ │ -00048360: 6572 6b6c 655f 7661 6c69 6461 7465 5f61  erkle_validate_a
    │ │ │ -00048370: 6e64 5f69 6e73 6572 745f 7072 6f6f 6673  nd_insert_proofs
    │ │ │ -00048380: 286d 5f74 7265 652c 2069 6e73 6572 745f  (m_tree, insert_
    │ │ │ -00048390: 726f 6f74 5f69 6478 2c20 7472 6565 5b30  root_idx, tree[0
    │ │ │ -000483a0: 5d2c 2075 6e63 6c65 5f68 6173 6865 7329  ], uncle_hashes)
    │ │ │ -000483b0: 290a 0909 0972 6574 7572 6e20 7b7d 3b0a  )....return {};.
    │ │ │ -000483c0: 0a09 092f 2f20 6669 7273 7420 6669 6c6c  ...// first fill
    │ │ │ -000483d0: 2069 6e20 7468 6520 7375 6274 7265 6520   in the subtree 
    │ │ │ -000483e0: 6f66 206b 6e6f 776e 2068 6173 6865 7320  of known hashes 
    │ │ │ -000483f0: 6672 6f6d 2074 6865 2062 6173 6520 6c61  from the base la
    │ │ │ -00048400: 7965 720a 0909 6175 746f 2063 6f6e 7374  yer...auto const
    │ │ │ -00048410: 206e 756d 5f6c 6561 6673 203d 206d 6572   num_leafs = mer
    │ │ │ -00048420: 6b6c 655f 6e75 6d5f 6c65 6166 7328 6d5f  kle_num_leafs(m_
    │ │ │ -00048430: 6e75 6d5f 626c 6f63 6b73 293b 0a09 0961  num_blocks);...a
    │ │ │ -00048440: 7574 6f20 636f 6e73 7420 6669 7273 745f  uto const first_
    │ │ │ -00048450: 6c65 6166 203d 206d 6572 6b6c 655f 6669  leaf = merkle_fi
    │ │ │ -00048460: 7273 745f 6c65 6166 286e 756d 5f6c 6561  rst_leaf(num_lea
    │ │ │ -00048470: 6673 293b 0a0a 0909 2f2f 2074 6869 7320  fs);....// this 
    │ │ │ -00048480: 6973 2074 6865 2073 7461 7274 206f 6620  is the start of 
    │ │ │ -00048490: 7468 6520 6c65 6166 206c 6179 6572 206f  the leaf layer o
    │ │ │ -000484a0: 6620 2274 7265 6522 2e20 5765 276c 6c20  f "tree". We'll 
    │ │ │ -000484b0: 7573 6520 7468 6973 0a09 092f 2f20 7661  use this...// va
    │ │ │ -000484c0: 7269 6162 6c65 2074 6f20 7374 6570 2075  riable to step u
    │ │ │ -000484d0: 7077 6172 6473 2074 6f77 6172 6473 2074  pwards towards t
    │ │ │ -000484e0: 6865 2072 6f6f 740a 0909 696e 7420 736f  he root...int so
    │ │ │ -000484f0: 7572 6365 5f63 7572 736f 7220 3d20 696e  urce_cursor = in
    │ │ │ -00048500: 7428 7472 6565 2e73 697a 6528 2929 202d  t(tree.size()) -
    │ │ │ -00048510: 206c 6561 665f 636f 756e 743b 0a09 092f   leaf_count;.../
    │ │ │ -00048520: 2f20 7468 6520 7275 6e6e 696e 6720 696e  / the running in
    │ │ │ -00048530: 6465 7820 696e 2074 6865 206c 6f6f 700a  dex in the loop.
    │ │ │ -00048540: 0909 696e 7420 6465 7374 5f63 7572 736f  ..int dest_curso
    │ │ │ -00048550: 7220 3d20 6465 7374 5f73 7461 7274 5f69  r = dest_start_i
    │ │ │ -00048560: 6478 3b0a 0a09 092f 2f20 7468 6520 6e75  dx;....// the nu
    │ │ │ -00048570: 6d62 6572 206f 6620 7472 6565 206c 6576  mber of tree lev
    │ │ │ -00048580: 656c 7320 696e 2061 2070 6965 6365 2068  els in a piece h
    │ │ │ -00048590: 6173 682e 2030 206d 6561 6e73 2074 6865  ash. 0 means the
    │ │ │ -000485a0: 2062 6c6f 636b 206c 6179 6572 2069 730a   block layer is.
    │ │ │ -000485b0: 0909 2f2f 2074 6865 2073 616d 6520 6173  ..// the same as
    │ │ │ -000485c0: 2074 6865 2070 6965 6365 206c 6179 6572   the piece layer
    │ │ │ -000485d0: 0a09 0969 6e74 2063 6f6e 7374 2062 6173  ...int const bas
    │ │ │ -000485e0: 6520 3d20 7069 6563 655f 6c65 7665 6c73  e = piece_levels
    │ │ │ -000485f0: 2829 3b0a 0a3c 6469 7620 7374 796c 653d  ();..
    ..for (int la │ │ │ -00048630: 7965 725f 7369 7a65 203d 206c 6561 665f yer_size = leaf_ │ │ │ -00048640: 636f 756e 743b 206c 6179 6572 5f73 697a count; layer_siz │ │ │ -00048650: 6520 213d 2030 3b20 6c61 7965 725f 7369 e != 0; layer_si │ │ │ -00048660: 7a65 202f 3d20 3229 0a3c 2f64 6976 3e09 ze /= 2).
    . │ │ │ -00048670: 097b 0a09 0909 666f 7220 2869 6e74 2069 .{....for (int i │ │ │ -00048680: 203d 2030 3b20 6920 266c 743b 206c 6179 = 0; i < lay │ │ │ -00048690: 6572 5f73 697a 653b 202b 2b69 290a 0909 er_size; ++i)... │ │ │ -000486a0: 097b 0a09 0909 0969 6e74 2063 6f6e 7374 .{.....int const │ │ │ -000486b0: 2064 7374 5f69 6478 203d 2064 6573 745f dst_idx = dest_ │ │ │ -000486c0: 6375 7273 6f72 202b 2069 3b0a 0909 0909 cursor + i;..... │ │ │ -000486d0: 696e 7420 636f 6e73 7420 7372 635f 6964 int const src_id │ │ │ -000486e0: 7820 3d20 736f 7572 6365 5f63 7572 736f x = source_curso │ │ │ -000486f0: 7220 2b20 693b 0a09 0909 0969 6620 2868 r + i;.....if (h │ │ │ -00048700: 6173 5f6e 6f64 6528 6473 745f 6964 7829 as_node(dst_idx) │ │ │ -00048710: 290a 0909 0909 7b0a 0909 0909 0969 6620 ).....{......if │ │ │ -00048720: 286d 5f74 7265 655b 6473 745f 6964 785d (m_tree[dst_idx] │ │ │ -00048730: 2021 3d20 7472 6565 5b73 7263 5f69 6478 != tree[src_idx │ │ │ -00048740: 5d29 0a09 0909 0909 7b0a 0909 0909 0909 ])......{....... │ │ │ -00048750: 2f2f 2074 6869 7320 6d75 7374 2062 6520 // this must be │ │ │ -00048760: 6120 626c 6f63 6b20 6861 7368 2062 6563 a block hash bec │ │ │ -00048770: 6175 7365 2069 6e6e 6572 206e 6f64 6573 ause inner nodes │ │ │ -00048780: 2061 7265 206e 6f74 2066 696c 6c65 6420 are not filled │ │ │ -00048790: 696e 2075 6e74 696c 0a09 0909 0909 092f in until......./ │ │ │ -000487a0: 2f20 7468 6579 2063 616e 2062 6520 7665 / they can be ve │ │ │ -000487b0: 7269 6669 6564 2e20 5468 6973 2061 7373 rified. This ass │ │ │ -000487c0: 6572 7420 656e 7375 7265 7320 7765 2772 ert ensures we'r │ │ │ -000487d0: 6520 6174 2074 6865 0a09 0909 0909 092f e at the......./ │ │ │ -000487e0: 2f20 6c65 6166 206c 6179 6572 206f 6620 / leaf layer of │ │ │ -000487f0: 7468 6520 6669 6c65 2074 7265 650a 0909 the file tree... │ │ │ -00048800: 0909 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -00048810: 5254 2864 7374 5f69 6478 2026 6774 3b3d RT(dst_idx >= │ │ │ -00048820: 2066 6972 7374 5f6c 6561 6629 3b0a 0a09 first_leaf);... │ │ │ -00048830: 0909 0909 0969 6e74 2063 6f6e 7374 2070 .....int const p │ │ │ -00048840: 6f73 203d 2064 7374 5f69 6478 202d 2066 os = dst_idx - f │ │ │ -00048850: 6972 7374 5f6c 6561 663b 0a09 0909 0909 irst_leaf;...... │ │ │ -00048860: 0961 7574 6f20 636f 6e73 7420 7069 6563 .auto const piec │ │ │ -00048870: 6520 3d20 7069 6563 655f 696e 6465 785f e = piece_index_ │ │ │ -00048880: 747b 706f 7320 2667 743b 2667 743b 206d t{pos >> m │ │ │ -00048890: 5f62 6c6f 636b 735f 7065 725f 7069 6563 _blocks_per_piec │ │ │ -000488a0: 655f 6c6f 677d 202b 2066 696c 655f 7069 e_log} + file_pi │ │ │ -000488b0: 6563 655f 6f66 6673 6574 3b0a 0909 0909 ece_offset;..... │ │ │ -000488c0: 0909 696e 7420 636f 6e73 7420 626c 6f63 ..int const bloc │ │ │ -000488d0: 6b20 3d20 706f 7320 2661 6d70 3b20 2828 k = pos & (( │ │ │ -000488e0: 3120 266c 743b 266c 743b 206d 5f62 6c6f 1 << m_blo │ │ │ -000488f0: 636b 735f 7065 725f 7069 6563 655f 6c6f cks_per_piece_lo │ │ │ -00048900: 6729 202d 2031 293b 0a0a 0909 0909 0909 g) - 1);........ │ │ │ -00048910: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ -00048920: 6f73 2026 6c74 3b20 6d5f 6e75 6d5f 626c os < m_num_bl │ │ │ -00048930: 6f63 6b73 293b 0a09 0909 0909 0969 6620 ocks);.......if │ │ │ -00048940: 2821 7265 742e 6661 696c 6564 2e65 6d70 (!ret.failed.emp │ │ │ -00048950: 7479 2829 2026 616d 703b 2661 6d70 3b20 ty() && │ │ │ -00048960: 7265 742e 6661 696c 6564 2e62 6163 6b28 ret.failed.back( │ │ │ -00048970: 292e 6669 7273 7420 3d3d 2070 6965 6365 ).first == piece │ │ │ -00048980: 290a 0909 0909 0909 0972 6574 2e66 6169 )........ret.fai │ │ │ -00048990: 6c65 642e 6261 636b 2829 2e73 6563 6f6e led.back().secon │ │ │ -000489a0: 642e 7075 7368 5f62 6163 6b28 626c 6f63 d.push_back(bloc │ │ │ -000489b0: 6b29 3b0a 0909 0909 0909 656c 7365 0a09 k);.......else.. │ │ │ -000489c0: 0909 0909 0909 7265 742e 6661 696c 6564 ......ret.failed │ │ │ -000489d0: 2e65 6d70 6c61 6365 5f62 6163 6b28 7069 .emplace_back(pi │ │ │ -000489e0: 6563 652c 2073 7464 3a3a 7665 6374 6f72 ece, std::vector │ │ │ -000489f0: 266c 743b 696e 7426 6774 3b7b 626c 6f63 <int>{bloc │ │ │ -00048a00: 6b7d 293b 0a0a 0909 0909 0909 2f2f 206e k});........// n │ │ │ -00048a10: 6f77 2074 6861 7420 7468 6973 2068 6173 ow that this has │ │ │ -00048a20: 6820 6861 7320 6265 656e 2072 6570 6f72 h has been repor │ │ │ -00048a30: 7465 6420 6173 2066 6169 6c69 6e67 2c20 ted as failing, │ │ │ -00048a40: 7765 0a09 0909 0909 092f 2f20 6361 6e20 we.......// can │ │ │ -00048a50: 636c 6561 7220 6974 2e20 5468 6973 2077 clear it. This w │ │ │ -00048a60: 696c 6c20 7072 6576 656e 7420 6974 2066 ill prevent it f │ │ │ -00048a70: 726f 6d20 6265 696e 670a 0909 0909 0909 rom being....... │ │ │ -00048a80: 2f2f 2072 6570 6f72 7465 6420 6173 2066 // reported as f │ │ │ -00048a90: 6169 6c69 6e67 2061 6761 696e 2e0a 0909 ailing again.... │ │ │ -00048aa0: 0909 0909 6d5f 7472 6565 5b64 7374 5f69 ....m_tree[dst_i │ │ │ -00048ab0: 6478 5d2e 636c 6561 7228 293b 0a09 0909 dx].clear();.... │ │ │ -00048ac0: 0909 7d0a 0909 0909 0965 6c73 6520 6966 ..}......else if │ │ │ -00048ad0: 2028 6473 745f 6964 7820 2667 743b 3d20 (dst_idx >= │ │ │ -00048ae0: 6669 7273 745f 6c65 6166 290a 3c2f 7072 first_leaf).rel │ │ │ -00048b20: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/me │ │ │ -00048b60: 726b 6c65 5f74 7265 652e 6370 703a 3433 rkle_tree.cpp:43 │ │ │ -00048b70: 353c 2f61 3e3c 2f74 643e 3c74 643e 696e 5in │ │ │ -00048b80: 7374 6561 6420 6f66 206f 7665 7277 7269 stead of overwri │ │ │ -00048b90: 7469 6e67 2074 6865 2072 6f6f 7420 616e ting the root an │ │ │ -00048ba0: 6420 636f 6d70 6172 696e 6720 6974 2061 d comparing it a │ │ │ -00048bb0: 6761 696e 7374 2068 6173 6865 735b 5d2c gainst hashes[], │ │ │ -00048bc0: 2077 7269 7465 2061 2066 756e 6374 696f write a functio │ │ │ -00048bd0: 6e73 2074 6861 7420 2a76 616c 6964 6174 ns that *validat │ │ │ -00048be0: 6573 2a20 6120 7472 6565 2062 7920 6a75 es* a tree by ju │ │ │ -00048bf0: 7374 2066 696c 6c69 6e67 2069 7420 7570 st filling it up │ │ │ -00048c00: 2074 6f20 7468 6520 6c65 7665 6c20 6265 to the level be │ │ │ -00048c10: 6c6f 7720 7468 6520 726f 6f74 2061 6e64 low the root and │ │ │ -00048c20: 2074 6865 6e20 7661 6c69 6461 7465 7320 then validates │ │ │ -00048c30: 6974 2e3c 2f74 643e 3c2f 7472 3e3c 7472 it.

    instead of over │ │ │ -00048c90: 7772 6974 696e 6720 7468 6520 726f 6f74 writing the root │ │ │ -00048ca0: 2061 6e64 2063 6f6d 7061 7269 6e67 2069 and comparing i │ │ │ -00048cb0: 740a 6167 6169 6e73 7420 6861 7368 6573 t.against hashes │ │ │ -00048cc0: 5b5d 2c20 7772 6974 6520 6120 6675 6e63 [], write a func │ │ │ -00048cd0: 7469 6f6e 7320 7468 6174 202a 7661 6c69 tions that *vali │ │ │ -00048ce0: 6461 7465 732a 2061 2074 7265 650a 6279 dates* a tree.by │ │ │ -00048cf0: 206a 7573 7420 6669 6c6c 696e 6720 6974 just filling it │ │ │ -00048d00: 2075 7020 746f 2074 6865 206c 6576 656c up to the level │ │ │ -00048d10: 2062 656c 6f77 2074 6865 2072 6f6f 7420 below the root │ │ │ -00048d20: 616e 6420 7468 656e 0a76 616c 6964 6174 and then.validat │ │ │ -00048d30: 6573 2069 742e 3c2f 6832 3e3c 6834 3e2e es it.

    . │ │ │ -00048d40: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ -00048d50: 652e 6370 703a 3433 353c 2f68 343e 3c70 e.cpp:435

    ...& │ │ │ -00048da0: 2661 6d70 3b20 6465 7374 5f73 7461 7274 & dest_start │ │ │ -00048db0: 5f69 6478 2026 6c74 3b20 6669 7273 745f _idx < first_ │ │ │ -00048dc0: 7069 6563 655f 6964 7820 2b20 6e75 6d5f piece_idx + num_ │ │ │ -00048dd0: 7069 6563 6573 2829 290a 0909 7b0a 0909 pieces())...{... │ │ │ -00048de0: 0969 6e74 2063 6f6e 7374 2062 6c6f 636b .int const block │ │ │ -00048df0: 735f 696e 5f70 6965 6365 203d 2031 2026 s_in_piece = 1 & │ │ │ -00048e00: 6c74 3b26 6c74 3b20 6261 7365 3b0a 0a09 lt;< base;... │ │ │ -00048e10: 0909 2f2f 2069 7420 6d61 7920 6e6f 7720 ..// it may now │ │ │ -00048e20: 6265 2070 6f73 7369 626c 6520 746f 2076 be possible to v │ │ │ -00048e30: 6572 6966 7920 7468 6520 6861 7368 6573 erify the hashes │ │ │ -00048e40: 206f 6620 7072 6576 696f 7573 6c79 2072 of previously r │ │ │ -00048e50: 6563 6569 7665 6420 626c 6f63 6b73 0a09 eceived blocks.. │ │ │ -00048e60: 0909 2f2f 2074 7279 2074 6f20 7665 7269 ..// try to veri │ │ │ -00048e70: 6679 2061 7320 6d61 6e79 2063 6869 6c64 fy as many child │ │ │ -00048e80: 206e 6f64 6573 206f 6620 7468 6520 7265 nodes of the re │ │ │ -00048e90: 6365 6976 6564 2068 6173 6865 7320 6173 ceived hashes as │ │ │ -00048ea0: 2070 6f73 7369 626c 650a 0909 0966 6f72 possible....for │ │ │ -00048eb0: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ -00048ec0: 6c74 3b20 696e 7428 6861 7368 6573 2e73 lt; int(hashes.s │ │ │ -00048ed0: 697a 6528 2929 3b20 2b2b 6929 0a09 0909 ize()); ++i).... │ │ │ -00048ee0: 7b0a 0909 0909 696e 7420 636f 6e73 7420 {.....int const │ │ │ -00048ef0: 7069 6563 6520 3d20 6465 7374 5f73 7461 piece = dest_sta │ │ │ -00048f00: 7274 5f69 6478 202b 2069 3b0a 0909 0909 rt_idx + i;..... │ │ │ -00048f10: 6966 2028 7069 6563 6520 2d20 6669 7273 if (piece - firs │ │ │ -00048f20: 745f 7069 6563 655f 6964 7820 2667 743b t_piece_idx > │ │ │ -00048f30: 3d20 6e75 6d5f 7069 6563 6573 2829 290a = num_pieces()). │ │ │ -00048f40: 0909 0909 0962 7265 616b 3b0a 0909 0909 .....break;..... │ │ │ -00048f50: 2f2f 2074 6865 2066 6972 7374 2062 6c6f // the first blo │ │ │ -00048f60: 636b 2069 6e20 7468 6973 2070 6965 6365 ck in this piece │ │ │ -00048f70: 0a09 0909 0969 6e74 2063 6f6e 7374 2062 .....int const b │ │ │ -00048f80: 6c6f 636b 5f69 6478 203d 206d 6572 6b6c lock_idx = merkl │ │ │ -00048f90: 655f 6765 745f 6669 7273 745f 6368 696c e_get_first_chil │ │ │ -00048fa0: 6428 7069 6563 652c 2062 6173 6529 3b0a d(piece, base);. │ │ │ -00048fb0: 0a09 0909 0969 6e74 2063 6f6e 7374 2062 .....int const b │ │ │ -00048fc0: 6c6f 636b 5f65 6e64 5f69 6478 203d 2073 lock_end_idx = s │ │ │ -00048fd0: 7464 3a3a 6d69 6e28 626c 6f63 6b5f 6964 td::min(block_id │ │ │ -00048fe0: 7820 2b20 626c 6f63 6b73 5f69 6e5f 7069 x + blocks_in_pi │ │ │ -00048ff0: 6563 652c 2066 6972 7374 5f6c 6561 6620 ece, first_leaf │ │ │ -00049000: 2b20 6d5f 6e75 6d5f 626c 6f63 6b73 293b + m_num_blocks); │ │ │ -00049010: 0a09 0909 0969 6620 2873 7464 3a3a 616e .....if (std::an │ │ │ -00049020: 795f 6f66 286d 5f74 7265 652e 6265 6769 y_of(m_tree.begi │ │ │ -00049030: 6e28 2920 2b20 626c 6f63 6b5f 6964 780a n() + block_idx. │ │ │ -00049040: 0909 0909 092c 206d 5f74 7265 652e 6265 ....., m_tree.be │ │ │ -00049050: 6769 6e28 2920 2b20 626c 6f63 6b5f 656e gin() + block_en │ │ │ -00049060: 645f 6964 780a 0909 0909 092c 205b 5d28 d_idx......, []( │ │ │ -00049070: 7368 6132 3536 5f68 6173 6820 636f 6e73 sha256_hash cons │ │ │ -00049080: 7426 616d 703b 2068 2920 7b20 7265 7475 t& h) { retu │ │ │ -00049090: 726e 2068 2e69 735f 616c 6c5f 7a65 726f rn h.is_all_zero │ │ │ -000490a0: 7328 293b 207d 2929 0a09 0909 0909 636f s(); }))......co │ │ │ -000490b0: 6e74 696e 7565 3b0a 0a3c 6469 7620 7374 ntinue;..

    ....merkl │ │ │ -000490f0: 655f 6669 6c6c 5f74 7265 6528 6d5f 7472 e_fill_tree(m_tr │ │ │ -00049100: 6565 2c20 626c 6f63 6b73 5f69 6e5f 7069 ee, blocks_in_pi │ │ │ -00049110: 6563 652c 2062 6c6f 636b 5f69 6478 293b ece, block_idx); │ │ │ -00049120: 0a3c 2f64 6976 3e09 0909 0969 6620 286d .
    ....if (m │ │ │ -00049130: 5f74 7265 655b 7069 6563 655d 2021 3d20 _tree[piece] != │ │ │ -00049140: 6861 7368 6573 5b69 5d29 0a09 0909 097b hashes[i]).....{ │ │ │ -00049150: 0a09 0909 0909 6d65 726b 6c65 5f63 6c65 ......merkle_cle │ │ │ -00049160: 6172 5f74 7265 6528 6d5f 7472 6565 2c20 ar_tree(m_tree, │ │ │ -00049170: 626c 6f63 6b73 5f69 6e5f 7069 6563 652c blocks_in_piece, │ │ │ -00049180: 2062 6c6f 636b 5f69 6478 293b 0a09 0909 block_idx);.... │ │ │ -00049190: 0909 2f2f 2077 7269 7465 2062 6163 6b20 ..// write back │ │ │ -000491a0: 7468 6520 636f 7272 6563 7420 6861 7368 the correct hash │ │ │ -000491b0: 0a09 0909 0909 6d5f 7472 6565 5b70 6965 ......m_tree[pie │ │ │ -000491c0: 6365 5d20 3d20 6861 7368 6573 5b69 5d3b ce] = hashes[i]; │ │ │ -000491d0: 0a09 0909 0909 544f 5252 454e 545f 4153 ......TORRENT_AS │ │ │ -000491e0: 5345 5254 2862 6c6f 636b 735f 696e 5f70 SERT(blocks_in_p │ │ │ -000491f0: 6965 6365 203d 3d20 626c 6f63 6b73 5f70 iece == blocks_p │ │ │ -00049200: 6572 5f70 6965 6365 2829 293b 0a0a 0909 er_piece());.... │ │ │ -00049210: 0909 092f 2f20 616e 2065 6d70 7479 2062 ...// an empty b │ │ │ -00049220: 6c6f 636b 7320 7665 6374 6f72 2069 6e64 locks vector ind │ │ │ -00049230: 6963 6174 6573 2074 6861 7420 7765 2064 icates that we d │ │ │ -00049240: 6f6e 2774 2068 6176 6520 7468 650a 0909 on't have the... │ │ │ -00049250: 0909 092f 2f20 626c 6f63 6b20 6861 7368 ...// block hash │ │ │ -00049260: 6573 2c20 616e 6420 7765 2063 616e 2774 es, and we can't │ │ │ -00049270: 206b 6e6f 7720 7768 6963 6820 626c 6f63 know which bloc │ │ │ -00049280: 6b20 6661 696c 6564 0a09 0909 0909 2f2f k failed......// │ │ │ -00049290: 2074 6869 7320 7769 6c6c 2063 6175 7365 this will cause │ │ │ -000492a0: 2074 6865 2062 6c6f 636b 2068 6173 6865 the block hashe │ │ │ -000492b0: 7320 746f 2062 6520 7265 7175 6573 7465 s to be requeste │ │ │ -000492c0: 640a 0909 0909 0972 6574 2e66 6169 6c65 d......ret.faile │ │ │ -000492d0: 642e 656d 706c 6163 655f 6261 636b 2870 d.emplace_back(p │ │ │ -000492e0: 6965 6365 5f69 6e64 6578 5f74 7b70 6965 iece_index_t{pie │ │ │ -000492f0: 6365 202d 2066 6972 7374 5f70 6965 6365 ce - first_piece │ │ │ -00049300: 5f69 6478 7d20 2b20 6669 6c65 5f70 6965 _idx} + file_pie │ │ │ -00049310: 6365 5f6f 6666 7365 740a 0909 0909 0909 ce_offset....... │ │ │ -00049320: 2c20 7374 643a 3a76 6563 746f 7226 6c74 , std::vector< │ │ │ -00049330: 3b69 6e74 2667 743b 2829 293b 0a09 0909 ;int>());.... │ │ │ -00049340: 097d 0a09 0909 0965 6c73 650a 0909 0909 .}.....else..... │ │ │ -00049350: 7b0a 0909 0909 0972 6574 2e70 6173 7365 {......ret.passe │ │ │ -00049360: 642e 7075 7368 5f62 6163 6b28 7069 6563 d.push_back(piec │ │ │ -00049370: 655f 696e 6465 785f 747b 7069 6563 6520 e_index_t{piece │ │ │ -00049380: 2d20 6669 7273 745f 7069 6563 655f 6964 - first_piece_id │ │ │ -00049390: 787d 202b 2066 696c 655f 7069 6563 655f x} + file_piece_ │ │ │ -000493a0: 6f66 6673 6574 293b 0a09 0909 0909 2f2f offset);......// │ │ │ -000493b0: 2072 6563 6f72 6420 7468 6174 2074 6865 record that the │ │ │ -000493c0: 7365 2062 6c6f 636b 2068 6173 6865 7320 se block hashes │ │ │ -000493d0: 6172 6520 636f 7272 6563 7421 0a09 0909 are correct!.... │ │ │ -000493e0: 0909 696e 7420 636f 6e73 7420 6c65 6166 ..int const leaf │ │ │ -000493f0: 735f 7374 6172 7420 3d20 626c 6f63 6b5f s_start = block_ │ │ │ -00049400: 6964 7820 2d20 626c 6f63 6b5f 6c61 7965 idx - block_laye │ │ │ -00049410: 725f 7374 6172 7428 293b 0a09 0909 0909 r_start();...... │ │ │ -00049420: 696e 7420 636f 6e73 7420 6c65 6166 735f int const leafs_ │ │ │ -00049430: 656e 6420 3d20 7374 643a 3a6d 696e 286d end = std::min(m │ │ │ -00049440: 5f6e 756d 5f62 6c6f 636b 732c 206c 6561 _num_blocks, lea │ │ │ -00049450: 6673 5f73 7461 7274 202b 2062 6c6f 636b fs_start + block │ │ │ -00049460: 735f 696e 5f70 6965 6365 293b 0a3c 2f70 s_in_piece);.

    re │ │ │ -000494a0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ -000494e0: 6572 6b6c 655f 7472 6565 2e63 7070 3a34 erkle_tree.cpp:4 │ │ │ -000494f0: 3539 3c2f 613e 3c2f 7464 3e3c 7464 3e74 59t │ │ │ -00049500: 6869 7320 636f 756c 6420 6265 2064 6f6e his could be don │ │ │ -00049510: 6520 6d6f 7265 2065 6666 6963 6965 6e74 e more efficient │ │ │ -00049520: 6c79 2069 6620 6269 7466 6965 6c64 2068 ly if bitfield h │ │ │ -00049530: 6164 2061 2066 756e 6374 696f 6e20 746f ad a function to │ │ │ -00049540: 2073 6574 2061 2072 616e 6765 206f 6620 set a range of │ │ │ -00049550: 6269 7473 3c2f 7464 3e3c 2f74 723e 3c74 bitsthis could be │ │ │ -000495b0: 646f 6e65 206d 6f72 6520 6566 6669 6369 done more effici │ │ │ -000495c0: 656e 746c 7920 6966 2062 6974 6669 656c ently if bitfiel │ │ │ -000495d0: 6420 6861 6420 6120 6675 6e63 7469 6f6e d had a function │ │ │ -000495e0: 0a74 6f20 7365 7420 6120 7261 6e67 6520 .to set a range │ │ │ -000495f0: 6f66 2062 6974 733c 2f68 323e 3c68 343e of bits

    │ │ │ -00049600: 2e2e 2f73 7263 2f6d 6572 6b6c 655f 7472 ../src/merkle_tr │ │ │ -00049610: 6565 2e63 7070 3a34 3539 3c2f 6834 3e3c ee.cpp:459

    < │ │ │ -00049620: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00049630: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00049640: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00049650: 7820 2364 6464 3b22 3e09 0909 096d 6572 x #ddd;">....mer │ │ │ -00049660: 6b6c 655f 6669 6c6c 5f74 7265 6528 6d5f kle_fill_tree(m_ │ │ │ -00049670: 7472 6565 2c20 626c 6f63 6b73 5f69 6e5f tree, blocks_in_ │ │ │ -00049680: 7069 6563 652c 2062 6c6f 636b 5f69 6478 piece, block_idx │ │ │ -00049690: 293b 0a09 0909 0969 6620 286d 5f74 7265 );.....if (m_tre │ │ │ -000496a0: 655b 7069 6563 655d 2021 3d20 6861 7368 e[piece] != hash │ │ │ -000496b0: 6573 5b69 5d29 0a09 0909 097b 0a09 0909 es[i]).....{.... │ │ │ -000496c0: 0909 6d65 726b 6c65 5f63 6c65 6172 5f74 ..merkle_clear_t │ │ │ -000496d0: 7265 6528 6d5f 7472 6565 2c20 626c 6f63 ree(m_tree, bloc │ │ │ -000496e0: 6b73 5f69 6e5f 7069 6563 652c 2062 6c6f ks_in_piece, blo │ │ │ -000496f0: 636b 5f69 6478 293b 0a09 0909 0909 2f2f ck_idx);......// │ │ │ -00049700: 2077 7269 7465 2062 6163 6b20 7468 6520 write back the │ │ │ -00049710: 636f 7272 6563 7420 6861 7368 0a09 0909 correct hash.... │ │ │ -00049720: 0909 6d5f 7472 6565 5b70 6965 6365 5d20 ..m_tree[piece] │ │ │ -00049730: 3d20 6861 7368 6573 5b69 5d3b 0a09 0909 = hashes[i];.... │ │ │ -00049740: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00049750: 2862 6c6f 636b 735f 696e 5f70 6965 6365 (blocks_in_piece │ │ │ -00049760: 203d 3d20 626c 6f63 6b73 5f70 6572 5f70 == blocks_per_p │ │ │ -00049770: 6965 6365 2829 293b 0a0a 0909 0909 092f iece());......./ │ │ │ -00049780: 2f20 616e 2065 6d70 7479 2062 6c6f 636b / an empty block │ │ │ -00049790: 7320 7665 6374 6f72 2069 6e64 6963 6174 s vector indicat │ │ │ -000497a0: 6573 2074 6861 7420 7765 2064 6f6e 2774 es that we don't │ │ │ -000497b0: 2068 6176 6520 7468 650a 0909 0909 092f have the....../ │ │ │ -000497c0: 2f20 626c 6f63 6b20 6861 7368 6573 2c20 / block hashes, │ │ │ -000497d0: 616e 6420 7765 2063 616e 2774 206b 6e6f and we can't kno │ │ │ -000497e0: 7720 7768 6963 6820 626c 6f63 6b20 6661 w which block fa │ │ │ -000497f0: 696c 6564 0a09 0909 0909 2f2f 2074 6869 iled......// thi │ │ │ -00049800: 7320 7769 6c6c 2063 6175 7365 2074 6865 s will cause the │ │ │ -00049810: 2062 6c6f 636b 2068 6173 6865 7320 746f block hashes to │ │ │ -00049820: 2062 6520 7265 7175 6573 7465 640a 0909 be requested... │ │ │ -00049830: 0909 0972 6574 2e66 6169 6c65 642e 656d ...ret.failed.em │ │ │ -00049840: 706c 6163 655f 6261 636b 2870 6965 6365 place_back(piece │ │ │ -00049850: 5f69 6e64 6578 5f74 7b70 6965 6365 202d _index_t{piece - │ │ │ -00049860: 2066 6972 7374 5f70 6965 6365 5f69 6478 first_piece_idx │ │ │ -00049870: 7d20 2b20 6669 6c65 5f70 6965 6365 5f6f } + file_piece_o │ │ │ -00049880: 6666 7365 740a 0909 0909 0909 2c20 7374 ffset......., st │ │ │ -00049890: 643a 3a76 6563 746f 7226 6c74 3b69 6e74 d::vector<int │ │ │ -000498a0: 2667 743b 2829 293b 0a09 0909 097d 0a09 >());.....}.. │ │ │ -000498b0: 0909 0965 6c73 650a 0909 0909 7b0a 0909 ...else.....{... │ │ │ -000498c0: 0909 0972 6574 2e70 6173 7365 642e 7075 ...ret.passed.pu │ │ │ -000498d0: 7368 5f62 6163 6b28 7069 6563 655f 696e sh_back(piece_in │ │ │ -000498e0: 6465 785f 747b 7069 6563 6520 2d20 6669 dex_t{piece - fi │ │ │ -000498f0: 7273 745f 7069 6563 655f 6964 787d 202b rst_piece_idx} + │ │ │ -00049900: 2066 696c 655f 7069 6563 655f 6f66 6673 file_piece_offs │ │ │ -00049910: 6574 293b 0a09 0909 0909 2f2f 2072 6563 et);......// rec │ │ │ -00049920: 6f72 6420 7468 6174 2074 6865 7365 2062 ord that these b │ │ │ -00049930: 6c6f 636b 2068 6173 6865 7320 6172 6520 lock hashes are │ │ │ -00049940: 636f 7272 6563 7421 0a09 0909 0909 696e correct!......in │ │ │ -00049950: 7420 636f 6e73 7420 6c65 6166 735f 7374 t const leafs_st │ │ │ -00049960: 6172 7420 3d20 626c 6f63 6b5f 6964 7820 art = block_idx │ │ │ -00049970: 2d20 626c 6f63 6b5f 6c61 7965 725f 7374 - block_layer_st │ │ │ -00049980: 6172 7428 293b 0a09 0909 0909 696e 7420 art();......int │ │ │ -00049990: 636f 6e73 7420 6c65 6166 735f 656e 6420 const leafs_end │ │ │ -000499a0: 3d20 7374 643a 3a6d 696e 286d 5f6e 756d = std::min(m_num │ │ │ -000499b0: 5f62 6c6f 636b 732c 206c 6561 6673 5f73 _blocks, leafs_s │ │ │ -000499c0: 7461 7274 202b 2062 6c6f 636b 735f 696e tart + blocks_in │ │ │ -000499d0: 5f70 6965 6365 293b 0a3c 6469 7620 7374 _piece);.
    .....for │ │ │ -00049a10: 2869 6e74 206b 203d 206c 6561 6673 5f73 (int k = leafs_s │ │ │ -00049a20: 7461 7274 3b20 6b20 266c 743b 206c 6561 tart; k < lea │ │ │ -00049a30: 6673 5f65 6e64 3b20 2b2b 6b29 0a3c 2f64 fs_end; ++k).......m_block │ │ │ -00049a50: 5f76 6572 6966 6965 642e 7365 745f 6269 _verified.set_bi │ │ │ -00049a60: 7428 6b29 3b0a 0909 0909 7d0a 0909 0909 t(k);.....}..... │ │ │ -00049a70: 544f 5252 454e 545f 4153 5345 5254 2828 TORRENT_ASSERT(( │ │ │ -00049a80: 7069 6563 6520 2d20 6669 7273 745f 7069 piece - first_pi │ │ │ -00049a90: 6563 655f 6964 7829 2026 6774 3b3d 2030 ece_idx) >= 0 │ │ │ -00049aa0: 293b 0a09 0909 7d0a 0909 7d0a 0a09 096f );....}...}....o │ │ │ -00049ab0: 7074 696d 697a 655f 7374 6f72 6167 6528 ptimize_storage( │ │ │ -00049ac0: 293b 0a0a 0909 7265 7475 726e 2072 6574 );....return ret │ │ │ -00049ad0: 3b0a 097d 0a0a 0973 7464 3a3a 7475 706c ;..}...std::tupl │ │ │ -00049ae0: 6526 6c74 3b6d 6572 6b6c 655f 7472 6565 e<merkle_tree │ │ │ -00049af0: 3a3a 7365 745f 626c 6f63 6b5f 7265 7375 ::set_block_resu │ │ │ -00049b00: 6c74 2c20 696e 742c 2069 6e74 2667 743b lt, int, int> │ │ │ -00049b10: 206d 6572 6b6c 655f 7472 6565 3a3a 7365 merkle_tree::se │ │ │ -00049b20: 745f 626c 6f63 6b28 696e 7420 636f 6e73 t_block(int cons │ │ │ -00049b30: 7420 626c 6f63 6b5f 696e 6465 780a 0909 t block_index... │ │ │ -00049b40: 2c20 7368 6132 3536 5f68 6173 6820 636f , sha256_hash co │ │ │ -00049b50: 6e73 7426 616d 703b 2068 290a 097b 0a23 nst& h)..{.# │ │ │ -00049b60: 6966 6465 6620 544f 5252 454e 545f 4558 ifdef TORRENT_EX │ │ │ -00049b70: 5045 4e53 4956 455f 494e 5641 5249 414e PENSIVE_INVARIAN │ │ │ -00049b80: 545f 4348 4543 4b53 0a09 0949 4e56 4152 T_CHECKS...INVAR │ │ │ -00049b90: 4941 4e54 5f43 4845 434b 3b0a 2365 6e64 IANT_CHECK;.#end │ │ │ -00049ba0: 6966 0a09 0954 4f52 5245 4e54 5f41 5353 if...TORRENT_ASS │ │ │ -00049bb0: 4552 5428 626c 6f63 6b5f 696e 6465 7820 ERT(block_index │ │ │ -00049bc0: 266c 743b 206d 5f6e 756d 5f62 6c6f 636b < m_num_block │ │ │ -00049bd0: 7329 3b0a 0a09 0961 7574 6f20 636f 6e73 s);....auto cons │ │ │ -00049be0: 7420 6e75 6d5f 6c65 6166 7320 3d20 6d65 t num_leafs = me │ │ │ -00049bf0: 726b 6c65 5f6e 756d 5f6c 6561 6673 286d rkle_num_leafs(m │ │ │ -00049c00: 5f6e 756d 5f62 6c6f 636b 7329 3b0a 0909 _num_blocks);... │ │ │ -00049c10: 6175 746f 2063 6f6e 7374 2066 6972 7374 auto const first │ │ │ -00049c20: 5f6c 6561 6620 3d20 6d65 726b 6c65 5f66 _leaf = merkle_f │ │ │ -00049c30: 6972 7374 5f6c 6561 6628 6e75 6d5f 6c65 irst_leaf(num_le │ │ │ -00049c40: 6166 7329 3b0a 0909 6175 746f 2063 6f6e afs);...auto con │ │ │ -00049c50: 7374 2062 6c6f 636b 5f74 7265 655f 696e st block_tree_in │ │ │ -00049c60: 6465 7820 3d20 6669 7273 745f 6c65 6166 dex = first_leaf │ │ │ -00049c70: 202b 2062 6c6f 636b 5f69 6e64 6578 3b0a + block_index;. │ │ │ -00049c80: 0a09 0969 6620 2862 6c6f 636b 735f 7665 ...if (blocks_ve │ │ │ -00049c90: 7269 6669 6564 2862 6c6f 636b 5f69 6e64 rified(block_ind │ │ │ -00049ca0: 6578 2c20 3129 290a 0909 7b0a 0909 092f ex, 1))...{..../ │ │ │ -00049cb0: 2f20 6966 2074 6869 7320 626c 6f63 6b73 / if this blocks │ │ │ -00049cc0: 2773 2068 6173 6820 6973 2061 6c72 6561 's hash is alrea │ │ │ -00049cd0: 6479 206b 6e6f 776e 2c20 6368 6563 6b20 dy known, check │ │ │ -00049ce0: 7468 6520 7061 7373 6564 2d69 6e20 6861 the passed-in ha │ │ │ -00049cf0: 7368 2061 6761 696e 7374 2069 740a 0909 sh against it... │ │ │ -00049d00: 0969 6620 2863 6f6d 7061 7265 5f6e 6f64 .if (compare_nod │ │ │ -00049d10: 6528 626c 6f63 6b5f 7472 6565 5f69 6e64 e(block_tree_ind │ │ │ -00049d20: 6578 2c20 6829 290a 0909 0909 7265 7475 ex, h)).....retu │ │ │ -00049d30: 726e 2073 7464 3a3a 6d61 6b65 5f74 7570 rn std::make_tup │ │ │ -00049d40: 6c65 2873 6574 5f62 6c6f 636b 5f72 6573 le(set_block_res │ │ │ -00049d50: 756c 743a 3a6f 6b2c 2062 6c6f 636b 5f69 ult::ok, block_i │ │ │ -00049d60: 6e64 6578 2c20 3129 3b0a 0909 0965 6c73 ndex, 1);....els │ │ │ -00049d70: 650a 0909 0909 7265 7475 726e 2073 7464 e.....return std │ │ │ -00049d80: 3a3a 6d61 6b65 5f74 7570 6c65 2873 6574 ::make_tuple(set │ │ │ -00049d90: 5f62 6c6f 636b 5f72 6573 756c 743a 3a62 _block_result::b │ │ │ -00049da0: 6c6f 636b 5f68 6173 685f 6661 696c 6564 lock_hash_failed │ │ │ -00049db0: 2c20 626c 6f63 6b5f 696e 6465 782c 2031 , block_index, 1 │ │ │ -00049dc0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -00049df0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00049e00: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00049e30: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ -00049e40: 2e63 7070 3a35 3233 3c2f 613e 3c2f 7464 .cpp:523this could │ │ │ -00049e60: 6265 2064 6f6e 6520 6d6f 7265 2065 6666 be done more eff │ │ │ -00049e70: 6963 6965 6e74 6c79 2069 6620 6269 7466 iciently if bitf │ │ │ -00049e80: 6965 6c64 2068 6164 2061 2066 756e 6374 ield had a funct │ │ │ -00049e90: 696f 6e20 746f 2073 6574 2061 2072 616e ion to set a ran │ │ │ -00049ea0: 6765 206f 6620 6269 7473 3c2f 7464 3e3c ge of bits< │ │ │ -00049eb0: 2f74 723e 3c74 7220 6964 3d22 3137 3922 /tr>

    this cou │ │ │ -00049f00: 6c64 2062 6520 646f 6e65 206d 6f72 6520 ld be done more │ │ │ -00049f10: 6566 6669 6369 656e 746c 7920 6966 2062 efficiently if b │ │ │ -00049f20: 6974 6669 656c 6420 6861 6420 6120 6675 itfield had a fu │ │ │ -00049f30: 6e63 7469 6f6e 0a74 6f20 7365 7420 6120 nction.to set a │ │ │ -00049f40: 7261 6e67 6520 6f66 2062 6974 733c 2f68 range of bits

    ../src/mer │ │ │ -00049f60: 6b6c 655f 7472 6565 2e63 7070 3a35 3233 kle_tree.cpp:523 │ │ │ -00049f70: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00049fb0: 0909 6d65 726b 6c65 5f66 696e 645f 6b6e  ..merkle_find_kn
    │ │ │ -00049fc0: 6f77 6e5f 7375 6274 7265 6528 6d5f 7472  own_subtree(m_tr
    │ │ │ -00049fd0: 6565 2c20 626c 6f63 6b5f 696e 6465 782c  ee, block_index,
    │ │ │ -00049fe0: 206d 5f6e 756d 5f62 6c6f 636b 7329 3b0a   m_num_blocks);.
    │ │ │ -00049ff0: 0a09 092f 2f20 6966 2074 6865 2072 6f6f  ...// if the roo
    │ │ │ -0004a000: 7420 6e6f 6465 2069 7320 756e 6b6e 6f77  t node is unknow
    │ │ │ -0004a010: 6e20 7468 6520 6861 7368 6573 2063 616e  n the hashes can
    │ │ │ -0004a020: 6e6f 7420 6265 2076 6572 6966 6965 6420  not be verified 
    │ │ │ -0004a030: 7965 740a 0909 6966 2028 6d5f 7472 6565  yet...if (m_tree
    │ │ │ -0004a040: 5b72 6f6f 745f 696e 6465 785d 2e69 735f  [root_index].is_
    │ │ │ -0004a050: 616c 6c5f 7a65 726f 7328 2929 0a09 0909  all_zeros())....
    │ │ │ -0004a060: 7265 7475 726e 2073 7464 3a3a 6d61 6b65  return std::make
    │ │ │ -0004a070: 5f74 7570 6c65 2873 6574 5f62 6c6f 636b  _tuple(set_block
    │ │ │ -0004a080: 5f72 6573 756c 743a 3a75 6e6b 6e6f 776e  _result::unknown
    │ │ │ -0004a090: 2c20 6c65 6166 735f 7374 6172 742c 206c  , leafs_start, l
    │ │ │ -0004a0a0: 6561 6673 5f73 697a 6529 3b0a 0a09 092f  eafs_size);..../
    │ │ │ -0004a0b0: 2f20 7361 7665 2074 6865 2072 6f6f 7420  / save the root 
    │ │ │ -0004a0c0: 6861 7368 2062 6563 6175 7365 206d 6572  hash because mer
    │ │ │ -0004a0d0: 6b6c 655f 6669 6c6c 5f74 7265 6520 7769  kle_fill_tree wi
    │ │ │ -0004a0e0: 6c6c 206f 7665 7277 7269 7465 2069 740a  ll overwrite it.
    │ │ │ -0004a0f0: 0909 7368 6132 3536 5f68 6173 6820 636f  ..sha256_hash co
    │ │ │ -0004a100: 6e73 7420 726f 6f74 203d 206d 5f74 7265  nst root = m_tre
    │ │ │ -0004a110: 655b 726f 6f74 5f69 6e64 6578 5d3b 0a09  e[root_index];..
    │ │ │ -0004a120: 096d 6572 6b6c 655f 6669 6c6c 5f74 7265  .merkle_fill_tre
    │ │ │ -0004a130: 6528 6d5f 7472 6565 2c20 6c65 6166 735f  e(m_tree, leafs_
    │ │ │ -0004a140: 7369 7a65 2c20 6669 7273 745f 6c65 6166  size, first_leaf
    │ │ │ -0004a150: 202b 206c 6561 6673 5f73 7461 7274 293b   + leafs_start);
    │ │ │ -0004a160: 0a0a 0909 6966 2028 726f 6f74 2021 3d20  ....if (root != 
    │ │ │ -0004a170: 6d5f 7472 6565 5b72 6f6f 745f 696e 6465  m_tree[root_inde
    │ │ │ -0004a180: 785d 290a 0909 7b0a 0909 092f 2f20 6861  x])...{....// ha
    │ │ │ -0004a190: 7368 2066 6169 6c75 7265 2c20 636c 6561  sh failure, clea
    │ │ │ -0004a1a0: 7220 616c 6c20 7468 6520 696e 7465 726e  r all the intern
    │ │ │ -0004a1b0: 616c 206e 6f64 6573 0a09 0909 2f2f 2074  al nodes....// t
    │ │ │ -0004a1c0: 6865 2077 686f 6c65 2070 6965 6365 2066  he whole piece f
    │ │ │ -0004a1d0: 6169 6c65 6420 7468 6520 6861 7368 2063  ailed the hash c
    │ │ │ -0004a1e0: 6865 636b 2e20 436c 6561 7220 616c 6c20  heck. Clear all 
    │ │ │ -0004a1f0: 626c 6f63 6b20 6861 7368 6573 0a09 0909  block hashes....
    │ │ │ -0004a200: 2f2f 2069 6e20 7468 6973 2070 6965 6365  // in this piece
    │ │ │ -0004a210: 2061 6e64 2072 6570 6f72 7420 6120 6861   and report a ha
    │ │ │ -0004a220: 7368 2066 6169 6c75 7265 0a09 0909 6d65  sh failure....me
    │ │ │ -0004a230: 726b 6c65 5f63 6c65 6172 5f74 7265 6528  rkle_clear_tree(
    │ │ │ -0004a240: 6d5f 7472 6565 2c20 6c65 6166 735f 7369  m_tree, leafs_si
    │ │ │ -0004a250: 7a65 2c20 6669 7273 745f 6c65 6166 202b  ze, first_leaf +
    │ │ │ -0004a260: 206c 6561 6673 5f73 7461 7274 293b 0a09   leafs_start);..
    │ │ │ -0004a270: 0909 6d5f 7472 6565 5b72 6f6f 745f 696e  ..m_tree[root_in
    │ │ │ -0004a280: 6465 785d 203d 2072 6f6f 743b 0a09 0909  dex] = root;....
    │ │ │ -0004a290: 7265 7475 726e 2073 7464 3a3a 6d61 6b65  return std::make
    │ │ │ -0004a2a0: 5f74 7570 6c65 2873 6574 5f62 6c6f 636b  _tuple(set_block
    │ │ │ -0004a2b0: 5f72 6573 756c 743a 3a68 6173 685f 6661  _result::hash_fa
    │ │ │ -0004a2c0: 696c 6564 2c20 6c65 6166 735f 7374 6172  iled, leafs_star
    │ │ │ -0004a2d0: 742c 206c 6561 6673 5f73 697a 6529 3b0a  t, leafs_size);.
    │ │ │ -0004a2e0: 0909 7d0a 0a3c 6469 7620 7374 796c 653d  ..}..
    ..int const l │ │ │ -0004a320: 6561 6673 5f65 6e64 203d 2073 7464 3a3a eafs_end = std:: │ │ │ -0004a330: 6d69 6e28 6d5f 6e75 6d5f 626c 6f63 6b73 min(m_num_blocks │ │ │ -0004a340: 2c20 6c65 6166 735f 7374 6172 7420 2b20 , leafs_start + │ │ │ -0004a350: 6c65 6166 735f 7369 7a65 293b 0a3c 2f64 leafs_size);...for (int i │ │ │ -0004a370: 3d20 6c65 6166 735f 7374 6172 743b 2069 = leafs_start; i │ │ │ -0004a380: 2026 6c74 3b20 6c65 6166 735f 656e 643b < leafs_end; │ │ │ -0004a390: 202b 2b69 290a 0909 096d 5f62 6c6f 636b ++i)....m_block │ │ │ -0004a3a0: 5f76 6572 6966 6965 642e 7365 745f 6269 _verified.set_bi │ │ │ -0004a3b0: 7428 6929 3b0a 0a09 092f 2f20 6174 7465 t(i);....// atte │ │ │ -0004a3c0: 6d70 7469 6e67 2074 6f20 6f70 7469 6d69 mpting to optimi │ │ │ -0004a3d0: 7a65 2073 746f 7261 6765 2069 7320 7175 ze storage is qu │ │ │ -0004a3e0: 6974 6520 636f 7374 6c79 2c20 6f6e 6c79 ite costly, only │ │ │ -0004a3f0: 2064 6f20 6974 2069 6620 7765 2068 6176 do it if we hav │ │ │ -0004a400: 650a 0909 2f2f 2061 2072 6561 736f 6e20 e...// a reason │ │ │ -0004a410: 746f 2062 656c 6965 7665 2069 7420 6d69 to believe it mi │ │ │ -0004a420: 6768 7420 6861 7665 2061 6e20 6566 6665 ght have an effe │ │ │ -0004a430: 6374 0a09 0969 6620 2862 6c6f 636b 5f69 ct...if (block_i │ │ │ -0004a440: 6e64 6578 203d 3d20 6d5f 6e75 6d5f 626c ndex == m_num_bl │ │ │ -0004a450: 6f63 6b73 202d 2031 207c 7c20 216d 5f74 ocks - 1 || !m_t │ │ │ -0004a460: 7265 655b 626c 6f63 6b5f 7472 6565 5f69 ree[block_tree_i │ │ │ -0004a470: 6e64 6578 202b 2031 5d2e 6973 5f61 6c6c ndex + 1].is_all │ │ │ -0004a480: 5f7a 6572 6f73 2829 290a 0909 096f 7074 _zeros())....opt │ │ │ -0004a490: 696d 697a 655f 7374 6f72 6167 6528 293b imize_storage(); │ │ │ -0004a4a0: 0a0a 0909 7265 7475 726e 2073 7464 3a3a ....return std:: │ │ │ -0004a4b0: 6d61 6b65 5f74 7570 6c65 2873 6574 5f62 make_tuple(set_b │ │ │ -0004a4c0: 6c6f 636b 5f72 6573 756c 743a 3a6f 6b2c lock_result::ok, │ │ │ -0004a4d0: 206c 6561 6673 5f73 7461 7274 2c20 6c65 leafs_start, le │ │ │ -0004a4e0: 6166 735f 7369 7a65 293b 0a09 7d0a 0a09 afs_size);..}... │ │ │ -0004a4f0: 7374 643a 3a73 697a 655f 7420 6d65 726b std::size_t merk │ │ │ -0004a500: 6c65 5f74 7265 653a 3a73 697a 6528 2920 le_tree::size() │ │ │ -0004a510: 636f 6e73 740a 097b 0a09 0972 6574 7572 const..{...retur │ │ │ -0004a520: 6e20 7374 6174 6963 5f63 6173 7426 6c74 n static_cast< │ │ │ -0004a530: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ -0004a540: 286d 6572 6b6c 655f 6e75 6d5f 6e6f 6465 (merkle_num_node │ │ │ -0004a550: 7328 6d65 726b 6c65 5f6e 756d 5f6c 6561 s(merkle_num_lea │ │ │ -0004a560: 6673 286d 5f6e 756d 5f62 6c6f 636b 7329 fs(m_num_blocks) │ │ │ -0004a570: 2929 3b0a 097d 0a0a 0969 6e74 206d 6572 ));..}...int mer │ │ │ -0004a580: 6b6c 655f 7472 6565 3a3a 6e75 6d5f 7069 kle_tree::num_pi │ │ │ -0004a590: 6563 6573 2829 2063 6f6e 7374 0a09 7b0a eces() const..{. │ │ │ -0004a5a0: 0909 696e 7420 636f 6e73 7420 7073 203d ..int const ps = │ │ │ -0004a5b0: 2062 6c6f 636b 735f 7065 725f 7069 6563 blocks_per_piec │ │ │ -0004a5c0: 6528 293b 0a09 0954 4f52 5245 4e54 5f41 e();...TORRENT_A │ │ │ -0004a5d0: 5353 4552 5428 7073 2026 6774 3b20 3029 SSERT(ps > 0) │ │ │ -0004a5e0: 3b0a 0909 7265 7475 726e 2028 6d5f 6e75 ;...return (m_nu │ │ │ -0004a5f0: 6d5f 626c 6f63 6b73 202b 2070 7320 2d20 m_blocks + ps - │ │ │ -0004a600: 3129 2026 6774 3b26 6774 3b20 6d5f 626c 1) >> m_bl │ │ │ -0004a610: 6f63 6b73 5f70 6572 5f70 6965 6365 5f6c ocks_per_piece_l │ │ │ -0004a620: 6f67 3b0a 097d 0a0a 0969 6e74 206d 6572 og;..}...int mer │ │ │ -0004a630: 6b6c 655f 7472 6565 3a3a 626c 6f63 6b5f kle_tree::block_ │ │ │ -0004a640: 6c61 7965 725f 7374 6172 7428 2920 636f layer_start() co │ │ │ -0004a650: 6e73 740a 097b 0a09 0969 6e74 2063 6f6e nst..{...int con │ │ │ -0004a660: 7374 206e 756d 5f6c 6561 6673 203d 206d st num_leafs = m │ │ │ -0004a670: 6572 6b6c 655f 6e75 6d5f 6c65 6166 7328 erkle_num_leafs( │ │ │ -0004a680: 6d5f 6e75 6d5f 626c 6f63 6b73 293b 0a09 m_num_blocks);.. │ │ │ -0004a690: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0004a6a0: 6e75 6d5f 6c65 6166 7320 2667 743b 2030 num_leafs > 0 │ │ │ -0004a6b0: 293b 0a09 0972 6574 7572 6e20 6d65 726b );...return merk │ │ │ -0004a6c0: 6c65 5f66 6972 7374 5f6c 6561 6628 6e75 le_first_leaf(nu │ │ │ -0004a6d0: 6d5f 6c65 6166 7329 3b0a 097d 0a0a 3c2f m_leafs);..}..r │ │ │ -0004a710: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0004a720: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0004a750: 6368 6f6b 6572 2e63 7070 3a32 3335 3c2f choker.cpp:235make │ │ │ -0004a770: 636f 6e66 6967 7572 6162 6c65 3c2f 7464 configurable

    make c │ │ │ -0004a7d0: 6f6e 6669 6775 7261 626c 653c 2f68 323e onfigurable

    │ │ │ -0004a7e0: 3c68 343e 2e2e 2f73 7263 2f63 686f 6b65

    ../src/choke │ │ │ -0004a7f0: 722e 6370 703a 3233 353c 2f68 343e 3c70 r.cpp:235

    ...// fi │ │ │ -0004a840: 7273 7420 7265 7365 7420 7468 6520 6e75 rst reset the nu │ │ │ -0004a850: 6d62 6572 206f 6620 756e 6368 6f6b 6520 mber of unchoke │ │ │ -0004a860: 736c 6f74 732c 2062 6563 6175 7365 2077 slots, because w │ │ │ -0004a870: 6527 6c6c 2063 616c 6375 6c61 7465 0a09 e'll calculate.. │ │ │ -0004a880: 0909 2f2f 2069 7420 7075 7265 6c79 2062 ..// it purely b │ │ │ -0004a890: 6173 6564 206f 6e20 7468 6520 6375 7272 ased on the curr │ │ │ -0004a8a0: 656e 7420 7374 6174 6520 6f66 206f 7572 ent state of our │ │ │ -0004a8b0: 2070 6565 7273 2e0a 0909 0975 706c 6f61 peers.....uploa │ │ │ -0004a8c0: 645f 736c 6f74 7320 3d20 303b 0a0a 0909 d_slots = 0;.... │ │ │ -0004a8d0: 0969 6e74 2072 6174 655f 7468 7265 7368 .int rate_thresh │ │ │ -0004a8e0: 6f6c 6420 3d20 7365 7474 2e67 6574 5f69 old = sett.get_i │ │ │ -0004a8f0: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ -0004a900: 3a3a 7261 7465 5f63 686f 6b65 725f 696e ::rate_choker_in │ │ │ -0004a910: 6974 6961 6c5f 7468 7265 7368 6f6c 6429 itial_threshold) │ │ │ -0004a920: 3b0a 0a09 0909 7374 643a 3a73 6f72 7428 ;.....std::sort( │ │ │ -0004a930: 7065 6572 732e 6265 6769 6e28 292c 2070 peers.begin(), p │ │ │ -0004a940: 6565 7273 2e65 6e64 2829 0a09 0909 092c eers.end()....., │ │ │ -0004a950: 205b 5d28 7065 6572 5f63 6f6e 6e65 6374 [](peer_connect │ │ │ -0004a960: 696f 6e20 636f 6e73 742a 206c 6873 2c20 ion const* lhs, │ │ │ -0004a970: 7065 6572 5f63 6f6e 6e65 6374 696f 6e20 peer_connection │ │ │ -0004a980: 636f 6e73 742a 2072 6873 290a 0909 0909 const* rhs)..... │ │ │ -0004a990: 7b20 7265 7475 726e 2075 706c 6f61 645f { return upload_ │ │ │ -0004a9a0: 7261 7465 5f63 6f6d 7061 7265 286c 6873 rate_compare(lhs │ │ │ -0004a9b0: 2c20 7268 7329 3b20 7d29 3b0a 0a09 0909 , rhs); });..... │ │ │ -0004a9c0: 666f 7220 2861 7574 6f20 636f 6e73 742a for (auto const* │ │ │ -0004a9d0: 2070 203a 2070 6565 7273 290a 0909 097b p : peers)....{ │ │ │ -0004a9e0: 0a09 0909 0969 6e74 2063 6f6e 7374 2072 .....int const r │ │ │ -0004a9f0: 6174 6520 3d20 696e 7428 702d 2667 743b ate = int(p-> │ │ │ -0004aa00: 7570 6c6f 6164 6564 5f69 6e5f 6c61 7374 uploaded_in_last │ │ │ -0004aa10: 5f72 6f75 6e64 2829 0a09 0909 0909 2a20 _round()......* │ │ │ -0004aa20: 3130 3030 202f 2074 6f74 616c 5f6d 696c 1000 / total_mil │ │ │ -0004aa30: 6c69 7365 636f 6e64 7328 756e 6368 6f6b liseconds(unchok │ │ │ -0004aa40: 655f 696e 7465 7276 616c 2929 3b0a 0a09 e_interval));... │ │ │ -0004aa50: 0909 092f 2f20 616c 7761 7973 2068 6176 ...// always hav │ │ │ -0004aa60: 6520 6174 206c 6561 7374 2031 2075 6e63 e at least 1 unc │ │ │ -0004aa70: 686f 6b65 2073 6c6f 740a 0909 0909 6966 hoke slot.....if │ │ │ -0004aa80: 2028 7261 7465 2026 6c74 3b20 7261 7465 (rate < rate │ │ │ -0004aa90: 5f74 6872 6573 686f 6c64 2920 6272 6561 _threshold) brea │ │ │ -0004aaa0: 6b3b 0a0a 0909 0909 2b2b 7570 6c6f 6164 k;......++upload │ │ │ -0004aab0: 5f73 6c6f 7473 3b0a 0a3c 6469 7620 7374 _slots;..

    ....rate_ │ │ │ -0004aaf0: 7468 7265 7368 6f6c 6420 2b3d 2032 3034 threshold += 204 │ │ │ -0004ab00: 383b 0a3c 2f64 6976 3e09 0909 7d0a 0909 8;.
    ...}... │ │ │ -0004ab10: 092b 2b75 706c 6f61 645f 736c 6f74 733b .++upload_slots; │ │ │ -0004ab20: 0a09 097d 0a0a 0909 2f2f 2073 6f72 7473 ...}....// sorts │ │ │ -0004ab30: 2074 6865 2070 6565 7273 2074 6861 7420 the peers that │ │ │ -0004ab40: 6172 6520 656c 6967 6962 6c65 2066 6f72 are eligible for │ │ │ -0004ab50: 2075 6e63 686f 6b65 2062 7920 646f 776e unchoke by down │ │ │ -0004ab60: 6c6f 6164 2072 6174 6520 616e 640a 0909 load rate and... │ │ │ -0004ab70: 2f2f 2073 6563 6f6e 6461 7279 2062 7920 // secondary by │ │ │ -0004ab80: 746f 7461 6c20 7570 6c6f 6164 2e20 5468 total upload. Th │ │ │ -0004ab90: 6520 7265 6173 6f6e 2066 6f72 2074 6869 e reason for thi │ │ │ -0004aba0: 7320 6973 2c20 6966 2061 6c6c 2074 6f72 s is, if all tor │ │ │ -0004abb0: 7265 6e74 7320 6172 650a 0909 2f2f 2062 rents are...// b │ │ │ -0004abc0: 6569 6e67 2073 6565 6465 642c 2074 6865 eing seeded, the │ │ │ -0004abd0: 2064 6f77 6e6c 6f61 6420 7261 7465 2077 download rate w │ │ │ -0004abe0: 696c 6c20 6265 2030 2c20 616e 6420 7468 ill be 0, and th │ │ │ -0004abf0: 6520 7065 6572 7320 7765 2068 6176 6520 e peers we have │ │ │ -0004ac00: 7365 6e74 0a09 092f 2f20 7468 6520 6c65 sent...// the le │ │ │ -0004ac10: 6173 7420 746f 2073 686f 756c 6420 6265 ast to should be │ │ │ -0004ac20: 2075 6e63 686f 6b65 640a 0a09 092f 2f20 unchoked....// │ │ │ -0004ac30: 7765 2075 7365 2070 6172 7469 616c 2073 we use partial s │ │ │ -0004ac40: 6f72 7420 6865 7265 2c20 6265 6361 7573 ort here, becaus │ │ │ -0004ac50: 6520 7765 206f 6e6c 7920 6361 7265 2061 e we only care a │ │ │ -0004ac60: 626f 7574 2074 6865 2074 6f70 0a09 092f bout the top.../ │ │ │ -0004ac70: 2f20 7570 6c6f 6164 5f73 6c6f 7473 2070 / upload_slots p │ │ │ -0004ac80: 6565 7273 2e0a 0a09 0969 6e74 2063 6f6e eers.....int con │ │ │ -0004ac90: 7374 2073 6c6f 7473 203d 2073 7464 3a3a st slots = std:: │ │ │ -0004aca0: 6d69 6e28 7570 6c6f 6164 5f73 6c6f 7473 min(upload_slots │ │ │ -0004acb0: 2c20 696e 7428 7065 6572 732e 7369 7a65 , int(peers.size │ │ │ -0004acc0: 2829 2929 3b0a 0909 696e 7420 636f 6e73 ()));...int cons │ │ │ -0004acd0: 7420 7365 6564 5f63 686f 6b65 203d 2073 t seed_choke = s │ │ │ -0004ace0: 6574 742e 6765 745f 696e 7428 7365 7474 ett.get_int(sett │ │ │ -0004acf0: 696e 6773 5f70 6163 6b3a 3a73 6565 645f ings_pack::seed_ │ │ │ -0004ad00: 6368 6f6b 696e 675f 616c 676f 7269 7468 choking_algorith │ │ │ -0004ad10: 6d29 3b0a 0a09 0969 6620 2873 6565 645f m);....if (seed_ │ │ │ -0004ad20: 6368 6f6b 6520 3d3d 2073 6574 7469 6e67 choke == setting │ │ │ -0004ad30: 735f 7061 636b 3a3a 6661 7374 6573 745f s_pack::fastest_ │ │ │ -0004ad40: 7570 6c6f 6164 290a 0909 7b0a 0909 0973 upload)...{....s │ │ │ -0004ad50: 7464 3a3a 6e74 685f 656c 656d 656e 7428 td::nth_element( │ │ │ -0004ad60: 7065 6572 732e 6265 6769 6e28 292c 2070 peers.begin(), p │ │ │ -0004ad70: 6565 7273 2e62 6567 696e 2829 0a09 0909 eers.begin().... │ │ │ -0004ad80: 092b 2073 6c6f 7473 2c20 7065 6572 732e .+ slots, peers. │ │ │ -0004ad90: 656e 6428 290a 0909 0909 2c20 5b5d 2870 end()....., [](p │ │ │ -0004ada0: 6565 725f 636f 6e6e 6563 7469 6f6e 2063 eer_connection c │ │ │ -0004adb0: 6f6e 7374 2a20 6c68 732c 2070 6565 725f onst* lhs, peer_ │ │ │ -0004adc0: 636f 6e6e 6563 7469 6f6e 2063 6f6e 7374 connection const │ │ │ -0004add0: 2a20 7268 7329 0a09 0909 097b 2072 6574 * rhs).....{ ret │ │ │ -0004ade0: 7572 6e20 756e 6368 6f6b 655f 636f 6d70 urn unchoke_comp │ │ │ -0004adf0: 6172 655f 6661 7374 6573 745f 7570 6c6f are_fastest_uplo │ │ │ -0004ae00: 6164 286c 6873 2c20 7268 7329 3b20 7d29 ad(lhs, rhs); }) │ │ │ -0004ae10: 3b0a 0909 7d0a 0909 656c 7365 2069 6620 ;...}...else if │ │ │ -0004ae20: 2873 6565 645f 6368 6f6b 6520 3d3d 2073 (seed_choke == s │ │ │ -0004ae30: 6574 7469 6e67 735f 7061 636b 3a3a 616e ettings_pack::an │ │ │ -0004ae40: 7469 5f6c 6565 6368 290a 0909 7b0a 0909 ti_leech)...{... │ │ │ -0004ae50: 0973 7464 3a3a 6e74 685f 656c 656d 656e .std::nth_elemen │ │ │ -0004ae60: 7428 7065 6572 732e 6265 6769 6e28 292c t(peers.begin(), │ │ │ -0004ae70: 2070 6565 7273 2e62 6567 696e 2829 0a09 peers.begin().. │ │ │ -0004ae80: 0909 092b 2073 6c6f 7473 2c20 7065 6572 ...+ slots, peer │ │ │ -0004ae90: 732e 656e 6428 290a 0909 0909 2c20 5b5d s.end()....., [] │ │ │ -0004aea0: 2870 6565 725f 636f 6e6e 6563 7469 6f6e (peer_connection │ │ │ -0004aeb0: 2063 6f6e 7374 2a20 6c68 732c 2070 6565 const* lhs, pee │ │ │ -0004aec0: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e r_connection con │ │ │ -0004aed0: 7374 2a20 7268 7329 0a09 0909 097b 2072 st* rhs).....{ r │ │ │ -0004aee0: 6574 7572 6e20 756e 6368 6f6b 655f 636f eturn unchoke_co │ │ │ -0004aef0: 6d70 6172 655f 616e 7469 5f6c 6565 6368 mpare_anti_leech │ │ │ -0004af00: 286c 6873 2c20 7268 7329 3b20 7d29 3b0a (lhs, rhs); });. │ │ │ -0004af10: 0909 7d0a 0909 656c 7365 0a3c 2f70 7265 ..}...else.
    rele │ │ │ -0004af50: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/add │ │ │ -0004af90: 5f74 6f72 7265 6e74 5f70 6172 616d 732e _torrent_params. │ │ │ -0004afa0: 6370 703a 3331 3c2f 613e 3c2f 7464 3e3c cpp:31< │ │ │ -0004afb0: 7464 3e69 7420 776f 756c 6420 6265 206e td>it would be n │ │ │ -0004afc0: 6963 6520 6966 2074 6869 7320 7761 7320 ice if this was │ │ │ -0004afd0: 6e6f 7468 726f 7720 6465 6661 756c 7420 nothrow default │ │ │ -0004afe0: 636f 6e73 7472 7563 7469 626c 6520 7374 constructible st │ │ │ -0004aff0: 6174 6963 5f61 7373 6572 7428 7374 643a atic_assert(std: │ │ │ -0004b000: 3a69 735f 6e6f 7468 726f 775f 6465 6661 :is_nothrow_defa │ │ │ -0004b010: 756c 745f 636f 6e73 7472 7563 7469 626c ult_constructibl │ │ │ -0004b020: 653c 6164 645f 746f 7272 656e 745f 7061 e::value , " │ │ │ -0004b040: 7368 6f75 6c64 2062 6520 6e6f 7468 726f should be nothro │ │ │ -0004b050: 7720 6465 6661 756c 7420 636f 6e73 7472 w default constr │ │ │ -0004b060: 7563 7469 626c 6522 293b 3c2f 7464 3e3c uctible");< │ │ │ -0004b070: 2f74 723e 3c74 7220 6964 3d22 3138 3122 /tr>

    it would │ │ │ -0004b0c0: 2062 6520 6e69 6365 2069 6620 7468 6973 be nice if this │ │ │ -0004b0d0: 2077 6173 206e 6f74 6872 6f77 2064 6566 was nothrow def │ │ │ -0004b0e0: 6175 6c74 2063 6f6e 7374 7275 6374 6962 ault constructib │ │ │ -0004b0f0: 6c65 0a73 7461 7469 635f 6173 7365 7274 le.static_assert │ │ │ -0004b100: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77 (std::is_nothrow │ │ │ -0004b110: 5f64 6566 6175 6c74 5f63 6f6e 7374 7275 _default_constru │ │ │ -0004b120: 6374 6962 6c65 3c61 6464 5f74 6f72 7265 ctible::valu │ │ │ -0004b140: 650a 2c20 2273 686f 756c 6420 6265 206e e., "should be n │ │ │ -0004b150: 6f74 6872 6f77 2064 6566 6175 6c74 2063 othrow default c │ │ │ -0004b160: 6f6e 7374 7275 6374 6962 6c65 2229 3b3c onstructible");< │ │ │ -0004b170: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f61 /h2>

    ../src/a │ │ │ -0004b180: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -0004b190: 732e 6370 703a 3331 3c2f 6834 3e3c 7072 s.cpp:31

    #include │ │ │ -0004b1e0: 226c 6962 746f 7272 656e 742f 6164 645f "libtorrent/add_ │ │ │ -0004b1f0: 746f 7272 656e 745f 7061 7261 6d73 2e68 torrent_params.h │ │ │ -0004b200: 7070 220a 0a6e 616d 6573 7061 6365 206c pp"..namespace l │ │ │ -0004b210: 6962 746f 7272 656e 7420 7b0a 0a09 6164 ibtorrent {...ad │ │ │ -0004b220: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ -0004b230: 3a3a 6164 645f 746f 7272 656e 745f 7061 ::add_torrent_pa │ │ │ -0004b240: 7261 6d73 2829 203d 2064 6566 6175 6c74 rams() = default │ │ │ -0004b250: 3b0a 0961 6464 5f74 6f72 7265 6e74 5f70 ;..add_torrent_p │ │ │ -0004b260: 6172 616d 733a 3a7e 6164 645f 746f 7272 arams::~add_torr │ │ │ -0004b270: 656e 745f 7061 7261 6d73 2829 203d 2064 ent_params() = d │ │ │ -0004b280: 6566 6175 6c74 3b0a 0961 6464 5f74 6f72 efault;..add_tor │ │ │ -0004b290: 7265 6e74 5f70 6172 616d 733a 3a61 6464 rent_params::add │ │ │ -0004b2a0: 5f74 6f72 7265 6e74 5f70 6172 616d 7328 _torrent_params( │ │ │ -0004b2b0: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ -0004b2c0: 6d73 2661 6d70 3b26 616d 703b 2920 6e6f ms&&) no │ │ │ -0004b2d0: 6578 6365 7074 203d 2064 6566 6175 6c74 except = default │ │ │ -0004b2e0: 3b0a 0961 6464 5f74 6f72 7265 6e74 5f70 ;..add_torrent_p │ │ │ -0004b2f0: 6172 616d 7326 616d 703b 2061 6464 5f74 arams& add_t │ │ │ -0004b300: 6f72 7265 6e74 5f70 6172 616d 733a 3a6f orrent_params::o │ │ │ -0004b310: 7065 7261 746f 723d 2861 6464 5f74 6f72 perator=(add_tor │ │ │ -0004b320: 7265 6e74 5f70 6172 616d 7326 616d 703b rent_params& │ │ │ -0004b330: 2661 6d70 3b29 2026 616d 703b 206e 6f65 &) & noe │ │ │ -0004b340: 7863 6570 7420 3d20 6465 6661 756c 743b xcept = default; │ │ │ -0004b350: 0a09 6164 645f 746f 7272 656e 745f 7061 ..add_torrent_pa │ │ │ -0004b360: 7261 6d73 3a3a 6164 645f 746f 7272 656e rams::add_torren │ │ │ -0004b370: 745f 7061 7261 6d73 2861 6464 5f74 6f72 t_params(add_tor │ │ │ -0004b380: 7265 6e74 5f70 6172 616d 7320 636f 6e73 rent_params cons │ │ │ -0004b390: 7426 616d 703b 2920 3d20 6465 6661 756c t&) = defaul │ │ │ -0004b3a0: 743b 0a09 6164 645f 746f 7272 656e 745f t;..add_torrent_ │ │ │ -0004b3b0: 7061 7261 6d73 2661 6d70 3b20 6164 645f params& add_ │ │ │ -0004b3c0: 746f 7272 656e 745f 7061 7261 6d73 3a3a torrent_params:: │ │ │ -0004b3d0: 6f70 6572 6174 6f72 3d28 6164 645f 746f operator=(add_to │ │ │ -0004b3e0: 7272 656e 745f 7061 7261 6d73 2063 6f6e rrent_params con │ │ │ -0004b3f0: 7374 2661 6d70 3b29 2026 616d 703b 203d st&) & = │ │ │ -0004b400: 2064 6566 6175 6c74 3b0a 0a09 7374 6174 default;...stat │ │ │ -0004b410: 6963 5f61 7373 6572 7428 7374 643a 3a69 ic_assert(std::i │ │ │ -0004b420: 735f 6e6f 7468 726f 775f 6d6f 7665 5f63 s_nothrow_move_c │ │ │ -0004b430: 6f6e 7374 7275 6374 6962 6c65 266c 743b onstructible< │ │ │ -0004b440: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ -0004b450: 6d73 2667 743b 3a3a 7661 6c75 650a 0909 ms>::value... │ │ │ -0004b460: 2c20 2273 686f 756c 6420 6265 206e 6f74 , "should be not │ │ │ -0004b470: 6872 6f77 206d 6f76 6520 636f 6e73 7472 hrow move constr │ │ │ -0004b480: 7563 7469 626c 6522 293b 0a0a 0973 7461 uctible");...sta │ │ │ -0004b490: 7469 635f 6173 7365 7274 2873 7464 3a3a tic_assert(std:: │ │ │ -0004b4a0: 6973 5f6e 6f74 6872 6f77 5f6d 6f76 655f is_nothrow_move_ │ │ │ -0004b4b0: 636f 6e73 7472 7563 7469 626c 6526 6c74 constructible< │ │ │ -0004b4c0: 3b73 7464 3a3a 7374 7269 6e67 2667 743b ;std::string> │ │ │ -0004b4d0: 3a3a 7661 6c75 650a 0909 2c20 2273 686f ::value..., "sho │ │ │ -0004b4e0: 756c 6420 6265 206e 6f74 6872 6f77 206d uld be nothrow m │ │ │ -0004b4f0: 6f76 6520 636f 6e73 7472 7563 7469 626c ove constructibl │ │ │ -0004b500: 6522 293b 0a0a 0973 7461 7469 635f 6173 e");...static_as │ │ │ -0004b510: 7365 7274 2873 7464 3a3a 6973 5f6e 6f74 sert(std::is_not │ │ │ -0004b520: 6872 6f77 5f6d 6f76 655f 6173 7369 676e hrow_move_assign │ │ │ -0004b530: 6162 6c65 266c 743b 6164 645f 746f 7272 able<add_torr │ │ │ -0004b540: 656e 745f 7061 7261 6d73 2667 743b 3a3a ent_params>:: │ │ │ -0004b550: 7661 6c75 650a 0909 2c20 2273 686f 756c value..., "shoul │ │ │ -0004b560: 6420 6265 206e 6f74 6872 6f77 206d 6f76 d be nothrow mov │ │ │ -0004b570: 6520 6173 7369 676e 6162 6c65 2229 3b0a e assignable");. │ │ │ -0004b580: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ -0004b5b0: 3c2f 6469 763e 6e61 6d65 7370 6163 6520
    namespace │ │ │ -0004b5c0: 6175 7820 7b0a 0a09 2f2f 2072 6574 7572 aux {...// retur │ │ │ -0004b5d0: 6e73 2077 6865 7468 6572 2074 6869 7320 ns whether this │ │ │ -0004b5e0: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ -0004b5f0: 6d73 206f 626a 6563 7420 6861 7320 2272 ms object has "r │ │ │ -0004b600: 6573 756d 652d 6461 7461 222c 2069 2e65 esume-data", i.e │ │ │ -0004b610: 2e0a 092f 2f20 696e 666f 726d 6174 696f ...// informatio │ │ │ -0004b620: 6e20 6162 6f75 7420 7768 6963 6820 7069 n about which pi │ │ │ -0004b630: 6563 6573 2077 6520 6861 7665 2e0a 0962 eces we have...b │ │ │ -0004b640: 6f6f 6c20 636f 6e74 6169 6e73 5f72 6573 ool contains_res │ │ │ -0004b650: 756d 655f 6461 7461 2861 6464 5f74 6f72 ume_data(add_tor │ │ │ -0004b660: 7265 6e74 5f70 6172 616d 7320 636f 6e73 rent_params cons │ │ │ -0004b670: 7426 616d 703b 2061 7470 290a 097b 0a09 t& atp)..{.. │ │ │ -0004b680: 0972 6574 7572 6e20 2161 7470 2e68 6176 .return !atp.hav │ │ │ -0004b690: 655f 7069 6563 6573 2e65 6d70 7479 2829 e_pieces.empty() │ │ │ -0004b6a0: 0a09 0909 7c7c 2028 6174 702e 666c 6167 ....|| (atp.flag │ │ │ -0004b6b0: 7320 2661 6d70 3b20 746f 7272 656e 745f s & torrent_ │ │ │ -0004b6c0: 666c 6167 733a 3a73 6565 645f 6d6f 6465 flags::seed_mode │ │ │ -0004b6d0: 293b 0a09 7d0a 7d0a 0a7d 0a3c 2f70 7265 );..}.}..}.

    rele │ │ │ -0004b710: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/i2p │ │ │ -0004b750: 5f70 6578 2e63 7070 3a34 3030 3c2f 613e _pex.cpp:400 │ │ │ -0004b760: 3c2f 7464 3e3c 7464 3e66 6163 746f 7220 factor │ │ │ -0004b770: 7468 6973 206f 7574 2069 6e74 6f20 2273 this out into "s │ │ │ -0004b780: 6c69 6469 6e67 2077 696e 646f 7722 3f20 liding window"? │ │ │ -0004b790: 4974 2773 2073 6861 7265 6420 7769 7468 It's shared with │ │ │ -0004b7a0: 2075 745f 7065 783c 2f74 643e 3c2f 7472 ut_pex

    factor this │ │ │ -0004b800: 206f 7574 2069 6e74 6f20 2273 6c69 6469 out into "slidi │ │ │ -0004b810: 6e67 2077 696e 646f 7722 3f20 4974 2773 ng window"? It's │ │ │ -0004b820: 2073 6861 7265 6420 7769 7468 2075 745f shared with ut_ │ │ │ -0004b830: 7065 783c 2f68 323e 3c68 343e 2e2e 2f73 pex

    ../s │ │ │ -0004b840: 7263 2f69 3270 5f70 6578 2e63 7070 3a34 rc/i2p_pex.cpp:4 │ │ │ -0004b850: 3030 3c2f 6834 3e3c 7072 6520 7374 796c 00

    ...m_pc.stats_c
    │ │ │ -0004b8a0: 6f75 6e74 6572 7328 292e 696e 635f 7374  ounters().inc_st
    │ │ │ -0004b8b0: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ -0004b8c0: 7465 7273 3a3a 6e75 6d5f 6f75 7467 6f69  ters::num_outgoi
    │ │ │ -0004b8d0: 6e67 5f65 7874 656e 6465 6429 3b0a 0909  ng_extended);...
    │ │ │ -0004b8e0: 096d 5f70 632e 7374 6174 735f 636f 756e  .m_pc.stats_coun
    │ │ │ -0004b8f0: 7465 7273 2829 2e69 6e63 5f73 7461 7473  ters().inc_stats
    │ │ │ -0004b900: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572  _counter(counter
    │ │ │ -0004b910: 733a 3a6e 756d 5f6f 7574 676f 696e 675f  s::num_outgoing_
    │ │ │ -0004b920: 7065 7829 3b0a 0a23 6966 6e64 6566 2054  pex);..#ifndef T
    │ │ │ -0004b930: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c  ORRENT_DISABLE_L
    │ │ │ -0004b940: 4f47 4749 4e47 0a09 0909 6d5f 7063 2e70  OGGING....m_pc.p
    │ │ │ -0004b950: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67  eer_log(peer_log
    │ │ │ -0004b960: 5f61 6c65 7274 3a3a 6f75 7467 6f69 6e67  _alert::outgoing
    │ │ │ -0004b970: 5f6d 6573 7361 6765 2c20 7065 6572 5f6c  _message, peer_l
    │ │ │ -0004b980: 6f67 5f61 6c65 7274 3a3a 6932 705f 7065  og_alert::i2p_pe
    │ │ │ -0004b990: 785f 6675 6c6c 0a09 0909 092c 2022 6164  x_full....., "ad
    │ │ │ -0004b9a0: 6465 643a 2025 6420 6d73 675f 7369 7a65  ded: %d msg_size
    │ │ │ -0004b9b0: 3a20 2564 222c 206e 756d 5f61 6464 6564  : %d", num_added
    │ │ │ -0004b9c0: 2c20 696e 7428 7065 785f 6d73 672e 7369  , int(pex_msg.si
    │ │ │ -0004b9d0: 7a65 2829 2929 3b0a 2365 6e64 6966 0a09  ze()));.#endif..
    │ │ │ -0004b9e0: 097d 0a0a 0909 6175 783a 3a74 6f72 7265  .}....aux::torre
    │ │ │ -0004b9f0: 6e74 2661 6d70 3b20 6d5f 746f 7272 656e  nt& m_torren
    │ │ │ -0004ba00: 743b 0a09 0961 7578 3a3a 7065 6572 5f63  t;...aux::peer_c
    │ │ │ -0004ba10: 6f6e 6e65 6374 696f 6e26 616d 703b 206d  onnection& m
    │ │ │ -0004ba20: 5f70 633b 0a09 0969 3270 5f70 6578 5f70  _pc;...i2p_pex_p
    │ │ │ -0004ba30: 6c75 6769 6e26 616d 703b 206d 5f74 703b  lugin& m_tp;
    │ │ │ -0004ba40: 0a0a 0909 2f2f 2074 6865 206c 6173 7420  ....// the last 
    │ │ │ -0004ba50: 7065 7820 6d65 7373 6167 6573 2077 6520  pex messages we 
    │ │ │ -0004ba60: 7265 6365 6976 6564 0a09 092f 2f20 5b30  received...// [0
    │ │ │ -0004ba70: 5d20 6973 2074 6865 206f 6c64 6573 7420  ] is the oldest 
    │ │ │ -0004ba80: 6f6e 652e 2054 6865 7265 2069 7320 6120  one. There is a 
    │ │ │ -0004ba90: 7072 6f62 6c65 6d20 7769 7468 0a09 092f  problem with.../
    │ │ │ -0004baa0: 2f20 7261 7465 206c 696d 6974 6564 2063  / rate limited c
    │ │ │ -0004bab0: 6f6e 6e65 6374 696f 6e73 2c20 6265 6361  onnections, beca
    │ │ │ -0004bac0: 7573 6520 7765 206d 6179 2073 6974 0a09  use we may sit..
    │ │ │ -0004bad0: 092f 2f20 666f 7220 6120 6c6f 6e67 2074  .// for a long t
    │ │ │ -0004bae0: 696d 652c 2061 6363 756d 756c 6174 696e  ime, accumulatin
    │ │ │ -0004baf0: 6720 7065 7820 6d65 7373 6167 6573 2c20  g pex messages, 
    │ │ │ -0004bb00: 616e 640a 0909 2f2f 2074 6865 6e20 6f6e  and...// then on
    │ │ │ -0004bb10: 6365 2077 6520 7265 6164 2066 726f 6d20  ce we read from 
    │ │ │ -0004bb20: 7468 6520 736f 636b 6574 2069 7420 7769  the socket it wi
    │ │ │ -0004bb30: 6c6c 206c 6f6f 6b20 6c69 6b65 0a09 092f  ll look like.../
    │ │ │ -0004bb40: 2f20 7765 2072 6563 6569 7665 6420 7468  / we received th
    │ │ │ -0004bb50: 656d 2061 6c6c 2062 6163 6b20 746f 2062  em all back to b
    │ │ │ -0004bb60: 6163 6b2e 2054 6861 7427 7320 7768 790a  ack. That's why.
    │ │ │ -0004bb70: 0909 2f2f 2077 6520 6c6f 6f6b 2061 7420  ..// we look at 
    │ │ │ -0004bb80: 3620 7065 7820 6d65 7373 6167 6573 2062  6 pex messages b
    │ │ │ -0004bb90: 6163 6b2e 0a3c 6469 7620 7374 796c 653d  ack..
    ..aux::array& │ │ │ -0004bbd0: 6c74 3b74 696d 655f 706f 696e 742c 2036 lt;time_point, 6 │ │ │ -0004bbe0: 2667 743b 206d 5f6c 6173 745f 7065 783b > m_last_pex; │ │ │ -0004bbf0: 0a3c 2f64 6976 3e0a 0909 7469 6d65 5f70 .
    ...time_p │ │ │ -0004bc00: 6f69 6e74 206d 5f6c 6173 745f 6d73 673b oint m_last_msg; │ │ │ -0004bc10: 0a09 0969 6e74 206d 5f6d 6573 7361 6765 ...int m_message │ │ │ -0004bc20: 5f69 6e64 6578 203d 2030 3b0a 0a09 092f _index = 0;..../ │ │ │ -0004bc30: 2f20 7468 6973 2069 7320 696e 6974 6961 / this is initia │ │ │ -0004bc40: 6c69 7a65 6420 746f 2074 7275 652c 2061 lized to true, a │ │ │ -0004bc50: 6e64 2073 6574 2074 6f0a 0909 2f2f 2066 nd set to...// f │ │ │ -0004bc60: 616c 7365 2061 6674 6572 2074 6865 2066 alse after the f │ │ │ -0004bc70: 6972 7374 2070 6578 206d 6573 7361 6765 irst pex message │ │ │ -0004bc80: 2068 6173 2062 6565 6e20 7365 6e74 2e0a has been sent.. │ │ │ -0004bc90: 0909 2f2f 2069 7420 6973 2075 7365 6420 ..// it is used │ │ │ -0004bca0: 746f 206b 6e6f 7720 6966 2061 2064 6966 to know if a dif │ │ │ -0004bcb0: 6620 6d65 7373 6167 6520 6f72 2061 2066 f message or a f │ │ │ -0004bcc0: 756c 6c0a 0909 2f2f 206d 6573 7361 6765 ull...// message │ │ │ -0004bcd0: 2073 686f 756c 6420 6265 2073 656e 742e should be sent. │ │ │ -0004bce0: 0a09 0962 6f6f 6c20 6d5f 6669 7273 745f ...bool m_first_ │ │ │ -0004bcf0: 7469 6d65 203d 2074 7275 653b 0a09 7d3b time = true;..}; │ │ │ -0004bd00: 0a0a 0973 7464 3a3a 7368 6172 6564 5f70 ...std::shared_p │ │ │ -0004bd10: 7472 266c 743b 7065 6572 5f70 6c75 6769 tr<peer_plugi │ │ │ -0004bd20: 6e26 6774 3b20 6932 705f 7065 785f 706c n> i2p_pex_pl │ │ │ -0004bd30: 7567 696e 3a3a 6e65 775f 636f 6e6e 6563 ugin::new_connec │ │ │ -0004bd40: 7469 6f6e 2870 6565 725f 636f 6e6e 6563 tion(peer_connec │ │ │ -0004bd50: 7469 6f6e 5f68 616e 646c 6520 636f 6e73 tion_handle cons │ │ │ -0004bd60: 7426 616d 703b 2070 6329 0a09 7b0a 0909 t& pc)..{... │ │ │ -0004bd70: 6966 2028 7063 2e74 7970 6528 2920 213d if (pc.type() != │ │ │ -0004bd80: 2063 6f6e 6e65 6374 696f 6e5f 7479 7065 connection_type │ │ │ -0004bd90: 3a3a 6269 7474 6f72 7265 6e74 2920 7265 ::bittorrent) re │ │ │ -0004bda0: 7475 726e 207b 7d3b 0a09 0961 7578 3a3a turn {};...aux:: │ │ │ -0004bdb0: 6274 5f70 6565 725f 636f 6e6e 6563 7469 bt_peer_connecti │ │ │ -0004bdc0: 6f6e 2a20 6320 3d20 7374 6174 6963 5f63 on* c = static_c │ │ │ -0004bdd0: 6173 7426 6c74 3b61 7578 3a3a 6274 5f70 ast<aux::bt_p │ │ │ -0004bde0: 6565 725f 636f 6e6e 6563 7469 6f6e 2a26 eer_connection*& │ │ │ -0004bdf0: 6774 3b28 7063 2e6e 6174 6976 655f 6861 gt;(pc.native_ha │ │ │ -0004be00: 6e64 6c65 2829 2e67 6574 2829 293b 0a0a ndle().get());.. │ │ │ -0004be10: 0909 2f2f 2074 6869 7320 6578 7465 6e73 ..// this extens │ │ │ -0004be20: 696f 6e20 6973 206f 6e6c 7920 666f 7220 ion is only for │ │ │ -0004be30: 6932 7020 7065 6572 2063 6f6e 6e65 6374 i2p peer connect │ │ │ -0004be40: 696f 6e73 0a09 0969 6620 2821 6973 5f69 ions...if (!is_i │ │ │ -0004be50: 3270 2863 2d26 6774 3b67 6574 5f73 6f63 2p(c->get_soc │ │ │ -0004be60: 6b65 7428 2929 2920 7265 7475 726e 207b ket())) return { │ │ │ -0004be70: 7d3b 0a0a 0909 7265 7475 726e 2073 7464 };....return std │ │ │ -0004be80: 3a3a 6d61 6b65 5f73 6861 7265 6426 6c74 ::make_shared< │ │ │ -0004be90: 3b69 3270 5f70 6578 5f70 6565 725f 706c ;i2p_pex_peer_pl │ │ │ -0004bea0: 7567 696e 2667 743b 286d 5f74 6f72 7265 ugin>(m_torre │ │ │ -0004beb0: 6e74 2c20 2a63 2c20 2a74 6869 7329 3b0a nt, *c, *this);. │ │ │ -0004bec0: 097d 0a7d 207d 0a0a 6e61 6d65 7370 6163 .}.} }..namespac │ │ │ -0004bed0: 6520 6c69 6274 6f72 7265 6e74 207b 0a0a e libtorrent {.. │ │ │ -0004bee0: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ -0004bef0: 266c 743b 746f 7272 656e 745f 706c 7567 <torrent_plug │ │ │ -0004bf00: 696e 2667 743b 2063 7265 6174 655f 6932 in> create_i2 │ │ │ -0004bf10: 705f 7065 785f 706c 7567 696e 2874 6f72 p_pex_plugin(tor │ │ │ -0004bf20: 7265 6e74 5f68 616e 646c 6520 636f 6e73 rent_handle cons │ │ │ -0004bf30: 7426 616d 703b 2074 682c 2063 6c69 656e t& th, clien │ │ │ -0004bf40: 745f 6461 7461 5f74 290a 097b 0a09 0961 t_data_t)..{...a │ │ │ -0004bf50: 7578 3a3a 746f 7272 656e 742a 2074 203d ux::torrent* t = │ │ │ -0004bf60: 2074 682e 6e61 7469 7665 5f68 616e 646c th.native_handl │ │ │ -0004bf70: 6528 292e 6765 7428 293b 0a09 092f 2f20 e().get();...// │ │ │ -0004bf80: 6f6e 6c79 2061 6464 2065 7874 656e 7369 only add extensi │ │ │ -0004bf90: 6f6e 2074 6f20 6932 7020 746f 7272 656e on to i2p torren │ │ │ -0004bfa0: 7473 0a09 0969 6620 2874 2d26 6774 3b74 ts...if (t->t │ │ │ -0004bfb0: 6f72 7265 6e74 5f66 696c 6528 292e 7072 orrent_file().pr │ │ │ -0004bfc0: 6976 2829 207c 7c20 2174 2d26 6774 3b69 iv() || !t->i │ │ │ -0004bfd0: 735f 6932 7028 2929 0a3c 2f70 7265 3e3c s_i2p()).
    < │ │ │ -0004bfe0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0004c010: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0004c020: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/ip_no │ │ │ -0004c050: 7469 6669 6572 2e63 7070 3a31 383c 2f61 tifier.cpp:18simula │ │ │ -0004c070: 746f 7220 7375 7070 6f72 743c 2f74 643e tor support │ │ │ -0004c080: 3c2f 7472 3e3c 7472 2069 643d 2231 3833

    simulat │ │ │ -0004c0d0: 6f72 2073 7570 706f 7274 3c2f 6832 3e3c or support

    < │ │ │ -0004c0e0: 6834 3e2e 2e2f 7372 632f 6970 5f6e 6f74 h4>../src/ip_not │ │ │ -0004c0f0: 6966 6965 722e 6370 703a 3138 3c2f 6834 ifier.cpp:18
    .#end
    │ │ │ -0004c140: 6966 0a23 656e 6469 660a 2f2a 0a0a 436f  if.#endif./*..Co
    │ │ │ -0004c150: 7079 7269 6768 7420 2863 2920 3230 3136  pyright (c) 2016
    │ │ │ -0004c160: 2d32 3031 372c 2032 3032 312c 2041 6c64  -2017, 2021, Ald
    │ │ │ -0004c170: 656e 2054 6f72 7265 730a 436f 7079 7269  en Torres.Copyri
    │ │ │ -0004c180: 6768 7420 2863 2920 3230 3136 2c20 3230  ght (c) 2016, 20
    │ │ │ -0004c190: 3230 2c20 5374 6576 656e 2053 696c 6f74  20, Steven Silot
    │ │ │ -0004c1a0: 690a 436f 7079 7269 6768 7420 2863 2920  i.Copyright (c) 
    │ │ │ -0004c1b0: 3230 3137 2d32 3032 322c 2041 7276 6964  2017-2022, Arvid
    │ │ │ -0004c1c0: 204e 6f72 6265 7267 0a43 6f70 7972 6967   Norberg.Copyrig
    │ │ │ -0004c1d0: 6874 2028 6329 2032 3031 372c 2054 696d  ht (c) 2017, Tim
    │ │ │ -0004c1e0: 204e 6965 6465 7268 6175 7365 6e0a 436f   Niederhausen.Co
    │ │ │ -0004c1f0: 7079 7269 6768 7420 2863 2920 3230 3230  pyright (c) 2020
    │ │ │ -0004c200: 2c20 5469 6765 7220 5761 6e67 0a41 6c6c  , Tiger Wang.All
    │ │ │ -0004c210: 2072 6967 6874 7320 7265 7365 7276 6564   rights reserved
    │ │ │ -0004c220: 2e0a 0a59 6f75 206d 6179 2075 7365 2c20  ...You may use, 
    │ │ │ -0004c230: 6469 7374 7269 6275 7465 2061 6e64 206d  distribute and m
    │ │ │ -0004c240: 6f64 6966 7920 7468 6973 2063 6f64 6520  odify this code 
    │ │ │ -0004c250: 756e 6465 7220 7468 6520 7465 726d 7320  under the terms 
    │ │ │ -0004c260: 6f66 2074 6865 2042 5344 206c 6963 656e  of the BSD licen
    │ │ │ -0004c270: 7365 2c0a 7365 6520 4c49 4345 4e53 4520  se,.see LICENSE 
    │ │ │ -0004c280: 6669 6c65 2e0a 2a2f 0a0a 2369 6e63 6c75  file..*/..#inclu
    │ │ │ -0004c290: 6465 2022 6c69 6274 6f72 7265 6e74 2f61  de "libtorrent/a
    │ │ │ -0004c2a0: 7578 5f2f 6970 5f6e 6f74 6966 6965 722e  ux_/ip_notifier.
    │ │ │ -0004c2b0: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ -0004c2c0: 6962 746f 7272 656e 742f 6173 7365 7274  ibtorrent/assert
    │ │ │ -0004c2d0: 2e68 7070 220a 0a23 6966 2064 6566 696e  .hpp"..#if defin
    │ │ │ -0004c2e0: 6564 2054 4f52 5245 4e54 5f42 5549 4c44  ed TORRENT_BUILD
    │ │ │ -0004c2f0: 5f53 494d 554c 4154 4f52 0a3c 6469 7620  _SIMULATOR.
    #elif T │ │ │ -0004c330: 4f52 5245 4e54 5f55 5345 5f4e 4554 4c49 ORRENT_USE_NETLI │ │ │ -0004c340: 4e4b 0a3c 2f64 6976 3e23 696e 636c 7564 NK.
    #includ │ │ │ -0004c350: 6520 226c 6962 746f 7272 656e 742f 6175 e "libtorrent/au │ │ │ -0004c360: 785f 2f6e 6574 6c69 6e6b 2e68 7070 220a x_/netlink.hpp". │ │ │ -0004c370: 2369 6e63 6c75 6465 2022 6c69 6274 6f72 #include "libtor │ │ │ -0004c380: 7265 6e74 2f73 6f63 6b65 742e 6870 7022 rent/socket.hpp" │ │ │ -0004c390: 0a23 696e 636c 7564 6520 266c 743b 6172 .#include <ar │ │ │ -0004c3a0: 7261 7926 6774 3b0a 2369 6e63 6c75 6465 ray>.#include │ │ │ -0004c3b0: 2026 6c74 3b75 6e6f 7264 6572 6564 5f6d <unordered_m │ │ │ -0004c3c0: 6170 2667 743b 0a23 656c 6966 2054 4f52 ap>.#elif TOR │ │ │ -0004c3d0: 5245 4e54 5f55 5345 5f53 5953 5445 4d43 RENT_USE_SYSTEMC │ │ │ -0004c3e0: 4f4e 4649 4755 5241 5449 4f4e 207c 7c20 ONFIGURATION || │ │ │ -0004c3f0: 544f 5252 454e 545f 5553 455f 5343 5f4e TORRENT_USE_SC_N │ │ │ -0004c400: 4554 574f 524b 5f52 4541 4348 4142 494c ETWORK_REACHABIL │ │ │ -0004c410: 4954 590a 2369 6e63 6c75 6465 2026 6c74 ITY.#include < │ │ │ -0004c420: 3b53 7973 7465 6d43 6f6e 6669 6775 7261 ;SystemConfigura │ │ │ -0004c430: 7469 6f6e 2f53 7973 7465 6d43 6f6e 6669 tion/SystemConfi │ │ │ -0004c440: 6775 7261 7469 6f6e 2e68 2667 743b 0a23 guration.h>.# │ │ │ -0004c450: 656c 6966 2064 6566 696e 6564 2054 4f52 elif defined TOR │ │ │ -0004c460: 5245 4e54 5f57 494e 444f 5753 0a23 696e RENT_WINDOWS.#in │ │ │ -0004c470: 636c 7564 6520 226c 6962 746f 7272 656e clude "libtorren │ │ │ -0004c480: 742f 6175 785f 2f74 6872 6f77 2e68 7070 t/aux_/throw.hpp │ │ │ -0004c490: 220a 2369 6e63 6c75 6465 2022 6c69 6274 ".#include "libt │ │ │ -0004c4a0: 6f72 7265 6e74 2f61 7578 5f2f 6469 7361 orrent/aux_/disa │ │ │ -0004c4b0: 626c 655f 7761 726e 696e 6773 5f70 7573 ble_warnings_pus │ │ │ -0004c4c0: 682e 6870 7022 0a23 696e 636c 7564 6520 h.hpp".#include │ │ │ -0004c4d0: 266c 743b 6970 686c 7061 7069 2e68 2667 <iphlpapi.h&g │ │ │ -0004c4e0: 743b 0a23 6966 6465 6620 544f 5252 454e t;.#ifdef TORREN │ │ │ -0004c4f0: 545f 5749 4e52 540a 2369 6e63 6c75 6465 T_WINRT.#include │ │ │ -0004c500: 2026 6c74 3b6e 6574 696f 6170 692e 6826 <netioapi.h& │ │ │ -0004c510: 6774 3b0a 2365 6e64 6966 0a23 696e 636c gt;.#endif.#incl │ │ │ -0004c520: 7564 6520 266c 743b 6d75 7465 7826 6774 ude <mutex> │ │ │ -0004c530: 3b0a 2369 6e63 6c75 6465 2022 6c69 6274 ;.#include "libt │ │ │ -0004c540: 6f72 7265 6e74 2f61 7578 5f2f 6469 7361 orrent/aux_/disa │ │ │ -0004c550: 626c 655f 7761 726e 696e 6773 5f70 6f70 ble_warnings_pop │ │ │ -0004c560: 2e68 7070 220a 2365 6e64 6966 0a0a 2369 .hpp".#endif..#i │ │ │ -0004c570: 6e63 6c75 6465 2022 6c69 6274 6f72 7265 nclude "libtorre │ │ │ -0004c580: 6e74 2f61 7578 5f2f 6e65 746c 696e 6b5f nt/aux_/netlink_ │ │ │ -0004c590: 7574 696c 732e 6870 7022 0a0a 6e61 6d65 utils.hpp"..name │ │ │ -0004c5a0: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ -0004c5b0: 3a3a 6175 7820 7b0a 0a6e 616d 6573 7061 ::aux {..namespa │ │ │ -0004c5c0: 6365 207b 0a0a 2369 6620 2854 4f52 5245 ce {..#if (TORRE │ │ │ -0004c5d0: 4e54 5f55 5345 5f53 5953 5445 4d43 4f4e NT_USE_SYSTEMCON │ │ │ -0004c5e0: 4649 4755 5241 5449 4f4e 207c 7c20 544f FIGURATION || TO │ │ │ -0004c5f0: 5252 454e 545f 5553 455f 5343 5f4e 4554 RRENT_USE_SC_NET │ │ │ -0004c600: 574f 524b 5f52 4541 4348 4142 494c 4954 WORK_REACHABILIT │ │ │ -0004c610: 5929 2026 616d 703b 2661 6d70 3b20 5c0a Y) && \. │ │ │ -0004c620: 0921 6465 6669 6e65 6420 544f 5252 454e .!defined TORREN │ │ │ -0004c630: 545f 4255 494c 445f 5349 4d55 4c41 544f T_BUILD_SIMULATO │ │ │ -0004c640: 520a 0a2f 2f20 636f 6d6d 6f6e 2075 7469 R..// common uti │ │ │ -0004c650: 6c69 7469 6573 2066 6f72 204d 6163 2061 lities for Mac a │ │ │ -0004c660: 6e64 2069 4f53 0a74 656d 706c 6174 6520 nd iOS.template │ │ │ -0004c670: 266c 743b 7479 7065 6e61 6d65 2054 2667 <typename T&g │ │ │ -0004c680: 743b 2076 6f69 6420 4346 5265 6652 6574 t; void CFRefRet │ │ │ -0004c690: 6169 6e28 5420 6829 207b 2043 4652 6574 ain(T h) { CFRet │ │ │ -0004c6a0: 6169 6e28 6829 3b20 7d0a 7465 6d70 6c61 ain(h); }.templa │ │ │ -0004c6b0: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ -0004c6c0: 5426 6774 3b20 766f 6964 2043 4652 6566 T> void CFRef │ │ │ -0004c6d0: 5265 6c65 6173 6528 5420 6829 207b 2043 Release(T h) { C │ │ │ -0004c6e0: 4652 656c 6561 7365 2868 293b 207d 0a0a FRelease(h); }.. │ │ │ -0004c6f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004c700: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004c730: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004c760: 632f 7472 6163 6b65 725f 6c69 7374 2e63 c/tracker_list.c │ │ │ -0004c770: 7070 3a38 333c 2f61 3e3c 2f74 643e 3c74 pp:83if this throws │ │ │ -0004c790: 2c20 6e65 775f 6165 206e 6565 6473 2074 , new_ae needs t │ │ │ -0004c7a0: 6f20 6265 2066 7265 6564 3c2f 7464 3e3c o be freed< │ │ │ -0004c7b0: 2f74 723e 3c74 7220 6964 3d22 3138 3422 /tr>

    if this │ │ │ -0004c800: 7468 726f 7773 2c20 6e65 775f 6165 206e throws, new_ae n │ │ │ -0004c810: 6565 6473 2074 6f20 6265 2066 7265 6564 eeds to be freed │ │ │ -0004c820: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0004c830: 7472 6163 6b65 725f 6c69 7374 2e63 7070 tracker_list.cpp │ │ │ -0004c840: 3a38 333c 2f68 343e 3c70 7265 2073 7479 :83

    {..ae->fail
    │ │ │ -0004c890: 5f6c 696d 6974 203d 2031 3b0a 7d0a 0a62  _limit = 1;.}..b
    │ │ │ -0004c8a0: 6f6f 6c20 7472 6163 6b65 725f 6c69 7374  ool tracker_list
    │ │ │ -0004c8b0: 3a3a 6164 645f 7472 6163 6b65 7228 616e  ::add_tracker(an
    │ │ │ -0004c8c0: 6e6f 756e 6365 5f65 6e74 7279 2063 6f6e  nounce_entry con
    │ │ │ -0004c8d0: 7374 2661 6d70 3b20 6165 290a 7b0a 0949  st& ae).{..I
    │ │ │ -0004c8e0: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ -0004c8f0: 0a09 6966 2028 6165 2e75 726c 2e65 6d70  ..if (ae.url.emp
    │ │ │ -0004c900: 7479 2829 2920 7265 7475 726e 2066 616c  ty()) return fal
    │ │ │ -0004c910: 7365 3b0a 0961 7574 6f2a 206b 203d 2066  se;..auto* k = f
    │ │ │ -0004c920: 696e 645f 7472 6163 6b65 7228 6165 2e75  ind_tracker(ae.u
    │ │ │ -0004c930: 726c 293b 0a09 6966 2028 6b29 0a09 7b0a  rl);..if (k)..{.
    │ │ │ -0004c940: 0909 6b2d 2667 743b 736f 7572 6365 207c  ..k->source |
    │ │ │ -0004c950: 3d20 6165 2e73 6f75 7263 653b 0a09 0972  = ae.source;...r
    │ │ │ -0004c960: 6574 7572 6e20 6661 6c73 653b 0a09 7d0a  eturn false;..}.
    │ │ │ -0004c970: 0a09 6175 746f 2a20 6e65 775f 6165 203d  ..auto* new_ae =
    │ │ │ -0004c980: 206d 5f73 746f 7261 6765 2e63 6f6e 7374   m_storage.const
    │ │ │ -0004c990: 7275 6374 2861 6529 3b0a 0969 6620 286d  ruct(ae);..if (m
    │ │ │ -0004c9a0: 5f74 7261 636b 6572 732e 656d 7074 7928  _trackers.empty(
    │ │ │ -0004c9b0: 2929 0a09 7b0a 0909 6d5f 7472 6163 6b65  ))..{...m_tracke
    │ │ │ -0004c9c0: 7273 2e70 7573 685f 6261 636b 282a 6e65  rs.push_back(*ne
    │ │ │ -0004c9d0: 775f 6165 293b 0a3c 6469 7620 7374 796c  w_ae);.
    ..m_url_ind │ │ │ -0004ca10: 6578 2e69 6e73 6572 7428 7374 643a 3a6d ex.insert(std::m │ │ │ -0004ca20: 616b 655f 7061 6972 2873 7472 696e 675f ake_pair(string_ │ │ │ -0004ca30: 7669 6577 286e 6577 5f61 652d 2667 743b view(new_ae-> │ │ │ -0004ca40: 7572 6c29 2c20 6e65 775f 6165 2929 3b0a url), new_ae));. │ │ │ -0004ca50: 3c2f 6469 763e 0909 7265 7475 726e 2074
    ..return t │ │ │ -0004ca60: 7275 653b 0a09 7d0a 0a09 6175 746f 2069 rue;..}...auto i │ │ │ -0004ca70: 7465 7220 3d20 6d5f 7472 6163 6b65 7273 ter = m_trackers │ │ │ -0004ca80: 2e65 6e64 2829 3b0a 0977 6869 6c65 2028 .end();..while ( │ │ │ -0004ca90: 6974 6572 2021 3d20 6d5f 7472 6163 6b65 iter != m_tracke │ │ │ -0004caa0: 7273 2e62 6567 696e 2829 2026 616d 703b rs.begin() & │ │ │ -0004cab0: 2661 6d70 3b20 7374 643a 3a70 7265 7628 & std::prev( │ │ │ -0004cac0: 6974 6572 292d 2667 743b 7469 6572 2026 iter)->tier & │ │ │ -0004cad0: 6774 3b20 6e65 775f 6165 2d26 6774 3b74 gt; new_ae->t │ │ │ -0004cae0: 6965 7229 0a09 092d 2d69 7465 723b 0a0a ier)...--iter;.. │ │ │ -0004caf0: 096d 5f74 7261 636b 6572 732e 696e 7365 .m_trackers.inse │ │ │ -0004cb00: 7274 2869 7465 722c 202a 6e65 775f 6165 rt(iter, *new_ae │ │ │ -0004cb10: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -0004cb40: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0004cb50: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0004cb80: 2f73 7263 2f74 7261 636b 6572 5f6c 6973 /src/tracker_lis │ │ │ -0004cb90: 742e 6370 703a 3933 3c2f 613e 3c2f 7464 t.cpp:93if this thr │ │ │ -0004cbb0: 6f77 732c 206e 6577 5f61 6520 6e65 6564 ows, new_ae need │ │ │ -0004cbc0: 7320 746f 2062 6520 6672 6565 643c 2f74 s to be freed

    if th │ │ │ -0004cc20: 6973 2074 6872 6f77 732c 206e 6577 5f61 is throws, new_a │ │ │ -0004cc30: 6520 6e65 6564 7320 746f 2062 6520 6672 e needs to be fr │ │ │ -0004cc40: 6565 643c 2f68 323e 3c68 343e 2e2e 2f73 eed

    ../s │ │ │ -0004cc50: 7263 2f74 7261 636b 6572 5f6c 6973 742e rc/tracker_list. │ │ │ -0004cc60: 6370 703a 3933 3c2f 6834 3e3c 7072 6520 cpp:93

    .auto* k = 
    │ │ │ -0004ccb0: 6669 6e64 5f74 7261 636b 6572 2861 652e  find_tracker(ae.
    │ │ │ -0004ccc0: 7572 6c29 3b0a 0969 6620 286b 290a 097b  url);..if (k)..{
    │ │ │ -0004ccd0: 0a09 096b 2d26 6774 3b73 6f75 7263 6520  ...k->source 
    │ │ │ -0004cce0: 7c3d 2061 652e 736f 7572 6365 3b0a 0909  |= ae.source;...
    │ │ │ -0004ccf0: 7265 7475 726e 2066 616c 7365 3b0a 097d  return false;..}
    │ │ │ -0004cd00: 0a0a 0961 7574 6f2a 206e 6577 5f61 6520  ...auto* new_ae 
    │ │ │ -0004cd10: 3d20 6d5f 7374 6f72 6167 652e 636f 6e73  = m_storage.cons
    │ │ │ -0004cd20: 7472 7563 7428 6165 293b 0a09 6966 2028  truct(ae);..if (
    │ │ │ -0004cd30: 6d5f 7472 6163 6b65 7273 2e65 6d70 7479  m_trackers.empty
    │ │ │ -0004cd40: 2829 290a 097b 0a09 096d 5f74 7261 636b  ())..{...m_track
    │ │ │ -0004cd50: 6572 732e 7075 7368 5f62 6163 6b28 2a6e  ers.push_back(*n
    │ │ │ -0004cd60: 6577 5f61 6529 3b0a 0909 6d5f 7572 6c5f  ew_ae);...m_url_
    │ │ │ -0004cd70: 696e 6465 782e 696e 7365 7274 2873 7464  index.insert(std
    │ │ │ -0004cd80: 3a3a 6d61 6b65 5f70 6169 7228 7374 7269  ::make_pair(stri
    │ │ │ -0004cd90: 6e67 5f76 6965 7728 6e65 775f 6165 2d26  ng_view(new_ae-&
    │ │ │ -0004cda0: 6774 3b75 726c 292c 206e 6577 5f61 6529  gt;url), new_ae)
    │ │ │ -0004cdb0: 293b 0a09 0972 6574 7572 6e20 7472 7565  );...return true
    │ │ │ -0004cdc0: 3b0a 097d 0a0a 0961 7574 6f20 6974 6572  ;..}...auto iter
    │ │ │ -0004cdd0: 203d 206d 5f74 7261 636b 6572 732e 656e   = m_trackers.en
    │ │ │ -0004cde0: 6428 293b 0a09 7768 696c 6520 2869 7465  d();..while (ite
    │ │ │ -0004cdf0: 7220 213d 206d 5f74 7261 636b 6572 732e  r != m_trackers.
    │ │ │ -0004ce00: 6265 6769 6e28 2920 2661 6d70 3b26 616d  begin() &&am
    │ │ │ -0004ce10: 703b 2073 7464 3a3a 7072 6576 2869 7465  p; std::prev(ite
    │ │ │ -0004ce20: 7229 2d26 6774 3b74 6965 7220 2667 743b  r)->tier >
    │ │ │ -0004ce30: 206e 6577 5f61 652d 2667 743b 7469 6572   new_ae->tier
    │ │ │ -0004ce40: 290a 0909 2d2d 6974 6572 3b0a 0a09 6d5f  )...--iter;...m_
    │ │ │ -0004ce50: 7472 6163 6b65 7273 2e69 6e73 6572 7428  trackers.insert(
    │ │ │ -0004ce60: 6974 6572 2c20 2a6e 6577 5f61 6529 3b0a  iter, *new_ae);.
    │ │ │ -0004ce70: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .m │ │ │ -0004cea0: 5f75 726c 5f69 6e64 6578 2e69 6e73 6572 _url_index.inser │ │ │ -0004ceb0: 7428 7374 643a 3a6d 616b 655f 7061 6972 t(std::make_pair │ │ │ -0004cec0: 2873 7472 696e 675f 7669 6577 286e 6577 (string_view(new │ │ │ -0004ced0: 5f61 652d 2667 743b 7572 6c29 2c20 6e65 _ae->url), ne │ │ │ -0004cee0: 775f 6165 2929 3b0a 3c2f 6469 763e 0a09 w_ae));.
    .. │ │ │ -0004cef0: 6966 2028 6e65 775f 6165 2d26 6774 3b73 if (new_ae->s │ │ │ -0004cf00: 6f75 7263 6520 3d3d 2030 2920 6e65 775f ource == 0) new_ │ │ │ -0004cf10: 6165 2d26 6774 3b73 6f75 7263 6520 3d20 ae->source = │ │ │ -0004cf20: 6c74 3a3a 616e 6e6f 756e 6365 5f65 6e74 lt::announce_ent │ │ │ -0004cf30: 7279 3a3a 736f 7572 6365 5f63 6c69 656e ry::source_clien │ │ │ -0004cf40: 743b 0a09 7265 7475 726e 2074 7275 653b t;..return true; │ │ │ -0004cf50: 0a7d 0a0a 766f 6964 2074 7261 636b 6572 .}..void tracker │ │ │ -0004cf60: 5f6c 6973 743a 3a70 7269 6f72 6974 697a _list::prioritiz │ │ │ -0004cf70: 655f 7564 705f 7472 6163 6b65 7273 2829 e_udp_trackers() │ │ │ -0004cf80: 0a7b 0a09 494e 5641 5249 414e 545f 4348 .{..INVARIANT_CH │ │ │ -0004cf90: 4543 4b3b 0a0a 092f 2f20 6c6f 6f6b 2066 ECK;...// look f │ │ │ -0004cfa0: 6f72 2075 6470 2d74 7261 636b 6572 730a or udp-trackers. │ │ │ -0004cfb0: 0966 6f72 2028 6175 746f 2069 203d 206d .for (auto i = m │ │ │ -0004cfc0: 5f74 7261 636b 6572 732e 6265 6769 6e28 _trackers.begin( │ │ │ -0004cfd0: 292c 2065 6e64 286d 5f74 7261 636b 6572 ), end(m_tracker │ │ │ -0004cfe0: 732e 656e 6428 2929 3b20 6920 213d 2065 s.end()); i != e │ │ │ -0004cff0: 6e64 3b20 2b2b 6929 0a09 7b0a 0909 6966 nd; ++i)..{...if │ │ │ -0004d000: 2028 692d 2667 743b 7572 6c2e 7375 6273 (i->url.subs │ │ │ -0004d010: 7472 2830 2c20 3629 2021 3d20 2275 6470 tr(0, 6) != "udp │ │ │ -0004d020: 3a2f 2f22 2920 636f 6e74 696e 7565 3b0a ://") continue;. │ │ │ -0004d030: 0909 2f2f 206e 6f77 2c20 6c6f 6f6b 2066 ..// now, look f │ │ │ -0004d040: 6f72 2074 7261 636b 6572 7320 7769 7468 or trackers with │ │ │ -0004d050: 2074 6865 2073 616d 6520 686f 7374 6e61 the same hostna │ │ │ -0004d060: 6d65 0a09 092f 2f20 7468 6174 2069 7320 me...// that is │ │ │ -0004d070: 6861 7320 6869 6768 6572 2070 7269 6f72 has higher prior │ │ │ -0004d080: 6974 7920 7468 616e 2074 6869 7320 6f6e ity than this on │ │ │ -0004d090: 650a 0909 2f2f 2069 6620 7765 2066 696e e...// if we fin │ │ │ -0004d0a0: 6420 6f6e 652c 2073 7761 7020 7769 7468 d one, swap with │ │ │ -0004d0b0: 2074 6865 2075 6470 2d74 7261 636b 6572 the udp-tracker │ │ │ -0004d0c0: 0a09 0965 7272 6f72 5f63 6f64 6520 6563 ...error_code ec │ │ │ -0004d0d0: 3b0a 0909 7374 643a 3a73 7472 696e 6720 ;...std::string │ │ │ -0004d0e0: 7564 705f 686f 7374 6e61 6d65 3b0a 0909 udp_hostname;... │ │ │ -0004d0f0: 7573 696e 6720 7374 643a 3a69 676e 6f72 using std::ignor │ │ │ -0004d100: 653b 0a09 0973 7464 3a3a 7469 6528 6967 e;...std::tie(ig │ │ │ -0004d110: 6e6f 7265 2c20 6967 6e6f 7265 2c20 7564 nore, ignore, ud │ │ │ -0004d120: 705f 686f 7374 6e61 6d65 2c20 6967 6e6f p_hostname, igno │ │ │ -0004d130: 7265 2c20 6967 6e6f 7265 290a 0909 093d re, ignore)....= │ │ │ -0004d140: 2070 6172 7365 5f75 726c 5f63 6f6d 706f parse_url_compo │ │ │ -0004d150: 6e65 6e74 7328 692d 2667 743b 7572 6c2c nents(i->url, │ │ │ -0004d160: 2065 6329 3b0a 0909 666f 7220 2861 7574 ec);...for (aut │ │ │ -0004d170: 6f20 6a20 3d20 6d5f 7472 6163 6b65 7273 o j = m_trackers │ │ │ -0004d180: 2e62 6567 696e 2829 3b20 6a20 213d 2069 .begin(); j != i │ │ │ -0004d190: 3b20 2b2b 6a29 0a09 097b 0a09 0909 6966 ; ++j)...{....if │ │ │ -0004d1a0: 2028 6a2d 2667 743b 7572 6c2e 7375 6273 (j->url.subs │ │ │ -0004d1b0: 7472 2830 2c20 3629 203d 3d20 2275 6470 tr(0, 6) == "udp │ │ │ -0004d1c0: 3a2f 2f22 2920 636f 6e74 696e 7565 3b0a ://") continue;. │ │ │ -0004d1d0: 0909 0973 7464 3a3a 7374 7269 6e67 2068 ...std::string h │ │ │ -0004d1e0: 6f73 746e 616d 653b 0a09 0909 7374 643a ostname;....std: │ │ │ -0004d1f0: 3a74 6965 2869 676e 6f72 652c 2069 676e :tie(ignore, ign │ │ │ -0004d200: 6f72 652c 2068 6f73 746e 616d 652c 2069 ore, hostname, i │ │ │ -0004d210: 676e 6f72 652c 2069 676e 6f72 6529 0a09 gnore, ignore).. │ │ │ -0004d220: 0909 093d 2070 6172 7365 5f75 726c 5f63 ...= parse_url_c │ │ │ -0004d230: 6f6d 706f 6e65 6e74 7328 6a2d 2667 743b omponents(j-> │ │ │ -0004d240: 7572 6c2c 2065 6329 3b0a 0909 0969 6620 url, ec);....if │ │ │ -0004d250: 2868 6f73 746e 616d 6520 213d 2075 6470 (hostname != udp │ │ │ -0004d260: 5f68 6f73 746e 616d 6529 2063 6f6e 7469 _hostname) conti │ │ │ -0004d270: 6e75 653b 0a09 0909 6175 746f 2a20 6165 nue;....auto* ae │ │ │ -0004d280: 3120 3d20 2661 6d70 3b2a 693b 0a09 0909 1 = &*i;.... │ │ │ -0004d290: 6175 746f 2a20 6165 3220 3d20 2661 6d70 auto* ae2 = & │ │ │ -0004d2a0: 3b2a 6a3b 0a3c 2f70 7265 3e3c 2f74 643e ;*j;.
    │ │ │ -0004d2b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0004d2e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0004d2f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0004d300: 7074 3a65 7870 616e 6428 3138 3629 223e pt:expand(186)"> │ │ │ -0004d310: 2e2e 2f73 7263 2f66 696c 652e 6370 703a ../src/file.cpp: │ │ │ -0004d320: 3138 333c 2f61 3e3c 2f74 643e 3c74 643e 183 │ │ │ -0004d330: 6966 2077 6520 6861 7665 206d 6f72 6520 if we have more │ │ │ -0004d340: 7468 616e 2031 2062 7566 6665 722c 2063 than 1 buffer, c │ │ │ -0004d350: 6f61 6c65 7363 6520 696e 746f 2061 2073 oalesce into a s │ │ │ -0004d360: 696e 676c 6520 6275 6666 6572 2061 6e64 ingle buffer and │ │ │ -0004d370: 2061 2073 696e 676c 6520 6361 6c6c 3c2f a single call

    if w │ │ │ -0004d3d0: 6520 6861 7665 206d 6f72 6520 7468 616e e have more than │ │ │ -0004d3e0: 2031 2062 7566 6665 722c 2063 6f61 6c65 1 buffer, coale │ │ │ -0004d3f0: 7363 6520 696e 746f 2061 2073 696e 676c sce into a singl │ │ │ -0004d400: 6520 6275 6666 6572 0a61 6e64 2061 2073 e buffer.and a s │ │ │ -0004d410: 696e 676c 6520 6361 6c6c 3c2f 6832 3e3c ingle call

    < │ │ │ -0004d420: 6834 3e2e 2e2f 7372 632f 6669 6c65 2e63 h4>../src/file.c │ │ │ -0004d430: 7070 3a31 3833 3c2f 6834 3e3c 7072 6520 pp:183
    ....ec = er
    │ │ │ -0004d480: 726f 725f 636f 6465 2865 7272 6e6f 2c20  ror_code(errno, 
    │ │ │ -0004d490: 7379 7374 656d 5f63 6174 6567 6f72 7928  system_category(
    │ │ │ -0004d4a0: 2929 3b0a 0909 0909 7265 7475 726e 202d  ));.....return -
    │ │ │ -0004d4b0: 313b 0a09 0909 7d0a 0909 0972 6574 202b  1;....}....ret +
    │ │ │ -0004d4c0: 3d20 723b 0a09 0909 6669 6c65 5f6f 6666  = r;....file_off
    │ │ │ -0004d4d0: 7365 7420 2b3d 2072 3b0a 0909 0976 6563  set += r;....vec
    │ │ │ -0004d4e0: 203d 2061 6476 616e 6365 5f69 6f76 6563   = advance_iovec
    │ │ │ -0004d4f0: 2876 6563 2c20 7229 3b0a 0909 7d20 7768  (vec, r);...} wh
    │ │ │ -0004d500: 696c 6520 2876 6563 2e73 697a 6528 2920  ile (vec.size() 
    │ │ │ -0004d510: 2667 743b 2030 293b 0a09 0972 6574 7572  > 0);...retur
    │ │ │ -0004d520: 6e20 7265 743b 0a09 7d0a 2365 6c73 650a  n ret;..}.#else.
    │ │ │ -0004d530: 0969 6e74 2070 7772 6974 6576 5f61 6c6c  .int pwritev_all
    │ │ │ -0004d540: 2868 616e 646c 655f 7479 7065 2063 6f6e  (handle_type con
    │ │ │ -0004d550: 7374 2068 616e 646c 650a 0909 2c20 7370  st handle..., sp
    │ │ │ -0004d560: 616e 266c 743b 7370 616e 266c 743b 6368  an<span<ch
    │ │ │ -0004d570: 6172 2063 6f6e 7374 2667 743b 2063 6f6e  ar const> con
    │ │ │ -0004d580: 7374 2667 743b 2062 7566 730a 0909 2c20  st> bufs..., 
    │ │ │ -0004d590: 7374 643a 3a69 6e74 3634 5f74 2066 696c  std::int64_t fil
    │ │ │ -0004d5a0: 655f 6f66 6673 6574 0a09 092c 2065 7272  e_offset..., err
    │ │ │ -0004d5b0: 6f72 5f63 6f64 6526 616d 703b 2065 6329  or_code& ec)
    │ │ │ -0004d5c0: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ -0004d5d0: 5345 5254 2862 7566 732e 7369 7a65 2829  SERT(bufs.size()
    │ │ │ -0004d5e0: 2026 6774 3b20 3029 3b0a 0909 6966 2028   > 0);...if (
    │ │ │ -0004d5f0: 6275 6673 2e73 697a 6528 2920 3d3d 2031  bufs.size() == 1
    │ │ │ -0004d600: 290a 0909 0972 6574 7572 6e20 7077 7269  )....return pwri
    │ │ │ -0004d610: 7465 5f61 6c6c 2868 616e 646c 652c 2062  te_all(handle, b
    │ │ │ -0004d620: 7566 735b 305d 2c20 6669 6c65 5f6f 6666  ufs[0], file_off
    │ │ │ -0004d630: 7365 742c 2065 6329 3b0a 0a09 0969 6e74  set, ec);....int
    │ │ │ -0004d640: 2072 6574 203d 2030 3b0a 3c64 6976 2073   ret = 0;.
    ..for (a │ │ │ -0004d680: 7574 6f20 636f 6e73 7426 616d 703b 2062 uto const& b │ │ │ -0004d690: 203a 2062 7566 7329 0a3c 2f64 6976 3e09 : bufs).
    . │ │ │ -0004d6a0: 097b 0a09 0909 696e 7420 7220 3d20 7077 .{....int r = pw │ │ │ -0004d6b0: 7269 7465 5f61 6c6c 2868 616e 646c 652c rite_all(handle, │ │ │ -0004d6c0: 2062 2c20 6669 6c65 5f6f 6666 7365 742c b, file_offset, │ │ │ -0004d6d0: 2065 6329 3b0a 0909 0969 6620 2865 6329 ec);....if (ec) │ │ │ -0004d6e0: 2072 6574 7572 6e20 2d31 3b0a 0909 0954 return -1;....T │ │ │ -0004d6f0: 4f52 5245 4e54 5f41 5353 4552 5428 7220 ORRENT_ASSERT(r │ │ │ -0004d700: 2667 743b 2030 293b 0a09 0909 6669 6c65 > 0);....file │ │ │ -0004d710: 5f6f 6666 7365 7420 2b3d 2072 3b0a 0909 _offset += r;... │ │ │ -0004d720: 0972 6574 202b 3d20 723b 0a09 097d 0a09 .ret += r;...}.. │ │ │ -0004d730: 0972 6574 7572 6e20 7265 743b 0a09 7d0a .return ret;..}. │ │ │ -0004d740: 2365 6e64 6966 0a0a 2369 6664 6566 2054 #endif..#ifdef T │ │ │ -0004d750: 4f52 5245 4e54 5f57 494e 444f 5753 0a09 ORRENT_WINDOWS.. │ │ │ -0004d760: 696e 7420 7072 6561 645f 616c 6c28 6861 int pread_all(ha │ │ │ -0004d770: 6e64 6c65 5f74 7970 6520 636f 6e73 7420 ndle_type const │ │ │ -0004d780: 6664 2c20 7370 616e 266c 743b 6368 6172 fd, span<char │ │ │ -0004d790: 2667 743b 2062 7566 2c20 7374 643a 3a69 > buf, std::i │ │ │ -0004d7a0: 6e74 3634 5f74 206f 6666 7365 742c 2065 nt64_t offset, e │ │ │ -0004d7b0: 7272 6f72 5f63 6f64 6526 616d 703b 2065 rror_code& e │ │ │ -0004d7c0: 6329 0a09 7b0a 0909 696e 7420 7265 7420 c)..{...int ret │ │ │ -0004d7d0: 3d20 303b 0a09 094f 5645 524c 4150 5045 = 0;...OVERLAPPE │ │ │ -0004d7e0: 4420 6f6c 7b7d 3b0a 0909 7768 696c 6520 D ol{};...while │ │ │ -0004d7f0: 2862 7566 2e73 697a 6528 2920 2667 743b (buf.size() > │ │ │ -0004d800: 2030 290a 0909 7b0a 0909 096f 6c2e 4f66 0)...{....ol.Of │ │ │ -0004d810: 6673 6574 203d 206f 6666 7365 7420 2661 fset = offset &a │ │ │ -0004d820: 6d70 3b20 3078 6666 6666 6666 6666 3b0a mp; 0xffffffff;. │ │ │ -0004d830: 0909 096f 6c2e 4f66 6673 6574 4869 6768 ...ol.OffsetHigh │ │ │ -0004d840: 203d 206f 6666 7365 7420 2667 743b 2667 = offset >&g │ │ │ -0004d850: 743b 2033 323b 0a09 0909 4457 4f52 4420 t; 32;....DWORD │ │ │ -0004d860: 636f 6e73 7420 6279 7465 735f 746f 5f72 const bytes_to_r │ │ │ -0004d870: 6561 6420 3d20 4457 4f52 4428 6275 662e ead = DWORD(buf. │ │ │ -0004d880: 7369 7a65 2829 293b 0a09 0909 4457 4f52 size());....DWOR │ │ │ -0004d890: 4420 6279 7465 735f 7265 6164 203d 2030 D bytes_read = 0 │ │ │ -0004d8a0: 3b0a 0909 0969 6620 2852 6561 6446 696c ;....if (ReadFil │ │ │ -0004d8b0: 6528 6664 2c20 6275 662e 6461 7461 2829 e(fd, buf.data() │ │ │ -0004d8c0: 2c20 6279 7465 735f 746f 5f72 6561 642c , bytes_to_read, │ │ │ -0004d8d0: 2026 616d 703b 6279 7465 735f 7265 6164 &bytes_read │ │ │ -0004d8e0: 2c20 2661 6d70 3b6f 6c29 203d 3d20 4641 , &ol) == FA │ │ │ -0004d8f0: 4c53 4529 0a09 0909 7b0a 0909 0909 2f2f LSE)....{.....// │ │ │ -0004d900: 2077 6865 6e20 7468 6520 7265 6164 2070 when the read p │ │ │ -0004d910: 6f73 6974 696f 6e20 6973 2061 7420 6f72 osition is at or │ │ │ -0004d920: 2062 6579 6f6e 6420 7468 6520 656e 6420 beyond the end │ │ │ -0004d930: 6f66 2074 6865 0a09 0909 092f 2f20 6669 of the.....// fi │ │ │ -0004d940: 6c65 2c20 5265 6164 4669 6c65 2829 2066 le, ReadFile() f │ │ │ -0004d950: 6169 6c73 2077 6974 6820 4552 524f 525f ails with ERROR_ │ │ │ -0004d960: 4841 4e44 4c45 5f45 4f46 2069 6e73 7465 HANDLE_EOF inste │ │ │ -0004d970: 6164 206f 660a 0909 0909 2f2f 2073 7563 ad of.....// suc │ │ │ -0004d980: 6365 6564 696e 6720 7769 7468 2030 2062 ceeding with 0 b │ │ │ -0004d990: 7974 6573 2072 6561 640a 0909 0909 4457 ytes read.....DW │ │ │ -0004d9a0: 4f52 4420 636f 6e73 7420 6c61 7374 5f65 ORD const last_e │ │ │ -0004d9b0: 7272 6f72 203d 203a 3a47 6574 4c61 7374 rror = ::GetLast │ │ │ -0004d9c0: 4572 726f 7228 293b 0a09 0909 0969 6620 Error();.....if │ │ │ -0004d9d0: 286c 6173 745f 6572 726f 7220 3d3d 2045 (last_error == E │ │ │ -0004d9e0: 5252 4f52 5f48 414e 444c 455f 454f 4629 RROR_HANDLE_EOF) │ │ │ -0004d9f0: 0a09 0909 0909 6563 2e61 7373 6967 6e28 ......ec.assign( │ │ │ -0004da00: 6572 726f 7273 3a3a 6669 6c65 5f74 6f6f errors::file_too │ │ │ -0004da10: 5f73 686f 7274 2c20 6c69 6274 6f72 7265 _short, libtorre │ │ │ -0004da20: 6e74 5f63 6174 6567 6f72 7928 2929 3b0a nt_category());. │ │ │ -0004da30: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004da40: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004da70: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004daa0: 632f 7265 736f 6c76 655f 6475 706c 6963 c/resolve_duplic │ │ │ -0004dab0: 6174 655f 6669 6c65 6e61 6d65 732e 6370 ate_filenames.cp │ │ │ -0004dac0: 703a 3135 383c 2f61 3e3c 2f74 643e 3c74 p:158this can be mo │ │ │ -0004dae0: 7265 2065 6666 6963 6965 6e74 2066 6f72 re efficient for │ │ │ -0004daf0: 2076 3220 746f 7272 656e 7473 3c2f 7464 v2 torrents

    this c │ │ │ -0004db50: 616e 2062 6520 6d6f 7265 2065 6666 6963 an be more effic │ │ │ -0004db60: 6965 6e74 2066 6f72 2076 3220 746f 7272 ient for v2 torr │ │ │ -0004db70: 656e 7473 3c2f 6832 3e3c 6834 3e2e 2e2f ents

    ../ │ │ │ -0004db80: 7372 632f 7265 736f 6c76 655f 6475 706c src/resolve_dupl │ │ │ -0004db90: 6963 6174 655f 6669 6c65 6e61 6d65 732e icate_filenames. │ │ │ -0004dba0: 6370 703a 3135 383c 2f68 343e 3c70 7265 cpp:158

    ....}.....
    │ │ │ -0004dbf0: 2b2b 6e75 6d5f 636f 6c6c 6973 696f 6e73  ++num_collisions
    │ │ │ -0004dc00: 3b0a 0909 0909 6966 2028 6e75 6d5f 636f  ;.....if (num_co
    │ │ │ -0004dc10: 6c6c 6973 696f 6e73 2026 6774 3b20 6d61  llisions > ma
    │ │ │ -0004dc20: 785f 6475 706c 6963 6174 655f 6669 6c65  x_duplicate_file
    │ │ │ -0004dc30: 6e61 6d65 7329 0a09 0909 097b 0a09 0909  names).....{....
    │ │ │ -0004dc40: 0909 6563 203d 2065 7272 6f72 733a 3a74  ..ec = errors::t
    │ │ │ -0004dc50: 6f6f 5f6d 616e 795f 6475 706c 6963 6174  oo_many_duplicat
    │ │ │ -0004dc60: 655f 6669 6c65 6e61 6d65 733b 0a09 0909  e_filenames;....
    │ │ │ -0004dc70: 0909 7265 7475 726e 207b 7d3b 0a09 0909  ..return {};....
    │ │ │ -0004dc80: 097d 0a09 0909 7d0a 0909 0972 6574 2e69  .}....}....ret.i
    │ │ │ -0004dc90: 6e73 6572 7428 7b69 2c20 6669 6c65 6e61  nsert({i, filena
    │ │ │ -0004dca0: 6d65 7d29 3b0a 0909 7d0a 0909 7265 7475  me});...}...retu
    │ │ │ -0004dcb0: 726e 2072 6574 3b0a 097d 0a0a 7d0a 0a09  rn ret;..}..}...
    │ │ │ -0004dcc0: 7374 643a 3a6d 6170 266c 743b 6669 6c65  std::map<file
    │ │ │ -0004dcd0: 5f69 6e64 6578 5f74 2c20 7374 643a 3a73  _index_t, std::s
    │ │ │ -0004dce0: 7472 696e 6726 6774 3b20 7265 736f 6c76  tring> resolv
    │ │ │ -0004dcf0: 655f 6475 706c 6963 6174 655f 6669 6c65  e_duplicate_file
    │ │ │ -0004dd00: 6e61 6d65 7328 0a09 0966 696c 655f 7374  names(...file_st
    │ │ │ -0004dd10: 6f72 6167 6520 636f 6e73 7426 616d 703b  orage const&
    │ │ │ -0004dd20: 2066 730a 0909 2c20 696e 7420 636f 6e73   fs..., int cons
    │ │ │ -0004dd30: 7420 6d61 785f 6475 706c 6963 6174 655f  t max_duplicate_
    │ │ │ -0004dd40: 6669 6c65 6e61 6d65 730a 0909 2c20 6572  filenames..., er
    │ │ │ -0004dd50: 726f 725f 636f 6465 2661 6d70 3b20 6563  ror_code& ec
    │ │ │ -0004dd60: 290a 097b 0a3c 6469 7620 7374 796c 653d  )..{.
    ..std::unorde │ │ │ -0004dda0: 7265 645f 7365 7426 6c74 3b73 7464 3a3a red_set<std:: │ │ │ -0004ddb0: 7569 6e74 3332 5f74 2667 743b 2066 696c uint32_t> fil │ │ │ -0004ddc0: 6573 3b0a 3c2f 6469 763e 0a09 0973 7464 es;.
    ...std │ │ │ -0004ddd0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2065 ::string const e │ │ │ -0004dde0: 6d70 7479 5f73 7472 3b0a 0a09 092f 2f20 mpty_str;....// │ │ │ -0004ddf0: 696e 7365 7274 2061 6c6c 2064 6972 6563 insert all direc │ │ │ -0004de00: 746f 7269 6573 2066 6972 7374 2c20 746f tories first, to │ │ │ -0004de10: 206d 616b 6520 7375 7265 206e 6f20 6669 make sure no fi │ │ │ -0004de20: 6c65 730a 0909 2f2f 2061 7265 2061 6c6c les...// are all │ │ │ -0004de30: 6f77 6564 2074 6f20 636f 6c6c 6965 6420 owed to collied │ │ │ -0004de40: 7769 7468 2074 6865 6d0a 0909 6673 2e61 with them...fs.a │ │ │ -0004de50: 6c6c 5f70 6174 685f 6861 7368 6573 2866 ll_path_hashes(f │ │ │ -0004de60: 696c 6573 293b 0a09 0966 6f72 2028 6175 iles);...for (au │ │ │ -0004de70: 746f 2063 6f6e 7374 2069 203a 2066 732e to const i : fs. │ │ │ -0004de80: 6669 6c65 5f72 616e 6765 2829 290a 0909 file_range())... │ │ │ -0004de90: 7b0a 0909 092f 2f20 6173 206c 6f6e 6720 {....// as long │ │ │ -0004dea0: 6173 2074 6869 7320 6669 6c65 2061 6c72 as this file alr │ │ │ -0004deb0: 6561 6479 2065 7869 7374 730a 0909 092f eady exists..../ │ │ │ -0004dec0: 2f20 696e 6372 6561 7365 2074 6865 2063 / increase the c │ │ │ -0004ded0: 6f75 6e74 6572 0a09 0909 7374 643a 3a75 ounter....std::u │ │ │ -0004dee0: 696e 7433 325f 7420 636f 6e73 7420 6820 int32_t const h │ │ │ -0004def0: 3d20 6673 2e66 696c 655f 7061 7468 5f68 = fs.file_path_h │ │ │ -0004df00: 6173 6828 692c 2065 6d70 7479 5f73 7472 ash(i, empty_str │ │ │ -0004df10: 293b 0a09 0909 6966 2028 2166 696c 6573 );....if (!files │ │ │ -0004df20: 2e69 6e73 6572 7428 6829 2e73 6563 6f6e .insert(h).secon │ │ │ -0004df30: 6429 0a09 0909 7b0a 0909 0909 2f2f 2054 d)....{.....// T │ │ │ -0004df40: 6869 7320 6669 6c65 6e61 6d65 2061 7070 his filename app │ │ │ -0004df50: 6561 7273 2074 6f20 616c 7265 6164 7920 ears to already │ │ │ -0004df60: 6578 6973 7421 0a09 0909 092f 2f20 4966 exist!.....// If │ │ │ -0004df70: 2074 6869 7320 6861 7070 656e 732c 206a this happens, j │ │ │ -0004df80: 7573 7420 7374 6172 7420 6f76 6572 2061 ust start over a │ │ │ -0004df90: 6e64 2064 6f20 6974 2074 6865 2073 6c6f nd do it the slo │ │ │ -0004dfa0: 7720 7761 792c 0a09 0909 092f 2f20 636f w way,.....// co │ │ │ -0004dfb0: 6d70 6172 696e 6720 6675 6c6c 2066 696c mparing full fil │ │ │ -0004dfc0: 6520 6e61 6d65 7320 616e 6420 636f 6d65 e names and come │ │ │ -0004dfd0: 2075 7020 7769 7468 206e 6577 206e 616d up with new nam │ │ │ -0004dfe0: 6573 0a09 0909 0972 6574 7572 6e20 7265 es.....return re │ │ │ -0004dff0: 736f 6c76 655f 6475 706c 6963 6174 655f solve_duplicate_ │ │ │ -0004e000: 6669 6c65 6e61 6d65 735f 736c 6f77 2866 filenames_slow(f │ │ │ -0004e010: 732c 206d 6178 5f64 7570 6c69 6361 7465 s, max_duplicate │ │ │ -0004e020: 5f66 696c 656e 616d 6573 2c20 6563 293b _filenames, ec); │ │ │ -0004e030: 0a09 0909 7d0a 0909 7d0a 0909 7265 7475 ....}...}...retu │ │ │ -0004e040: 726e 207b 7d3b 0a09 7d0a 0a7d 0a3c 2f70 rn {};..}..}.

    re │ │ │ -0004e080: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ -0004e0c0: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ -0004e0d0: 3130 303c 2f61 3e3c 2f74 643e 3c74 643e 100 │ │ │ -0004e0e0: 6669 6e64 2061 2062 6574 7465 7220 706c find a better pl │ │ │ -0004e0f0: 6163 6520 666f 7220 7468 6973 3c2f 7464 ace for this

    find a │ │ │ -0004e150: 2062 6574 7465 7220 706c 6163 6520 666f better place fo │ │ │ -0004e160: 7220 7468 6973 3c2f 6832 3e3c 6834 3e2e r this

    . │ │ │ -0004e170: 2e2f 7372 632f 7069 6563 655f 7069 636b ./src/piece_pick │ │ │ -0004e180: 6572 2e63 7070 3a31 3030 3c2f 6834 3e3c er.cpp:100

    < │ │ │ -0004e190: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0004e1a0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0004e1b0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0004e1c0: 7820 2364 6464 3b22 3e09 0909 7b0a 0909 x #ddd;">...{... │ │ │ -0004e1d0: 0909 7374 643a 3a63 6572 7220 266c 743b ..std::cerr < │ │ │ -0004e1e0: 266c 743b 2022 202e 2e2e 223b 0a09 0909 < " ...";.... │ │ │ -0004e1f0: 0962 7265 616b 3b0a 0909 097d 0a09 0909 .break;....}.... │ │ │ -0004e200: 6966 2028 2a69 203d 3d20 2d31 2920 6272 if (*i == -1) br │ │ │ -0004e210: 6561 6b3b 0a09 0909 7768 696c 6520 286a eak;....while (j │ │ │ -0004e220: 2021 3d20 702e 6d5f 7072 696f 7269 7479 != p.m_priority │ │ │ -0004e230: 5f62 6f75 6e64 6172 6965 732e 656e 6428 _boundaries.end( │ │ │ -0004e240: 2920 2661 6d70 3b26 616d 703b 202a 6a20 ) && *j │ │ │ -0004e250: 266c 743b 3d20 696e 6465 7829 0a09 0909 <= index).... │ │ │ -0004e260: 7b0a 0909 0909 7374 643a 3a63 6572 7220 {.....std::cerr │ │ │ -0004e270: 266c 743b 266c 743b 2022 7c20 223b 0a09 << "| ";.. │ │ │ -0004e280: 0909 092b 2b6a 3b0a 0909 097d 0a09 0909 ...++j;....}.... │ │ │ -0004e290: 7374 643a 3a63 6572 7220 266c 743b 266c std::cerr <&l │ │ │ -0004e2a0: 743b 202a 6920 266c 743b 266c 743b 2022 t; *i << " │ │ │ -0004e2b0: 2822 2026 6c74 3b26 6c74 3b20 702e 6d5f (" << p.m_ │ │ │ -0004e2c0: 7069 6563 655f 6d61 705b 2a69 5d2e 696e piece_map[*i].in │ │ │ -0004e2d0: 6465 7820 266c 743b 266c 743b 2022 2920 dex << ") │ │ │ -0004e2e0: 223b 0a09 0909 2d2d 6c69 6d69 743b 0a09 ";....--limit;.. │ │ │ -0004e2f0: 097d 0a09 0973 7464 3a3a 6365 7272 2026 .}...std::cerr & │ │ │ -0004e300: 6c74 3b26 6c74 3b20 7374 643a 3a65 6e64 lt;< std::end │ │ │ -0004e310: 6c3b 0a09 7d0a 7d0a 2365 6e64 6966 202f l;..}.}.#endif / │ │ │ -0004e320: 2f20 544f 5252 454e 545f 5049 434b 4552 / TORRENT_PICKER │ │ │ -0004e330: 5f4c 4f47 0a0a 6e61 6d65 7370 6163 6520 _LOG..namespace │ │ │ -0004e340: 6c69 6274 6f72 7265 6e74 207b 0a0a 3c64 libtorrent {...con │ │ │ -0004e380: 7374 2070 6965 6365 5f62 6c6f 636b 2070 st piece_block p │ │ │ -0004e390: 6965 6365 5f62 6c6f 636b 3a3a 696e 7661 iece_block::inva │ │ │ -0004e3a0: 6c69 6428 0a3c 2f64 6976 3e09 0973 7464 lid(.
    ..std │ │ │ -0004e3b0: 3a3a 6e75 6d65 7269 635f 6c69 6d69 7473 ::numeric_limits │ │ │ -0004e3c0: 266c 743b 7069 6563 655f 696e 6465 785f <piece_index_ │ │ │ -0004e3d0: 7426 6774 3b3a 3a6d 6178 2829 0a09 092c t>::max()..., │ │ │ -0004e3e0: 2073 7464 3a3a 6e75 6d65 7269 635f 6c69 std::numeric_li │ │ │ -0004e3f0: 6d69 7473 266c 743b 696e 7426 6774 3b3a mits<int>: │ │ │ -0004e400: 3a6d 6178 2829 293b 0a7d 0a0a 6e61 6d65 :max());.}..name │ │ │ -0004e410: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ -0004e420: 3a3a 6175 7820 7b0a 0a09 2f2f 2074 6865 ::aux {...// the │ │ │ -0004e430: 206d 6178 206e 756d 6265 7220 6f66 2062 max number of b │ │ │ -0004e440: 6c6f 636b 7320 746f 2063 7265 6174 6520 locks to create │ │ │ -0004e450: 616e 2061 6666 696e 6974 7920 666f 720a an affinity for. │ │ │ -0004e460: 0963 6f6e 7374 6578 7072 2069 6e74 206d .constexpr int m │ │ │ -0004e470: 6178 5f70 6965 6365 5f61 6666 696e 6974 ax_piece_affinit │ │ │ -0004e480: 795f 6578 7465 6e74 203d 2034 202a 2031 y_extent = 4 * 1 │ │ │ -0004e490: 3032 3420 2a20 3130 3234 202f 2064 6566 024 * 1024 / def │ │ │ -0004e4a0: 6175 6c74 5f62 6c6f 636b 5f73 697a 653b ault_block_size; │ │ │ -0004e4b0: 0a0a 0970 6965 6365 5f70 6963 6b65 723a ...piece_picker: │ │ │ -0004e4c0: 3a70 6965 6365 5f70 6963 6b65 7228 7374 :piece_picker(st │ │ │ -0004e4d0: 643a 3a69 6e74 3634 5f74 2063 6f6e 7374 d::int64_t const │ │ │ -0004e4e0: 2074 6f74 616c 5f73 697a 652c 2069 6e74 total_size, int │ │ │ -0004e4f0: 2063 6f6e 7374 2070 6965 6365 5f73 697a const piece_siz │ │ │ -0004e500: 6529 0a09 093a 206d 5f70 7269 6f72 6974 e)...: m_priorit │ │ │ -0004e510: 795f 626f 756e 6461 7269 6573 2831 2c20 y_boundaries(1, │ │ │ -0004e520: 6d5f 7069 6563 6573 2e65 6e64 5f69 6e64 m_pieces.end_ind │ │ │ -0004e530: 6578 2829 290a 097b 0a09 0954 4f52 5245 ex())..{...TORRE │ │ │ -0004e540: 4e54 5f41 5353 4552 5428 746f 7461 6c5f NT_ASSERT(total_ │ │ │ -0004e550: 7369 7a65 2026 6774 3b20 3029 3b0a 0909 size > 0);... │ │ │ -0004e560: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ -0004e570: 6965 6365 5f73 697a 6520 2667 743b 2030 iece_size > 0 │ │ │ -0004e580: 293b 0a23 6966 6465 6620 544f 5252 454e );.#ifdef TORREN │ │ │ -0004e590: 545f 5049 434b 4552 5f4c 4f47 0a09 0973 T_PICKER_LOG...s │ │ │ -0004e5a0: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74 td::cerr << │ │ │ -0004e5b0: 3b20 225b 2220 266c 743b 266c 743b 2074 ; "[" << t │ │ │ -0004e5c0: 6869 7320 266c 743b 266c 743b 2022 5d20 his << "] │ │ │ -0004e5d0: 2220 266c 743b 266c 743b 2022 6e65 7720 " << "new │ │ │ -0004e5e0: 7069 6563 655f 7069 636b 6572 2220 266c piece_picker" &l │ │ │ -0004e5f0: 743b 266c 743b 2073 7464 3a3a 656e 646c t;< std::endl │ │ │ -0004e600: 3b0a 2365 6e64 6966 0a23 6966 2054 4f52 ;.#endif.#if TOR │ │ │ -0004e610: 5245 4e54 5f55 5345 5f49 4e56 4152 4941 RENT_USE_INVARIA │ │ │ -0004e620: 4e54 5f43 4845 434b 530a 0909 6368 6563 NT_CHECKS...chec │ │ │ -0004e630: 6b5f 696e 7661 7269 616e 7428 293b 0a23 k_invariant();.# │ │ │ -0004e640: 656e 6469 660a 0a09 0972 6573 697a 6528 endif....resize( │ │ │ -0004e650: 746f 7461 6c5f 7369 7a65 2c20 7069 6563 total_size, piec │ │ │ -0004e660: 655f 7369 7a65 293b 0a09 7d0a 0a09 766f e_size);..}...vo │ │ │ -0004e670: 6964 2070 6965 6365 5f70 6963 6b65 723a id piece_picker: │ │ │ -0004e680: 3a72 6573 697a 6528 7374 643a 3a69 6e74 :resize(std::int │ │ │ -0004e690: 3634 5f74 2063 6f6e 7374 2074 6f74 616c 64_t const total │ │ │ -0004e6a0: 5f73 697a 652c 2069 6e74 2063 6f6e 7374 _size, int const │ │ │ -0004e6b0: 2070 6965 6365 5f73 697a 6529 0a09 7b0a piece_size)..{. │ │ │ -0004e6c0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0004e6d0: 2874 6f74 616c 5f73 697a 6520 2667 743b (total_size > │ │ │ -0004e6e0: 2030 293b 0a09 0954 4f52 5245 4e54 5f41 0);...TORRENT_A │ │ │ -0004e6f0: 5353 4552 5428 7069 6563 655f 7369 7a65 SSERT(piece_size │ │ │ -0004e700: 2026 6774 3b20 3029 3b0a 0a09 096d 5f74 > 0);....m_t │ │ │ -0004e710: 6f74 616c 5f73 697a 6520 3d20 746f 7461 otal_size = tota │ │ │ -0004e720: 6c5f 7369 7a65 3b0a 3c2f 7072 653e 3c2f l_size;.relevan │ │ │ -0004e760: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/piece_ │ │ │ -0004e7a0: 7069 636b 6572 2e63 7070 3a32 3035 333c picker.cpp:2053< │ │ │ -0004e7b0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -0004e7c0: 2063 6f75 6c64 2070 726f 6261 626c 7920 could probably │ │ │ -0004e7d0: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ -0004e7e0: 696e 6372 656d 656e 7461 6c6c 7920 6361 incrementally ca │ │ │ -0004e7f0: 6c6c 696e 6720 7061 7274 6961 6c5f 736f lling partial_so │ │ │ -0004e800: 7274 2074 6f20 736f 7274 206f 6e65 206d rt to sort one m │ │ │ -0004e810: 6f72 6520 656c 656d 656e 7420 696e 2074 ore element in t │ │ │ -0004e820: 6865 206c 6973 742e 2042 6563 6175 7365 he list. Because │ │ │ -0004e830: 2063 6861 6e63 6573 2061 7265 2074 6861 chances are tha │ │ │ -0004e840: 7420 7765 276c 6c20 6a75 7374 206e 6565 t we'll just nee │ │ │ -0004e850: 6420 6120 7369 6e67 6c65 2070 6965 6365 d a single piece │ │ │ -0004e860: 2c20 616e 6420 6f6e 6365 2077 6527 7665 , and once we've │ │ │ -0004e870: 2070 6963 6b65 6420 6672 6f6d 2069 7420 picked from it │ │ │ -0004e880: 7765 2772 6520 646f 6e65 2e20 536f 7274 we're done. Sort │ │ │ -0004e890: 696e 6720 7468 6520 7265 7374 206f 6620 ing the rest of │ │ │ -0004e8a0: 7468 6520 6c69 7374 2069 6e20 7468 6174 the list in that │ │ │ -0004e8b0: 2063 6173 6520 6973 2061 2077 6173 7465 case is a waste │ │ │ -0004e8c0: 206f 6620 7469 6d65 2e3c 2f74 643e 3c2f of time.

    this coul │ │ │ -0004e920: 6420 7072 6f62 6162 6c79 2062 6520 6f70 d probably be op │ │ │ -0004e930: 7469 6d69 7a65 6420 6279 2069 6e63 7265 timized by incre │ │ │ -0004e940: 6d65 6e74 616c 6c79 0a63 616c 6c69 6e67 mentally.calling │ │ │ -0004e950: 2070 6172 7469 616c 5f73 6f72 7420 746f partial_sort to │ │ │ -0004e960: 2073 6f72 7420 6f6e 6520 6d6f 7265 2065 sort one more e │ │ │ -0004e970: 6c65 6d65 6e74 2069 6e20 7468 6520 6c69 lement in the li │ │ │ -0004e980: 7374 2e20 4265 6361 7573 650a 6368 616e st. Because.chan │ │ │ -0004e990: 6365 7320 6172 6520 7468 6174 2077 6527 ces are that we' │ │ │ -0004e9a0: 6c6c 206a 7573 7420 6e65 6564 2061 2073 ll just need a s │ │ │ -0004e9b0: 696e 676c 6520 7069 6563 652c 2061 6e64 ingle piece, and │ │ │ -0004e9c0: 206f 6e63 6520 7765 2776 650a 7069 636b once we've.pick │ │ │ -0004e9d0: 6564 2066 726f 6d20 6974 2077 6527 7265 ed from it we're │ │ │ -0004e9e0: 2064 6f6e 652e 2053 6f72 7469 6e67 2074 done. Sorting t │ │ │ -0004e9f0: 6865 2072 6573 7420 6f66 2074 6865 206c he rest of the l │ │ │ -0004ea00: 6973 7420 696e 2074 6861 740a 6361 7365 ist in that.case │ │ │ -0004ea10: 2069 7320 6120 7761 7374 6520 6f66 2074 is a waste of t │ │ │ -0004ea20: 696d 652e 3c2f 6832 3e3c 6834 3e2e 2e2f ime.

    ../ │ │ │ -0004ea30: 7372 632f 7069 6563 655f 7069 636b 6572 src/piece_picker │ │ │ -0004ea40: 2e63 7070 3a32 3035 333c 2f68 343e 3c70 .cpp:2053

    ...// no │ │ │ -0004ea90: 772c 2063 6f70 7920 6f76 6572 2074 6865 w, copy over the │ │ │ -0004eaa0: 2070 6f69 6e74 6572 732e 2057 6520 616c pointers. We al │ │ │ -0004eab0: 736f 2061 7070 6c79 2061 2066 696c 7465 so apply a filte │ │ │ -0004eac0: 7220 6865 7265 2074 6f20 6e6f 740a 0909 r here to not... │ │ │ -0004ead0: 092f 2f20 696e 636c 7564 6520 696e 656c .// include inel │ │ │ -0004eae0: 6967 6962 6c65 2070 6965 6365 7320 696e igible pieces in │ │ │ -0004eaf0: 2063 6572 7461 696e 206d 6f64 6573 2e20 certain modes. │ │ │ -0004eb00: 466f 7220 696e 7374 616e 6365 2c20 6120 For instance, a │ │ │ -0004eb10: 7069 6563 650a 0909 092f 2f20 7468 6174 piece....// that │ │ │ -0004eb20: 2074 6865 2063 7572 7265 6e74 2070 6565 the current pee │ │ │ -0004eb30: 7220 646f 6573 6e27 7420 6861 7665 2069 r doesn't have i │ │ │ -0004eb40: 7320 6e6f 7420 696e 636c 7564 6564 2e0a s not included.. │ │ │ -0004eb50: 0909 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -0004eb60: 7374 2661 6d70 3b20 6470 203a 206d 5f64 st& dp : m_d │ │ │ -0004eb70: 6f77 6e6c 6f61 6473 5b70 6965 6365 5f70 ownloads[piece_p │ │ │ -0004eb80: 6f73 3a3a 7069 6563 655f 646f 776e 6c6f os::piece_downlo │ │ │ -0004eb90: 6164 696e 675d 290a 0909 097b 0a09 0909 ading])....{.... │ │ │ -0004eba0: 0970 632e 696e 635f 7374 6174 735f 636f .pc.inc_stats_co │ │ │ -0004ebb0: 756e 7465 7228 636f 756e 7465 7273 3a3a unter(counters:: │ │ │ -0004ebc0: 7069 6563 655f 7069 636b 6572 5f70 6172 piece_picker_par │ │ │ -0004ebd0: 7469 616c 5f6c 6f6f 7073 293b 0a0a 0909 tial_loops);.... │ │ │ -0004ebe0: 0909 6966 2028 2169 735f 7069 6563 655f ..if (!is_piece_ │ │ │ -0004ebf0: 6672 6565 2864 702e 696e 6465 782c 2070 free(dp.index, p │ │ │ -0004ec00: 6965 6365 7329 2920 636f 6e74 696e 7565 ieces)) continue │ │ │ -0004ec10: 3b0a 0a09 0909 0954 4f52 5245 4e54 5f41 ;......TORRENT_A │ │ │ -0004ec20: 5353 4552 5428 6d5f 7069 6563 655f 6d61 SSERT(m_piece_ma │ │ │ -0004ec30: 705b 6470 2e69 6e64 6578 5d2e 646f 776e p[dp.index].down │ │ │ -0004ec40: 6c6f 6164 5f71 7565 7565 2829 0a09 0909 load_queue().... │ │ │ -0004ec50: 0909 3d3d 2070 6965 6365 5f70 6f73 3a3a ..== piece_pos:: │ │ │ -0004ec60: 7069 6563 655f 646f 776e 6c6f 6164 696e piece_downloadin │ │ │ -0004ec70: 6729 3b0a 0a09 0909 096f 7264 6572 6564 g);......ordered │ │ │ -0004ec80: 5f70 6172 7469 616c 735b 6e75 6d5f 6f72 _partials[num_or │ │ │ -0004ec90: 6465 7265 645f 7061 7274 6961 6c73 2b2b dered_partials++ │ │ │ -0004eca0: 5d20 3d20 2661 6d70 3b64 703b 0a09 0909 ] = &dp;.... │ │ │ -0004ecb0: 7d0a 0a09 0909 2f2f 206e 6f77 2c20 736f }.....// now, so │ │ │ -0004ecc0: 7274 2074 6865 206c 6973 742e 0a09 0909 rt the list..... │ │ │ -0004ecd0: 6966 2028 6f70 7469 6f6e 7320 2661 6d70 if (options & │ │ │ -0004ece0: 3b20 7261 7265 7374 5f66 6972 7374 290a ; rarest_first). │ │ │ -0004ecf0: 0909 097b 0a09 0909 0972 6574 207c 3d20 ...{.....ret |= │ │ │ -0004ed00: 7069 636b 6572 5f6c 6f67 5f61 6c65 7274 picker_log_alert │ │ │ -0004ed10: 3a3a 7261 7265 7374 5f66 6972 7374 5f70 ::rarest_first_p │ │ │ -0004ed20: 6172 7469 616c 733b 0a0a 3c64 6976 2073 artials;..

    ....std: │ │ │ -0004ed60: 3a73 6f72 7428 6f72 6465 7265 645f 7061 :sort(ordered_pa │ │ │ -0004ed70: 7274 6961 6c73 2e62 6567 696e 2829 2c20 rtials.begin(), │ │ │ -0004ed80: 6f72 6465 7265 645f 7061 7274 6961 6c73 ordered_partials │ │ │ -0004ed90: 2e62 6567 696e 2829 202b 206e 756d 5f6f .begin() + num_o │ │ │ -0004eda0: 7264 6572 6564 5f70 6172 7469 616c 730a rdered_partials. │ │ │ -0004edb0: 3c2f 6469 763e 0909 0909 092c 2073 7464
    ....., std │ │ │ -0004edc0: 3a3a 6269 6e64 2826 616d 703b 7069 6563 ::bind(&piec │ │ │ -0004edd0: 655f 7069 636b 6572 3a3a 7061 7274 6961 e_picker::partia │ │ │ -0004ede0: 6c5f 636f 6d70 6172 655f 7261 7265 7374 l_compare_rarest │ │ │ -0004edf0: 5f66 6972 7374 2c20 7468 6973 0a09 0909 _first, this.... │ │ │ -0004ee00: 0909 092c 205f 312c 205f 3229 293b 0a09 ..., _1, _2));.. │ │ │ -0004ee10: 0909 7d0a 0a09 0909 666f 7220 2869 6e74 ..}.....for (int │ │ │ -0004ee20: 2069 203d 2030 3b20 6920 266c 743b 206e i = 0; i < n │ │ │ -0004ee30: 756d 5f6f 7264 6572 6564 5f70 6172 7469 um_ordered_parti │ │ │ -0004ee40: 616c 733b 202b 2b69 290a 0909 097b 0a09 als; ++i)....{.. │ │ │ -0004ee50: 0909 0972 6574 207c 3d20 7069 636b 6572 ...ret |= picker │ │ │ -0004ee60: 5f6c 6f67 5f61 6c65 7274 3a3a 7072 696f _log_alert::prio │ │ │ -0004ee70: 7269 7469 7a65 5f70 6172 7469 616c 733b ritize_partials; │ │ │ -0004ee80: 0a0a 0909 0909 6e75 6d5f 626c 6f63 6b73 ......num_blocks │ │ │ -0004ee90: 203d 2061 6464 5f62 6c6f 636b 735f 646f = add_blocks_do │ │ │ -0004eea0: 776e 6c6f 6164 696e 6728 2a6f 7264 6572 wnloading(*order │ │ │ -0004eeb0: 6564 5f70 6172 7469 616c 735b 695d 2c20 ed_partials[i], │ │ │ -0004eec0: 7069 6563 6573 0a09 0909 0909 2c20 696e pieces......, in │ │ │ -0004eed0: 7465 7265 7374 696e 675f 626c 6f63 6b73 teresting_blocks │ │ │ -0004eee0: 2c20 6261 636b 7570 5f62 6c6f 636b 730a , backup_blocks. │ │ │ -0004eef0: 0909 0909 092c 206e 756d 5f62 6c6f 636b ....., num_block │ │ │ -0004ef00: 732c 2070 7265 6665 725f 636f 6e74 6967 s, prefer_contig │ │ │ -0004ef10: 756f 7573 5f62 6c6f 636b 732c 2070 6565 uous_blocks, pee │ │ │ -0004ef20: 722c 206f 7074 696f 6e73 293b 0a09 0909 r, options);.... │ │ │ -0004ef30: 0969 6620 286e 756d 5f62 6c6f 636b 7320 .if (num_blocks │ │ │ -0004ef40: 266c 743b 3d20 3029 2072 6574 7572 6e20 <= 0) return │ │ │ -0004ef50: 7265 743b 0a09 0909 0969 6620 2869 6e74 ret;.....if (int │ │ │ -0004ef60: 2862 6163 6b75 705f 626c 6f63 6b73 2e73 (backup_blocks.s │ │ │ -0004ef70: 697a 6528 2929 2026 6774 3b3d 206e 756d ize()) >= num │ │ │ -0004ef80: 5f62 6c6f 636b 7329 0a09 0909 0909 6272 _blocks)......br │ │ │ -0004ef90: 6561 6b3b 0a09 0909 7d0a 0a09 0909 6e75 eak;....}.....nu │ │ │ -0004efa0: 6d5f 626c 6f63 6b73 203d 2061 7070 656e m_blocks = appen │ │ │ -0004efb0: 645f 626c 6f63 6b73 2869 6e74 6572 6573 d_blocks(interes │ │ │ -0004efc0: 7469 6e67 5f62 6c6f 636b 732c 2062 6163 ting_blocks, bac │ │ │ -0004efd0: 6b75 705f 626c 6f63 6b73 0a09 0909 092c kup_blocks....., │ │ │ -0004efe0: 206e 756d 5f62 6c6f 636b 7329 3b0a 0909 num_blocks);... │ │ │ -0004eff0: 0969 6620 286e 756d 5f62 6c6f 636b 7320 .if (num_blocks │ │ │ -0004f000: 266c 743b 3d20 3029 2072 6574 7572 6e20 <= 0) return │ │ │ -0004f010: 7265 743b 0a09 097d 0a0a 0909 6966 2028 ret;...}....if ( │ │ │ -0004f020: 2173 7567 6765 7374 6564 5f70 6965 6365 !suggested_piece │ │ │ -0004f030: 732e 656d 7074 7928 2929 0a09 097b 0a09 s.empty())...{.. │ │ │ -0004f040: 0909 666f 7220 2870 6965 6365 5f69 6e64 ..for (piece_ind │ │ │ -0004f050: 6578 5f74 2069 203a 2073 7567 6765 7374 ex_t i : suggest │ │ │ -0004f060: 6564 5f70 6965 6365 7329 0a09 0909 7b0a ed_pieces)....{. │ │ │ -0004f070: 0909 0909 7063 2e69 6e63 5f73 7461 7473 ....pc.inc_stats │ │ │ -0004f080: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572 _counter(counter │ │ │ -0004f090: 733a 3a70 6965 6365 5f70 6963 6b65 725f s::piece_picker_ │ │ │ -0004f0a0: 7375 6767 6573 745f 6c6f 6f70 7329 3b0a suggest_loops);. │ │ │ -0004f0b0: 0909 0909 6966 2028 2169 735f 7069 6563 ....if (!is_piec │ │ │ -0004f0c0: 655f 6672 6565 2869 2c20 7069 6563 6573 e_free(i, pieces │ │ │ -0004f0d0: 2929 2063 6f6e 7469 6e75 653b 0a0a 0909 )) continue;.... │ │ │ -0004f0e0: 0909 7265 7420 7c3d 2070 6963 6b65 725f ..ret |= picker_ │ │ │ -0004f0f0: 6c6f 675f 616c 6572 743a 3a73 7567 6765 log_alert::sugge │ │ │ -0004f100: 7374 6564 5f70 6965 6365 733b 0a0a 3c2f sted_pieces;..r │ │ │ -0004f140: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0004f150: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../src/ │ │ │ -0004f180: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ -0004f190: 3a32 3139 353c 2f61 3e3c 2f74 643e 3c74 :2195Is it a good i │ │ │ -0004f1b0: 6465 6120 7468 6174 2074 6869 7320 6166 dea that this af │ │ │ -0004f1c0: 6669 6e69 7479 2074 616b 6573 2070 7265 finity takes pre │ │ │ -0004f1d0: 6365 6465 6e63 6520 6f76 6572 2070 6965 cedence over pie │ │ │ -0004f1e0: 6365 2070 7269 6f72 6974 793f 3c2f 7464 ce priority?

    Is it │ │ │ -0004f240: 6120 676f 6f64 2069 6465 6120 7468 6174 a good idea that │ │ │ -0004f250: 2074 6869 7320 6166 6669 6e69 7479 2074 this affinity t │ │ │ -0004f260: 616b 6573 2070 7265 6365 6465 6e63 6520 akes precedence │ │ │ -0004f270: 6f76 6572 0a70 6965 6365 2070 7269 6f72 over.piece prior │ │ │ -0004f280: 6974 793f 3c2f 6832 3e3c 6834 3e2e 2e2f ity?

    ../ │ │ │ -0004f290: 7372 632f 7069 6563 655f 7069 636b 6572 src/piece_picker │ │ │ -0004f2a0: 2e63 7070 3a32 3139 353c 2f68 343e 3c70 .cpp:2195

    ......pc │ │ │ -0004f2f0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ -0004f300: 6572 2863 6f75 6e74 6572 733a 3a70 6965 er(counters::pie │ │ │ -0004f310: 6365 5f70 6963 6b65 725f 7265 7665 7273 ce_picker_revers │ │ │ -0004f320: 655f 7261 7265 5f6c 6f6f 7073 293b 0a0a e_rare_loops);.. │ │ │ -0004f330: 0909 0909 0909 6966 2028 2169 735f 7069 ......if (!is_pi │ │ │ -0004f340: 6563 655f 6672 6565 286d 5f70 6965 6365 ece_free(m_piece │ │ │ -0004f350: 735b 705d 2c20 7069 6563 6573 2929 2063 s[p], pieces)) c │ │ │ -0004f360: 6f6e 7469 6e75 653b 0a09 0909 0909 092f ontinue;......./ │ │ │ -0004f370: 2f20 6375 7273 6f72 7320 6172 6520 6e6f / cursors are no │ │ │ -0004f380: 7420 6d75 7461 7465 6420 6475 7269 6e67 t mutated during │ │ │ -0004f390: 2070 6963 6b69 6e67 3b20 6d61 6b65 2073 picking; make s │ │ │ -0004f3a0: 7572 6520 7765 2064 6f6e 2774 2070 6963 ure we don't pic │ │ │ -0004f3b0: 6b20 7069 6563 6573 2077 6974 6869 6e20 k pieces within │ │ │ -0004f3c0: 7468 650a 0909 0909 0909 2f2f 2073 6571 the.......// seq │ │ │ -0004f3d0: 7565 6e74 6961 6c20 7261 6e67 6520 6966 uential range if │ │ │ -0004f3e0: 2069 6e20 7365 7175 656e 7469 616c 2064 in sequential d │ │ │ -0004f3f0: 6f77 6e6c 6f61 6420 6d6f 6465 2073 6f20 ownload mode so │ │ │ -0004f400: 7468 6174 2077 6520 646f 6e27 7420 7069 that we don't pi │ │ │ -0004f410: 636b 2064 7570 6c69 6361 7465 2070 6965 ck duplicate pie │ │ │ -0004f420: 6365 730a 0909 0909 0909 6966 2028 286f ces.......if ((o │ │ │ -0004f430: 7074 696f 6e73 2026 616d 703b 2073 6571 ptions & seq │ │ │ -0004f440: 7565 6e74 6961 6c29 2026 616d 703b 2661 uential) &&a │ │ │ -0004f450: 6d70 3b20 6d5f 7069 6563 6573 5b70 5d20 mp; m_pieces[p] │ │ │ -0004f460: 2667 743b 3d20 6d5f 6375 7273 6f72 2026 >= m_cursor & │ │ │ -0004f470: 616d 703b 2661 6d70 3b20 6d5f 7069 6563 amp;& m_piec │ │ │ -0004f480: 6573 5b70 5d20 266c 743b 206d 5f72 6576 es[p] < m_rev │ │ │ -0004f490: 6572 7365 5f63 7572 736f 7229 2063 6f6e erse_cursor) con │ │ │ -0004f4a0: 7469 6e75 653b 0a0a 0909 0909 0909 7265 tinue;........re │ │ │ -0004f4b0: 7420 7c3d 2070 6963 6b65 725f 6c6f 675f t |= picker_log_ │ │ │ -0004f4c0: 616c 6572 743a 3a72 6576 6572 7365 5f72 alert::reverse_r │ │ │ -0004f4d0: 6172 6573 745f 6669 7273 743b 0a0a 0909 arest_first;.... │ │ │ -0004f4e0: 0909 0909 6e75 6d5f 626c 6f63 6b73 203d ....num_blocks = │ │ │ -0004f4f0: 2061 6464 5f62 6c6f 636b 7328 6d5f 7069 add_blocks(m_pi │ │ │ -0004f500: 6563 6573 5b70 5d2c 2070 6965 6365 730a eces[p], pieces. │ │ │ -0004f510: 0909 0909 0909 092c 2069 6e74 6572 6573 ......., interes │ │ │ -0004f520: 7469 6e67 5f62 6c6f 636b 730a 0909 0909 ting_blocks..... │ │ │ -0004f530: 0909 092c 2062 6163 6b75 705f 626c 6f63 ..., backup_bloc │ │ │ -0004f540: 6b73 2c20 6e75 6d5f 626c 6f63 6b73 0a09 ks, num_blocks.. │ │ │ -0004f550: 0909 0909 0909 2c20 7072 6566 6572 5f63 ......, prefer_c │ │ │ -0004f560: 6f6e 7469 6775 6f75 735f 626c 6f63 6b73 ontiguous_blocks │ │ │ -0004f570: 2c20 7065 6572 2c20 6967 6e6f 7265 645f , peer, ignored_ │ │ │ -0004f580: 7069 6563 6573 0a09 0909 0909 0909 2c20 pieces........, │ │ │ -0004f590: 6f70 7469 6f6e 7329 3b0a 0909 0909 0909 options);....... │ │ │ -0004f5a0: 6966 2028 6e75 6d5f 626c 6f63 6b73 2026 if (num_blocks & │ │ │ -0004f5b0: 6c74 3b3d 2030 2920 7265 7475 726e 2072 lt;= 0) return r │ │ │ -0004f5c0: 6574 3b0a 0909 0909 097d 0a09 0909 097d et;......}.....} │ │ │ -0004f5d0: 0a09 0909 7d0a 0909 0965 6c73 650a 0909 ....}....else... │ │ │ -0004f5e0: 097b 0a3c 6469 7620 7374 796c 653d 2262 .{.

    ....if (options │ │ │ -0004f620: 2026 616d 703b 2070 6965 6365 5f65 7874 & piece_ext │ │ │ -0004f630: 656e 745f 6166 6669 6e69 7479 290a 3c2f ent_affinity).....{......i │ │ │ -0004f650: 6e74 2074 6f5f 6572 6173 6520 3d20 2d31 nt to_erase = -1 │ │ │ -0004f660: 3b0a 0909 0909 0969 6e74 2069 6478 203d ;......int idx = │ │ │ -0004f670: 202d 313b 0a09 0909 0909 666f 7220 2870 -1;......for (p │ │ │ -0004f680: 6965 6365 5f65 7874 656e 745f 7420 636f iece_extent_t co │ │ │ -0004f690: 6e73 7420 6520 3a20 6d5f 7265 6365 6e74 nst e : m_recent │ │ │ -0004f6a0: 5f65 7874 656e 7473 290a 0909 0909 097b _extents)......{ │ │ │ -0004f6b0: 0a09 0909 0909 092b 2b69 6478 3b0a 0909 .......++idx;... │ │ │ -0004f6c0: 0909 0909 626f 6f6c 2068 6176 655f 616c ....bool have_al │ │ │ -0004f6d0: 6c20 3d20 7472 7565 3b0a 0909 0909 0909 l = true;....... │ │ │ -0004f6e0: 666f 7220 2870 6965 6365 5f69 6e64 6578 for (piece_index │ │ │ -0004f6f0: 5f74 2063 6f6e 7374 2070 203a 2065 7874 _t const p : ext │ │ │ -0004f700: 656e 745f 666f 7228 6529 290a 0909 0909 ent_for(e))..... │ │ │ -0004f710: 0909 7b0a 0909 0909 0909 0969 6620 2821 ..{........if (! │ │ │ -0004f720: 6d5f 7069 6563 655f 6d61 705b 705d 2e66 m_piece_map[p].f │ │ │ -0004f730: 6c75 7368 6564 2829 2920 6861 7665 5f61 lushed()) have_a │ │ │ -0004f740: 6c6c 203d 2066 616c 7365 3b0a 0909 0909 ll = false;..... │ │ │ -0004f750: 0909 0969 6620 2821 6973 5f70 6965 6365 ...if (!is_piece │ │ │ -0004f760: 5f66 7265 6528 702c 2070 6965 6365 7329 _free(p, pieces) │ │ │ -0004f770: 2920 636f 6e74 696e 7565 3b0a 0909 0909 ) continue;..... │ │ │ -0004f780: 0909 0969 6620 2828 6f70 7469 6f6e 7320 ...if ((options │ │ │ -0004f790: 2661 6d70 3b20 7365 7175 656e 7469 616c & sequential │ │ │ -0004f7a0: 2920 2661 6d70 3b26 616d 703b 2070 2026 ) && p & │ │ │ -0004f7b0: 6774 3b3d 206d 5f63 7572 736f 7220 2661 gt;= m_cursor &a │ │ │ -0004f7c0: 6d70 3b26 616d 703b 2070 2026 6c74 3b20 mp;& p < │ │ │ -0004f7d0: 6d5f 7265 7665 7273 655f 6375 7273 6f72 m_reverse_cursor │ │ │ -0004f7e0: 2920 636f 6e74 696e 7565 3b0a 0a09 0909 ) continue;..... │ │ │ -0004f7f0: 0909 0909 7265 7420 7c3d 2070 6963 6b65 ....ret |= picke │ │ │ -0004f800: 725f 6c6f 675f 616c 6572 743a 3a65 7874 r_log_alert::ext │ │ │ -0004f810: 656e 745f 6166 6669 6e69 7479 3b0a 0a09 ent_affinity;... │ │ │ -0004f820: 0909 0909 0909 6e75 6d5f 626c 6f63 6b73 ......num_blocks │ │ │ -0004f830: 203d 2061 6464 5f62 6c6f 636b 7328 702c = add_blocks(p, │ │ │ -0004f840: 2070 6965 6365 730a 0909 0909 0909 0909 pieces......... │ │ │ -0004f850: 2c20 696e 7465 7265 7374 696e 675f 626c , interesting_bl │ │ │ -0004f860: 6f63 6b73 0a09 0909 0909 0909 092c 2062 ocks........., b │ │ │ -0004f870: 6163 6b75 705f 626c 6f63 6b73 2c20 6e75 ackup_blocks, nu │ │ │ -0004f880: 6d5f 626c 6f63 6b73 0a09 0909 0909 0909 m_blocks........ │ │ │ -0004f890: 092c 2070 7265 6665 725f 636f 6e74 6967 ., prefer_contig │ │ │ -0004f8a0: 756f 7573 5f62 6c6f 636b 732c 2070 6565 uous_blocks, pee │ │ │ -0004f8b0: 722c 2069 676e 6f72 6564 5f70 6965 6365 r, ignored_piece │ │ │ -0004f8c0: 730a 0909 0909 0909 0909 2c20 6f70 7469 s........., opti │ │ │ -0004f8d0: 6f6e 7329 3b0a 0909 0909 0909 0969 6620 ons);........if │ │ │ -0004f8e0: 286e 756d 5f62 6c6f 636b 7320 266c 743b (num_blocks < │ │ │ -0004f8f0: 3d20 3029 0a09 0909 0909 0909 7b0a 0909 = 0)........{... │ │ │ -0004f900: 0909 0909 0909 2f2f 2069 6620 7765 2068 ......// if we h │ │ │ -0004f910: 6176 6520 616c 6c20 7069 6563 6573 2062 ave all pieces b │ │ │ -0004f920: 656c 6f6e 6769 6e67 2074 6f20 7468 6973 elonging to this │ │ │ -0004f930: 2065 7874 656e 742c 2072 656d 6f76 6520 extent, remove │ │ │ -0004f940: 6974 0a09 0909 0909 0909 0969 6620 2874 it.........if (t │ │ │ -0004f950: 6f5f 6572 6173 6520 213d 202d 3129 206d o_erase != -1) m │ │ │ -0004f960: 5f72 6563 656e 745f 6578 7465 6e74 732e _recent_extents. │ │ │ -0004f970: 6572 6173 6528 6d5f 7265 6365 6e74 5f65 erase(m_recent_e │ │ │ -0004f980: 7874 656e 7473 2e62 6567 696e 2829 202b xtents.begin() + │ │ │ -0004f990: 2074 6f5f 6572 6173 6529 3b0a 0909 0909 to_erase);..... │ │ │ -0004f9a0: 0909 0909 7265 7475 726e 2072 6574 3b0a ....return ret;. │ │ │ -0004f9b0: 0909 0909 0909 097d 0a09 0909 0909 097d .......}.......} │ │ │ -0004f9c0: 0a09 0909 0909 092f 2f20 6966 2077 6520 .......// if we │ │ │ -0004f9d0: 6861 7665 2061 6c6c 2070 6965 6365 7320 have all pieces │ │ │ -0004f9e0: 6265 6c6f 6e67 696e 6720 746f 2074 6869 belonging to thi │ │ │ -0004f9f0: 7320 6578 7465 6e74 2c20 7265 6d6f 7665 s extent, remove │ │ │ -0004fa00: 2069 740a 0909 0909 0909 6966 2028 6861 it.......if (ha │ │ │ -0004fa10: 7665 5f61 6c6c 2920 746f 5f65 7261 7365 ve_all) to_erase │ │ │ -0004fa20: 203d 2069 6478 3b0a 0909 0909 097d 0a3c = idx;......}.< │ │ │ -0004fa30: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0004fa40: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0004fa50: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0004fa60: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0004fa70: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0004faa0: 2f70 6965 6365 5f70 6963 6b65 722e 6370 /piece_picker.cp │ │ │ -0004fab0: 703a 3235 3437 3c2f 613e 3c2f 7464 3e3c p:2547< │ │ │ -0004fac0: 7464 3e77 6865 6e20 6578 7061 6e64 696e td>when expandin │ │ │ -0004fad0: 6720 7069 6563 6573 2066 6f72 2063 6163 g pieces for cac │ │ │ -0004fae0: 6865 2073 7472 6970 6520 7265 6173 6f6e he stripe reason │ │ │ -0004faf0: 732c 2074 6865 2021 646f 776e 6c6f 6164 s, the !download │ │ │ -0004fb00: 696e 6720 636f 6e64 6974 696f 6e20 646f ing condition do │ │ │ -0004fb10: 6573 6e27 7420 6d61 6b65 206d 7563 6820 esn't make much │ │ │ -0004fb20: 7365 6e73 653c 2f74 643e 3c2f 7472 3e3c sense< │ │ │ -0004fb30: 7472 2069 643d 2231 3931 2220 7374 796c tr id="191" styl │ │ │ -0004fb40: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0004fb50: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0004fb60: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0004fb70: 6832 3e77 6865 6e20 6578 7061 6e64 696e h2>when expandin │ │ │ -0004fb80: 6720 7069 6563 6573 2066 6f72 2063 6163 g pieces for cac │ │ │ -0004fb90: 6865 2073 7472 6970 6520 7265 6173 6f6e he stripe reason │ │ │ -0004fba0: 732c 0a74 6865 2021 646f 776e 6c6f 6164 s,.the !download │ │ │ -0004fbb0: 696e 6720 636f 6e64 6974 696f 6e20 646f ing condition do │ │ │ -0004fbc0: 6573 6e27 7420 6d61 6b65 206d 7563 6820 esn't make much │ │ │ -0004fbd0: 7365 6e73 653c 2f68 323e 3c68 343e 2e2e sense

    .. │ │ │ -0004fbe0: 2f73 7263 2f70 6965 6365 5f70 6963 6b65 /src/piece_picke │ │ │ -0004fbf0: 722e 6370 703a 3235 3437 3c2f 6834 3e3c r.cpp:2547

    < │ │ │ -0004fc00: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0004fc10: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0004fc20: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0004fc30: 7820 2364 6464 3b22 3e09 0954 4f52 5245 x #ddd;">..TORRE │ │ │ -0004fc40: 4e54 5f41 5353 4552 5428 696e 6465 7820 NT_ASSERT(index │ │ │ -0004fc50: 266c 743b 206d 5f70 6965 6365 5f6d 6170 < m_piece_map │ │ │ -0004fc60: 2e65 6e64 5f69 6e64 6578 2829 293b 0a09 .end_index());.. │ │ │ -0004fc70: 0969 6620 286e 6578 7428 696e 6465 7829 .if (next(index) │ │ │ -0004fc80: 203d 3d20 6d5f 7069 6563 655f 6d61 702e == m_piece_map. │ │ │ -0004fc90: 656e 645f 696e 6465 7828 2929 0a09 0909 end_index()).... │ │ │ -0004fca0: 7265 7475 726e 206d 5f62 6c6f 636b 735f return m_blocks_ │ │ │ -0004fcb0: 696e 5f6c 6173 745f 7069 6563 653b 0a09 in_last_piece;.. │ │ │ -0004fcc0: 0965 6c73 650a 0909 0972 6574 7572 6e20 .else....return │ │ │ -0004fcd0: 626c 6f63 6b73 5f70 6572 5f70 6965 6365 blocks_per_piece │ │ │ -0004fce0: 2829 3b0a 097d 0a0a 0962 6f6f 6c20 7069 ();..}...bool pi │ │ │ -0004fcf0: 6563 655f 7069 636b 6572 3a3a 6973 5f70 ece_picker::is_p │ │ │ -0004fd00: 6965 6365 5f66 7265 6528 7069 6563 655f iece_free(piece_ │ │ │ -0004fd10: 696e 6465 785f 7420 636f 6e73 7420 7069 index_t const pi │ │ │ -0004fd20: 6563 650a 0909 2c20 7479 7065 645f 6269 ece..., typed_bi │ │ │ -0004fd30: 7466 6965 6c64 266c 743b 7069 6563 655f tfield<piece_ │ │ │ -0004fd40: 696e 6465 785f 7426 6774 3b20 636f 6e73 index_t> cons │ │ │ -0004fd50: 7426 616d 703b 2062 6974 6d61 736b 2920 t& bitmask) │ │ │ -0004fd60: 636f 6e73 740a 097b 0a09 0972 6574 7572 const..{...retur │ │ │ -0004fd70: 6e20 6269 746d 6173 6b5b 7069 6563 655d n bitmask[piece] │ │ │ -0004fd80: 0a09 0909 2661 6d70 3b26 616d 703b 2021 ....&& ! │ │ │ -0004fd90: 6d5f 7069 6563 655f 6d61 705b 7069 6563 m_piece_map[piec │ │ │ -0004fda0: 655d 2e66 6c75 7368 6564 2829 0a09 0909 e].flushed().... │ │ │ -0004fdb0: 2661 6d70 3b26 616d 703b 2021 6d5f 7069 && !m_pi │ │ │ -0004fdc0: 6563 655f 6d61 705b 7069 6563 655d 2e66 ece_map[piece].f │ │ │ -0004fdd0: 696c 7465 7265 6428 293b 0a09 7d0a 0a09 iltered();..}... │ │ │ -0004fde0: 626f 6f6c 2070 6965 6365 5f70 6963 6b65 bool piece_picke │ │ │ -0004fdf0: 723a 3a63 616e 5f70 6963 6b28 7069 6563 r::can_pick(piec │ │ │ -0004fe00: 655f 696e 6465 785f 7420 636f 6e73 7420 e_index_t const │ │ │ -0004fe10: 7069 6563 650a 0909 2c20 7479 7065 645f piece..., typed_ │ │ │ -0004fe20: 6269 7466 6965 6c64 266c 743b 7069 6563 bitfield<piec │ │ │ -0004fe30: 655f 696e 6465 785f 7426 6774 3b20 636f e_index_t> co │ │ │ -0004fe40: 6e73 7426 616d 703b 2062 6974 6d61 736b nst& bitmask │ │ │ -0004fe50: 2920 636f 6e73 740a 097b 0a09 0972 6574 ) const..{...ret │ │ │ -0004fe60: 7572 6e20 6269 746d 6173 6b5b 7069 6563 urn bitmask[piec │ │ │ -0004fe70: 655d 0a09 0909 2661 6d70 3b26 616d 703b e]....&& │ │ │ -0004fe80: 2021 6d5f 7069 6563 655f 6d61 705b 7069 !m_piece_map[pi │ │ │ -0004fe90: 6563 655d 2e66 6c75 7368 6564 2829 0a3c ece].flushed().< │ │ │ -0004fea0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -0004feb0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -0004fec0: 7769 6474 683d 2231 3030 2522 3e09 0909 width="100%">... │ │ │ -0004fed0: 2661 6d70 3b26 616d 703b 2021 6d5f 7069 && !m_pi │ │ │ -0004fee0: 6563 655f 6d61 705b 7069 6563 655d 2e64 ece_map[piece].d │ │ │ -0004fef0: 6f77 6e6c 6f61 6469 6e67 2829 0a3c 2f64 ownloading()....&& │ │ │ -0004ff10: 2021 6d5f 7069 6563 655f 6d61 705b 7069 !m_piece_map[pi │ │ │ -0004ff20: 6563 655d 2e66 696c 7465 7265 6428 293b ece].filtered(); │ │ │ -0004ff30: 0a09 7d0a 0a23 6966 2054 4f52 5245 4e54 ..}..#if TORRENT │ │ │ -0004ff40: 5f55 5345 5f49 4e56 4152 4941 4e54 5f43 _USE_INVARIANT_C │ │ │ -0004ff50: 4845 434b 530a 0976 6f69 6420 7069 6563 HECKS..void piec │ │ │ -0004ff60: 655f 7069 636b 6572 3a3a 6368 6563 6b5f e_picker::check_ │ │ │ -0004ff70: 7065 6572 7328 290a 097b 0a09 0966 6f72 peers()..{...for │ │ │ -0004ff80: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ -0004ff90: 3b20 6220 3a20 6d5f 626c 6f63 6b5f 696e ; b : m_block_in │ │ │ -0004ffa0: 666f 290a 0909 7b0a 0909 0954 4f52 5245 fo)...{....TORRE │ │ │ -0004ffb0: 4e54 5f41 5353 4552 5428 622e 7065 6572 NT_ASSERT(b.peer │ │ │ -0004ffc0: 203d 3d20 6e75 6c6c 7074 7220 7c7c 2073 == nullptr || s │ │ │ -0004ffd0: 7461 7469 635f 6361 7374 266c 743b 6175 tatic_cast<au │ │ │ -0004ffe0: 783a 3a74 6f72 7265 6e74 5f70 6565 722a x::torrent_peer* │ │ │ -0004fff0: 2667 743b 2862 2e70 6565 7229 2d26 6774 >(b.peer)-> │ │ │ -00050000: 3b69 6e5f 7573 6529 3b0a 0909 7d0a 097d ;in_use);...}..} │ │ │ -00050010: 0a23 656e 6469 660a 0a09 766f 6964 2070 .#endif...void p │ │ │ -00050020: 6965 6365 5f70 6963 6b65 723a 3a63 6c65 iece_picker::cle │ │ │ -00050030: 6172 5f70 6565 7228 6175 783a 3a74 6f72 ar_peer(aux::tor │ │ │ -00050040: 7265 6e74 5f70 6565 722a 2070 6565 7229 rent_peer* peer) │ │ │ -00050050: 0a09 7b0a 0909 666f 7220 2861 7574 6f26 ..{...for (auto& │ │ │ -00050060: 616d 703b 2062 203a 206d 5f62 6c6f 636b amp; b : m_block │ │ │ -00050070: 5f69 6e66 6f29 0a09 097b 0a09 0909 6966 _info)...{....if │ │ │ -00050080: 2028 622e 7065 6572 203d 3d20 7065 6572 (b.peer == peer │ │ │ -00050090: 2920 622e 7065 6572 203d 206e 756c 6c70 ) b.peer = nullp │ │ │ -000500a0: 7472 3b0a 0909 7d0a 097d 0a0a 092f 2f20 tr;...}..}...// │ │ │ -000500b0: 7468 6520 6669 7273 7420 626f 6f6c 2069 the first bool i │ │ │ -000500c0: 7320 7472 7565 2069 6620 7468 6973 2069 s true if this i │ │ │ -000500d0: 7320 7468 6520 6f6e 6c79 2070 6565 7220 s the only peer │ │ │ -000500e0: 7468 6174 2068 6173 2072 6571 7565 7374 that has request │ │ │ -000500f0: 6564 2061 6e64 2064 6f77 6e6c 6f61 6465 ed and downloade │ │ │ -00050100: 640a 092f 2f20 626c 6f63 6b73 2066 726f d..// blocks fro │ │ │ -00050110: 6d20 7468 6973 2070 6965 6365 2e0a 092f m this piece.../ │ │ │ -00050120: 2f20 7468 6520 7365 636f 6e64 2062 6f6f / the second boo │ │ │ -00050130: 6c20 6973 2074 7275 6520 6966 2074 6869 l is true if thi │ │ │ -00050140: 7320 6973 2074 6865 206f 6e6c 7920 6163 s is the only ac │ │ │ -00050150: 7469 7665 2070 6565 7220 7468 6174 2069 tive peer that i │ │ │ -00050160: 7320 7265 7175 6573 7469 6e67 0a09 2f2f s requesting..// │ │ │ -00050170: 2061 6e64 2064 6f77 6e6c 6f61 6469 6e67 and downloading │ │ │ -00050180: 2062 6c6f 636b 7320 6672 6f6d 2074 6869 blocks from thi │ │ │ -00050190: 7320 7069 6563 652e 2041 6374 6976 6520 s piece. Active │ │ │ -000501a0: 6d65 616e 7320 6861 7669 6e67 2061 2063 means having a c │ │ │ -000501b0: 6f6e 6e65 6374 696f 6e2e 0a3c 2f70 7265 onnection..rele │ │ │ -000501f0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pie │ │ │ -00050230: 6365 5f70 6963 6b65 722e 6370 703a 3331 ce_picker.cpp:31 │ │ │ -00050240: 3139 3c2f 613e 3c2f 7464 3e3c 7464 3e73 19s │ │ │ -00050250: 686f 756c 6420 3520 6265 2063 6f6e 6669 hould 5 be confi │ │ │ -00050260: 6775 7261 626c 653f 3c2f 7464 3e3c 2f74 gurable?

    should 5 b │ │ │ -000502c0: 6520 636f 6e66 6967 7572 6162 6c65 3f3c e configurable?< │ │ │ -000502d0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ -000502e0: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ -000502f0: 3331 3139 3c2f 6834 3e3c 7072 6520 7374 3119

    ..bool have_a
    │ │ │ -00050340: 6c6c 203d 2074 7275 653b 0a0a 0909 666f  ll = true;....fo
    │ │ │ -00050350: 7220 2861 7574 6f20 636f 6e73 7420 7069  r (auto const pi
    │ │ │ -00050360: 6563 6520 3a20 6578 7465 6e74 5f66 6f72  ece : extent_for
    │ │ │ -00050370: 2874 6869 735f 6578 7465 6e74 2929 0a09  (this_extent))..
    │ │ │ -00050380: 097b 0a09 0909 6966 2028 7069 6563 6520  .{....if (piece 
    │ │ │ -00050390: 3d3d 2070 2920 636f 6e74 696e 7565 3b0a  == p) continue;.
    │ │ │ -000503a0: 0a09 0909 6966 2028 216d 5f70 6965 6365  ....if (!m_piece
    │ │ │ -000503b0: 5f6d 6170 5b70 6965 6365 5d2e 666c 7573  _map[piece].flus
    │ │ │ -000503c0: 6865 6428 2929 2068 6176 655f 616c 6c20  hed()) have_all 
    │ │ │ -000503d0: 3d20 6661 6c73 653b 0a0a 0909 092f 2f20  = false;.....// 
    │ │ │ -000503e0: 6966 2061 7420 6c65 6173 7420 6f6e 6520  if at least one 
    │ │ │ -000503f0: 7069 6563 6520 696e 2074 6869 7320 6578  piece in this ex
    │ │ │ -00050400: 7465 6e74 2068 6173 2061 2064 6966 6665  tent has a diffe
    │ │ │ -00050410: 7265 6e74 2070 7269 6f72 6974 7920 7468  rent priority th
    │ │ │ -00050420: 616e 0a09 0909 2f2f 2074 6865 206f 6e65  an....// the one
    │ │ │ -00050430: 2077 6520 6a75 7374 2073 7461 7274 6564   we just started
    │ │ │ -00050440: 2064 6f77 6e6c 6f61 6469 6e67 2c20 646f   downloading, do
    │ │ │ -00050450: 6e27 7420 6372 6561 7465 2061 6e20 6166  n't create an af
    │ │ │ -00050460: 6669 6e69 7479 2066 6f72 0a09 0909 2f2f  finity for....//
    │ │ │ -00050470: 2061 646a 6163 656e 7420 7069 6563 6573   adjacent pieces
    │ │ │ -00050480: 2e20 5468 6973 2070 726f 6261 626c 7920  . This probably 
    │ │ │ -00050490: 6d65 616e 7320 7468 6520 7069 6563 6573  means the pieces
    │ │ │ -000504a0: 2062 656c 6f6e 6720 746f 2064 6966 6665   belong to diffe
    │ │ │ -000504b0: 7265 6e74 0a09 0909 2f2f 2066 696c 6573  rent....// files
    │ │ │ -000504c0: 2c20 6f72 2074 6861 7420 736f 6d65 206f  , or that some o
    │ │ │ -000504d0: 7468 6572 206d 6563 6861 6e69 736d 2064  ther mechanism d
    │ │ │ -000504e0: 6574 6572 6d69 6e69 6e67 2074 6865 2070  etermining the p
    │ │ │ -000504f0: 7269 6f72 6974 7920 7368 6f75 6c64 0a09  riority should..
    │ │ │ -00050500: 0909 2f2f 2074 616b 6520 7072 6563 6564  ..// take preced
    │ │ │ -00050510: 656e 6365 2e0a 0909 0969 6620 2870 6965  ence.....if (pie
    │ │ │ -00050520: 6365 5f70 7269 6f72 6974 7928 7069 6563  ce_priority(piec
    │ │ │ -00050530: 6529 2021 3d20 7468 6973 5f70 7269 6f29  e) != this_prio)
    │ │ │ -00050540: 2072 6574 7572 6e3b 0a09 097d 0a0a 0909   return;...}....
    │ │ │ -00050550: 2f2f 2069 6620 7765 2061 6c72 6561 6479  // if we already
    │ │ │ -00050560: 2068 6176 6520 616c 6c20 7468 6520 2a6f   have all the *o
    │ │ │ -00050570: 7468 6572 2a20 7069 6563 6573 2069 6e20  ther* pieces in 
    │ │ │ -00050580: 7468 6973 2065 7874 656e 742c 2074 6865  this extent, the
    │ │ │ -00050590: 7265 2773 206e 6f0a 0909 2f2f 206e 6565  re's no...// nee
    │ │ │ -000505a0: 6420 746f 2069 6e66 6c61 7465 2074 6865  d to inflate the
    │ │ │ -000505b0: 6972 2070 7269 6f72 6974 6965 730a 0909  ir priorities...
    │ │ │ -000505c0: 6966 2028 6861 7665 5f61 6c6c 2920 7265  if (have_all) re
    │ │ │ -000505d0: 7475 726e 3b0a 0a3c 6469 7620 7374 796c  turn;..
    ..if (m_rec │ │ │ -00050610: 656e 745f 6578 7465 6e74 732e 7369 7a65 ent_extents.size │ │ │ -00050620: 2829 2026 6c74 3b20 3529 0a3c 2f64 6976 () < 5).
    ...m_recent_ext │ │ │ -00050640: 656e 7473 2e70 7573 685f 6261 636b 2874 ents.push_back(t │ │ │ -00050650: 6869 735f 6578 7465 6e74 293b 0a0a 0909 his_extent);.... │ │ │ -00050660: 2f2f 206c 696d 6974 2074 6865 206e 756d // limit the num │ │ │ -00050670: 6265 7220 6f66 2065 7874 656e 7420 6166 ber of extent af │ │ │ -00050680: 6669 6e69 7469 6573 2061 6374 6976 6520 finities active │ │ │ -00050690: 6174 2061 6e79 2067 6976 656e 2074 696d at any given tim │ │ │ -000506a0: 6520 746f 206c 696d 6974 0a09 092f 2f20 e to limit...// │ │ │ -000506b0: 7468 6520 636f 7374 206f 6620 6368 6563 the cost of chec │ │ │ -000506c0: 6b69 6e67 2074 6865 6d2e 2041 6c73 6f2c king them. Also, │ │ │ -000506d0: 2064 6f6e 2774 2072 6570 6c61 6365 2074 don't replace t │ │ │ -000506e0: 6865 6d2c 2063 6f6d 6d69 7420 746f 0a09 hem, commit to.. │ │ │ -000506f0: 092f 2f20 6669 6e69 7368 696e 6720 7468 .// finishing th │ │ │ -00050700: 656d 2062 6566 6f72 6520 7374 6172 7469 em before starti │ │ │ -00050710: 6e67 2061 6e6f 7468 6572 2065 7874 656e ng another exten │ │ │ -00050720: 742e 2054 6869 7320 6973 2061 6e61 6c6f t. This is analo │ │ │ -00050730: 676f 7573 2074 6f0a 0909 2f2f 206c 696d gous to...// lim │ │ │ -00050740: 6974 696e 6720 7468 6520 6e75 6d62 6572 iting the number │ │ │ -00050750: 206f 6620 7061 7274 6961 6c20 7069 6563 of partial piec │ │ │ -00050760: 6573 2e0a 097d 0a0a 092f 2f20 6f70 7469 es...}...// opti │ │ │ -00050770: 6f6e 7320 6d61 7920 6265 2030 206f 7220 ons may be 0 or │ │ │ -00050780: 7069 6563 655f 7069 636b 6572 3a3a 7265 piece_picker::re │ │ │ -00050790: 7665 7273 650a 092f 2f20 7265 7475 726e verse..// return │ │ │ -000507a0: 7320 6661 6c73 6520 6966 2074 6865 2062 s false if the b │ │ │ -000507b0: 6c6f 636b 2063 6f75 6c64 206e 6f74 2062 lock could not b │ │ │ -000507c0: 6520 6d61 726b 6564 2061 7320 646f 776e e marked as down │ │ │ -000507d0: 6c6f 6164 696e 670a 0962 6f6f 6c20 7069 loading..bool pi │ │ │ -000507e0: 6563 655f 7069 636b 6572 3a3a 6d61 726b ece_picker::mark │ │ │ -000507f0: 5f61 735f 646f 776e 6c6f 6164 696e 6728 _as_downloading( │ │ │ -00050800: 7069 6563 655f 626c 6f63 6b20 636f 6e73 piece_block cons │ │ │ -00050810: 7420 626c 6f63 6b0a 0909 2c20 6175 783a t block..., aux: │ │ │ -00050820: 3a74 6f72 7265 6e74 5f70 6565 722a 2070 :torrent_peer* p │ │ │ -00050830: 6565 722c 2070 6963 6b65 725f 6f70 7469 eer, picker_opti │ │ │ -00050840: 6f6e 735f 7420 636f 6e73 7420 6f70 7469 ons_t const opti │ │ │ -00050850: 6f6e 7329 0a09 7b0a 2369 6664 6566 2054 ons)..{.#ifdef T │ │ │ -00050860: 4f52 5245 4e54 5f50 4943 4b45 525f 4c4f ORRENT_PICKER_LO │ │ │ -00050870: 470a 0909 7374 643a 3a63 6572 7220 266c G...std::cerr &l │ │ │ -00050880: 743b 266c 743b 2022 5b22 2026 6c74 3b26 t;< "[" <& │ │ │ -00050890: 6c74 3b20 7468 6973 2026 6c74 3b26 6c74 lt; this << │ │ │ -000508a0: 3b20 225d 2022 2026 6c74 3b26 6c74 3b20 ; "] " << │ │ │ -000508b0: 226d 6172 6b5f 6173 5f64 6f77 6e6c 6f61 "mark_as_downloa │ │ │ -000508c0: 6469 6e67 2820 7b22 0a09 0909 266c 743b ding( {"....< │ │ │ -000508d0: 266c 743b 2062 6c6f 636b 2e70 6965 6365 < block.piece │ │ │ -000508e0: 5f69 6e64 6578 2026 6c74 3b26 6c74 3b20 _index << │ │ │ -000508f0: 222c 2022 2026 6c74 3b26 6c74 3b20 626c ", " << bl │ │ │ -00050900: 6f63 6b2e 626c 6f63 6b5f 696e 6465 7820 ock.block_index │ │ │ -00050910: 266c 743b 266c 743b 2022 7d20 2922 2026 << "} )" & │ │ │ -00050920: 6c74 3b26 6c74 3b20 7374 643a 3a65 6e64 lt;< std::end │ │ │ -00050930: 6c3b 0a23 656e 6469 660a 0a09 0954 4f52 l;.#endif....TOR │ │ │ -00050940: 5245 4e54 5f41 5353 4552 5428 7065 6572 RENT_ASSERT(peer │ │ │ -00050950: 203d 3d20 6e75 6c6c 7074 7220 7c7c 2070 == nullptr || p │ │ │ -00050960: 6565 722d 2667 743b 696e 5f75 7365 293b eer->in_use); │ │ │ -00050970: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00050980: 5428 626c 6f63 6b2e 626c 6f63 6b5f 696e T(block.block_in │ │ │ -00050990: 6465 7820 213d 2070 6965 6365 5f62 6c6f dex != piece_blo │ │ │ -000509a0: 636b 3a3a 696e 7661 6c69 642e 626c 6f63 ck::invalid.bloc │ │ │ -000509b0: 6b5f 696e 6465 7829 3b0a 0909 544f 5252 k_index);...TORR │ │ │ -000509c0: 454e 545f 4153 5345 5254 2862 6c6f 636b ENT_ASSERT(block │ │ │ -000509d0: 2e70 6965 6365 5f69 6e64 6578 2021 3d20 .piece_index != │ │ │ -000509e0: 7069 6563 655f 626c 6f63 6b3a 3a69 6e76 piece_block::inv │ │ │ -000509f0: 616c 6964 2e70 6965 6365 5f69 6e64 6578 alid.piece_index │ │ │ -00050a00: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -00050a10: 4552 5428 626c 6f63 6b2e 7069 6563 655f ERT(block.piece_ │ │ │ -00050a20: 696e 6465 7820 266c 743b 206d 5f70 6965 index < m_pie │ │ │ -00050a30: 6365 5f6d 6170 2e65 6e64 5f69 6e64 6578 ce_map.end_index │ │ │ -00050a40: 2829 293b 0a09 0954 4f52 5245 4e54 5f41 ());...TORRENT_A │ │ │ -00050a50: 5353 4552 5428 626c 6f63 6b2e 626c 6f63 SSERT(block.bloc │ │ │ -00050a60: 6b5f 696e 6465 7820 266c 743b 2062 6c6f k_index < blo │ │ │ -00050a70: 636b 735f 696e 5f70 6965 6365 2862 6c6f cks_in_piece(blo │ │ │ -00050a80: 636b 2e70 6965 6365 5f69 6e64 6578 2929 ck.piece_index)) │ │ │ -00050a90: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ -00050aa0: 5254 2821 6d5f 7069 6563 655f 6d61 705b RT(!m_piece_map[ │ │ │ -00050ab0: 626c 6f63 6b2e 7069 6563 655f 696e 6465 block.piece_inde │ │ │ -00050ac0: 785d 2e66 6c75 7368 6564 2829 293b 0a0a x].flushed());.. │ │ │ -00050ad0: 0909 7069 6563 655f 706f 7326 616d 703b ..piece_pos& │ │ │ -00050ae0: 2070 203d 206d 5f70 6965 6365 5f6d 6170 p = m_piece_map │ │ │ -00050af0: 5b62 6c6f 636b 2e70 6965 6365 5f69 6e64 [block.piece_ind │ │ │ -00050b00: 6578 5d3b 0a09 0969 6620 2870 2e64 6f77 ex];...if (p.dow │ │ │ -00050b10: 6e6c 6f61 645f 7175 6575 6528 2920 3d3d nload_queue() == │ │ │ -00050b20: 2070 6965 6365 5f70 6f73 3a3a 7069 6563 piece_pos::piec │ │ │ -00050b30: 655f 6f70 656e 290a 0909 7b0a 2369 6664 e_open)...{.#ifd │ │ │ -00050b40: 6566 2054 4f52 5245 4e54 5f45 5850 454e ef TORRENT_EXPEN │ │ │ -00050b50: 5349 5645 5f49 4e56 4152 4941 4e54 5f43 SIVE_INVARIANT_C │ │ │ -00050b60: 4845 434b 530a 0909 0949 4e56 4152 4941 HECKS....INVARIA │ │ │ -00050b70: 4e54 5f43 4845 434b 3b0a 3c2f 7072 653e NT_CHECK;.
    │ │ │ -00050b80: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00050bb0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00050bc0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/stor │ │ │ -00050bf0: 6167 655f 7574 696c 732e 6370 703a 3132 age_utils.cpp:12 │ │ │ -00050c00: 333c 2f61 3e3c 2f74 643e 3c74 643e 6964 3id │ │ │ -00050c10: 6561 6c6c 792c 2069 6620 7765 2065 6e64 eally, if we end │ │ │ -00050c20: 2075 7020 636f 7079 696e 6720 6669 6c65 up copying file │ │ │ -00050c30: 7320 6265 6361 7573 6520 6f66 2061 206d s because of a m │ │ │ -00050c40: 6f76 6520 6163 726f 7373 2076 6f6c 756d ove across volum │ │ │ -00050c50: 6573 2c20 7468 6520 736f 7572 6365 2073 es, the source s │ │ │ -00050c60: 686f 756c 6420 6e6f 7420 6265 2064 656c hould not be del │ │ │ -00050c70: 6574 6564 2075 6e74 696c 2074 6865 7927 eted until they' │ │ │ -00050c80: 7665 2061 6c6c 2062 6565 6e20 636f 7069 ve all been copi │ │ │ -00050c90: 6564 2e20 5468 6174 2077 6f75 6c64 206c ed. That would l │ │ │ -00050ca0: 6574 2075 7320 726f 6c6c 6261 636b 2077 et us rollback w │ │ │ -00050cb0: 6974 6820 6869 6768 6572 2063 6f6e 6669 ith higher confi │ │ │ -00050cc0: 6465 6e63 652e 3c2f 7464 3e3c 2f74 723e dence. │ │ │ -00050cd0: 3c74 7220 6964 3d22 3139 3322 2073 7479 │ │ │ -00050d00: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00050d10: 3c68 323e 6964 6561 6c6c 792c 2069 6620

    ideally, if │ │ │ -00050d20: 7765 2065 6e64 2075 7020 636f 7079 696e we end up copyin │ │ │ -00050d30: 6720 6669 6c65 7320 6265 6361 7573 6520 g files because │ │ │ -00050d40: 6f66 2061 206d 6f76 6520 6163 726f 7373 of a move across │ │ │ -00050d50: 0a76 6f6c 756d 6573 2c20 7468 6520 736f .volumes, the so │ │ │ -00050d60: 7572 6365 2073 686f 756c 6420 6e6f 7420 urce should not │ │ │ -00050d70: 6265 2064 656c 6574 6564 2075 6e74 696c be deleted until │ │ │ -00050d80: 2074 6865 7927 7665 2061 6c6c 2062 6565 they've all bee │ │ │ -00050d90: 6e0a 636f 7069 6564 2e20 5468 6174 2077 n.copied. That w │ │ │ -00050da0: 6f75 6c64 206c 6574 2075 7320 726f 6c6c ould let us roll │ │ │ -00050db0: 6261 636b 2077 6974 6820 6869 6768 6572 back with higher │ │ │ -00050dc0: 2063 6f6e 6669 6465 6e63 652e 3c2f 6832 confidence.

    ../src/stor │ │ │ -00050de0: 6167 655f 7574 696c 732e 6370 703a 3132 age_utils.cpp:12 │ │ │ -00050df0: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -00050e30: 0909 2f2f 206c 6174 6572 0a09 0961 7578  ..// later...aux
    │ │ │ -00050e40: 3a3a 7665 6374 6f72 266c 743b 626f 6f6c  ::vector<bool
    │ │ │ -00050e50: 2c20 6669 6c65 5f69 6e64 6578 5f74 2667  , file_index_t&g
    │ │ │ -00050e60: 743b 2063 6f70 6965 645f 6669 6c65 7328  t; copied_files(
    │ │ │ -00050e70: 7374 643a 3a73 697a 655f 7428 662e 6e75  std::size_t(f.nu
    │ │ │ -00050e80: 6d5f 6669 6c65 7328 2929 2c20 6661 6c73  m_files()), fals
    │ │ │ -00050e90: 6529 3b0a 0a09 092f 2f20 7472 6163 6b20  e);....// track 
    │ │ │ -00050ea0: 686f 7720 6661 7220 7765 2067 6f74 2069  how far we got i
    │ │ │ -00050eb0: 6e20 6361 7365 206f 6620 616e 2065 7272  n case of an err
    │ │ │ -00050ec0: 6f72 0a09 0966 696c 655f 696e 6465 785f  or...file_index_
    │ │ │ -00050ed0: 7420 6669 6c65 5f69 6e64 6578 7b7d 3b0a  t file_index{};.
    │ │ │ -00050ee0: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ -00050ef0: 7420 6920 3a20 662e 6669 6c65 5f72 616e  t i : f.file_ran
    │ │ │ -00050f00: 6765 2829 290a 0909 7b0a 0909 092f 2f20  ge())...{....// 
    │ │ │ -00050f10: 6669 6c65 7320 6d6f 7665 6420 6f75 7420  files moved out 
    │ │ │ -00050f20: 746f 2061 6273 6f6c 7574 6520 7061 7468  to absolute path
    │ │ │ -00050f30: 7320 6172 6520 6e6f 7420 6d6f 7665 640a  s are not moved.
    │ │ │ -00050f40: 0909 0969 6620 2866 2e66 696c 655f 6162  ...if (f.file_ab
    │ │ │ -00050f50: 736f 6c75 7465 5f70 6174 6828 6929 2920  solute_path(i)) 
    │ │ │ -00050f60: 636f 6e74 696e 7565 3b0a 0a09 0909 7374  continue;.....st
    │ │ │ -00050f70: 643a 3a73 7472 696e 6720 636f 6e73 7420  d::string const 
    │ │ │ -00050f80: 6f6c 645f 7061 7468 203d 2063 6f6d 6269  old_path = combi
    │ │ │ -00050f90: 6e65 5f70 6174 6828 7361 7665 5f70 6174  ne_path(save_pat
    │ │ │ -00050fa0: 682c 2066 2e66 696c 655f 7061 7468 2869  h, f.file_path(i
    │ │ │ -00050fb0: 2929 3b0a 0909 0973 7464 3a3a 7374 7269  ));....std::stri
    │ │ │ -00050fc0: 6e67 2063 6f6e 7374 206e 6577 5f70 6174  ng const new_pat
    │ │ │ -00050fd0: 6820 3d20 636f 6d62 696e 655f 7061 7468  h = combine_path
    │ │ │ -00050fe0: 286e 6577 5f73 6176 655f 7061 7468 2c20  (new_save_path, 
    │ │ │ -00050ff0: 662e 6669 6c65 5f70 6174 6828 6929 293b  f.file_path(i));
    │ │ │ -00051000: 0a0a 0909 0965 7272 6f72 5f63 6f64 6520  .....error_code 
    │ │ │ -00051010: 6967 6e6f 7265 3b0a 0909 0969 6620 2866  ignore;....if (f
    │ │ │ -00051020: 6c61 6773 203d 3d20 6d6f 7665 5f66 6c61  lags == move_fla
    │ │ │ -00051030: 6773 5f74 3a3a 646f 6e74 5f72 6570 6c61  gs_t::dont_repla
    │ │ │ -00051040: 6365 2026 616d 703b 2661 6d70 3b20 6578  ce && ex
    │ │ │ -00051050: 6973 7473 286e 6577 5f70 6174 682c 2069  ists(new_path, i
    │ │ │ -00051060: 676e 6f72 6529 290a 0909 097b 0a09 0909  gnore))....{....
    │ │ │ -00051070: 0972 6574 207c 3d20 6469 736b 5f73 7461  .ret |= disk_sta
    │ │ │ -00051080: 7475 733a 3a6e 6565 645f 6675 6c6c 5f63  tus::need_full_c
    │ │ │ -00051090: 6865 636b 3b0a 0909 0909 636f 6e74 696e  heck;.....contin
    │ │ │ -000510a0: 7565 3b0a 0909 097d 0a0a 3c64 6976 2073  ue;....}..
    ...move_ │ │ │ -000510e0: 6669 6c65 286f 6c64 5f70 6174 682c 206e file(old_path, n │ │ │ -000510f0: 6577 5f70 6174 682c 2065 6329 3b0a 3c2f ew_path, ec);.....// if th │ │ │ -00051110: 6520 736f 7572 6365 2066 696c 6520 646f e source file do │ │ │ -00051120: 6573 6e27 7420 6578 6973 742e 2054 6861 esn't exist. Tha │ │ │ -00051130: 7427 7320 6e6f 7420 6120 7072 6f62 6c65 t's not a proble │ │ │ -00051140: 6d0a 0909 092f 2f20 7765 206a 7573 7420 m....// we just │ │ │ -00051150: 6967 6e6f 7265 2074 6861 7420 6669 6c65 ignore that file │ │ │ -00051160: 0a09 0909 6966 2028 6563 2e65 6320 3d3d ....if (ec.ec == │ │ │ -00051170: 2062 6f6f 7374 3a3a 7379 7374 656d 3a3a boost::system:: │ │ │ -00051180: 6572 7263 3a3a 6e6f 5f73 7563 685f 6669 errc::no_such_fi │ │ │ -00051190: 6c65 5f6f 725f 6469 7265 6374 6f72 7929 le_or_directory) │ │ │ -000511a0: 0a09 0909 0965 632e 6563 2e63 6c65 6172 .....ec.ec.clear │ │ │ -000511b0: 2829 3b0a 0909 0965 6c73 6520 6966 2028 ();....else if ( │ │ │ -000511c0: 6563 0a09 0909 0926 616d 703b 2661 6d70 ec.....&& │ │ │ -000511d0: 3b20 6563 2e65 6320 213d 2062 6f6f 7374 ; ec.ec != boost │ │ │ -000511e0: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ -000511f0: 696e 7661 6c69 645f 6172 6775 6d65 6e74 invalid_argument │ │ │ -00051200: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ -00051210: 6563 2e65 6320 213d 2062 6f6f 7374 3a3a ec.ec != boost:: │ │ │ -00051220: 7379 7374 656d 3a3a 6572 7263 3a3a 7065 system::errc::pe │ │ │ -00051230: 726d 6973 7369 6f6e 5f64 656e 6965 6429 rmission_denied) │ │ │ -00051240: 0a09 0909 7b0a 0909 0909 2f2f 206d 6f76 ....{.....// mov │ │ │ -00051250: 696e 6720 7468 6520 6669 6c65 2066 6169 ing the file fai │ │ │ -00051260: 6c65 640a 0909 0909 2f2f 206f 6e20 4f53 led.....// on OS │ │ │ -00051270: 582c 2074 6865 2065 7272 6f72 2077 6865 X, the error whe │ │ │ -00051280: 6e20 7472 7969 6e67 2074 6f20 7265 6e61 n trying to rena │ │ │ -00051290: 6d65 2061 2066 696c 6520 6163 726f 7373 me a file across │ │ │ -000512a0: 2064 6966 6665 7265 6e74 0a09 0909 092f different...../ │ │ │ -000512b0: 2f20 766f 6c75 6d65 7320 6973 2045 5844 / volumes is EXD │ │ │ -000512c0: 4556 2c20 7768 6963 6820 7769 6c6c 206d EV, which will m │ │ │ -000512d0: 616b 6520 6974 2066 616c 6c20 6261 636b ake it fall back │ │ │ -000512e0: 2074 6f20 636f 7079 696e 672e 0a09 0909 to copying..... │ │ │ -000512f0: 0965 632e 6563 2e63 6c65 6172 2829 3b0a .ec.ec.clear();. │ │ │ -00051300: 0909 0909 636f 7079 5f66 696c 6528 6f6c ....copy_file(ol │ │ │ -00051310: 645f 7061 7468 2c20 6e65 775f 7061 7468 d_path, new_path │ │ │ -00051320: 2c20 6563 293b 0a09 0909 0969 6620 2821 , ec);.....if (! │ │ │ -00051330: 6563 2920 636f 7069 6564 5f66 696c 6573 ec) copied_files │ │ │ -00051340: 5b69 5d20 3d20 7472 7565 3b0a 0909 097d [i] = true;....} │ │ │ -00051350: 0a0a 0909 0969 6620 2865 6329 0a09 0909 .....if (ec).... │ │ │ -00051360: 7b0a 0909 0909 6563 2e66 696c 6528 6929 {.....ec.file(i) │ │ │ -00051370: 3b0a 0909 0909 6669 6c65 5f69 6e64 6578 ;.....file_index │ │ │ -00051380: 203d 2069 3b0a 0909 0909 6272 6561 6b3b = i;.....break; │ │ │ -00051390: 0a09 0909 7d0a 0909 7d0a 0a09 0969 6620 ....}...}....if │ │ │ -000513a0: 2821 6563 2026 616d 703b 2661 6d70 3b20 (!ec && │ │ │ -000513b0: 6d6f 7665 5f70 6172 7466 696c 6529 0a09 move_partfile).. │ │ │ -000513c0: 097b 0a09 0909 6572 726f 725f 636f 6465 .{....error_code │ │ │ -000513d0: 2065 3b0a 0909 096d 6f76 655f 7061 7274 e;....move_part │ │ │ -000513e0: 6669 6c65 286e 6577 5f73 6176 655f 7061 file(new_save_pa │ │ │ -000513f0: 7468 2c20 6529 3b0a 0909 0969 6620 2865 th, e);....if (e │ │ │ -00051400: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ -00051430: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00051440: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00051470: 7372 632f 7374 6f72 6167 655f 7574 696c src/storage_util │ │ │ -00051480: 732e 6370 703a 3433 313c 2f61 3e3c 2f74 s.cpp:431it would s │ │ │ -000514a0: 6565 6d20 7265 6173 6f6e 6162 6c65 2074 eem reasonable t │ │ │ -000514b0: 6f2c 2069 6e73 7465 6164 2c20 7365 7420 o, instead, set │ │ │ -000514c0: 7468 6520 6861 7665 5f70 6965 6365 7320 the have_pieces │ │ │ -000514d0: 6269 7473 2066 6f72 2074 6865 2070 6965 bits for the pie │ │ │ -000514e0: 6365 7320 7265 7072 6573 656e 7469 6e67 ces representing │ │ │ -000514f0: 2074 6865 7365 2066 696c 6573 2c20 616e these files, an │ │ │ -00051500: 6420 7265 7375 6d65 2077 6974 6820 7468 d resume with th │ │ │ -00051510: 6520 6e6f 726d 616c 206c 6f67 6963 3c2f e normal logic

    it w │ │ │ -00051570: 6f75 6c64 2073 6565 6d20 7265 6173 6f6e ould seem reason │ │ │ -00051580: 6162 6c65 2074 6f2c 2069 6e73 7465 6164 able to, instead │ │ │ -00051590: 2c20 7365 7420 7468 6520 6861 7665 5f70 , set the have_p │ │ │ -000515a0: 6965 6365 7320 6269 7473 0a66 6f72 2074 ieces bits.for t │ │ │ -000515b0: 6865 2070 6965 6365 7320 7265 7072 6573 he pieces repres │ │ │ -000515c0: 656e 7469 6e67 2074 6865 7365 2066 696c enting these fil │ │ │ -000515d0: 6573 2c20 616e 6420 7265 7375 6d65 2077 es, and resume w │ │ │ -000515e0: 6974 6820 7468 6520 6e6f 726d 616c 0a6c ith the normal.l │ │ │ -000515f0: 6f67 6963 3c2f 6832 3e3c 6834 3e2e 2e2f ogic

    ../ │ │ │ -00051600: 7372 632f 7374 6f72 6167 655f 7574 696c src/storage_util │ │ │ -00051610: 732e 6370 703a 3433 313c 2f68 343e 3c70 s.cpp:431

    .....con │ │ │ -00051660: 7469 6e75 653b 0a0a 0909 0909 7374 643a tinue;......std: │ │ │ -00051670: 3a69 6e74 3634 5f74 2063 6f6e 7374 2073 :int64_t const s │ │ │ -00051680: 697a 6520 3d20 6765 745f 6669 6c65 7369 ize = get_filesi │ │ │ -00051690: 7a65 2873 7461 742c 2066 696c 655f 696e ze(stat, file_in │ │ │ -000516a0: 6465 782c 2066 730a 0909 0909 092c 2073 dex, fs......, s │ │ │ -000516b0: 6176 655f 7061 7468 2c20 6563 293b 0a09 ave_path, ec);.. │ │ │ -000516c0: 0909 0969 6620 2873 697a 6520 266c 743b ...if (size < │ │ │ -000516d0: 2030 2920 7265 7475 726e 2066 616c 7365 0) return false │ │ │ -000516e0: 3b0a 0a09 0909 0969 6620 2873 697a 6520 ;......if (size │ │ │ -000516f0: 266c 743b 2066 732e 6669 6c65 5f73 697a < fs.file_siz │ │ │ -00051700: 6528 6669 6c65 5f69 6e64 6578 2929 0a09 e(file_index)).. │ │ │ -00051710: 0909 097b 0a09 0909 0909 6563 2e65 6320 ...{......ec.ec │ │ │ -00051720: 3d20 6572 726f 7273 3a3a 6d69 736d 6174 = errors::mismat │ │ │ -00051730: 6368 696e 675f 6669 6c65 5f73 697a 653b ching_file_size; │ │ │ -00051740: 0a09 0909 0909 6563 2e66 696c 6528 6669 ......ec.file(fi │ │ │ -00051750: 6c65 5f69 6e64 6578 293b 0a09 0909 0909 le_index);...... │ │ │ -00051760: 6563 2e6f 7065 7261 7469 6f6e 203d 206f ec.operation = o │ │ │ -00051770: 7065 7261 7469 6f6e 5f74 3a3a 6368 6563 peration_t::chec │ │ │ -00051780: 6b5f 7265 7375 6d65 3b0a 0909 0909 0972 k_resume;......r │ │ │ -00051790: 6574 7572 6e20 6661 6c73 653b 0a09 0909 eturn false;.... │ │ │ -000517a0: 097d 0a09 0909 7d0a 0909 0972 6574 7572 .}....}....retur │ │ │ -000517b0: 6e20 7472 7565 3b0a 0909 7d0a 0a23 6966 n true;...}..#if │ │ │ -000517c0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -000517d0: 4142 4c45 5f4d 5554 4142 4c45 5f54 4f52 ABLE_MUTABLE_TOR │ │ │ -000517e0: 5245 4e54 530a 0909 2f2f 2061 6c77 6179 RENTS...// alway │ │ │ -000517f0: 7320 7472 6967 6765 7220 6120 6675 6c6c s trigger a full │ │ │ -00051800: 2072 6563 6865 636b 2077 6865 6e20 7765 recheck when we │ │ │ -00051810: 2070 756c 6c20 696e 2066 696c 6573 2066 pull in files f │ │ │ -00051820: 726f 6d20 6f74 6865 720a 0909 2f2f 2074 rom other...// t │ │ │ -00051830: 6f72 7265 6e74 732c 2076 6961 2068 6172 orrents, via har │ │ │ -00051840: 6420 6c69 6e6b 730a 3c64 6976 2073 7479 d links.

    ..if (adde │ │ │ -00051880: 645f 6669 6c65 7329 2072 6574 7572 6e20 d_files) return │ │ │ -00051890: 6661 6c73 653b 0a3c 2f64 6976 3e23 656e false;.
    #en │ │ │ -000518a0: 6469 660a 0a09 092f 2f20 7061 7273 6520 dif....// parse │ │ │ -000518b0: 6861 7665 2062 6974 6d61 736b 2e20 5665 have bitmask. Ve │ │ │ -000518c0: 7269 6679 2074 6861 7420 6669 6c65 7320 rify that files │ │ │ -000518d0: 746f 7563 6865 6420 6279 2063 6f6d 706c touched by compl │ │ │ -000518e0: 6574 6564 2070 6965 6365 730a 0909 2f2f eted pieces...// │ │ │ -000518f0: 2061 6374 7561 6c6c 7920 6578 6973 742e actually exist. │ │ │ -00051900: 2041 2063 6f6d 706c 6574 6564 2070 6965 A completed pie │ │ │ -00051910: 6365 206d 6179 2073 7061 6e20 6d75 6c74 ce may span mult │ │ │ -00051920: 6970 6c65 2066 696c 6573 2e0a 0909 666f iple files....fo │ │ │ -00051930: 7220 2866 696c 655f 696e 6465 785f 7420 r (file_index_t │ │ │ -00051940: 636f 6e73 7420 6669 6c65 5f69 6e64 6578 const file_index │ │ │ -00051950: 203a 2066 732e 6669 6c65 5f72 616e 6765 : fs.file_range │ │ │ -00051960: 2829 290a 0909 7b0a 0909 092f 2f20 6669 ())...{....// fi │ │ │ -00051970: 6c65 7320 7769 7468 2070 7269 6f72 6974 les with priorit │ │ │ -00051980: 7920 7a65 726f 206d 6179 206e 6f74 2068 y zero may not h │ │ │ -00051990: 6176 6520 6265 656e 2073 6176 6564 2074 ave been saved t │ │ │ -000519a0: 6f20 6469 736b 2061 7420 7468 6569 720a o disk at their. │ │ │ -000519b0: 0909 092f 2f20 6578 7065 6374 6564 206c ...// expected l │ │ │ -000519c0: 6f63 6174 696f 6e2c 2062 7574 2069 7320 ocation, but is │ │ │ -000519d0: 6c69 6b65 6c79 2074 6f20 6265 2069 6e20 likely to be in │ │ │ -000519e0: 6120 7061 7274 6669 6c65 2e20 4a75 7374 a partfile. Just │ │ │ -000519f0: 2065 7865 6d70 7420 6974 0a09 0909 2f2f exempt it....// │ │ │ -00051a00: 2066 726f 6d20 6368 6563 6b69 6e67 0a09 from checking.. │ │ │ -00051a10: 0909 6966 2028 6669 6c65 5f69 6e64 6578 ..if (file_index │ │ │ -00051a20: 2026 6c74 3b20 6669 6c65 5f70 7269 6f72 < file_prior │ │ │ -00051a30: 6974 792e 656e 645f 696e 6465 7828 290a ity.end_index(). │ │ │ -00051a40: 0909 0909 2661 6d70 3b26 616d 703b 2066 ....&& f │ │ │ -00051a50: 696c 655f 7072 696f 7269 7479 5b66 696c ile_priority[fil │ │ │ -00051a60: 655f 696e 6465 785d 203d 3d20 646f 6e74 e_index] == dont │ │ │ -00051a70: 5f64 6f77 6e6c 6f61 6429 0a09 0909 0963 _download).....c │ │ │ -00051a80: 6f6e 7469 6e75 653b 0a0a 0909 0969 6620 ontinue;.....if │ │ │ -00051a90: 2866 732e 7061 645f 6669 6c65 5f61 7428 (fs.pad_file_at( │ │ │ -00051aa0: 6669 6c65 5f69 6e64 6578 2929 2063 6f6e file_index)) con │ │ │ -00051ab0: 7469 6e75 653b 0a09 0909 6966 2028 6673 tinue;....if (fs │ │ │ -00051ac0: 2e66 696c 655f 7369 7a65 2866 696c 655f .file_size(file_ │ │ │ -00051ad0: 696e 6465 7829 203d 3d20 3029 2063 6f6e index) == 0) con │ │ │ -00051ae0: 7469 6e75 653b 0a0a 0909 0961 7574 6f20 tinue;.....auto │ │ │ -00051af0: 636f 6e73 7420 7069 6563 655f 7261 6e67 const piece_rang │ │ │ -00051b00: 6520 3d20 6175 783a 3a66 696c 655f 7069 e = aux::file_pi │ │ │ -00051b10: 6563 655f 7261 6e67 655f 696e 636c 7573 ece_range_inclus │ │ │ -00051b20: 6976 6528 6673 2c20 6669 6c65 5f69 6e64 ive(fs, file_ind │ │ │ -00051b30: 6578 293b 0a09 0909 7069 6563 655f 696e ex);....piece_in │ │ │ -00051b40: 6465 785f 7420 636f 6e73 7420 7374 6172 dex_t const star │ │ │ -00051b50: 745f 7069 6563 6520 3d20 7069 6563 655f t_piece = piece_ │ │ │ -00051b60: 7261 6e67 652e 5f62 6567 696e 3b0a 0a09 range._begin;... │ │ │ -00051b70: 0909 7069 6563 655f 696e 6465 785f 7420 ..piece_index_t │ │ │ -00051b80: 636f 6e73 7420 656e 645f 7069 6563 6520 const end_piece │ │ │ -00051b90: 3d20 7374 643a 3a6d 696e 2870 6965 6365 = std::min(piece │ │ │ -00051ba0: 5f72 616e 6765 2e5f 656e 642c 2072 642e _range._end, rd. │ │ │ -00051bb0: 6861 7665 5f70 6965 6365 732e 656e 645f have_pieces.end_ │ │ │ -00051bc0: 696e 6465 7828 2929 3b0a 0a09 0909 626f index());.....bo │ │ │ -00051bd0: 6f6c 2068 6173 5f63 6f6d 706c 6574 6564 ol has_completed │ │ │ -00051be0: 5f72 6573 756d 655f 7069 6563 6520 3d20 _resume_piece = │ │ │ -00051bf0: 6661 6c73 653b 0a09 0909 666f 7220 2870 false;....for (p │ │ │ -00051c00: 6965 6365 5f69 6e64 6578 5f74 2070 6965 iece_index_t pie │ │ │ -00051c10: 6365 203d 2073 7461 7274 5f70 6965 6365 ce = start_piece │ │ │ -00051c20: 3b20 7069 6563 6520 266c 743b 2065 6e64 ; piece < end │ │ │ -00051c30: 5f70 6965 6365 3b20 2b2b 7069 6563 6529 _piece; ++piece) │ │ │ -00051c40: 0a09 0909 7b0a 0909 0909 6966 2028 2172 ....{.....if (!r │ │ │ -00051c50: 642e 6861 7665 5f70 6965 6365 732e 6765 d.have_pieces.ge │ │ │ -00051c60: 745f 6269 7428 7069 6563 6529 2920 636f t_bit(piece)) co │ │ │ -00051c70: 6e74 696e 7565 3b0a 0909 0909 6861 735f ntinue;.....has_ │ │ │ -00051c80: 636f 6d70 6c65 7465 645f 7265 7375 6d65 completed_resume │ │ │ -00051c90: 5f70 6965 6365 203d 2074 7275 653b 0a09 _piece = true;.. │ │ │ -00051ca0: 0909 0962 7265 616b 3b0a 0909 097d 0a0a ...break;....}.. │ │ │ -00051cb0: 0909 0969 6620 2821 6861 735f 636f 6d70 ...if (!has_comp │ │ │ -00051cc0: 6c65 7465 645f 7265 7375 6d65 5f70 6965 leted_resume_pie │ │ │ -00051cd0: 6365 2920 636f 6e74 696e 7565 3b0a 3c2f ce) continue;.r │ │ │ -00051d10: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00051d20: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00051d50: 6469 7361 626c 6564 5f64 6973 6b5f 696f disabled_disk_io │ │ │ -00051d60: 2e63 7070 3a38 333c 2f61 3e3c 2f74 643e .cpp:83 │ │ │ -00051d70: 3c74 643e 6974 2077 6f75 6c64 2062 6520 it would be │ │ │ -00051d80: 6e69 6365 2074 6f20 7265 7475 726e 2061 nice to return a │ │ │ -00051d90: 2076 616c 6964 2068 6173 6820 6f66 207a valid hash of z │ │ │ -00051da0: 6572 6f65 7320 6865 7265 3c2f 7464 3e3c eroes here< │ │ │ -00051db0: 2f74 723e 3c74 7220 6964 3d22 3139 3522 /tr>

    it would │ │ │ -00051e00: 2062 6520 6e69 6365 2074 6f20 7265 7475 be nice to retu │ │ │ -00051e10: 726e 2061 2076 616c 6964 2068 6173 6820 rn a valid hash │ │ │ -00051e20: 6f66 207a 6572 6f65 7320 6865 7265 3c2f of zeroes here

    ../src/di │ │ │ -00051e40: 7361 626c 6564 5f64 6973 6b5f 696f 2e63 sabled_disk_io.c │ │ │ -00051e50: 7070 3a38 333c 2f68 343e 3c70 7265 2073 pp:83

    ..});..}...b
    │ │ │ -00051ea0: 6f6f 6c20 6173 796e 635f 7772 6974 6528  ool async_write(
    │ │ │ -00051eb0: 7374 6f72 6167 655f 696e 6465 785f 740a  storage_index_t.
    │ │ │ -00051ec0: 0909 2c20 7065 6572 5f72 6571 7565 7374  .., peer_request
    │ │ │ -00051ed0: 2063 6f6e 7374 2661 6d70 3b20 720a 0909   const& r...
    │ │ │ -00051ee0: 2c20 6368 6172 2063 6f6e 7374 2a2c 2073  , char const*, s
    │ │ │ -00051ef0: 7464 3a3a 7368 6172 6564 5f70 7472 266c  td::shared_ptr&l
    │ │ │ -00051f00: 743b 6469 736b 5f6f 6273 6572 7665 7226  t;disk_observer&
    │ │ │ -00051f10: 6774 3b0a 0909 2c20 7374 643a 3a66 756e  gt;..., std::fun
    │ │ │ -00051f20: 6374 696f 6e26 6c74 3b76 6f69 6428 7374  ction<void(st
    │ │ │ -00051f30: 6f72 6167 655f 6572 726f 7220 636f 6e73  orage_error cons
    │ │ │ -00051f40: 7426 616d 703b 2926 6774 3b20 6861 6e64  t&)> hand
    │ │ │ -00051f50: 6c65 720a 0909 2c20 6469 736b 5f6a 6f62  ler..., disk_job
    │ │ │ -00051f60: 5f66 6c61 6773 5f74 2920 6f76 6572 7269  _flags_t) overri
    │ │ │ -00051f70: 6465 0a09 7b0a 0909 544f 5252 454e 545f  de..{...TORRENT_
    │ │ │ -00051f80: 4153 5345 5254 2872 2e6c 656e 6774 6820  ASSERT(r.length 
    │ │ │ -00051f90: 266c 743b 3d20 6465 6661 756c 745f 626c  <= default_bl
    │ │ │ -00051fa0: 6f63 6b5f 7369 7a65 293b 0a09 0954 4f52  ock_size);...TOR
    │ │ │ -00051fb0: 5245 4e54 5f55 4e55 5345 4428 7229 3b0a  RENT_UNUSED(r);.
    │ │ │ -00051fc0: 0a09 0970 6f73 7428 6d5f 696f 732c 205b  ...post(m_ios, [
    │ │ │ -00051fd0: 6820 3d20 7374 643a 3a6d 6f76 6528 6861  h = std::move(ha
    │ │ │ -00051fe0: 6e64 6c65 7229 5d20 7b20 6828 7374 6f72  ndler)] { h(stor
    │ │ │ -00051ff0: 6167 655f 6572 726f 727b 7d29 3b20 7d29  age_error{}); })
    │ │ │ -00052000: 3b0a 0909 7265 7475 726e 2066 616c 7365  ;...return false
    │ │ │ -00052010: 3b0a 097d 0a0a 0976 6f69 6420 6173 796e  ;..}...void asyn
    │ │ │ -00052020: 635f 6861 7368 2873 746f 7261 6765 5f69  c_hash(storage_i
    │ │ │ -00052030: 6e64 6578 5f74 0a09 092c 2070 6965 6365  ndex_t..., piece
    │ │ │ -00052040: 5f69 6e64 6578 5f74 2070 6965 6365 2c20  _index_t piece, 
    │ │ │ -00052050: 7370 616e 266c 743b 7368 6132 3536 5f68  span<sha256_h
    │ │ │ -00052060: 6173 6826 6774 3b2c 2064 6973 6b5f 6a6f  ash>, disk_jo
    │ │ │ -00052070: 625f 666c 6167 735f 740a 0909 2c20 7374  b_flags_t..., st
    │ │ │ -00052080: 643a 3a66 756e 6374 696f 6e26 6c74 3b76  d::function<v
    │ │ │ -00052090: 6f69 6428 7069 6563 655f 696e 6465 785f  oid(piece_index_
    │ │ │ -000520a0: 742c 2073 6861 315f 6861 7368 2063 6f6e  t, sha1_hash con
    │ │ │ -000520b0: 7374 2661 6d70 3b2c 2073 746f 7261 6765  st&, storage
    │ │ │ -000520c0: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70  _error const&
    │ │ │ -000520d0: 3b29 2667 743b 2068 616e 646c 6572 2920  ;)> handler) 
    │ │ │ -000520e0: 6f76 6572 7269 6465 0a09 7b0a 3c64 6976  override..{.
    ..post │ │ │ -00052120: 286d 5f69 6f73 2c20 5b68 203d 2073 7464 (m_ios, [h = std │ │ │ -00052130: 3a3a 6d6f 7665 2868 616e 646c 6572 292c ::move(handler), │ │ │ -00052140: 2070 6965 6365 5d20 7b20 6828 7069 6563 piece] { h(piec │ │ │ -00052150: 652c 2073 6861 315f 6861 7368 7b7d 2c20 e, sha1_hash{}, │ │ │ -00052160: 7374 6f72 6167 655f 6572 726f 727b 7d29 storage_error{}) │ │ │ -00052170: 3b20 7d29 3b0a 3c2f 6469 763e 097d 0a0a ; });.
    .}.. │ │ │ -00052180: 0976 6f69 6420 6173 796e 635f 6861 7368 .void async_hash │ │ │ -00052190: 3228 7374 6f72 6167 655f 696e 6465 785f 2(storage_index_ │ │ │ -000521a0: 742c 2070 6965 6365 5f69 6e64 6578 5f74 t, piece_index_t │ │ │ -000521b0: 2070 6965 6365 2c20 696e 740a 0909 2c20 piece, int..., │ │ │ -000521c0: 6469 736b 5f6a 6f62 5f66 6c61 6773 5f74 disk_job_flags_t │ │ │ -000521d0: 0a09 092c 2073 7464 3a3a 6675 6e63 7469 ..., std::functi │ │ │ -000521e0: 6f6e 266c 743b 766f 6964 2870 6965 6365 on<void(piece │ │ │ -000521f0: 5f69 6e64 6578 5f74 2c20 7368 6132 3536 _index_t, sha256 │ │ │ -00052200: 5f68 6173 6820 636f 6e73 7426 616d 703b _hash const& │ │ │ -00052210: 2c20 7374 6f72 6167 655f 6572 726f 7220 , storage_error │ │ │ -00052220: 636f 6e73 7426 616d 703b 2926 6774 3b20 const&)> │ │ │ -00052230: 6861 6e64 6c65 7229 206f 7665 7272 6964 handler) overrid │ │ │ -00052240: 650a 097b 0a09 0970 6f73 7428 6d5f 696f e..{...post(m_io │ │ │ -00052250: 732c 205b 6820 3d20 7374 643a 3a6d 6f76 s, [h = std::mov │ │ │ -00052260: 6528 6861 6e64 6c65 7229 2c20 7069 6563 e(handler), piec │ │ │ -00052270: 655d 2829 207b 2068 2870 6965 6365 2c20 e]() { h(piece, │ │ │ -00052280: 7368 6132 3536 5f68 6173 687b 7d2c 2073 sha256_hash{}, s │ │ │ -00052290: 746f 7261 6765 5f65 7272 6f72 7b7d 293b torage_error{}); │ │ │ -000522a0: 207d 293b 0a09 7d0a 0a09 766f 6964 2061 });..}...void a │ │ │ -000522b0: 7379 6e63 5f6d 6f76 655f 7374 6f72 6167 sync_move_storag │ │ │ -000522c0: 6528 7374 6f72 6167 655f 696e 6465 785f e(storage_index_ │ │ │ -000522d0: 740a 0909 2c20 7374 643a 3a73 7472 696e t..., std::strin │ │ │ -000522e0: 6720 702c 206d 6f76 655f 666c 6167 735f g p, move_flags_ │ │ │ -000522f0: 740a 0909 2c20 7374 643a 3a66 756e 6374 t..., std::funct │ │ │ -00052300: 696f 6e26 6c74 3b76 6f69 6428 7374 6174 ion<void(stat │ │ │ -00052310: 7573 5f74 2c20 7374 643a 3a73 7472 696e us_t, std::strin │ │ │ -00052320: 6720 636f 6e73 7426 616d 703b 2c20 7374 g const&, st │ │ │ -00052330: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ -00052340: 7426 616d 703b 2926 6774 3b20 6861 6e64 t&)> hand │ │ │ -00052350: 6c65 7229 206f 7665 7272 6964 650a 097b ler) override..{ │ │ │ -00052360: 0a09 0970 6f73 7428 6d5f 696f 732c 205b ...post(m_ios, [ │ │ │ -00052370: 6820 3d20 7374 643a 3a6d 6f76 6528 6861 h = std::move(ha │ │ │ -00052380: 6e64 6c65 7229 2c20 7061 7468 203d 2073 ndler), path = s │ │ │ -00052390: 7464 3a3a 6d6f 7665 2870 295d 2028 2920 td::move(p)] () │ │ │ -000523a0: 6d75 7461 626c 650a 0909 097b 2068 2873 mutable....{ h(s │ │ │ -000523b0: 7461 7475 735f 747b 7d2c 2073 7464 3a3a tatus_t{}, std:: │ │ │ -000523c0: 6d6f 7665 2870 6174 6829 2c20 7374 6f72 move(path), stor │ │ │ -000523d0: 6167 655f 6572 726f 727b 7d29 3b20 7d29 age_error{}); }) │ │ │ -000523e0: 3b0a 097d 0a0a 0976 6f69 6420 6173 796e ;..}...void asyn │ │ │ -000523f0: 635f 7265 6c65 6173 655f 6669 6c65 7328 c_release_files( │ │ │ -00052400: 7374 6f72 6167 655f 696e 6465 785f 742c storage_index_t, │ │ │ -00052410: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c std::function&l │ │ │ -00052420: 743b 766f 6964 2829 2667 743b 2068 616e t;void()> han │ │ │ -00052430: 646c 6572 2920 6f76 6572 7269 6465 0a09 dler) override.. │ │ │ -00052440: 7b0a 0909 706f 7374 286d 5f69 6f73 2c20 {...post(m_ios, │ │ │ -00052450: 5b68 203d 2073 7464 3a3a 6d6f 7665 2868 [h = std::move(h │ │ │ -00052460: 616e 646c 6572 295d 207b 2068 2829 3b20 andler)] { h(); │ │ │ -00052470: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ -00052480: 796e 635f 6465 6c65 7465 5f66 696c 6573 ync_delete_files │ │ │ -00052490: 2873 746f 7261 6765 5f69 6e64 6578 5f74 (storage_index_t │ │ │ -000524a0: 0a09 092c 2072 656d 6f76 655f 666c 6167 ..., remove_flag │ │ │ -000524b0: 735f 742c 2073 7464 3a3a 6675 6e63 7469 s_t, std::functi │ │ │ -000524c0: 6f6e 266c 743b 766f 6964 2873 746f 7261 on<void(stora │ │ │ -000524d0: 6765 5f65 7272 6f72 2063 6f6e 7374 2661 ge_error const&a │ │ │ -000524e0: 6d70 3b29 2667 743b 2068 616e 646c 6572 mp;)> handler │ │ │ -000524f0: 2920 6f76 6572 7269 6465 0a09 7b0a 0909 ) override..{... │ │ │ -00052500: 706f 7374 286d 5f69 6f73 2c20 5b68 203d post(m_ios, [h = │ │ │ -00052510: 2073 7464 3a3a 6d6f 7665 2868 616e 646c std::move(handl │ │ │ -00052520: 6572 295d 207b 2068 2873 746f 7261 6765 er)] { h(storage │ │ │ -00052530: 5f65 7272 6f72 7b7d 293b 207d 293b 0a09 _error{}); });.. │ │ │ -00052540: 7d0a 0a09 766f 6964 2061 7379 6e63 5f63 }...void async_c │ │ │ -00052550: 6865 636b 5f66 696c 6573 2873 746f 7261 heck_files(stora │ │ │ -00052560: 6765 5f69 6e64 6578 5f74 0a09 092c 2061 ge_index_t..., a │ │ │ -00052570: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -00052580: 7320 636f 6e73 742a 0a3c 2f70 7265 3e3c s const*.
    < │ │ │ -00052590: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000525c0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000525d0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/utp_s │ │ │ -00052600: 6f63 6b65 745f 6d61 6e61 6765 722e 6370 ocket_manager.cp │ │ │ -00052610: 703a 3138 303c 2f61 3e3c 2f74 643e 3c74 p:180this should no │ │ │ -00052630: 7420 6265 2068 6561 7020 616c 6c6f 6361 t be heap alloca │ │ │ -00052640: 7465 642c 2073 6f63 6b65 7473 2073 686f ted, sockets sho │ │ │ -00052650: 756c 6420 6265 206d 6f76 6162 6c65 3c2f uld be movable

    this │ │ │ -000526b0: 2073 686f 756c 6420 6e6f 7420 6265 2068 should not be h │ │ │ -000526c0: 6561 7020 616c 6c6f 6361 7465 642c 2073 eap allocated, s │ │ │ -000526d0: 6f63 6b65 7473 2073 686f 756c 6420 6265 ockets should be │ │ │ -000526e0: 206d 6f76 6162 6c65 3c2f 6832 3e3c 6834 movable

    ../src/utp_sock │ │ │ -00052700: 6574 5f6d 616e 6167 6572 2e63 7070 3a31 et_manager.cpp:1 │ │ │ -00052710: 3830 3c2f 6834 3e3c 7072 6520 7374 796c 80

    .//..UTP_LOGV("
    │ │ │ -00052760: 696e 636f 6d69 6e67 2070 6163 6b65 7420  incoming packet 
    │ │ │ -00052770: 6964 3a25 6420 736f 7572 6365 3a25 735c  id:%d source:%s\
    │ │ │ -00052780: 6e22 2c20 6964 2c20 7072 696e 745f 656e  n", id, print_en
    │ │ │ -00052790: 6470 6f69 6e74 2865 7029 2e63 5f73 7472  dpoint(ep).c_str
    │ │ │ -000527a0: 2829 293b 0a0a 0909 6966 2028 216d 5f73  ());....if (!m_s
    │ │ │ -000527b0: 6574 742e 6765 745f 626f 6f6c 2873 6574  ett.get_bool(set
    │ │ │ -000527c0: 7469 6e67 735f 7061 636b 3a3a 656e 6162  tings_pack::enab
    │ │ │ -000527d0: 6c65 5f69 6e63 6f6d 696e 675f 7574 7029  le_incoming_utp)
    │ │ │ -000527e0: 290a 0909 0972 6574 7572 6e20 6661 6c73  )....return fals
    │ │ │ -000527f0: 653b 0a0a 0909 2f2f 2069 6620 6e6f 7420  e;....// if not 
    │ │ │ -00052800: 666f 756e 642c 2073 6565 2069 6620 6974  found, see if it
    │ │ │ -00052810: 2773 2061 2053 594e 2070 6163 6b65 742c  's a SYN packet,
    │ │ │ -00052820: 2069 6620 6974 2069 732c 0a09 092f 2f20   if it is,...// 
    │ │ │ -00052830: 6372 6561 7465 2061 206e 6577 2075 7470  create a new utp
    │ │ │ -00052840: 5f73 7472 6561 6d0a 0909 6966 2028 7068  _stream...if (ph
    │ │ │ -00052850: 2d26 6774 3b67 6574 5f74 7970 6528 2920  ->get_type() 
    │ │ │ -00052860: 3d3d 2053 545f 5359 4e29 0a09 097b 0a09  == ST_SYN)...{..
    │ │ │ -00052870: 0909 2f2f 2070 6f73 7369 626c 6520 5359  ..// possible SY
    │ │ │ -00052880: 4e20 666c 6f6f 642e 204a 7573 7420 6967  N flood. Just ig
    │ │ │ -00052890: 6e6f 7265 0a09 0909 6966 2028 696e 7428  nore....if (int(
    │ │ │ -000528a0: 6d5f 7574 705f 736f 636b 6574 732e 7369  m_utp_sockets.si
    │ │ │ -000528b0: 7a65 2829 2920 2667 743b 206d 5f73 6574  ze()) > m_set
    │ │ │ -000528c0: 742e 6765 745f 696e 7428 7365 7474 696e  t.get_int(settin
    │ │ │ -000528d0: 6773 5f70 6163 6b3a 3a63 6f6e 6e65 6374  gs_pack::connect
    │ │ │ -000528e0: 696f 6e73 5f6c 696d 6974 2920 2a20 3229  ions_limit) * 2)
    │ │ │ -000528f0: 0a09 0909 0972 6574 7572 6e20 6661 6c73  .....return fals
    │ │ │ -00052900: 653b 0a0a 0909 0954 4f52 5245 4e54 5f41  e;.....TORRENT_A
    │ │ │ -00052910: 5353 4552 5428 6d5f 6e65 775f 636f 6e6e  SSERT(m_new_conn
    │ │ │ -00052920: 6563 7469 6f6e 203d 3d20 2d31 293b 0a09  ection == -1);..
    │ │ │ -00052930: 0909 2f2f 2063 7265 6174 6520 7468 6520  ..// create the 
    │ │ │ -00052940: 6e65 7720 736f 636b 6574 2077 6974 6820  new socket with 
    │ │ │ -00052950: 7468 6973 2049 440a 0909 096d 5f6e 6577  this ID....m_new
    │ │ │ -00052960: 5f63 6f6e 6e65 6374 696f 6e20 3d20 6964  _connection = id
    │ │ │ -00052970: 3b0a 0a2f 2f09 0909 5554 505f 4c4f 4756  ;..//...UTP_LOGV
    │ │ │ -00052980: 2822 6e6f 7420 666f 756e 642c 206e 6577  ("not found, new
    │ │ │ -00052990: 2063 6f6e 6e65 6374 696f 6e20 6964 3a25   connection id:%
    │ │ │ -000529a0: 645c 6e22 2c20 6d5f 6e65 775f 636f 6e6e  d\n", m_new_conn
    │ │ │ -000529b0: 6563 7469 6f6e 293b 0a0a 3c64 6976 2073  ection);..
    ...aux:: │ │ │ -000529f0: 736f 636b 6574 5f74 7970 6520 6328 6175 socket_type c(au │ │ │ -00052a00: 783a 3a69 6e73 7461 6e74 6961 7465 5f63 x::instantiate_c │ │ │ -00052a10: 6f6e 6e65 6374 696f 6e28 6d5f 696f 732c onnection(m_ios, │ │ │ -00052a20: 2061 7578 3a3a 7072 6f78 795f 7365 7474 aux::proxy_sett │ │ │ -00052a30: 696e 6773 2829 2c20 6d5f 7373 6c5f 636f ings(), m_ssl_co │ │ │ -00052a40: 6e74 6578 742c 2074 6869 732c 2074 7275 ntext, this, tru │ │ │ -00052a50: 652c 2066 616c 7365 2929 3b0a 3c2f 6469 e, false));.....utp_stream │ │ │ -00052a70: 2a20 7374 7220 3d20 6e75 6c6c 7074 723b * str = nullptr; │ │ │ -00052a80: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ -00052a90: 5353 4c5f 5045 4552 530a 0909 0969 6620 SSL_PEERS....if │ │ │ -00052aa0: 2869 735f 7373 6c28 6329 290a 0909 0909 (is_ssl(c))..... │ │ │ -00052ab0: 7374 7220 3d20 2661 6d70 3b73 7464 3a3a str = &std:: │ │ │ -00052ac0: 6765 7426 6c74 3b73 736c 5f73 7472 6561 get<ssl_strea │ │ │ -00052ad0: 6d26 6c74 3b75 7470 5f73 7472 6561 6d26 m<utp_stream& │ │ │ -00052ae0: 6774 3b26 6774 3b28 6329 2e6e 6578 745f gt;>(c).next_ │ │ │ -00052af0: 6c61 7965 7228 293b 0a09 0909 656c 7365 layer();....else │ │ │ -00052b00: 0a23 656e 6469 660a 0909 0909 7374 7220 .#endif.....str │ │ │ -00052b10: 3d20 7374 643a 3a67 6574 5f69 6626 6c74 = std::get_if< │ │ │ -00052b20: 3b75 7470 5f73 7472 6561 6d26 6774 3b28 ;utp_stream>( │ │ │ -00052b30: 2661 6d70 3b63 293b 0a0a 0909 0954 4f52 &c);.....TOR │ │ │ -00052b40: 5245 4e54 5f41 5353 4552 5428 7374 7229 RENT_ASSERT(str) │ │ │ -00052b50: 3b0a 0909 0969 6e74 2063 6f6e 7374 206d ;....int const m │ │ │ -00052b60: 7475 203d 206d 7475 5f66 6f72 5f64 6573 tu = mtu_for_des │ │ │ -00052b70: 7428 6570 2e61 6464 7265 7373 2829 293b t(ep.address()); │ │ │ -00052b80: 0a09 0909 7374 722d 2667 743b 6765 745f ....str->get_ │ │ │ -00052b90: 696d 706c 2829 2d26 6774 3b69 6e69 745f impl()->init_ │ │ │ -00052ba0: 6d74 7528 6d74 7529 3b0a 0909 0973 7472 mtu(mtu);....str │ │ │ -00052bb0: 2d26 6774 3b67 6574 5f69 6d70 6c28 292d ->get_impl()- │ │ │ -00052bc0: 2667 743b 6d5f 736f 636b 203d 2073 7464 >m_sock = std │ │ │ -00052bd0: 3a3a 6d6f 7665 2873 6f63 6b65 7429 3b0a ::move(socket);. │ │ │ -00052be0: 0909 0962 6f6f 6c20 636f 6e73 7420 7265 ...bool const re │ │ │ -00052bf0: 7420 3d20 7374 722d 2667 743b 6765 745f t = str->get_ │ │ │ -00052c00: 696d 706c 2829 2d26 6774 3b69 6e63 6f6d impl()->incom │ │ │ -00052c10: 696e 675f 7061 636b 6574 2870 2c20 6570 ing_packet(p, ep │ │ │ -00052c20: 2c20 7265 6365 6976 655f 7469 6d65 293b , receive_time); │ │ │ -00052c30: 0a09 0909 6966 2028 2172 6574 2920 7265 ....if (!ret) re │ │ │ -00052c40: 7475 726e 2066 616c 7365 3b0a 0909 096d turn false;....m │ │ │ -00052c50: 5f6c 6173 745f 736f 636b 6574 203d 2073 _last_socket = s │ │ │ -00052c60: 7472 2d26 6774 3b67 6574 5f69 6d70 6c28 tr->get_impl( │ │ │ -00052c70: 293b 0a09 0909 6d5f 6362 2873 7464 3a3a );....m_cb(std:: │ │ │ -00052c80: 6d6f 7665 2863 2929 3b0a 0909 092f 2f20 move(c));....// │ │ │ -00052c90: 7468 6520 636f 6e6e 6563 7469 6f6e 206d the connection m │ │ │ -00052ca0: 6f73 7420 6c69 6b65 6c79 2063 6861 6e67 ost likely chang │ │ │ -00052cb0: 6564 2069 7473 2063 6f6e 6e65 6374 696f ed its connectio │ │ │ -00052cc0: 6e20 4944 2068 6572 650a 0909 092f 2f20 n ID here....// │ │ │ -00052cd0: 7765 206e 6565 6420 746f 206d 6f76 6520 we need to move │ │ │ -00052ce0: 6974 2074 6f20 7468 6520 636f 7272 6563 it to the correc │ │ │ -00052cf0: 7420 4944 0a09 0909 7265 7475 726e 2074 t ID....return t │ │ │ -00052d00: 7275 653b 0a09 097d 0a0a 0909 6966 2028 rue;...}....if ( │ │ │ -00052d10: 7068 2d26 6774 3b67 6574 5f74 7970 6528 ph->get_type( │ │ │ -00052d20: 2920 3d3d 2053 545f 5245 5345 5429 2072 ) == ST_RESET) r │ │ │ -00052d30: 6574 7572 6e20 6661 6c73 653b 0a0a 0909 eturn false;.... │ │ │ -00052d40: 2f2f 2023 6572 726f 7220 7365 6e64 2072 // #error send r │ │ │ -00052d50: 6573 6574 0a0a 0909 7265 7475 726e 2066 eset....return f │ │ │ -00052d60: 616c 7365 3b0a 097d 0a0a 0976 6f69 6420 alse;..}...void │ │ │ -00052d70: 7574 705f 736f 636b 6574 5f6d 616e 6167 utp_socket_manag │ │ │ -00052d80: 6572 3a3a 7375 6273 6372 6962 655f 7772 er::subscribe_wr │ │ │ -00052d90: 6974 6162 6c65 2875 7470 5f73 6f63 6b65 itable(utp_socke │ │ │ -00052da0: 745f 696d 706c 2a20 7329 0a3c 2f70 7265 t_impl* s).
    rele │ │ │ -00052de0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ran │ │ │ -00052e20: 646f 6d2e 6370 703a 3131 373c 2f61 3e3c dom.cpp:117< │ │ │ -00052e30: 2f74 643e 3c74 643e 696d 7072 6f76 6520 /td>improve │ │ │ -00052e40: 6361 6c6c 696e 6720 5241 4e44 5f62 7974 calling RAND_byt │ │ │ -00052e50: 6573 206d 756c 7469 706c 6520 7469 6d65 es multiple time │ │ │ -00052e60: 732c 2075 7369 6e67 2066 616c 6c62 6163 s, using fallbac │ │ │ -00052e70: 6b20 666f 7220 6e6f 773c 2f74 643e 3c2f k for now

    improve c │ │ │ -00052ed0: 616c 6c69 6e67 2052 414e 445f 6279 7465 alling RAND_byte │ │ │ -00052ee0: 7320 6d75 6c74 6970 6c65 2074 696d 6573 s multiple times │ │ │ -00052ef0: 2c20 7573 696e 6720 6661 6c6c 6261 636b , using fallback │ │ │ -00052f00: 2066 6f72 206e 6f77 3c2f 6832 3e3c 6834 for now

    ../src/random.c │ │ │ -00052f20: 7070 3a31 3137 3c2f 6834 3e3c 7072 6520 pp:117

    #else....st
    │ │ │ -00052f70: 643a 3a67 656e 6572 6174 6528 6275 6666  d::generate(buff
    │ │ │ -00052f80: 6572 2e62 6567 696e 2829 2c20 6275 6666  er.begin(), buff
    │ │ │ -00052f90: 6572 2e65 6e64 2829 2c20 5b5d 207b 2072  er.end(), [] { r
    │ │ │ -00052fa0: 6574 7572 6e20 6368 6172 2872 616e 646f  eturn char(rando
    │ │ │ -00052fb0: 6d28 3078 6666 2929 3b20 7d29 3b0a 2365  m(0xff)); });.#e
    │ │ │ -00052fc0: 6e64 6966 0a09 097d 0a0a 0909 766f 6964  ndif...}....void
    │ │ │ -00052fd0: 2063 7279 7074 6f5f 7261 6e64 6f6d 5f62   crypto_random_b
    │ │ │ -00052fe0: 7974 6573 2873 7061 6e26 6c74 3b63 6861  ytes(span<cha
    │ │ │ -00052ff0: 7226 6774 3b20 6275 6666 6572 290a 0909  r> buffer)...
    │ │ │ -00053000: 7b0a 2369 6664 6566 2054 4f52 5245 4e54  {.#ifdef TORRENT
    │ │ │ -00053010: 5f42 5549 4c44 5f53 494d 554c 4154 4f52  _BUILD_SIMULATOR
    │ │ │ -00053020: 0a09 0909 2f2f 2049 6e20 7468 6520 7369  ....// In the si
    │ │ │ -00053030: 6d75 6c61 746f 7220 7765 2077 616e 7420  mulator we want 
    │ │ │ -00053040: 6465 7465 726d 696e 6973 7469 6320 7261  deterministic ra
    │ │ │ -00053050: 6e64 6f6d 206e 756d 6265 7273 0a09 0909  ndom numbers....
    │ │ │ -00053060: 7374 643a 3a67 656e 6572 6174 6528 6275  std::generate(bu
    │ │ │ -00053070: 6666 6572 2e62 6567 696e 2829 2c20 6275  ffer.begin(), bu
    │ │ │ -00053080: 6666 6572 2e65 6e64 2829 2c20 5b5d 207b  ffer.end(), [] {
    │ │ │ -00053090: 2072 6574 7572 6e20 6368 6172 2872 616e   return char(ran
    │ │ │ -000530a0: 646f 6d28 3078 6666 2929 3b20 7d29 3b0a  dom(0xff)); });.
    │ │ │ -000530b0: 2365 6c69 6620 544f 5252 454e 545f 5553  #elif TORRENT_US
    │ │ │ -000530c0: 455f 434e 470a 0909 0961 7578 3a3a 636e  E_CNG....aux::cn
    │ │ │ -000530d0: 675f 6765 6e5f 7261 6e64 6f6d 2862 7566  g_gen_random(buf
    │ │ │ -000530e0: 6665 7229 3b0a 2365 6c69 6620 544f 5252  fer);.#elif TORR
    │ │ │ -000530f0: 454e 545f 5553 455f 4352 5950 544f 4150  ENT_USE_CRYPTOAP
    │ │ │ -00053100: 490a 0909 092f 2f20 7769 6e64 6f77 730a  I....// windows.
    │ │ │ -00053110: 0909 0961 7578 3a3a 6372 7970 745f 6765  ...aux::crypt_ge
    │ │ │ -00053120: 6e5f 7261 6e64 6f6d 2862 7566 6665 7229  n_random(buffer)
    │ │ │ -00053130: 3b0a 2365 6c69 6620 6465 6669 6e65 6420  ;.#elif defined 
    │ │ │ -00053140: 544f 5252 454e 545f 5553 455f 4c49 4243  TORRENT_USE_LIBC
    │ │ │ -00053150: 5259 5054 4f20 2661 6d70 3b26 616d 703b  RYPTO &&
    │ │ │ -00053160: 2021 6465 6669 6e65 6420 544f 5252 454e   !defined TORREN
    │ │ │ -00053170: 545f 5553 455f 574f 4c46 5353 4c0a 2f2f  T_USE_WOLFSSL.//
    │ │ │ -00053180: 2077 6f6c 6653 534c 2075 7365 7320 7763   wolfSSL uses wc
    │ │ │ -00053190: 5f52 4e47 5f47 656e 6572 6174 6542 6c6f  _RNG_GenerateBlo
    │ │ │ -000531a0: 636b 2061 7320 7468 6520 696e 7465 726e  ck as the intern
    │ │ │ -000531b0: 616c 2066 756e 6374 696f 6e20 666f 7220  al function for 
    │ │ │ -000531c0: 7468 650a 2f2f 206f 7065 6e73 736c 2063  the.// openssl c
    │ │ │ -000531d0: 6f6d 7061 7469 6269 6c69 7479 206c 6179  ompatibility lay
    │ │ │ -000531e0: 6572 2e20 5468 6973 2066 756e 6374 696f  er. This functio
    │ │ │ -000531f0: 6e20 4150 4920 646f 6573 206e 6f74 2073  n API does not s
    │ │ │ -00053200: 7570 706f 7274 0a2f 2f20 616e 2061 7262  upport.// an arb
    │ │ │ -00053210: 6974 7261 7279 2062 7566 6665 7220 7369  itrary buffer si
    │ │ │ -00053220: 7a65 2028 6f70 656e 7373 6c20 646f 6573  ze (openssl does
    │ │ │ -00053230: 292c 2069 7420 6973 206c 696d 6974 6564  ), it is limited
    │ │ │ -00053240: 2062 7920 7468 650a 2f2f 2063 6f6e 7374   by the.// const
    │ │ │ -00053250: 616e 7420 524e 475f 4d41 585f 424c 4f43  ant RNG_MAX_BLOC
    │ │ │ -00053260: 4b5f 4c45 4e2e 0a3c 6469 7620 7374 796c  K_LEN..
    .
    .../ │ │ │ -000532a0: 2f20 6f70 656e 7373 6c0a 0909 0969 6e74 / openssl....int │ │ │ -000532b0: 2072 203d 2052 414e 445f 6279 7465 7328 r = RAND_bytes( │ │ │ -000532c0: 7265 696e 7465 7270 7265 745f 6361 7374 reinterpret_cast │ │ │ -000532d0: 266c 743b 756e 7369 676e 6564 2063 6861 <unsigned cha │ │ │ -000532e0: 722a 2667 743b 2862 7566 6665 722e 6461 r*>(buffer.da │ │ │ -000532f0: 7461 2829 290a 0909 0909 2c20 696e 7428 ta())....., int( │ │ │ -00053300: 6275 6666 6572 2e73 697a 6528 2929 293b buffer.size())); │ │ │ -00053310: 0a09 0909 6966 2028 7220 213d 2031 2920 ....if (r != 1) │ │ │ -00053320: 6175 783a 3a74 6872 6f77 5f65 7826 6c74 aux::throw_ex< │ │ │ -00053330: 3b73 7973 7465 6d5f 6572 726f 7226 6774 ;system_error> │ │ │ -00053340: 3b28 6572 726f 7273 3a3a 6e6f 5f65 6e74 ;(errors::no_ent │ │ │ -00053350: 726f 7079 293b 0a23 656c 6966 2054 4f52 ropy);.#elif TOR │ │ │ -00053360: 5245 4e54 5f55 5345 5f47 4554 5241 4e44 RENT_USE_GETRAND │ │ │ -00053370: 4f4d 0a09 0909 7373 697a 655f 7420 636f OM....ssize_t co │ │ │ -00053380: 6e73 7420 7220 3d20 3a3a 6765 7472 616e nst r = ::getran │ │ │ -00053390: 646f 6d28 6275 6666 6572 2e64 6174 6128 dom(buffer.data( │ │ │ -000533a0: 292c 2073 7461 7469 635f 6361 7374 266c ), static_cast&l │ │ │ -000533b0: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ -000533c0: 3b28 6275 6666 6572 2e73 697a 6528 2929 ;(buffer.size()) │ │ │ -000533d0: 2c20 3029 3b0a 0909 0969 6620 2872 203d , 0);....if (r = │ │ │ -000533e0: 3d20 7373 697a 655f 7428 6275 6666 6572 = ssize_t(buffer │ │ │ -000533f0: 2e73 697a 6528 2929 2920 7265 7475 726e .size())) return │ │ │ -00053400: 3b0a 0909 0969 6620 2872 203d 3d20 2d31 ;....if (r == -1 │ │ │ -00053410: 2026 616d 703b 2661 6d70 3b20 6572 726e && errn │ │ │ -00053420: 6f20 213d 2045 4e4f 5359 5329 2061 7578 o != ENOSYS) aux │ │ │ -00053430: 3a3a 7468 726f 775f 6578 266c 743b 7379 ::throw_ex<sy │ │ │ -00053440: 7374 656d 5f65 7272 6f72 2667 743b 2865 stem_error>(e │ │ │ -00053450: 7272 6f72 5f63 6f64 6528 6572 726e 6f2c rror_code(errno, │ │ │ -00053460: 2067 656e 6572 6963 5f63 6174 6567 6f72 generic_categor │ │ │ -00053470: 7928 2929 293b 0a09 0909 7374 6174 6963 y()));....static │ │ │ -00053480: 2064 6576 5f72 616e 646f 6d20 6465 763b dev_random dev; │ │ │ -00053490: 0a09 0909 6465 762e 7265 6164 2862 7566 ....dev.read(buf │ │ │ -000534a0: 6665 7229 3b0a 2365 6c69 6620 544f 5252 fer);.#elif TORR │ │ │ -000534b0: 454e 545f 5553 455f 4445 565f 5241 4e44 ENT_USE_DEV_RAND │ │ │ -000534c0: 4f4d 0a09 0909 7374 6174 6963 2064 6576 OM....static dev │ │ │ -000534d0: 5f72 616e 646f 6d20 6465 763b 0a09 0909 _random dev;.... │ │ │ -000534e0: 6465 762e 7265 6164 2862 7566 6665 7229 dev.read(buffer) │ │ │ -000534f0: 3b0a 2365 6c73 650a 0a23 6966 2054 4f52 ;.#else..#if TOR │ │ │ -00053500: 5245 4e54 5f42 524f 4b45 4e5f 5241 4e44 RENT_BROKEN_RAND │ │ │ -00053510: 4f4d 5f44 4556 4943 450a 0909 092f 2f20 OM_DEVICE....// │ │ │ -00053520: 6576 656e 2070 7365 7564 6f20 7261 6e64 even pseudo rand │ │ │ -00053530: 6f6d 206e 756d 6265 7273 2072 656c 7920 om numbers rely │ │ │ -00053540: 6f6e 2062 6569 6e67 2061 626c 6520 746f on being able to │ │ │ -00053550: 2073 6565 6420 7468 6520 7261 6e64 6f6d seed the random │ │ │ -00053560: 0a09 0909 2f2f 2067 656e 6572 6174 6f72 ....// generator │ │ │ -00053570: 0a23 6572 726f 7220 226e 6f20 656e 7472 .#error "no entr │ │ │ -00053580: 6f70 7920 736f 7572 6365 2061 7661 696c opy source avail │ │ │ -00053590: 6162 6c65 220a 2365 6c73 650a 2369 6664 able".#else.#ifd │ │ │ -000535a0: 6566 2054 4f52 5245 4e54 5f49 5f57 414e ef TORRENT_I_WAN │ │ │ -000535b0: 545f 494e 5345 4355 5245 5f52 414e 444f T_INSECURE_RANDO │ │ │ -000535c0: 4d5f 4e55 4d42 4552 530a 0909 0973 7464 M_NUMBERS....std │ │ │ -000535d0: 3a3a 6765 6e65 7261 7465 2862 7566 6665 ::generate(buffe │ │ │ -000535e0: 722e 6265 6769 6e28 292c 2062 7566 6665 r.begin(), buffe │ │ │ -000535f0: 722e 656e 6428 292c 205b 5d20 7b20 7265 r.end(), [] { re │ │ │ -00053600: 7475 726e 2063 6861 7228 7261 6e64 6f6d turn char(random │ │ │ -00053610: 2830 7866 6629 293b 207d 293b 0a23 656c (0xff)); });.#el │ │ │ -00053620: 7365 0a23 6572 726f 7220 226e 6f20 7365 se.#error "no se │ │ │ -00053630: 6375 7265 2065 6e74 726f 7079 2073 6f75 cure entropy sou │ │ │ -00053640: 7263 6520 6176 6169 6c61 626c 652e 2049 rce available. I │ │ │ -00053650: 6620 796f 7520 7265 616c 6c79 2077 616e f you really wan │ │ │ -00053660: 7420 696e 7365 6375 7265 2072 616e 646f t insecure rando │ │ │ -00053670: 6d20 6e75 6d62 6572 732c 2064 6566 696e m numbers, defin │ │ │ -00053680: 6520 544f 5252 454e 545f 495f 5741 4e54 e TORRENT_I_WANT │ │ │ -00053690: 5f49 4e53 4543 5552 455f 5241 4e44 4f4d _INSECURE_RANDOM │ │ │ -000536a0: 5f4e 554d 4245 5253 220a 2365 6e64 6966 _NUMBERS".#endif │ │ │ -000536b0: 0a23 656e 6469 660a 0a23 656e 6469 660a .#endif..#endif. │ │ │ -000536c0: 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..
    │ │ │ -000536d0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00053700: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00053710: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00053720: 7074 3a65 7870 616e 6428 3139 3829 223e pt:expand(198)"> │ │ │ -00053730: 2e2e 2f73 7263 2f70 655f 6372 7970 746f ../src/pe_crypto │ │ │ -00053740: 2e63 7070 3a31 3332 3c2f 613e 3c2f 7464 .cpp:132it would be │ │ │ -00053760: 206e 6963 6520 746f 2062 6520 6162 6c65 nice to be able │ │ │ -00053770: 2074 6f20 6578 706f 7274 2074 6f20 6120 to export to a │ │ │ -00053780: 6669 7865 6420 7769 6474 6820 6669 656c fixed width fiel │ │ │ -00053790: 642c 2073 6f20 7765 2077 6f75 6c64 6e27 d, so we wouldn' │ │ │ -000537a0: 7420 6861 7665 2074 6f20 7368 6966 7420 t have to shift │ │ │ -000537b0: 6974 206c 6174 6572 3c2f 7464 3e3c 2f74 it later

    it would b │ │ │ -00053810: 6520 6e69 6365 2074 6f20 6265 2061 626c e nice to be abl │ │ │ -00053820: 6520 746f 2065 7870 6f72 7420 746f 2061 e to export to a │ │ │ -00053830: 2066 6978 6564 2077 6964 7468 2066 6965 fixed width fie │ │ │ -00053840: 6c64 2c20 736f 0a77 6520 776f 756c 646e ld, so.we wouldn │ │ │ -00053850: 2774 2068 6176 6520 746f 2073 6869 6674 't have to shift │ │ │ -00053860: 2069 7420 6c61 7465 723c 2f68 323e 3c68 it later

    ../src/pe_cryp │ │ │ -00053880: 746f 2e63 7070 3a31 3332 3c2f 6834 3e3c to.cpp:132< │ │ │ -00053890: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000538a0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000538b0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -000538c0: 7820 2364 6464 3b22 3e09 0909 0942 4e5f x #ddd;">....BN_ │ │ │ -000538d0: 4d4f 4e54 5f43 5458 5f6e 6577 2829 2c20 MONT_CTX_new(), │ │ │ -000538e0: 2661 6d70 3b42 4e5f 4d4f 4e54 5f43 5458 &BN_MONT_CTX │ │ │ -000538f0: 5f66 7265 6529 3b0a 0909 0969 6620 2821 _free);....if (! │ │ │ -00053900: 7265 7420 7c7c 2021 424e 5f4d 4f4e 545f ret || !BN_MONT_ │ │ │ -00053910: 4354 585f 7365 7428 7265 742e 6765 7428 CTX_set(ret.get( │ │ │ -00053920: 292c 2064 685f 7072 696d 6528 292e 6765 ), dh_prime().ge │ │ │ -00053930: 7428 292c 2063 7478 2829 2929 0a09 0909 t(), ctx())).... │ │ │ -00053940: 0961 7578 3a3a 7468 726f 775f 6578 266c .aux::throw_ex&l │ │ │ -00053950: 743b 7379 7374 656d 5f65 7272 6f72 2667 t;system_error&g │ │ │ -00053960: 743b 2865 7272 6f72 733a 3a6e 6f5f 6d65 t;(errors::no_me │ │ │ -00053970: 6d6f 7279 293b 0a09 0909 7265 7475 726e mory);....return │ │ │ -00053980: 2072 6574 3b0a 0909 7d3b 0a23 6966 6465 ret;...};.#ifde │ │ │ -00053990: 6620 424f 4f53 545f 4e4f 5f43 5858 3131 f BOOST_NO_CXX11 │ │ │ -000539a0: 5f54 4852 4541 445f 4c4f 4341 4c0a 0909 _THREAD_LOCAL... │ │ │ -000539b0: 7374 6174 6963 2073 7464 3a3a 756e 6971 static std::uniq │ │ │ -000539c0: 7565 5f70 7472 266c 743b 3a3a 424e 5f4d ue_ptr<::BN_M │ │ │ -000539d0: 4f4e 545f 4354 582c 2076 6f69 6420 282a ONT_CTX, void (* │ │ │ -000539e0: 2928 3a3a 424e 5f4d 4f4e 545f 4354 582a )(::BN_MONT_CTX* │ │ │ -000539f0: 2926 6774 3b20 7368 6172 6564 5f6d 6f6e )> shared_mon │ │ │ -00053a00: 7420 3d20 6d61 6b65 5f6d 6f6e 7428 293b t = make_mont(); │ │ │ -00053a10: 0a23 656c 7365 0a09 0974 6872 6561 645f .#else...thread_ │ │ │ -00053a20: 6c6f 6361 6c20 7374 6174 6963 2073 7464 local static std │ │ │ -00053a30: 3a3a 756e 6971 7565 5f70 7472 266c 743b ::unique_ptr< │ │ │ -00053a40: 3a3a 424e 5f4d 4f4e 545f 4354 582c 2076 ::BN_MONT_CTX, v │ │ │ -00053a50: 6f69 6420 282a 2928 3a3a 424e 5f4d 4f4e oid (*)(::BN_MON │ │ │ -00053a60: 545f 4354 582a 2926 6774 3b20 7368 6172 T_CTX*)> shar │ │ │ -00053a70: 6564 5f6d 6f6e 7420 3d0a 0909 096d 616b ed_mont =....mak │ │ │ -00053a80: 655f 6d6f 6e74 2829 3b0a 2365 6e64 6966 e_mont();.#endif │ │ │ -00053a90: 0a09 0972 6574 7572 6e20 7368 6172 6564 ...return shared │ │ │ -00053aa0: 5f6d 6f6e 742e 6765 7428 293b 0a09 7d0a _mont.get();..}. │ │ │ -00053ab0: 0a09 7374 643a 3a61 7272 6179 266c 743b ..std::array< │ │ │ -00053ac0: 6368 6172 2c20 3936 2667 743b 2064 685f char, 96> dh_ │ │ │ -00053ad0: 6b65 795f 6578 6368 616e 6765 3a3a 6578 key_exchange::ex │ │ │ -00053ae0: 706f 7274 5f6b 6579 286b 6579 5f74 2063 port_key(key_t c │ │ │ -00053af0: 6f6e 7374 2661 6d70 3b20 6b29 0a09 7b0a onst& k)..{. │ │ │ -00053b00: 0909 7374 643a 3a61 7272 6179 266c 743b ..std::array< │ │ │ -00053b10: 6368 6172 2c20 3936 2667 743b 2072 6574 char, 96> ret │ │ │ -00053b20: 3b0a 0909 6175 746f 2a20 6265 6769 6e20 ;...auto* begin │ │ │ -00053b30: 3d20 7265 696e 7465 7270 7265 745f 6361 = reinterpret_ca │ │ │ -00053b40: 7374 266c 743b 756e 7369 676e 6564 2063 st<unsigned c │ │ │ -00053b50: 6861 722a 2667 743b 2872 6574 2e64 6174 har*>(ret.dat │ │ │ -00053b60: 6128 2929 3b0a 0909 696e 7420 636f 6e73 a());...int cons │ │ │ -00053b70: 7420 6c65 6e20 3d20 424e 5f62 6e32 6269 t len = BN_bn2bi │ │ │ -00053b80: 6e28 6b2e 6765 7428 292c 2062 6567 696e n(k.get(), begin │ │ │ -00053b90: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22 );..
    ..if (len < │ │ │ -00053bd0: 2039 3629 0a3c 2f64 6976 3e09 097b 0a09 96).
    ..{.. │ │ │ -00053be0: 0909 7374 643a 3a6d 656d 6d6f 7665 2862 ..std::memmove(b │ │ │ -00053bf0: 6567 696e 202b 2039 3620 2d20 6c65 6e2c egin + 96 - len, │ │ │ -00053c00: 2062 6567 696e 2c20 6175 783a 3a6e 756d begin, aux::num │ │ │ -00053c10: 6572 6963 5f63 6173 7426 6c74 3b73 7464 eric_cast<std │ │ │ -00053c20: 3a3a 7369 7a65 5f74 2667 743b 286c 656e ::size_t>(len │ │ │ -00053c30: 2929 3b0a 0909 0973 7464 3a3a 6d65 6d73 ));....std::mems │ │ │ -00053c40: 6574 2862 6567 696e 2c20 302c 2061 7578 et(begin, 0, aux │ │ │ -00053c50: 3a3a 6e75 6d65 7269 635f 6361 7374 266c ::numeric_cast&l │ │ │ -00053c60: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ -00053c70: 3b28 3936 202d 206c 656e 2929 3b0a 0909 ;(96 - len));... │ │ │ -00053c80: 7d0a 0909 7265 7475 726e 2072 6574 3b0a }...return ret;. │ │ │ -00053c90: 097d 0a0a 092f 2f20 5365 7420 7468 6520 .}...// Set the │ │ │ -00053ca0: 7072 696d 6520 5020 616e 6420 7468 6520 prime P and the │ │ │ -00053cb0: 6765 6e65 7261 746f 722c 2067 656e 6572 generator, gener │ │ │ -00053cc0: 6174 6520 6c6f 6361 6c20 7075 626c 6963 ate local public │ │ │ -00053cd0: 206b 6579 0a09 6468 5f6b 6579 5f65 7863 key..dh_key_exc │ │ │ -00053ce0: 6861 6e67 653a 3a64 685f 6b65 795f 6578 hange::dh_key_ex │ │ │ -00053cf0: 6368 616e 6765 2829 0a09 7b0a 0909 6175 change()..{...au │ │ │ -00053d00: 783a 3a61 7272 6179 266c 743b 7374 643a x::array<std: │ │ │ -00053d10: 3a75 696e 7438 5f74 2c20 3230 2667 743b :uint8_t, 20> │ │ │ -00053d20: 2072 616e 646f 6d5f 6b65 793b 0a09 0961 random_key;...a │ │ │ -00053d30: 7578 3a3a 7261 6e64 6f6d 5f62 7974 6573 ux::random_bytes │ │ │ -00053d40: 287b 7265 696e 7465 7270 7265 745f 6361 ({reinterpret_ca │ │ │ -00053d50: 7374 266c 743b 6368 6172 2a26 6774 3b28 st<char*>( │ │ │ -00053d60: 7261 6e64 6f6d 5f6b 6579 2e64 6174 6128 random_key.data( │ │ │ -00053d70: 2929 2c0a 0909 0973 7461 7469 635f 6361 )),....static_ca │ │ │ -00053d80: 7374 266c 743b 7374 643a 3a70 7472 6469 st<std::ptrdi │ │ │ -00053d90: 6666 5f74 2667 743b 2872 616e 646f 6d5f ff_t>(random_ │ │ │ -00053da0: 6b65 792e 7369 7a65 2829 297d 293b 0a0a key.size())});.. │ │ │ -00053db0: 0909 2f2f 2063 7265 6174 6520 6c6f 6361 ..// create loca │ │ │ -00053dc0: 6c20 6b65 7920 2872 616e 646f 6d29 0a09 l key (random).. │ │ │ -00053dd0: 0969 6620 2821 424e 5f62 696e 3262 6e28 .if (!BN_bin2bn( │ │ │ -00053de0: 7261 6e64 6f6d 5f6b 6579 2e64 6174 6128 random_key.data( │ │ │ -00053df0: 292c 2069 6e74 2872 616e 646f 6d5f 6b65 ), int(random_ke │ │ │ -00053e00: 792e 7369 7a65 2829 292c 206d 5f64 685f y.size()), m_dh_ │ │ │ -00053e10: 6c6f 6361 6c5f 7365 6372 6574 2e67 6574 local_secret.get │ │ │ -00053e20: 2829 2929 0a09 0909 6175 783a 3a74 6872 ()))....aux::thr │ │ │ -00053e30: 6f77 5f65 7826 6c74 3b73 7973 7465 6d5f ow_ex<system_ │ │ │ -00053e40: 6572 726f 7226 6774 3b28 6572 726f 7273 error>(errors │ │ │ -00053e50: 3a3a 6e6f 5f6d 656d 6f72 7929 3b0a 0a09 ::no_memory);... │ │ │ -00053e60: 092f 2f20 6b65 7920 3d20 2832 205e 2073 .// key = (2 ^ s │ │ │ -00053e70: 6563 7265 7429 2025 2070 7269 6d65 0a09 ecret) % prime.. │ │ │ -00053e80: 096b 6579 5f74 206c 6f63 616c 5f6b 6579 .key_t local_key │ │ │ -00053e90: 3b0a 0a09 097b 0a23 6966 6465 6620 424f ;....{.#ifdef BO │ │ │ -00053ea0: 4f53 545f 4e4f 5f43 5858 3131 5f54 4852 OST_NO_CXX11_THR │ │ │ -00053eb0: 4541 445f 4c4f 4341 4c0a 0909 0973 7464 EAD_LOCAL....std │ │ │ -00053ec0: 3a3a 6c6f 636b 5f67 7561 7264 266c 743b ::lock_guard< │ │ │ -00053ed0: 7374 643a 3a6d 7574 6578 2667 743b 206c std::mutex> l │ │ │ -00053ee0: 2867 5f62 6e5f 6374 785f 6d75 7465 7829 (g_bn_ctx_mutex) │ │ │ -00053ef0: 3b0a 2365 6e64 6966 0a09 0909 6966 2028 ;.#endif....if ( │ │ │ -00053f00: 2142 4e5f 6d6f 645f 6578 705f 6d6f 6e74 !BN_mod_exp_mont │ │ │ -00053f10: 286c 6f63 616c 5f6b 6579 2e67 6574 2829 (local_key.get() │ │ │ -00053f20: 2c0a 0909 0909 0974 776f 2829 2e67 6574 ,......two().get │ │ │ -00053f30: 2829 2c0a 0909 0909 096d 5f64 685f 6c6f (),......m_dh_lo │ │ │ -00053f40: 6361 6c5f 7365 6372 6574 2e67 6574 2829 cal_secret.get() │ │ │ -00053f50: 2c0a 0909 0909 0964 685f 7072 696d 6528 ,......dh_prime( │ │ │ -00053f60: 292e 6765 7428 292c 0a09 0909 0909 6374 ).get(),......ct │ │ │ -00053f70: 7828 292c 0a3c 2f70 7265 3e3c 2f74 643e x(),. │ │ │ -00053f80: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00053fb0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00053fc0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00053fd0: 7074 3a65 7870 616e 6428 3139 3929 223e pt:expand(199)"> │ │ │ -00053fe0: 2e2e 2f73 7263 2f70 655f 6372 7970 746f ../src/pe_crypto │ │ │ -00053ff0: 2e63 7070 3a32 3132 3c2f 613e 3c2f 7464 .cpp:212it would be │ │ │ -00054010: 206e 6963 6520 746f 2067 6574 2074 6865 nice to get the │ │ │ -00054020: 206c 6974 6572 616c 2077 6f72 6b69 6e67 literal working │ │ │ -00054030: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -00054080: 2077 6f75 6c64 2062 6520 6e69 6365 2074 would be nice t │ │ │ -00054090: 6f20 6765 7420 7468 6520 6c69 7465 7261 o get the litera │ │ │ -000540a0: 6c20 776f 726b 696e 673c 2f68 323e 3c68 l working

    ../src/pe_cryp │ │ │ -000540c0: 746f 2e63 7070 3a32 3132 3c2f 6834 3e3c to.cpp:212< │ │ │ -000540d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000540e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000540f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00054100: 7820 2364 6464 3b22 3e09 0909 6966 2028 x #ddd;">...if ( │ │ │ -00054110: 2142 4e5f 6d6f 645f 6578 705f 6d6f 6e74 !BN_mod_exp_mont │ │ │ -00054120: 2873 6563 7265 742e 6765 7428 292c 0a09 (secret.get(),.. │ │ │ -00054130: 0909 0909 6b65 792e 6765 7428 292c 0a09 ....key.get(),.. │ │ │ -00054140: 0909 0909 6d5f 6468 5f6c 6f63 616c 5f73 ....m_dh_local_s │ │ │ -00054150: 6563 7265 742e 6765 7428 292c 0a09 0909 ecret.get(),.... │ │ │ -00054160: 0909 6468 5f70 7269 6d65 2829 2e67 6574 ..dh_prime().get │ │ │ -00054170: 2829 2c0a 0909 0909 0963 7478 2829 2c0a (),......ctx(),. │ │ │ -00054180: 0909 0909 096d 6f6e 7428 2929 290a 0909 .....mont()))... │ │ │ -00054190: 0909 6175 783a 3a74 6872 6f77 5f65 7826 ..aux::throw_ex& │ │ │ -000541a0: 6c74 3b73 7973 7465 6d5f 6572 726f 7226 lt;system_error& │ │ │ -000541b0: 6774 3b28 6572 726f 7273 3a3a 6e6f 5f6d gt;(errors::no_m │ │ │ -000541c0: 656d 6f72 7929 3b0a 0909 7d0a 0909 6d5f emory);...}...m_ │ │ │ -000541d0: 6468 5f73 6861 7265 645f 7365 6372 6574 dh_shared_secret │ │ │ -000541e0: 203d 2065 7870 6f72 745f 6b65 7928 7365 = export_key(se │ │ │ -000541f0: 6372 6574 293b 0a0a 0909 7374 6174 6963 cret);....static │ │ │ -00054200: 2063 6861 7220 636f 6e73 7420 7265 7133 char const req3 │ │ │ -00054210: 5b34 5d20 3d20 7b27 7227 2c20 2765 272c [4] = {'r', 'e', │ │ │ -00054220: 2027 7127 2c20 2733 277d 3b0a 0909 2f2f 'q', '3'};...// │ │ │ -00054230: 2063 616c 6375 6c61 7465 2074 6865 2078 calculate the x │ │ │ -00054240: 6f72 206d 6173 6b20 666f 7220 7468 6520 or mask for the │ │ │ -00054250: 6f62 6675 7363 6174 6564 2068 6173 680a obfuscated hash. │ │ │ -00054260: 0909 6d5f 786f 725f 6d61 736b 203d 2068 ..m_xor_mask = h │ │ │ -00054270: 6173 6865 7228 7265 7133 292e 7570 6461 asher(req3).upda │ │ │ -00054280: 7465 286d 5f64 685f 7368 6172 6564 5f73 te(m_dh_shared_s │ │ │ -00054290: 6563 7265 7429 2e66 696e 616c 2829 3b0a ecret).final();. │ │ │ -000542a0: 0909 7265 7475 726e 2074 7275 653b 0a09 ..return true;.. │ │ │ -000542b0: 7d0a 0a23 656c 7365 202f 2f20 544f 5252 }..#else // TORR │ │ │ -000542c0: 454e 545f 5553 455f 4c49 4243 5259 5054 ENT_USE_LIBCRYPT │ │ │ -000542d0: 4f0a 0a09 6468 5f6b 6579 5f65 7863 6861 O...dh_key_excha │ │ │ -000542e0: 6e67 653a 3a6b 6579 5f74 2063 6f6e 7374 nge::key_t const │ │ │ -000542f0: 2661 6d70 3b20 6468 5f6b 6579 5f65 7863 & dh_key_exc │ │ │ -00054300: 6861 6e67 653a 3a64 685f 7072 696d 6528 hange::dh_prime( │ │ │ -00054310: 290a 097b 0a3c 6469 7620 7374 796c 653d )..{.
    ..static key_ │ │ │ -00054350: 7420 636f 6e73 7420 7072 696d 6528 0a3c t const prime(.< │ │ │ -00054360: 2f64 6976 3e09 0909 2230 7846 4646 4646 /div>..."0xFFFFF │ │ │ -00054370: 4646 4646 4646 4646 4646 4643 3930 4644 FFFFFFFFFFFC90FD │ │ │ -00054380: 4141 3232 3136 3843 3233 3443 3443 3636 AA22168C234C4C66 │ │ │ -00054390: 3238 4238 3044 4331 4344 3132 3930 3234 28B80DC1CD129024 │ │ │ -000543a0: 4530 3838 4136 3743 4337 3430 3230 4242 E088A67CC74020BB │ │ │ -000543b0: 4541 3633 4231 3339 4232 3235 3134 4122 EA63B139B22514A" │ │ │ -000543c0: 0a09 0909 2230 3837 3938 4533 3430 3444 ...."08798E3404D │ │ │ -000543d0: 4445 4639 3531 3942 3343 4433 4134 3331 DEF9519B3CD3A431 │ │ │ -000543e0: 4233 3032 4230 4136 4446 3235 4631 3433 B302B0A6DF25F143 │ │ │ -000543f0: 3734 4645 3133 3536 4436 4435 3143 3234 74FE1356D6D51C24 │ │ │ -00054400: 3545 3438 3542 3537 3636 3235 4537 4543 5E485B576625E7EC │ │ │ -00054410: 3646 3434 4334 3245 3941 3622 0a09 0909 6F44C42E9A6".... │ │ │ -00054420: 2233 4133 3632 3130 3030 3030 3030 3030 "3A3621000000000 │ │ │ -00054430: 3030 3930 3536 3322 293b 0a09 0972 6574 0090563");...ret │ │ │ -00054440: 7572 6e20 7072 696d 653b 0a09 7d0a 0a09 urn prime;..}... │ │ │ -00054450: 7374 643a 3a61 7272 6179 266c 743b 6368 std::array<ch │ │ │ -00054460: 6172 2c20 3936 2667 743b 2064 685f 6b65 ar, 96> dh_ke │ │ │ -00054470: 795f 6578 6368 616e 6765 3a3a 6578 706f y_exchange::expo │ │ │ -00054480: 7274 5f6b 6579 286b 6579 5f74 2063 6f6e rt_key(key_t con │ │ │ -00054490: 7374 2661 6d70 3b20 6b29 0a09 7b0a 0909 st& k)..{... │ │ │ -000544a0: 7374 643a 3a61 7272 6179 266c 743b 6368 std::array<ch │ │ │ -000544b0: 6172 2c20 3936 2667 743b 2072 6574 3b0a ar, 96> ret;. │ │ │ -000544c0: 0909 6175 746f 2a20 6265 6769 6e20 3d20 ..auto* begin = │ │ │ -000544d0: 7265 696e 7465 7270 7265 745f 6361 7374 reinterpret_cast │ │ │ -000544e0: 266c 743b 7374 643a 3a75 696e 7438 5f74 <std::uint8_t │ │ │ -000544f0: 2a26 6774 3b28 7265 742e 6461 7461 2829 *>(ret.data() │ │ │ -00054500: 293b 0a09 0973 7464 3a3a 7569 6e74 385f );...std::uint8_ │ │ │ -00054510: 742a 2065 6e64 203d 206d 703a 3a65 7870 t* end = mp::exp │ │ │ -00054520: 6f72 745f 6269 7473 286b 2c20 6265 6769 ort_bits(k, begi │ │ │ -00054530: 6e2c 2038 293b 0a0a 3c2f 7072 653e 3c2f n, 8);..relevan │ │ │ -00054570: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/pe_cry │ │ │ -000545b0: 7074 6f2e 6370 703a 3232 363c 2f61 3e3c pto.cpp:226< │ │ │ -000545c0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ -000545d0: 2062 6520 6e69 6365 2074 6f20 6265 2061 be nice to be a │ │ │ -000545e0: 626c 6520 746f 2065 7870 6f72 7420 746f ble to export to │ │ │ -000545f0: 2061 2066 6978 6564 2077 6964 7468 2066 a fixed width f │ │ │ -00054600: 6965 6c64 2c20 736f 2077 6520 776f 756c ield, so we woul │ │ │ -00054610: 646e 2774 2068 6176 6520 746f 2073 6869 dn't have to shi │ │ │ -00054620: 6674 2069 7420 6c61 7465 723c 2f74 643e ft it later │ │ │ -00054630: 3c2f 7472 3e3c 7472 2069 643d 2232 3030

    it woul │ │ │ -00054680: 6420 6265 206e 6963 6520 746f 2062 6520 d be nice to be │ │ │ -00054690: 6162 6c65 2074 6f20 6578 706f 7274 2074 able to export t │ │ │ -000546a0: 6f20 6120 6669 7865 6420 7769 6474 6820 o a fixed width │ │ │ -000546b0: 6669 656c 642c 2073 6f0a 7765 2077 6f75 field, so.we wou │ │ │ -000546c0: 6c64 6e27 7420 6861 7665 2074 6f20 7368 ldn't have to sh │ │ │ -000546d0: 6966 7420 6974 206c 6174 6572 3c2f 6832 ift it later

    ../src/pe_c │ │ │ -000546f0: 7279 7074 6f2e 6370 703a 3232 363c 2f68 rypto.cpp:226
    ..re
    │ │ │ -00054740: 7475 726e 2074 7275 653b 0a09 7d0a 0a23  turn true;..}..#
    │ │ │ -00054750: 656c 7365 202f 2f20 544f 5252 454e 545f  else // TORRENT_
    │ │ │ -00054760: 5553 455f 4c49 4243 5259 5054 4f0a 0a09  USE_LIBCRYPTO...
    │ │ │ -00054770: 6468 5f6b 6579 5f65 7863 6861 6e67 653a  dh_key_exchange:
    │ │ │ -00054780: 3a6b 6579 5f74 2063 6f6e 7374 2661 6d70  :key_t const&
    │ │ │ -00054790: 3b20 6468 5f6b 6579 5f65 7863 6861 6e67  ; dh_key_exchang
    │ │ │ -000547a0: 653a 3a64 685f 7072 696d 6528 290a 097b  e::dh_prime()..{
    │ │ │ -000547b0: 0a09 0973 7461 7469 6320 6b65 795f 7420  ...static key_t 
    │ │ │ -000547c0: 636f 6e73 7420 7072 696d 6528 0a09 0909  const prime(....
    │ │ │ -000547d0: 2230 7846 4646 4646 4646 4646 4646 4646  "0xFFFFFFFFFFFFF
    │ │ │ -000547e0: 4646 4643 3930 4644 4141 3232 3136 3843  FFFC90FDAA22168C
    │ │ │ -000547f0: 3233 3443 3443 3636 3238 4238 3044 4331  234C4C6628B80DC1
    │ │ │ -00054800: 4344 3132 3930 3234 4530 3838 4136 3743  CD129024E088A67C
    │ │ │ -00054810: 4337 3430 3230 4242 4541 3633 4231 3339  C74020BBEA63B139
    │ │ │ -00054820: 4232 3235 3134 4122 0a09 0909 2230 3837  B22514A"...."087
    │ │ │ -00054830: 3938 4533 3430 3444 4445 4639 3531 3942  98E3404DDEF9519B
    │ │ │ -00054840: 3343 4433 4134 3331 4233 3032 4230 4136  3CD3A431B302B0A6
    │ │ │ -00054850: 4446 3235 4631 3433 3734 4645 3133 3536  DF25F14374FE1356
    │ │ │ -00054860: 4436 4435 3143 3234 3545 3438 3542 3537  D6D51C245E485B57
    │ │ │ -00054870: 3636 3235 4537 4543 3646 3434 4334 3245  6625E7EC6F44C42E
    │ │ │ -00054880: 3941 3622 0a09 0909 2233 4133 3632 3130  9A6"...."3A36210
    │ │ │ -00054890: 3030 3030 3030 3030 3030 3930 3536 3322  000000000090563"
    │ │ │ -000548a0: 293b 0a09 0972 6574 7572 6e20 7072 696d  );...return prim
    │ │ │ -000548b0: 653b 0a09 7d0a 0a09 7374 643a 3a61 7272  e;..}...std::arr
    │ │ │ -000548c0: 6179 266c 743b 6368 6172 2c20 3936 2667  ay<char, 96&g
    │ │ │ -000548d0: 743b 2064 685f 6b65 795f 6578 6368 616e  t; dh_key_exchan
    │ │ │ -000548e0: 6765 3a3a 6578 706f 7274 5f6b 6579 286b  ge::export_key(k
    │ │ │ -000548f0: 6579 5f74 2063 6f6e 7374 2661 6d70 3b20  ey_t const& 
    │ │ │ -00054900: 6b29 0a09 7b0a 0909 7374 643a 3a61 7272  k)..{...std::arr
    │ │ │ -00054910: 6179 266c 743b 6368 6172 2c20 3936 2667  ay<char, 96&g
    │ │ │ -00054920: 743b 2072 6574 3b0a 0909 6175 746f 2a20  t; ret;...auto* 
    │ │ │ -00054930: 6265 6769 6e20 3d20 7265 696e 7465 7270  begin = reinterp
    │ │ │ -00054940: 7265 745f 6361 7374 266c 743b 7374 643a  ret_cast<std:
    │ │ │ -00054950: 3a75 696e 7438 5f74 2a26 6774 3b28 7265  :uint8_t*>(re
    │ │ │ -00054960: 742e 6461 7461 2829 293b 0a09 0973 7464  t.data());...std
    │ │ │ -00054970: 3a3a 7569 6e74 385f 742a 2065 6e64 203d  ::uint8_t* end =
    │ │ │ -00054980: 206d 703a 3a65 7870 6f72 745f 6269 7473   mp::export_bits
    │ │ │ -00054990: 286b 2c20 6265 6769 6e2c 2038 293b 0a0a  (k, begin, 8);..
    │ │ │ -000549a0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -000549d0: 6966 2028 656e 6420 266c 743b 2062 6567 if (end < beg │ │ │ -000549e0: 696e 202b 2039 3629 0a3c 2f64 6976 3e09 in + 96).
    . │ │ │ -000549f0: 097b 0a09 0909 696e 7420 636f 6e73 7420 .{....int const │ │ │ -00054a00: 6c65 6e20 3d20 696e 7428 656e 6420 2d20 len = int(end - │ │ │ -00054a10: 6265 6769 6e29 3b0a 2369 6620 6465 6669 begin);.#if defi │ │ │ -00054a20: 6e65 6420 5f5f 474e 5543 5f5f 2026 616d ned __GNUC__ &am │ │ │ -00054a30: 703b 2661 6d70 3b20 5f5f 474e 5543 5f5f p;& __GNUC__ │ │ │ -00054a40: 203d 3d20 3132 0a23 7072 6167 6d61 2047 == 12.#pragma G │ │ │ -00054a50: 4343 2064 6961 676e 6f73 7469 6320 7075 CC diagnostic pu │ │ │ -00054a60: 7368 0a23 7072 6167 6d61 2047 4343 2064 sh.#pragma GCC d │ │ │ -00054a70: 6961 676e 6f73 7469 6320 6967 6e6f 7265 iagnostic ignore │ │ │ -00054a80: 6420 222d 5773 7472 696e 676f 702d 6f76 d "-Wstringop-ov │ │ │ -00054a90: 6572 666c 6f77 220a 2365 6e64 6966 0a09 erflow".#endif.. │ │ │ -00054aa0: 0909 7374 643a 3a6d 656d 6d6f 7665 2862 ..std::memmove(b │ │ │ -00054ab0: 6567 696e 202b 2039 3620 2d20 6c65 6e2c egin + 96 - len, │ │ │ -00054ac0: 2062 6567 696e 2c20 6175 783a 3a6e 756d begin, aux::num │ │ │ -00054ad0: 6572 6963 5f63 6173 7426 6c74 3b73 7464 eric_cast<std │ │ │ -00054ae0: 3a3a 7369 7a65 5f74 2667 743b 286c 656e ::size_t>(len │ │ │ -00054af0: 2929 3b0a 2369 6620 6465 6669 6e65 6420 ));.#if defined │ │ │ -00054b00: 5f5f 474e 5543 5f5f 2026 616d 703b 2661 __GNUC__ &&a │ │ │ -00054b10: 6d70 3b20 5f5f 474e 5543 5f5f 203d 3d20 mp; __GNUC__ == │ │ │ -00054b20: 3132 0a23 7072 6167 6d61 2047 4343 2064 12.#pragma GCC d │ │ │ -00054b30: 6961 676e 6f73 7469 6320 706f 700a 2365 iagnostic pop.#e │ │ │ -00054b40: 6e64 6966 0a09 0909 7374 643a 3a6d 656d ndif....std::mem │ │ │ -00054b50: 7365 7428 6265 6769 6e2c 2030 2c20 6175 set(begin, 0, au │ │ │ -00054b60: 783a 3a6e 756d 6572 6963 5f63 6173 7426 x::numeric_cast& │ │ │ -00054b70: 6c74 3b73 7464 3a3a 7369 7a65 5f74 2667 lt;std::size_t&g │ │ │ -00054b80: 743b 2839 3620 2d20 6c65 6e29 293b 0a09 t;(96 - len));.. │ │ │ -00054b90: 097d 0a09 0972 6574 7572 6e20 7265 743b .}...return ret; │ │ │ -00054ba0: 0a09 7d0a 0a09 2f2f 2053 6574 2074 6865 ..}...// Set the │ │ │ -00054bb0: 2070 7269 6d65 2050 2061 6e64 2074 6865 prime P and the │ │ │ -00054bc0: 2067 656e 6572 6174 6f72 2c20 6765 6e65 generator, gene │ │ │ -00054bd0: 7261 7465 206c 6f63 616c 2070 7562 6c69 rate local publi │ │ │ -00054be0: 6320 6b65 790a 0964 685f 6b65 795f 6578 c key..dh_key_ex │ │ │ -00054bf0: 6368 616e 6765 3a3a 6468 5f6b 6579 5f65 change::dh_key_e │ │ │ -00054c00: 7863 6861 6e67 6528 290a 097b 0a09 0961 xchange()..{...a │ │ │ -00054c10: 7578 3a3a 6172 7261 7926 6c74 3b73 7464 ux::array<std │ │ │ -00054c20: 3a3a 7569 6e74 385f 742c 2032 3026 6774 ::uint8_t, 20> │ │ │ -00054c30: 3b20 7261 6e64 6f6d 5f6b 6579 3b0a 0909 ; random_key;... │ │ │ -00054c40: 6175 783a 3a72 616e 646f 6d5f 6279 7465 aux::random_byte │ │ │ -00054c50: 7328 7b72 6569 6e74 6572 7072 6574 5f63 s({reinterpret_c │ │ │ -00054c60: 6173 7426 6c74 3b63 6861 722a 2667 743b ast<char*> │ │ │ -00054c70: 2872 616e 646f 6d5f 6b65 792e 6461 7461 (random_key.data │ │ │ -00054c80: 2829 290a 0909 092c 2073 7461 7469 635f ())...., static_ │ │ │ -00054c90: 6361 7374 266c 743b 7374 643a 3a70 7472 cast<std::ptr │ │ │ -00054ca0: 6469 6666 5f74 2667 743b 2872 616e 646f diff_t>(rando │ │ │ -00054cb0: 6d5f 6b65 792e 7369 7a65 2829 297d 293b m_key.size())}); │ │ │ -00054cc0: 0a0a 0909 2f2f 2063 7265 6174 6520 6c6f ....// create lo │ │ │ -00054cd0: 6361 6c20 6b65 7920 2872 616e 646f 6d29 cal key (random) │ │ │ -00054ce0: 0a09 096d 703a 3a69 6d70 6f72 745f 6269 ...mp::import_bi │ │ │ -00054cf0: 7473 286d 5f64 685f 6c6f 6361 6c5f 7365 ts(m_dh_local_se │ │ │ -00054d00: 6372 6574 2c20 7261 6e64 6f6d 5f6b 6579 cret, random_key │ │ │ -00054d10: 2e62 6567 696e 2829 2c20 7261 6e64 6f6d .begin(), random │ │ │ -00054d20: 5f6b 6579 2e65 6e64 2829 293b 0a0a 0909 _key.end());.... │ │ │ -00054d30: 2f2f 206b 6579 203d 2028 3220 5e20 7365 // key = (2 ^ se │ │ │ -00054d40: 6372 6574 2920 2520 7072 696d 650a 0909 cret) % prime... │ │ │ -00054d50: 6b65 795f 7420 636f 6e73 7420 6c6f 6361 key_t const loca │ │ │ -00054d60: 6c5f 6b65 7920 3d20 6d70 3a3a 706f 776d l_key = mp::powm │ │ │ -00054d70: 286b 6579 5f74 2832 292c 206d 5f64 685f (key_t(2), m_dh_ │ │ │ -00054d80: 6c6f 6361 6c5f 7365 6372 6574 2c20 6468 local_secret, dh │ │ │ -00054d90: 5f70 7269 6d65 2829 293b 0a09 096d 5f64 _prime());...m_d │ │ │ -00054da0: 685f 6c6f 6361 6c5f 6b65 7920 3d20 6578 h_local_key = ex │ │ │ -00054db0: 706f 7274 5f6b 6579 286c 6f63 616c 5f6b port_key(local_k │ │ │ -00054dc0: 6579 293b 0a09 7d0a 0a3c 2f70 7265 3e3c ey);..}..
    < │ │ │ -00054dd0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00054e00: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00054e10: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/peer_ │ │ │ -00054e40: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a31 connection.cpp:1 │ │ │ -00054e50: 3038 373c 2f61 3e3c 2f74 643e 3c74 643e 087 │ │ │ -00054e60: 7468 6973 2073 686f 756c 6420 6265 2074 this should be t │ │ │ -00054e70: 6865 2067 6c6f 6261 6c20 646f 776e 6c6f he global downlo │ │ │ -00054e80: 6164 2072 6174 653c 2f74 643e 3c2f 7472 ad rate

    this should │ │ │ -00054ee0: 2062 6520 7468 6520 676c 6f62 616c 2064 be the global d │ │ │ -00054ef0: 6f77 6e6c 6f61 6420 7261 7465 3c2f 6832 ownload rate

    ../src/peer │ │ │ -00054f10: 5f63 6f6e 6e65 6374 696f 6e2e 6370 703a _connection.cpp: │ │ │ -00054f20: 3130 3837 3c2f 6834 3e3c 7072 6520 7374 1087

    ...int rate =
    │ │ │ -00054f70: 2030 3b0a 0a09 092f 2f20 6966 2077 6520   0;....// if we 
    │ │ │ -00054f80: 6861 7665 6e27 7420 7265 6365 6976 6564  haven't received
    │ │ │ -00054f90: 2061 6e79 2064 6174 6120 7265 6365 6e74   any data recent
    │ │ │ -00054fa0: 6c79 2c20 7468 6520 6375 7272 656e 7420  ly, the current 
    │ │ │ -00054fb0: 646f 776e 6c6f 6164 2072 6174 650a 0909  download rate...
    │ │ │ -00054fc0: 2f2f 2069 7320 6e6f 7420 7265 7072 6573  // is not repres
    │ │ │ -00054fd0: 656e 7461 7469 7665 0a09 0969 6620 2861  entative...if (a
    │ │ │ -00054fe0: 7578 3a3a 7469 6d65 5f6e 6f77 2829 202d  ux::time_now() -
    │ │ │ -00054ff0: 206d 5f6c 6173 745f 7069 6563 652e 6765   m_last_piece.ge
    │ │ │ -00055000: 7428 6d5f 636f 6e6e 6563 7429 2026 6774  t(m_connect) >
    │ │ │ -00055010: 3b20 7365 636f 6e64 7328 3330 2920 2661  ; seconds(30) &a
    │ │ │ -00055020: 6d70 3b26 616d 703b 206d 5f64 6f77 6e6c  mp;& m_downl
    │ │ │ -00055030: 6f61 645f 7261 7465 5f70 6561 6b20 2667  oad_rate_peak &g
    │ │ │ -00055040: 743b 2030 290a 0909 7b0a 0909 0972 6174  t; 0)...{....rat
    │ │ │ -00055050: 6520 3d20 6d5f 646f 776e 6c6f 6164 5f72  e = m_download_r
    │ │ │ -00055060: 6174 655f 7065 616b 3b0a 0909 7d0a 0909  ate_peak;...}...
    │ │ │ -00055070: 656c 7365 2069 6620 2861 7578 3a3a 7469  else if (aux::ti
    │ │ │ -00055080: 6d65 5f6e 6f77 2829 202d 206d 5f6c 6173  me_now() - m_las
    │ │ │ -00055090: 745f 756e 6368 6f6b 6564 2e67 6574 286d  t_unchoked.get(m
    │ │ │ -000550a0: 5f63 6f6e 6e65 6374 2920 266c 743b 2073  _connect) < s
    │ │ │ -000550b0: 6563 6f6e 6473 2835 290a 0909 0926 616d  econds(5)....&am
    │ │ │ -000550c0: 703b 2661 6d70 3b20 6d5f 7374 6174 6973  p;& m_statis
    │ │ │ -000550d0: 7469 6373 2e74 6f74 616c 5f70 6179 6c6f  tics.total_paylo
    │ │ │ -000550e0: 6164 5f75 706c 6f61 6428 2920 266c 743b  ad_upload() <
    │ │ │ -000550f0: 2032 202a 2030 7834 3030 3029 0a09 097b   2 * 0x4000)...{
    │ │ │ -00055100: 0a09 0909 2f2f 2069 6620 7765 2772 6520  ....// if we're 
    │ │ │ -00055110: 6861 7665 206f 6e6c 7920 6265 656e 2075  have only been u
    │ │ │ -00055120: 6e63 686f 6b65 6420 666f 7220 6120 7368  nchoked for a sh
    │ │ │ -00055130: 6f72 7420 7065 7269 6f64 206f 6620 7469  ort period of ti
    │ │ │ -00055140: 6d65 2c0a 0909 092f 2f20 7765 2064 6f6e  me,....// we don
    │ │ │ -00055150: 2774 206b 6e6f 7720 7768 6174 2072 6174  't know what rat
    │ │ │ -00055160: 6520 7765 2063 616e 2067 6574 2066 726f  e we can get fro
    │ │ │ -00055170: 6d20 7468 6973 2070 6565 722e 2049 6e73  m this peer. Ins
    │ │ │ -00055180: 7465 6164 206f 6620 6173 7375 6d69 6e67  tead of assuming
    │ │ │ -00055190: 0a09 0909 2f2f 2074 6865 206c 6f77 6573  ....// the lowes
    │ │ │ -000551a0: 7420 706f 7373 6962 6c65 2072 6174 652c  t possible rate,
    │ │ │ -000551b0: 2061 7373 756d 6520 7468 6520 6176 6572   assume the aver
    │ │ │ -000551c0: 6167 652e 0a0a 0909 0969 6e74 2070 6565  age......int pee
    │ │ │ -000551d0: 7273 5f77 6974 685f 7265 7175 6573 7473  rs_with_requests
    │ │ │ -000551e0: 203d 2069 6e74 2873 7461 7473 5f63 6f75   = int(stats_cou
    │ │ │ -000551f0: 6e74 6572 7328 295b 636f 756e 7465 7273  nters()[counters
    │ │ │ -00055200: 3a3a 6e75 6d5f 7065 6572 735f 646f 776e  ::num_peers_down
    │ │ │ -00055210: 5f72 6571 7565 7374 735d 293b 0a09 0909  _requests]);....
    │ │ │ -00055220: 2f2f 2061 766f 6964 2064 6976 6973 696f  // avoid divisio
    │ │ │ -00055230: 6e20 6279 2030 0a09 0909 6966 2028 7065  n by 0....if (pe
    │ │ │ -00055240: 6572 735f 7769 7468 5f72 6571 7565 7374  ers_with_request
    │ │ │ -00055250: 7320 3d3d 2030 2920 7065 6572 735f 7769  s == 0) peers_wi
    │ │ │ -00055260: 7468 5f72 6571 7565 7374 7320 3d20 313b  th_requests = 1;
    │ │ │ -00055270: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -000552a0: 0909 0972 6174 6520 3d20 742d 2667 743b ...rate = t-> │ │ │ -000552b0: 7374 6174 6973 7469 6373 2829 2e74 7261 statistics().tra │ │ │ -000552c0: 6e73 6665 725f 7261 7465 2861 7578 3a3a nsfer_rate(aux:: │ │ │ -000552d0: 7374 6174 3a3a 646f 776e 6c6f 6164 5f70 stat::download_p │ │ │ -000552e0: 6179 6c6f 6164 2920 2f20 7065 6572 735f ayload) / peers_ │ │ │ -000552f0: 7769 7468 5f72 6571 7565 7374 733b 0a3c with_requests;.< │ │ │ -00055300: 2f64 6976 3e09 097d 0a09 0965 6c73 650a /div>..}...else. │ │ │ -00055310: 0909 7b0a 0909 092f 2f20 6375 7272 656e ..{....// curren │ │ │ -00055320: 7420 646f 776e 6c6f 6164 2072 6174 6520 t download rate │ │ │ -00055330: 696e 2062 7974 6573 2070 6572 2073 6563 in bytes per sec │ │ │ -00055340: 6f6e 6473 0a09 0909 7261 7465 203d 206d onds....rate = m │ │ │ -00055350: 5f73 7461 7469 7374 6963 732e 7472 616e _statistics.tran │ │ │ -00055360: 7366 6572 5f72 6174 6528 6175 783a 3a73 sfer_rate(aux::s │ │ │ -00055370: 7461 743a 3a64 6f77 6e6c 6f61 645f 7061 tat::download_pa │ │ │ -00055380: 796c 6f61 6429 3b0a 0909 7d0a 0a09 092f yload);...}..../ │ │ │ -00055390: 2f20 6176 6f69 6420 6469 7669 7369 6f6e / avoid division │ │ │ -000553a0: 2062 7920 7a65 726f 0a09 0969 6620 2872 by zero...if (r │ │ │ -000553b0: 6174 6520 266c 743b 2035 3029 2072 6174 ate < 50) rat │ │ │ -000553c0: 6520 3d20 3530 3b0a 0a09 092f 2f20 6176 e = 50;....// av │ │ │ -000553d0: 6572 6167 6520 6f66 2063 7572 7265 6e74 erage of current │ │ │ -000553e0: 2072 6174 6520 616e 6420 7065 616b 0a2f rate and peak./ │ │ │ -000553f0: 2f09 0972 6174 6520 3d20 2872 6174 6520 /..rate = (rate │ │ │ -00055400: 2b20 6d5f 646f 776e 6c6f 6164 5f72 6174 + m_download_rat │ │ │ -00055410: 655f 7065 616b 2920 2f20 323b 0a0a 0909 e_peak) / 2;.... │ │ │ -00055420: 7265 7475 726e 206d 696c 6c69 7365 636f return milliseco │ │ │ -00055430: 6e64 7328 2873 7464 3a3a 696e 7436 345f nds((std::int64_ │ │ │ -00055440: 7428 6d5f 6f75 7473 7461 6e64 696e 675f t(m_outstanding_ │ │ │ -00055450: 6279 7465 7329 202b 2065 7874 7261 5f62 bytes) + extra_b │ │ │ -00055460: 7974 6573 0a09 0909 0909 0909 092b 2073 ytes.........+ s │ │ │ -00055470: 7464 3a3a 696e 7436 345f 7428 6d5f 7175 td::int64_t(m_qu │ │ │ -00055480: 6575 6564 5f74 696d 655f 6372 6974 6963 eued_time_critic │ │ │ -00055490: 616c 2920 2a20 742d 2667 743b 626c 6f63 al) * t->bloc │ │ │ -000554a0: 6b5f 7369 7a65 2829 202a 2031 3030 3029 k_size() * 1000) │ │ │ -000554b0: 0a09 0909 2f20 7261 7465 293b 0a09 7d0a ..../ rate);..}. │ │ │ -000554c0: 0a09 766f 6964 2070 6565 725f 636f 6e6e ..void peer_conn │ │ │ -000554d0: 6563 7469 6f6e 3a3a 6164 645f 7374 6174 ection::add_stat │ │ │ -000554e0: 2873 7464 3a3a 696e 7436 345f 7420 636f (std::int64_t co │ │ │ -000554f0: 6e73 7420 646f 776e 6c6f 6164 6564 2c20 nst downloaded, │ │ │ -00055500: 7374 643a 3a69 6e74 3634 5f74 2063 6f6e std::int64_t con │ │ │ -00055510: 7374 2075 706c 6f61 6465 6429 0a09 7b0a st uploaded)..{. │ │ │ -00055520: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00055530: 2869 735f 7369 6e67 6c65 5f74 6872 6561 (is_single_threa │ │ │ -00055540: 6428 2929 3b0a 0909 6d5f 7374 6174 6973 d());...m_statis │ │ │ -00055550: 7469 6373 2e61 6464 5f73 7461 7428 646f tics.add_stat(do │ │ │ -00055560: 776e 6c6f 6164 6564 2c20 7570 6c6f 6164 wnloaded, upload │ │ │ -00055570: 6564 293b 0a09 7d0a 0a09 7368 6131 5f68 ed);..}...sha1_h │ │ │ -00055580: 6173 6820 7065 6572 5f63 6f6e 6e65 6374 ash peer_connect │ │ │ -00055590: 696f 6e3a 3a61 7373 6f63 6961 7465 645f ion::associated_ │ │ │ -000555a0: 696e 666f 5f68 6173 6828 2920 636f 6e73 info_hash() cons │ │ │ -000555b0: 740a 097b 0a09 0961 7574 6f20 7420 3d20 t..{...auto t = │ │ │ -000555c0: 6173 736f 6369 6174 6564 5f74 6f72 7265 associated_torre │ │ │ -000555d0: 6e74 2829 2e6c 6f63 6b28 293b 0a09 0954 nt().lock();...T │ │ │ -000555e0: 4f52 5245 4e54 5f41 5353 4552 5428 7429 ORRENT_ASSERT(t) │ │ │ -000555f0: 3b0a 0909 6175 746f 2063 6f6e 7374 2661 ;...auto const&a │ │ │ -00055600: 6d70 3b20 6968 203d 2074 2d26 6774 3b69 mp; ih = t->i │ │ │ -00055610: 6e66 6f5f 6861 7368 2829 3b0a 0909 2f2f nfo_hash();...// │ │ │ -00055620: 2061 2070 6565 7227 7320 7072 6f74 6f63 a peer's protoc │ │ │ -00055630: 6f6c 5f76 3220 666c 6167 206d 6179 2062 ol_v2 flag may b │ │ │ -00055640: 6520 7365 7420 7370 6563 756c 6174 6976 e set speculativ │ │ │ -00055650: 656c 7920 7768 696c 6520 6d65 7461 6461 ely while metada │ │ │ -00055660: 7461 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ta.
    │ │ │ -00055690: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -000556a0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -000556d0: 2f73 7263 2f70 6565 725f 636f 6e6e 6563 /src/peer_connec │ │ │ -000556e0: 7469 6f6e 2e63 7070 3a31 3139 323c 2f61 tion.cpp:1192store │ │ │ -00055700: 7468 6520 7361 6832 3536 2068 6173 6820 the sah256 hash │ │ │ -00055710: 6f66 2074 6865 2064 6573 7469 6e61 7469 of the destinati │ │ │ -00055720: 6f6e 2069 6e20 7468 6520 6932 705f 7065 on in the i2p_pe │ │ │ -00055730: 6572 2073 7472 7563 742c 2073 6f20 7765 er struct, so we │ │ │ -00055740: 2064 6f6e 2774 2068 6176 6520 746f 2072 don't have to r │ │ │ -00055750: 6563 6f6d 7075 7465 2069 7420 6576 6572 ecompute it ever │ │ │ -00055760: 7920 7469 6d65 3c2f 7464 3e3c 2f74 723e y time │ │ │ -00055770: 3c74 7220 6964 3d22 3230 3222 2073 7479 │ │ │ -000557a0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000557b0: 3c68 323e 7374 6f72 6520 7468 6520 7361

    store the sa │ │ │ -000557c0: 6832 3536 2068 6173 6820 6f66 2074 6865 h256 hash of the │ │ │ -000557d0: 2064 6573 7469 6e61 7469 6f6e 2069 6e20 destination in │ │ │ -000557e0: 7468 650a 6932 705f 7065 6572 2073 7472 the.i2p_peer str │ │ │ -000557f0: 7563 742c 2073 6f20 7765 2064 6f6e 2774 uct, so we don't │ │ │ -00055800: 2068 6176 6520 746f 2072 6563 6f6d 7075 have to recompu │ │ │ -00055810: 7465 2069 7420 6576 6572 7920 7469 6d65 te it every time │ │ │ -00055820: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00055830: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ -00055840: 6370 703a 3131 3932 3c2f 6834 3e3c 7072 cpp:1192

    ..auto t │ │ │ -00055890: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b = m_torrent.lock │ │ │ -000558a0: 2829 3b0a 0909 6966 2028 2174 2920 7265 ();...if (!t) re │ │ │ -000558b0: 7475 726e 3b0a 0909 742d 2667 743b 7365 turn;...t->se │ │ │ -000558c0: 6e74 5f73 796e 2869 7076 3629 3b0a 097d nt_syn(ipv6);..} │ │ │ -000558d0: 0a0a 0976 6f69 6420 7065 6572 5f63 6f6e ...void peer_con │ │ │ -000558e0: 6e65 6374 696f 6e3a 3a72 6563 6569 7665 nection::receive │ │ │ -000558f0: 645f 7379 6e61 636b 2862 6f6f 6c20 636f d_synack(bool co │ │ │ -00055900: 6e73 7420 6970 7636 290a 097b 0a09 0954 nst ipv6)..{...T │ │ │ -00055910: 4f52 5245 4e54 5f41 5353 4552 5428 6973 ORRENT_ASSERT(is │ │ │ -00055920: 5f73 696e 676c 655f 7468 7265 6164 2829 _single_thread() │ │ │ -00055930: 293b 0a09 096d 5f73 7461 7469 7374 6963 );...m_statistic │ │ │ -00055940: 732e 7265 6365 6976 6564 5f73 796e 6163 s.received_synac │ │ │ -00055950: 6b28 6970 7636 293b 0a09 0969 6620 286d k(ipv6);...if (m │ │ │ -00055960: 5f69 676e 6f72 655f 7374 6174 7329 2072 _ignore_stats) r │ │ │ -00055970: 6574 7572 6e3b 0a09 0961 7574 6f20 7420 eturn;...auto t │ │ │ -00055980: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b = m_torrent.lock │ │ │ -00055990: 2829 3b0a 0909 6966 2028 2174 2920 7265 ();...if (!t) re │ │ │ -000559a0: 7475 726e 3b0a 0909 742d 2667 743b 7265 turn;...t->re │ │ │ -000559b0: 6365 6976 6564 5f73 796e 6163 6b28 6970 ceived_synack(ip │ │ │ -000559c0: 7636 293b 0a09 7d0a 0a09 7065 6572 5f65 v6);..}...peer_e │ │ │ -000559d0: 6e64 706f 696e 745f 7420 7065 6572 5f63 ndpoint_t peer_c │ │ │ -000559e0: 6f6e 6e65 6374 696f 6e3a 3a72 656d 6f74 onnection::remot │ │ │ -000559f0: 655f 656e 6470 6f69 6e74 2829 2063 6f6e e_endpoint() con │ │ │ -00055a00: 7374 0a09 7b0a 2369 6620 544f 5252 454e st..{.#if TORREN │ │ │ -00055a10: 545f 5553 455f 4932 500a 0909 6966 2028 T_USE_I2P...if ( │ │ │ -00055a20: 6175 746f 2073 203d 2073 7464 3a3a 6765 auto s = std::ge │ │ │ -00055a30: 745f 6966 266c 743b 6932 705f 7374 7265 t_if<i2p_stre │ │ │ -00055a40: 616d 2667 743b 2826 616d 703b 6d5f 736f am>(&m_so │ │ │ -00055a50: 636b 6574 2929 0a09 097b 0a3c 6469 7620 cket))...{.
    ...retu │ │ │ -00055a90: 726e 2068 6173 6865 7232 3536 2862 6173 rn hasher256(bas │ │ │ -00055aa0: 6536 3464 6563 6f64 655f 6932 7028 732d e64decode_i2p(s- │ │ │ -00055ab0: 2667 743b 6465 7374 696e 6174 696f 6e28 >destination( │ │ │ -00055ac0: 2929 292e 6669 6e61 6c28 293b 0a3c 2f64 ))).final();...}.#endif... │ │ │ -00055ae0: 7265 7475 726e 206d 5f72 656d 6f74 653b return m_remote; │ │ │ -00055af0: 0a09 7d0a 0a23 6966 2054 4f52 5245 4e54 ..}..#if TORRENT │ │ │ -00055b00: 5f55 5345 5f49 3250 0a09 7374 643a 3a73 _USE_I2P..std::s │ │ │ -00055b10: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -00055b20: 2070 6565 725f 636f 6e6e 6563 7469 6f6e peer_connection │ │ │ -00055b30: 3a3a 6465 7374 696e 6174 696f 6e28 2920 ::destination() │ │ │ -00055b40: 636f 6e73 740a 097b 0a09 0973 7461 7469 const..{...stati │ │ │ -00055b50: 6320 7374 643a 3a73 7472 696e 6720 636f c std::string co │ │ │ -00055b60: 6e73 7420 656d 7074 793b 0a09 0961 7574 nst empty;...aut │ │ │ -00055b70: 6f20 7320 3d20 7374 643a 3a67 6574 5f69 o s = std::get_i │ │ │ -00055b80: 6626 6c74 3b69 3270 5f73 7472 6561 6d26 f<i2p_stream& │ │ │ -00055b90: 6774 3b28 2661 6d70 3b6d 5f73 6f63 6b65 gt;(&m_socke │ │ │ -00055ba0: 7429 3b0a 0909 7265 7475 726e 2073 203f t);...return s ? │ │ │ -00055bb0: 2073 2d26 6774 3b64 6573 7469 6e61 7469 s->destinati │ │ │ -00055bc0: 6f6e 2829 203a 2065 6d70 7479 3b0a 097d on() : empty;..} │ │ │ -00055bd0: 0a0a 0973 7464 3a3a 7374 7269 6e67 2063 ...std::string c │ │ │ -00055be0: 6f6e 7374 2661 6d70 3b20 7065 6572 5f63 onst& peer_c │ │ │ -00055bf0: 6f6e 6e65 6374 696f 6e3a 3a6c 6f63 616c onnection::local │ │ │ -00055c00: 5f69 3270 5f65 6e64 706f 696e 7428 2920 _i2p_endpoint() │ │ │ -00055c10: 636f 6e73 740a 097b 0a09 0973 7461 7469 const..{...stati │ │ │ -00055c20: 6320 7374 643a 3a73 7472 696e 6720 636f c std::string co │ │ │ -00055c30: 6e73 7420 656d 7074 793b 0a09 0961 7574 nst empty;...aut │ │ │ -00055c40: 6f20 7320 3d20 7374 643a 3a67 6574 5f69 o s = std::get_i │ │ │ -00055c50: 6626 6c74 3b69 3270 5f73 7472 6561 6d26 f<i2p_stream& │ │ │ -00055c60: 6774 3b28 2661 6d70 3b6d 5f73 6f63 6b65 gt;(&m_socke │ │ │ -00055c70: 7429 3b0a 0909 7265 7475 726e 2073 203f t);...return s ? │ │ │ -00055c80: 2073 2d26 6774 3b6c 6f63 616c 5f69 3270 s->local_i2p │ │ │ -00055c90: 5f65 6e64 706f 696e 7428 2920 3a20 656d _endpoint() : em │ │ │ -00055ca0: 7074 793b 0a09 7d0a 2365 6e64 6966 0a0a pty;..}.#endif.. │ │ │ -00055cb0: 0974 7970 6564 5f62 6974 6669 656c 6426 .typed_bitfield& │ │ │ -00055cc0: 6c74 3b70 6965 6365 5f69 6e64 6578 5f74 lt;piece_index_t │ │ │ -00055cd0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ -00055ce0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ -00055cf0: 3a67 6574 5f62 6974 6669 656c 6428 2920 :get_bitfield() │ │ │ -00055d00: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ -00055d10: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ -00055d20: 676c 655f 7468 7265 6164 2829 293b 0a09 gle_thread());.. │ │ │ -00055d30: 0972 6574 7572 6e20 6d5f 6861 7665 5f70 .return m_have_p │ │ │ -00055d40: 6965 6365 3b0a 097d 0a0a 0976 6f69 6420 iece;..}...void │ │ │ -00055d50: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ -00055d60: 3a72 6563 6569 7665 645f 7661 6c69 645f :received_valid_ │ │ │ -00055d70: 6461 7461 2870 6965 6365 5f69 6e64 6578 data(piece_index │ │ │ -00055d80: 5f74 2063 6f6e 7374 2069 6e64 6578 290a _t const index). │ │ │ -00055d90: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ -00055da0: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ -00055db0: 7265 6164 2829 293b 0a3c 2f70 7265 3e3c read());.< │ │ │ -00055dc0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00055df0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00055e00: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/peer_ │ │ │ -00055e30: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a33 connection.cpp:3 │ │ │ -00055e40: 3535 333c 2f61 3e3c 2f74 643e 3c74 643e 553 │ │ │ -00055e50: 736f 7274 2074 6865 2061 6c6c 6f77 6564 sort the allowed │ │ │ -00055e60: 2066 6173 7420 7365 7420 696e 2070 7269 fast set in pri │ │ │ -00055e70: 6f72 6974 7920 6f72 6465 723c 2f74 643e ority order │ │ │ -00055e80: 3c2f 7472 3e3c 7472 2069 643d 2232 3033

    sort th │ │ │ -00055ed0: 6520 616c 6c6f 7765 6420 6661 7374 2073 e allowed fast s │ │ │ -00055ee0: 6574 2069 6e20 7072 696f 7269 7479 206f et in priority o │ │ │ -00055ef0: 7264 6572 3c2f 6832 3e3c 6834 3e2e 2e2f rder

    ../ │ │ │ -00055f00: 7372 632f 7065 6572 5f63 6f6e 6e65 6374 src/peer_connect │ │ │ -00055f10: 696f 6e2e 6370 703a 3335 3533 3c2f 6834 ion.cpp:3553

    ...//
    │ │ │ -00055f60: 2069 6620 7468 6520 7065 6572 2068 6173   if the peer has
    │ │ │ -00055f70: 2074 6865 2070 6965 6365 2061 6e64 2077   the piece and w
    │ │ │ -00055f80: 6520 7761 6e74 0a09 092f 2f20 746f 2064  e want...// to d
    │ │ │ -00055f90: 6f77 6e6c 6f61 6420 6974 2c20 7265 7175  ownload it, requ
    │ │ │ -00055fa0: 6573 7420 6974 0a09 0969 6620 2869 6e64  est it...if (ind
    │ │ │ -00055fb0: 6578 2026 6c74 3b20 6d5f 6861 7665 5f70  ex < m_have_p
    │ │ │ -00055fc0: 6965 6365 2e65 6e64 5f69 6e64 6578 2829  iece.end_index()
    │ │ │ -00055fd0: 0a09 0909 2661 6d70 3b26 616d 703b 206d  ....&& m
    │ │ │ -00055fe0: 5f68 6176 655f 7069 6563 655b 696e 6465  _have_piece[inde
    │ │ │ -00055ff0: 785d 0a09 0909 2661 6d70 3b26 616d 703b  x]....&&
    │ │ │ -00056000: 2021 742d 2667 743b 6861 7665 5f70 6965   !t->have_pie
    │ │ │ -00056010: 6365 2869 6e64 6578 290a 0909 0926 616d  ce(index)....&am
    │ │ │ -00056020: 703b 2661 6d70 3b20 742d 2667 743b 7661  p;& t->va
    │ │ │ -00056030: 6c69 645f 6d65 7461 6461 7461 2829 0a09  lid_metadata()..
    │ │ │ -00056040: 0909 2661 6d70 3b26 616d 703b 2074 2d26  ..&& t-&
    │ │ │ -00056050: 6774 3b68 6173 5f70 6963 6b65 7228 290a  gt;has_picker().
    │ │ │ -00056060: 0909 0926 616d 703b 2661 6d70 3b20 742d  ...&& t-
    │ │ │ -00056070: 2667 743b 7069 636b 6572 2829 2e70 6965  >picker().pie
    │ │ │ -00056080: 6365 5f70 7269 6f72 6974 7928 696e 6465  ce_priority(inde
    │ │ │ -00056090: 7829 2026 6774 3b20 646f 6e74 5f64 6f77  x) > dont_dow
    │ │ │ -000560a0: 6e6c 6f61 6429 0a09 097b 0a09 0909 742d  nload)...{....t-
    │ │ │ -000560b0: 2667 743b 7065 6572 5f69 735f 696e 7465  >peer_is_inte
    │ │ │ -000560c0: 7265 7374 696e 6728 2a74 6869 7329 3b0a  resting(*this);.
    │ │ │ -000560d0: 0909 7d0a 097d 0a0a 0973 7464 3a3a 7665  ..}..}...std::ve
    │ │ │ -000560e0: 6374 6f72 266c 743b 7069 6563 655f 696e  ctor<piece_in
    │ │ │ -000560f0: 6465 785f 7426 6774 3b20 636f 6e73 7426  dex_t> const&
    │ │ │ -00056100: 616d 703b 2070 6565 725f 636f 6e6e 6563  amp; peer_connec
    │ │ │ -00056110: 7469 6f6e 3a3a 616c 6c6f 7765 645f 6661  tion::allowed_fa
    │ │ │ -00056120: 7374 2829 0a09 7b0a 0909 544f 5252 454e  st()..{...TORREN
    │ │ │ -00056130: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ -00056140: 6c65 5f74 6872 6561 6428 2929 3b0a 0909  le_thread());...
    │ │ │ -00056150: 6175 746f 2074 203d 206d 5f74 6f72 7265  auto t = m_torre
    │ │ │ -00056160: 6e74 2e6c 6f63 6b28 293b 0a09 0954 4f52  nt.lock();...TOR
    │ │ │ -00056170: 5245 4e54 5f41 5353 4552 5428 7429 3b0a  RENT_ASSERT(t);.
    │ │ │ -00056180: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000561b0: 0972 6574 7572 6e20 6d5f 616c 6c6f 7765 .return m_allowe │ │ │ -000561c0: 645f 6661 7374 3b0a 3c2f 6469 763e 097d d_fast;.
    .} │ │ │ -000561d0: 0a0a 0962 6f6f 6c20 7065 6572 5f63 6f6e ...bool peer_con │ │ │ -000561e0: 6e65 6374 696f 6e3a 3a63 616e 5f72 6571 nection::can_req │ │ │ -000561f0: 7565 7374 5f74 696d 655f 6372 6974 6963 uest_time_critic │ │ │ -00056200: 616c 2829 2063 6f6e 7374 0a09 7b0a 0909 al() const..{... │ │ │ -00056210: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ -00056220: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ -00056230: 2929 3b0a 0909 6966 2028 6861 735f 7065 ));...if (has_pe │ │ │ -00056240: 6572 5f63 686f 6b65 6428 2920 7c7c 2021 er_choked() || ! │ │ │ -00056250: 6973 5f69 6e74 6572 6573 7469 6e67 2829 is_interesting() │ │ │ -00056260: 2920 7265 7475 726e 2066 616c 7365 3b0a ) return false;. │ │ │ -00056270: 0909 6966 2028 696e 7428 6d5f 646f 776e ..if (int(m_down │ │ │ -00056280: 6c6f 6164 5f71 7565 7565 2e73 697a 6528 load_queue.size( │ │ │ -00056290: 2929 202b 2069 6e74 286d 5f72 6571 7565 )) + int(m_reque │ │ │ -000562a0: 7374 5f71 7565 7565 2e73 697a 6528 2929 st_queue.size()) │ │ │ -000562b0: 0a09 0909 2667 743b 206d 5f64 6573 6972 ....> m_desir │ │ │ -000562c0: 6564 5f71 7565 7565 5f73 697a 6520 2a20 ed_queue_size * │ │ │ -000562d0: 3229 2072 6574 7572 6e20 6661 6c73 653b 2) return false; │ │ │ -000562e0: 0a09 0969 6620 286f 6e5f 7061 726f 6c65 ...if (on_parole │ │ │ -000562f0: 2829 2920 7265 7475 726e 2066 616c 7365 ()) return false │ │ │ -00056300: 3b0a 0909 6966 2028 6d5f 6469 7363 6f6e ;...if (m_discon │ │ │ -00056310: 6e65 6374 696e 6729 2072 6574 7572 6e20 necting) return │ │ │ -00056320: 6661 6c73 653b 0a09 0961 7574 6f20 7420 false;...auto t │ │ │ -00056330: 3d20 6d5f 746f 7272 656e 742e 6c6f 636b = m_torrent.lock │ │ │ -00056340: 2829 3b0a 0909 544f 5252 454e 545f 4153 ();...TORRENT_AS │ │ │ -00056350: 5345 5254 2874 293b 0a09 0969 6620 2874 SERT(t);...if (t │ │ │ -00056360: 2d26 6774 3b75 706c 6f61 645f 6d6f 6465 ->upload_mode │ │ │ -00056370: 2829 2920 7265 7475 726e 2066 616c 7365 ()) return false │ │ │ -00056380: 3b0a 0a09 092f 2f20 6967 6e6f 7265 2073 ;....// ignore s │ │ │ -00056390: 6e75 6262 6564 2070 6565 7273 2c20 7369 nubbed peers, si │ │ │ -000563a0: 6e63 6520 7468 6579 2772 6520 6e6f 7420 nce they're not │ │ │ -000563b0: 6c69 6b65 6c79 2074 6f20 7265 7475 726e likely to return │ │ │ -000563c0: 2070 6965 6365 7320 696e 2061 0a09 092f pieces in a.../ │ │ │ -000563d0: 2f20 7469 6d65 6c79 206d 616e 6e65 7220 / timely manner │ │ │ -000563e0: 616e 7977 6179 0a09 0969 6620 286d 5f73 anyway...if (m_s │ │ │ -000563f0: 6e75 6262 6564 2920 7265 7475 726e 2066 nubbed) return f │ │ │ -00056400: 616c 7365 3b0a 0909 7265 7475 726e 2074 alse;...return t │ │ │ -00056410: 7275 653b 0a09 7d0a 0a09 626f 6f6c 2070 rue;..}...bool p │ │ │ -00056420: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a eer_connection:: │ │ │ -00056430: 6d61 6b65 5f74 696d 655f 6372 6974 6963 make_time_critic │ │ │ -00056440: 616c 2870 6965 6365 5f62 6c6f 636b 2063 al(piece_block c │ │ │ -00056450: 6f6e 7374 2661 6d70 3b20 626c 6f63 6b29 onst& block) │ │ │ -00056460: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ -00056470: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ -00056480: 6872 6561 6428 2929 3b0a 0909 6175 746f hread());...auto │ │ │ -00056490: 2063 6f6e 7374 2072 6974 203d 2073 7464 const rit = std │ │ │ -000564a0: 3a3a 6669 6e64 5f69 6628 6d5f 7265 7175 ::find_if(m_requ │ │ │ -000564b0: 6573 745f 7175 6575 652e 6265 6769 6e28 est_queue.begin( │ │ │ -000564c0: 290a 0909 092c 206d 5f72 6571 7565 7374 )...., m_request │ │ │ -000564d0: 5f71 7565 7565 2e65 6e64 2829 2c20 6175 _queue.end(), au │ │ │ -000564e0: 783a 3a68 6173 5f62 6c6f 636b 2862 6c6f x::has_block(blo │ │ │ -000564f0: 636b 2929 3b0a 0909 6966 2028 7269 7420 ck));...if (rit │ │ │ -00056500: 3d3d 206d 5f72 6571 7565 7374 5f71 7565 == m_request_que │ │ │ -00056510: 7565 2e65 6e64 2829 2920 7265 7475 726e ue.end()) return │ │ │ -00056520: 2066 616c 7365 3b0a 2369 6620 544f 5252 false;.#if TORR │ │ │ -00056530: 454e 545f 5553 455f 4153 5345 5254 530a ENT_USE_ASSERTS. │ │ │ -00056540: 0909 6175 746f 2074 203d 206d 5f74 6f72 ..auto t = m_tor │ │ │ -00056550: 7265 6e74 2e6c 6f63 6b28 293b 0a09 0954 rent.lock();...T │ │ │ -00056560: 4f52 5245 4e54 5f41 5353 4552 5428 7429 ORRENT_ASSERT(t) │ │ │ -00056570: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ -00056580: 5254 2874 2d26 6774 3b68 6173 5f70 6963 RT(t->has_pic │ │ │ -00056590: 6b65 7228 2929 3b0a 3c2f 7072 653e 3c2f ker());.
    relevan │ │ │ -000565d0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/sessio │ │ │ -00056610: 6e5f 696d 706c 2e63 7070 3a35 3837 3c2f n_impl.cpp:587come │ │ │ -00056630: 7570 2077 6974 6820 736f 6d65 2061 6273 up with some abs │ │ │ -00056640: 7472 6163 7469 6f6e 2074 6f20 646f 2074 traction to do t │ │ │ -00056650: 6869 7320 666f 7220 676e 7574 6c73 2061 his for gnutls a │ │ │ -00056660: 7320 7765 6c6c 206c 6f61 6420 6365 7274 s well load cert │ │ │ -00056670: 6966 6963 6174 6573 2066 726f 6d20 7468 ificates from th │ │ │ -00056680: 6520 7769 6e64 6f77 7320 7379 7374 656d e windows system │ │ │ -00056690: 2063 6572 7469 6669 6361 7465 2073 746f certificate sto │ │ │ -000566a0: 7265 3c2f 7464 3e3c 2f74 723e 3c74 7220 re

    │ │ │ -000566f0: 636f 6d65 2075 7020 7769 7468 2073 6f6d come up with som │ │ │ -00056700: 6520 6162 7374 7261 6374 696f 6e20 746f e abstraction to │ │ │ -00056710: 2064 6f20 7468 6973 2066 6f72 2067 6e75 do this for gnu │ │ │ -00056720: 746c 7320 6173 2077 656c 6c0a 6c6f 6164 tls as well.load │ │ │ -00056730: 2063 6572 7469 6669 6361 7465 7320 6672 certificates fr │ │ │ -00056740: 6f6d 2074 6865 2077 696e 646f 7773 2073 om the windows s │ │ │ -00056750: 7973 7465 6d20 6365 7274 6966 6963 6174 ystem certificat │ │ │ -00056760: 6520 7374 6f72 653c 2f68 323e 3c68 343e e store

    │ │ │ -00056770: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -00056780: 6d70 6c2e 6370 703a 3538 373c 2f68 343e mpl.cpp:587

    │ │ │ -00056790: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .void 
    │ │ │ -000567d0: 7365 7373 696f 6e5f 696d 706c 3a3a 7374  session_impl::st
    │ │ │ -000567e0: 6172 745f 7365 7373 696f 6e28 290a 097b  art_session()..{
    │ │ │ -000567f0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -00056800: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -00056810: 0a09 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ -00056820: 7374 6172 7420 7365 7373 696f 6e22 293b  start session");
    │ │ │ -00056830: 0a23 656e 6469 660a 0a23 6966 2054 4f52  .#endif..#if TOR
    │ │ │ -00056840: 5245 4e54 5f55 5345 5f53 534c 0a09 0965  RENT_USE_SSL...e
    │ │ │ -00056850: 7272 6f72 5f63 6f64 6520 6563 3b0a 0909  rror_code ec;...
    │ │ │ -00056860: 6d5f 7373 6c5f 6374 782e 7365 745f 6f70  m_ssl_ctx.set_op
    │ │ │ -00056870: 7469 6f6e 7328 7373 6c3a 3a6e 6f5f 6c65  tions(ssl::no_le
    │ │ │ -00056880: 6761 6379 5f74 6c73 5f76 6572 7369 6f6e  gacy_tls_version
    │ │ │ -00056890: 732c 2065 6329 3b0a 2369 666e 6465 6620  s, ec);.#ifndef 
    │ │ │ -000568a0: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ -000568b0: 4c4f 4747 494e 470a 0909 6966 2028 6563  LOGGING...if (ec
    │ │ │ -000568c0: 290a 0909 0973 6573 7369 6f6e 5f6c 6f67  )....session_log
    │ │ │ -000568d0: 2822 5353 4c20 7365 745f 6f70 7469 6f6e  ("SSL set_option
    │ │ │ -000568e0: 7320 6661 696c 6564 3a20 2573 222c 2065  s failed: %s", e
    │ │ │ -000568f0: 632e 6d65 7373 6167 6528 292e 635f 7374  c.message().c_st
    │ │ │ -00056900: 7228 2929 3b0a 0909 6563 2e63 6c65 6172  r());...ec.clear
    │ │ │ -00056910: 2829 3b0a 2365 6e64 6966 0a09 096d 5f73  ();.#endif...m_s
    │ │ │ -00056920: 736c 5f63 7478 2e73 6574 5f64 6566 6175  sl_ctx.set_defau
    │ │ │ -00056930: 6c74 5f76 6572 6966 795f 7061 7468 7328  lt_verify_paths(
    │ │ │ -00056940: 6563 293b 0a23 6966 6e64 6566 2054 4f52  ec);.#ifndef TOR
    │ │ │ -00056950: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -00056960: 4749 4e47 0a09 0969 6620 2865 6329 2073  GING...if (ec) s
    │ │ │ -00056970: 6573 7369 6f6e 5f6c 6f67 2822 5353 4c20  ession_log("SSL 
    │ │ │ -00056980: 7365 745f 6465 6661 756c 7420 7665 7269  set_default veri
    │ │ │ -00056990: 6679 5f70 6174 6873 2066 6169 6c65 643a  fy_paths failed:
    │ │ │ -000569a0: 2025 7322 2c20 6563 2e6d 6573 7361 6765   %s", ec.message
    │ │ │ -000569b0: 2829 2e63 5f73 7472 2829 293b 0a09 0965  ().c_str());...e
    │ │ │ -000569c0: 632e 636c 6561 7228 293b 0a23 656e 6469  c.clear();.#endi
    │ │ │ -000569d0: 660a 2369 6620 6465 6669 6e65 6420 544f  f.#if defined TO
    │ │ │ -000569e0: 5252 454e 545f 5749 4e44 4f57 5320 2661  RRENT_WINDOWS &a
    │ │ │ -000569f0: 6d70 3b26 616d 703b 2064 6566 696e 6564  mp;& defined
    │ │ │ -00056a00: 2054 4f52 5245 4e54 5f55 5345 5f4f 5045   TORRENT_USE_OPE
    │ │ │ -00056a10: 4e53 534c 2026 616d 703b 2661 6d70 3b20  NSSL && 
    │ │ │ -00056a20: 2164 6566 696e 6564 2054 4f52 5245 4e54  !defined TORRENT
    │ │ │ -00056a30: 5f57 494e 5254 0a3c 6469 7620 7374 796c  _WINRT.
    ..X509_STOR │ │ │ -00056a70: 452a 2073 746f 7265 203d 2058 3530 395f E* store = X509_ │ │ │ -00056a80: 5354 4f52 455f 6e65 7728 293b 0a3c 2f64 STORE_new();...if (store). │ │ │ -00056aa0: 0909 7b0a 0909 0948 4345 5254 5354 4f52 ..{....HCERTSTOR │ │ │ -00056ab0: 4520 7379 7374 656d 5f73 746f 7265 203d E system_store = │ │ │ -00056ac0: 2043 6572 744f 7065 6e53 7973 7465 6d53 CertOpenSystemS │ │ │ -00056ad0: 746f 7265 4128 302c 2022 524f 4f54 2229 toreA(0, "ROOT") │ │ │ -00056ae0: 3b0a 0909 092f 2f20 7468 6973 2069 7320 ;....// this is │ │ │ -00056af0: 6265 7374 2065 6666 6f72 740a 0909 0969 best effort....i │ │ │ -00056b00: 6620 2873 7973 7465 6d5f 7374 6f72 6529 f (system_store) │ │ │ -00056b10: 0a09 0909 7b0a 0909 0909 4345 5254 5f43 ....{.....CERT_C │ │ │ -00056b20: 4f4e 5445 5854 2063 6f6e 7374 2a20 6374 ONTEXT const* ct │ │ │ -00056b30: 7820 3d20 6e75 6c6c 7074 723b 0a09 0909 x = nullptr;.... │ │ │ -00056b40: 0977 6869 6c65 2028 2863 7478 203d 2043 .while ((ctx = C │ │ │ -00056b50: 6572 7445 6e75 6d43 6572 7469 6669 6361 ertEnumCertifica │ │ │ -00056b60: 7465 7349 6e53 746f 7265 2873 7973 7465 tesInStore(syste │ │ │ -00056b70: 6d5f 7374 6f72 652c 2063 7478 2929 2021 m_store, ctx)) ! │ │ │ -00056b80: 3d20 6e75 6c6c 7074 7229 0a09 0909 097b = nullptr).....{ │ │ │ -00056b90: 0a09 0909 0909 756e 7369 676e 6564 2063 ......unsigned c │ │ │ -00056ba0: 6861 7220 636f 6e73 742a 2063 6572 745f har const* cert_ │ │ │ -00056bb0: 7074 7220 3d20 7265 696e 7465 7270 7265 ptr = reinterpre │ │ │ -00056bc0: 745f 6361 7374 266c 743b 756e 7369 676e t_cast<unsign │ │ │ -00056bd0: 6564 2063 6861 7220 636f 6e73 742a 2667 ed char const*&g │ │ │ -00056be0: 743b 2863 7478 2d26 6774 3b70 6243 6572 t;(ctx->pbCer │ │ │ -00056bf0: 7445 6e63 6f64 6564 293b 0a09 0909 0909 tEncoded);...... │ │ │ -00056c00: 5835 3039 2a20 7835 3039 203d 2064 3269 X509* x509 = d2i │ │ │ -00056c10: 5f58 3530 3928 6e75 6c6c 7074 722c 2026 _X509(nullptr, & │ │ │ -00056c20: 616d 703b 6365 7274 5f70 7472 2c20 6374 amp;cert_ptr, ct │ │ │ -00056c30: 782d 2667 743b 6362 4365 7274 456e 636f x->cbCertEnco │ │ │ -00056c40: 6465 6429 3b0a 0909 0909 092f 2f20 7468 ded);......// th │ │ │ -00056c50: 6973 2069 7320 6265 7374 2065 6666 6f72 is is best effor │ │ │ -00056c60: 740a 0909 0909 0969 6620 2821 7835 3039 t......if (!x509 │ │ │ -00056c70: 2920 636f 6e74 696e 7565 3b0a 0909 0909 ) continue;..... │ │ │ -00056c80: 0958 3530 395f 5354 4f52 455f 6164 645f .X509_STORE_add_ │ │ │ -00056c90: 6365 7274 2873 746f 7265 2c20 7835 3039 cert(store, x509 │ │ │ -00056ca0: 293b 0a09 0909 0909 5835 3039 5f66 7265 );......X509_fre │ │ │ -00056cb0: 6528 7835 3039 293b 0a09 0909 097d 0a09 e(x509);.....}.. │ │ │ -00056cc0: 0909 0943 6572 7446 7265 6543 6572 7469 ...CertFreeCerti │ │ │ -00056cd0: 6669 6361 7465 436f 6e74 6578 7428 6374 ficateContext(ct │ │ │ -00056ce0: 7829 3b0a 0909 0909 4365 7274 436c 6f73 x);.....CertClos │ │ │ -00056cf0: 6553 746f 7265 2873 7973 7465 6d5f 7374 eStore(system_st │ │ │ -00056d00: 6f72 652c 2030 293b 0a09 0909 7d0a 0909 ore, 0);....}... │ │ │ -00056d10: 7d0a 0a09 0953 534c 5f43 5458 2a20 7373 }....SSL_CTX* ss │ │ │ -00056d20: 6c5f 6374 7820 3d20 6d5f 7373 6c5f 6374 l_ctx = m_ssl_ct │ │ │ -00056d30: 782e 6e61 7469 7665 5f68 616e 646c 6528 x.native_handle( │ │ │ -00056d40: 293b 0a09 0953 534c 5f43 5458 5f73 6574 );...SSL_CTX_set │ │ │ -00056d50: 5f63 6572 745f 7374 6f72 6528 7373 6c5f _cert_store(ssl_ │ │ │ -00056d60: 6374 782c 2073 746f 7265 293b 0a23 656e ctx, store);.#en │ │ │ -00056d70: 6469 660a 2369 6664 6566 205f 5f41 5050 dif.#ifdef __APP │ │ │ -00056d80: 4c45 5f5f 0a09 096d 5f73 736c 5f63 7478 LE__...m_ssl_ctx │ │ │ -00056d90: 2e6c 6f61 645f 7665 7269 6679 5f66 696c .load_verify_fil │ │ │ -00056da0: 6528 222f 6574 632f 7373 6c2f 6365 7274 e("/etc/ssl/cert │ │ │ -00056db0: 2e70 656d 222c 2065 6329 3b0a 2369 666e .pem", ec);.#ifn │ │ │ -00056dc0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00056dd0: 424c 455f 4c4f 4747 494e 470a 0909 6966 BLE_LOGGING...if │ │ │ -00056de0: 2028 6563 2920 7365 7373 696f 6e5f 6c6f (ec) session_lo │ │ │ -00056df0: 6728 2253 534c 206c 6f61 645f 7665 7269 g("SSL load_veri │ │ │ -00056e00: 6679 5f66 696c 6520 6661 696c 6564 3a20 fy_file failed: │ │ │ -00056e10: 2573 222c 2065 632e 6d65 7373 6167 6528 %s", ec.message( │ │ │ -00056e20: 292e 635f 7374 7228 2929 3b0a 2365 6e64 ).c_str());.#end │ │ │ -00056e30: 6966 0a09 0965 632e 636c 6561 7228 293b if...ec.clear(); │ │ │ -00056e40: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00056e80: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0
    ../s │ │ │ -00056eb0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -00056ec0: 6370 703a 3134 3632 3c2f 613e 3c2f 7464 cpp:1462it would be │ │ │ -00056ee0: 206e 6963 6520 746f 2072 6573 6572 7665 nice to reserve │ │ │ -00056ef0: 2829 2074 6865 7365 2076 6563 746f 7273 () these vectors │ │ │ -00056f00: 2075 7020 6672 6f6e 743c 2f74 643e 3c2f up front

    it would │ │ │ -00056f60: 6265 206e 6963 6520 746f 2072 6573 6572 be nice to reser │ │ │ -00056f70: 7665 2829 2074 6865 7365 2076 6563 746f ve() these vecto │ │ │ -00056f80: 7273 2075 7020 6672 6f6e 743c 2f68 323e rs up front

    │ │ │ -00056f90: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ -00056fa0: 6f6e 5f69 6d70 6c2e 6370 703a 3134 3632 on_impl.cpp:1462 │ │ │ -00056fb0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00056ff0: 0909 6261 6e64 7769 6474 685f 6368 616e  ..bandwidth_chan
    │ │ │ -00057000: 6e65 6c2a 2063 6820 3d20 2661 6d70 3b70  nel* ch = &p
    │ │ │ -00057010: 2d26 6774 3b63 6861 6e6e 656c 5b70 6565  ->channel[pee
    │ │ │ -00057020: 725f 636f 6e6e 6563 7469 6f6e 3a3a 646f  r_connection::do
    │ │ │ -00057030: 776e 6c6f 6164 5f63 6861 6e6e 656c 5d3b  wnload_channel];
    │ │ │ -00057040: 0a09 0909 6966 2028 7573 655f 7175 6f74  ....if (use_quot
    │ │ │ -00057050: 615f 6f76 6572 6865 6164 2863 682c 2061  a_overhead(ch, a
    │ │ │ -00057060: 6d6f 756e 745f 646f 776e 2929 0a09 0909  mount_down))....
    │ │ │ -00057070: 0972 6574 207c 3d20 3175 2026 6c74 3b26  .ret |= 1u <&
    │ │ │ -00057080: 6c74 3b20 7065 6572 5f63 6f6e 6e65 6374  lt; peer_connect
    │ │ │ -00057090: 696f 6e3a 3a64 6f77 6e6c 6f61 645f 6368  ion::download_ch
    │ │ │ -000570a0: 616e 6e65 6c3b 0a09 0909 6368 203d 2026  annel;....ch = &
    │ │ │ -000570b0: 616d 703b 702d 2667 743b 6368 616e 6e65  amp;p->channe
    │ │ │ -000570c0: 6c5b 7065 6572 5f63 6f6e 6e65 6374 696f  l[peer_connectio
    │ │ │ -000570d0: 6e3a 3a75 706c 6f61 645f 6368 616e 6e65  n::upload_channe
    │ │ │ -000570e0: 6c5d 3b0a 0909 0969 6620 2875 7365 5f71  l];....if (use_q
    │ │ │ -000570f0: 756f 7461 5f6f 7665 7268 6561 6428 6368  uota_overhead(ch
    │ │ │ -00057100: 2c20 616d 6f75 6e74 5f75 7029 290a 0909  , amount_up))...
    │ │ │ -00057110: 0909 7265 7420 7c3d 2031 7520 266c 743b  ..ret |= 1u <
    │ │ │ -00057120: 266c 743b 2070 6565 725f 636f 6e6e 6563  < peer_connec
    │ │ │ -00057130: 7469 6f6e 3a3a 7570 6c6f 6164 5f63 6861  tion::upload_cha
    │ │ │ -00057140: 6e6e 656c 3b0a 0909 7d0a 0909 7265 7475  nnel;...}...retu
    │ │ │ -00057150: 726e 2072 6574 3b0a 097d 0a0a 092f 2f20  rn ret;..}...// 
    │ │ │ -00057160: 7365 7373 696f 6e5f 696d 706c 2069 7320  session_impl is 
    │ │ │ -00057170: 7265 7370 6f6e 7369 626c 6520 666f 7220  responsible for 
    │ │ │ -00057180: 6465 6c65 7469 6e67 2027 7061 636b 270a  deleting 'pack'.
    │ │ │ -00057190: 0976 6f69 6420 7365 7373 696f 6e5f 696d  .void session_im
    │ │ │ -000571a0: 706c 3a3a 6170 706c 795f 7365 7474 696e  pl::apply_settin
    │ │ │ -000571b0: 6773 5f70 6163 6b28 7374 643a 3a73 6861  gs_pack(std::sha
    │ │ │ -000571c0: 7265 645f 7074 7226 6c74 3b73 6574 7469  red_ptr<setti
    │ │ │ -000571d0: 6e67 735f 7061 636b 2667 743b 2070 6163  ngs_pack> pac
    │ │ │ -000571e0: 6b29 0a09 7b0a 0909 494e 5641 5249 414e  k)..{...INVARIAN
    │ │ │ -000571f0: 545f 4348 4543 4b3b 0a09 0961 7070 6c79  T_CHECK;...apply
    │ │ │ -00057200: 5f73 6574 7469 6e67 735f 7061 636b 5f69  _settings_pack_i
    │ │ │ -00057210: 6d70 6c28 2a70 6163 6b29 3b0a 097d 0a0a  mpl(*pack);..}..
    │ │ │ -00057220: 0973 6574 7469 6e67 735f 7061 636b 2073  .settings_pack s
    │ │ │ -00057230: 6573 7369 6f6e 5f69 6d70 6c3a 3a67 6574  ession_impl::get
    │ │ │ -00057240: 5f73 6574 7469 6e67 7328 2920 636f 6e73  _settings() cons
    │ │ │ -00057250: 740a 097b 0a09 0973 6574 7469 6e67 735f  t..{...settings_
    │ │ │ -00057260: 7061 636b 2072 6574 3b0a 3c64 6976 2073  pack ret;.
    ..for (i │ │ │ -000572a0: 6e74 2069 203d 2073 6574 7469 6e67 735f nt i = settings_ │ │ │ -000572b0: 7061 636b 3a3a 7374 7269 6e67 5f74 7970 pack::string_typ │ │ │ -000572c0: 655f 6261 7365 3b0a 3c2f 6469 763e 0909 e_base;.
    .. │ │ │ -000572d0: 0969 2026 6c74 3b20 7365 7474 696e 6773 .i < settings │ │ │ -000572e0: 5f70 6163 6b3a 3a6d 6178 5f73 7472 696e _pack::max_strin │ │ │ -000572f0: 675f 7365 7474 696e 675f 696e 7465 726e g_setting_intern │ │ │ -00057300: 616c 3b20 2b2b 6929 0a09 097b 0a09 0909 al; ++i)...{.... │ │ │ -00057310: 7265 742e 7365 745f 7374 7228 692c 206d ret.set_str(i, m │ │ │ -00057320: 5f73 6574 7469 6e67 732e 6765 745f 7374 _settings.get_st │ │ │ -00057330: 7228 6929 293b 0a09 097d 0a09 0966 6f72 r(i));...}...for │ │ │ -00057340: 2028 696e 7420 6920 3d20 7365 7474 696e (int i = settin │ │ │ -00057350: 6773 5f70 6163 6b3a 3a69 6e74 5f74 7970 gs_pack::int_typ │ │ │ -00057360: 655f 6261 7365 3b0a 0909 0969 2026 6c74 e_base;....i < │ │ │ -00057370: 3b20 7365 7474 696e 6773 5f70 6163 6b3a ; settings_pack: │ │ │ -00057380: 3a6d 6178 5f69 6e74 5f73 6574 7469 6e67 :max_int_setting │ │ │ -00057390: 5f69 6e74 6572 6e61 6c3b 202b 2b69 290a _internal; ++i). │ │ │ -000573a0: 0909 7b0a 0909 0972 6574 2e73 6574 5f69 ..{....ret.set_i │ │ │ -000573b0: 6e74 2869 2c20 6d5f 7365 7474 696e 6773 nt(i, m_settings │ │ │ -000573c0: 2e67 6574 5f69 6e74 2869 2929 3b0a 0909 .get_int(i));... │ │ │ -000573d0: 7d0a 0909 666f 7220 2869 6e74 2069 203d }...for (int i = │ │ │ -000573e0: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ -000573f0: 626f 6f6c 5f74 7970 655f 6261 7365 3b0a bool_type_base;. │ │ │ -00057400: 0909 0969 2026 6c74 3b20 7365 7474 696e ...i < settin │ │ │ -00057410: 6773 5f70 6163 6b3a 3a6d 6178 5f62 6f6f gs_pack::max_boo │ │ │ -00057420: 6c5f 7365 7474 696e 675f 696e 7465 726e l_setting_intern │ │ │ -00057430: 616c 3b20 2b2b 6929 0a09 097b 0a09 0909 al; ++i)...{.... │ │ │ -00057440: 7265 742e 7365 745f 626f 6f6c 2869 2c20 ret.set_bool(i, │ │ │ -00057450: 6d5f 7365 7474 696e 6773 2e67 6574 5f62 m_settings.get_b │ │ │ -00057460: 6f6f 6c28 6929 293b 0a09 097d 0a09 0972 ool(i));...}...r │ │ │ -00057470: 6574 7572 6e20 7265 743b 0a09 7d0a 0a6e eturn ret;..}..n │ │ │ -00057480: 616d 6573 7061 6365 207b 0a09 7465 6d70 amespace {..temp │ │ │ -00057490: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ -000574a0: 6520 5061 636b 2667 743b 0a09 696e 7420 e Pack>..int │ │ │ -000574b0: 6765 745f 7365 7474 696e 675f 696d 706c get_setting_impl │ │ │ -000574c0: 2850 6163 6b20 636f 6e73 7426 616d 703b (Pack const& │ │ │ -000574d0: 2070 2c20 696e 7420 6e61 6d65 2c20 696e p, int name, in │ │ │ -000574e0: 742a 290a 097b 2072 6574 7572 6e20 702e t*)..{ return p. │ │ │ -000574f0: 6765 745f 696e 7428 6e61 6d65 293b 207d get_int(name); } │ │ │ -00057500: 0a0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ -00057510: 7479 7065 6e61 6d65 2050 6163 6b26 6774 typename Pack> │ │ │ -00057520: 3b0a 0962 6f6f 6c20 6765 745f 7365 7474 ;..bool get_sett │ │ │ -00057530: 696e 675f 696d 706c 2850 6163 6b20 636f ing_impl(Pack co │ │ │ -00057540: 6e73 7426 616d 703b 2070 2c20 696e 7420 nst& p, int │ │ │ -00057550: 6e61 6d65 2c20 626f 6f6c 2a29 0a09 7b20 name, bool*)..{ │ │ │ -00057560: 7265 7475 726e 2070 2e67 6574 5f62 6f6f return p.get_boo │ │ │ -00057570: 6c28 6e61 6d65 293b 207d 0a0a 0974 656d l(name); }...tem │ │ │ -00057580: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -00057590: 6d65 2050 6163 6b26 6774 3b0a 0973 7464 me Pack>..std │ │ │ -000575a0: 3a3a 7374 7269 6e67 2067 6574 5f73 6574 ::string get_set │ │ │ -000575b0: 7469 6e67 5f69 6d70 6c28 5061 636b 2063 ting_impl(Pack c │ │ │ -000575c0: 6f6e 7374 2661 6d70 3b20 702c 2069 6e74 onst& p, int │ │ │ -000575d0: 206e 616d 652c 2073 7464 3a3a 7374 7269 name, std::stri │ │ │ -000575e0: 6e67 2a29 0a09 7b20 7265 7475 726e 2070 ng*)..{ return p │ │ │ -000575f0: 2e67 6574 5f73 7472 286e 616d 6529 3b20 .get_str(name); │ │ │ -00057600: 7d0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f }..
    │ │ │ -00057630: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00057640: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00057670: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -00057680: 6c2e 6370 703a 3230 3237 3c2f 613e 3c2f l.cpp:2027could thi │ │ │ -000576a0: 7320 6675 6e63 7469 6f6e 2062 6520 6d65 s function be me │ │ │ -000576b0: 7267 6564 2077 6974 6820 6578 7061 6e64 rged with expand │ │ │ -000576c0: 5f75 6e73 7065 6369 6669 6564 5f61 6464 _unspecified_add │ │ │ -000576d0: 7265 7373 6573 3f20 7269 6768 7420 6e6f resses? right no │ │ │ -000576e0: 7720 626f 7468 206c 6973 7465 6e5f 656e w both listen_en │ │ │ -000576f0: 6470 6f69 6e74 5f74 2061 6e64 206c 6973 dpoint_t and lis │ │ │ -00057700: 7465 6e5f 696e 7465 7266 6163 655f 7420 ten_interface_t │ │ │ -00057710: 6172 6520 616c 6d6f 7374 2069 6465 6e74 are almost ident │ │ │ -00057720: 6963 616c 2c20 6d61 7962 6520 7468 6520 ical, maybe the │ │ │ -00057730: 6c61 7474 6572 2063 6f75 6c64 2062 6520 latter could be │ │ │ -00057740: 7265 6d6f 7665 6420 746f 6f3c 2f74 643e removed too │ │ │ -00057750: 3c2f 7472 3e3c 7472 2069 643d 2232 3036

    could t │ │ │ -000577a0: 6869 7320 6675 6e63 7469 6f6e 2062 6520 his function be │ │ │ -000577b0: 6d65 7267 6564 2077 6974 6820 6578 7061 merged with expa │ │ │ -000577c0: 6e64 5f75 6e73 7065 6369 6669 6564 5f61 nd_unspecified_a │ │ │ -000577d0: 6464 7265 7373 6573 3f0a 7269 6768 7420 ddresses?.right │ │ │ -000577e0: 6e6f 7720 626f 7468 206c 6973 7465 6e5f now both listen_ │ │ │ -000577f0: 656e 6470 6f69 6e74 5f74 2061 6e64 206c endpoint_t and l │ │ │ -00057800: 6973 7465 6e5f 696e 7465 7266 6163 655f isten_interface_ │ │ │ -00057810: 7420 6172 6520 616c 6d6f 7374 0a69 6465 t are almost.ide │ │ │ -00057820: 6e74 6963 616c 2c20 6d61 7962 6520 7468 ntical, maybe th │ │ │ -00057830: 6520 6c61 7474 6572 2063 6f75 6c64 2062 e latter could b │ │ │ -00057840: 6520 7265 6d6f 7665 6420 746f 6f3c 2f68 e removed too

    ../src/ses │ │ │ -00057860: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3230 sion_impl.cpp:20 │ │ │ -00057870: 3237 3c2f 6834 3e3c 7072 6520 7374 796c 27

    ..session_log("
    │ │ │ -000578c0: 4641 5441 4c20 5345 5353 494f 4e20 4552  FATAL SESSION ER
    │ │ │ -000578d0: 524f 5220 2825 7320 3a20 2564 2920 5b25  ROR (%s : %d) [%
    │ │ │ -000578e0: 735d 220a 0909 092c 2065 632e 6361 7465  s]"...., ec.cate
    │ │ │ -000578f0: 676f 7279 2829 2e6e 616d 6528 292c 2065  gory().name(), e
    │ │ │ -00057900: 632e 7661 6c75 6528 292c 2065 632e 6d65  c.value(), ec.me
    │ │ │ -00057910: 7373 6167 6528 292e 635f 7374 7228 2929  ssage().c_str())
    │ │ │ -00057920: 3b0a 2365 6e64 6966 0a09 0974 6869 732d  ;.#endif...this-
    │ │ │ -00057930: 2667 743b 6162 6f72 7428 293b 0a09 7d0a  >abort();..}.
    │ │ │ -00057940: 0a09 766f 6964 2073 6573 7369 6f6e 5f69  ..void session_i
    │ │ │ -00057950: 6d70 6c3a 3a6f 6e5f 6970 5f63 6861 6e67  mpl::on_ip_chang
    │ │ │ -00057960: 6528 6572 726f 725f 636f 6465 2063 6f6e  e(error_code con
    │ │ │ -00057970: 7374 2661 6d70 3b20 6563 290a 097b 0a23  st& ec)..{.#
    │ │ │ -00057980: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -00057990: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ -000579a0: 0969 6620 2821 6563 290a 0909 0973 6573  .if (!ec)....ses
    │ │ │ -000579b0: 7369 6f6e 5f6c 6f67 2822 7265 6365 6976  sion_log("receiv
    │ │ │ -000579c0: 6564 2069 7020 6368 616e 6765 2066 726f  ed ip change fro
    │ │ │ -000579d0: 6d20 696e 7465 726e 616c 2069 705f 6e6f  m internal ip_no
    │ │ │ -000579e0: 7469 6669 6572 2229 3b0a 0909 656c 7365  tifier");...else
    │ │ │ -000579f0: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728  ....session_log(
    │ │ │ -00057a00: 2272 6563 6569 7665 6420 6572 726f 7220  "received error 
    │ │ │ -00057a10: 6f6e 5f69 705f 6368 616e 6765 3a20 2564  on_ip_change: %d
    │ │ │ -00057a20: 2c20 2573 222c 2065 632e 7661 6c75 6528  , %s", ec.value(
    │ │ │ -00057a30: 292c 2065 632e 6d65 7373 6167 6528 292e  ), ec.message().
    │ │ │ -00057a40: 635f 7374 7228 2929 3b0a 2365 6e64 6966  c_str());.#endif
    │ │ │ -00057a50: 0a09 0969 6620 2865 6320 7c7c 206d 5f61  ...if (ec || m_a
    │ │ │ -00057a60: 626f 7274 207c 7c20 216d 5f69 705f 6e6f  bort || !m_ip_no
    │ │ │ -00057a70: 7469 6669 6572 2920 7265 7475 726e 3b0a  tifier) return;.
    │ │ │ -00057a80: 0909 6d5f 6970 5f6e 6f74 6966 6965 722d  ..m_ip_notifier-
    │ │ │ -00057a90: 2667 743b 6173 796e 635f 7761 6974 285b  >async_wait([
    │ │ │ -00057aa0: 7468 6973 5d20 2865 7272 6f72 5f63 6f64  this] (error_cod
    │ │ │ -00057ab0: 6520 636f 6e73 7426 616d 703b 2065 290a  e const& e).
    │ │ │ -00057ac0: 0909 097b 2077 7261 7028 2661 6d70 3b73  ...{ wrap(&s
    │ │ │ -00057ad0: 6573 7369 6f6e 5f69 6d70 6c3a 3a6f 6e5f  ession_impl::on_
    │ │ │ -00057ae0: 6970 5f63 6861 6e67 652c 2065 293b 207d  ip_change, e); }
    │ │ │ -00057af0: 293b 0a09 0972 656f 7065 6e5f 6e65 7477  );...reopen_netw
    │ │ │ -00057b00: 6f72 6b5f 736f 636b 6574 7328 7b7d 293b  ork_sockets({});
    │ │ │ -00057b10: 0a09 7d0a 0a3c 6469 7620 7374 796c 653d  ..}..
    .void interfa │ │ │ -00057b50: 6365 5f74 6f5f 656e 6470 6f69 6e74 7328 ce_to_endpoints( │ │ │ -00057b60: 6c69 7374 656e 5f69 6e74 6572 6661 6365 listen_interface │ │ │ -00057b70: 5f74 2063 6f6e 7374 2661 6d70 3b20 6966 _t const& if │ │ │ -00057b80: 6163 650a 3c2f 6469 763e 0909 2c20 6c69 ace.
    .., li │ │ │ -00057b90: 7374 656e 5f73 6f63 6b65 745f 666c 6167 sten_socket_flag │ │ │ -00057ba0: 735f 7420 666c 6167 730a 0909 2c20 7370 s_t flags..., sp │ │ │ -00057bb0: 616e 266c 743b 6970 5f69 6e74 6572 6661 an<ip_interfa │ │ │ -00057bc0: 6365 2063 6f6e 7374 2667 743b 2063 6f6e ce const> con │ │ │ -00057bd0: 7374 2069 6673 0a09 092c 2073 7464 3a3a st ifs..., std:: │ │ │ -00057be0: 7665 6374 6f72 266c 743b 6c69 7374 656e vector<listen │ │ │ -00057bf0: 5f65 6e64 706f 696e 745f 7426 6774 3b26 _endpoint_t>& │ │ │ -00057c00: 616d 703b 2065 7073 290a 097b 0a09 0966 amp; eps)..{...f │ │ │ -00057c10: 6c61 6773 207c 3d20 6966 6163 652e 6c6f lags |= iface.lo │ │ │ -00057c20: 6361 6c20 3f20 6c69 7374 656e 5f73 6f63 cal ? listen_soc │ │ │ -00057c30: 6b65 745f 743a 3a6c 6f63 616c 5f6e 6574 ket_t::local_net │ │ │ -00057c40: 776f 726b 203a 206c 6973 7465 6e5f 736f work : listen_so │ │ │ -00057c50: 636b 6574 5f66 6c61 6773 5f74 7b7d 3b0a cket_flags_t{};. │ │ │ -00057c60: 0909 7472 616e 7370 6f72 7420 636f 6e73 ..transport cons │ │ │ -00057c70: 7420 7373 6c20 3d20 6966 6163 652e 7373 t ssl = iface.ss │ │ │ -00057c80: 6c20 3f20 7472 616e 7370 6f72 743a 3a73 l ? transport::s │ │ │ -00057c90: 736c 203a 2074 7261 6e73 706f 7274 3a3a sl : transport:: │ │ │ -00057ca0: 706c 6169 6e74 6578 743b 0a0a 0909 2f2f plaintext;....// │ │ │ -00057cb0: 2046 6972 7374 2c20 6368 6563 6b20 746f First, check to │ │ │ -00057cc0: 2073 6565 2069 6620 6974 2773 2061 6e20 see if it's an │ │ │ -00057cd0: 4950 2061 6464 7265 7373 0a09 0965 7272 IP address...err │ │ │ -00057ce0: 6f72 5f63 6f64 6520 6572 723b 0a09 0961 or_code err;...a │ │ │ -00057cf0: 6464 7265 7373 2063 6f6e 7374 2061 6472 ddress const adr │ │ │ -00057d00: 203d 206d 616b 655f 6164 6472 6573 7328 = make_address( │ │ │ -00057d10: 6966 6163 652e 6465 7669 6365 2e63 5f73 iface.device.c_s │ │ │ -00057d20: 7472 2829 2c20 6572 7229 3b0a 0909 6966 tr(), err);...if │ │ │ -00057d30: 2028 2165 7272 290a 0909 7b0a 0909 0965 (!err)...{....e │ │ │ -00057d40: 7073 2e65 6d70 6c61 6365 5f62 6163 6b28 ps.emplace_back( │ │ │ -00057d50: 6164 722c 2069 6661 6365 2e70 6f72 742c adr, iface.port, │ │ │ -00057d60: 2073 7464 3a3a 7374 7269 6e67 7b7d 2c20 std::string{}, │ │ │ -00057d70: 7373 6c2c 2066 6c61 6773 293b 0a09 097d ssl, flags);...} │ │ │ -00057d80: 0a09 0965 6c73 650a 0909 7b0a 0909 0966 ...else...{....f │ │ │ -00057d90: 6c61 6773 207c 3d20 6c69 7374 656e 5f73 lags |= listen_s │ │ │ -00057da0: 6f63 6b65 745f 743a 3a77 6173 5f65 7870 ocket_t::was_exp │ │ │ -00057db0: 616e 6465 643b 0a0a 0909 092f 2f20 7468 anded;.....// th │ │ │ -00057dc0: 6973 2069 7320 7468 6520 6361 7365 2077 is is the case w │ │ │ -00057dd0: 6865 7265 2064 6576 6963 6520 6e61 6d65 here device name │ │ │ -00057de0: 7320 6120 6e65 7477 6f72 6b20 6465 7669 s a network devi │ │ │ -00057df0: 6365 2e20 5765 206e 6565 6420 746f 0a09 ce. We need to.. │ │ │ -00057e00: 0909 2f2f 2065 6e75 6d65 7261 7465 2061 ..// enumerate a │ │ │ -00057e10: 6c6c 2049 5073 2061 7373 6f63 6961 7465 ll IPs associate │ │ │ -00057e20: 6420 7769 7468 2074 6869 7320 6465 7669 d with this devi │ │ │ -00057e30: 6365 0a09 0909 666f 7220 2861 7574 6f20 ce....for (auto │ │ │ -00057e40: 636f 6e73 7426 616d 703b 2069 7066 6163 const& ipfac │ │ │ -00057e50: 6520 3a20 6966 7329 0a09 0909 7b0a 0909 e : ifs)....{... │ │ │ -00057e60: 0909 2f2f 2077 6527 7265 206c 6f6f 6b69 ..// we're looki │ │ │ -00057e70: 6e67 2066 6f72 2061 2073 7065 6369 6669 ng for a specifi │ │ │ -00057e80: 6320 696e 7465 7266 6163 652c 2061 6e64 c interface, and │ │ │ -00057e90: 2069 7473 2061 6464 7265 7373 0a09 0909 its address.... │ │ │ -00057ea0: 092f 2f20 2877 6869 6368 206d 7573 7420 .// (which must │ │ │ -00057eb0: 6265 206f 6620 7468 6520 7361 6d65 2066 be of the same f │ │ │ -00057ec0: 616d 696c 7920 6173 2074 6865 2061 6464 amily as the add │ │ │ -00057ed0: 7265 7373 2077 6527 7265 0a09 0909 092f ress we're...../ │ │ │ -00057ee0: 2f20 636f 6e6e 6563 7469 6e67 2074 6f29 / connecting to) │ │ │ -00057ef0: 0a09 0909 0969 6620 2869 6661 6365 2e64 .....if (iface.d │ │ │ -00057f00: 6576 6963 6520 213d 2069 7066 6163 652e evice != ipface. │ │ │ -00057f10: 6e61 6d65 2920 636f 6e74 696e 7565 3b0a name) continue;. │ │ │ -00057f20: 0a09 0909 0962 6f6f 6c20 636f 6e73 7420 .....bool const │ │ │ -00057f30: 6c6f 6361 6c20 3d20 6966 6163 652e 6c6f local = iface.lo │ │ │ -00057f40: 6361 6c0a 0909 0909 097c 7c20 6970 6661 cal......|| ipfa │ │ │ -00057f50: 6365 2e69 6e74 6572 6661 6365 5f61 6464 ce.interface_add │ │ │ -00057f60: 7265 7373 2e69 735f 6c6f 6f70 6261 636b ress.is_loopback │ │ │ -00057f70: 2829 0a09 0909 0909 7c7c 2069 735f 6c69 ()......|| is_li │ │ │ -00057f80: 6e6b 5f6c 6f63 616c 2869 7066 6163 652e nk_local(ipface. │ │ │ -00057f90: 696e 7465 7266 6163 655f 6164 6472 6573 interface_addres │ │ │ -00057fa0: 7329 3b0a 3c2f 7072 653e 3c2f 7464 3e3c s);.
    < │ │ │ -00057fb0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00057fe0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00058010: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -00058020: 706c 2e63 7070 3a32 3335 353c 2f61 3e3c pl.cpp:2355< │ │ │ -00058030: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ -00058040: 2070 726f 6261 626c 7920 6265 2062 6574 probably be bet │ │ │ -00058050: 7465 7220 746f 2064 6f20 7468 6973 2062 ter to do this b │ │ │ -00058060: 7920 6861 7669 6e67 2061 206c 6973 7465 y having a liste │ │ │ -00058070: 6e2d 736f 636b 6574 2022 7665 7273 696f n-socket "versio │ │ │ -00058080: 6e22 206e 756d 6265 7220 7468 6174 2067 n" number that g │ │ │ -00058090: 6574 7320 6275 6d70 6564 2e20 416e 6420 ets bumped. And │ │ │ -000580a0: 696e 7374 6561 6420 6f66 2073 6574 7469 instead of setti │ │ │ -000580b0: 6e67 2061 2062 6f6f 6c20 746f 2064 6973 ng a bool to dis │ │ │ -000580c0: 6162 6c65 2061 2074 7261 636b 6572 2c20 able a tracker, │ │ │ -000580d0: 7765 2073 6574 2074 6865 2076 6572 7369 we set the versi │ │ │ -000580e0: 6f6e 206e 756d 6265 7220 7468 6174 2069 on number that i │ │ │ -000580f0: 7420 7761 7320 6469 7361 626c 6564 2061 t was disabled a │ │ │ -00058100: 742e 2054 6869 7320 6368 616e 6765 2077 t. This change w │ │ │ -00058110: 6f75 6c64 2061 6666 6563 7420 7468 6520 ould affect the │ │ │ -00058120: 4142 4920 696e 2031 2e32 2c20 736f 2073 ABI in 1.2, so s │ │ │ -00058130: 686f 756c 6420 6265 2064 6f6e 6520 696e hould be done in │ │ │ -00058140: 2032 2e30 206f 7220 6c61 7465 723c 2f74 2.0 or later

    it wo │ │ │ -000581a0: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ -000581b0: 6265 7474 6572 2074 6f20 646f 2074 6869 better to do thi │ │ │ -000581c0: 7320 6279 2068 6176 696e 6720 610a 6c69 s by having a.li │ │ │ -000581d0: 7374 656e 2d73 6f63 6b65 7420 2276 6572 sten-socket "ver │ │ │ -000581e0: 7369 6f6e 2220 6e75 6d62 6572 2074 6861 sion" number tha │ │ │ -000581f0: 7420 6765 7473 2062 756d 7065 642e 2041 t gets bumped. A │ │ │ -00058200: 6e64 2069 6e73 7465 6164 206f 660a 7365 nd instead of.se │ │ │ -00058210: 7474 696e 6720 6120 626f 6f6c 2074 6f20 tting a bool to │ │ │ -00058220: 6469 7361 626c 6520 6120 7472 6163 6b65 disable a tracke │ │ │ -00058230: 722c 2077 6520 7365 7420 7468 6520 7665 r, we set the ve │ │ │ -00058240: 7273 696f 6e20 6e75 6d62 6572 2074 6861 rsion number tha │ │ │ -00058250: 740a 6974 2077 6173 2064 6973 6162 6c65 t.it was disable │ │ │ -00058260: 6420 6174 2e20 5468 6973 2063 6861 6e67 d at. This chang │ │ │ -00058270: 6520 776f 756c 6420 6166 6665 6374 2074 e would affect t │ │ │ -00058280: 6865 2041 4249 2069 6e20 312e 322c 2073 he ABI in 1.2, s │ │ │ -00058290: 6f0a 7368 6f75 6c64 2062 6520 646f 6e65 o.should be done │ │ │ -000582a0: 2069 6e20 322e 3020 6f72 206c 6174 6572 in 2.0 or later │ │ │ -000582b0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -000582c0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -000582d0: 3a32 3335 353c 2f68 343e 3c70 7265 2073 :2355

    ..{....for (
    │ │ │ -00058320: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ -00058330: 7320 3a20 6d5f 6c69 7374 656e 5f73 6f63  s : m_listen_soc
    │ │ │ -00058340: 6b65 7473 290a 0909 0909 7265 6d61 705f  kets).....remap_
    │ │ │ -00058350: 706f 7274 7328 7265 6d61 705f 6e61 7470  ports(remap_natp
    │ │ │ -00058360: 6d70 5f61 6e64 5f75 706e 702c 202a 7329  mp_and_upnp, *s)
    │ │ │ -00058370: 3b0a 0909 7d0a 0909 656c 7365 0a09 097b  ;...}...else...{
    │ │ │ -00058380: 0a09 0909 2f2f 206e 6577 2073 6f63 6b65  ....// new socke
    │ │ │ -00058390: 7473 206e 6565 6420 746f 206d 6170 2070  ts need to map p
    │ │ │ -000583a0: 6f72 7473 2065 7665 6e20 6966 2074 6865  orts even if the
    │ │ │ -000583b0: 2063 616c 6c65 7220 6469 6420 6e6f 7420   caller did not 
    │ │ │ -000583c0: 7265 7175 6573 740a 0909 092f 2f20 7265  request....// re
    │ │ │ -000583d0: 2d6d 6170 7069 6e67 0a09 0909 666f 7220  -mapping....for 
    │ │ │ -000583e0: 2861 7574 6f20 636f 6e73 7426 616d 703b  (auto const&
    │ │ │ -000583f0: 2073 203a 206e 6577 5f73 6f63 6b65 7473   s : new_sockets
    │ │ │ -00058400: 290a 0909 0909 7265 6d61 705f 706f 7274  ).....remap_port
    │ │ │ -00058410: 7328 7265 6d61 705f 6e61 7470 6d70 5f61  s(remap_natpmp_a
    │ │ │ -00058420: 6e64 5f75 706e 702c 202a 7329 3b0a 0909  nd_upnp, *s);...
    │ │ │ -00058430: 7d0a 0a09 0975 7064 6174 655f 6c73 6428  }....update_lsd(
    │ │ │ -00058440: 293b 0a0a 2369 6620 544f 5252 454e 545f  );..#if TORRENT_
    │ │ │ -00058450: 5553 455f 4932 500a 0909 6f70 656e 5f6e  USE_I2P...open_n
    │ │ │ -00058460: 6577 5f69 6e63 6f6d 696e 675f 6932 705f  ew_incoming_i2p_
    │ │ │ -00058470: 636f 6e6e 6563 7469 6f6e 2829 3b0a 2365  connection();.#e
    │ │ │ -00058480: 6e64 6966 0a0a 0909 2f2f 2074 7261 636b  ndif....// track
    │ │ │ -00058490: 6572 7320 7468 6174 2077 6572 6520 6e6f  ers that were no
    │ │ │ -000584a0: 7420 7265 6163 6861 626c 652c 206d 6179  t reachable, may
    │ │ │ -000584b0: 2068 6176 6520 6265 636f 6d65 2072 6561   have become rea
    │ │ │ -000584c0: 6368 6162 6c65 206e 6f77 2e0a 0909 2f2f  chable now....//
    │ │ │ -000584d0: 2073 6f20 636c 6561 7220 7468 6520 2264   so clear the "d
    │ │ │ -000584e0: 6973 6162 6c65 6422 2066 6c61 6773 2074  isabled" flags t
    │ │ │ -000584f0: 6f20 6c65 7420 7468 656d 2062 6520 7472  o let them be tr
    │ │ │ -00058500: 6965 6420 6f6e 6520 6d6f 7265 2074 696d  ied one more tim
    │ │ │ -00058510: 650a 3c64 6976 2073 7479 6c65 3d22 6261  e.
    │ │ │ -00058540: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -00058550: 2074 203a 206d 5f74 6f72 7265 6e74 7329 t : m_torrents) │ │ │ -00058560: 0a3c 2f64 6976 3e09 0909 742d 2667 743b .
    ...t-> │ │ │ -00058570: 656e 6162 6c65 5f61 6c6c 5f74 7261 636b enable_all_track │ │ │ -00058580: 6572 7328 293b 0a09 7d0a 0a09 766f 6964 ers();..}...void │ │ │ -00058590: 2073 6573 7369 6f6e 5f69 6d70 6c3a 3a72 session_impl::r │ │ │ -000585a0: 656f 7065 6e5f 6e65 7477 6f72 6b5f 736f eopen_network_so │ │ │ -000585b0: 636b 6574 7328 7265 6f70 656e 5f6e 6574 ckets(reopen_net │ │ │ -000585c0: 776f 726b 5f66 6c61 6773 5f74 2063 6f6e work_flags_t con │ │ │ -000585d0: 7374 206f 7074 696f 6e73 290a 097b 0a09 st options)..{.. │ │ │ -000585e0: 0972 656f 7065 6e5f 6c69 7374 656e 5f73 .reopen_listen_s │ │ │ -000585f0: 6f63 6b65 7473 2862 6f6f 6c28 6f70 7469 ockets(bool(opti │ │ │ -00058600: 6f6e 7320 2661 6d70 3b20 7365 7373 696f ons & sessio │ │ │ -00058610: 6e5f 6861 6e64 6c65 3a3a 7265 6f70 656e n_handle::reopen │ │ │ -00058620: 5f6d 6170 5f70 6f72 7473 2929 3b0a 097d _map_ports));..} │ │ │ -00058630: 0a0a 096e 616d 6573 7061 6365 207b 0a09 ...namespace {.. │ │ │ -00058640: 0974 656d 706c 6174 6520 266c 743b 7479 .template <ty │ │ │ -00058650: 7065 6e61 6d65 204d 6170 5072 6f74 6f63 pename MapProtoc │ │ │ -00058660: 6f6c 2c20 7479 7065 6e61 6d65 2050 726f ol, typename Pro │ │ │ -00058670: 746f 5479 7065 2c20 7479 7065 6e61 6d65 toType, typename │ │ │ -00058680: 2045 6e64 706f 696e 7454 7970 6526 6774 EndpointType> │ │ │ -00058690: 3b0a 0909 766f 6964 206d 6170 5f70 6f72 ;...void map_por │ │ │ -000586a0: 7428 4d61 7050 726f 746f 636f 6c26 616d t(MapProtocol&am │ │ │ -000586b0: 703b 206d 2c20 5072 6f74 6f54 7970 6520 p; m, ProtoType │ │ │ -000586c0: 7072 6f74 6f63 6f6c 2c20 456e 6470 6f69 protocol, Endpoi │ │ │ -000586d0: 6e74 5479 7065 2063 6f6e 7374 2661 6d70 ntType const& │ │ │ -000586e0: 3b20 6570 0a09 0909 2c20 706f 7274 5f6d ; ep...., port_m │ │ │ -000586f0: 6170 7069 6e67 5f74 2661 6d70 3b20 6d61 apping_t& ma │ │ │ -00058700: 705f 6861 6e64 6c65 2c20 7374 643a 3a73 p_handle, std::s │ │ │ -00058710: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -00058720: 2064 6576 6963 6529 0a09 097b 0a09 0909 device)...{.... │ │ │ -00058730: 6966 2028 6d61 705f 6861 6e64 6c65 2021 if (map_handle ! │ │ │ -00058740: 3d20 706f 7274 5f6d 6170 7069 6e67 5f74 = port_mapping_t │ │ │ -00058750: 7b2d 317d 2920 6d2e 6465 6c65 7465 5f6d {-1}) m.delete_m │ │ │ -00058760: 6170 7069 6e67 286d 6170 5f68 616e 646c apping(map_handl │ │ │ -00058770: 6529 3b0a 0909 096d 6170 5f68 616e 646c e);....map_handl │ │ │ -00058780: 6520 3d20 706f 7274 5f6d 6170 7069 6e67 e = port_mapping │ │ │ -00058790: 5f74 7b2d 317d 3b0a 0a09 0909 6164 6472 _t{-1};.....addr │ │ │ -000587a0: 6573 7320 636f 6e73 7420 6164 6472 203d ess const addr = │ │ │ -000587b0: 2065 702e 6164 6472 6573 7328 293b 0a09 ep.address();.. │ │ │ -000587c0: 0909 2f2f 2077 6974 6820 4950 7634 2074 ..// with IPv4 t │ │ │ -000587d0: 6865 2069 6e74 6572 6661 6365 206d 6967 he interface mig │ │ │ -000587e0: 6874 2062 6520 6265 6869 6e64 204e 4154 ht be behind NAT │ │ │ -000587f0: 2073 6f20 7765 2063 616e 2774 2073 6b69 so we can't ski │ │ │ -00058800: 7020 7468 656d 0a09 0909 2f2f 2062 6173 p them....// bas │ │ │ -00058810: 6564 206f 6e20 7468 6520 7363 6f70 6520 ed on the scope │ │ │ -00058820: 6f66 2074 6865 206c 6f63 616c 2061 6464 of the local add │ │ │ -00058830: 7265 7373 0a09 0909 6966 2028 6164 6472 ress....if (addr │ │ │ -00058840: 2e69 735f 7636 2829 2026 616d 703b 2661 .is_v6() &&a │ │ │ -00058850: 6d70 3b20 6973 5f6c 6f63 616c 2861 6464 mp; is_local(add │ │ │ -00058860: 7229 290a 0909 0909 7265 7475 726e 3b0a r)).....return;. │ │ │ -00058870: 0a09 0909 2f2f 206f 6e6c 7920 7570 6461 ....// only upda │ │ │ -00058880: 7465 2074 6869 7320 6d61 7070 696e 6720 te this mapping │ │ │ -00058890: 6966 2077 6520 6163 7475 616c 6c79 2068 if we actually h │ │ │ -000588a0: 6176 6520 6120 736f 636b 6574 206c 6973 ave a socket lis │ │ │ -000588b0: 7465 6e69 6e67 0a09 0909 6966 2028 6570 tening....if (ep │ │ │ -000588c0: 2021 3d20 456e 6470 6f69 6e74 5479 7065 != EndpointType │ │ │ -000588d0: 2829 290a 0909 0909 6d61 705f 6861 6e64 ()).....map_hand │ │ │ -000588e0: 6c65 203d 206d 2e61 6464 5f6d 6170 7069 le = m.add_mappi │ │ │ -000588f0: 6e67 2870 726f 746f 636f 6c2c 2065 702e ng(protocol, ep. │ │ │ -00058900: 706f 7274 2829 2c20 6570 2c20 6465 7669 port(), ep, devi │ │ │ -00058910: 6365 293b 0a09 097d 0a09 7d0a 0a09 766f ce);...}..}...vo │ │ │ -00058920: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a id session_impl: │ │ │ -00058930: 3a72 656d 6170 5f70 6f72 7473 2872 656d :remap_ports(rem │ │ │ -00058940: 6170 5f70 6f72 745f 6d61 736b 5f74 2063 ap_port_mask_t c │ │ │ -00058950: 6f6e 7374 206d 6173 6b0a 0909 2c20 6c69 onst mask..., li │ │ │ -00058960: 7374 656e 5f73 6f63 6b65 745f 7426 616d sten_socket_t&am │ │ │ -00058970: 703b 2073 290a 3c2f 7072 653e 3c2f 7464 p; s).
    relevance │ │ │ -000589b0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -000589c0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session_ │ │ │ -000589f0: 696d 706c 2e63 7070 3a32 3939 343c 2f61 impl.cpp:2994this s │ │ │ -00058a10: 697a 6520 6e65 6564 2074 6f20 6265 2063 ize need to be c │ │ │ -00058a20: 6170 7065 643c 2f74 643e 3c2f 7472 3e3c apped< │ │ │ -00058a30: 7472 2069 643d 2232 3038 2220 7374 796c tr id="208" styl │ │ │ -00058a40: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00058a50: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00058a60: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00058a70: 6832 3e74 6869 7320 7369 7a65 206e 6565 h2>this size nee │ │ │ -00058a80: 6420 746f 2062 6520 6361 7070 6564 3c2f d to be capped

    ../src/se │ │ │ -00058aa0: 7373 696f 6e5f 696d 706c 2e63 7070 3a32 ssion_impl.cpp:2 │ │ │ -00058ab0: 3939 343c 2f68 343e 3c70 7265 2073 7479 994

    ....// handsha
    │ │ │ -00058b00: 6b69 6e67 0a09 0909 0972 6574 7572 6e20  king.....return 
    │ │ │ -00058b10: 736f 636b 6574 5f74 7970 6528 7373 6c5f  socket_type(ssl_
    │ │ │ -00058b20: 7374 7265 616d 266c 743b 7463 703a 3a73  stream<tcp::s
    │ │ │ -00058b30: 6f63 6b65 7426 6774 3b28 7463 703a 3a73  ocket>(tcp::s
    │ │ │ -00058b40: 6f63 6b65 7428 7374 643a 3a6d 6f76 6528  ocket(std::move(
    │ │ │ -00058b50: 7329 292c 206d 5f70 6565 725f 7373 6c5f  s)), m_peer_ssl_
    │ │ │ -00058b60: 6374 7829 293b 0a09 0909 7d0a 0909 0965  ctx));....}....e
    │ │ │ -00058b70: 6c73 650a 2365 6e64 6966 0a09 0909 7b0a  lse.#endif....{.
    │ │ │ -00058b80: 0909 0909 7265 7475 726e 2073 6f63 6b65  ....return socke
    │ │ │ -00058b90: 745f 7479 7065 2874 6370 3a3a 736f 636b  t_type(tcp::sock
    │ │ │ -00058ba0: 6574 2873 7464 3a3a 6d6f 7665 2873 2929  et(std::move(s))
    │ │ │ -00058bb0: 293b 0a09 0909 7d0a 0909 7d28 293b 0a0a  );....}...}();..
    │ │ │ -00058bc0: 2369 6664 6566 2054 4f52 5245 4e54 5f53  #ifdef TORRENT_S
    │ │ │ -00058bd0: 534c 5f50 4545 5253 0a09 0954 4f52 5245  SL_PEERS...TORRE
    │ │ │ -00058be0: 4e54 5f41 5353 4552 5428 2873 736c 203d  NT_ASSERT((ssl =
    │ │ │ -00058bf0: 3d20 7472 616e 7370 6f72 743a 3a73 736c  = transport::ssl
    │ │ │ -00058c00: 2920 3d3d 2069 735f 7373 6c28 6329 293b  ) == is_ssl(c));
    │ │ │ -00058c10: 0a23 656e 6469 660a 0a23 6966 6465 6620  .#endif..#ifdef 
    │ │ │ -00058c20: 544f 5252 454e 545f 5353 4c5f 5045 4552  TORRENT_SSL_PEER
    │ │ │ -00058c30: 530a 0909 6966 2028 7373 6c20 3d3d 2074  S...if (ssl == t
    │ │ │ -00058c40: 7261 6e73 706f 7274 3a3a 7373 6c29 0a09  ransport::ssl)..
    │ │ │ -00058c50: 097b 0a09 0909 544f 5252 454e 545f 4153  .{....TORRENT_AS
    │ │ │ -00058c60: 5345 5254 2869 735f 7373 6c28 6329 293b  SERT(is_ssl(c));
    │ │ │ -00058c70: 0a0a 0909 092f 2f20 7361 7665 2074 6865  .....// save the
    │ │ │ -00058c80: 2073 6f63 6b65 7420 736f 2077 6520 6361   socket so we ca
    │ │ │ -00058c90: 6e20 6361 6e63 656c 2074 6865 2068 616e  n cancel the han
    │ │ │ -00058ca0: 6473 6861 6b65 0a3c 6469 7620 7374 796c  dshake.
    ...auto ite │ │ │ -00058ce0: 7220 3d20 6d5f 696e 636f 6d69 6e67 5f73 r = m_incoming_s │ │ │ -00058cf0: 6f63 6b65 7473 2e65 6d70 6c61 6365 2873 ockets.emplace(s │ │ │ -00058d00: 7464 3a3a 6d61 6b65 5f75 6e69 7175 6526 td::make_unique& │ │ │ -00058d10: 6c74 3b73 6f63 6b65 745f 7479 7065 2667 lt;socket_type&g │ │ │ -00058d20: 743b 2873 7464 3a3a 6d6f 7665 2863 2929 t;(std::move(c)) │ │ │ -00058d30: 292e 6669 7273 743b 0a3c 2f64 6976 3e0a ).first;.
    . │ │ │ -00058d40: 0909 0961 7574 6f20 736f 636b 203d 2069 ...auto sock = i │ │ │ -00058d50: 7465 722d 2667 743b 6765 7428 293b 0a09 ter->get();.. │ │ │ -00058d60: 0909 2f2f 2066 6f72 2053 534c 2063 6f6e ..// for SSL con │ │ │ -00058d70: 6e65 6374 696f 6e73 2c20 696e 636f 6d69 nections, incomi │ │ │ -00058d80: 6e67 5f63 6f6e 6e65 6374 696f 6e28 2920 ng_connection() │ │ │ -00058d90: 6973 2063 616c 6c65 640a 0909 092f 2f20 is called....// │ │ │ -00058da0: 6166 7465 7220 7468 6520 6861 6e64 7368 after the handsh │ │ │ -00058db0: 616b 6520 6973 2064 6f6e 650a 0909 0941 ake is done....A │ │ │ -00058dc0: 4444 5f4f 5554 5354 414e 4449 4e47 5f41 DD_OUTSTANDING_A │ │ │ -00058dd0: 5359 4e43 2822 7365 7373 696f 6e5f 696d SYNC("session_im │ │ │ -00058de0: 706c 3a3a 7373 6c5f 6861 6e64 7368 616b pl::ssl_handshak │ │ │ -00058df0: 6522 293b 0a09 0909 7374 643a 3a67 6574 e");....std::get │ │ │ -00058e00: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ -00058e10: 743b 7463 703a 3a73 6f63 6b65 7426 6774 t;tcp::socket> │ │ │ -00058e20: 3b26 6774 3b28 2a2a 6974 6572 292e 6173 ;>(**iter).as │ │ │ -00058e30: 796e 635f 6163 6365 7074 5f68 616e 6473 ync_accept_hands │ │ │ -00058e40: 6861 6b65 280a 0909 0909 5b74 6869 732c hake(.....[this, │ │ │ -00058e50: 2073 6f63 6b5d 2028 6572 726f 725f 636f sock] (error_co │ │ │ -00058e60: 6465 2063 6f6e 7374 2661 6d70 3b20 6572 de const& er │ │ │ -00058e70: 7229 207b 2073 736c 5f68 616e 6473 6861 r) { ssl_handsha │ │ │ -00058e80: 6b65 2865 7272 2c20 736f 636b 293b 207d ke(err, sock); } │ │ │ -00058e90: 293b 0a09 097d 0a09 0965 6c73 650a 2365 );...}...else.#e │ │ │ -00058ea0: 6e64 6966 0a09 097b 0a09 0909 696e 636f ndif...{....inco │ │ │ -00058eb0: 6d69 6e67 5f63 6f6e 6e65 6374 696f 6e28 ming_connection( │ │ │ -00058ec0: 7374 643a 3a6d 6f76 6528 6329 293b 0a09 std::move(c));.. │ │ │ -00058ed0: 097d 0a09 7d0a 0a23 6966 6465 6620 544f .}..}..#ifdef TO │ │ │ -00058ee0: 5252 454e 545f 5353 4c5f 5045 4552 530a RRENT_SSL_PEERS. │ │ │ -00058ef0: 0a09 766f 6964 2073 6573 7369 6f6e 5f69 ..void session_i │ │ │ -00058f00: 6d70 6c3a 3a6f 6e5f 696e 636f 6d69 6e67 mpl::on_incoming │ │ │ -00058f10: 5f75 7470 5f73 736c 2873 6f63 6b65 745f _utp_ssl(socket_ │ │ │ -00058f20: 7479 7065 2073 290a 097b 0a09 0954 4f52 type s)..{...TOR │ │ │ -00058f30: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ -00058f40: 736c 2873 2929 3b0a 0a09 092f 2f20 7361 sl(s));....// sa │ │ │ -00058f50: 7665 2074 6865 2073 6f63 6b65 7420 736f ve the socket so │ │ │ -00058f60: 2077 6520 6361 6e20 6361 6e63 656c 2074 we can cancel t │ │ │ -00058f70: 6865 2068 616e 6473 6861 6b65 0a0a 3c2f he handshake..r │ │ │ -00058fb0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00058fc0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00058ff0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -00059000: 3a33 3031 393c 2f61 3e3c 2f74 643e 3c74 :3019this size need │ │ │ -00059020: 2074 6f20 6265 2063 6170 7065 643c 2f74 to be capped

    this │ │ │ -00059080: 7369 7a65 206e 6565 6420 746f 2062 6520 size need to be │ │ │ -00059090: 6361 7070 6564 3c2f 6832 3e3c 6834 3e2e capped

    . │ │ │ -000590a0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -000590b0: 706c 2e63 7070 3a33 3031 393c 2f68 343e pl.cpp:3019

    │ │ │ -000590c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...// 
    │ │ │ -00059100: 6166 7465 7220 7468 6520 6861 6e64 7368  after the handsh
    │ │ │ -00059110: 616b 6520 6973 2064 6f6e 650a 0909 0941  ake is done....A
    │ │ │ -00059120: 4444 5f4f 5554 5354 414e 4449 4e47 5f41  DD_OUTSTANDING_A
    │ │ │ -00059130: 5359 4e43 2822 7365 7373 696f 6e5f 696d  SYNC("session_im
    │ │ │ -00059140: 706c 3a3a 7373 6c5f 6861 6e64 7368 616b  pl::ssl_handshak
    │ │ │ -00059150: 6522 293b 0a09 0909 7374 643a 3a67 6574  e");....std::get
    │ │ │ -00059160: 266c 743b 7373 6c5f 7374 7265 616d 266c  <ssl_stream&l
    │ │ │ -00059170: 743b 7463 703a 3a73 6f63 6b65 7426 6774  t;tcp::socket>
    │ │ │ -00059180: 3b26 6774 3b28 2a2a 6974 6572 292e 6173  ;>(**iter).as
    │ │ │ -00059190: 796e 635f 6163 6365 7074 5f68 616e 6473  ync_accept_hands
    │ │ │ -000591a0: 6861 6b65 280a 0909 0909 5b74 6869 732c  hake(.....[this,
    │ │ │ -000591b0: 2073 6f63 6b5d 2028 6572 726f 725f 636f   sock] (error_co
    │ │ │ -000591c0: 6465 2063 6f6e 7374 2661 6d70 3b20 6572  de const& er
    │ │ │ -000591d0: 7229 207b 2073 736c 5f68 616e 6473 6861  r) { ssl_handsha
    │ │ │ -000591e0: 6b65 2865 7272 2c20 736f 636b 293b 207d  ke(err, sock); }
    │ │ │ -000591f0: 293b 0a09 097d 0a09 0965 6c73 650a 2365  );...}...else.#e
    │ │ │ -00059200: 6e64 6966 0a09 097b 0a09 0909 696e 636f  ndif...{....inco
    │ │ │ -00059210: 6d69 6e67 5f63 6f6e 6e65 6374 696f 6e28  ming_connection(
    │ │ │ -00059220: 7374 643a 3a6d 6f76 6528 6329 293b 0a09  std::move(c));..
    │ │ │ -00059230: 097d 0a09 7d0a 0a23 6966 6465 6620 544f  .}..}..#ifdef TO
    │ │ │ -00059240: 5252 454e 545f 5353 4c5f 5045 4552 530a  RRENT_SSL_PEERS.
    │ │ │ -00059250: 0a09 766f 6964 2073 6573 7369 6f6e 5f69  ..void session_i
    │ │ │ -00059260: 6d70 6c3a 3a6f 6e5f 696e 636f 6d69 6e67  mpl::on_incoming
    │ │ │ -00059270: 5f75 7470 5f73 736c 2873 6f63 6b65 745f  _utp_ssl(socket_
    │ │ │ -00059280: 7479 7065 2073 290a 097b 0a09 0954 4f52  type s)..{...TOR
    │ │ │ -00059290: 5245 4e54 5f41 5353 4552 5428 6973 5f73  RENT_ASSERT(is_s
    │ │ │ -000592a0: 736c 2873 2929 3b0a 0a09 092f 2f20 7361  sl(s));....// sa
    │ │ │ -000592b0: 7665 2074 6865 2073 6f63 6b65 7420 736f  ve the socket so
    │ │ │ -000592c0: 2077 6520 6361 6e20 6361 6e63 656c 2074   we can cancel t
    │ │ │ -000592d0: 6865 2068 616e 6473 6861 6b65 0a0a 3c64  he handshake....au
    │ │ │ -00059310: 746f 2069 7465 7220 3d20 6d5f 696e 636f  to iter = m_inco
    │ │ │ -00059320: 6d69 6e67 5f73 6f63 6b65 7473 2e65 6d70  ming_sockets.emp
    │ │ │ -00059330: 6c61 6365 2873 7464 3a3a 6d61 6b65 5f75  lace(std::make_u
    │ │ │ -00059340: 6e69 7175 6526 6c74 3b73 6f63 6b65 745f  nique<socket_
    │ │ │ -00059350: 7479 7065 2667 743b 2873 7464 3a3a 6d6f  type>(std::mo
    │ │ │ -00059360: 7665 2873 2929 292e 6669 7273 743b 0a3c  ve(s))).first;.<
    │ │ │ -00059370: 2f64 6976 3e09 0961 7574 6f20 736f 636b  /div>..auto sock
    │ │ │ -00059380: 203d 2069 7465 722d 2667 743b 6765 7428   = iter->get(
    │ │ │ -00059390: 293b 0a0a 0909 2f2f 2066 6f72 2053 534c  );....// for SSL
    │ │ │ -000593a0: 2063 6f6e 6e65 6374 696f 6e73 2c20 696e   connections, in
    │ │ │ -000593b0: 636f 6d69 6e67 5f63 6f6e 6e65 6374 696f  coming_connectio
    │ │ │ -000593c0: 6e28 2920 6973 2063 616c 6c65 640a 0909  n() is called...
    │ │ │ -000593d0: 2f2f 2061 6674 6572 2074 6865 2068 616e  // after the han
    │ │ │ -000593e0: 6473 6861 6b65 2069 7320 646f 6e65 0a09  dshake is done..
    │ │ │ -000593f0: 0941 4444 5f4f 5554 5354 414e 4449 4e47  .ADD_OUTSTANDING
    │ │ │ -00059400: 5f41 5359 4e43 2822 7365 7373 696f 6e5f  _ASYNC("session_
    │ │ │ -00059410: 696d 706c 3a3a 7373 6c5f 6861 6e64 7368  impl::ssl_handsh
    │ │ │ -00059420: 616b 6522 293b 0a09 0973 7464 3a3a 6765  ake");...std::ge
    │ │ │ -00059430: 7426 6c74 3b73 736c 5f73 7472 6561 6d26  t<ssl_stream&
    │ │ │ -00059440: 6c74 3b75 7470 5f73 7472 6561 6d26 6774  lt;utp_stream>
    │ │ │ -00059450: 3b26 6774 3b28 2a2a 6974 6572 292e 6173  ;>(**iter).as
    │ │ │ -00059460: 796e 635f 6163 6365 7074 5f68 616e 6473  ync_accept_hands
    │ │ │ -00059470: 6861 6b65 280a 0909 095b 7468 6973 2c20  hake(....[this, 
    │ │ │ -00059480: 736f 636b 5d20 2865 7272 6f72 5f63 6f64  sock] (error_cod
    │ │ │ -00059490: 6520 636f 6e73 7426 616d 703b 2065 7272  e const& err
    │ │ │ -000594a0: 2920 7b20 7373 6c5f 6861 6e64 7368 616b  ) { ssl_handshak
    │ │ │ -000594b0: 6528 6572 722c 2073 6f63 6b29 3b20 7d29  e(err, sock); })
    │ │ │ -000594c0: 3b0a 097d 0a0a 092f 2f20 746f 2074 6573  ;..}...// to tes
    │ │ │ -000594d0: 7420 5353 4c20 636f 6e6e 6563 7469 6f6e  t SSL connection
    │ │ │ -000594e0: 732c 206f 6e65 2063 616e 2075 7365 2074  s, one can use t
    │ │ │ -000594f0: 6869 7320 6f70 656e 7373 6c20 636f 6d6d  his openssl comm
    │ │ │ -00059500: 616e 6420 7465 6d70 6c61 7465 3a0a 092f  and template:../
    │ │ │ -00059510: 2f0a 092f 2f20 6f70 656e 7373 6c20 735f  /..// openssl s_
    │ │ │ -00059520: 636c 6965 6e74 202d 6365 7274 2026 6c74  client -cert <
    │ │ │ -00059530: 3b63 6c69 656e 742d 6365 7274 2667 743b  ;client-cert>
    │ │ │ -00059540: 2e70 656d 202d 6b65 7920 266c 743b 636c  .pem -key <cl
    │ │ │ -00059550: 6965 6e74 2d70 7269 7661 7465 2d6b 6579  ient-private-key
    │ │ │ -00059560: 2667 743b 2e70 656d 0a09 2f2f 2020 202d  >.pem..//   -
    │ │ │ -00059570: 4341 6669 6c65 2026 6c74 3b74 6f72 7265  CAfile <torre
    │ │ │ -00059580: 6e74 2d63 6572 7426 6774 3b2e 7065 6d20  nt-cert>.pem 
    │ │ │ -00059590: 202d 6465 6275 6720 2d63 6f6e 6e65 6374   -debug -connect
    │ │ │ -000595a0: 2031 3237 2e30 2e30 2e31 3a34 3433 3320   127.0.0.1:4433 
    │ │ │ -000595b0: 2d74 6c73 310a 092f 2f20 2020 2d73 6572  -tls1..//   -ser
    │ │ │ -000595c0: 7665 726e 616d 6520 266c 743b 6865 782d  vername <hex-
    │ │ │ -000595d0: 656e 636f 6465 642d 696e 666f 2d68 6173  encoded-info-has
    │ │ │ -000595e0: 6826 6774 3b0a 0a09 766f 6964 2073 6573  h>...void ses
    │ │ │ -000595f0: 7369 6f6e 5f69 6d70 6c3a 3a73 736c 5f68  sion_impl::ssl_h
    │ │ │ -00059600: 616e 6473 6861 6b65 2865 7272 6f72 5f63  andshake(error_c
    │ │ │ -00059610: 6f64 6520 636f 6e73 7426 616d 703b 2065  ode const& e
    │ │ │ -00059620: 632c 2073 6f63 6b65 745f 7479 7065 2a20  c, socket_type* 
    │ │ │ -00059630: 736f 636b 290a 097b 0a09 0943 4f4d 504c  sock)..{...COMPL
    │ │ │ -00059640: 4554 455f 4153 594e 4328 2273 6573 7369  ETE_ASYNC("sessi
    │ │ │ -00059650: 6f6e 5f69 6d70 6c3a 3a73 736c 5f68 616e  on_impl::ssl_han
    │ │ │ -00059660: 6473 6861 6b65 2229 3b0a 0a09 0961 7574  dshake");....aut
    │ │ │ -00059670: 6f20 6974 6572 203d 206d 5f69 6e63 6f6d  o iter = m_incom
    │ │ │ -00059680: 696e 675f 736f 636b 6574 732e 6669 6e64  ing_sockets.find
    │ │ │ -00059690: 2873 6f63 6b29 3b0a 0a09 092f 2f20 7468  (sock);....// th
    │ │ │ -000596a0: 6973 2068 6170 7065 6e73 2069 6620 7468  is happens if th
    │ │ │ -000596b0: 6520 5353 4c20 636f 6e6e 6563 7469 6f6e  e SSL connection
    │ │ │ -000596c0: 2069 7320 6162 6f72 7465 6420 6265 6361   is aborted beca
    │ │ │ -000596d0: 7573 6520 7765 2772 6520 7368 7574 7469  use we're shutti
    │ │ │ -000596e0: 6e67 0a09 092f 2f20 646f 776e 0a09 0969  ng...// down...i
    │ │ │ -000596f0: 6620 2869 7465 7220 3d3d 206d 5f69 6e63  f (iter == m_inc
    │ │ │ -00059700: 6f6d 696e 675f 736f 636b 6574 732e 656e  oming_sockets.en
    │ │ │ -00059710: 6428 2929 2072 6574 7572 6e3b 0a0a 0909  d()) return;....
    │ │ │ -00059720: 736f 636b 6574 5f74 7970 6520 7328 7374  socket_type s(st
    │ │ │ -00059730: 643a 3a6d 6f76 6528 2a2a 6974 6572 2929  d::move(**iter))
    │ │ │ -00059740: 3b0a 0909 544f 5252 454e 545f 4153 5345  ;...TORRENT_ASSE
    │ │ │ -00059750: 5254 2869 735f 7373 6c28 7329 293b 0a09  RT(is_ssl(s));..
    │ │ │ -00059760: 096d 5f69 6e63 6f6d 696e 675f 736f 636b  .m_incoming_sock
    │ │ │ -00059770: 6574 732e 6572 6173 6528 6974 6572 293b  ets.erase(iter);
    │ │ │ -00059780: 0a0a 0909 6572 726f 725f 636f 6465 2065  ....error_code e
    │ │ │ -00059790: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ;.
    < │ │ │ -000597c0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000597d0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00059800: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -00059810: 2e63 7070 3a33 3733 313c 2f61 3e3c 2f74 .cpp:3731have a sep │ │ │ -00059830: 6172 6174 6520 6c69 7374 2066 6f72 2074 arate list for t │ │ │ -00059840: 6865 7365 2063 6f6e 6e65 6374 696f 6e73 hese connections │ │ │ -00059850: 2c20 696e 7374 6561 6420 6f66 2068 6176 , instead of hav │ │ │ -00059860: 696e 6720 746f 206c 6f6f 7020 7468 726f ing to loop thro │ │ │ -00059870: 7567 6820 616c 6c20 6f66 2074 6865 6d3c ugh all of them< │ │ │ -00059880: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    hav │ │ │ -000598d0: 6520 6120 7365 7061 7261 7465 206c 6973 e a separate lis │ │ │ -000598e0: 7420 666f 7220 7468 6573 6520 636f 6e6e t for these conn │ │ │ -000598f0: 6563 7469 6f6e 732c 2069 6e73 7465 6164 ections, instead │ │ │ -00059900: 206f 6620 6861 7669 6e67 2074 6f20 6c6f of having to lo │ │ │ -00059910: 6f70 2074 6872 6f75 6768 2061 6c6c 206f op through all o │ │ │ -00059920: 6620 7468 656d 3c2f 6832 3e3c 6834 3e2e f them

    . │ │ │ -00059930: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -00059940: 706c 2e63 7070 3a33 3733 313c 2f68 343e pl.cpp:3731

    │ │ │ -00059950: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..// -
    │ │ │ -00059990: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -000599a0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -000599b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -000599c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0909  -------------...
    │ │ │ -000599d0: 6966 2028 216d 5f70 6175 7365 6429 206d  if (!m_paused) m
    │ │ │ -000599e0: 5f61 7574 6f5f 6d61 6e61 6765 5f74 696d  _auto_manage_tim
    │ │ │ -000599f0: 655f 7363 616c 6572 2d2d 3b0a 0909 6966  e_scaler--;...if
    │ │ │ -00059a00: 2028 6d5f 6175 746f 5f6d 616e 6167 655f   (m_auto_manage_
    │ │ │ -00059a10: 7469 6d65 5f73 6361 6c65 7220 266c 743b  time_scaler <
    │ │ │ -00059a20: 2030 290a 0909 7b0a 0909 096d 5f61 7574   0)...{....m_aut
    │ │ │ -00059a30: 6f5f 6d61 6e61 6765 5f74 696d 655f 7363  o_manage_time_sc
    │ │ │ -00059a40: 616c 6572 203d 2073 6574 7469 6e67 7328  aler = settings(
    │ │ │ -00059a50: 292e 6765 745f 696e 7428 7365 7474 696e  ).get_int(settin
    │ │ │ -00059a60: 6773 5f70 6163 6b3a 3a61 7574 6f5f 6d61  gs_pack::auto_ma
    │ │ │ -00059a70: 6e61 6765 5f69 6e74 6572 7661 6c29 3b0a  nage_interval);.
    │ │ │ -00059a80: 0909 0972 6563 616c 6375 6c61 7465 5f61  ...recalculate_a
    │ │ │ -00059a90: 7574 6f5f 6d61 6e61 6765 645f 746f 7272  uto_managed_torr
    │ │ │ -00059aa0: 656e 7473 2829 3b0a 0909 7d0a 0a09 092f  ents();...}..../
    │ │ │ -00059ab0: 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  / --------------
    │ │ │ -00059ac0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059ad0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059ae0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059af0: 0a09 092f 2f20 6368 6563 6b20 666f 7220  ...// check for 
    │ │ │ -00059b00: 696e 636f 6d69 6e67 2063 6f6e 6e65 6374  incoming connect
    │ │ │ -00059b10: 696f 6e73 2074 6861 7420 6d69 6768 7420  ions that might 
    │ │ │ -00059b20: 6861 7665 2074 696d 6564 206f 7574 0a09  have timed out..
    │ │ │ -00059b30: 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  .// ------------
    │ │ │ -00059b40: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059b50: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059b60: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00059b70: 2d2d 0a0a 0909 666f 7220 2861 7574 6f20  --....for (auto 
    │ │ │ -00059b80: 6920 3d20 6d5f 636f 6e6e 6563 7469 6f6e  i = m_connection
    │ │ │ -00059b90: 732e 6265 6769 6e28 293b 2069 2021 3d20  s.begin(); i != 
    │ │ │ -00059ba0: 6d5f 636f 6e6e 6563 7469 6f6e 732e 656e  m_connections.en
    │ │ │ -00059bb0: 6428 293b 290a 0909 7b0a 0909 0970 6565  d();)...{....pee
    │ │ │ -00059bc0: 725f 636f 6e6e 6563 7469 6f6e 2a20 7020  r_connection* p 
    │ │ │ -00059bd0: 3d20 282a 6929 2e67 6574 2829 3b0a 0909  = (*i).get();...
    │ │ │ -00059be0: 092b 2b69 3b0a 0909 092f 2f20 6967 6e6f  .++i;....// igno
    │ │ │ -00059bf0: 7265 2063 6f6e 6e65 6374 696f 6e73 2074  re connections t
    │ │ │ -00059c00: 6861 7420 616c 7265 6164 7920 6861 7665  hat already have
    │ │ │ -00059c10: 2061 2074 6f72 7265 6e74 2c20 7369 6e63   a torrent, sinc
    │ │ │ -00059c20: 6520 7468 6579 0a09 0909 2f2f 2061 7265  e they....// are
    │ │ │ -00059c30: 2074 6963 6b65 6420 7468 726f 7567 6820   ticked through 
    │ │ │ -00059c40: 7468 6520 746f 7272 656e 7473 2720 7365  the torrents' se
    │ │ │ -00059c50: 636f 6e64 5f74 6963 6b0a 0909 0969 6620  cond_tick....if 
    │ │ │ -00059c60: 2821 702d 2667 743b 6173 736f 6369 6174  (!p->associat
    │ │ │ -00059c70: 6564 5f74 6f72 7265 6e74 2829 2e65 7870  ed_torrent().exp
    │ │ │ -00059c80: 6972 6564 2829 2920 636f 6e74 696e 7565  ired()) continue
    │ │ │ -00059c90: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ...int timeout │ │ │ -00059cd0: 3d20 6d5f 7365 7474 696e 6773 2e67 6574 = m_settings.get │ │ │ -00059ce0: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ -00059cf0: 636b 3a3a 6861 6e64 7368 616b 655f 7469 ck::handshake_ti │ │ │ -00059d00: 6d65 6f75 7429 3b0a 3c2f 6469 763e 2369 meout);.
    #i │ │ │ -00059d10: 6620 544f 5252 454e 545f 5553 455f 4932 f TORRENT_USE_I2 │ │ │ -00059d20: 500a 0909 0974 696d 656f 7574 202a 3d20 P....timeout *= │ │ │ -00059d30: 6973 5f69 3270 2870 2d26 6774 3b67 6574 is_i2p(p->get │ │ │ -00059d40: 5f73 6f63 6b65 7428 2929 203f 2034 203a _socket()) ? 4 : │ │ │ -00059d50: 2031 3b0a 2365 6e64 6966 0a09 0909 6966 1;.#endif....if │ │ │ -00059d60: 2028 6d5f 6c61 7374 5f74 6963 6b20 2d20 (m_last_tick - │ │ │ -00059d70: 702d 2667 743b 636f 6e6e 6563 7465 645f p->connected_ │ │ │ -00059d80: 7469 6d65 2028 2920 2667 743b 2073 6563 time () > sec │ │ │ -00059d90: 6f6e 6473 2874 696d 656f 7574 2929 0a09 onds(timeout)).. │ │ │ -00059da0: 0909 0970 2d26 6774 3b64 6973 636f 6e6e ...p->disconn │ │ │ -00059db0: 6563 7428 6572 726f 7273 3a3a 7469 6d65 ect(errors::time │ │ │ -00059dc0: 645f 6f75 742c 206f 7065 7261 7469 6f6e d_out, operation │ │ │ -00059dd0: 5f74 3a3a 6269 7474 6f72 7265 6e74 293b _t::bittorrent); │ │ │ -00059de0: 0a09 097d 0a0a 0909 2f2f 202d 2d2d 2d2d ...}....// ----- │ │ │ -00059df0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e00: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e10: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e20: 2d2d 2d2d 2d2d 2d2d 2d0a 0909 2f2f 2073 ---------...// s │ │ │ -00059e30: 6563 6f6e 645f 7469 636b 2065 7665 7279 econd_tick every │ │ │ -00059e40: 2074 6f72 7265 6e74 2028 7468 6174 2077 torrent (that w │ │ │ -00059e50: 616e 7473 2069 7429 0a09 092f 2f20 2d2d ants it)...// -- │ │ │ -00059e60: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e70: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -00059e90: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a0a 2369 ------------..#i │ │ │ -00059ea0: 6620 544f 5252 454e 545f 4445 4255 475f f TORRENT_DEBUG_ │ │ │ -00059eb0: 5354 5245 414d 494e 4720 2667 743b 2030 STREAMING > 0 │ │ │ -00059ec0: 0a09 0973 7464 3a3a 7072 696e 7466 2822 ...std::printf(" │ │ │ -00059ed0: 5c30 3333 5b32 4a5c 3033 335b 303b 3048 \033[2J\033[0;0H │ │ │ -00059ee0: 2229 3b0a 2365 6e64 6966 0a0a 0909 6175 ");.#endif....au │ │ │ -00059ef0: 783a 3a76 6563 746f 7226 6c74 3b74 6f72 x::vector<tor │ │ │ -00059f00: 7265 6e74 2a26 6774 3b26 616d 703b 2077 rent*>& w │ │ │ -00059f10: 616e 745f 7469 636b 203d 206d 5f74 6f72 ant_tick = m_tor │ │ │ -00059f20: 7265 6e74 5f6c 6973 7473 5b74 6f72 7265 rent_lists[torre │ │ │ -00059f30: 6e74 5f77 616e 745f 7469 636b 5d3b 0a09 nt_want_tick];.. │ │ │ -00059f40: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ -00059f50: 2069 2026 6c74 3b20 696e 7428 7761 6e74 i < int(want │ │ │ -00059f60: 5f74 6963 6b2e 7369 7a65 2829 293b 202b _tick.size()); + │ │ │ -00059f70: 2b69 290a 0909 7b0a 0909 0974 6f72 7265 +i)...{....torre │ │ │ -00059f80: 6e74 2661 6d70 3b20 7420 3d20 2a77 616e nt& t = *wan │ │ │ -00059f90: 745f 7469 636b 5b69 5d3b 0a09 0909 544f t_tick[i];....TO │ │ │ -00059fa0: 5252 454e 545f 4153 5345 5254 2874 2e77 RRENT_ASSERT(t.w │ │ │ -00059fb0: 616e 745f 7469 636b 2829 293b 0a09 0909 ant_tick());.... │ │ │ -00059fc0: 544f 5252 454e 545f 4153 5345 5254 2821 TORRENT_ASSERT(! │ │ │ -00059fd0: 742e 6973 5f61 626f 7274 6564 2829 293b t.is_aborted()); │ │ │ -00059fe0: 0a0a 0909 0974 2e73 6563 6f6e 645f 7469 .....t.second_ti │ │ │ -00059ff0: 636b 2874 6963 6b5f 696e 7465 7276 616c ck(tick_interval │ │ │ -0005a000: 5f6d 7329 3b0a 0a09 0909 2f2f 2069 6620 _ms);.....// if │ │ │ -0005a010: 7468 6520 6361 6c6c 2074 6f20 7365 636f the call to seco │ │ │ -0005a020: 6e64 5f74 6963 6b20 6361 7573 6564 2074 nd_tick caused t │ │ │ -0005a030: 6865 2074 6f72 7265 6e74 0a09 0909 2f2f he torrent....// │ │ │ -0005a040: 2074 6f20 6e6f 206c 6f6e 6765 7220 7761 to no longer wa │ │ │ -0005a050: 6e74 2074 6f20 6265 2074 6963 6b65 6420 nt to be ticked │ │ │ -0005a060: 2869 2e65 2e20 6974 2077 6173 0a09 0909 (i.e. it was.... │ │ │ -0005a070: 2f2f 2072 656d 6f76 6564 2066 726f 6d20 // removed from │ │ │ -0005a080: 7468 6520 6c69 7374 2920 7765 206e 6565 the list) we nee │ │ │ -0005a090: 6420 746f 2062 6163 6b20 7570 2074 6865 d to back up the │ │ │ -0005a0a0: 2063 6f75 6e74 6572 0a09 0909 2f2f 2074 counter....// t │ │ │ -0005a0b0: 6f20 6e6f 7420 6d69 7373 2074 6865 2074 o not miss the t │ │ │ -0005a0c0: 6f72 7265 6e74 2061 6674 6572 2069 740a orrent after it. │ │ │ -0005a0d0: 0909 0969 6620 2821 742e 7761 6e74 5f74 ...if (!t.want_t │ │ │ -0005a0e0: 6963 6b28 2929 202d 2d69 3b0a 0909 7d0a ick()) --i;...}. │ │ │ -0005a0f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0005a100: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0005a130: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0005a160: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -0005a170: 7070 3a33 3736 343c 2f61 3e3c 2f74 643e pp:3764 │ │ │ -0005a180: 3c74 643e 7468 6973 2073 686f 756c 6420 this should │ │ │ -0005a190: 6170 706c 7920 746f 2061 6c6c 2062 616e apply to all ban │ │ │ -0005a1a0: 6477 6964 7468 2063 6861 6e6e 656c 733c dwidth channels< │ │ │ -0005a1b0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    thi │ │ │ -0005a200: 7320 7368 6f75 6c64 2061 7070 6c79 2074 s should apply t │ │ │ -0005a210: 6f20 616c 6c20 6261 6e64 7769 6474 6820 o all bandwidth │ │ │ -0005a220: 6368 616e 6e65 6c73 3c2f 6832 3e3c 6834 channels

    ../src/session_ │ │ │ -0005a240: 696d 706c 2e63 7070 3a33 3736 343c 2f68 impl.cpp:3764
    #if 
    │ │ │ -0005a290: 544f 5252 454e 545f 4445 4255 475f 5354  TORRENT_DEBUG_ST
    │ │ │ -0005a2a0: 5245 414d 494e 4720 2667 743b 2030 0a09  REAMING > 0..
    │ │ │ -0005a2b0: 0973 7464 3a3a 7072 696e 7466 2822 5c30  .std::printf("\0
    │ │ │ -0005a2c0: 3333 5b32 4a5c 3033 335b 303b 3048 2229  33[2J\033[0;0H")
    │ │ │ -0005a2d0: 3b0a 2365 6e64 6966 0a0a 0909 6175 783a  ;.#endif....aux:
    │ │ │ -0005a2e0: 3a76 6563 746f 7226 6c74 3b74 6f72 7265  :vector<torre
    │ │ │ -0005a2f0: 6e74 2a26 6774 3b26 616d 703b 2077 616e  nt*>& wan
    │ │ │ -0005a300: 745f 7469 636b 203d 206d 5f74 6f72 7265  t_tick = m_torre
    │ │ │ -0005a310: 6e74 5f6c 6973 7473 5b74 6f72 7265 6e74  nt_lists[torrent
    │ │ │ -0005a320: 5f77 616e 745f 7469 636b 5d3b 0a09 0966  _want_tick];...f
    │ │ │ -0005a330: 6f72 2028 696e 7420 6920 3d20 303b 2069  or (int i = 0; i
    │ │ │ -0005a340: 2026 6c74 3b20 696e 7428 7761 6e74 5f74   < int(want_t
    │ │ │ -0005a350: 6963 6b2e 7369 7a65 2829 293b 202b 2b69  ick.size()); ++i
    │ │ │ -0005a360: 290a 0909 7b0a 0909 0974 6f72 7265 6e74  )...{....torrent
    │ │ │ -0005a370: 2661 6d70 3b20 7420 3d20 2a77 616e 745f  & t = *want_
    │ │ │ -0005a380: 7469 636b 5b69 5d3b 0a09 0909 544f 5252  tick[i];....TORR
    │ │ │ -0005a390: 454e 545f 4153 5345 5254 2874 2e77 616e  ENT_ASSERT(t.wan
    │ │ │ -0005a3a0: 745f 7469 636b 2829 293b 0a09 0909 544f  t_tick());....TO
    │ │ │ -0005a3b0: 5252 454e 545f 4153 5345 5254 2821 742e  RRENT_ASSERT(!t.
    │ │ │ -0005a3c0: 6973 5f61 626f 7274 6564 2829 293b 0a0a  is_aborted());..
    │ │ │ -0005a3d0: 0909 0974 2e73 6563 6f6e 645f 7469 636b  ...t.second_tick
    │ │ │ -0005a3e0: 2874 6963 6b5f 696e 7465 7276 616c 5f6d  (tick_interval_m
    │ │ │ -0005a3f0: 7329 3b0a 0a09 0909 2f2f 2069 6620 7468  s);.....// if th
    │ │ │ -0005a400: 6520 6361 6c6c 2074 6f20 7365 636f 6e64  e call to second
    │ │ │ -0005a410: 5f74 6963 6b20 6361 7573 6564 2074 6865  _tick caused the
    │ │ │ -0005a420: 2074 6f72 7265 6e74 0a09 0909 2f2f 2074   torrent....// t
    │ │ │ -0005a430: 6f20 6e6f 206c 6f6e 6765 7220 7761 6e74  o no longer want
    │ │ │ -0005a440: 2074 6f20 6265 2074 6963 6b65 6420 2869   to be ticked (i
    │ │ │ -0005a450: 2e65 2e20 6974 2077 6173 0a09 0909 2f2f  .e. it was....//
    │ │ │ -0005a460: 2072 656d 6f76 6564 2066 726f 6d20 7468   removed from th
    │ │ │ -0005a470: 6520 6c69 7374 2920 7765 206e 6565 6420  e list) we need 
    │ │ │ -0005a480: 746f 2062 6163 6b20 7570 2074 6865 2063  to back up the c
    │ │ │ -0005a490: 6f75 6e74 6572 0a09 0909 2f2f 2074 6f20  ounter....// to 
    │ │ │ -0005a4a0: 6e6f 7420 6d69 7373 2074 6865 2074 6f72  not miss the tor
    │ │ │ -0005a4b0: 7265 6e74 2061 6674 6572 2069 740a 0909  rent after it...
    │ │ │ -0005a4c0: 0969 6620 2821 742e 7761 6e74 5f74 6963  .if (!t.want_tic
    │ │ │ -0005a4d0: 6b28 2929 202d 2d69 3b0a 0909 7d0a 0a3c  k()) --i;...}..<
    │ │ │ -0005a4e0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0005a4f0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0005a500: 7769 6474 683d 2231 3030 2522 3e09 0969  width="100%">..i
    │ │ │ -0005a510: 6620 286d 5f73 6574 7469 6e67 732e 6765  f (m_settings.ge
    │ │ │ -0005a520: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -0005a530: 7061 636b 3a3a 7261 7465 5f6c 696d 6974  pack::rate_limit
    │ │ │ -0005a540: 5f69 705f 6f76 6572 6865 6164 2929 0a3c  _ip_overhead)).<
    │ │ │ -0005a550: 2f64 6976 3e09 097b 0a09 0909 696e 7420  /div>..{....int 
    │ │ │ -0005a560: 636f 6e73 7420 7570 5f6c 696d 6974 203d  const up_limit =
    │ │ │ -0005a570: 2075 706c 6f61 645f 7261 7465 5f6c 696d   upload_rate_lim
    │ │ │ -0005a580: 6974 286d 5f67 6c6f 6261 6c5f 636c 6173  it(m_global_clas
    │ │ │ -0005a590: 7329 3b0a 0909 0969 6e74 2063 6f6e 7374  s);....int const
    │ │ │ -0005a5a0: 2064 6f77 6e5f 6c69 6d69 7420 3d20 646f   down_limit = do
    │ │ │ -0005a5b0: 776e 6c6f 6164 5f72 6174 655f 6c69 6d69  wnload_rate_limi
    │ │ │ -0005a5c0: 7428 6d5f 676c 6f62 616c 5f63 6c61 7373  t(m_global_class
    │ │ │ -0005a5d0: 293b 0a0a 0909 0969 6620 2864 6f77 6e5f  );.....if (down_
    │ │ │ -0005a5e0: 6c69 6d69 7420 2667 743b 2030 0a09 0909  limit > 0....
    │ │ │ -0005a5f0: 0926 616d 703b 2661 6d70 3b20 6d5f 7374  .&& m_st
    │ │ │ -0005a600: 6174 2e64 6f77 6e6c 6f61 645f 6970 5f6f  at.download_ip_o
    │ │ │ -0005a610: 7665 7268 6561 6428 2920 2667 743b 3d20  verhead() >= 
    │ │ │ -0005a620: 646f 776e 5f6c 696d 6974 0a09 0909 0926  down_limit.....&
    │ │ │ -0005a630: 616d 703b 2661 6d70 3b20 6d5f 616c 6572  amp;& m_aler
    │ │ │ -0005a640: 7473 2e73 686f 756c 645f 706f 7374 266c  ts.should_post&l
    │ │ │ -0005a650: 743b 7065 7266 6f72 6d61 6e63 655f 616c  t;performance_al
    │ │ │ -0005a660: 6572 7426 6774 3b28 2929 0a09 0909 7b0a  ert>())....{.
    │ │ │ -0005a670: 0909 0909 6d5f 616c 6572 7473 2e65 6d70  ....m_alerts.emp
    │ │ │ -0005a680: 6c61 6365 5f61 6c65 7274 266c 743b 7065  lace_alert<pe
    │ │ │ -0005a690: 7266 6f72 6d61 6e63 655f 616c 6572 7426  rformance_alert&
    │ │ │ -0005a6a0: 6774 3b28 746f 7272 656e 745f 6861 6e64  gt;(torrent_hand
    │ │ │ -0005a6b0: 6c65 2829 0a09 0909 0909 2c20 7065 7266  le()......, perf
    │ │ │ -0005a6c0: 6f72 6d61 6e63 655f 616c 6572 743a 3a64  ormance_alert::d
    │ │ │ -0005a6d0: 6f77 6e6c 6f61 645f 6c69 6d69 745f 746f  ownload_limit_to
    │ │ │ -0005a6e0: 6f5f 6c6f 7729 3b0a 0909 097d 0a0a 0909  o_low);....}....
    │ │ │ -0005a6f0: 0969 6620 2875 705f 6c69 6d69 7420 2667  .if (up_limit &g
    │ │ │ -0005a700: 743b 2030 0a09 0909 0926 616d 703b 2661  t; 0.....&&a
    │ │ │ -0005a710: 6d70 3b20 6d5f 7374 6174 2e75 706c 6f61  mp; m_stat.uploa
    │ │ │ -0005a720: 645f 6970 5f6f 7665 7268 6561 6428 2920  d_ip_overhead() 
    │ │ │ -0005a730: 2667 743b 3d20 7570 5f6c 696d 6974 0a09  >= up_limit..
    │ │ │ -0005a740: 0909 0926 616d 703b 2661 6d70 3b20 6d5f  ...&& m_
    │ │ │ -0005a750: 616c 6572 7473 2e73 686f 756c 645f 706f  alerts.should_po
    │ │ │ -0005a760: 7374 266c 743b 7065 7266 6f72 6d61 6e63  st<performanc
    │ │ │ -0005a770: 655f 616c 6572 7426 6774 3b28 2929 0a09  e_alert>())..
    │ │ │ -0005a780: 0909 7b0a 0909 0909 6d5f 616c 6572 7473  ..{.....m_alerts
    │ │ │ -0005a790: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c  .emplace_alert&l
    │ │ │ -0005a7a0: 743b 7065 7266 6f72 6d61 6e63 655f 616c  t;performance_al
    │ │ │ -0005a7b0: 6572 7426 6774 3b28 746f 7272 656e 745f  ert>(torrent_
    │ │ │ -0005a7c0: 6861 6e64 6c65 2829 0a09 0909 0909 2c20  handle()......, 
    │ │ │ -0005a7d0: 7065 7266 6f72 6d61 6e63 655f 616c 6572  performance_aler
    │ │ │ -0005a7e0: 743a 3a75 706c 6f61 645f 6c69 6d69 745f  t::upload_limit_
    │ │ │ -0005a7f0: 746f 6f5f 6c6f 7729 3b0a 0909 097d 0a09  too_low);....}..
    │ │ │ -0005a800: 097d 0a0a 2369 6620 544f 5252 454e 545f  .}..#if TORRENT_
    │ │ │ -0005a810: 4142 495f 5645 5253 494f 4e20 3d3d 2031  ABI_VERSION == 1
    │ │ │ -0005a820: 0a09 096d 5f70 6561 6b5f 7570 5f72 6174  ...m_peak_up_rat
    │ │ │ -0005a830: 6520 3d20 7374 643a 3a6d 6178 286d 5f73  e = std::max(m_s
    │ │ │ -0005a840: 7461 742e 7570 6c6f 6164 5f72 6174 6528  tat.upload_rate(
    │ │ │ -0005a850: 292c 206d 5f70 6561 6b5f 7570 5f72 6174  ), m_peak_up_rat
    │ │ │ -0005a860: 6529 3b0a 2365 6e64 6966 0a0a 0909 6d5f  e);.#endif....m_
    │ │ │ -0005a870: 7374 6174 2e73 6563 6f6e 645f 7469 636b  stat.second_tick
    │ │ │ -0005a880: 2874 6963 6b5f 696e 7465 7276 616c 5f6d  (tick_interval_m
    │ │ │ -0005a890: 7329 3b0a 0a09 092f 2f20 2d2d 2d2d 2d2d  s);....// ------
    │ │ │ -0005a8a0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a8b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a8c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005a8d0: 2d2d 2d2d 2d2d 2d2d 0a09 092f 2f20 7363  --------...// sc
    │ │ │ -0005a8e0: 7261 7065 2070 6175 7365 6420 746f 7272  rape paused torr
    │ │ │ -0005a8f0: 656e 7473 2074 6861 7420 6172 6520 6175  ents that are au
    │ │ │ -0005a900: 746f 206d 616e 6167 6564 0a09 092f 2f20  to managed...// 
    │ │ │ -0005a910: 2875 6e6c 6573 7320 7468 6520 7365 7373  (unless the sess
    │ │ │ -0005a920: 696f 6e20 6973 2070 6175 7365 6429 0a3c  ion is paused).<
    │ │ │ -0005a930: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -0005a940: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -0005a950: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -0005a960: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -0005a970: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../src
    │ │ │ -0005a9a0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370  /session_impl.cp
    │ │ │ -0005a9b0: 703a 3435 3139 3c2f 613e 3c2f 7464 3e3c  p:4519<
    │ │ │ -0005a9c0: 7464 3e75 7365 2061 206c 6f77 6572 206c  td>use a lower l
    │ │ │ -0005a9d0: 696d 6974 2074 6861 6e20 6d5f 7365 7474  imit than m_sett
    │ │ │ -0005a9e0: 696e 6773 2e63 6f6e 6e65 6374 696f 6e73  ings.connections
    │ │ │ -0005a9f0: 5f6c 696d 6974 2074 6f20 616c 6c6f 6361  _limit to alloca
    │ │ │ -0005aa00: 7465 2074 6865 2074 6f20 3130 2520 6f72  te the to 10% or
    │ │ │ -0005aa10: 2073 6f20 6f66 2063 6f6e 6e65 6374 696f   so of connectio
    │ │ │ -0005aa20: 6e20 736c 6f74 7320 666f 7220 696e 636f  n slots for inco
    │ │ │ -0005aa30: 6d69 6e67 2063 6f6e 6e65 6374 696f 6e73  ming connections
    │ │ │ -0005aa40: 2063 6170 2074 6869 7320 6174 206d 6178   cap this at max
    │ │ │ -0005aa50: 202d 2031 2c20 7369 6e63 6520 7765 206d   - 1, since we m
    │ │ │ -0005aa60: 6179 2061 6464 206f 6e65 2062 656c 6f77  ay add one below
    │ │ │ -0005aa70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    us │ │ │ -0005aac0: 6520 6120 6c6f 7765 7220 6c69 6d69 7420 e a lower limit │ │ │ -0005aad0: 7468 616e 206d 5f73 6574 7469 6e67 732e than m_settings. │ │ │ -0005aae0: 636f 6e6e 6563 7469 6f6e 735f 6c69 6d69 connections_limi │ │ │ -0005aaf0: 740a 746f 2061 6c6c 6f63 6174 6520 7468 t.to allocate th │ │ │ -0005ab00: 6520 746f 2031 3025 206f 7220 736f 206f e to 10% or so o │ │ │ -0005ab10: 6620 636f 6e6e 6563 7469 6f6e 2073 6c6f f connection slo │ │ │ -0005ab20: 7473 2066 6f72 2069 6e63 6f6d 696e 670a ts for incoming. │ │ │ -0005ab30: 636f 6e6e 6563 7469 6f6e 730a 6361 7020 connections.cap │ │ │ -0005ab40: 7468 6973 2061 7420 6d61 7820 2d20 312c this at max - 1, │ │ │ -0005ab50: 2073 696e 6365 2077 6520 6d61 7920 6164 since we may ad │ │ │ -0005ab60: 6420 6f6e 6520 6265 6c6f 773c 2f68 323e d one below

    │ │ │ -0005ab70: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ -0005ab80: 6f6e 5f69 6d70 6c2e 6370 703a 3435 3139 on_impl.cpp:4519 │ │ │ -0005ab90: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0005abd0: 092f 2f20 626f 6f73 742c 2077 6869 6368  .// boost, which
    │ │ │ -0005abe0: 2061 7265 2064 6f6e 6520 696d 6d65 6469   are done immedi
    │ │ │ -0005abf0: 6174 656c 7920 6f6e 2061 2074 7261 636b  ately on a track
    │ │ │ -0005ac00: 6572 2072 6573 706f 6e73 652e 2054 6865  er response. The
    │ │ │ -0005ac10: 7365 0a09 092f 2f20 636f 6e6e 6563 7469  se...// connecti
    │ │ │ -0005ac20: 6f6e 7320 6e65 6564 7320 746f 2062 6520  ons needs to be 
    │ │ │ -0005ac30: 6465 6475 6374 6564 2066 726f 6d20 7468  deducted from th
    │ │ │ -0005ac40: 6520 7265 6775 6c61 7220 636f 6e6e 6563  e regular connec
    │ │ │ -0005ac50: 7469 6f6e 2061 7474 656d 7074 0a09 092f  tion attempt.../
    │ │ │ -0005ac60: 2f20 7175 6f74 6120 666f 7220 7468 6973  / quota for this
    │ │ │ -0005ac70: 2074 6963 6b0a 0909 6966 2028 6d5f 626f   tick...if (m_bo
    │ │ │ -0005ac80: 6f73 745f 636f 6e6e 6563 7469 6f6e 7320  ost_connections 
    │ │ │ -0005ac90: 2667 743b 2030 290a 0909 7b0a 0909 0969  > 0)...{....i
    │ │ │ -0005aca0: 6620 286d 5f62 6f6f 7374 5f63 6f6e 6e65  f (m_boost_conne
    │ │ │ -0005acb0: 6374 696f 6e73 2026 6774 3b20 6d61 785f  ctions > max_
    │ │ │ -0005acc0: 636f 6e6e 6563 7469 6f6e 7329 0a09 0909  connections)....
    │ │ │ -0005acd0: 7b0a 0909 0909 6d5f 626f 6f73 745f 636f  {.....m_boost_co
    │ │ │ -0005ace0: 6e6e 6563 7469 6f6e 7320 2d3d 206d 6178  nnections -= max
    │ │ │ -0005acf0: 5f63 6f6e 6e65 6374 696f 6e73 3b0a 0909  _connections;...
    │ │ │ -0005ad00: 0909 6d61 785f 636f 6e6e 6563 7469 6f6e  ..max_connection
    │ │ │ -0005ad10: 7320 3d20 303b 0a09 0909 7d0a 0909 0965  s = 0;....}....e
    │ │ │ -0005ad20: 6c73 650a 0909 097b 0a09 0909 096d 6178  lse....{.....max
    │ │ │ -0005ad30: 5f63 6f6e 6e65 6374 696f 6e73 202d 3d20  _connections -= 
    │ │ │ -0005ad40: 6d5f 626f 6f73 745f 636f 6e6e 6563 7469  m_boost_connecti
    │ │ │ -0005ad50: 6f6e 733b 0a09 0909 096d 5f62 6f6f 7374  ons;.....m_boost
    │ │ │ -0005ad60: 5f63 6f6e 6e65 6374 696f 6e73 203d 2030  _connections = 0
    │ │ │ -0005ad70: 3b0a 0909 097d 0a09 097d 0a0a 0909 2f2f  ;....}...}....//
    │ │ │ -0005ad80: 207a 6572 6f20 636f 6e6e 6563 7469 6f6e   zero connection
    │ │ │ -0005ad90: 7320 7370 6565 6473 2061 7265 2061 6c6c  s speeds are all
    │ │ │ -0005ada0: 6f77 6564 2c20 7765 206a 7573 7420 776f  owed, we just wo
    │ │ │ -0005adb0: 6e27 7420 6d61 6b65 2061 6e79 2063 6f6e  n't make any con
    │ │ │ -0005adc0: 6e65 6374 696f 6e73 0a09 0969 6620 286d  nections...if (m
    │ │ │ -0005add0: 6178 5f63 6f6e 6e65 6374 696f 6e73 2026  ax_connections &
    │ │ │ -0005ade0: 6c74 3b3d 2030 2920 7265 7475 726e 3b0a  lt;= 0) return;.
    │ │ │ -0005adf0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0005ae20: 0969 6e74 2063 6f6e 7374 206c 696d 6974 .int const limit │ │ │ -0005ae30: 203d 2073 7464 3a3a 6d69 6e28 6d5f 7365 = std::min(m_se │ │ │ -0005ae40: 7474 696e 6773 2e67 6574 5f69 6e74 2873 ttings.get_int(s │ │ │ -0005ae50: 6574 7469 6e67 735f 7061 636b 3a3a 636f ettings_pack::co │ │ │ -0005ae60: 6e6e 6563 7469 6f6e 735f 6c69 6d69 7429 nnections_limit) │ │ │ -0005ae70: 0a3c 2f64 6976 3e09 0909 2d20 6e75 6d5f .
    ...- num_ │ │ │ -0005ae80: 636f 6e6e 6563 7469 6f6e 7328 292c 2073 connections(), s │ │ │ -0005ae90: 7464 3a3a 6e75 6d65 7269 635f 6c69 6d69 td::numeric_limi │ │ │ -0005aea0: 7473 266c 743b 696e 7426 6774 3b3a 3a6d ts<int>::m │ │ │ -0005aeb0: 6178 2829 202d 2031 293b 0a0a 0909 2f2f ax() - 1);....// │ │ │ -0005aec0: 2074 6869 7320 6c6f 6769 6320 6973 2068 this logic is h │ │ │ -0005aed0: 6572 6520 746f 2073 6d6f 6f74 6820 6f75 ere to smooth ou │ │ │ -0005aee0: 7420 7468 6520 6e75 6d62 6572 206f 6620 t the number of │ │ │ -0005aef0: 6e65 7720 636f 6e6e 6563 7469 6f6e 0a09 new connection.. │ │ │ -0005af00: 092f 2f20 6174 7465 6d70 7473 206f 7665 .// attempts ove │ │ │ -0005af10: 7220 7469 6d65 2c20 746f 2070 7265 7665 r time, to preve │ │ │ -0005af20: 6e74 2063 6f6e 6e65 6374 696e 6720 6120 nt connecting a │ │ │ -0005af30: 6c61 7267 6520 6e75 6d62 6572 206f 660a large number of. │ │ │ -0005af40: 0909 2f2f 2073 6f63 6b65 7473 2c20 7761 ..// sockets, wa │ │ │ -0005af50: 6974 2031 3020 7365 636f 6e64 732c 2061 it 10 seconds, a │ │ │ -0005af60: 6e64 2074 6865 6e20 7472 7920 6167 6169 nd then try agai │ │ │ -0005af70: 6e0a 0909 6966 2028 6d5f 7365 7474 696e n...if (m_settin │ │ │ -0005af80: 6773 2e67 6574 5f62 6f6f 6c28 7365 7474 gs.get_bool(sett │ │ │ -0005af90: 696e 6773 5f70 6163 6b3a 3a73 6d6f 6f74 ings_pack::smoot │ │ │ -0005afa0: 685f 636f 6e6e 6563 7473 2920 2661 6d70 h_connects) & │ │ │ -0005afb0: 3b26 616d 703b 206d 6178 5f63 6f6e 6e65 ;& max_conne │ │ │ -0005afc0: 6374 696f 6e73 2026 6774 3b20 286c 696d ctions > (lim │ │ │ -0005afd0: 6974 2b31 2920 2f20 3229 0a09 0909 6d61 it+1) / 2)....ma │ │ │ -0005afe0: 785f 636f 6e6e 6563 7469 6f6e 7320 3d20 x_connections = │ │ │ -0005aff0: 286c 696d 6974 202b 2031 2920 2f20 323b (limit + 1) / 2; │ │ │ -0005b000: 0a0a 0909 6175 783a 3a76 6563 746f 7226 ....aux::vector& │ │ │ -0005b010: 6c74 3b74 6f72 7265 6e74 2a26 6774 3b26 lt;torrent*>& │ │ │ -0005b020: 616d 703b 2077 616e 745f 7065 6572 735f amp; want_peers_ │ │ │ -0005b030: 646f 776e 6c6f 6164 203d 206d 5f74 6f72 download = m_tor │ │ │ -0005b040: 7265 6e74 5f6c 6973 7473 5b74 6f72 7265 rent_lists[torre │ │ │ -0005b050: 6e74 5f77 616e 745f 7065 6572 735f 646f nt_want_peers_do │ │ │ -0005b060: 776e 6c6f 6164 5d3b 0a09 0961 7578 3a3a wnload];...aux:: │ │ │ -0005b070: 7665 6374 6f72 266c 743b 746f 7272 656e vector<torren │ │ │ -0005b080: 742a 2667 743b 2661 6d70 3b20 7761 6e74 t*>& want │ │ │ -0005b090: 5f70 6565 7273 5f66 696e 6973 6865 6420 _peers_finished │ │ │ -0005b0a0: 3d20 6d5f 746f 7272 656e 745f 6c69 7374 = m_torrent_list │ │ │ -0005b0b0: 735b 746f 7272 656e 745f 7761 6e74 5f70 s[torrent_want_p │ │ │ -0005b0c0: 6565 7273 5f66 696e 6973 6865 645d 3b0a eers_finished];. │ │ │ -0005b0d0: 0a09 092f 2f20 6966 206e 6f20 746f 7272 ...// if no torr │ │ │ -0005b0e0: 656e 7420 7761 6e74 2061 6e79 2070 6565 ent want any pee │ │ │ -0005b0f0: 7273 2c20 6a75 7374 2072 6574 7572 6e0a rs, just return. │ │ │ -0005b100: 0909 6966 2028 7761 6e74 5f70 6565 7273 ..if (want_peers │ │ │ -0005b110: 5f64 6f77 6e6c 6f61 642e 656d 7074 7928 _download.empty( │ │ │ -0005b120: 2920 2661 6d70 3b26 616d 703b 2077 616e ) && wan │ │ │ -0005b130: 745f 7065 6572 735f 6669 6e69 7368 6564 t_peers_finished │ │ │ -0005b140: 2e65 6d70 7479 2829 2920 7265 7475 726e .empty()) return │ │ │ -0005b150: 3b0a 0a09 092f 2f20 6966 2077 6520 646f ;....// if we do │ │ │ -0005b160: 6e27 7420 6861 7665 2061 6e79 2063 6f6e n't have any con │ │ │ -0005b170: 6e65 6374 696f 6e20 6174 7465 6d70 7420 nection attempt │ │ │ -0005b180: 7175 6f74 612c 2072 6574 7572 6e0a 0909 quota, return... │ │ │ -0005b190: 6966 2028 6d61 785f 636f 6e6e 6563 7469 if (max_connecti │ │ │ -0005b1a0: 6f6e 7320 266c 743b 3d20 3029 2072 6574 ons <= 0) ret │ │ │ -0005b1b0: 7572 6e3b 0a0a 0909 696e 7420 7374 6570 urn;....int step │ │ │ -0005b1c0: 735f 7369 6e63 655f 6c61 7374 5f63 6f6e s_since_last_con │ │ │ -0005b1d0: 6e65 6374 203d 2030 3b0a 0909 696e 7420 nect = 0;...int │ │ │ -0005b1e0: 636f 6e73 7420 6e75 6d5f 746f 7272 656e const num_torren │ │ │ -0005b1f0: 7473 203d 2069 6e74 2877 616e 745f 7065 ts = int(want_pe │ │ │ -0005b200: 6572 735f 6669 6e69 7368 6564 2e73 697a ers_finished.siz │ │ │ -0005b210: 6528 2920 2b20 7761 6e74 5f70 6565 7273 e() + want_peers │ │ │ -0005b220: 5f64 6f77 6e6c 6f61 642e 7369 7a65 2829 _download.size() │ │ │ -0005b230: 293b 0a09 0966 6f72 2028 3b3b 290a 0909 );...for (;;)... │ │ │ -0005b240: 7b0a 0909 0969 6620 286d 5f6e 6578 745f {....if (m_next_ │ │ │ -0005b250: 646f 776e 6c6f 6164 696e 675f 636f 6e6e downloading_conn │ │ │ -0005b260: 6563 745f 746f 7272 656e 7420 2667 743b ect_torrent > │ │ │ -0005b270: 3d20 696e 7428 7761 6e74 5f70 6565 7273 = int(want_peers │ │ │ -0005b280: 5f64 6f77 6e6c 6f61 642e 7369 7a65 2829 _download.size() │ │ │ -0005b290: 2929 0a09 0909 096d 5f6e 6578 745f 646f )).....m_next_do │ │ │ -0005b2a0: 776e 6c6f 6164 696e 675f 636f 6e6e 6563 wnloading_connec │ │ │ -0005b2b0: 745f 746f 7272 656e 7420 3d20 303b 0a0a t_torrent = 0;.. │ │ │ -0005b2c0: 0909 0969 6620 286d 5f6e 6578 745f 6669 ...if (m_next_fi │ │ │ -0005b2d0: 6e69 7368 6564 5f63 6f6e 6e65 6374 5f74 nished_connect_t │ │ │ -0005b2e0: 6f72 7265 6e74 2026 6774 3b3d 2069 6e74 orrent >= int │ │ │ -0005b2f0: 2877 616e 745f 7065 6572 735f 6669 6e69 (want_peers_fini │ │ │ -0005b300: 7368 6564 2e73 697a 6528 2929 290a 0909 shed.size()))... │ │ │ -0005b310: 0909 6d5f 6e65 7874 5f66 696e 6973 6865 ..m_next_finishe │ │ │ -0005b320: 645f 636f 6e6e 6563 745f 746f 7272 656e d_connect_torren │ │ │ -0005b330: 7420 3d20 303b 0a0a 0909 0974 6f72 7265 t = 0;.....torre │ │ │ -0005b340: 6e74 2a20 7420 3d20 6e75 6c6c 7074 723b nt* t = nullptr; │ │ │ -0005b350: 0a09 0909 2f2f 2074 6865 7265 2061 7265 ....// there are │ │ │ -0005b360: 2070 7269 6f72 6974 697a 6564 2074 6f72 prioritized tor │ │ │ -0005b370: 7265 6e74 732e 2050 6963 6b20 6f6e 6520 rents. Pick one │ │ │ -0005b380: 6f66 2074 686f 7365 0a09 0909 7768 696c of those....whil │ │ │ -0005b390: 6520 2821 6d5f 7072 696f 5f74 6f72 7265 e (!m_prio_torre │ │ │ -0005b3a0: 6e74 732e 656d 7074 7928 2929 0a3c 2f70 nts.empty()).

    re │ │ │ -0005b3e0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/s │ │ │ -0005b420: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ -0005b430: 3436 3634 3c2f 613e 3c2f 7464 3e3c 7464 4664post a message │ │ │ -0005b450: 746f 2068 6176 6520 7468 6973 2068 6170 to have this hap │ │ │ -0005b460: 7065 6e20 696d 6d65 6469 6174 656c 7920 pen immediately │ │ │ -0005b470: 696e 7374 6561 6420 6f66 2077 6169 7469 instead of waiti │ │ │ -0005b480: 6e67 2066 6f72 2074 6865 206e 6578 7420 ng for the next │ │ │ -0005b490: 7469 636b 3c2f 7464 3e3c 2f74 723e 3c74 tickpost a message │ │ │ -0005b4f0: 2074 6f20 6861 7665 2074 6869 7320 6861 to have this ha │ │ │ -0005b500: 7070 656e 0a69 6d6d 6564 6961 7465 6c79 ppen.immediately │ │ │ -0005b510: 2069 6e73 7465 6164 206f 6620 7761 6974 instead of wait │ │ │ -0005b520: 696e 6720 666f 7220 7468 6520 6e65 7874 ing for the next │ │ │ -0005b530: 2074 6963 6b3c 2f68 323e 3c68 343e 2e2e tick

    .. │ │ │ -0005b540: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ -0005b550: 6c2e 6370 703a 3436 3634 3c2f 6834 3e3c l.cpp:4664

    < │ │ │ -0005b560: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0005b570: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0005b580: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0005b590: 7820 2364 6464 3b22 3e09 0909 0963 6f6e x #ddd;">....con │ │ │ -0005b5a0: 7469 6e75 653b 0a09 0909 7d0a 0a09 0909 tinue;....}..... │ │ │ -0005b5b0: 6966 2028 2170 2d26 6774 3b69 735f 7065 if (!p->is_pe │ │ │ -0005b5c0: 6572 5f69 6e74 6572 6573 7465 6428 290a er_interested(). │ │ │ -0005b5d0: 0909 0909 7c7c 2070 2d26 6774 3b69 735f ....|| p->is_ │ │ │ -0005b5e0: 6469 7363 6f6e 6e65 6374 696e 6728 290a disconnecting(). │ │ │ -0005b5f0: 0909 0909 7c7c 2070 2d26 6774 3b69 735f ....|| p->is_ │ │ │ -0005b600: 636f 6e6e 6563 7469 6e67 2829 290a 0909 connecting())... │ │ │ -0005b610: 097b 0a09 0909 092f 2f20 7468 6973 2070 .{.....// this p │ │ │ -0005b620: 6565 7220 6973 206e 6f74 2075 6e63 686f eer is not uncho │ │ │ -0005b630: 6b61 626c 652e 2053 6f2c 2069 6620 6974 kable. So, if it │ │ │ -0005b640: 2773 2075 6e63 686f 6b65 640a 0909 0909 's unchoked..... │ │ │ -0005b650: 2f2f 2061 6c72 6561 6479 2c20 6d61 6b65 // already, make │ │ │ -0005b660: 2073 7572 6520 746f 2063 686f 6b65 2069 sure to choke i │ │ │ -0005b670: 742e 0a09 0909 0969 6620 2870 2d26 6774 t......if (p-> │ │ │ -0005b680: 3b69 735f 6368 6f6b 6564 2829 290a 0909 ;is_choked())... │ │ │ -0005b690: 0909 7b0a 0909 0909 0970 2d26 6774 3b72 ..{......p->r │ │ │ -0005b6a0: 6573 6574 5f63 686f 6b65 5f63 6f75 6e74 eset_choke_count │ │ │ -0005b6b0: 6572 7328 293b 0a09 0909 0909 636f 6e74 ers();......cont │ │ │ -0005b6c0: 696e 7565 3b0a 0909 0909 7d0a 0909 0909 inue;.....}..... │ │ │ -0005b6d0: 6966 2028 7069 2026 616d 703b 2661 6d70 if (pi && │ │ │ -0005b6e0: 3b20 7069 2d26 6774 3b6f 7074 696d 6973 ; pi->optimis │ │ │ -0005b6f0: 7469 6361 6c6c 795f 756e 6368 6f6b 6564 tically_unchoked │ │ │ -0005b700: 290a 0909 0909 7b0a 0909 0909 096d 5f73 ).....{......m_s │ │ │ -0005b710: 7461 7473 5f63 6f75 6e74 6572 732e 696e tats_counters.in │ │ │ -0005b720: 635f 7374 6174 735f 636f 756e 7465 7228 c_stats_counter( │ │ │ -0005b730: 636f 756e 7465 7273 3a3a 6e75 6d5f 7065 counters::num_pe │ │ │ -0005b740: 6572 735f 7570 5f75 6e63 686f 6b65 645f ers_up_unchoked_ │ │ │ -0005b750: 6f70 7469 6d69 7374 6963 2c20 2d31 293b optimistic, -1); │ │ │ -0005b760: 0a09 0909 0909 7069 2d26 6774 3b6f 7074 ......pi->opt │ │ │ -0005b770: 696d 6973 7469 6361 6c6c 795f 756e 6368 imistically_unch │ │ │ -0005b780: 6f6b 6564 203d 2066 616c 7365 3b0a 0909 oked = false;... │ │ │ -0005b790: 0909 092f 2f20 666f 7263 6520 6120 6e65 ...// force a ne │ │ │ -0005b7a0: 7720 6f70 7469 6d69 7374 6963 2075 6e63 w optimistic unc │ │ │ -0005b7b0: 686f 6b65 0a09 0909 0909 6d5f 6f70 7469 hoke......m_opti │ │ │ -0005b7c0: 6d69 7374 6963 5f75 6e63 686f 6b65 5f74 mistic_unchoke_t │ │ │ -0005b7d0: 696d 655f 7363 616c 6572 203d 2030 3b0a ime_scaler = 0;. │ │ │ -0005b7e0: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .. │ │ │ -0005b810: 0909 7d0a 3c2f 6469 763e 0909 0909 742d ..}.
    ....t- │ │ │ -0005b820: 2667 743b 6368 6f6b 655f 7065 6572 282a >choke_peer(* │ │ │ -0005b830: 7029 3b0a 0909 0909 702d 2667 743b 7265 p);.....p->re │ │ │ -0005b840: 7365 745f 6368 6f6b 655f 636f 756e 7465 set_choke_counte │ │ │ -0005b850: 7273 2829 3b0a 0909 0909 636f 6e74 696e rs();.....contin │ │ │ -0005b860: 7565 3b0a 0909 097d 0a0a 0909 0970 6565 ue;....}.....pee │ │ │ -0005b870: 7273 2e70 7573 685f 6261 636b 2870 2e67 rs.push_back(p.g │ │ │ -0005b880: 6574 2829 293b 0a09 097d 0a0a 0909 696e et());...}....in │ │ │ -0005b890: 7420 636f 6e73 7420 616c 6c6f 7765 645f t const allowed_ │ │ │ -0005b8a0: 7570 6c6f 6164 5f73 6c6f 7473 203d 2075 upload_slots = u │ │ │ -0005b8b0: 6e63 686f 6b65 5f73 6f72 7428 7065 6572 nchoke_sort(peer │ │ │ -0005b8c0: 730a 0909 092c 2075 6e63 686f 6b65 5f69 s...., unchoke_i │ │ │ -0005b8d0: 6e74 6572 7661 6c2c 206d 5f73 6574 7469 nterval, m_setti │ │ │ -0005b8e0: 6e67 7329 3b0a 0a09 0969 6620 286d 5f73 ngs);....if (m_s │ │ │ -0005b8f0: 6574 7469 6e67 732e 6765 745f 696e 7428 ettings.get_int( │ │ │ -0005b900: 7365 7474 696e 6773 5f70 6163 6b3a 3a63 settings_pack::c │ │ │ -0005b910: 686f 6b69 6e67 5f61 6c67 6f72 6974 686d hoking_algorithm │ │ │ -0005b920: 2920 3d3d 2073 6574 7469 6e67 735f 7061 ) == settings_pa │ │ │ -0005b930: 636b 3a3a 6669 7865 645f 736c 6f74 735f ck::fixed_slots_ │ │ │ -0005b940: 6368 6f6b 6572 290a 0909 7b0a 0909 0969 choker)...{....i │ │ │ -0005b950: 6e74 2063 6f6e 7374 2075 706c 6f61 645f nt const upload_ │ │ │ -0005b960: 736c 6f74 7320 3d20 6765 745f 696e 745f slots = get_int_ │ │ │ -0005b970: 7365 7474 696e 6728 7365 7474 696e 6773 setting(settings │ │ │ -0005b980: 5f70 6163 6b3a 3a75 6e63 686f 6b65 5f73 _pack::unchoke_s │ │ │ -0005b990: 6c6f 7473 5f6c 696d 6974 293b 0a09 0909 lots_limit);.... │ │ │ -0005b9a0: 6d5f 7374 6174 735f 636f 756e 7465 7273 m_stats_counters │ │ │ -0005b9b0: 2e73 6574 5f76 616c 7565 2863 6f75 6e74 .set_value(count │ │ │ -0005b9c0: 6572 733a 3a6e 756d 5f75 6e63 686f 6b65 ers::num_unchoke │ │ │ -0005b9d0: 5f73 6c6f 7473 2c20 7570 6c6f 6164 5f73 _slots, upload_s │ │ │ -0005b9e0: 6c6f 7473 293b 0a09 097d 0a09 0965 6c73 lots);...}...els │ │ │ -0005b9f0: 650a 0909 7b0a 0909 096d 5f73 7461 7473 e...{....m_stats │ │ │ -0005ba00: 5f63 6f75 6e74 6572 732e 7365 745f 7661 _counters.set_va │ │ │ -0005ba10: 6c75 6528 636f 756e 7465 7273 3a3a 6e75 lue(counters::nu │ │ │ -0005ba20: 6d5f 756e 6368 6f6b 655f 736c 6f74 730a m_unchoke_slots. │ │ │ -0005ba30: 0909 0909 2c20 616c 6c6f 7765 645f 7570 ...., allowed_up │ │ │ -0005ba40: 6c6f 6164 5f73 6c6f 7473 293b 0a09 097d load_slots);...} │ │ │ -0005ba50: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ -0005ba60: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -0005ba70: 470a 0909 6966 2028 7368 6f75 6c64 5f6c G...if (should_l │ │ │ -0005ba80: 6f67 2829 290a 0909 7b0a 0909 0973 6573 og())...{....ses │ │ │ -0005ba90: 7369 6f6e 5f6c 6f67 2822 5245 4341 4c43 sion_log("RECALC │ │ │ -0005baa0: 554c 4154 4520 554e 4348 4f4b 4520 534c ULATE UNCHOKE SL │ │ │ -0005bab0: 4f54 533a 205b 2070 6565 7273 3a20 2564 OTS: [ peers: %d │ │ │ -0005bac0: 2022 0a09 0909 0922 656c 6967 6962 6c65 "....."eligible │ │ │ -0005bad0: 2d70 6565 7273 3a20 2564 220a 0909 0909 -peers: %d"..... │ │ │ -0005bae0: 2220 616c 6c6f 7765 642d 736c 6f74 733a " allowed-slots: │ │ │ -0005baf0: 2025 6420 5d22 0a09 0909 092c 2069 6e74 %d ]"....., int │ │ │ -0005bb00: 286d 5f63 6f6e 6e65 6374 696f 6e73 2e73 (m_connections.s │ │ │ -0005bb10: 697a 6528 2929 0a09 0909 092c 2069 6e74 ize())....., int │ │ │ -0005bb20: 2870 6565 7273 2e73 697a 6528 2929 0a3c (peers.size()).< │ │ │ -0005bb30: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0005bb40: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0005bb50: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0005bb60: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0005bb70: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0005bba0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0005bbb0: 703a 3439 3931 3c2f 613e 3c2f 7464 3e3c p:4991< │ │ │ -0005bbc0: 7464 3e69 7420 6d69 6768 7420 6265 2061 td>it might be a │ │ │ -0005bbd0: 206e 6963 6520 6665 6174 7572 6520 6865 nice feature he │ │ │ -0005bbe0: 7265 2074 6f20 6c69 6d69 7420 7468 6520 re to limit the │ │ │ -0005bbf0: 6e75 6d62 6572 206f 6620 746f 7272 656e number of torren │ │ │ -0005bc00: 7473 2074 6f20 7365 6e64 2069 6e20 6120 ts to send in a │ │ │ -0005bc10: 7369 6e67 6c65 2075 7064 6174 652e 2042 single update. B │ │ │ -0005bc20: 7920 6a75 7374 2070 6f73 7469 6e67 2074 y just posting t │ │ │ -0005bc30: 6865 2066 6972 7374 206e 2074 6f72 7265 he first n torre │ │ │ -0005bc40: 6e74 732c 2074 6865 7920 776f 756c 6420 nts, they would │ │ │ -0005bc50: 6e69 6365 6c79 2062 6520 726f 756e 642d nicely be round- │ │ │ -0005bc60: 726f 6269 6e65 6420 6265 6361 7573 6520 robined because │ │ │ -0005bc70: 7468 6520 746f 7272 656e 7420 6c69 7374 the torrent list │ │ │ -0005bc80: 7320 6172 6520 616c 7761 7973 2070 7573 s are always pus │ │ │ -0005bc90: 6865 6420 6261 636b 2e20 5065 7268 6170 hed back. Perhap │ │ │ -0005bca0: 7320 7468 6520 7374 6174 7573 5f75 7064 s the status_upd │ │ │ -0005bcb0: 6174 655f 616c 6572 7420 636f 756c 6420 ate_alert could │ │ │ -0005bcc0: 6576 656e 2068 6176 6520 6120 6669 7865 even have a fixe │ │ │ -0005bcd0: 6420 6172 7261 7920 6f66 206e 2065 6e74 d array of n ent │ │ │ -0005bce0: 7269 6573 2072 6174 6865 7220 7468 616e ries rather than │ │ │ -0005bcf0: 2061 2076 6563 746f 722c 2074 6f20 6675 a vector, to fu │ │ │ -0005bd00: 7274 6865 7220 696d 7072 6f76 6520 6d65 rther improve me │ │ │ -0005bd10: 6d6f 7279 206c 6f63 616c 6974 792e 3c2f mory locality.

    it m │ │ │ -0005bd70: 6967 6874 2062 6520 6120 6e69 6365 2066 ight be a nice f │ │ │ -0005bd80: 6561 7475 7265 2068 6572 6520 746f 206c eature here to l │ │ │ -0005bd90: 696d 6974 2074 6865 206e 756d 6265 7220 imit the number │ │ │ -0005bda0: 6f66 2074 6f72 7265 6e74 730a 746f 2073 of torrents.to s │ │ │ -0005bdb0: 656e 6420 696e 2061 2073 696e 676c 6520 end in a single │ │ │ -0005bdc0: 7570 6461 7465 2e20 4279 206a 7573 7420 update. By just │ │ │ -0005bdd0: 706f 7374 696e 6720 7468 6520 6669 7273 posting the firs │ │ │ -0005bde0: 7420 6e20 746f 7272 656e 7473 2c20 7468 t n torrents, th │ │ │ -0005bdf0: 6579 0a77 6f75 6c64 206e 6963 656c 7920 ey.would nicely │ │ │ -0005be00: 6265 2072 6f75 6e64 2d72 6f62 696e 6564 be round-robined │ │ │ -0005be10: 2062 6563 6175 7365 2074 6865 2074 6f72 because the tor │ │ │ -0005be20: 7265 6e74 206c 6973 7473 2061 7265 2061 rent lists are a │ │ │ -0005be30: 6c77 6179 730a 7075 7368 6564 2062 6163 lways.pushed bac │ │ │ -0005be40: 6b2e 2050 6572 6861 7073 2074 6865 2073 k. Perhaps the s │ │ │ -0005be50: 7461 7475 735f 7570 6461 7465 5f61 6c65 tatus_update_ale │ │ │ -0005be60: 7274 2063 6f75 6c64 2065 7665 6e20 6861 rt could even ha │ │ │ -0005be70: 7665 2061 2066 6978 6564 0a61 7272 6179 ve a fixed.array │ │ │ -0005be80: 206f 6620 6e20 656e 7472 6965 7320 7261 of n entries ra │ │ │ -0005be90: 7468 6572 2074 6861 6e20 6120 7665 6374 ther than a vect │ │ │ -0005bea0: 6f72 2c20 746f 2066 7572 7468 6572 2069 or, to further i │ │ │ -0005beb0: 6d70 726f 7665 206d 656d 6f72 790a 6c6f mprove memory.lo │ │ │ -0005bec0: 6361 6c69 7479 2e3c 2f68 323e 3c68 343e cality.

    │ │ │ -0005bed0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0005bee0: 6d70 6c2e 6370 703a 3439 3931 3c2f 6834 mpl.cpp:4991

    ...t-
    │ │ │ -0005bf30: 2667 743b 7374 6174 7573 2826 616d 703b  >status(&
    │ │ │ -0005bf40: 7374 2c20 666c 6167 7329 3b0a 0909 7d0a  st, flags);...}.
    │ │ │ -0005bf50: 097d 0a0a 0976 6f69 6420 7365 7373 696f  .}...void sessio
    │ │ │ -0005bf60: 6e5f 696d 706c 3a3a 706f 7374 5f74 6f72  n_impl::post_tor
    │ │ │ -0005bf70: 7265 6e74 5f75 7064 6174 6573 2873 7461  rent_updates(sta
    │ │ │ -0005bf80: 7475 735f 666c 6167 735f 7420 636f 6e73  tus_flags_t cons
    │ │ │ -0005bf90: 7420 666c 6167 7329 0a09 7b0a 0909 494e  t flags)..{...IN
    │ │ │ -0005bfa0: 5641 5249 414e 545f 4348 4543 4b3b 0a0a  VARIANT_CHECK;..
    │ │ │ -0005bfb0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0005bfc0: 2869 735f 7369 6e67 6c65 5f74 6872 6561  (is_single_threa
    │ │ │ -0005bfd0: 6428 2929 3b0a 0a09 0973 7464 3a3a 7665  d());....std::ve
    │ │ │ -0005bfe0: 6374 6f72 266c 743b 746f 7272 656e 742a  ctor<torrent*
    │ │ │ -0005bff0: 2667 743b 2661 6d70 3b20 7374 6174 655f  >& state_
    │ │ │ -0005c000: 7570 6461 7465 730a 0909 093d 206d 5f74  updates....= m_t
    │ │ │ -0005c010: 6f72 7265 6e74 5f6c 6973 7473 5b61 7578  orrent_lists[aux
    │ │ │ -0005c020: 3a3a 7365 7373 696f 6e5f 696d 706c 3a3a  ::session_impl::
    │ │ │ -0005c030: 746f 7272 656e 745f 7374 6174 655f 7570  torrent_state_up
    │ │ │ -0005c040: 6461 7465 735d 3b0a 0a23 6966 2054 4f52  dates];..#if TOR
    │ │ │ -0005c050: 5245 4e54 5f55 5345 5f41 5353 4552 5453  RENT_USE_ASSERTS
    │ │ │ -0005c060: 0a09 096d 5f70 6f73 7469 6e67 5f74 6f72  ...m_posting_tor
    │ │ │ -0005c070: 7265 6e74 5f75 7064 6174 6573 203d 2074  rent_updates = t
    │ │ │ -0005c080: 7275 653b 0a23 656e 6469 660a 0a09 0973  rue;.#endif....s
    │ │ │ -0005c090: 7464 3a3a 7665 6374 6f72 266c 743b 746f  td::vector<to
    │ │ │ -0005c0a0: 7272 656e 745f 7374 6174 7573 2667 743b  rrent_status>
    │ │ │ -0005c0b0: 2073 7461 7475 733b 0a09 0973 7461 7475   status;...statu
    │ │ │ -0005c0c0: 732e 7265 7365 7276 6528 7374 6174 655f  s.reserve(state_
    │ │ │ -0005c0d0: 7570 6461 7465 732e 7369 7a65 2829 293b  updates.size());
    │ │ │ -0005c0e0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0005c110: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -0005c120: 2074 203a 2073 7461 7465 5f75 7064 6174 t : state_updat │ │ │ -0005c130: 6573 290a 3c2f 6469 763e 0909 7b0a 0909 es).
    ..{... │ │ │ -0005c140: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005c150: 742d 2667 743b 6d5f 6c69 6e6b 735b 6175 t->m_links[au │ │ │ -0005c160: 783a 3a73 6573 7369 6f6e 5f69 6d70 6c3a x::session_impl: │ │ │ -0005c170: 3a74 6f72 7265 6e74 5f73 7461 7465 5f75 :torrent_state_u │ │ │ -0005c180: 7064 6174 6573 5d2e 696e 5f6c 6973 7428 pdates].in_list( │ │ │ -0005c190: 2929 3b0a 0909 0973 7461 7475 732e 656d ));....status.em │ │ │ -0005c1a0: 706c 6163 655f 6261 636b 2829 3b0a 0909 place_back();... │ │ │ -0005c1b0: 092f 2f20 7175 6572 7969 6e67 2061 6363 .// querying acc │ │ │ -0005c1c0: 7572 6174 6520 646f 776e 6c6f 6164 2063 urate download c │ │ │ -0005c1d0: 6f75 6e74 6572 7320 6d61 7920 7265 7175 ounters may requ │ │ │ -0005c1e0: 6972 650a 0909 092f 2f20 7468 6520 746f ire....// the to │ │ │ -0005c1f0: 7272 656e 7420 746f 2062 6520 6c6f 6164 rrent to be load │ │ │ -0005c200: 6564 2e20 4c6f 6164 696e 6720 6120 746f ed. Loading a to │ │ │ -0005c210: 7272 656e 742c 2061 6e64 2065 7669 6374 rrent, and evict │ │ │ -0005c220: 696e 6720 616e 6f74 6865 720a 0909 092f ing another..../ │ │ │ -0005c230: 2f20 6f6e 6520 7769 6c6c 206c 6561 6420 / one will lead │ │ │ -0005c240: 746f 2063 616c 6c69 6e67 2073 7461 7465 to calling state │ │ │ -0005c250: 5f75 7064 6174 6564 2829 2c20 7768 6963 _updated(), whic │ │ │ -0005c260: 6820 7363 7265 7773 2077 6974 680a 0909 h screws with... │ │ │ -0005c270: 092f 2f20 7468 6973 206c 6973 7420 7768 .// this list wh │ │ │ -0005c280: 696c 6520 7765 2772 6520 776f 726b 696e ile we're workin │ │ │ -0005c290: 6720 6f6e 2069 742c 2061 6e64 2062 7265 g on it, and bre │ │ │ -0005c2a0: 616b 2074 6869 6e67 730a 0909 0974 2d26 ak things....t-& │ │ │ -0005c2b0: 6774 3b73 7461 7475 7328 2661 6d70 3b73 gt;status(&s │ │ │ -0005c2c0: 7461 7475 732e 6261 636b 2829 2c20 666c tatus.back(), fl │ │ │ -0005c2d0: 6167 7329 3b0a 0909 0974 2d26 6774 3b63 ags);....t->c │ │ │ -0005c2e0: 6c65 6172 5f69 6e5f 7374 6174 655f 7570 lear_in_state_up │ │ │ -0005c2f0: 6461 7465 2829 3b0a 0909 7d0a 0909 7374 date();...}...st │ │ │ -0005c300: 6174 655f 7570 6461 7465 732e 636c 6561 ate_updates.clea │ │ │ -0005c310: 7228 293b 0a0a 2369 6620 544f 5252 454e r();..#if TORREN │ │ │ -0005c320: 545f 5553 455f 4153 5345 5254 530a 0909 T_USE_ASSERTS... │ │ │ -0005c330: 6d5f 706f 7374 696e 675f 746f 7272 656e m_posting_torren │ │ │ -0005c340: 745f 7570 6461 7465 7320 3d20 6661 6c73 t_updates = fals │ │ │ -0005c350: 653b 0a23 656e 6469 660a 0a09 096d 5f61 e;.#endif....m_a │ │ │ -0005c360: 6c65 7274 732e 656d 706c 6163 655f 616c lerts.emplace_al │ │ │ -0005c370: 6572 7426 6c74 3b73 7461 7465 5f75 7064 ert<state_upd │ │ │ -0005c380: 6174 655f 616c 6572 7426 6774 3b28 7374 ate_alert>(st │ │ │ -0005c390: 643a 3a6d 6f76 6528 7374 6174 7573 2929 d::move(status)) │ │ │ -0005c3a0: 3b0a 097d 0a0a 0976 6f69 6420 7365 7373 ;..}...void sess │ │ │ -0005c3b0: 696f 6e5f 696d 706c 3a3a 706f 7374 5f73 ion_impl::post_s │ │ │ -0005c3c0: 6573 7369 6f6e 5f73 7461 7473 2829 0a09 ession_stats().. │ │ │ -0005c3d0: 7b0a 0909 6966 2028 216d 5f70 6f73 7465 {...if (!m_poste │ │ │ -0005c3e0: 645f 7374 6174 735f 6865 6164 6572 290a d_stats_header). │ │ │ -0005c3f0: 0909 7b0a 0909 096d 5f70 6f73 7465 645f ..{....m_posted_ │ │ │ -0005c400: 7374 6174 735f 6865 6164 6572 203d 2074 stats_header = t │ │ │ -0005c410: 7275 653b 0a09 0909 6d5f 616c 6572 7473 rue;....m_alerts │ │ │ -0005c420: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c .emplace_alert&l │ │ │ -0005c430: 743b 7365 7373 696f 6e5f 7374 6174 735f t;session_stats_ │ │ │ -0005c440: 6865 6164 6572 5f61 6c65 7274 2667 743b header_alert> │ │ │ -0005c450: 2829 3b0a 0909 7d0a 0909 6d5f 6469 736b ();...}...m_disk │ │ │ -0005c460: 5f74 6872 6561 642d 2667 743b 7570 6461 _thread->upda │ │ │ -0005c470: 7465 5f73 7461 7473 5f63 6f75 6e74 6572 te_stats_counter │ │ │ -0005c480: 7328 6d5f 7374 6174 735f 636f 756e 7465 s(m_stats_counte │ │ │ -0005c490: 7273 293b 0a0a 2369 666e 6465 6620 544f rs);..#ifndef TO │ │ │ -0005c4a0: 5252 454e 545f 4449 5341 424c 455f 4448 RRENT_DISABLE_DH │ │ │ -0005c4b0: 540a 0909 6966 2028 6d5f 6468 7429 0a3c T...if (m_dht).< │ │ │ -0005c4c0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0005c4d0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0005c4e0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0005c4f0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0005c500: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0005c530: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0005c540: 703a 3533 3835 3c2f 613e 3c2f 7464 3e3c p:5385< │ │ │ -0005c550: 7464 3e66 6163 746f 7220 6f75 7420 7468 td>factor out th │ │ │ -0005c560: 6973 206c 6f67 6963 2069 6e74 6f20 6120 is logic into a │ │ │ -0005c570: 7365 7061 7261 7465 2066 756e 6374 696f separate functio │ │ │ -0005c580: 6e20 666f 7220 756e 6974 2074 6573 7469 n for unit testi │ │ │ -0005c590: 6e67 3c2f 7464 3e3c 2f74 723e 3c74 7220 ng

    │ │ │ -0005c5e0: 6661 6374 6f72 206f 7574 2074 6869 7320 factor out this │ │ │ -0005c5f0: 6c6f 6769 6320 696e 746f 2061 2073 6570 logic into a sep │ │ │ -0005c600: 6172 6174 6520 6675 6e63 7469 6f6e 2066 arate function f │ │ │ -0005c610: 6f72 2075 6e69 740a 7465 7374 696e 673c or unit.testing< │ │ │ -0005c620: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ -0005c630: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ -0005c640: 3533 3835 3c2f 6834 3e3c 7072 6520 7374 5385

    ..if (m_setti
    │ │ │ -0005c690: 6e67 732e 6765 745f 696e 7428 7365 7474  ngs.get_int(sett
    │ │ │ -0005c6a0: 696e 6773 5f70 6163 6b3a 3a6f 7574 676f  ings_pack::outgo
    │ │ │ -0005c6b0: 696e 675f 706f 7274 2920 2667 743b 2030  ing_port) > 0
    │ │ │ -0005c6c0: 290a 0909 7b0a 2369 6664 6566 2054 4f52  )...{.#ifdef TOR
    │ │ │ -0005c6d0: 5245 4e54 5f57 494e 444f 5753 0a09 0909  RENT_WINDOWS....
    │ │ │ -0005c6e0: 732e 7365 745f 6f70 7469 6f6e 2865 7863  s.set_option(exc
    │ │ │ -0005c6f0: 6c75 7369 7665 5f61 6464 7265 7373 5f75  lusive_address_u
    │ │ │ -0005c700: 7365 2874 7275 6529 2c20 6563 293b 0a23  se(true), ec);.#
    │ │ │ -0005c710: 656c 7365 0a09 0909 732e 7365 745f 6f70  else....s.set_op
    │ │ │ -0005c720: 7469 6f6e 2874 6370 3a3a 6163 6365 7074  tion(tcp::accept
    │ │ │ -0005c730: 6f72 3a3a 7265 7573 655f 6164 6472 6573  or::reuse_addres
    │ │ │ -0005c740: 7328 7472 7565 292c 2065 6329 3b0a 2365  s(true), ec);.#e
    │ │ │ -0005c750: 6e64 6966 0a09 0909 2f2f 2069 676e 6f72  ndif....// ignor
    │ │ │ -0005c760: 6520 6572 726f 7273 2062 6563 6175 7365  e errors because
    │ │ │ -0005c770: 2074 6865 2075 6e64 6572 6c79 696e 6720   the underlying 
    │ │ │ -0005c780: 736f 636b 6574 206d 6179 206e 6f74 0a09  socket may not..
    │ │ │ -0005c790: 0909 2f2f 2062 6520 6f70 656e 6564 2079  ..// be opened y
    │ │ │ -0005c7a0: 6574 2e20 5468 6973 2068 6170 7065 6e73  et. This happens
    │ │ │ -0005c7b0: 2077 6865 6e20 7765 2772 6520 726f 7574   when we're rout
    │ │ │ -0005c7c0: 696e 6720 7468 726f 7567 680a 0909 092f  ing through..../
    │ │ │ -0005c7d0: 2f20 6120 7072 6f78 792e 2049 6e20 7468  / a proxy. In th
    │ │ │ -0005c7e0: 6174 2063 6173 652c 2077 6520 646f 6e27  at case, we don'
    │ │ │ -0005c7f0: 7420 7965 7420 6b6e 6f77 2074 6865 2061  t yet know the a
    │ │ │ -0005c800: 6464 7265 7373 206f 660a 0909 092f 2f20  ddress of....// 
    │ │ │ -0005c810: 7468 6520 7072 6f78 7920 7365 7276 6572  the proxy server
    │ │ │ -0005c820: 2c20 616e 6420 6d6f 7265 2069 6d70 6f72  , and more impor
    │ │ │ -0005c830: 7461 6e74 6c79 2c20 7765 2064 6f6e 2774  tantly, we don't
    │ │ │ -0005c840: 206b 6e6f 770a 0909 092f 2f20 7468 6520   know....// the 
    │ │ │ -0005c850: 6164 6472 6573 7320 6661 6d69 6c79 206f  address family o
    │ │ │ -0005c860: 6620 6974 7320 6164 6472 6573 732e 2054  f its address. T
    │ │ │ -0005c870: 6869 7320 6d65 616e 7320 7765 2063 616e  his means we can
    │ │ │ -0005c880: 2774 0a09 0909 2f2f 206f 7065 6e20 7468  't....// open th
    │ │ │ -0005c890: 6520 736f 636b 6574 2079 6574 2e20 5468  e socket yet. Th
    │ │ │ -0005c8a0: 6520 736f 636b 7320 6162 7374 7261 6374  e socks abstract
    │ │ │ -0005c8b0: 696f 6e20 6c61 7965 7220 6465 6665 7273  ion layer defers
    │ │ │ -0005c8c0: 0a09 0909 2f2f 206f 7065 6e69 6e67 2069  ....// opening i
    │ │ │ -0005c8d0: 742e 0a09 0909 6563 2e63 6c65 6172 2829  t.....ec.clear()
    │ │ │ -0005c8e0: 3b0a 0909 0962 696e 645f 6570 2e70 6f72  ;....bind_ep.por
    │ │ │ -0005c8f0: 7428 7374 643a 3a75 696e 7431 365f 7428  t(std::uint16_t(
    │ │ │ -0005c900: 6e65 7874 5f70 6f72 7428 2929 293b 0a09  next_port()));..
    │ │ │ -0005c910: 097d 0a0a 0909 6966 2028 6973 5f75 7470  .}....if (is_utp
    │ │ │ -0005c920: 2873 2929 0a09 097b 0a3c 6469 7620 7374  (s))...{.
    .
    .. │ │ │ -0005c960: 0975 7470 5f73 6f63 6b65 745f 696d 706c .utp_socket_impl │ │ │ -0005c970: 2a20 696d 706c 203d 206e 756c 6c70 7472 * impl = nullptr │ │ │ -0005c980: 3b0a 0909 0974 7261 6e73 706f 7274 2073 ;....transport s │ │ │ -0005c990: 736c 203d 2074 7261 6e73 706f 7274 3a3a sl = transport:: │ │ │ -0005c9a0: 706c 6169 6e74 6578 743b 0a23 6966 2054 plaintext;.#if T │ │ │ -0005c9b0: 4f52 5245 4e54 5f55 5345 5f53 534c 0a09 ORRENT_USE_SSL.. │ │ │ -0005c9c0: 0909 6966 2028 7374 643a 3a67 6574 5f69 ..if (std::get_i │ │ │ -0005c9d0: 6626 6c74 3b73 736c 5f73 7472 6561 6d26 f<ssl_stream& │ │ │ -0005c9e0: 6c74 3b75 7470 5f73 7472 6561 6d26 6774 lt;utp_stream> │ │ │ -0005c9f0: 3b26 6774 3b28 2661 6d70 3b73 2e76 6172 ;>(&s.var │ │ │ -0005ca00: 2829 2920 213d 206e 756c 6c70 7472 290a ()) != nullptr). │ │ │ -0005ca10: 0909 097b 0a09 0909 0969 6d70 6c20 3d20 ...{.....impl = │ │ │ -0005ca20: 7374 643a 3a67 6574 266c 743b 7373 6c5f std::get<ssl_ │ │ │ -0005ca30: 7374 7265 616d 266c 743b 7574 705f 7374 stream<utp_st │ │ │ -0005ca40: 7265 616d 2667 743b 2667 743b 2873 292e ream>>(s). │ │ │ -0005ca50: 6e65 7874 5f6c 6179 6572 2829 2e67 6574 next_layer().get │ │ │ -0005ca60: 5f69 6d70 6c28 293b 0a09 0909 0973 736c _impl();.....ssl │ │ │ -0005ca70: 203d 2074 7261 6e73 706f 7274 3a3a 7373 = transport::ss │ │ │ -0005ca80: 6c3b 0a09 0909 7d0a 0909 0965 6c73 650a l;....}....else. │ │ │ -0005ca90: 2365 6e64 6966 0a09 0909 0969 6d70 6c20 #endif.....impl │ │ │ -0005caa0: 3d20 7374 643a 3a67 6574 266c 743b 7574 = std::get<ut │ │ │ -0005cab0: 705f 7374 7265 616d 2667 743b 2873 292e p_stream>(s). │ │ │ -0005cac0: 6765 745f 696d 706c 2829 3b0a 0a09 0909 get_impl();..... │ │ │ -0005cad0: 7374 643a 3a76 6563 746f 7226 6c74 3b73 std::vector<s │ │ │ -0005cae0: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ -0005caf0: 743b 6c69 7374 656e 5f73 6f63 6b65 745f t;listen_socket_ │ │ │ -0005cb00: 7426 6774 3b26 6774 3b20 7769 7468 5f67 t>> with_g │ │ │ -0005cb10: 6174 6577 6179 733b 0a09 0909 7374 643a ateways;....std: │ │ │ -0005cb20: 3a73 6861 7265 645f 7074 7226 6c74 3b6c :shared_ptr<l │ │ │ -0005cb30: 6973 7465 6e5f 736f 636b 6574 5f74 2667 isten_socket_t&g │ │ │ -0005cb40: 743b 206d 6174 6368 3b0a 0909 0966 6f72 t; match;....for │ │ │ -0005cb50: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ -0005cb60: 3b20 6c73 203a 206d 5f6c 6973 7465 6e5f ; ls : m_listen_ │ │ │ -0005cb70: 736f 636b 6574 7329 0a09 0909 7b0a 0909 sockets)....{... │ │ │ -0005cb80: 0909 2f2f 2074 6869 7320 6973 2061 6c6d ..// this is alm │ │ │ -0005cb90: 6f73 742c 2062 7574 206e 6f74 2071 7569 ost, but not qui │ │ │ -0005cba0: 7465 2c20 6c69 6b65 2063 616e 5f72 6f75 te, like can_rou │ │ │ -0005cbb0: 7465 2829 0a09 0909 0969 6620 2821 286c te().....if (!(l │ │ │ -0005cbc0: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ -0005cbd0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ -0005cbe0: 743a 3a70 726f 7879 290a 0909 0909 0926 t::proxy)......& │ │ │ -0005cbf0: 616d 703b 2661 6d70 3b20 6973 5f76 3428 amp;& is_v4( │ │ │ -0005cc00: 6c73 2d26 6774 3b6c 6f63 616c 5f65 6e64 ls->local_end │ │ │ -0005cc10: 706f 696e 7429 2021 3d20 7265 6d6f 7465 point) != remote │ │ │ -0005cc20: 5f61 6464 7265 7373 2e69 735f 7634 2829 _address.is_v4() │ │ │ -0005cc30: 290a 0909 0909 0963 6f6e 7469 6e75 653b )......continue; │ │ │ -0005cc40: 0a09 0909 0969 6620 286c 732d 2667 743b .....if (ls-> │ │ │ -0005cc50: 7373 6c20 213d 2073 736c 2920 636f 6e74 ssl != ssl) cont │ │ │ -0005cc60: 696e 7565 3b0a 0909 0909 6966 2028 2128 inue;.....if (!( │ │ │ -0005cc70: 6c73 2d26 6774 3b66 6c61 6773 2026 616d ls->flags &am │ │ │ -0005cc80: 703b 206c 6973 7465 6e5f 736f 636b 6574 p; listen_socket │ │ │ -0005cc90: 5f74 3a3a 6c6f 6361 6c5f 6e65 7477 6f72 _t::local_networ │ │ │ -0005cca0: 6b29 290a 0909 0909 0977 6974 685f 6761 k))......with_ga │ │ │ -0005ccb0: 7465 7761 7973 2e70 7573 685f 6261 636b teways.push_back │ │ │ -0005ccc0: 286c 7329 3b0a 0a09 0909 0969 6620 286c (ls);......if (l │ │ │ -0005ccd0: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ -0005cce0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ -0005ccf0: 743a 3a70 726f 7879 0a09 0909 0909 7c7c t::proxy......|| │ │ │ -0005cd00: 206d 6174 6368 5f61 6464 725f 6d61 736b match_addr_mask │ │ │ -0005cd10: 286c 732d 2667 743b 6c6f 6361 6c5f 656e (ls->local_en │ │ │ -0005cd20: 6470 6f69 6e74 2e61 6464 7265 7373 2829 dpoint.address() │ │ │ -0005cd30: 2c20 7265 6d6f 7465 5f61 6464 7265 7373 , remote_address │ │ │ -0005cd40: 2c20 6c73 2d26 6774 3b6e 6574 6d61 736b , ls->netmask │ │ │ -0005cd50: 2929 0a09 0909 097b 0a09 0909 0909 2f2f )).....{......// │ │ │ -0005cd60: 2069 7320 7468 6973 2062 6574 7465 7220 is this better │ │ │ -0005cd70: 7468 616e 2074 6865 2070 7265 7669 6f75 than the previou │ │ │ -0005cd80: 7320 6d61 7463 683f 0a09 0909 0909 6d61 s match?......ma │ │ │ -0005cd90: 7463 6820 3d20 6c73 3b0a 0909 0909 7d0a tch = ls;.....}. │ │ │ -0005cda0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0005cdb0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0005cde0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0005ce10: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -0005ce20: 7070 3a36 3131 373c 2f61 3e3c 2f74 643e pp:6117 │ │ │ -0005ce30: 3c74 643e 7265 6661 6374 6f72 2c20 6d6f refactor, mo │ │ │ -0005ce40: 7665 2074 6865 2073 746f 7261 6765 2074 ve the storage t │ │ │ -0005ce50: 6f20 6468 745f 7472 6163 6b65 723c 2f74 o dht_tracker

    refac │ │ │ -0005ceb0: 746f 722c 206d 6f76 6520 7468 6520 7374 tor, move the st │ │ │ -0005cec0: 6f72 6167 6520 746f 2064 6874 5f74 7261 orage to dht_tra │ │ │ -0005ced0: 636b 6572 3c2f 6832 3e3c 6834 3e2e 2e2f cker

    ../ │ │ │ -0005cee0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0005cef0: 2e63 7070 3a36 3131 373c 2f68 343e 3c70 .cpp:6117

    #ifndef │ │ │ -0005cf40: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0005cf50: 4c4f 4747 494e 470a 0909 0973 6573 7369 LOGGING....sessi │ │ │ -0005cf60: 6f6e 5f6c 6f67 2822 6e6f 7420 7374 6172 on_log("not star │ │ │ -0005cf70: 7469 6e67 2044 4854 2c20 6f75 7473 7461 ting DHT, outsta │ │ │ -0005cf80: 6e64 696e 6720 726f 7574 6572 206c 6f6f nding router loo │ │ │ -0005cf90: 6b75 7073 3a20 2564 220a 0909 0909 2c20 kups: %d"....., │ │ │ -0005cfa0: 6d5f 6f75 7473 7461 6e64 696e 675f 726f m_outstanding_ro │ │ │ -0005cfb0: 7574 6572 5f6c 6f6f 6b75 7073 293b 0a23 uter_lookups);.# │ │ │ -0005cfc0: 656e 6469 660a 0909 0972 6574 7572 6e3b endif....return; │ │ │ -0005cfd0: 0a09 097d 0a0a 0909 6966 2028 6d5f 6162 ...}....if (m_ab │ │ │ -0005cfe0: 6f72 7429 0a09 097b 0a23 6966 6e64 6566 ort)...{.#ifndef │ │ │ -0005cff0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -0005d000: 5f4c 4f47 4749 4e47 0a09 0909 7365 7373 _LOGGING....sess │ │ │ -0005d010: 696f 6e5f 6c6f 6728 226e 6f74 2073 7461 ion_log("not sta │ │ │ -0005d020: 7274 696e 6720 4448 542c 2061 626f 7274 rting DHT, abort │ │ │ -0005d030: 696e 6722 293b 0a23 656e 6469 660a 0909 ing");.#endif... │ │ │ -0005d040: 0972 6574 7572 6e3b 0a09 097d 0a0a 2369 .return;...}..#i │ │ │ -0005d050: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -0005d060: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ -0005d070: 7365 7373 696f 6e5f 6c6f 6728 2273 7461 session_log("sta │ │ │ -0005d080: 7274 696e 6720 4448 542c 2072 756e 6e69 rting DHT, runni │ │ │ -0005d090: 6e67 3a20 2573 2c20 726f 7574 6572 206c ng: %s, router l │ │ │ -0005d0a0: 6f6f 6b75 7073 3a20 2564 220a 0909 092c ookups: %d"...., │ │ │ -0005d0b0: 206d 5f64 6874 203f 2022 7472 7565 2220 m_dht ? "true" │ │ │ -0005d0c0: 3a20 2266 616c 7365 222c 206d 5f6f 7574 : "false", m_out │ │ │ -0005d0d0: 7374 616e 6469 6e67 5f72 6f75 7465 725f standing_router_ │ │ │ -0005d0e0: 6c6f 6f6b 7570 7329 3b0a 2365 6e64 6966 lookups);.#endif │ │ │ -0005d0f0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261 ..

    │ │ │ -0005d120: 0909 6d5f 6468 745f 7374 6f72 6167 6520 ..m_dht_storage │ │ │ -0005d130: 3d20 6d5f 6468 745f 7374 6f72 6167 655f = m_dht_storage_ │ │ │ -0005d140: 636f 6e73 7472 7563 746f 7228 6d5f 7365 constructor(m_se │ │ │ -0005d150: 7474 696e 6773 293b 0a3c 2f64 6976 3e09 ttings);.
    . │ │ │ -0005d160: 096d 5f64 6874 203d 2073 7464 3a3a 6d61 .m_dht = std::ma │ │ │ -0005d170: 6b65 5f73 6861 7265 6426 6c74 3b64 6874 ke_shared<dht │ │ │ -0005d180: 3a3a 6468 745f 7472 6163 6b65 7226 6774 ::dht_tracker> │ │ │ -0005d190: 3b28 0a09 0909 7374 6174 6963 5f63 6173 ;(....static_cas │ │ │ -0005d1a0: 7426 6c74 3b64 6874 3a3a 6468 745f 6f62 t<dht::dht_ob │ │ │ -0005d1b0: 7365 7276 6572 2a26 6774 3b28 7468 6973 server*>(this │ │ │ -0005d1c0: 290a 0909 092c 206d 5f69 6f5f 636f 6e74 )...., m_io_cont │ │ │ -0005d1d0: 6578 740a 0909 092c 205b 7468 6973 5d28 ext...., [this]( │ │ │ -0005d1e0: 6175 783a 3a6c 6973 7465 6e5f 736f 636b aux::listen_sock │ │ │ -0005d1f0: 6574 5f68 616e 646c 6520 636f 6e73 7426 et_handle const& │ │ │ -0005d200: 616d 703b 2073 6f63 6b0a 0909 0909 2c20 amp; sock....., │ │ │ -0005d210: 7564 703a 3a65 6e64 706f 696e 7420 636f udp::endpoint co │ │ │ -0005d220: 6e73 7426 616d 703b 2065 700a 0909 0909 nst& ep..... │ │ │ -0005d230: 2c20 7370 616e 266c 743b 6368 6172 2063 , span<char c │ │ │ -0005d240: 6f6e 7374 2667 743b 2070 0a09 0909 092c onst> p....., │ │ │ -0005d250: 2065 7272 6f72 5f63 6f64 6526 616d 703b error_code& │ │ │ -0005d260: 2065 630a 0909 0909 2c20 7564 705f 7365 ec....., udp_se │ │ │ -0005d270: 6e64 5f66 6c61 6773 5f74 2063 6f6e 7374 nd_flags_t const │ │ │ -0005d280: 2066 6c61 6773 290a 0909 0909 7b20 7365 flags).....{ se │ │ │ -0005d290: 6e64 5f75 6470 5f70 6163 6b65 745f 6c69 nd_udp_packet_li │ │ │ -0005d2a0: 7374 656e 2873 6f63 6b2c 2065 702c 2070 sten(sock, ep, p │ │ │ -0005d2b0: 2c20 6563 2c20 666c 6167 7329 3b20 7d0a , ec, flags); }. │ │ │ -0005d2c0: 0909 092c 206d 5f73 6574 7469 6e67 730a ..., m_settings. │ │ │ -0005d2d0: 0909 092c 206d 5f73 7461 7473 5f63 6f75 ..., m_stats_cou │ │ │ -0005d2e0: 6e74 6572 730a 0909 092c 202a 6d5f 6468 nters...., *m_dh │ │ │ -0005d2f0: 745f 7374 6f72 6167 650a 0909 092c 2073 t_storage...., s │ │ │ -0005d300: 7464 3a3a 6d6f 7665 286d 5f64 6874 5f73 td::move(m_dht_s │ │ │ -0005d310: 7461 7465 2929 3b0a 0a09 0966 6f72 2028 tate));....for ( │ │ │ -0005d320: 6175 746f 2661 6d70 3b20 7320 3a20 6d5f auto& s : m_ │ │ │ -0005d330: 6c69 7374 656e 5f73 6f63 6b65 7473 290a listen_sockets). │ │ │ -0005d340: 0909 7b0a 0909 0969 6620 2873 2d26 6774 ..{....if (s-> │ │ │ -0005d350: 3b73 736c 2021 3d20 7472 616e 7370 6f72 ;ssl != transpor │ │ │ -0005d360: 743a 3a73 736c 0a09 0909 0926 616d 703b t::ssl.....& │ │ │ -0005d370: 2661 6d70 3b20 2128 732d 2667 743b 666c & !(s->fl │ │ │ -0005d380: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ -0005d390: 5f73 6f63 6b65 745f 743a 3a6c 6f63 616c _socket_t::local │ │ │ -0005d3a0: 5f6e 6574 776f 726b 2929 0a09 0909 7b0a _network))....{. │ │ │ -0005d3b0: 0909 0909 6d5f 6468 742d 2667 743b 6e65 ....m_dht->ne │ │ │ -0005d3c0: 775f 736f 636b 6574 2873 293b 0a09 0909 w_socket(s);.... │ │ │ -0005d3d0: 7d0a 0909 7d0a 0a09 0966 6f72 2028 6175 }...}....for (au │ │ │ -0005d3e0: 746f 2063 6f6e 7374 2661 6d70 3b20 6e20 to const& n │ │ │ -0005d3f0: 3a20 6d5f 6468 745f 726f 7574 6572 5f6e : m_dht_router_n │ │ │ -0005d400: 6f64 6573 290a 0909 7b0a 0909 096d 5f64 odes)...{....m_d │ │ │ -0005d410: 6874 2d26 6774 3b61 6464 5f72 6f75 7465 ht->add_route │ │ │ -0005d420: 725f 6e6f 6465 286e 293b 0a09 097d 0a0a r_node(n);...}.. │ │ │ -0005d430: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -0005d440: 7426 616d 703b 206e 203a 206d 5f64 6874 t& n : m_dht │ │ │ -0005d450: 5f6e 6f64 6573 290a 0909 7b0a 3c2f 7072 _nodes)...{.rel │ │ │ -0005d490: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/se │ │ │ -0005d4d0: 7373 696f 6e5f 696d 706c 2e63 7070 3a36 ssion_impl.cpp:6 │ │ │ -0005d4e0: 3530 303c 2f61 3e3c 2f74 643e 3c74 643e 500 │ │ │ -0005d4f0: 6173 7365 7274 7320 7468 6174 206e 6f20 asserts that no │ │ │ -0005d500: 6f75 7473 7461 6e64 696e 6720 6173 796e outstanding asyn │ │ │ -0005d510: 6320 6f70 6572 6174 696f 6e73 2061 7265 c operations are │ │ │ -0005d520: 2073 7469 6c6c 2069 6e20 666c 6967 6874 still in flight │ │ │ -0005d530: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    as │ │ │ -0005d580: 7365 7274 7320 7468 6174 206e 6f20 6f75 serts that no ou │ │ │ -0005d590: 7473 7461 6e64 696e 6720 6173 796e 6320 tstanding async │ │ │ -0005d5a0: 6f70 6572 6174 696f 6e73 2061 7265 2073 operations are s │ │ │ -0005d5b0: 7469 6c6c 2069 6e20 666c 6967 6874 3c2f till in flight

    ../src/se │ │ │ -0005d5d0: 7373 696f 6e5f 696d 706c 2e63 7070 3a36 ssion_impl.cpp:6 │ │ │ -0005d5e0: 3530 303c 2f68 343e 3c70 7265 2073 7479 500

    ..if (!m_dht) 
    │ │ │ -0005d630: 7265 7475 726e 3b0a 0909 6d5f 6468 742d  return;...m_dht-
    │ │ │ -0005d640: 2667 743b 6469 7265 6374 5f72 6571 7565  >direct_reque
    │ │ │ -0005d650: 7374 2865 702c 2065 2c20 7374 643a 3a62  st(ep, e, std::b
    │ │ │ -0005d660: 696e 6428 2661 6d70 3b6f 6e5f 6469 7265  ind(&on_dire
    │ │ │ -0005d670: 6374 5f72 6573 706f 6e73 652c 2073 7464  ct_response, std
    │ │ │ -0005d680: 3a3a 7265 6628 6d5f 616c 6572 7473 292c  ::ref(m_alerts),
    │ │ │ -0005d690: 2075 7365 7264 6174 612c 205f 3129 293b   userdata, _1));
    │ │ │ -0005d6a0: 0a09 7d0a 0a23 656e 6469 660a 0a09 626f  ..}..#endif...bo
    │ │ │ -0005d6b0: 6f6c 2073 6573 7369 6f6e 5f69 6d70 6c3a  ol session_impl:
    │ │ │ -0005d6c0: 3a69 735f 6c69 7374 656e 696e 6728 2920  :is_listening() 
    │ │ │ -0005d6d0: 636f 6e73 740a 097b 0a09 0972 6574 7572  const..{...retur
    │ │ │ -0005d6e0: 6e20 216d 5f6c 6973 7465 6e5f 736f 636b  n !m_listen_sock
    │ │ │ -0005d6f0: 6574 732e 656d 7074 7928 293b 0a09 7d0a  ets.empty();..}.
    │ │ │ -0005d700: 0a09 7365 7373 696f 6e5f 696d 706c 3a3a  ..session_impl::
    │ │ │ -0005d710: 7e73 6573 7369 6f6e 5f69 6d70 6c28 290a  ~session_impl().
    │ │ │ -0005d720: 097b 0a09 092f 2f20 7369 6e63 6520 7765  .{...// since we
    │ │ │ -0005d730: 2772 6520 6465 7374 7275 6374 696e 6720  're destructing 
    │ │ │ -0005d740: 7468 6520 7365 7373 696f 6e2c 206e 6f20  the session, no 
    │ │ │ -0005d750: 6d6f 7265 2061 6c65 7274 7320 7769 6c6c  more alerts will
    │ │ │ -0005d760: 206d 616b 6520 6974 206f 7574 2074 6f0a   make it out to.
    │ │ │ -0005d770: 0909 2f2f 2074 6865 2075 7365 722e 2053  ..// the user. S
    │ │ │ -0005d780: 6f20 7374 6f70 2070 6f73 7469 6e67 2074  o stop posting t
    │ │ │ -0005d790: 6865 6d20 6e6f 770a 0909 6d5f 616c 6572  hem now...m_aler
    │ │ │ -0005d7a0: 7473 2e73 6574 5f61 6c65 7274 5f6d 6173  ts.set_alert_mas
    │ │ │ -0005d7b0: 6b28 7b7d 293b 0a09 096d 5f61 6c65 7274  k({});...m_alert
    │ │ │ -0005d7c0: 732e 7365 745f 6e6f 7469 6679 5f66 756e  s.set_notify_fun
    │ │ │ -0005d7d0: 6374 696f 6e28 7b7d 293b 0a0a 0909 2f2f  ction({});....//
    │ │ │ -0005d7e0: 2074 6869 7320 6973 206e 6f74 2061 6c6c   this is not all
    │ │ │ -0005d7f0: 6f77 6564 2074 6f20 6265 2074 6865 206e  owed to be the n
    │ │ │ -0005d800: 6574 776f 726b 2074 6872 6561 6421 0a2f  etwork thread!./
    │ │ │ -0005d810: 2f09 0954 4f52 5245 4e54 5f41 5353 4552  /..TORRENT_ASSER
    │ │ │ -0005d820: 5428 6973 5f6e 6f74 5f74 6872 6561 6428  T(is_not_thread(
    │ │ │ -0005d830: 2929 3b0a 3c64 6976 2073 7479 6c65 3d22  ));.
    .
    ..// th │ │ │ -0005d870: 6973 2063 616e 2068 6170 7065 6e20 6966 is can happen if │ │ │ -0005d880: 2077 6520 656e 6420 7468 6520 696f 5f63 we end the io_c │ │ │ -0005d890: 6f6e 7465 7874 2072 756e 206c 6f6f 7020 ontext run loop │ │ │ -0005d8a0: 7769 7468 2061 6e20 6578 6365 7074 696f with an exceptio │ │ │ -0005d8b0: 6e0a 0909 6d5f 636f 6e6e 6563 7469 6f6e n...m_connection │ │ │ -0005d8c0: 732e 636c 6561 7228 293b 0a09 0966 6f72 s.clear();...for │ │ │ -0005d8d0: 2028 6175 746f 2661 6d70 3b20 7420 3a20 (auto& t : │ │ │ -0005d8e0: 6d5f 746f 7272 656e 7473 290a 0909 7b0a m_torrents)...{. │ │ │ -0005d8f0: 0909 0974 2d26 6774 3b70 616e 6963 2829 ...t->panic() │ │ │ -0005d900: 3b0a 0909 0974 2d26 6774 3b61 626f 7274 ;....t->abort │ │ │ -0005d910: 2829 3b0a 0909 7d0a 0909 6d5f 746f 7272 ();...}...m_torr │ │ │ -0005d920: 656e 7473 2e63 6c65 6172 2829 3b0a 0a09 ents.clear();... │ │ │ -0005d930: 092f 2f20 7468 6973 2068 6173 2070 726f .// this has pro │ │ │ -0005d940: 6261 626c 7920 6265 656e 2063 616c 6c65 bably been calle │ │ │ -0005d950: 6420 616c 7265 6164 792c 2062 7574 2069 d already, but i │ │ │ -0005d960: 6e20 6361 7365 206f 6620 7375 6464 656e n case of sudden │ │ │ -0005d970: 0a09 092f 2f20 7465 726d 696e 6174 696f ...// terminatio │ │ │ -0005d980: 6e20 7468 726f 7567 6820 616e 2065 7863 n through an exc │ │ │ -0005d990: 6570 7469 6f6e 2c20 6974 206d 6179 206e eption, it may n │ │ │ -0005d9a0: 6f74 2068 6176 6520 6265 656e 2064 6f6e ot have been don │ │ │ -0005d9b0: 650a 0909 6162 6f72 745f 7374 6167 6532 e...abort_stage2 │ │ │ -0005d9c0: 2829 3b0a 0a23 6966 2064 6566 696e 6564 ();..#if defined │ │ │ -0005d9d0: 2054 4f52 5245 4e54 5f41 5349 4f5f 4445 TORRENT_ASIO_DE │ │ │ -0005d9e0: 4255 4747 494e 470a 0909 4649 4c45 2a20 BUGGING...FILE* │ │ │ -0005d9f0: 6620 3d20 666f 7065 6e28 2277 616b 6575 f = fopen("wakeu │ │ │ -0005da00: 7073 2e6c 6f67 222c 2022 772b 2229 3b0a ps.log", "w+");. │ │ │ -0005da10: 0909 6966 2028 6620 213d 206e 756c 6c70 ..if (f != nullp │ │ │ -0005da20: 7472 290a 0909 7b0a 0909 0974 696d 655f tr)...{....time_ │ │ │ -0005da30: 706f 696e 7420 6d20 3d20 6d69 6e5f 7469 point m = min_ti │ │ │ -0005da40: 6d65 2829 3b0a 0909 0969 6620 2821 5f77 me();....if (!_w │ │ │ -0005da50: 616b 6575 7073 2e65 6d70 7479 2829 2920 akeups.empty()) │ │ │ -0005da60: 6d20 3d20 5f77 616b 6575 7073 5b30 5d2e m = _wakeups[0]. │ │ │ -0005da70: 7469 6d65 7374 616d 703b 0a09 0909 7469 timestamp;....ti │ │ │ -0005da80: 6d65 5f70 6f69 6e74 2070 7265 7620 3d20 me_point prev = │ │ │ -0005da90: 6d3b 0a09 0909 7374 643a 3a75 696e 7436 m;....std::uint6 │ │ │ -0005daa0: 345f 7420 7072 6576 5f63 7377 203d 2030 4_t prev_csw = 0 │ │ │ -0005dab0: 3b0a 0909 0969 6620 2821 5f77 616b 6575 ;....if (!_wakeu │ │ │ -0005dac0: 7073 2e65 6d70 7479 2829 2920 7072 6576 ps.empty()) prev │ │ │ -0005dad0: 5f63 7377 203d 205f 7761 6b65 7570 735b _csw = _wakeups[ │ │ │ -0005dae0: 305d 2e63 6f6e 7465 7874 5f73 7769 7463 0].context_switc │ │ │ -0005daf0: 6865 733b 0a09 0909 7374 643a 3a66 7072 hes;....std::fpr │ │ │ -0005db00: 696e 7466 2866 2c20 2261 6273 2e20 7469 intf(f, "abs. ti │ │ │ -0005db10: 6d65 5c74 7265 6c2e 2074 696d 655c 7463 me\trel. time\tc │ │ │ -0005db20: 7478 2073 7769 7463 685c 7469 646c 652d tx switch\tidle- │ │ │ -0005db30: 7761 6b65 7570 5c74 6f70 6572 6174 696f wakeup\toperatio │ │ │ -0005db40: 6e5c 6e22 293b 0a09 0909 666f 7220 2877 n\n");....for (w │ │ │ -0005db50: 616b 6575 705f 7420 636f 6e73 7426 616d akeup_t const&am │ │ │ -0005db60: 703b 2077 203a 205f 7761 6b65 7570 7329 p; w : _wakeups) │ │ │ -0005db70: 0a09 0909 7b0a 0909 0909 626f 6f6c 2063 ....{.....bool c │ │ │ -0005db80: 6f6e 7374 2069 646c 655f 7761 6b65 7570 onst idle_wakeup │ │ │ -0005db90: 203d 2077 2e63 6f6e 7465 7874 5f73 7769 = w.context_swi │ │ │ -0005dba0: 7463 6865 7320 2667 743b 2070 7265 765f tches > prev_ │ │ │ -0005dbb0: 6373 773b 0a09 0909 0973 7464 3a3a 6670 csw;.....std::fp │ │ │ -0005dbc0: 7269 6e74 6628 662c 2022 2522 2050 5249 rintf(f, "%" PRI │ │ │ -0005dbd0: 6436 3420 225c 7425 2220 5052 4964 3634 d64 "\t%" PRId64 │ │ │ -0005dbe0: 2022 5c74 2522 2050 5249 6436 3420 225c "\t%" PRId64 "\ │ │ │ -0005dbf0: 7425 635c 7425 735c 6e22 0a09 0909 0909 t%c\t%s\n"...... │ │ │ -0005dc00: 2c20 746f 7461 6c5f 6d69 6372 6f73 6563 , total_microsec │ │ │ -0005dc10: 6f6e 6473 2877 2e74 696d 6573 7461 6d70 onds(w.timestamp │ │ │ -0005dc20: 202d 206d 290a 0909 0909 092c 2074 6f74 - m)......, tot │ │ │ -0005dc30: 616c 5f6d 6963 726f 7365 636f 6e64 7328 al_microseconds( │ │ │ -0005dc40: 772e 7469 6d65 7374 616d 7020 2d20 7072 w.timestamp - pr │ │ │ -0005dc50: 6576 290a 0909 0909 092c 2077 2e63 6f6e ev)......, w.con │ │ │ -0005dc60: 7465 7874 5f73 7769 7463 6865 730a 3c2f text_switches.r │ │ │ -0005dca0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0005dcb0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0005dce0: 6d6d 6170 5f64 6973 6b5f 696f 2e63 7070 mmap_disk_io.cpp │ │ │ -0005dcf0: 3a33 3737 3c2f 613e 3c2f 7464 3e3c 7464 :377in the future, │ │ │ -0005dd10: 7072 6f70 6167 6174 6520 6578 6365 7074 propagate except │ │ │ -0005dd20: 696f 6e73 2062 6163 6b20 746f 2074 6865 ions back to the │ │ │ -0005dd30: 2068 616e 646c 6572 733c 2f74 643e 3c2f handlers

    in the fu │ │ │ -0005dd90: 7475 7265 2c20 7072 6f70 6167 6174 6520 ture, propagate │ │ │ -0005dda0: 6578 6365 7074 696f 6e73 2062 6163 6b20 exceptions back │ │ │ -0005ddb0: 746f 2074 6865 2068 616e 646c 6572 733c to the handlers< │ │ │ -0005ddc0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6d /h2>

    ../src/m │ │ │ -0005ddd0: 6d61 705f 6469 736b 5f69 6f2e 6370 703a map_disk_io.cpp: │ │ │ -0005dde0: 3337 373c 2f68 343e 3c70 7265 2073 7479 377

    .void mmap_dis
    │ │ │ -0005de30: 6b5f 696f 3a3a 7065 7266 6f72 6d5f 6a6f  k_io::perform_jo
    │ │ │ -0005de40: 6228 6175 783a 3a6d 6d61 705f 6469 736b  b(aux::mmap_disk
    │ │ │ -0005de50: 5f6a 6f62 2a20 6a2c 206a 6f62 7175 6575  _job* j, jobqueu
    │ │ │ -0005de60: 655f 7426 616d 703b 2063 6f6d 706c 6574  e_t& complet
    │ │ │ -0005de70: 6564 5f6a 6f62 7329 0a09 7b0a 0909 544f  ed_jobs)..{...TO
    │ │ │ -0005de80: 5252 454e 545f 4153 5345 5254 286a 2d26  RRENT_ASSERT(j-&
    │ │ │ -0005de90: 6774 3b6e 6578 7420 3d3d 206e 756c 6c70  gt;next == nullp
    │ │ │ -0005dea0: 7472 293b 0a09 0954 4f52 5245 4e54 5f41  tr);...TORRENT_A
    │ │ │ -0005deb0: 5353 4552 5428 286a 2d26 6774 3b66 6c61  SSERT((j->fla
    │ │ │ -0005dec0: 6773 2026 616d 703b 2061 7578 3a3a 6469  gs & aux::di
    │ │ │ -0005ded0: 736b 5f6a 6f62 3a3a 696e 5f70 726f 6772  sk_job::in_progr
    │ │ │ -0005dee0: 6573 7329 207c 7c20 216a 2d26 6774 3b73  ess) || !j->s
    │ │ │ -0005def0: 746f 7261 6765 293b 0a0a 2369 6620 4445  torage);..#if DE
    │ │ │ -0005df00: 4255 475f 4449 534b 5f54 4852 4541 440a  BUG_DISK_THREAD.
    │ │ │ -0005df10: 0909 7b0a 0909 0973 7464 3a3a 756e 6971  ..{....std::uniq
    │ │ │ -0005df20: 7565 5f6c 6f63 6b26 6c74 3b73 7464 3a3a  ue_lock<std::
    │ │ │ -0005df30: 6d75 7465 7826 6774 3b20 6c28 6d5f 6a6f  mutex> l(m_jo
    │ │ │ -0005df40: 625f 6d75 7465 7829 3b0a 0a09 0909 444c  b_mutex);.....DL
    │ │ │ -0005df50: 4f47 2822 7065 7266 6f72 6d5f 6a6f 6220  OG("perform_job 
    │ │ │ -0005df60: 6a6f 623a 2025 7320 6f75 7473 7461 6e64  job: %s outstand
    │ │ │ -0005df70: 696e 673a 2025 645c 6e22 0a09 0909 092c  ing: %d\n".....,
    │ │ │ -0005df80: 2070 7269 6e74 5f6a 6f62 282a 6a29 2e63   print_job(*j).c
    │ │ │ -0005df90: 5f73 7472 2829 0a09 0909 092c 206a 2d26  _str()....., j-&
    │ │ │ -0005dfa0: 6774 3b73 746f 7261 6765 203f 206a 2d26  gt;storage ? j-&
    │ │ │ -0005dfb0: 6774 3b73 746f 7261 6765 2d26 6774 3b6e  gt;storage->n
    │ │ │ -0005dfc0: 756d 5f6f 7574 7374 616e 6469 6e67 5f6a  um_outstanding_j
    │ │ │ -0005dfd0: 6f62 7328 2920 3a20 2d31 293b 0a09 097d  obs() : -1);...}
    │ │ │ -0005dfe0: 0a23 656e 6469 660a 0a09 0973 7464 3a3a  .#endif....std::
    │ │ │ -0005dff0: 7368 6172 6564 5f70 7472 266c 743b 6175  shared_ptr<au
    │ │ │ -0005e000: 783a 3a6d 6d61 705f 7374 6f72 6167 6526  x::mmap_storage&
    │ │ │ -0005e010: 6774 3b20 7374 6f72 6167 6520 3d20 6a2d  gt; storage = j-
    │ │ │ -0005e020: 2667 743b 7374 6f72 6167 653b 0a0a 0909  >storage;....
    │ │ │ -0005e030: 6d5f 7374 6174 735f 636f 756e 7465 7273  m_stats_counters
    │ │ │ -0005e040: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ -0005e050: 6572 2863 6f75 6e74 6572 733a 3a6e 756d  er(counters::num
    │ │ │ -0005e060: 5f72 756e 6e69 6e67 5f64 6973 6b5f 6a6f  _running_disk_jo
    │ │ │ -0005e070: 6273 2c20 3129 3b0a 0a09 092f 2f20 6361  bs, 1);....// ca
    │ │ │ -0005e080: 6c6c 2064 6973 6b20 6675 6e63 7469 6f6e  ll disk function
    │ │ │ -0005e090: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0005e0c0: 0973 7461 7475 735f 7420 7265 747b 7d3b .status_t ret{}; │ │ │ -0005e0d0: 0a3c 2f64 6976 3e09 0974 7279 0a09 097b .
    ..try...{ │ │ │ -0005e0e0: 0a09 0909 7265 7420 3d20 7374 643a 3a76 ....ret = std::v │ │ │ -0005e0f0: 6973 6974 285b 7468 6973 2c20 6a5d 2861 isit([this, j](a │ │ │ -0005e100: 7574 6f26 616d 703b 2061 2920 7b20 7265 uto& a) { re │ │ │ -0005e110: 7475 726e 2074 6869 732d 2667 743b 646f turn this->do │ │ │ -0005e120: 5f6a 6f62 2861 2c20 6a29 3b20 7d2c 206a _job(a, j); }, j │ │ │ -0005e130: 2d26 6774 3b61 6374 696f 6e29 3b0a 0909 ->action);... │ │ │ -0005e140: 7d0a 0909 6361 7463 6820 2862 6f6f 7374 }...catch (boost │ │ │ -0005e150: 3a3a 7379 7374 656d 3a3a 7379 7374 656d ::system::system │ │ │ -0005e160: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70 _error const& │ │ │ -0005e170: 3b20 6572 7229 0a09 097b 0a09 0909 7265 ; err)...{....re │ │ │ -0005e180: 7420 3d20 6469 736b 5f73 7461 7475 733a t = disk_status: │ │ │ -0005e190: 3a66 6174 616c 5f64 6973 6b5f 6572 726f :fatal_disk_erro │ │ │ -0005e1a0: 723b 0a09 0909 6a2d 2667 743b 6572 726f r;....j->erro │ │ │ -0005e1b0: 722e 6563 203d 2065 7272 2e63 6f64 6528 r.ec = err.code( │ │ │ -0005e1c0: 293b 0a09 0909 6a2d 2667 743b 6572 726f );....j->erro │ │ │ -0005e1d0: 722e 6f70 6572 6174 696f 6e20 3d20 6f70 r.operation = op │ │ │ -0005e1e0: 6572 6174 696f 6e5f 743a 3a65 7863 6570 eration_t::excep │ │ │ -0005e1f0: 7469 6f6e 3b0a 0909 7d0a 0909 6361 7463 tion;...}...catc │ │ │ -0005e200: 6820 2873 7464 3a3a 6261 645f 616c 6c6f h (std::bad_allo │ │ │ -0005e210: 6320 636f 6e73 7426 616d 703b 290a 0909 c const&)... │ │ │ -0005e220: 7b0a 0909 0972 6574 203d 2064 6973 6b5f {....ret = disk_ │ │ │ -0005e230: 7374 6174 7573 3a3a 6661 7461 6c5f 6469 status::fatal_di │ │ │ -0005e240: 736b 5f65 7272 6f72 3b0a 0909 096a 2d26 sk_error;....j-& │ │ │ -0005e250: 6774 3b65 7272 6f72 2e65 6320 3d20 6572 gt;error.ec = er │ │ │ -0005e260: 726f 7273 3a3a 6e6f 5f6d 656d 6f72 793b rors::no_memory; │ │ │ -0005e270: 0a09 0909 6a2d 2667 743b 6572 726f 722e ....j->error. │ │ │ -0005e280: 6f70 6572 6174 696f 6e20 3d20 6f70 6572 operation = oper │ │ │ -0005e290: 6174 696f 6e5f 743a 3a65 7863 6570 7469 ation_t::excepti │ │ │ -0005e2a0: 6f6e 3b0a 0909 7d0a 0909 6361 7463 6820 on;...}...catch │ │ │ -0005e2b0: 2873 7464 3a3a 6578 6365 7074 696f 6e20 (std::exception │ │ │ -0005e2c0: 636f 6e73 7426 616d 703b 290a 0909 7b0a const&)...{. │ │ │ -0005e2d0: 0909 0972 6574 203d 2064 6973 6b5f 7374 ...ret = disk_st │ │ │ -0005e2e0: 6174 7573 3a3a 6661 7461 6c5f 6469 736b atus::fatal_disk │ │ │ -0005e2f0: 5f65 7272 6f72 3b0a 0909 096a 2d26 6774 _error;....j-> │ │ │ -0005e300: 3b65 7272 6f72 2e65 6320 3d20 626f 6f73 ;error.ec = boos │ │ │ -0005e310: 743a 3a61 7369 6f3a 3a65 7272 6f72 3a3a t::asio::error:: │ │ │ -0005e320: 6661 756c 743b 0a09 0909 6a2d 2667 743b fault;....j-> │ │ │ -0005e330: 6572 726f 722e 6f70 6572 6174 696f 6e20 error.operation │ │ │ -0005e340: 3d20 6f70 6572 6174 696f 6e5f 743a 3a65 = operation_t::e │ │ │ -0005e350: 7863 6570 7469 6f6e 3b0a 0909 7d0a 0a09 xception;...}... │ │ │ -0005e360: 092f 2f20 6e6f 7465 2074 6861 7420 2d32 .// note that -2 │ │ │ -0005e370: 2065 7272 6f72 7320 6172 6520 4f4b 0a09 errors are OK.. │ │ │ -0005e380: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005e390: 2128 7265 7420 2661 6d70 3b20 6469 736b !(ret & disk │ │ │ -0005e3a0: 5f73 7461 7475 733a 3a66 6174 616c 5f64 _status::fatal_d │ │ │ -0005e3b0: 6973 6b5f 6572 726f 7229 0a09 0909 7c7c isk_error)....|| │ │ │ -0005e3c0: 2028 6a2d 2667 743b 6572 726f 722e 6563 (j->error.ec │ │ │ -0005e3d0: 2026 616d 703b 2661 6d70 3b20 6a2d 2667 && j-&g │ │ │ -0005e3e0: 743b 6572 726f 722e 6f70 6572 6174 696f t;error.operatio │ │ │ -0005e3f0: 6e20 213d 206f 7065 7261 7469 6f6e 5f74 n != operation_t │ │ │ -0005e400: 3a3a 756e 6b6e 6f77 6e29 293b 0a0a 0909 ::unknown));.... │ │ │ -0005e410: 6d5f 7374 6174 735f 636f 756e 7465 7273 m_stats_counters │ │ │ -0005e420: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ -0005e430: 6572 2863 6f75 6e74 6572 733a 3a6e 756d er(counters::num │ │ │ -0005e440: 5f72 756e 6e69 6e67 5f64 6973 6b5f 6a6f _running_disk_jo │ │ │ -0005e450: 6273 2c20 2d31 293b 0a0a 0909 6a2d 2667 bs, -1);....j-&g │ │ │ -0005e460: 743b 7265 7420 3d20 7265 743b 0a3c 2f70 t;ret = ret;.

    re │ │ │ -0005e4a0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ -0005e4e0: 6d61 705f 6469 736b 5f69 6f2e 6370 703a map_disk_io.cpp: │ │ │ -0005e4f0: 3835 363c 2f61 3e3c 2f74 643e 3c74 643e 856 │ │ │ -0005e500: 7468 6973 2069 7320 706f 7465 6e74 6961 this is potentia │ │ │ -0005e510: 6c6c 7920 7665 7279 2065 7870 656e 7369 lly very expensi │ │ │ -0005e520: 7665 2e20 4f6e 6520 7761 7920 746f 2073 ve. One way to s │ │ │ -0005e530: 6f6c 7665 2069 7420 776f 756c 6420 6265 olve it would be │ │ │ -0005e540: 2074 6f20 6861 7665 2061 2066 656e 6365 to have a fence │ │ │ -0005e550: 2066 6f72 206a 7573 7420 7468 6973 206f for just this o │ │ │ -0005e560: 6e65 2070 6965 6365 2e20 6275 7420 6974 ne piece. but it │ │ │ -0005e570: 2068 6172 646c 7920 7365 656d 7320 776f hardly seems wo │ │ │ -0005e580: 7274 6820 7468 6520 636f 6d70 6c65 7869 rth the complexi │ │ │ -0005e590: 7479 2061 6e64 2063 6f73 7420 6a75 7374 ty and cost just │ │ │ -0005e5a0: 2066 6f72 2074 6865 2065 6467 6520 6361 for the edge ca │ │ │ -0005e5b0: 7365 206f 6620 7265 6365 6976 696e 6720 se of receiving │ │ │ -0005e5c0: 6120 636f 7272 7570 7420 7069 6563 653c a corrupt piece< │ │ │ -0005e5d0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    thi │ │ │ -0005e620: 7320 6973 2070 6f74 656e 7469 616c 6c79 s is potentially │ │ │ -0005e630: 2076 6572 7920 6578 7065 6e73 6976 652e very expensive. │ │ │ -0005e640: 204f 6e65 2077 6179 2074 6f20 736f 6c76 One way to solv │ │ │ -0005e650: 650a 6974 2077 6f75 6c64 2062 6520 746f e.it would be to │ │ │ -0005e660: 2068 6176 6520 6120 6665 6e63 6520 666f have a fence fo │ │ │ -0005e670: 7220 6a75 7374 2074 6869 7320 6f6e 6520 r just this one │ │ │ -0005e680: 7069 6563 652e 0a62 7574 2069 7420 6861 piece..but it ha │ │ │ -0005e690: 7264 6c79 2073 6565 6d73 2077 6f72 7468 rdly seems worth │ │ │ -0005e6a0: 2074 6865 2063 6f6d 706c 6578 6974 7920 the complexity │ │ │ -0005e6b0: 616e 6420 636f 7374 206a 7573 7420 666f and cost just fo │ │ │ -0005e6c0: 7220 7468 6520 6564 6765 0a63 6173 6520 r the edge.case │ │ │ -0005e6d0: 6f66 2072 6563 6569 7669 6e67 2061 2063 of receiving a c │ │ │ -0005e6e0: 6f72 7275 7074 2070 6965 6365 3c2f 6832 orrupt piece

    ../src/mmap │ │ │ -0005e700: 5f64 6973 6b5f 696f 2e63 7070 3a38 3536 _disk_io.cpp:856 │ │ │ -0005e710: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0005e750: 0909 7374 643a 3a6d 6f76 6528 7072 696f  ..std::move(prio
    │ │ │ -0005e760: 7329 0a09 0929 3b0a 0a09 0961 6464 5f66  s)...);....add_f
    │ │ │ -0005e770: 656e 6365 5f6a 6f62 286a 293b 0a09 7d0a  ence_job(j);..}.
    │ │ │ -0005e780: 0a09 766f 6964 206d 6d61 705f 6469 736b  ..void mmap_disk
    │ │ │ -0005e790: 5f69 6f3a 3a61 7379 6e63 5f63 6c65 6172  _io::async_clear
    │ │ │ -0005e7a0: 5f70 6965 6365 2873 746f 7261 6765 5f69  _piece(storage_i
    │ │ │ -0005e7b0: 6e64 6578 5f74 2063 6f6e 7374 2073 746f  ndex_t const sto
    │ │ │ -0005e7c0: 7261 6765 0a09 092c 2070 6965 6365 5f69  rage..., piece_i
    │ │ │ -0005e7d0: 6e64 6578 5f74 2063 6f6e 7374 2069 6e64  ndex_t const ind
    │ │ │ -0005e7e0: 6578 2c20 7374 643a 3a66 756e 6374 696f  ex, std::functio
    │ │ │ -0005e7f0: 6e26 6c74 3b76 6f69 6428 7069 6563 655f  n<void(piece_
    │ │ │ -0005e800: 696e 6465 785f 7429 2667 743b 2068 616e  index_t)> han
    │ │ │ -0005e810: 646c 6572 290a 097b 0a09 0961 7578 3a3a  dler)..{...aux::
    │ │ │ -0005e820: 6d6d 6170 5f64 6973 6b5f 6a6f 622a 206a  mmap_disk_job* j
    │ │ │ -0005e830: 203d 206d 5f6a 6f62 5f70 6f6f 6c2e 616c   = m_job_pool.al
    │ │ │ -0005e840: 6c6f 6361 7465 5f6a 6f62 266c 743b 6175  locate_job<au
    │ │ │ -0005e850: 783a 3a6a 6f62 3a3a 636c 6561 725f 7069  x::job::clear_pi
    │ │ │ -0005e860: 6563 6526 6774 3b28 0a09 0909 7b7d 2c0a  ece>(....{},.
    │ │ │ -0005e870: 0909 096d 5f74 6f72 7265 6e74 735b 7374  ...m_torrents[st
    │ │ │ -0005e880: 6f72 6167 655d 2d26 6774 3b73 6861 7265  orage]->share
    │ │ │ -0005e890: 645f 6672 6f6d 5f74 6869 7328 292c 0a09  d_from_this(),..
    │ │ │ -0005e8a0: 0909 7374 643a 3a6d 6f76 6528 6861 6e64  ..std::move(hand
    │ │ │ -0005e8b0: 6c65 7229 2c0a 0909 0969 6e64 6578 0a09  ler),....index..
    │ │ │ -0005e8c0: 0929 3b0a 0a09 092f 2f20 7265 6775 6c61  .);....// regula
    │ │ │ -0005e8d0: 7220 6a6f 6273 2061 7265 206e 6f74 2067  r jobs are not g
    │ │ │ -0005e8e0: 7561 7261 6e74 6565 6420 746f 2062 6520  uaranteed to be 
    │ │ │ -0005e8f0: 6578 6563 7574 6564 2069 6e2d 6f72 6465  executed in-orde
    │ │ │ -0005e900: 720a 0909 2f2f 2073 696e 6365 2063 6c65  r...// since cle
    │ │ │ -0005e910: 6172 2070 6965 6365 206d 7573 7420 6775  ar piece must gu
    │ │ │ -0005e920: 6172 616e 7465 6520 7468 6174 2061 6c6c  arantee that all
    │ │ │ -0005e930: 2077 7269 7465 206a 6f62 7320 7468 6174   write jobs that
    │ │ │ -0005e940: 0a09 092f 2f20 6861 7665 2062 6565 6e20  ...// have been 
    │ │ │ -0005e950: 6973 7375 6564 2066 696e 6973 6820 6265  issued finish be
    │ │ │ -0005e960: 666f 7265 2074 6865 2063 6c65 6172 2070  fore the clear p
    │ │ │ -0005e970: 6965 6365 206a 6f62 2063 6f6d 706c 6574  iece job complet
    │ │ │ -0005e980: 6573 0a0a 3c64 6976 2073 7479 6c65 3d22  es..
    .
    < │ │ │ -0005e9c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0005e9f0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0005ea00: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/mmap_ │ │ │ -0005ea30: 6469 736b 5f69 6f2e 6370 703a 3836 313c disk_io.cpp:861< │ │ │ -0005ea40: 2f61 3e3c 2f74 643e 3c74 643e 5065 7268 /a>Perh │ │ │ -0005ea50: 6170 7320 7468 6520 6a6f 6220 7175 6575 aps the job queu │ │ │ -0005ea60: 6520 636f 756c 6420 6265 2074 7261 7665 e could be trave │ │ │ -0005ea70: 7273 6564 2061 6e64 2061 6c6c 206a 6f62 rsed and all job │ │ │ -0005ea80: 7320 666f 7220 7468 6973 2070 6965 6365 s for this piece │ │ │ -0005ea90: 2063 6f75 6c64 2062 6520 6361 6e63 656c could be cancel │ │ │ -0005eaa0: 6c65 642e 2049 6620 7468 6572 6520 6172 led. If there ar │ │ │ -0005eab0: 6520 6e6f 2074 6872 6561 6473 2063 7572 e no threads cur │ │ │ -0005eac0: 7265 6e74 6c79 2077 7269 7469 6e67 2074 rently writing t │ │ │ -0005ead0: 6f20 7468 6973 2070 6965 6365 2c20 7765 o this piece, we │ │ │ -0005eae0: 2063 6f75 6c64 2073 6b69 7020 7468 6520 could skip the │ │ │ -0005eaf0: 6665 6e63 6520 616c 746f 6765 7468 6572 fence altogether │ │ │ -0005eb00: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    Pe │ │ │ -0005eb50: 7268 6170 7320 7468 6520 6a6f 6220 7175 rhaps the job qu │ │ │ -0005eb60: 6575 6520 636f 756c 6420 6265 2074 7261 eue could be tra │ │ │ -0005eb70: 7665 7273 6564 2061 6e64 2061 6c6c 206a versed and all j │ │ │ -0005eb80: 6f62 7320 666f 7220 7468 6973 0a70 6965 obs for this.pie │ │ │ -0005eb90: 6365 2063 6f75 6c64 2062 6520 6361 6e63 ce could be canc │ │ │ -0005eba0: 656c 6c65 642e 2049 6620 7468 6572 6520 elled. If there │ │ │ -0005ebb0: 6172 6520 6e6f 2074 6872 6561 6473 2063 are no threads c │ │ │ -0005ebc0: 7572 7265 6e74 6c79 2077 7269 7469 6e67 urrently writing │ │ │ -0005ebd0: 0a74 6f20 7468 6973 2070 6965 6365 2c20 .to this piece, │ │ │ -0005ebe0: 7765 2063 6f75 6c64 2073 6b69 7020 7468 we could skip th │ │ │ -0005ebf0: 6520 6665 6e63 6520 616c 746f 6765 7468 e fence altogeth │ │ │ -0005ec00: 6572 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 er

    ../sr │ │ │ -0005ec10: 632f 6d6d 6170 5f64 6973 6b5f 696f 2e63 c/mmap_disk_io.c │ │ │ -0005ec20: 7070 3a38 3631 3c2f 6834 3e3c 7072 6520 pp:861

    ..);....add
    │ │ │ -0005ec70: 5f66 656e 6365 5f6a 6f62 286a 293b 0a09  _fence_job(j);..
    │ │ │ -0005ec80: 7d0a 0a09 766f 6964 206d 6d61 705f 6469  }...void mmap_di
    │ │ │ -0005ec90: 736b 5f69 6f3a 3a61 7379 6e63 5f63 6c65  sk_io::async_cle
    │ │ │ -0005eca0: 6172 5f70 6965 6365 2873 746f 7261 6765  ar_piece(storage
    │ │ │ -0005ecb0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2073  _index_t const s
    │ │ │ -0005ecc0: 746f 7261 6765 0a09 092c 2070 6965 6365  torage..., piece
    │ │ │ -0005ecd0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069  _index_t const i
    │ │ │ -0005ece0: 6e64 6578 2c20 7374 643a 3a66 756e 6374  ndex, std::funct
    │ │ │ -0005ecf0: 696f 6e26 6c74 3b76 6f69 6428 7069 6563  ion<void(piec
    │ │ │ -0005ed00: 655f 696e 6465 785f 7429 2667 743b 2068  e_index_t)> h
    │ │ │ -0005ed10: 616e 646c 6572 290a 097b 0a09 0961 7578  andler)..{...aux
    │ │ │ -0005ed20: 3a3a 6d6d 6170 5f64 6973 6b5f 6a6f 622a  ::mmap_disk_job*
    │ │ │ -0005ed30: 206a 203d 206d 5f6a 6f62 5f70 6f6f 6c2e   j = m_job_pool.
    │ │ │ -0005ed40: 616c 6c6f 6361 7465 5f6a 6f62 266c 743b  allocate_job<
    │ │ │ -0005ed50: 6175 783a 3a6a 6f62 3a3a 636c 6561 725f  aux::job::clear_
    │ │ │ -0005ed60: 7069 6563 6526 6774 3b28 0a09 0909 7b7d  piece>(....{}
    │ │ │ -0005ed70: 2c0a 0909 096d 5f74 6f72 7265 6e74 735b  ,....m_torrents[
    │ │ │ -0005ed80: 7374 6f72 6167 655d 2d26 6774 3b73 6861  storage]->sha
    │ │ │ -0005ed90: 7265 645f 6672 6f6d 5f74 6869 7328 292c  red_from_this(),
    │ │ │ -0005eda0: 0a09 0909 7374 643a 3a6d 6f76 6528 6861  ....std::move(ha
    │ │ │ -0005edb0: 6e64 6c65 7229 2c0a 0909 0969 6e64 6578  ndler),....index
    │ │ │ -0005edc0: 0a09 0929 3b0a 0a09 092f 2f20 7265 6775  ...);....// regu
    │ │ │ -0005edd0: 6c61 7220 6a6f 6273 2061 7265 206e 6f74  lar jobs are not
    │ │ │ -0005ede0: 2067 7561 7261 6e74 6565 6420 746f 2062   guaranteed to b
    │ │ │ -0005edf0: 6520 6578 6563 7574 6564 2069 6e2d 6f72  e executed in-or
    │ │ │ -0005ee00: 6465 720a 0909 2f2f 2073 696e 6365 2063  der...// since c
    │ │ │ -0005ee10: 6c65 6172 2070 6965 6365 206d 7573 7420  lear piece must 
    │ │ │ -0005ee20: 6775 6172 616e 7465 6520 7468 6174 2061  guarantee that a
    │ │ │ -0005ee30: 6c6c 2077 7269 7465 206a 6f62 7320 7468  ll write jobs th
    │ │ │ -0005ee40: 6174 0a09 092f 2f20 6861 7665 2062 6565  at...// have bee
    │ │ │ -0005ee50: 6e20 6973 7375 6564 2066 696e 6973 6820  n issued finish 
    │ │ │ -0005ee60: 6265 666f 7265 2074 6865 2063 6c65 6172  before the clear
    │ │ │ -0005ee70: 2070 6965 6365 206a 6f62 2063 6f6d 706c   piece job compl
    │ │ │ -0005ee80: 6574 6573 0a0a 0a3c 6469 7620 7374 796c  etes...
    ..add_fence │ │ │ -0005eec0: 5f6a 6f62 286a 293b 0a3c 2f64 6976 3e09 _job(j);.
    . │ │ │ -0005eed0: 7d0a 0a09 7374 6174 7573 5f74 206d 6d61 }...status_t mma │ │ │ -0005eee0: 705f 6469 736b 5f69 6f3a 3a64 6f5f 6a6f p_disk_io::do_jo │ │ │ -0005eef0: 6228 6175 783a 3a6a 6f62 3a3a 6861 7368 b(aux::job::hash │ │ │ -0005ef00: 2661 6d70 3b20 612c 2061 7578 3a3a 6d6d & a, aux::mm │ │ │ -0005ef10: 6170 5f64 6973 6b5f 6a6f 622a 206a 290a ap_disk_job* j). │ │ │ -0005ef20: 097b 0a09 092f 2f20 7765 2772 6520 6e6f .{...// we're no │ │ │ -0005ef30: 7420 7573 696e 6720 6120 6361 6368 652e t using a cache. │ │ │ -0005ef40: 2054 6869 7320 6973 2074 6865 2073 696d This is the sim │ │ │ -0005ef50: 706c 6520 7061 7468 0a09 092f 2f20 6a75 ple path...// ju │ │ │ -0005ef60: 7374 2072 6561 6420 7374 7261 6967 6874 st read straight │ │ │ -0005ef70: 2066 726f 6d20 7468 6520 6669 6c65 0a09 from the file.. │ │ │ -0005ef80: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005ef90: 6d5f 6d61 6769 6320 3d3d 2030 7831 3333 m_magic == 0x133 │ │ │ -0005efa0: 3729 3b0a 0a09 0962 6f6f 6c20 636f 6e73 7);....bool cons │ │ │ -0005efb0: 7420 7631 203d 2062 6f6f 6c28 6a2d 2667 t v1 = bool(j-&g │ │ │ -0005efc0: 743b 666c 6167 7320 2661 6d70 3b20 6469 t;flags & di │ │ │ -0005efd0: 736b 5f69 6e74 6572 6661 6365 3a3a 7631 sk_interface::v1 │ │ │ -0005efe0: 5f68 6173 6829 3b0a 0909 626f 6f6c 2063 _hash);...bool c │ │ │ -0005eff0: 6f6e 7374 2076 3220 3d20 2161 2e62 6c6f onst v2 = !a.blo │ │ │ -0005f000: 636b 5f68 6173 6865 732e 656d 7074 7928 ck_hashes.empty( │ │ │ -0005f010: 293b 0a0a 0909 696e 7420 636f 6e73 7420 );....int const │ │ │ -0005f020: 7069 6563 655f 7369 7a65 203d 2076 3120 piece_size = v1 │ │ │ -0005f030: 3f20 6a2d 2667 743b 7374 6f72 6167 652d ? j->storage- │ │ │ -0005f040: 2667 743b 6669 6c65 7328 292e 7069 6563 >files().piec │ │ │ -0005f050: 655f 7369 7a65 2861 2e70 6965 6365 2920 e_size(a.piece) │ │ │ -0005f060: 3a20 303b 0a09 0969 6e74 2063 6f6e 7374 : 0;...int const │ │ │ -0005f070: 2070 6965 6365 5f73 697a 6532 203d 2076 piece_size2 = v │ │ │ -0005f080: 3220 3f20 6a2d 2667 743b 7374 6f72 6167 2 ? j->storag │ │ │ -0005f090: 652d 2667 743b 6669 6c65 7328 292e 7069 e->files().pi │ │ │ -0005f0a0: 6563 655f 7369 7a65 3228 612e 7069 6563 ece_size2(a.piec │ │ │ -0005f0b0: 6529 203a 2030 3b0a 0909 696e 7420 636f e) : 0;...int co │ │ │ -0005f0c0: 6e73 7420 626c 6f63 6b73 5f69 6e5f 7069 nst blocks_in_pi │ │ │ -0005f0d0: 6563 6520 3d20 7631 203f 2028 7069 6563 ece = v1 ? (piec │ │ │ -0005f0e0: 655f 7369 7a65 202b 2064 6566 6175 6c74 e_size + default │ │ │ -0005f0f0: 5f62 6c6f 636b 5f73 697a 6520 2d20 3129 _block_size - 1) │ │ │ -0005f100: 202f 2064 6566 6175 6c74 5f62 6c6f 636b / default_block │ │ │ -0005f110: 5f73 697a 6520 3a20 303b 0a09 0969 6e74 _size : 0;...int │ │ │ -0005f120: 2063 6f6e 7374 2062 6c6f 636b 735f 696e const blocks_in │ │ │ -0005f130: 5f70 6965 6365 3220 3d20 7632 203f 206a _piece2 = v2 ? j │ │ │ -0005f140: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -0005f150: 3b66 696c 6573 2829 2e62 6c6f 636b 735f ;files().blocks_ │ │ │ -0005f160: 696e 5f70 6965 6365 3228 612e 7069 6563 in_piece2(a.piec │ │ │ -0005f170: 6529 203a 2030 3b0a 0909 6175 783a 3a6f e) : 0;...aux::o │ │ │ -0005f180: 7065 6e5f 6d6f 6465 5f74 2063 6f6e 7374 pen_mode_t const │ │ │ -0005f190: 2066 696c 655f 6d6f 6465 203d 2066 696c file_mode = fil │ │ │ -0005f1a0: 655f 6d6f 6465 5f66 6f72 5f6a 6f62 286a e_mode_for_job(j │ │ │ -0005f1b0: 293b 0a0a 0909 544f 5252 454e 545f 4153 );....TORRENT_AS │ │ │ -0005f1c0: 5345 5254 2821 7632 207c 7c20 696e 7428 SERT(!v2 || int( │ │ │ -0005f1d0: 612e 626c 6f63 6b5f 6861 7368 6573 2e73 a.block_hashes.s │ │ │ -0005f1e0: 697a 6528 2929 2026 6774 3b3d 2062 6c6f ize()) >= blo │ │ │ -0005f1f0: 636b 735f 696e 5f70 6965 6365 3229 3b0a cks_in_piece2);. │ │ │ -0005f200: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0005f210: 2876 3120 7c7c 2076 3229 3b0a 0a09 092f (v1 || v2);..../ │ │ │ -0005f220: 2f20 636f 6e73 756d 6520 5348 412d 3235 / consume SHA-25 │ │ │ -0005f230: 3620 6861 7368 6573 2063 6f6d 7075 7465 6 hashes compute │ │ │ -0005f240: 6420 696e 6c69 6e65 2064 7572 696e 6720 d inline during │ │ │ -0005f250: 646f 5f6a 6f62 2877 7269 7465 293b 2066 do_job(write); f │ │ │ -0005f260: 6f72 2061 6e79 0a09 092f 2f20 626c 6f63 or any...// bloc │ │ │ -0005f270: 6b20 7768 6572 6520 7765 2064 6f6e 2774 k where we don't │ │ │ -0005f280: 2068 6176 6520 6f6e 6520 2861 6e20 616c have one (an al │ │ │ -0005f290: 6c2d 7a65 726f 2065 6e74 7279 292c 2066 l-zero entry), f │ │ │ -0005f2a0: 616c 6c20 7468 726f 7567 6820 746f 2074 all through to t │ │ │ -0005f2b0: 6865 0a09 092f 2f20 6578 6973 7469 6e67 he...// existing │ │ │ -0005f2c0: 2070 6174 680a 0909 6175 783a 3a76 6563 path...aux::vec │ │ │ -0005f2d0: 746f 7226 6c74 3b73 6861 3235 365f 6861 tor<sha256_ha │ │ │ -0005f2e0: 7368 2667 743b 2063 6f6e 7374 2070 6320 sh> const pc │ │ │ -0005f2f0: 3d0a 0909 0976 3220 3f20 6a2d 2667 743b =....v2 ? j-> │ │ │ -0005f300: 7374 6f72 6167 652d 2667 743b 7461 6b65 storage->take │ │ │ -0005f310: 5f70 7265 636f 6d70 7574 6564 5f76 3228 _precomputed_v2( │ │ │ -0005f320: 612e 7069 6563 6529 203a 2061 7578 3a3a a.piece) : aux:: │ │ │ -0005f330: 7665 6374 6f72 266c 743b 7368 6132 3536 vector<sha256 │ │ │ -0005f340: 5f68 6173 6826 6774 3b7b 7d3b 0a0a 0909 _hash>{};.... │ │ │ -0005f350: 6861 7368 6572 2068 3b0a 0909 696e 7420 hasher h;...int │ │ │ -0005f360: 7265 7420 3d20 303b 0a09 0969 6e74 206f ret = 0;...int o │ │ │ -0005f370: 6666 7365 7420 3d20 303b 0a09 0969 6e74 ffset = 0;...int │ │ │ -0005f380: 2063 6f6e 7374 2062 6c6f 636b 735f 746f const blocks_to │ │ │ -0005f390: 5f72 6561 6420 3d20 7374 643a 3a6d 6178 _read = std::max │ │ │ -0005f3a0: 2862 6c6f 636b 735f 696e 5f70 6965 6365 (blocks_in_piece │ │ │ -0005f3b0: 2c20 626c 6f63 6b73 5f69 6e5f 7069 6563 , blocks_in_piec │ │ │ -0005f3c0: 6532 293b 0a3c 2f70 7265 3e3c 2f74 643e e2);.
    │ │ │ -0005f3d0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0005f400: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0005f410: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0005f420: 7074 3a65 7870 616e 6428 3232 3129 223e pt:expand(221)"> │ │ │ -0005f430: 2e2e 2f73 7263 2f73 6573 7369 6f6e 2e63 ../src/session.c │ │ │ -0005f440: 7070 3a32 3631 3c2f 613e 3c2f 7464 3e3c pp:261
    < │ │ │ -0005f450: 7464 3e73 7461 7274 2829 2073 686f 756c td>start() shoul │ │ │ -0005f460: 6420 6a75 7374 2075 7365 2066 6c61 6773 d just use flags │ │ │ -0005f470: 206f 7574 206f 6620 7468 6520 7365 7373 out of the sess │ │ │ -0005f480: 696f 6e5f 7061 7261 6d73 206f 626a 6563 ion_params objec │ │ │ -0005f490: 742c 3c2f 7464 3e3c 2f74 723e 3c74 7220 t,

    │ │ │ -0005f4e0: 7374 6172 7428 2920 7368 6f75 6c64 206a start() should j │ │ │ -0005f4f0: 7573 7420 7573 6520 666c 6167 7320 6f75 ust use flags ou │ │ │ -0005f500: 7420 6f66 2074 6865 2073 6573 7369 6f6e t of the session │ │ │ -0005f510: 5f70 6172 616d 7320 6f62 6a65 6374 2c3c _params object,< │ │ │ -0005f520: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ -0005f530: 6573 7369 6f6e 2e63 7070 3a32 3631 3c2f ession.cpp:261
    ..S
    │ │ │ -0005f580: 4554 5f42 4f4f 4c28 7265 7374 7269 6374  ET_BOOL(restrict
    │ │ │ -0005f590: 5f72 6f75 7469 6e67 5f69 7073 293b 0a09  _routing_ips);..
    │ │ │ -0005f5a0: 0953 4554 5f42 4f4f 4c28 7265 7374 7269  .SET_BOOL(restri
    │ │ │ -0005f5b0: 6374 5f73 6561 7263 685f 6970 7329 3b0a  ct_search_ips);.
    │ │ │ -0005f5c0: 0909 5345 545f 424f 4f4c 2865 7874 656e  ..SET_BOOL(exten
    │ │ │ -0005f5d0: 6465 645f 726f 7574 696e 675f 7461 626c  ded_routing_tabl
    │ │ │ -0005f5e0: 6529 3b0a 0909 5345 545f 424f 4f4c 2861  e);...SET_BOOL(a
    │ │ │ -0005f5f0: 6767 7265 7373 6976 655f 6c6f 6f6b 7570  ggressive_lookup
    │ │ │ -0005f600: 7329 3b0a 0909 5345 545f 424f 4f4c 2870  s);...SET_BOOL(p
    │ │ │ -0005f610: 7269 7661 6379 5f6c 6f6f 6b75 7073 293b  rivacy_lookups);
    │ │ │ -0005f620: 0a09 0953 4554 5f42 4f4f 4c28 656e 666f  ...SET_BOOL(enfo
    │ │ │ -0005f630: 7263 655f 6e6f 6465 5f69 6429 3b0a 0909  rce_node_id);...
    │ │ │ -0005f640: 5345 545f 424f 4f4c 2869 676e 6f72 655f  SET_BOOL(ignore_
    │ │ │ -0005f650: 6461 726b 5f69 6e74 6572 6e65 7429 3b0a  dark_internet);.
    │ │ │ -0005f660: 0909 5345 545f 494e 5428 626c 6f63 6b5f  ..SET_INT(block_
    │ │ │ -0005f670: 7469 6d65 6f75 7429 3b0a 0909 5345 545f  timeout);...SET_
    │ │ │ -0005f680: 494e 5428 626c 6f63 6b5f 7261 7465 6c69  INT(block_rateli
    │ │ │ -0005f690: 6d69 7429 3b0a 0909 5345 545f 424f 4f4c  mit);...SET_BOOL
    │ │ │ -0005f6a0: 2872 6561 645f 6f6e 6c79 293b 0a09 0953  (read_only);...S
    │ │ │ -0005f6b0: 4554 5f49 4e54 2869 7465 6d5f 6c69 6665  ET_INT(item_life
    │ │ │ -0005f6c0: 7469 6d65 293b 0a09 0953 4554 5f49 4e54  time);...SET_INT
    │ │ │ -0005f6d0: 2875 706c 6f61 645f 7261 7465 5f6c 696d  (upload_rate_lim
    │ │ │ -0005f6e0: 6974 293b 0a09 0953 4554 5f49 4e54 2873  it);...SET_INT(s
    │ │ │ -0005f6f0: 616d 706c 655f 696e 666f 6861 7368 6573  ample_infohashes
    │ │ │ -0005f700: 5f69 6e74 6572 7661 6c29 3b0a 0909 5345  _interval);...SE
    │ │ │ -0005f710: 545f 494e 5428 6d61 785f 696e 666f 6861  T_INT(max_infoha
    │ │ │ -0005f720: 7368 6573 5f73 616d 706c 655f 636f 756e  shes_sample_coun
    │ │ │ -0005f730: 7429 3b0a 2375 6e64 6566 2053 4554 5f42  t);.#undef SET_B
    │ │ │ -0005f740: 4f4f 4c0a 2375 6e64 6566 2053 4554 5f49  OOL.#undef SET_I
    │ │ │ -0005f750: 4e54 0a09 097d 0a23 656e 6469 660a 2365  NT...}.#endif.#e
    │ │ │ -0005f760: 6e64 6966 0a0a 3c64 6976 2073 7479 6c65  ndif..
    ..m_impl = s │ │ │ -0005f7a0: 7464 3a3a 6d61 6b65 5f73 6861 7265 6426 td::make_shared& │ │ │ -0005f7b0: 6c74 3b61 7578 3a3a 7365 7373 696f 6e5f lt;aux::session_ │ │ │ -0005f7c0: 696d 706c 2667 743b 2873 7464 3a3a 7265 impl>(std::re │ │ │ -0005f7d0: 6628 2a69 6f73 290a 3c2f 6469 763e 0909 f(*ios).
    .. │ │ │ -0005f7e0: 092c 2073 7464 3a3a 6d6f 7665 2870 6172 ., std::move(par │ │ │ -0005f7f0: 616d 732e 7365 7474 696e 6773 290a 0909 ams.settings)... │ │ │ -0005f800: 092c 2073 7464 3a3a 6d6f 7665 2870 6172 ., std::move(par │ │ │ -0005f810: 616d 732e 6469 736b 5f69 6f5f 636f 6e73 ams.disk_io_cons │ │ │ -0005f820: 7472 7563 746f 7229 0a09 0909 2c20 666c tructor)...., fl │ │ │ -0005f830: 6167 7329 3b0a 0909 2a73 7461 7469 635f ags);...*static_ │ │ │ -0005f840: 6361 7374 266c 743b 7365 7373 696f 6e5f cast<session_ │ │ │ -0005f850: 6861 6e64 6c65 2a26 6774 3b28 7468 6973 handle*>(this │ │ │ -0005f860: 2920 3d20 7365 7373 696f 6e5f 6861 6e64 ) = session_hand │ │ │ -0005f870: 6c65 286d 5f69 6d70 6c29 3b0a 0a23 6966 le(m_impl);..#if │ │ │ -0005f880: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ -0005f890: 4142 4c45 5f45 5854 454e 5349 4f4e 530a ABLE_EXTENSIONS. │ │ │ -0005f8a0: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -0005f8b0: 2065 7874 203a 2070 6172 616d 732e 6578 ext : params.ex │ │ │ -0005f8c0: 7465 6e73 696f 6e73 290a 0909 7b0a 0909 tensions)...{... │ │ │ -0005f8d0: 0965 7874 2d26 6774 3b6c 6f61 645f 7374 .ext->load_st │ │ │ -0005f8e0: 6174 6528 7061 7261 6d73 2e65 7874 5f73 ate(params.ext_s │ │ │ -0005f8f0: 7461 7465 293b 0a09 0909 6d5f 696d 706c tate);....m_impl │ │ │ -0005f900: 2d26 6774 3b61 6464 5f73 6573 5f65 7874 ->add_ses_ext │ │ │ -0005f910: 656e 7369 6f6e 2873 7464 3a3a 6d6f 7665 ension(std::move │ │ │ -0005f920: 2865 7874 2929 3b0a 0909 7d0a 2365 6e64 (ext));...}.#end │ │ │ -0005f930: 6966 0a0a 2369 666e 6465 6620 544f 5252 if..#ifndef TORR │ │ │ -0005f940: 454e 545f 4449 5341 424c 455f 4448 540a ENT_DISABLE_DHT. │ │ │ -0005f950: 0909 6d5f 696d 706c 2d26 6774 3b73 6574 ..m_impl->set │ │ │ -0005f960: 5f64 6874 5f73 7461 7465 2873 7464 3a3a _dht_state(std:: │ │ │ -0005f970: 6d6f 7665 2870 6172 616d 732e 6468 745f move(params.dht_ │ │ │ -0005f980: 7374 6174 6529 293b 0a0a 0909 544f 5252 state));....TORR │ │ │ -0005f990: 454e 545f 4153 5345 5254 2870 6172 616d ENT_ASSERT(param │ │ │ -0005f9a0: 732e 6468 745f 7374 6f72 6167 655f 636f s.dht_storage_co │ │ │ -0005f9b0: 6e73 7472 7563 746f 7229 3b0a 0909 6d5f nstructor);...m_ │ │ │ -0005f9c0: 696d 706c 2d26 6774 3b73 6574 5f64 6874 impl->set_dht │ │ │ -0005f9d0: 5f73 746f 7261 6765 2873 7464 3a3a 6d6f _storage(std::mo │ │ │ -0005f9e0: 7665 2870 6172 616d 732e 6468 745f 7374 ve(params.dht_st │ │ │ -0005f9f0: 6f72 6167 655f 636f 6e73 7472 7563 746f orage_constructo │ │ │ -0005fa00: 7229 293b 0a23 656e 6469 660a 0a09 0969 r));.#endif....i │ │ │ -0005fa10: 6620 2821 7061 7261 6d73 2e69 705f 6669 f (!params.ip_fi │ │ │ -0005fa20: 6c74 6572 2e65 6d70 7479 2829 290a 0909 lter.empty())... │ │ │ -0005fa30: 7b0a 0909 0973 7464 3a3a 7368 6172 6564 {....std::shared │ │ │ -0005fa40: 5f70 7472 266c 743b 6970 5f66 696c 7465 _ptr<ip_filte │ │ │ -0005fa50: 7226 6774 3b20 636f 7079 203d 2073 7464 r> copy = std │ │ │ -0005fa60: 3a3a 6d61 6b65 5f73 6861 7265 6426 6c74 ::make_shared< │ │ │ -0005fa70: 3b69 705f 6669 6c74 6572 2667 743b 2873 ;ip_filter>(s │ │ │ -0005fa80: 7464 3a3a 6d6f 7665 2870 6172 616d 732e td::move(params. │ │ │ -0005fa90: 6970 5f66 696c 7465 7229 293b 0a09 0909 ip_filter));.... │ │ │ -0005faa0: 6d5f 696d 706c 2d26 6774 3b73 6574 5f69 m_impl->set_i │ │ │ -0005fab0: 705f 6669 6c74 6572 2873 7464 3a3a 6d6f p_filter(std::mo │ │ │ -0005fac0: 7665 2863 6f70 7929 293b 0a09 097d 0a0a ve(copy));...}.. │ │ │ -0005fad0: 0909 6d5f 696d 706c 2d26 6774 3b73 7461 ..m_impl->sta │ │ │ -0005fae0: 7274 5f73 6573 7369 6f6e 2829 3b0a 0a09 rt_session();... │ │ │ -0005faf0: 0969 6620 2869 6e74 6572 6e61 6c5f 6578 .if (internal_ex │ │ │ -0005fb00: 6563 7574 6f72 290a 0909 7b0a 3c2f 7072 ecutor)...{.rel │ │ │ -0005fb40: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/ma │ │ │ -0005fb80: 676e 6574 5f75 7269 2e63 7070 3a34 3235 gnet_uri.cpp:425 │ │ │ -0005fb90: 3c2f 613e 3c2f 7464 3e3c 7464 3e77 6861 wha │ │ │ -0005fba0: 7427 7320 7468 6520 7269 6768 7420 6e75 t's the right nu │ │ │ -0005fbb0: 6d62 6572 2068 6572 653f 3c2f 7464 3e3c mber here?< │ │ │ -0005fbc0: 2f74 723e 3c74 7220 6964 3d22 3232 3222 /tr>

    what's t │ │ │ -0005fc10: 6865 2072 6967 6874 206e 756d 6265 7220 he right number │ │ │ -0005fc20: 6865 7265 3f3c 2f68 323e 3c68 343e 2e2e here?

    .. │ │ │ -0005fc30: 2f73 7263 2f6d 6167 6e65 745f 7572 692e /src/magnet_uri. │ │ │ -0005fc40: 6370 703a 3432 353c 2f68 343e 3c70 7265 cpp:425

    ...}....el
    │ │ │ -0005fc90: 7365 2069 6620 2861 7578 3a3a 7374 7269  se if (aux::stri
    │ │ │ -0005fca0: 6e67 5f65 7175 616c 5f6e 6f5f 6361 7365  ng_equal_no_case
    │ │ │ -0005fcb0: 286e 616d 652c 2022 736f 225f 7376 2929  (name, "so"_sv))
    │ │ │ -0005fcc0: 202f 2f20 7365 6c65 6374 2d6f 6e6c 7920   // select-only 
    │ │ │ -0005fcd0: 2866 696c 6573 290a 0909 097b 0a09 0909  (files)....{....
    │ │ │ -0005fce0: 092f 2f20 6163 6365 7074 206f 6e6c 7920  .// accept only 
    │ │ │ -0005fcf0: 6469 6769 7473 2c20 272d 2720 616e 6420  digits, '-' and 
    │ │ │ -0005fd00: 272c 270a 0909 0909 6966 2028 7374 643a  ','.....if (std:
    │ │ │ -0005fd10: 3a61 6e79 5f6f 6628 7661 6c75 652e 6265  :any_of(value.be
    │ │ │ -0005fd20: 6769 6e28 292c 2076 616c 7565 2e65 6e64  gin(), value.end
    │ │ │ -0005fd30: 2829 2c20 5b5d 2863 6861 7220 6329 0a09  (), [](char c)..
    │ │ │ -0005fd40: 0909 0909 7b20 7265 7475 726e 2021 6175  ....{ return !au
    │ │ │ -0005fd50: 783a 3a69 735f 6469 6769 7428 6329 2026  x::is_digit(c) &
    │ │ │ -0005fd60: 616d 703b 2661 6d70 3b20 6320 213d 2027  amp;& c != '
    │ │ │ -0005fd70: 2d27 2026 616d 703b 2661 6d70 3b20 6320  -' && c 
    │ │ │ -0005fd80: 213d 2027 2c27 3b20 7d29 290a 0909 0909  != ','; })).....
    │ │ │ -0005fd90: 0963 6f6e 7469 6e75 653b 0a0a 0909 0909  .continue;......
    │ │ │ -0005fda0: 2f2f 206d 616b 6520 7375 7265 2061 6c6c  // make sure all
    │ │ │ -0005fdb0: 2066 696c 6520 7072 696f 7269 7469 6573   file priorities
    │ │ │ -0005fdc0: 2061 7265 2073 6574 2074 6f20 302c 2065   are set to 0, e
    │ │ │ -0005fdd0: 7863 6570 7420 7468 6520 6f6e 6573 0a09  xcept the ones..
    │ │ │ -0005fde0: 0909 092f 2f20 7765 2073 7065 6369 6679  ...// we specify
    │ │ │ -0005fdf0: 2069 6e20 7468 6520 6669 6c65 5f70 7269   in the file_pri
    │ │ │ -0005fe00: 6f72 6974 6965 730a 0909 0909 702e 666c  orities.....p.fl
    │ │ │ -0005fe10: 6167 7320 7c3d 2074 6f72 7265 6e74 5f66  ags |= torrent_f
    │ │ │ -0005fe20: 6c61 6773 3a3a 6465 6661 756c 745f 646f  lags::default_do
    │ │ │ -0005fe30: 6e74 5f64 6f77 6e6c 6f61 643b 0a0a 0909  nt_download;....
    │ │ │ -0005fe40: 0909 646f 0a09 0909 097b 0a09 0909 0909  ..do.....{......
    │ │ │ -0005fe50: 7374 7269 6e67 5f76 6965 7720 746f 6b65  string_view toke
    │ │ │ -0005fe60: 6e3b 0a09 0909 0909 7374 643a 3a74 6965  n;......std::tie
    │ │ │ -0005fe70: 2874 6f6b 656e 2c20 7661 6c75 6529 203d  (token, value) =
    │ │ │ -0005fe80: 2061 7578 3a3a 7370 6c69 745f 7374 7269   aux::split_stri
    │ │ │ -0005fe90: 6e67 2876 616c 7565 2c20 272c 2729 3b0a  ng(value, ',');.
    │ │ │ -0005fea0: 0a09 0909 0909 6966 2028 746f 6b65 6e2e  ......if (token.
    │ │ │ -0005feb0: 656d 7074 7928 2929 2063 6f6e 7469 6e75  empty()) continu
    │ │ │ -0005fec0: 653b 0a0a 0909 0909 0969 6e74 2069 6478  e;.......int idx
    │ │ │ -0005fed0: 312c 2069 6478 323b 0a3c 6469 7620 7374  1, idx2;.
    .....cons │ │ │ -0005ff10: 7465 7870 7220 696e 7420 6d61 785f 696e texpr int max_in │ │ │ -0005ff20: 6465 7820 3d20 3130 3030 303b 202f 2f20 dex = 10000; // │ │ │ -0005ff30: 6361 6e27 7420 7269 736b 206f 7574 206f can't risk out o │ │ │ -0005ff40: 6620 6d65 6d6f 7279 0a3c 2f64 6976 3e0a f memory.
    . │ │ │ -0005ff50: 0909 0909 0961 7574 6f20 636f 6e73 7420 .....auto const │ │ │ -0005ff60: 6469 7669 6465 7220 3d20 746f 6b65 6e2e divider = token. │ │ │ -0005ff70: 6669 6e64 5f66 6972 7374 5f6f 6628 272d find_first_of('- │ │ │ -0005ff80: 2729 3b0a 0909 0909 0969 6620 2864 6976 ');......if (div │ │ │ -0005ff90: 6964 6572 2021 3d20 7374 643a 3a73 7472 ider != std::str │ │ │ -0005ffa0: 696e 673a 3a6e 706f 7329 202f 2f20 6974 ing::npos) // it │ │ │ -0005ffb0: 2773 2061 2072 616e 6765 0a09 0909 0909 's a range...... │ │ │ -0005ffc0: 7b0a 0909 0909 0909 6966 2028 6469 7669 {.......if (divi │ │ │ -0005ffd0: 6465 7220 3d3d 2030 2920 2f2f 206e 6f20 der == 0) // no │ │ │ -0005ffe0: 7374 6172 7420 696e 6465 780a 0909 0909 start index..... │ │ │ -0005fff0: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ -00060000: 0909 0969 6620 2864 6976 6964 6572 203d ...if (divider = │ │ │ -00060010: 3d20 746f 6b65 6e2e 7369 7a65 2829 202d = token.size() - │ │ │ -00060020: 2031 2920 2f2f 206e 6f20 656e 6420 696e 1) // no end in │ │ │ -00060030: 6465 780a 0909 0909 0909 0963 6f6e 7469 dex........conti │ │ │ -00060040: 6e75 653b 0a0a 0909 0909 0909 6175 746f nue;........auto │ │ │ -00060050: 2063 6f6e 7374 2066 6972 7374 203d 2061 const first = a │ │ │ -00060060: 7578 3a3a 7061 7273 655f 6465 6369 6d61 ux::parse_decima │ │ │ -00060070: 6c28 746f 6b65 6e2e 7375 6273 7472 2830 l(token.substr(0 │ │ │ -00060080: 2c20 6469 7669 6465 7229 293b 0a09 0909 , divider));.... │ │ │ -00060090: 0909 0969 6620 2821 6669 7273 7420 7c7c ...if (!first || │ │ │ -000600a0: 202a 6669 7273 7420 266c 743b 2030 207c *first < 0 | │ │ │ -000600b0: 7c20 2a66 6972 7374 2026 6774 3b20 6d61 | *first > ma │ │ │ -000600c0: 785f 696e 6465 7829 202f 2f20 696e 7661 x_index) // inva │ │ │ -000600d0: 6c69 6420 696e 6465 780a 0909 0909 0909 lid index....... │ │ │ -000600e0: 0963 6f6e 7469 6e75 653b 0a09 0909 0909 .continue;...... │ │ │ -000600f0: 0961 7574 6f20 636f 6e73 7420 6c61 7374 .auto const last │ │ │ -00060100: 203d 2061 7578 3a3a 7061 7273 655f 6465 = aux::parse_de │ │ │ -00060110: 6369 6d61 6c28 746f 6b65 6e2e 7375 6273 cimal(token.subs │ │ │ -00060120: 7472 2864 6976 6964 6572 202b 2031 2929 tr(divider + 1)) │ │ │ -00060130: 3b0a 0909 0909 0909 6966 2028 216c 6173 ;.......if (!las │ │ │ -00060140: 7420 7c7c 202a 6c61 7374 2026 6c74 3b20 t || *last < │ │ │ -00060150: 3020 7c7c 202a 6c61 7374 2026 6774 3b20 0 || *last > │ │ │ -00060160: 6d61 785f 696e 6465 7829 202f 2f20 696e max_index) // in │ │ │ -00060170: 7661 6c69 6420 696e 6465 780a 0909 0909 valid index..... │ │ │ -00060180: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ -00060190: 0909 0969 6478 3120 3d20 2a66 6972 7374 ...idx1 = *first │ │ │ -000601a0: 3b0a 0909 0909 0909 6964 7832 203d 202a ;.......idx2 = * │ │ │ -000601b0: 6c61 7374 3b0a 0a09 0909 0909 0969 6620 last;........if │ │ │ -000601c0: 2869 6478 3120 2667 743b 2069 6478 3229 (idx1 > idx2) │ │ │ -000601d0: 202f 2f20 7772 6f6e 6720 7261 6e67 6520 // wrong range │ │ │ -000601e0: 6c69 6d69 7473 0a09 0909 0909 0909 636f limits........co │ │ │ -000601f0: 6e74 696e 7565 3b0a 0909 0909 097d 0a09 ntinue;......}.. │ │ │ -00060200: 0909 0909 656c 7365 202f 2f20 6974 2773 ....else // it's │ │ │ -00060210: 2061 6e20 696e 6465 780a 0909 0909 097b an index......{ │ │ │ -00060220: 0a09 0909 0909 0961 7574 6f20 636f 6e73 .......auto cons │ │ │ -00060230: 7420 6964 7820 3d20 6175 783a 3a70 6172 t idx = aux::par │ │ │ -00060240: 7365 5f64 6563 696d 616c 2874 6f6b 656e se_decimal(token │ │ │ -00060250: 293b 0a09 0909 0909 0969 6620 2821 6964 );.......if (!id │ │ │ -00060260: 7820 7c7c 202a 6964 7820 266c 743b 2030 x || *idx < 0 │ │ │ -00060270: 207c 7c20 2a69 6478 2026 6774 3b20 6d61 || *idx > ma │ │ │ -00060280: 785f 696e 6465 7829 202f 2f20 696e 7661 x_index) // inva │ │ │ -00060290: 6c69 6420 696e 6465 780a 0909 0909 0909 lid index....... │ │ │ -000602a0: 0963 6f6e 7469 6e75 653b 0a09 0909 0909 .continue;...... │ │ │ -000602b0: 0969 6478 3120 3d20 2a69 6478 3b0a 0909 .idx1 = *idx;... │ │ │ -000602c0: 0909 0909 6964 7832 203d 2069 6478 313b ....idx2 = idx1; │ │ │ -000602d0: 0a09 0909 0909 7d0a 0a3c 2f70 7265 3e3c ......}..
    < │ │ │ -000602e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00060310: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00060320: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/udp_s │ │ │ -00060350: 6f63 6b65 742e 6370 703a 3634 333c 2f61 ocket.cpp:643perhap │ │ │ -00060370: 7320 616e 2061 7474 656d 7074 2073 686f s an attempt sho │ │ │ -00060380: 756c 6420 6265 206d 6164 6520 746f 2062 uld be made to b │ │ │ -00060390: 696e 6420 6d5f 736f 636b 7335 5f73 6f63 ind m_socks5_soc │ │ │ -000603a0: 6b20 746f 2074 6865 2064 6576 6963 6520 k to the device │ │ │ -000603b0: 6f66 206d 5f6c 6973 7465 6e5f 736f 636b of m_listen_sock │ │ │ -000603c0: 6574 3c2f 7464 3e3c 2f74 723e 3c74 7220 et

    │ │ │ -00060410: 7065 7268 6170 7320 616e 2061 7474 656d perhaps an attem │ │ │ -00060420: 7074 2073 686f 756c 6420 6265 206d 6164 pt should be mad │ │ │ -00060430: 6520 746f 2062 696e 6420 6d5f 736f 636b e to bind m_sock │ │ │ -00060440: 7335 5f73 6f63 6b20 746f 2074 6865 0a64 s5_sock to the.d │ │ │ -00060450: 6576 6963 6520 6f66 206d 5f6c 6973 7465 evice of m_liste │ │ │ -00060460: 6e5f 736f 636b 6574 3c2f 6832 3e3c 6834 n_socket

    ../src/udp_sock │ │ │ -00060480: 6574 2e63 7070 3a36 3433 3c2f 6834 3e3c et.cpp:643

    < │ │ │ -00060490: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000604a0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000604b0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -000604c0: 7820 2364 6464 3b22 3e09 6966 2028 6563 x #ddd;">.if (ec │ │ │ -000604d0: 290a 097b 0a09 0969 6620 286d 5f61 6c65 )..{...if (m_ale │ │ │ -000604e0: 7274 732e 7368 6f75 6c64 5f70 6f73 7426 rts.should_post& │ │ │ -000604f0: 6c74 3b73 6f63 6b73 355f 616c 6572 7426 lt;socks5_alert& │ │ │ -00060500: 6774 3b28 2929 0a09 0909 6d5f 616c 6572 gt;())....m_aler │ │ │ -00060510: 7473 2e65 6d70 6c61 6365 5f61 6c65 7274 ts.emplace_alert │ │ │ -00060520: 266c 743b 736f 636b 7335 5f61 6c65 7274 <socks5_alert │ │ │ -00060530: 2667 743b 286d 5f70 726f 7879 5f61 6464 >(m_proxy_add │ │ │ -00060540: 722c 206f 7065 7261 7469 6f6e 5f74 3a3a r, operation_t:: │ │ │ -00060550: 736f 636b 5f6f 7074 696f 6e2c 2065 6329 sock_option, ec) │ │ │ -00060560: 3b0a 0909 6563 2e63 6c65 6172 2829 3b0a ;...ec.clear();. │ │ │ -00060570: 097d 0a23 656e 6469 660a 2365 6e64 6966 .}.#endif.#endif │ │ │ -00060580: 0a0a 0974 6370 3a3a 656e 6470 6f69 6e74 ...tcp::endpoint │ │ │ -00060590: 2063 6f6e 7374 2062 696e 645f 6570 286d const bind_ep(m │ │ │ -000605a0: 5f6c 6973 7465 6e5f 736f 636b 6574 2e67 _listen_socket.g │ │ │ -000605b0: 6574 5f6c 6f63 616c 5f65 6e64 706f 696e et_local_endpoin │ │ │ -000605c0: 7428 292e 6164 6472 6573 7328 292c 2030 t().address(), 0 │ │ │ -000605d0: 293b 0a09 6d5f 736f 636b 7335 5f73 6f63 );..m_socks5_soc │ │ │ -000605e0: 6b2e 6269 6e64 2862 696e 645f 6570 2c20 k.bind(bind_ep, │ │ │ -000605f0: 6563 293b 0a09 6966 2028 6563 290a 097b ec);..if (ec)..{ │ │ │ -00060600: 0a09 0969 6620 286d 5f61 6c65 7274 732e ...if (m_alerts. │ │ │ -00060610: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b73 should_post<s │ │ │ -00060620: 6f63 6b73 355f 616c 6572 7426 6774 3b28 ocks5_alert>( │ │ │ -00060630: 2929 0a09 0909 6d5f 616c 6572 7473 2e65 ))....m_alerts.e │ │ │ -00060640: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -00060650: 736f 636b 7335 5f61 6c65 7274 2667 743b socks5_alert> │ │ │ -00060660: 286d 5f70 726f 7879 5f61 6464 722c 206f (m_proxy_addr, o │ │ │ -00060670: 7065 7261 7469 6f6e 5f74 3a3a 736f 636b peration_t::sock │ │ │ -00060680: 5f62 696e 642c 2065 6329 3b0a 0909 2b2b _bind, ec);...++ │ │ │ -00060690: 6d5f 6661 696c 7572 6573 3b0a 0909 7265 m_failures;...re │ │ │ -000606a0: 7472 795f 636f 6e6e 6563 7469 6f6e 2829 try_connection() │ │ │ -000606b0: 3b0a 0909 7265 7475 726e 3b0a 097d 0a0a ;...return;..}.. │ │ │ -000606c0: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .< │ │ │ -000606f0: 2f64 6976 3e09 4144 445f 4f55 5453 5441 /div>.ADD_OUTSTA │ │ │ -00060700: 4e44 494e 475f 4153 594e 4328 2273 6f63 NDING_ASYNC("soc │ │ │ -00060710: 6b73 353a 3a6f 6e5f 636f 6e6e 6563 7465 ks5::on_connecte │ │ │ -00060720: 6422 293b 0a09 6d5f 736f 636b 7335 5f73 d");..m_socks5_s │ │ │ -00060730: 6f63 6b2e 6173 796e 635f 636f 6e6e 6563 ock.async_connec │ │ │ -00060740: 7428 6d5f 7072 6f78 795f 6164 6472 0a09 t(m_proxy_addr.. │ │ │ -00060750: 092c 2073 7464 3a3a 6269 6e64 2826 616d ., std::bind(&am │ │ │ -00060760: 703b 736f 636b 7335 3a3a 6f6e 5f63 6f6e p;socks5::on_con │ │ │ -00060770: 6e65 6374 6564 2c20 7365 6c66 2829 2c20 nected, self(), │ │ │ -00060780: 5f31 2929 3b0a 0a09 4144 445f 4f55 5453 _1));...ADD_OUTS │ │ │ -00060790: 5441 4e44 494e 475f 4153 594e 4328 2273 TANDING_ASYNC("s │ │ │ -000607a0: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563 ocks5::on_connec │ │ │ -000607b0: 745f 7469 6d65 6f75 7422 293b 0a09 6d5f t_timeout");..m_ │ │ │ -000607c0: 7469 6d65 722e 6578 7069 7265 735f 6166 timer.expires_af │ │ │ -000607d0: 7465 7228 7365 636f 6e64 7328 3130 2929 ter(seconds(10)) │ │ │ -000607e0: 3b0a 096d 5f74 696d 6572 2e61 7379 6e63 ;..m_timer.async │ │ │ -000607f0: 5f77 6169 7428 7374 643a 3a62 696e 6428 _wait(std::bind( │ │ │ -00060800: 2661 6d70 3b73 6f63 6b73 353a 3a6f 6e5f &socks5::on_ │ │ │ -00060810: 636f 6e6e 6563 745f 7469 6d65 6f75 740a connect_timeout. │ │ │ -00060820: 0909 2c20 7365 6c66 2829 2c20 5f31 2929 .., self(), _1)) │ │ │ -00060830: 3b0a 7d0a 0a76 6f69 6420 736f 636b 7335 ;.}..void socks5 │ │ │ -00060840: 3a3a 6f6e 5f63 6f6e 6e65 6374 5f74 696d ::on_connect_tim │ │ │ -00060850: 656f 7574 2865 7272 6f72 5f63 6f64 6520 eout(error_code │ │ │ -00060860: 636f 6e73 7426 616d 703b 2065 290a 7b0a const& e).{. │ │ │ -00060870: 0943 4f4d 504c 4554 455f 4153 594e 4328 .COMPLETE_ASYNC( │ │ │ -00060880: 2273 6f63 6b73 353a 3a6f 6e5f 636f 6e6e "socks5::on_conn │ │ │ -00060890: 6563 745f 7469 6d65 6f75 7422 293b 0a0a ect_timeout");.. │ │ │ -000608a0: 0969 6620 2865 203d 3d20 626f 6f73 743a .if (e == boost: │ │ │ -000608b0: 3a61 7369 6f3a 3a65 7272 6f72 3a3a 6f70 :asio::error::op │ │ │ -000608c0: 6572 6174 696f 6e5f 6162 6f72 7465 6429 eration_aborted) │ │ │ -000608d0: 2072 6574 7572 6e3b 0a0a 0969 6620 286d return;...if (m │ │ │ -000608e0: 5f61 626f 7274 2920 7265 7475 726e 3b0a _abort) return;. │ │ │ -000608f0: 0a09 6966 2028 6d5f 616c 6572 7473 2e73 ..if (m_alerts.s │ │ │ -00060900: 686f 756c 645f 706f 7374 266c 743b 736f hould_post<so │ │ │ -00060910: 636b 7335 5f61 6c65 7274 2667 743b 2829 cks5_alert>() │ │ │ -00060920: 290a 0909 6d5f 616c 6572 7473 2e65 6d70 )...m_alerts.emp │ │ │ -00060930: 6c61 6365 5f61 6c65 7274 266c 743b 736f lace_alert<so │ │ │ -00060940: 636b 7335 5f61 6c65 7274 2667 743b 286d cks5_alert>(m │ │ │ -00060950: 5f70 726f 7879 5f61 6464 722c 206f 7065 _proxy_addr, ope │ │ │ -00060960: 7261 7469 6f6e 5f74 3a3a 636f 6e6e 6563 ration_t::connec │ │ │ -00060970: 742c 2065 7272 6f72 733a 3a74 696d 6564 t, errors::timed │ │ │ -00060980: 5f6f 7574 293b 0a0a 0965 7272 6f72 5f63 _out);...error_c │ │ │ -00060990: 6f64 6520 6967 6e6f 7265 3b0a 096d 5f73 ode ignore;..m_s │ │ │ -000609a0: 6f63 6b73 355f 736f 636b 2e63 6c6f 7365 ocks5_sock.close │ │ │ -000609b0: 2869 676e 6f72 6529 3b0a 0a09 2b2b 6d5f (ignore);...++m_ │ │ │ -000609c0: 6661 696c 7572 6573 3b0a 0972 6574 7279 failures;..retry │ │ │ -000609d0: 5f63 6f6e 6e65 6374 696f 6e28 293b 0a7d _connection();.} │ │ │ -000609e0: 0a0a 766f 6964 2073 6f63 6b73 353a 3a6f ..void socks5::o │ │ │ -000609f0: 6e5f 636f 6e6e 6563 7465 6428 6572 726f n_connected(erro │ │ │ -00060a00: 725f 636f 6465 2063 6f6e 7374 2661 6d70 r_code const& │ │ │ -00060a10: 3b20 6529 0a7b 0a3c 2f70 7265 3e3c 2f74 ; e).{.
    relevanc │ │ │ -00060a50: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/pread_d │ │ │ -00060a90: 6973 6b5f 696f 2e63 7070 3a37 3532 3c2f isk_io.cpp:752back- │ │ │ -00060ab0: 7072 6573 7375 7265 2028 7468 6520 6469 pressure (the di │ │ │ -00060ac0: 736b 5f6f 6273 6572 7665 7220 6f29 2069 sk_observer o) i │ │ │ -00060ad0: 7320 6472 6f70 7065 6420 6f6e 2074 6865 s dropped on the │ │ │ -00060ae0: 2062 6c6f 636b 6564 2070 6174 682e 2061 blocked path. a │ │ │ -00060af0: 7379 6e63 5f77 7269 7465 2072 6574 7572 sync_write retur │ │ │ -00060b00: 6e73 2066 616c 7365 2028 6b65 6570 2077 ns false (keep w │ │ │ -00060b10: 7269 7469 6e67 2920 6275 7420 7468 6520 riting) but the │ │ │ -00060b20: 6361 6368 6527 7320 6261 636b 2d70 7265 cache's back-pre │ │ │ -00060b30: 7373 7572 6520 2864 7269 7665 6e20 6f66 ssure (driven of │ │ │ -00060b40: 6620 6d5f 626c 6f63 6b73 2920 6361 6e27 f m_blocks) can' │ │ │ -00060b50: 7420 7365 6520 7468 6520 7061 726b 6564 t see the parked │ │ │ -00060b60: 2077 7269 7465 732c 2073 6f20 6120 6c6f writes, so a lo │ │ │ -00060b70: 6e67 2d6c 6976 6564 2066 656e 6365 2028 ng-lived fence ( │ │ │ -00060b80: 652e 672e 206d 6f76 655f 7374 6f72 6167 e.g. move_storag │ │ │ -00060b90: 6529 206f 6e20 6120 6275 7379 2074 6f72 e) on a busy tor │ │ │ -00060ba0: 7265 6e74 2063 616e 2067 726f 7720 6d5f rent can grow m_ │ │ │ -00060bb0: 626c 6f63 6b65 645f 6a6f 6273 2075 6e62 blocked_jobs unb │ │ │ -00060bc0: 6f75 6e64 6564 2e20 4361 7272 7920 7468 ounded. Carry th │ │ │ -00060bd0: 6520 6f62 7365 7276 6572 2074 6872 6f75 e observer throu │ │ │ -00060be0: 6768 2074 6f20 7468 726f 7474 6c65 2074 gh to throttle t │ │ │ -00060bf0: 6865 2070 6565 7220 7768 696c 6520 6974 he peer while it │ │ │ -00060c00: 7320 7772 6974 6573 2061 7265 2070 6172 s writes are par │ │ │ -00060c10: 6b65 642e 3c2f 7464 3e3c 2f74 723e 3c74 ked.back-pressure │ │ │ -00060c70: 2874 6865 2064 6973 6b5f 6f62 7365 7276 (the disk_observ │ │ │ -00060c80: 6572 206f 2920 6973 2064 726f 7070 6564 er o) is dropped │ │ │ -00060c90: 206f 6e20 7468 6520 626c 6f63 6b65 6420 on the blocked │ │ │ -00060ca0: 7061 7468 2e0a 6173 796e 635f 7772 6974 path..async_writ │ │ │ -00060cb0: 6520 7265 7475 726e 7320 6661 6c73 6520 e returns false │ │ │ -00060cc0: 286b 6565 7020 7772 6974 696e 6729 2062 (keep writing) b │ │ │ -00060cd0: 7574 2074 6865 2063 6163 6865 2773 2062 ut the cache's b │ │ │ -00060ce0: 6163 6b2d 7072 6573 7375 7265 0a28 6472 ack-pressure.(dr │ │ │ -00060cf0: 6976 656e 206f 6666 206d 5f62 6c6f 636b iven off m_block │ │ │ -00060d00: 7329 2063 616e 2774 2073 6565 2074 6865 s) can't see the │ │ │ -00060d10: 2070 6172 6b65 6420 7772 6974 6573 2c20 parked writes, │ │ │ -00060d20: 736f 2061 206c 6f6e 672d 6c69 7665 6420 so a long-lived │ │ │ -00060d30: 6665 6e63 650a 2865 2e67 2e20 6d6f 7665 fence.(e.g. move │ │ │ -00060d40: 5f73 746f 7261 6765 2920 6f6e 2061 2062 _storage) on a b │ │ │ -00060d50: 7573 7920 746f 7272 656e 7420 6361 6e20 usy torrent can │ │ │ -00060d60: 6772 6f77 206d 5f62 6c6f 636b 6564 5f6a grow m_blocked_j │ │ │ -00060d70: 6f62 7320 756e 626f 756e 6465 642e 0a43 obs unbounded..C │ │ │ -00060d80: 6172 7279 2074 6865 206f 6273 6572 7665 arry the observe │ │ │ -00060d90: 7220 7468 726f 7567 6820 746f 2074 6872 r through to thr │ │ │ -00060da0: 6f74 746c 6520 7468 6520 7065 6572 2077 ottle the peer w │ │ │ -00060db0: 6869 6c65 2069 7473 2077 7269 7465 7320 hile its writes │ │ │ -00060dc0: 6172 6520 7061 726b 6564 2e3c 2f68 323e are parked.

    │ │ │ -00060dd0: 3c68 343e 2e2e 2f73 7263 2f70 7265 6164

    ../src/pread │ │ │ -00060de0: 5f64 6973 6b5f 696f 2e63 7070 3a37 3532 _disk_io.cpp:752 │ │ │ -00060df0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00060e30: 2f2f 2073 746f 7261 6765 2773 206f 7574  // storage's out
    │ │ │ -00060e40: 7374 616e 6469 6e67 2d6a 6f62 2063 6f75  standing-job cou
    │ │ │ -00060e50: 6e74 2e20 6973 5f62 6c6f 636b 6564 2829  nt. is_blocked()
    │ │ │ -00060e60: 2068 6173 206e 6f74 2072 756e 2c20 736f   has not run, so
    │ │ │ -00060e70: 206a 2069 7320 6e6f 740a 092f 2f20 696e   j is not..// in
    │ │ │ -00060e80: 5f70 726f 6772 6573 7320 616e 6420 6d75  _progress and mu
    │ │ │ -00060e90: 7374 206e 6f74 2062 6520 6a6f 625f 636f  st not be job_co
    │ │ │ -00060ea0: 6d70 6c65 7465 2829 6420 2d2d 2061 626f  mplete()d -- abo
    │ │ │ -00060eb0: 7274 2069 7420 6469 7265 6374 6c79 2e0a  rt it directly..
    │ │ │ -00060ec0: 0969 6620 286d 5f61 626f 7274 290a 097b  .if (m_abort)..{
    │ │ │ -00060ed0: 0a09 096d 5f63 6f6d 706c 6574 6564 5f6a  ...m_completed_j
    │ │ │ -00060ee0: 6f62 732e 6162 6f72 745f 6a6f 6228 6d5f  obs.abort_job(m_
    │ │ │ -00060ef0: 696f 732c 206a 293b 0a09 0972 6574 7572  ios, j);...retur
    │ │ │ -00060f00: 6e20 6661 6c73 653b 0a09 7d0a 0a09 2f2f  n false;..}...//
    │ │ │ -00060f10: 2061 2077 7269 7465 2063 6f75 6e74 7320   a write counts 
    │ │ │ -00060f20: 6173 2061 6e20 6f75 7473 7461 6e64 696e  as an outstandin
    │ │ │ -00060f30: 6720 6a6f 6220 6f6e 2074 6865 2073 746f  g job on the sto
    │ │ │ -00060f40: 7261 6765 2028 6c69 6b65 2061 2072 6561  rage (like a rea
    │ │ │ -00060f50: 6420 6f72 2068 6173 6829 2c0a 092f 2f20  d or hash),..// 
    │ │ │ -00060f60: 736f 2061 2066 656e 6365 2077 6169 7473  so a fence waits
    │ │ │ -00060f70: 2066 6f72 2062 7566 6665 7265 6420 7772   for buffered wr
    │ │ │ -00060f80: 6974 6573 2061 6e64 2074 6865 6972 2069  ites and their i
    │ │ │ -00060f90: 6e2d 666c 6967 6874 2066 6c75 7368 2062  n-flight flush b
    │ │ │ -00060fa0: 6566 6f72 6520 6974 0a09 2f2f 2072 756e  efore it..// run
    │ │ │ -00060fb0: 732c 2072 6174 6865 7220 7468 616e 2074  s, rather than t
    │ │ │ -00060fc0: 6561 7269 6e67 2074 6865 2073 746f 7261  earing the stora
    │ │ │ -00060fd0: 6765 2064 6f77 6e20 756e 6465 7220 6120  ge down under a 
    │ │ │ -00060fe0: 666c 7573 682e 2054 6869 7320 646f 6573  flush. This does
    │ │ │ -00060ff0: 206e 6f74 0a09 2f2f 2064 6561 646c 6f63   not..// deadloc
    │ │ │ -00061000: 6b20 7468 6520 6665 6e63 653a 2061 6464  k the fence: add
    │ │ │ -00061010: 5f66 656e 6365 5f6a 6f62 2829 2068 616e  _fence_job() han
    │ │ │ -00061020: 6473 2061 2073 746f 7261 6765 2077 6974  ds a storage wit
    │ │ │ -00061030: 6820 6f75 7473 7461 6e64 696e 6720 7772  h outstanding wr
    │ │ │ -00061040: 6974 6573 0a09 2f2f 2074 6f20 6120 6765  ites..// to a ge
    │ │ │ -00061050: 6e65 7269 6320 7468 7265 6164 2074 6f20  neric thread to 
    │ │ │ -00061060: 666c 7573 682c 2064 7261 696e 696e 6720  flush, draining 
    │ │ │ -00061070: 7468 6520 7772 6974 6573 2074 6865 2066  the writes the f
    │ │ │ -00061080: 656e 6365 2077 6169 7473 206f 6e2e 0a09  ence waits on...
    │ │ │ -00061090: 2f2f 0a09 2f2f 2077 6865 6e20 6120 6665  //..// when a fe
    │ │ │ -000610a0: 6e63 6520 6973 2075 702c 2069 735f 626c  nce is up, is_bl
    │ │ │ -000610b0: 6f63 6b65 6428 2920 7061 726b 7320 7468  ocked() parks th
    │ │ │ -000610c0: 6520 6a6f 6220 696e 2074 6865 2066 656e  e job in the fen
    │ │ │ -000610d0: 6365 2773 2062 6c6f 636b 6564 2071 7565  ce's blocked que
    │ │ │ -000610e0: 7565 0a09 2f2f 2074 6f20 6265 2072 6570  ue..// to be rep
    │ │ │ -000610f0: 6f73 7465 6420 696e 746f 2074 6865 2063  osted into the c
    │ │ │ -00061100: 6163 6865 206f 6e63 6520 7468 6520 6665  ache once the fe
    │ │ │ -00061110: 6e63 6520 6c6f 7765 7273 2028 6164 645f  nce lowers (add_
    │ │ │ -00061120: 636f 6d70 6c65 7465 645f 6a6f 6273 5f69  completed_jobs_i
    │ │ │ -00061130: 6d70 6c29 2e0a 092f 2f20 496e 7365 7274  mpl)...// Insert
    │ │ │ -00061140: 696e 6720 6e6f 7720 776f 756c 6420 7261  ing now would ra
    │ │ │ -00061150: 6365 2074 6561 7264 6f77 6e3a 2066 6f72  ce teardown: for
    │ │ │ -00061160: 2063 6c65 6172 5f70 6965 6365 2074 6865   clear_piece the
    │ │ │ -00061170: 2063 7065 2069 7320 6162 6f75 7420 746f   cpe is about to
    │ │ │ -00061180: 2062 650a 092f 2f20 7265 7365 742c 2066   be..// reset, f
    │ │ │ -00061190: 6f72 2073 746f 7261 6765 2d77 6964 6520  or storage-wide 
    │ │ │ -000611a0: 6665 6e63 6573 2074 6865 2073 746f 7261  fences the stora
    │ │ │ -000611b0: 6765 2069 7320 6162 6f75 7420 746f 2067  ge is about to g
    │ │ │ -000611c0: 6f20 6177 6179 2e20 5061 726b 696e 670a  o away. Parking.
    │ │ │ -000611d0: 092f 2f20 6b65 6570 7320 7468 6520 626c  .// keeps the bl
    │ │ │ -000611e0: 6f63 6b20 2277 7269 7469 6e67 2220 696e  ock "writing" in
    │ │ │ -000611f0: 2074 6865 2070 6963 6b65 7227 7320 7669   the picker's vi
    │ │ │ -00061200: 6577 2c20 736f 2074 6865 2070 6965 6365  ew, so the piece
    │ │ │ -00061210: 2069 736e 2774 2072 6570 6f72 7465 640a   isn't reported.
    │ │ │ -00061220: 092f 2f20 6669 6e69 7368 6564 2061 6e64  .// finished and
    │ │ │ -00061230: 2069 7473 2068 6173 6820 6973 6e27 7420   its hash isn't 
    │ │ │ -00061240: 7265 7175 6573 7465 6420 6265 666f 7265  requested before
    │ │ │ -00061250: 2074 6865 2062 6c6f 636b 2068 6173 2062   the block has b
    │ │ │ -00061260: 6565 6e20 696e 7365 7274 6564 2e0a 3c64  een inserted...if 
    │ │ │ -000612a0: 286a 2d26 6774 3b73 746f 7261 6765 2d26  (j->storage-&
    │ │ │ -000612b0: 6774 3b69 735f 626c 6f63 6b65 6428 6a2c  gt;is_blocked(j,
    │ │ │ -000612c0: 206d 5f73 7461 7473 5f63 6f75 6e74 6572   m_stats_counter
    │ │ │ -000612d0: 7329 290a 3c2f 6469 763e 097b 0a09 0972  s)).
    .{...r │ │ │ -000612e0: 6574 7572 6e20 6661 6c73 653b 0a09 7d0a eturn false;..}. │ │ │ -000612f0: 0a09 2f2f 2069 735f 626c 6f63 6b65 6428 ..// is_blocked( │ │ │ -00061300: 2920 6d61 726b 6564 206a 2069 6e5f 7072 ) marked j in_pr │ │ │ -00061310: 6f67 7265 7373 2061 6e64 2063 6f75 6e74 ogress and count │ │ │ -00061320: 6564 2069 7420 6173 206f 7574 7374 616e ed it as outstan │ │ │ -00061330: 6469 6e67 2e0a 0962 6f6f 6c20 636f 6e73 ding...bool cons │ │ │ -00061340: 7420 6578 6365 6564 6564 203d 2061 6464 t exceeded = add │ │ │ -00061350: 5f77 7269 7465 5f74 6f5f 6361 6368 6528 _write_to_cache( │ │ │ -00061360: 6a2c 2073 7464 3a3a 6d6f 7665 286f 2929 j, std::move(o)) │ │ │ -00061370: 3b0a 0973 6368 6564 756c 655f 666c 7573 ;..schedule_flus │ │ │ -00061380: 6828 293b 0a09 7265 7475 726e 2065 7863 h();..return exc │ │ │ -00061390: 6565 6465 643b 0a7d 0a0a 6175 783a 3a69 eeded;.}..aux::i │ │ │ -000613a0: 6e73 6572 745f 7265 7375 6c74 5f66 6c61 nsert_result_fla │ │ │ -000613b0: 6773 2070 7265 6164 5f64 6973 6b5f 696f gs pread_disk_io │ │ │ -000613c0: 3a3a 696e 7365 7274 5f77 7269 7465 280a ::insert_write(. │ │ │ -000613d0: 0961 7578 3a3a 7072 6561 645f 6469 736b .aux::pread_disk │ │ │ -000613e0: 5f6a 6f62 2a20 6a2c 2073 7464 3a3a 7368 _job* j, std::sh │ │ │ -000613f0: 6172 6564 5f70 7472 266c 743b 6469 736b ared_ptr<disk │ │ │ -00061400: 5f6f 6273 6572 7665 7226 6774 3b20 6f29 _observer> o) │ │ │ -00061410: 0a7b 0a09 6175 746f 2063 6f6e 7374 2661 .{..auto const&a │ │ │ -00061420: 6d70 3b20 6120 3d20 7374 643a 3a67 6574 mp; a = std::get │ │ │ -00061430: 266c 743b 6175 783a 3a6a 6f62 3a3a 7772 <aux::job::wr │ │ │ -00061440: 6974 6526 6774 3b28 6a2d 2667 743b 6163 ite>(j->ac │ │ │ -00061450: 7469 6f6e 293b 0a09 7069 6563 655f 696e tion);..piece_in │ │ │ -00061460: 6465 785f 7420 636f 6e73 7420 7069 6563 dex_t const piec │ │ │ -00061470: 6520 3d20 612e 7069 6563 653b 0a09 696e e = a.piece;..in │ │ │ -00061480: 7420 636f 6e73 7420 6f66 6673 6574 203d t const offset = │ │ │ -00061490: 2061 2e6f 6666 7365 743b 0a0a 0944 4c4f a.offset;...DLO │ │ │ -000614a0: 4728 2261 7379 6e63 5f77 7269 7465 3a20 G("async_write: │ │ │ -000614b0: 7069 6563 653a 2025 6420 6f66 6673 6574 piece: %d offset │ │ │ -000614c0: 3a20 2564 2066 6c61 6773 3a20 2578 5c6e : %d flags: %x\n │ │ │ -000614d0: 222c 0a09 0969 6e74 2870 6965 6365 292c ",...int(piece), │ │ │ -000614e0: 0a09 0969 6e74 286f 6666 7365 7429 2c0a ...int(offset),. │ │ │ -000614f0: 0909 7374 6174 6963 5f63 6173 7426 6c74 ..static_cast< │ │ │ -00061500: 3b73 7464 3a3a 7569 6e74 385f 7426 6774 ;std::uint8_t> │ │ │ -00061510: 3b28 6a2d 2667 743b 666c 6167 7329 293b ;(j->flags)); │ │ │ -00061520: 0a09 626f 6f6c 2063 6f6e 7374 2066 6f72 ..bool const for │ │ │ -00061530: 6365 5f66 6c75 7368 203d 2062 6f6f 6c28 ce_flush = bool( │ │ │ -00061540: 6a2d 2667 743b 666c 6167 7320 2661 6d70 j->flags & │ │ │ -00061550: 3b20 666c 7573 685f 7069 6563 6529 3b0a ; flush_piece);. │ │ │ -00061560: 0966 696c 655f 7374 6f72 6167 6520 636f .file_storage co │ │ │ -00061570: 6e73 7426 616d 703b 2066 7320 3d20 6a2d nst& fs = j- │ │ │ -00061580: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ -00061590: 6669 6c65 7328 293b 0a09 2f2f 2069 6e20 files();..// in │ │ │ -000615a0: 6f72 6465 7220 746f 2063 6f6d 7075 7465 order to compute │ │ │ -000615b0: 2076 3120 6861 7368 6573 2c20 7765 206e v1 hashes, we n │ │ │ -000615c0: 6565 6420 7468 6520 6675 6c6c 2070 6965 eed the full pie │ │ │ -000615d0: 6365 2c20 696e 636c 7564 696e 6720 7061 ce, including pa │ │ │ -000615e0: 640a 092f 2f20 6669 6c65 732e 2045 7665 d..// files. Eve │ │ │ -000615f0: 6e20 7468 6f75 6768 2076 3220 746f 7272 n though v2 torr │ │ │ -00061600: 656e 7473 2067 7561 7261 6e74 6565 2074 ents guarantee t │ │ │ -00061610: 6861 7420 7468 6579 2061 7265 207a 6572 hat they are zer │ │ │ -00061620: 6f2e 0a09 696e 7420 636f 6e73 7420 7069 o...int const pi │ │ │ -00061630: 6563 655f 7369 7a65 203d 206a 2d26 6774 ece_size = j-> │ │ │ -00061640: 3b73 746f 7261 6765 2d26 6774 3b76 3128 ;storage->v1( │ │ │ -00061650: 2920 3f20 6673 2e70 6965 6365 5f73 697a ) ? fs.piece_siz │ │ │ -00061660: 6528 7069 6563 6529 203a 2066 732e 7069 e(piece) : fs.pi │ │ │ -00061670: 6563 655f 7369 7a65 3228 7069 6563 6529 ece_size2(piece) │ │ │ -00061680: 3b0a 0954 4f52 5245 4e54 5f41 5353 4552 ;..TORRENT_ASSER │ │ │ -00061690: 5428 612e 6275 6666 6572 5f73 697a 6520 T(a.buffer_size │ │ │ -000616a0: 3d3d 2073 7464 3a3a 6d69 6e28 7069 6563 == std::min(piec │ │ │ -000616b0: 655f 7369 7a65 202d 206f 6666 7365 742c e_size - offset, │ │ │ -000616c0: 2064 6566 6175 6c74 5f62 6c6f 636b 5f73 default_block_s │ │ │ -000616d0: 697a 6529 293b 0a09 6175 783a 3a64 6973 ize));..aux::dis │ │ │ -000616e0: 6b5f 6361 6368 653a 3a70 6965 6365 5f65 k_cache::piece_e │ │ │ -000616f0: 6e74 7279 5f70 6172 616d 7320 636f 6e73 ntry_params cons │ │ │ -00061700: 7420 7069 6563 655f 7061 7261 6d73 7b0a t piece_params{. │ │ │ -00061710: 0909 6673 2e70 6965 6365 5f73 697a 6532 ..fs.piece_size2 │ │ │ -00061720: 2870 6965 6365 292c 2070 6965 6365 5f73 (piece), piece_s │ │ │ -00061730: 697a 652c 206a 2d26 6774 3b73 746f 7261 ize, j->stora │ │ │ -00061740: 6765 2d26 6774 3b76 3128 292c 206a 2d26 ge->v1(), j-& │ │ │ -00061750: 6774 3b73 746f 7261 6765 2d26 6774 3b76 gt;storage->v │ │ │ -00061760: 3228 292c 206a 2d26 6774 3b73 746f 7261 2(), j->stora │ │ │ -00061770: 6765 7d3b 0a09 7265 7475 726e 206d 5f63 ge};..return m_c │ │ │ -00061780: 6163 6865 2e69 6e73 6572 7428 7b6a 2d26 ache.insert({j-& │ │ │ -00061790: 6774 3b73 746f 7261 6765 2d26 6774 3b73 gt;storage->s │ │ │ -000617a0: 746f 7261 6765 5f69 6e64 6578 2829 2c20 torage_index(), │ │ │ -000617b0: 7069 6563 657d 2c0a 3c2f 7072 653e 3c2f piece},.relevan │ │ │ -000617f0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/pread_ │ │ │ -00061830: 6469 736b 5f69 6f2e 6370 703a 3933 363c disk_io.cpp:936< │ │ │ -00061840: 2f61 3e3c 2f74 643e 3c74 643e 7765 206d /a>we m │ │ │ -00061850: 6179 206e 6f74 206e 6565 6420 746f 2064 ay not need to d │ │ │ -00061860: 6f20 7468 6973 2c20 7468 6520 6361 6368 o this, the cach │ │ │ -00061870: 6520 636f 756c 6420 7465 6c6c 2075 7320 e could tell us │ │ │ -00061880: 7468 6973 2070 6965 6365 2073 686f 756c this piece shoul │ │ │ -00061890: 6420 6265 2066 6c75 7368 6564 2074 6f20 d be flushed to │ │ │ -000618a0: 6469 736b 206e 6f77 2e3c 2f74 643e 3c2f disk now.

    we may no │ │ │ -00061900: 7420 6e65 6564 2074 6f20 646f 2074 6869 t need to do thi │ │ │ -00061910: 732c 2074 6865 2063 6163 6865 2063 6f75 s, the cache cou │ │ │ -00061920: 6c64 2074 656c 6c20 7573 0a74 6869 7320 ld tell us.this │ │ │ -00061930: 7069 6563 6520 7368 6f75 6c64 2062 6520 piece should be │ │ │ -00061940: 666c 7573 6865 6420 746f 2064 6973 6b20 flushed to disk │ │ │ -00061950: 6e6f 772e 3c2f 6832 3e3c 6834 3e2e 2e2f now.

    ../ │ │ │ -00061960: 7372 632f 7072 6561 645f 6469 736b 5f69 src/pread_disk_i │ │ │ -00061970: 6f2e 6370 703a 3933 363c 2f68 343e 3c70 o.cpp:936

    ...fill_ │ │ │ -000619c0: 7072 6563 6f6d 7075 7465 645f 7632 280a precomputed_v2(. │ │ │ -000619d0: 0909 0909 612e 626c 6f63 6b5f 6861 7368 ....a.block_hash │ │ │ -000619e0: 6573 2c20 6a2d 2667 743b 7374 6f72 6167 es, j->storag │ │ │ -000619f0: 652d 2667 743b 7461 6b65 5f70 7265 636f e->take_preco │ │ │ -00061a00: 6d70 7574 6564 5f76 3228 7069 6563 6529 mputed_v2(piece) │ │ │ -00061a10: 2c20 626c 6f63 6b73 5f69 6e5f 7069 6563 , blocks_in_piec │ │ │ -00061a20: 6532 293b 0a0a 0909 0966 6f72 2028 696e e2);.....for (in │ │ │ -00061a30: 7420 6920 3d20 303b 2069 2026 6c74 3b20 t i = 0; i < │ │ │ -00061a40: 626c 6f63 6b73 5f69 6e5f 7069 6563 6532 blocks_in_piece2 │ │ │ -00061a50: 3b20 2b2b 6929 0a09 0909 7b0a 0909 0909 ; ++i)....{..... │ │ │ -00061a60: 6966 2028 6920 2667 743b 3d20 696e 7428 if (i >= int( │ │ │ -00061a70: 612e 626c 6f63 6b5f 6861 7368 6573 2e73 a.block_hashes.s │ │ │ -00061a80: 697a 6528 2929 207c 7c20 612e 626c 6f63 ize()) || a.bloc │ │ │ -00061a90: 6b5f 6861 7368 6573 5b69 5d2e 6973 5f61 k_hashes[i].is_a │ │ │ -00061aa0: 6c6c 5f7a 6572 6f73 2829 290a 0909 0909 ll_zeros())..... │ │ │ -00061ab0: 7b0a 0909 0909 096e 6565 645f 6469 736b {......need_disk │ │ │ -00061ac0: 5f66 616c 6c62 6163 6b20 3d20 7472 7565 _fallback = true │ │ │ -00061ad0: 3b0a 0909 0909 0962 7265 616b 3b0a 0909 ;......break;... │ │ │ -00061ae0: 0909 7d0a 0909 097d 0a09 097d 0a0a 0909 ..}....}...}.... │ │ │ -00061af0: 6966 2028 6e65 6564 5f64 6973 6b5f 6661 if (need_disk_fa │ │ │ -00061b00: 6c6c 6261 636b 290a 0909 7b0a 0909 0944 llback)...{....D │ │ │ -00061b10: 4c4f 4728 2261 7379 6e63 5f68 6173 683a LOG("async_hash: │ │ │ -00061b20: 2076 3220 6861 7368 6573 2069 6e63 6f6d v2 hashes incom │ │ │ -00061b30: 706c 6574 652c 2066 616c 6c69 6e67 2062 plete, falling b │ │ │ -00061b40: 6163 6b20 746f 2064 6f5f 6a6f 6228 6861 ack to do_job(ha │ │ │ -00061b50: 7368 295c 6e22 293b 0a09 0909 6164 645f sh)\n");....add_ │ │ │ -00061b60: 6a6f 6228 6a29 3b0a 0909 0972 6574 7572 job(j);....retur │ │ │ -00061b70: 6e3b 0a09 097d 0a0a 3c64 6976 2073 7479 n;...}..

    ..m_generi │ │ │ -00061bb0: 635f 7468 7265 6164 732e 696e 7465 7272 c_threads.interr │ │ │ -00061bc0: 7570 7428 293b 0a3c 2f64 6976 3e0a 0909 upt();.
    ... │ │ │ -00061bd0: 6a6f 6271 7565 7565 5f74 206a 6f62 733b jobqueue_t jobs; │ │ │ -00061be0: 0a09 096a 6f62 732e 7075 7368 5f62 6163 ...jobs.push_bac │ │ │ -00061bf0: 6b28 6a29 3b0a 0909 6164 645f 636f 6d70 k(j);...add_comp │ │ │ -00061c00: 6c65 7465 645f 6a6f 6273 2873 7464 3a3a leted_jobs(std:: │ │ │ -00061c10: 6d6f 7665 286a 6f62 7329 293b 0a09 0972 move(jobs));...r │ │ │ -00061c20: 6574 7572 6e3b 0a09 7d0a 0a09 2f2f 2049 eturn;..}...// I │ │ │ -00061c30: 6e20 7468 6973 2063 6173 6520 7468 6520 n this case the │ │ │ -00061c40: 6a6f 6220 6861 7320 6265 656e 2071 7565 job has been que │ │ │ -00061c50: 7565 6420 6f6e 2074 6865 2070 6965 6365 ued on the piece │ │ │ -00061c60: 2c20 616e 6420 7769 6c6c 2062 6520 706f , and will be po │ │ │ -00061c70: 7374 6564 0a09 2f2f 206f 6e63 6520 7468 sted..// once th │ │ │ -00061c80: 6520 6861 7368 696e 6720 636f 6d70 6c65 e hashing comple │ │ │ -00061c90: 7465 730a 0969 6620 2872 6574 203d 3d20 tes..if (ret == │ │ │ -00061ca0: 6175 783a 3a64 6973 6b5f 6361 6368 653a aux::disk_cache: │ │ │ -00061cb0: 3a6a 6f62 5f71 7565 7565 6429 0a09 0972 :job_queued)...r │ │ │ -00061cc0: 6574 7572 6e3b 0a0a 0961 6464 5f6a 6f62 eturn;...add_job │ │ │ -00061cd0: 286a 293b 0a7d 0a0a 766f 6964 2070 7265 (j);.}..void pre │ │ │ -00061ce0: 6164 5f64 6973 6b5f 696f 3a3a 6173 796e ad_disk_io::asyn │ │ │ -00061cf0: 635f 6861 7368 3228 7374 6f72 6167 655f c_hash2(storage_ │ │ │ -00061d00: 696e 6465 785f 7420 636f 6e73 7420 7374 index_t const st │ │ │ -00061d10: 6f72 6167 650a 092c 2070 6965 6365 5f69 orage.., piece_i │ │ │ -00061d20: 6e64 6578 5f74 2063 6f6e 7374 2070 6965 ndex_t const pie │ │ │ -00061d30: 6365 2c20 696e 7420 636f 6e73 7420 6f66 ce, int const of │ │ │ -00061d40: 6673 6574 2c20 6469 736b 5f6a 6f62 5f66 fset, disk_job_f │ │ │ -00061d50: 6c61 6773 5f74 2063 6f6e 7374 2066 6c61 lags_t const fla │ │ │ -00061d60: 6773 0a09 2c20 7374 643a 3a66 756e 6374 gs.., std::funct │ │ │ -00061d70: 696f 6e26 6c74 3b76 6f69 6428 7069 6563 ion<void(piec │ │ │ -00061d80: 655f 696e 6465 785f 742c 2073 6861 3235 e_index_t, sha25 │ │ │ -00061d90: 365f 6861 7368 2063 6f6e 7374 2661 6d70 6_hash const& │ │ │ -00061da0: 3b2c 2073 746f 7261 6765 5f65 7272 6f72 ;, storage_error │ │ │ -00061db0: 2063 6f6e 7374 2661 6d70 3b29 2667 743b const&)> │ │ │ -00061dc0: 2068 616e 646c 6572 290a 7b0a 0954 4f52 handler).{..TOR │ │ │ -00061dd0: 5245 4e54 5f41 5353 4552 5428 7661 6c69 RENT_ASSERT(vali │ │ │ -00061de0: 645f 666c 6167 7328 666c 6167 7329 293b d_flags(flags)); │ │ │ -00061df0: 0a09 6175 783a 3a70 7265 6164 5f64 6973 ..aux::pread_dis │ │ │ -00061e00: 6b5f 6a6f 622a 206a 203d 206d 5f6a 6f62 k_job* j = m_job │ │ │ -00061e10: 5f70 6f6f 6c2e 616c 6c6f 6361 7465 5f6a _pool.allocate_j │ │ │ -00061e20: 6f62 266c 743b 6175 783a 3a6a 6f62 3a3a ob<aux::job:: │ │ │ -00061e30: 6861 7368 3226 6774 3b28 0a09 0966 6c61 hash2>(...fla │ │ │ -00061e40: 6773 2c0a 0909 6d5f 746f 7272 656e 7473 gs,...m_torrents │ │ │ -00061e50: 5b73 746f 7261 6765 5d2d 2667 743b 7368 [storage]->sh │ │ │ -00061e60: 6172 6564 5f66 726f 6d5f 7468 6973 2829 ared_from_this() │ │ │ -00061e70: 2c0a 0909 7374 643a 3a6d 6f76 6528 6861 ,...std::move(ha │ │ │ -00061e80: 6e64 6c65 7229 2c0a 0909 7069 6563 652c ndler),...piece, │ │ │ -00061e90: 0a09 096f 6666 7365 742c 0a09 0973 6861 ...offset,...sha │ │ │ -00061ea0: 3235 365f 6861 7368 7b7d 0a09 293b 0a0a 256_hash{}..);.. │ │ │ -00061eb0: 092f 2f20 496e 2074 6865 6f72 792c 2077 .// In theory, w │ │ │ -00061ec0: 6520 636f 756c 6420 6368 6563 6b20 7468 e could check th │ │ │ -00061ed0: 6520 6361 6368 6520 666f 7220 7468 6973 e cache for this │ │ │ -00061ee0: 2062 6c6f 636b 2068 6173 682c 2062 7574 block hash, but │ │ │ -00061ef0: 2077 650a 3c2f 7072 653e 3c2f 7464 3e3c we.< │ │ │ -00061f00: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00061f30: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ -00061f60: 2e2f 7372 632f 7072 6561 645f 6469 736b ./src/pread_disk │ │ │ -00061f70: 5f69 6f2e 6370 703a 3134 3230 3c2f 613e _io.cpp:1420 │ │ │ -00061f80: 3c2f 7464 3e3c 7464 3e6d 6179 6265 2077 maybe w │ │ │ -00061f90: 6520 646f 6e27 7420 6e65 6564 2074 6f20 e don't need to │ │ │ -00061fa0: 7772 6974 6520 746f 2066 696c 6573 2077 write to files w │ │ │ -00061fb0: 6527 7265 2061 626f 7574 2074 6f20 6465 e're about to de │ │ │ -00061fc0: 6c65 7465 3c2f 7464 3e3c 2f74 723e 3c74 letemaybe we don't │ │ │ -00062020: 206e 6565 6420 746f 2077 7269 7465 2074 need to write t │ │ │ -00062030: 6f20 6669 6c65 7320 7765 2772 6520 6162 o files we're ab │ │ │ -00062040: 6f75 7420 746f 2064 656c 6574 653c 2f68 out to delete

    ../src/pre │ │ │ -00062060: 6164 5f64 6973 6b5f 696f 2e63 7070 3a31 ad_disk_io.cpp:1 │ │ │ -00062070: 3432 303c 2f68 343e 3c70 7265 2073 7479 420

    .a.path = std:
    │ │ │ -000620c0: 3a6d 6f76 6528 7029 3b0a 0972 6574 7572  :move(p);..retur
    │ │ │ -000620d0: 6e20 7265 743b 0a7d 0a0a 7374 6174 7573  n ret;.}..status
    │ │ │ -000620e0: 5f74 2070 7265 6164 5f64 6973 6b5f 696f  _t pread_disk_io
    │ │ │ -000620f0: 3a3a 646f 5f6a 6f62 2861 7578 3a3a 6a6f  ::do_job(aux::jo
    │ │ │ -00062100: 623a 3a72 656c 6561 7365 5f66 696c 6573  b::release_files
    │ │ │ -00062110: 2661 6d70 3b2c 2061 7578 3a3a 7072 6561  &, aux::prea
    │ │ │ -00062120: 645f 6469 736b 5f6a 6f62 2a20 6a29 0a7b  d_disk_job* j).{
    │ │ │ -00062130: 0a09 2f2f 2069 6620 7468 6973 2061 7373  ..// if this ass
    │ │ │ -00062140: 6572 7420 6661 696c 732c 2073 6f6d 6574  ert fails, somet
    │ │ │ -00062150: 6869 6e67 2773 2077 726f 6e67 2077 6974  hing's wrong wit
    │ │ │ -00062160: 6820 7468 6520 6665 6e63 6520 6c6f 6769  h the fence logi
    │ │ │ -00062170: 630a 0954 4f52 5245 4e54 5f41 5353 4552  c..TORRENT_ASSER
    │ │ │ -00062180: 5428 6a2d 2667 743b 7374 6f72 6167 652d  T(j->storage-
    │ │ │ -00062190: 2667 743b 6e75 6d5f 6f75 7473 7461 6e64  >num_outstand
    │ │ │ -000621a0: 696e 675f 6a6f 6273 2829 203d 3d20 3129  ing_jobs() == 1)
    │ │ │ -000621b0: 3b0a 0966 6c75 7368 5f73 746f 7261 6765  ;..flush_storage
    │ │ │ -000621c0: 286a 2d26 6774 3b73 746f 7261 6765 293b  (j->storage);
    │ │ │ -000621d0: 0a09 6a2d 2667 743b 7374 6f72 6167 652d  ..j->storage-
    │ │ │ -000621e0: 2667 743b 7265 6c65 6173 655f 6669 6c65  >release_file
    │ │ │ -000621f0: 7328 6a2d 2667 743b 6572 726f 7229 3b0a  s(j->error);.
    │ │ │ -00062200: 0972 6574 7572 6e20 6a2d 2667 743b 6572  .return j->er
    │ │ │ -00062210: 726f 7220 3f20 6469 736b 5f73 7461 7475  ror ? disk_statu
    │ │ │ -00062220: 733a 3a66 6174 616c 5f64 6973 6b5f 6572  s::fatal_disk_er
    │ │ │ -00062230: 726f 7220 3a20 7374 6174 7573 5f74 7b7d  ror : status_t{}
    │ │ │ -00062240: 3b0a 7d0a 0a73 7461 7475 735f 7420 7072  ;.}..status_t pr
    │ │ │ -00062250: 6561 645f 6469 736b 5f69 6f3a 3a64 6f5f  ead_disk_io::do_
    │ │ │ -00062260: 6a6f 6228 6175 783a 3a6a 6f62 3a3a 6465  job(aux::job::de
    │ │ │ -00062270: 6c65 7465 5f66 696c 6573 2661 6d70 3b20  lete_files& 
    │ │ │ -00062280: 612c 2061 7578 3a3a 7072 6561 645f 6469  a, aux::pread_di
    │ │ │ -00062290: 736b 5f6a 6f62 2a20 6a29 0a7b 0a09 544f  sk_job* j).{..TO
    │ │ │ -000622a0: 5252 454e 545f 4153 5345 5254 2861 2e66  RRENT_ASSERT(a.f
    │ │ │ -000622b0: 6c61 6773 293b 0a0a 092f 2f20 6966 2074  lags);...// if t
    │ │ │ -000622c0: 6869 7320 6173 7365 7274 2066 6169 6c73  his assert fails
    │ │ │ -000622d0: 2c20 736f 6d65 7468 696e 6727 7320 7772  , something's wr
    │ │ │ -000622e0: 6f6e 6720 7769 7468 2074 6865 2066 656e  ong with the fen
    │ │ │ -000622f0: 6365 206c 6f67 6963 0a09 544f 5252 454e  ce logic..TORREN
    │ │ │ -00062300: 545f 4153 5345 5254 286a 2d26 6774 3b73  T_ASSERT(j->s
    │ │ │ -00062310: 746f 7261 6765 2d26 6774 3b6e 756d 5f6f  torage->num_o
    │ │ │ -00062320: 7574 7374 616e 6469 6e67 5f6a 6f62 7328  utstanding_jobs(
    │ │ │ -00062330: 2920 3d3d 2031 293b 0a0a 3c64 6976 2073  ) == 1);..
    .flush_s │ │ │ -00062370: 746f 7261 6765 286a 2d26 6774 3b73 746f torage(j->sto │ │ │ -00062380: 7261 6765 293b 0a3c 2f64 6976 3e0a 096a rage);.
    ..j │ │ │ -00062390: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -000623a0: 3b64 656c 6574 655f 6669 6c65 7328 612e ;delete_files(a. │ │ │ -000623b0: 666c 6167 732c 206a 2d26 6774 3b65 7272 flags, j->err │ │ │ -000623c0: 6f72 293b 0a09 7265 7475 726e 206a 2d26 or);..return j-& │ │ │ -000623d0: 6774 3b65 7272 6f72 203f 2064 6973 6b5f gt;error ? disk_ │ │ │ -000623e0: 7374 6174 7573 3a3a 6661 7461 6c5f 6469 status::fatal_di │ │ │ -000623f0: 736b 5f65 7272 6f72 203a 2073 7461 7475 sk_error : statu │ │ │ -00062400: 735f 747b 7d3b 0a7d 0a0a 7374 6174 7573 s_t{};.}..status │ │ │ -00062410: 5f74 2070 7265 6164 5f64 6973 6b5f 696f _t pread_disk_io │ │ │ -00062420: 3a3a 646f 5f6a 6f62 2861 7578 3a3a 6a6f ::do_job(aux::jo │ │ │ -00062430: 623a 3a63 6865 636b 5f66 6173 7472 6573 b::check_fastres │ │ │ -00062440: 756d 6526 616d 703b 2061 2c20 6175 783a ume& a, aux: │ │ │ -00062450: 3a70 7265 6164 5f64 6973 6b5f 6a6f 622a :pread_disk_job* │ │ │ -00062460: 206a 290a 7b0a 092f 2f20 6966 2074 6869 j).{..// if thi │ │ │ -00062470: 7320 6173 7365 7274 2066 6169 6c73 2c20 s assert fails, │ │ │ -00062480: 736f 6d65 7468 696e 6727 7320 7772 6f6e something's wron │ │ │ -00062490: 6720 7769 7468 2074 6865 2066 656e 6365 g with the fence │ │ │ -000624a0: 206c 6f67 6963 0a09 544f 5252 454e 545f logic..TORRENT_ │ │ │ -000624b0: 4153 5345 5254 286a 2d26 6774 3b73 746f ASSERT(j->sto │ │ │ -000624c0: 7261 6765 2d26 6774 3b6e 756d 5f6f 7574 rage->num_out │ │ │ -000624d0: 7374 616e 6469 6e67 5f6a 6f62 7328 2920 standing_jobs() │ │ │ -000624e0: 3d3d 2031 293b 0a09 666c 7573 685f 7374 == 1);..flush_st │ │ │ -000624f0: 6f72 6167 6528 6a2d 2667 743b 7374 6f72 orage(j->stor │ │ │ -00062500: 6167 6529 3b0a 0961 6464 5f74 6f72 7265 age);..add_torre │ │ │ -00062510: 6e74 5f70 6172 616d 7320 636f 6e73 742a nt_params const* │ │ │ -00062520: 2072 6420 3d20 612e 7265 7375 6d65 5f64 rd = a.resume_d │ │ │ -00062530: 6174 613b 0a09 6164 645f 746f 7272 656e ata;..add_torren │ │ │ -00062540: 745f 7061 7261 6d73 2074 6d70 3b0a 0969 t_params tmp;..i │ │ │ -00062550: 6620 2872 6420 3d3d 206e 756c 6c70 7472 f (rd == nullptr │ │ │ -00062560: 2920 7264 203d 2026 616d 703b 746d 703b ) rd = &tmp; │ │ │ -00062570: 0a0a 0973 7464 3a3a 756e 6971 7565 5f70 ...std::unique_p │ │ │ -00062580: 7472 266c 743b 6175 783a 3a76 6563 746f tr<aux::vecto │ │ │ -00062590: 7226 6c74 3b73 7464 3a3a 7374 7269 6e67 r<std::string │ │ │ -000625a0: 2c20 6669 6c65 5f69 6e64 6578 5f74 2667 , file_index_t&g │ │ │ -000625b0: 743b 2667 743b 206c 696e 6b73 2861 2e6c t;> links(a.l │ │ │ -000625c0: 696e 6b73 293b 0a09 2f2f 2063 6865 636b inks);..// check │ │ │ -000625d0: 2069 6620 7468 6520 6661 7374 7265 7375 if the fastresu │ │ │ -000625e0: 6d65 2064 6174 6120 6973 2075 7020 746f me data is up to │ │ │ -000625f0: 2064 6174 650a 092f 2f20 6966 2069 7420 date..// if it │ │ │ -00062600: 6973 2c20 7573 6520 6974 2061 6e64 2072 is, use it and r │ │ │ -00062610: 6574 7572 6e20 7472 7565 2e20 4966 2069 eturn true. If i │ │ │ -00062620: 740a 092f 2f20 6973 6e27 7420 7265 7475 t..// isn't retu │ │ │ -00062630: 726e 2066 616c 7365 2061 6e64 2074 6865 rn false and the │ │ │ -00062640: 2066 756c 6c20 6368 6563 6b0a 092f 2f20 full check..// │ │ │ -00062650: 7769 6c6c 2062 6520 7275 6e2e 2049 6620 will be run. If │ │ │ -00062660: 7468 6520 6c69 6e6b 7320 706f 696e 7465 the links pointe │ │ │ -00062670: 7220 6973 206e 6f6e 2d65 6d70 7479 2c20 r is non-empty, │ │ │ -00062680: 6974 2068 6173 2074 6865 2073 616d 6520 it has the same │ │ │ -00062690: 6e75 6d62 6572 0a09 2f2f 206f 6620 656c number..// of el │ │ │ -000626a0: 656d 656e 7473 2061 7320 7468 6572 6520 ements as there │ │ │ -000626b0: 6172 6520 6669 6c65 732e 2045 6163 6820 are files. Each │ │ │ -000626c0: 656c 656d 656e 7420 6973 2065 6974 6865 element is eithe │ │ │ -000626d0: 7220 656d 7074 7920 6f72 2063 6f6e 7461 r empty or conta │ │ │ -000626e0: 696e 730a 092f 2f20 7468 6520 6162 736f ins..// the abso │ │ │ -000626f0: 6c75 7465 2070 6174 6820 746f 2061 2066 lute path to a f │ │ │ -00062700: 696c 6520 6964 656e 7469 6361 6c20 746f ile identical to │ │ │ -00062710: 2074 6865 2063 6f72 7265 7370 6f6e 6469 the correspondi │ │ │ -00062720: 6e67 2066 696c 6520 696e 2074 6869 730a ng file in this. │ │ │ -00062730: 092f 2f20 746f 7272 656e 742e 2054 6865 .// torrent. The │ │ │ -00062740: 2073 746f 7261 6765 206d 7573 7420 6372 storage must cr │ │ │ -00062750: 6561 7465 2068 6172 6420 6c69 6e6b 7320 eate hard links │ │ │ -00062760: 286f 7220 636f 7079 2920 7468 6f73 6520 (or copy) those │ │ │ -00062770: 6669 6c65 732e 2049 660a 092f 2f20 616e files. If..// an │ │ │ -00062780: 7920 6669 6c65 2064 6f65 7320 6e6f 7420 y file does not │ │ │ -00062790: 6578 6973 7420 6f72 2069 7320 696e 6163 exist or is inac │ │ │ -000627a0: 6365 7373 6962 6c65 2c20 7468 6520 6469 cessible, the di │ │ │ -000627b0: 736b 206a 6f62 206d 7573 7420 6661 696c sk job must fail │ │ │ -000627c0: 2e0a 0a09 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -000627d0: 5254 286a 2d26 6774 3b73 746f 7261 6765 RT(j->storage │ │ │ -000627e0: 2d26 6774 3b66 696c 6573 2829 2e70 6965 ->files().pie │ │ │ -000627f0: 6365 5f6c 656e 6774 6828 2920 2667 743b ce_length() > │ │ │ -00062800: 2030 293b 0a0a 092f 2f20 616c 7761 7973 0);...// always │ │ │ -00062810: 2069 6e69 7469 616c 697a 6520 7468 6520 initialize the │ │ │ -00062820: 7374 6f72 6167 650a 0961 7574 6f20 636f storage..auto co │ │ │ -00062830: 6e73 7420 7265 745f 666c 6167 203d 206a nst ret_flag = j │ │ │ -00062840: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -00062850: 3b69 6e69 7469 616c 697a 6528 6d5f 7365 ;initialize(m_se │ │ │ -00062860: 7474 696e 6773 2c20 6a2d 2667 743b 6572 ttings, j->er │ │ │ -00062870: 726f 7229 3b0a 0969 6620 286a 2d26 6774 ror);..if (j-> │ │ │ -00062880: 3b65 7272 6f72 2920 7265 7475 726e 2064 ;error) return d │ │ │ -00062890: 6973 6b5f 7374 6174 7573 3a3a 6661 7461 isk_status::fata │ │ │ -000628a0: 6c5f 6469 736b 5f65 7272 6f72 207c 2072 l_disk_error | r │ │ │ -000628b0: 6574 5f66 6c61 673b 0a0a 3c2f 7072 653e et_flag;..
    │ │ │ -000628c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000628f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00062900: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ -00062930: 656e 742e 6370 703a 3231 3032 3c2f 613e ent.cpp:2102 │ │ │ -00062940: 3c2f 7464 3e3c 7464 3e74 6869 7320 636f this co │ │ │ -00062950: 756c 6420 6265 206f 7074 696d 697a 6564 uld be optimized │ │ │ -00062960: 2062 7920 6c6f 6f6b 696e 6720 7570 2077 by looking up w │ │ │ -00062970: 6869 6368 2066 696c 6573 2061 7265 2063 hich files are c │ │ │ -00062980: 6f6d 706c 6574 6520 616e 6420 6a75 7374 omplete and just │ │ │ -00062990: 206c 6f6f 6b20 6174 2074 686f 7365 3c2f look at those

    this │ │ │ -000629f0: 2063 6f75 6c64 2062 6520 6f70 7469 6d69 could be optimi │ │ │ -00062a00: 7a65 6420 6279 206c 6f6f 6b69 6e67 2075 zed by looking u │ │ │ -00062a10: 7020 7768 6963 6820 6669 6c65 7320 6172 p which files ar │ │ │ -00062a20: 650a 636f 6d70 6c65 7465 2061 6e64 206a e.complete and j │ │ │ -00062a30: 7573 7420 6c6f 6f6b 2061 7420 7468 6f73 ust look at thos │ │ │ -00062a40: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ -00062a50: 2f74 6f72 7265 6e74 2e63 7070 3a32 3130 /torrent.cpp:210 │ │ │ -00062a60: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ -00062aa0: 2f2f 0909 0909 544f 5252 454e 545f 4153  //....TORRENT_AS
    │ │ │ -00062ab0: 5345 5254 2870 6963 6b65 7228 292e 6861  SERT(picker().ha
    │ │ │ -00062ac0: 7665 5f70 6965 6365 2869 2929 3b0a 0909  ve_piece(i));...
    │ │ │ -00062ad0: 0909 7765 5f68 6176 6528 6929 3b0a 0909  ..we_have(i);...
    │ │ │ -00062ae0: 097d 0a09 097d 0a0a 0909 7365 745f 7374  .}...}....set_st
    │ │ │ -00062af0: 6174 6528 746f 7272 656e 745f 7374 6174  ate(torrent_stat
    │ │ │ -00062b00: 7573 3a3a 6368 6563 6b69 6e67 5f72 6573  us::checking_res
    │ │ │ -00062b10: 756d 655f 6461 7461 293b 0a0a 0909 6175  ume_data);....au
    │ │ │ -00062b20: 783a 3a76 6563 746f 7226 6c74 3b73 7464  x::vector<std
    │ │ │ -00062b30: 3a3a 7374 7269 6e67 2c20 6669 6c65 5f69  ::string, file_i
    │ │ │ -00062b40: 6e64 6578 5f74 2667 743b 206c 696e 6b73  ndex_t> links
    │ │ │ -00062b50: 3b0a 2369 666e 6465 6620 544f 5252 454e  ;.#ifndef TORREN
    │ │ │ -00062b60: 545f 4449 5341 424c 455f 4d55 5441 424c  T_DISABLE_MUTABL
    │ │ │ -00062b70: 455f 544f 5252 454e 5453 0a09 0969 6620  E_TORRENTS...if 
    │ │ │ -00062b80: 2821 6d5f 746f 7272 656e 745f 6669 6c65  (!m_torrent_file
    │ │ │ -00062b90: 2d26 6774 3b73 696d 696c 6172 5f74 6f72  ->similar_tor
    │ │ │ -00062ba0: 7265 6e74 7328 292e 656d 7074 7928 290a  rents().empty().
    │ │ │ -00062bb0: 0909 097c 7c20 216d 5f74 6f72 7265 6e74  ...|| !m_torrent
    │ │ │ -00062bc0: 5f66 696c 652d 2667 743b 636f 6c6c 6563  _file->collec
    │ │ │ -00062bd0: 7469 6f6e 7328 292e 656d 7074 7928 2929  tions().empty())
    │ │ │ -00062be0: 0a09 097b 0a09 0909 7265 736f 6c76 655f  ...{....resolve_
    │ │ │ -00062bf0: 6c69 6e6b 7320 7265 7328 6d5f 746f 7272  links res(m_torr
    │ │ │ -00062c00: 656e 745f 6669 6c65 293b 0a0a 0909 0966  ent_file);.....f
    │ │ │ -00062c10: 6f72 2028 6175 746f 2063 6f6e 7374 2661  or (auto const&a
    │ │ │ -00062c20: 6d70 3b20 6968 203a 206d 5f74 6f72 7265  mp; ih : m_torre
    │ │ │ -00062c30: 6e74 5f66 696c 652d 2667 743b 7369 6d69  nt_file->simi
    │ │ │ -00062c40: 6c61 725f 746f 7272 656e 7473 2829 290a  lar_torrents()).
    │ │ │ -00062c50: 0909 097b 0a09 0909 0973 7464 3a3a 7368  ...{.....std::sh
    │ │ │ -00062c60: 6172 6564 5f70 7472 266c 743b 746f 7272  ared_ptr<torr
    │ │ │ -00062c70: 656e 7426 6774 3b20 7420 3d20 6d5f 7365  ent> t = m_se
    │ │ │ -00062c80: 732e 6669 6e64 5f74 6f72 7265 6e74 2869  s.find_torrent(i
    │ │ │ -00062c90: 6e66 6f5f 6861 7368 5f74 2869 6829 292e  nfo_hash_t(ih)).
    │ │ │ -00062ca0: 6c6f 636b 2829 3b0a 0909 0909 6966 2028  lock();.....if (
    │ │ │ -00062cb0: 2174 2920 636f 6e74 696e 7565 3b0a 0a09  !t) continue;...
    │ │ │ -00062cc0: 0909 092f 2f20 4f6e 6c79 2061 7474 656d  ...// Only attem
    │ │ │ -00062cd0: 7074 2074 6f20 7265 7573 6520 6669 6c65  pt to reuse file
    │ │ │ -00062ce0: 7320 6672 6f6d 2074 6f72 7265 6e74 7320  s from torrents 
    │ │ │ -00062cf0: 7468 6174 2061 7265 2073 6565 6469 6e67  that are seeding
    │ │ │ -00062d00: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00062d30: 0909 0909 6966 2028 2174 2d26 6774 3b69 ....if (!t->i │ │ │ -00062d40: 735f 7365 6564 2829 2920 636f 6e74 696e s_seed()) contin │ │ │ -00062d50: 7565 3b0a 3c2f 6469 763e 0a09 0909 0961 ue;.
    .....a │ │ │ -00062d60: 7574 6f20 7469 203d 2074 2d26 6774 3b67 uto ti = t->g │ │ │ -00062d70: 6574 5f74 6f72 7265 6e74 5f66 696c 6528 et_torrent_file( │ │ │ -00062d80: 293b 0a09 0909 0972 6573 2e6d 6174 6368 );.....res.match │ │ │ -00062d90: 282a 7469 2c20 6669 6c65 6e61 6d65 7328 (*ti, filenames( │ │ │ -00062da0: 7469 2d26 6774 3b6c 6179 6f75 7428 292c ti->layout(), │ │ │ -00062db0: 2074 2d26 6774 3b6d 5f72 656e 616d 6564 t->m_renamed │ │ │ -00062dc0: 5f66 696c 6573 292c 2074 2d26 6774 3b73 _files), t->s │ │ │ -00062dd0: 6176 655f 7061 7468 2829 293b 0a09 0909 ave_path());.... │ │ │ -00062de0: 7d0a 0909 0966 6f72 2028 6175 746f 2063 }....for (auto c │ │ │ -00062df0: 6f6e 7374 2661 6d70 3b20 6320 3a20 6d5f onst& c : m_ │ │ │ -00062e00: 746f 7272 656e 745f 6669 6c65 2d26 6774 torrent_file-> │ │ │ -00062e10: 3b63 6f6c 6c65 6374 696f 6e73 2829 290a ;collections()). │ │ │ -00062e20: 0909 097b 0a09 0909 0973 7464 3a3a 7665 ...{.....std::ve │ │ │ -00062e30: 6374 6f72 266c 743b 7374 643a 3a73 6861 ctor<std::sha │ │ │ -00062e40: 7265 645f 7074 7226 6c74 3b74 6f72 7265 red_ptr<torre │ │ │ -00062e50: 6e74 2667 743b 2667 743b 2074 7320 3d20 nt>> ts = │ │ │ -00062e60: 6d5f 7365 732e 6669 6e64 5f63 6f6c 6c65 m_ses.find_colle │ │ │ -00062e70: 6374 696f 6e28 6329 3b0a 0a09 0909 0966 ction(c);......f │ │ │ -00062e80: 6f72 2028 6175 746f 2063 6f6e 7374 2661 or (auto const&a │ │ │ -00062e90: 6d70 3b20 7420 3a20 7473 290a 0909 0909 mp; t : ts)..... │ │ │ -00062ea0: 7b0a 0909 0909 092f 2f20 4f6e 6c79 2061 {......// Only a │ │ │ -00062eb0: 7474 656d 7074 2074 6f20 7265 7573 6520 ttempt to reuse │ │ │ -00062ec0: 6669 6c65 7320 6672 6f6d 2074 6f72 7265 files from torre │ │ │ -00062ed0: 6e74 7320 7468 6174 2061 7265 2073 6565 nts that are see │ │ │ -00062ee0: 6469 6e67 2e0a 3c2f 7072 653e 3c2f 7464 ding..
    relevance │ │ │ -00062f20: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00062f30: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ -00062f60: 6370 703a 3231 3136 3c2f 613e 3c2f 7464 cpp:2116this could │ │ │ -00062f80: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ -00062f90: 6c6f 6f6b 696e 6720 7570 2077 6869 6368 looking up which │ │ │ -00062fa0: 2066 696c 6573 2061 7265 2063 6f6d 706c files are compl │ │ │ -00062fb0: 6574 6520 616e 6420 6a75 7374 206c 6f6f ete and just loo │ │ │ -00062fc0: 6b20 6174 2074 686f 7365 3c2f 7464 3e3c k at those< │ │ │ -00062fd0: 2f74 723e 3c74 7220 6964 3d22 3232 3822 /tr>

    this cou │ │ │ -00063020: 6c64 2062 6520 6f70 7469 6d69 7a65 6420 ld be optimized │ │ │ -00063030: 6279 206c 6f6f 6b69 6e67 2075 7020 7768 by looking up wh │ │ │ -00063040: 6963 6820 6669 6c65 7320 6172 650a 636f ich files are.co │ │ │ -00063050: 6d70 6c65 7465 2061 6e64 206a 7573 7420 mplete and just │ │ │ -00063060: 6c6f 6f6b 2061 7420 7468 6f73 653c 2f68 look at those

    ../src/tor │ │ │ -00063080: 7265 6e74 2e63 7070 3a32 3131 363c 2f68 rent.cpp:2116
    ...r
    │ │ │ -000630d0: 6573 6f6c 7665 5f6c 696e 6b73 2072 6573  esolve_links res
    │ │ │ -000630e0: 286d 5f74 6f72 7265 6e74 5f66 696c 6529  (m_torrent_file)
    │ │ │ -000630f0: 3b0a 0a09 0909 666f 7220 2861 7574 6f20  ;.....for (auto 
    │ │ │ -00063100: 636f 6e73 7426 616d 703b 2069 6820 3a20  const& ih : 
    │ │ │ -00063110: 6d5f 746f 7272 656e 745f 6669 6c65 2d26  m_torrent_file-&
    │ │ │ -00063120: 6774 3b73 696d 696c 6172 5f74 6f72 7265  gt;similar_torre
    │ │ │ -00063130: 6e74 7328 2929 0a09 0909 7b0a 0909 0909  nts())....{.....
    │ │ │ -00063140: 7374 643a 3a73 6861 7265 645f 7074 7226  std::shared_ptr&
    │ │ │ -00063150: 6c74 3b74 6f72 7265 6e74 2667 743b 2074  lt;torrent> t
    │ │ │ -00063160: 203d 206d 5f73 6573 2e66 696e 645f 746f   = m_ses.find_to
    │ │ │ -00063170: 7272 656e 7428 696e 666f 5f68 6173 685f  rrent(info_hash_
    │ │ │ -00063180: 7428 6968 2929 2e6c 6f63 6b28 293b 0a09  t(ih)).lock();..
    │ │ │ -00063190: 0909 0969 6620 2821 7429 2063 6f6e 7469  ...if (!t) conti
    │ │ │ -000631a0: 6e75 653b 0a0a 0909 0909 2f2f 204f 6e6c  nue;......// Onl
    │ │ │ -000631b0: 7920 6174 7465 6d70 7420 746f 2072 6575  y attempt to reu
    │ │ │ -000631c0: 7365 2066 696c 6573 2066 726f 6d20 746f  se files from to
    │ │ │ -000631d0: 7272 656e 7473 2074 6861 7420 6172 6520  rrents that are 
    │ │ │ -000631e0: 7365 6564 696e 672e 0a09 0909 0969 6620  seeding......if 
    │ │ │ -000631f0: 2821 742d 2667 743b 6973 5f73 6565 6428  (!t->is_seed(
    │ │ │ -00063200: 2929 2063 6f6e 7469 6e75 653b 0a0a 0909  )) continue;....
    │ │ │ -00063210: 0909 6175 746f 2074 6920 3d20 742d 2667  ..auto ti = t-&g
    │ │ │ -00063220: 743b 6765 745f 746f 7272 656e 745f 6669  t;get_torrent_fi
    │ │ │ -00063230: 6c65 2829 3b0a 0909 0909 7265 732e 6d61  le();.....res.ma
    │ │ │ -00063240: 7463 6828 2a74 692c 2066 696c 656e 616d  tch(*ti, filenam
    │ │ │ -00063250: 6573 2874 692d 2667 743b 6c61 796f 7574  es(ti->layout
    │ │ │ -00063260: 2829 2c20 742d 2667 743b 6d5f 7265 6e61  (), t->m_rena
    │ │ │ -00063270: 6d65 645f 6669 6c65 7329 2c20 742d 2667  med_files), t-&g
    │ │ │ -00063280: 743b 7361 7665 5f70 6174 6828 2929 3b0a  t;save_path());.
    │ │ │ -00063290: 0909 097d 0a09 0909 666f 7220 2861 7574  ...}....for (aut
    │ │ │ -000632a0: 6f20 636f 6e73 7426 616d 703b 2063 203a  o const& c :
    │ │ │ -000632b0: 206d 5f74 6f72 7265 6e74 5f66 696c 652d   m_torrent_file-
    │ │ │ -000632c0: 2667 743b 636f 6c6c 6563 7469 6f6e 7328  >collections(
    │ │ │ -000632d0: 2929 0a09 0909 7b0a 0909 0909 7374 643a  ))....{.....std:
    │ │ │ -000632e0: 3a76 6563 746f 7226 6c74 3b73 7464 3a3a  :vector<std::
    │ │ │ -000632f0: 7368 6172 6564 5f70 7472 266c 743b 746f  shared_ptr<to
    │ │ │ -00063300: 7272 656e 7426 6774 3b26 6774 3b20 7473  rrent>> ts
    │ │ │ -00063310: 203d 206d 5f73 6573 2e66 696e 645f 636f   = m_ses.find_co
    │ │ │ -00063320: 6c6c 6563 7469 6f6e 2863 293b 0a0a 0909  llection(c);....
    │ │ │ -00063330: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ -00063340: 7426 616d 703b 2074 203a 2074 7329 0a09  t& t : ts)..
    │ │ │ -00063350: 0909 097b 0a09 0909 0909 2f2f 204f 6e6c  ...{......// Onl
    │ │ │ -00063360: 7920 6174 7465 6d70 7420 746f 2072 6575  y attempt to reu
    │ │ │ -00063370: 7365 2066 696c 6573 2066 726f 6d20 746f  se files from to
    │ │ │ -00063380: 7272 656e 7473 2074 6861 7420 6172 6520  rrents that are 
    │ │ │ -00063390: 7365 6564 696e 672e 0a3c 6469 7620 7374  seeding..
    .....if ( │ │ │ -000633d0: 2174 2d26 6774 3b69 735f 7365 6564 2829 !t->is_seed() │ │ │ -000633e0: 2920 636f 6e74 696e 7565 3b0a 3c2f 6469 ) continue;.......auto ti │ │ │ -00063400: 3d20 742d 2667 743b 6765 745f 746f 7272 = t->get_torr │ │ │ -00063410: 656e 745f 6669 6c65 2829 3b0a 0909 0909 ent_file();..... │ │ │ -00063420: 0972 6573 2e6d 6174 6368 282a 7469 2c20 .res.match(*ti, │ │ │ -00063430: 6669 6c65 6e61 6d65 7328 7469 2d26 6774 filenames(ti-> │ │ │ -00063440: 3b6c 6179 6f75 7428 292c 2074 2d26 6774 ;layout(), t-> │ │ │ -00063450: 3b6d 5f72 656e 616d 6564 5f66 696c 6573 ;m_renamed_files │ │ │ -00063460: 292c 2074 2d26 6774 3b73 6176 655f 7061 ), t->save_pa │ │ │ -00063470: 7468 2829 293b 0a09 0909 097d 0a09 0909 th());.....}.... │ │ │ -00063480: 7d0a 0a09 0909 6c69 6e6b 7320 3d20 7374 }.....links = st │ │ │ -00063490: 643a 3a6d 6f76 6528 7265 7329 2e67 6574 d::move(res).get │ │ │ -000634a0: 5f6c 696e 6b73 2829 3b0a 0909 7d0a 2365 _links();...}.#e │ │ │ -000634b0: 6e64 6966 202f 2f20 544f 5252 454e 545f ndif // TORRENT_ │ │ │ -000634c0: 4449 5341 424c 455f 4d55 5441 424c 455f DISABLE_MUTABLE_ │ │ │ -000634d0: 544f 5252 454e 5453 0a0a 2369 6620 544f TORRENTS..#if TO │ │ │ -000634e0: 5252 454e 545f 5553 455f 4153 5345 5254 RRENT_USE_ASSERT │ │ │ -000634f0: 530a 0909 544f 5252 454e 545f 4153 5345 S...TORRENT_ASSE │ │ │ -00063500: 5254 286d 5f6f 7574 7374 616e 6469 6e67 RT(m_outstanding │ │ │ -00063510: 5f63 6865 636b 5f66 696c 6573 203d 3d20 _check_files == │ │ │ -00063520: 6661 6c73 6529 3b0a 0909 6d5f 6f75 7473 false);...m_outs │ │ │ -00063530: 7461 6e64 696e 675f 6368 6563 6b5f 6669 tanding_check_fi │ │ │ -00063540: 6c65 7320 3d20 7472 7565 3b0a 2365 6e64 les = true;.#end │ │ │ -00063550: 6966 0a0a 0909 6966 2028 216d 5f61 6464 if....if (!m_add │ │ │ -00063560: 5f74 6f72 7265 6e74 5f70 6172 616d 7320 _torrent_params │ │ │ -00063570: 7c7c 2021 286d 5f61 6464 5f74 6f72 7265 || !(m_add_torre │ │ │ -00063580: 6e74 5f70 6172 616d 732d 2667 743b 666c nt_params->fl │ │ │ -00063590: 6167 7320 2661 6d70 3b20 746f 7272 656e ags & torren │ │ │ -000635a0: 745f 666c 6167 733a 3a6e 6f5f 7665 7269 t_flags::no_veri │ │ │ -000635b0: 6679 5f66 696c 6573 2929 0a09 097b 0a09 fy_files))...{.. │ │ │ -000635c0: 0909 6d5f 7365 732e 6469 736b 5f74 6872 ..m_ses.disk_thr │ │ │ -000635d0: 6561 6428 292e 6173 796e 635f 6368 6563 ead().async_chec │ │ │ -000635e0: 6b5f 6669 6c65 7328 0a09 0909 096d 5f73 k_files(.....m_s │ │ │ -000635f0: 746f 7261 6765 2c20 6d5f 6164 645f 746f torage, m_add_to │ │ │ -00063600: 7272 656e 745f 7061 7261 6d73 203f 206d rrent_params ? m │ │ │ -00063610: 5f61 6464 5f74 6f72 7265 6e74 5f70 6172 _add_torrent_par │ │ │ -00063620: 616d 732e 6765 7428 2920 3a20 6e75 6c6c ams.get() : null │ │ │ -00063630: 7074 720a 0909 0909 2c20 7374 643a 3a6d ptr....., std::m │ │ │ -00063640: 6f76 6528 6c69 6e6b 7329 2c20 5b73 656c ove(links), [sel │ │ │ -00063650: 6620 3d20 7368 6172 6564 5f66 726f 6d5f f = shared_from_ │ │ │ -00063660: 7468 6973 2829 5d28 7374 6174 7573 5f74 this()](status_t │ │ │ -00063670: 2073 742c 2073 746f 7261 6765 5f65 7272 st, storage_err │ │ │ -00063680: 6f72 2063 6f6e 7374 2661 6d70 3b20 6572 or const& er │ │ │ -00063690: 726f 7229 0a09 0909 097b 2073 656c 662d ror).....{ self- │ │ │ -000636a0: 2667 743b 6f6e 5f72 6573 756d 655f 6461 >on_resume_da │ │ │ -000636b0: 7461 5f63 6865 636b 6564 2873 742c 2065 ta_checked(st, e │ │ │ -000636c0: 7272 6f72 293b 207d 293b 0a23 6966 6e64 rror); });.#ifnd │ │ │ -000636d0: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -000636e0: 4c45 5f4c 4f47 4749 4e47 0a09 0909 6465 LE_LOGGING....de │ │ │ -000636f0: 6275 675f 6c6f 6728 2269 6e69 742c 2061 bug_log("init, a │ │ │ -00063700: 7379 6e63 5f63 6865 636b 5f66 696c 6573 sync_check_files │ │ │ -00063710: 2229 3b0a 2365 6e64 6966 0a09 0909 6d5f ");.#endif....m_ │ │ │ -00063720: 7365 732e 6465 6665 7272 6564 5f73 7562 ses.deferred_sub │ │ │ -00063730: 6d69 745f 6a6f 6273 2829 3b0a 0909 7d0a mit_jobs();...}. │ │ │ -00063740: 0909 656c 7365 0a09 097b 0a09 0909 6f6e ..else...{....on │ │ │ -00063750: 5f72 6573 756d 655f 6461 7461 5f63 6865 _resume_data_che │ │ │ -00063760: 636b 6564 287b 7d2c 2073 746f 7261 6765 cked({}, storage │ │ │ -00063770: 5f65 7272 6f72 7b7d 293b 0a09 097d 0a3c _error{});...}.< │ │ │ -00063780: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00063790: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -000637a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -000637b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000637c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -000637f0: 2f74 6f72 7265 6e74 2e63 7070 3a32 3839 /torrent.cpp:289 │ │ │ -00063800: 313c 2f61 3e3c 2f74 643e 3c74 643e 7468 1th │ │ │ -00063810: 6973 2070 6174 7465 726e 2069 7320 7265 is pattern is re │ │ │ -00063820: 7065 6174 6564 2069 6e20 6120 6665 7720 peated in a few │ │ │ -00063830: 706c 6163 6573 2e20 4661 6374 6f72 2074 places. Factor t │ │ │ -00063840: 6869 7320 696e 746f 2061 2066 756e 6374 his into a funct │ │ │ -00063850: 696f 6e20 616e 6420 6765 6e65 7261 6c69 ion and generali │ │ │ -00063860: 7a65 2074 6865 2063 6f6e 6365 7074 206f ze the concept o │ │ │ -00063870: 6620 6120 746f 7272 656e 7420 6861 7669 f a torrent havi │ │ │ -00063880: 6e67 2061 2064 6564 6963 6174 6564 206c ng a dedicated l │ │ │ -00063890: 6973 7465 6e20 706f 7274 3c2f 7464 3e3c isten port< │ │ │ -000638a0: 2f74 723e 3c74 7220 6964 3d22 3232 3922 /tr>

    this pat │ │ │ -000638f0: 7465 726e 2069 7320 7265 7065 6174 6564 tern is repeated │ │ │ -00063900: 2069 6e20 6120 6665 7720 706c 6163 6573 in a few places │ │ │ -00063910: 2e20 4661 6374 6f72 2074 6869 7320 696e . Factor this in │ │ │ -00063920: 746f 0a61 2066 756e 6374 696f 6e20 616e to.a function an │ │ │ -00063930: 6420 6765 6e65 7261 6c69 7a65 2074 6865 d generalize the │ │ │ -00063940: 2063 6f6e 6365 7074 206f 6620 6120 746f concept of a to │ │ │ -00063950: 7272 656e 7420 6861 7669 6e67 2061 0a64 rrent having a.d │ │ │ -00063960: 6564 6963 6174 6564 206c 6973 7465 6e20 edicated listen │ │ │ -00063970: 706f 7274 3c2f 6832 3e3c 6834 3e2e 2e2f port

    ../ │ │ │ -00063980: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00063990: 3238 3931 3c2f 6834 3e3c 7072 6520 7374 2891

    ..// not read
    │ │ │ -000639e0: 7920 666f 7220 7065 6572 732e 2045 7863  y for peers. Exc
    │ │ │ -000639f0: 6570 742c 2069 6620 7765 2064 6f6e 2774  ept, if we don't
    │ │ │ -00063a00: 2068 6176 6520 6d65 7461 6461 7461 2c0a   have metadata,.
    │ │ │ -00063a10: 0909 2f2f 2077 6520 6e65 6564 2070 6565  ..// we need pee
    │ │ │ -00063a20: 7273 2074 6f20 646f 776e 6c6f 6164 2066  rs to download f
    │ │ │ -00063a30: 726f 6d0a 0909 6966 2028 216d 5f66 696c  rom...if (!m_fil
    │ │ │ -00063a40: 6573 5f63 6865 636b 6564 2026 616d 703b  es_checked &
    │ │ │ -00063a50: 2661 6d70 3b20 7661 6c69 645f 6d65 7461  & valid_meta
    │ │ │ -00063a60: 6461 7461 2829 2920 7265 7475 726e 3b0a  data()) return;.
    │ │ │ -00063a70: 0a09 0969 6620 2821 6d5f 616e 6e6f 756e  ...if (!m_announ
    │ │ │ -00063a80: 6365 5f74 6f5f 6c73 6429 2072 6574 7572  ce_to_lsd) retur
    │ │ │ -00063a90: 6e3b 0a0a 0909 2f2f 2070 7269 7661 7465  n;....// private
    │ │ │ -00063aa0: 2074 6f72 7265 6e74 7320 6172 6520 6e65   torrents are ne
    │ │ │ -00063ab0: 7665 7220 616e 6e6f 756e 6365 6420 6f6e  ver announced on
    │ │ │ -00063ac0: 204c 5344 0a09 0969 6620 286d 5f74 6f72   LSD...if (m_tor
    │ │ │ -00063ad0: 7265 6e74 5f66 696c 652d 2667 743b 6973  rent_file->is
    │ │ │ -00063ae0: 5f76 616c 6964 2829 2026 616d 703b 2661  _valid() &&a
    │ │ │ -00063af0: 6d70 3b20 6d5f 746f 7272 656e 745f 6669  mp; m_torrent_fi
    │ │ │ -00063b00: 6c65 2d26 6774 3b70 7269 7628 2929 2072  le->priv()) r
    │ │ │ -00063b10: 6574 7572 6e3b 0a0a 2369 6620 544f 5252  eturn;..#if TORR
    │ │ │ -00063b20: 454e 545f 5553 455f 4932 500a 0909 2f2f  ENT_USE_I2P...//
    │ │ │ -00063b30: 2069 3270 2074 6f72 7265 6e74 7320 6172   i2p torrents ar
    │ │ │ -00063b40: 6520 616c 736f 206e 6576 6572 2061 6e6e  e also never ann
    │ │ │ -00063b50: 6f75 6e63 6564 206f 6e20 4c53 440a 0909  ounced on LSD...
    │ │ │ -00063b60: 2f2f 2075 6e6c 6573 7320 7765 2061 6c6c  // unless we all
    │ │ │ -00063b70: 6f77 206d 6978 6564 2073 7761 726d 730a  ow mixed swarms.
    │ │ │ -00063b80: 0909 6966 2028 6973 5f69 3270 2829 2026  ..if (is_i2p() &
    │ │ │ -00063b90: 616d 703b 2661 6d70 3b20 2173 6574 7469  amp;& !setti
    │ │ │ -00063ba0: 6e67 7328 292e 6765 745f 626f 6f6c 2873  ngs().get_bool(s
    │ │ │ -00063bb0: 6574 7469 6e67 735f 7061 636b 3a3a 616c  ettings_pack::al
    │ │ │ -00063bc0: 6c6f 775f 6932 705f 6d69 7865 6429 290a  low_i2p_mixed)).
    │ │ │ -00063bd0: 0909 0972 6574 7572 6e3b 0a23 656e 6469  ...return;.#endi
    │ │ │ -00063be0: 660a 0a09 0969 6620 2869 735f 7061 7573  f....if (is_paus
    │ │ │ -00063bf0: 6564 2829 2920 7265 7475 726e 3b0a 0a09  ed()) return;...
    │ │ │ -00063c00: 0969 6620 2821 6d5f 7365 732e 6861 735f  .if (!m_ses.has_
    │ │ │ -00063c10: 6c73 6428 2929 2072 6574 7572 6e3b 0a0a  lsd()) return;..
    │ │ │ -00063c20: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    #i │ │ │ -00063c50: 6664 6566 2054 4f52 5245 4e54 5f53 534c fdef TORRENT_SSL │ │ │ -00063c60: 5f50 4545 5253 0a3c 2f64 6976 3e09 0969 _PEERS.
    ..i │ │ │ -00063c70: 6e74 2070 6f72 7420 3d20 6973 5f73 736c nt port = is_ssl │ │ │ -00063c80: 5f74 6f72 7265 6e74 2829 203f 206d 5f73 _torrent() ? m_s │ │ │ -00063c90: 6573 2e73 736c 5f6c 6973 7465 6e5f 706f es.ssl_listen_po │ │ │ -00063ca0: 7274 2829 203a 206d 5f73 6573 2e6c 6973 rt() : m_ses.lis │ │ │ -00063cb0: 7465 6e5f 706f 7274 2829 3b0a 2365 6c73 ten_port();.#els │ │ │ -00063cc0: 650a 0909 696e 7420 706f 7274 203d 206d e...int port = m │ │ │ -00063cd0: 5f73 6573 2e6c 6973 7465 6e5f 706f 7274 _ses.listen_port │ │ │ -00063ce0: 2829 3b0a 2365 6e64 6966 0a0a 0909 2f2f ();.#endif....// │ │ │ -00063cf0: 2061 6e6e 6f75 6e63 6520 7769 7468 2074 announce with t │ │ │ -00063d00: 6865 206c 6f63 616c 2064 6973 636f 7665 he local discove │ │ │ -00063d10: 7279 2073 6572 7669 6365 0a09 096d 5f74 ry service...m_t │ │ │ -00063d20: 6f72 7265 6e74 5f66 696c 652d 2667 743b orrent_file-> │ │ │ -00063d30: 696e 666f 5f68 6173 6865 7328 292e 666f info_hashes().fo │ │ │ -00063d40: 725f 6561 6368 285b 2661 6d70 3b5d 2873 r_each([&](s │ │ │ -00063d50: 6861 315f 6861 7368 2063 6f6e 7374 2661 ha1_hash const&a │ │ │ -00063d60: 6d70 3b20 6968 2c20 7072 6f74 6f63 6f6c mp; ih, protocol │ │ │ -00063d70: 5f76 6572 7369 6f6e 290a 0909 7b0a 0909 _version)...{... │ │ │ -00063d80: 096d 5f73 6573 2e61 6e6e 6f75 6e63 655f .m_ses.announce_ │ │ │ -00063d90: 6c73 6428 6968 2c20 706f 7274 293b 0a09 lsd(ih, port);.. │ │ │ -00063da0: 097d 293b 0a09 7d0a 0a23 6966 6e64 6566 .});..}..#ifndef │ │ │ -00063db0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00063dc0: 5f44 4854 0a0a 0976 6f69 6420 746f 7272 _DHT...void torr │ │ │ -00063dd0: 656e 743a 3a64 6874 5f61 6e6e 6f75 6e63 ent::dht_announc │ │ │ -00063de0: 6528 290a 097b 0a09 0954 4f52 5245 4e54 e()..{...TORRENT │ │ │ -00063df0: 5f41 5353 4552 5428 6973 5f73 696e 676c _ASSERT(is_singl │ │ │ -00063e00: 655f 7468 7265 6164 2829 293b 0a09 0969 e_thread());...i │ │ │ -00063e10: 6620 2821 6d5f 7365 732e 6468 7428 2929 f (!m_ses.dht()) │ │ │ -00063e20: 0a09 097b 0a23 6966 6e64 6566 2054 4f52 ...{.#ifndef TOR │ │ │ -00063e30: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ -00063e40: 4749 4e47 0a09 0909 6465 6275 675f 6c6f GING....debug_lo │ │ │ -00063e50: 6728 2244 4854 3a20 6e6f 2064 6874 2069 g("DHT: no dht i │ │ │ -00063e60: 6e69 7469 616c 697a 6564 2229 3b0a 2365 nitialized");.#e │ │ │ -00063e70: 6e64 6966 0a09 0909 7265 7475 726e 3b0a ndif....return;. │ │ │ -00063e80: 0909 7d0a 0909 6966 2028 2173 686f 756c ..}...if (!shoul │ │ │ -00063e90: 645f 616e 6e6f 756e 6365 5f64 6874 2829 d_announce_dht() │ │ │ -00063ea0: 290a 0909 7b0a 2369 666e 6465 6620 544f )...{.#ifndef TO │ │ │ -00063eb0: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ -00063ec0: 4747 494e 470a 0909 0969 6620 2873 686f GGING....if (sho │ │ │ -00063ed0: 756c 645f 6c6f 6728 2929 0a09 0909 7b0a uld_log())....{. │ │ │ -00063ee0: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ -00063ef0: 4932 500a 3c2f 7072 653e 3c2f 7464 3e3c I2P.
    < │ │ │ -00063f00: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00063f30: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00063f60: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00063f70: 703a 3332 3336 3c2f 613e 3c2f 7464 3e3c p:3236< │ │ │ -00063f80: 7464 3e69 7420 776f 756c 6420 6265 206e td>it would be n │ │ │ -00063f90: 6963 6520 746f 2072 6169 7365 2074 6865 ice to raise the │ │ │ -00063fa0: 2061 6273 7472 6163 7469 6f6e 206c 6576 abstraction lev │ │ │ -00063fb0: 656c 206f 6620 7468 6520 7472 6163 6b65 el of the tracke │ │ │ -00063fc0: 725f 6c69 7374 206f 7220 7472 6163 6b65 r_list or tracke │ │ │ -00063fd0: 7273 2061 2062 6974 2068 6572 653c 2f74 rs a bit here

    it wo │ │ │ -00064030: 756c 6420 6265 206e 6963 6520 746f 2072 uld be nice to r │ │ │ -00064040: 6169 7365 2074 6865 2061 6273 7472 6163 aise the abstrac │ │ │ -00064050: 7469 6f6e 206c 6576 656c 206f 6620 7468 tion level of th │ │ │ -00064060: 650a 7472 6163 6b65 725f 6c69 7374 206f e.tracker_list o │ │ │ -00064070: 7220 7472 6163 6b65 7273 2061 2062 6974 r trackers a bit │ │ │ -00064080: 2068 6572 653c 2f68 323e 3c68 343e 2e2e here

    .. │ │ │ -00064090: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -000640a0: 3a33 3233 363c 2f68 343e 3c70 7265 2073 :3236

    ..time_point
    │ │ │ -000640f0: 3332 2063 6f6e 7374 206e 6f77 203d 2061  32 const now = a
    │ │ │ -00064100: 7578 3a3a 7469 6d65 5f6e 6f77 3332 2829  ux::time_now32()
    │ │ │ -00064110: 3b0a 0a09 092f 2f20 6561 6368 206c 6973  ;....// each lis
    │ │ │ -00064120: 7465 6e20 736f 636b 6574 2067 6574 7320  ten socket gets 
    │ │ │ -00064130: 6974 7320 6f77 6e20 616e 6e6f 756e 6365  its own announce
    │ │ │ -00064140: 2073 7461 7465 0a09 092f 2f20 736f 2074   state...// so t
    │ │ │ -00064150: 6861 7420 6561 6368 206f 6e65 2073 686f  hat each one sho
    │ │ │ -00064160: 756c 6420 6765 7420 6174 206c 6561 7374  uld get at least
    │ │ │ -00064170: 206f 6e65 2061 6e6e 6f75 6e63 650a 0909   one announce...
    │ │ │ -00064180: 7374 643a 3a76 6563 746f 7226 6c74 3b61  std::vector<a
    │ │ │ -00064190: 6e6e 6f75 6e63 655f 7374 6174 6526 6774  nnounce_state>
    │ │ │ -000641a0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f  ; listen_socket_
    │ │ │ -000641b0: 7374 6174 6573 3b0a 0a09 0962 6f6f 6c20  states;....bool 
    │ │ │ -000641c0: 636f 6e73 7420 616e 6e6f 756e 6365 5f74  const announce_t
    │ │ │ -000641d0: 6f5f 616c 6c5f 7469 6572 7320 3d20 7365  o_all_tiers = se
    │ │ │ -000641e0: 7474 696e 6773 2829 2e67 6574 5f62 6f6f  ttings().get_boo
    │ │ │ -000641f0: 6c28 7365 7474 696e 6773 5f70 6163 6b3a  l(settings_pack:
    │ │ │ -00064200: 3a61 6e6e 6f75 6e63 655f 746f 5f61 6c6c  :announce_to_all
    │ │ │ -00064210: 5f74 6965 7273 293b 0a09 0962 6f6f 6c20  _tiers);...bool 
    │ │ │ -00064220: 636f 6e73 7420 616e 6e6f 756e 6365 5f74  const announce_t
    │ │ │ -00064230: 6f5f 616c 6c5f 7472 6163 6b65 7273 203d  o_all_trackers =
    │ │ │ -00064240: 2073 6574 7469 6e67 7328 292e 6765 745f   settings().get_
    │ │ │ -00064250: 626f 6f6c 2873 6574 7469 6e67 735f 7061  bool(settings_pa
    │ │ │ -00064260: 636b 3a3a 616e 6e6f 756e 6365 5f74 6f5f  ck::announce_to_
    │ │ │ -00064270: 616c 6c5f 7472 6163 6b65 7273 293b 0a23  all_trackers);.#
    │ │ │ -00064280: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -00064290: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ -000642a0: 0969 6e74 2069 6478 203d 202d 313b 0a09  .int idx = -1;..
    │ │ │ -000642b0: 0969 6620 2873 686f 756c 645f 6c6f 6728  .if (should_log(
    │ │ │ -000642c0: 2929 0a09 097b 0a09 0909 6465 6275 675f  ))...{....debug_
    │ │ │ -000642d0: 6c6f 6728 222a 2a2a 2061 6e6e 6f75 6e63  log("*** announc
    │ │ │ -000642e0: 653a 2022 0a09 0909 0922 5b20 616e 6e6f  e: "....."[ anno
    │ │ │ -000642f0: 756e 6365 5f74 6f5f 616c 6c5f 7469 6572  unce_to_all_tier
    │ │ │ -00064300: 733a 2025 6420 616e 6e6f 756e 6365 5f74  s: %d announce_t
    │ │ │ -00064310: 6f5f 616c 6c5f 7472 6163 6b65 7273 3a20  o_all_trackers: 
    │ │ │ -00064320: 2564 206e 756d 5f74 7261 636b 6572 733a  %d num_trackers:
    │ │ │ -00064330: 2025 6420 5d22 0a09 0909 092c 2061 6e6e   %d ]"....., ann
    │ │ │ -00064340: 6f75 6e63 655f 746f 5f61 6c6c 5f74 6965  ounce_to_all_tie
    │ │ │ -00064350: 7273 0a09 0909 092c 2061 6e6e 6f75 6e63  rs....., announc
    │ │ │ -00064360: 655f 746f 5f61 6c6c 5f74 7261 636b 6572  e_to_all_tracker
    │ │ │ -00064370: 730a 0909 0909 2c20 696e 7428 6d5f 7472  s....., int(m_tr
    │ │ │ -00064380: 6163 6b65 7273 2e73 697a 6528 2929 293b  ackers.size()));
    │ │ │ -00064390: 0a09 097d 0a23 656e 6469 660a 0a3c 6469  ...}.#endif....for
    │ │ │ -000643d0: 2028 6175 746f 2661 6d70 3b20 6165 203a   (auto& ae :
    │ │ │ -000643e0: 206d 5f74 7261 636b 6572 7329 0a3c 2f64   m_trackers)...{.#ifndef T
    │ │ │ -00064400: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c  ORRENT_DISABLE_L
    │ │ │ -00064410: 4f47 4749 4e47 0a09 0909 2b2b 6964 783b  OGGING....++idx;
    │ │ │ -00064420: 0a23 656e 6469 660a 0909 0972 6566 7265  .#endif....refre
    │ │ │ -00064430: 7368 5f65 6e64 706f 696e 745f 6c69 7374  sh_endpoint_list
    │ │ │ -00064440: 286d 5f73 6573 2c20 6973 5f73 736c 5f74  (m_ses, is_ssl_t
    │ │ │ -00064450: 6f72 7265 6e74 2829 2c20 626f 6f6c 286d  orrent(), bool(m
    │ │ │ -00064460: 5f63 6f6d 706c 6574 655f 7365 6e74 292c  _complete_sent),
    │ │ │ -00064470: 2061 6529 3b0a 0a09 0909 2f2f 2069 6620   ae);.....// if 
    │ │ │ -00064480: 7472 6163 6b65 7269 6420 6973 206e 6f74  trackerid is not
    │ │ │ -00064490: 2073 7065 6369 6669 6564 2066 6f72 2074   specified for t
    │ │ │ -000644a0: 7261 636b 6572 2075 7365 2064 6566 6175  racker use defau
    │ │ │ -000644b0: 6c74 206f 6e65 2c20 7072 6f62 6162 6c79  lt one, probably
    │ │ │ -000644c0: 2073 6574 2065 7870 6c69 6369 746c 790a   set explicitly.
    │ │ │ -000644d0: 0909 0972 6571 2e74 7261 636b 6572 6964  ...req.trackerid
    │ │ │ -000644e0: 203d 2061 652e 7472 6163 6b65 7269 642e   = ae.trackerid.
    │ │ │ -000644f0: 656d 7074 7928 2920 3f20 6d5f 7472 6163  empty() ? m_trac
    │ │ │ -00064500: 6b65 7269 6420 3a20 6165 2e74 7261 636b  kerid : ae.track
    │ │ │ -00064510: 6572 6964 3b0a 0909 0972 6571 2e75 726c  erid;....req.url
    │ │ │ -00064520: 203d 2061 652e 7572 6c3b 0a0a 2369 6620   = ae.url;..#if 
    │ │ │ -00064530: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ -00064540: 0909 092f 2f20 6966 2077 6520 646f 6e27  ...// if we don'
    │ │ │ -00064550: 7420 616c 6c6f 7720 6d69 7869 6e67 206e  t allow mixing n
    │ │ │ -00064560: 6f72 6d61 6c20 7065 6572 7320 696e 746f  ormal peers into
    │ │ │ -00064570: 2074 6869 7320 6932 7020 746f 7272 656e   this i2p torren
    │ │ │ -00064580: 742c 0a09 0909 2f2f 2073 6b69 7020 6e6f  t,....// skip no
    │ │ │ -00064590: 6e2d 6932 7020 7472 6163 6b65 7273 2e20  n-i2p trackers. 
    │ │ │ -000645a0: 7570 6461 7465 5f74 7261 636b 6572 5f74  update_tracker_t
    │ │ │ -000645b0: 696d 6572 2829 2061 7070 6c69 6573 2074  imer() applies t
    │ │ │ -000645c0: 6865 0a09 0909 2f2f 2073 616d 6520 736b  he....// same sk
    │ │ │ -000645d0: 6970 2073 6f20 7468 6520 7469 6d65 7220  ip so the timer 
    │ │ │ -000645e0: 646f 6573 6e27 7420 6b65 6570 2066 6972  doesn't keep fir
    │ │ │ -000645f0: 696e 6720 666f 7220 7472 6163 6b65 7273  ing for trackers
    │ │ │ -00064600: 2077 6527 6c6c 0a09 0909 2f2f 206e 6576   we'll....// nev
    │ │ │ -00064610: 6572 2063 6f6e 7461 6374 2e0a 0909 0969  er contact.....i
    │ │ │ -00064620: 6620 2821 6932 705f 636f 6d70 6174 6962  f (!i2p_compatib
    │ │ │ -00064630: 6c65 5f74 7261 636b 6572 2861 6529 2920  le_tracker(ae)) 
    │ │ │ -00064640: 636f 6e74 696e 7565 3b0a 0909 092f 2f20  continue;....// 
    │ │ │ -00064650: 7265 7120 6973 2072 6575 7365 6420 6163  req is reused ac
    │ │ │ -00064660: 726f 7373 2069 7465 7261 7469 6f6e 732c  ross iterations,
    │ │ │ -00064670: 2073 6f20 7365 7420 7468 6520 6932 7020   so set the i2p 
    │ │ │ -00064680: 6269 7420 746f 206d 6174 6368 0a09 0909  bit to match....
    │ │ │ -00064690: 2f2f 2074 6869 7320 7472 6163 6b65 7220  // this tracker 
    │ │ │ -000646a0: 7261 7468 6572 2074 6861 6e20 6f6e 6c79  rather than only
    │ │ │ -000646b0: 2065 7665 7220 4f52 2d69 6e67 2069 7420   ever OR-ing it 
    │ │ │ -000646c0: 696e 2e0a 0909 0969 6620 2861 652e 6932  in.....if (ae.i2
    │ │ │ -000646d0: 7029 0a09 0909 0972 6571 2e6b 696e 6420  p).....req.kind 
    │ │ │ -000646e0: 7c3d 2074 7261 636b 6572 5f72 6571 7565  |= tracker_reque
    │ │ │ -000646f0: 7374 3a3a 6932 703b 0a09 0909 656c 7365  st::i2p;....else
    │ │ │ -00064700: 0a09 0909 0972 6571 2e6b 696e 6420 2661  .....req.kind &a
    │ │ │ -00064710: 6d70 3b3d 207e 7472 6163 6b65 725f 7265  mp;= ~tracker_re
    │ │ │ -00064720: 7175 6573 743a 3a69 3270 3b0a 2365 6e64  quest::i2p;.#end
    │ │ │ -00064730: 6966 0a0a 0909 0966 6f72 2028 6175 746f  if.....for (auto
    │ │ │ -00064740: 2661 6d70 3b20 6165 7020 3a20 6165 2e65  & aep : ae.e
    │ │ │ -00064750: 6e64 706f 696e 7473 290a 0909 097b 0a09  ndpoints)....{..
    │ │ │ -00064760: 0909 092f 2f20 646f 206e 6f74 2061 6464  ...// do not add
    │ │ │ -00064770: 2063 6f64 6520 7768 6963 6820 636f 6e74   code which cont
    │ │ │ -00064780: 696e 7565 7320 746f 2074 6865 206e 6578  inues to the nex
    │ │ │ -00064790: 7420 656e 6470 6f69 6e74 2068 6572 6521  t endpoint here!
    │ │ │ -000647a0: 0a09 0909 092f 2f20 6c69 7374 656e 5f73  .....// listen_s
    │ │ │ -000647b0: 6f63 6b65 745f 7374 6174 6573 206e 6565  ocket_states nee
    │ │ │ -000647c0: 6473 2074 6f20 6265 2070 6f70 756c 6174  ds to be populat
    │ │ │ -000647d0: 6564 2065 7665 6e20 6966 206e 6f6e 6520  ed even if none 
    │ │ │ -000647e0: 6f66 2074 6865 2065 6e64 706f 696e 7473  of the endpoints
    │ │ │ -000647f0: 0a09 0909 092f 2f20 7769 6c6c 2062 6520  .....// will be 
    │ │ │ -00064800: 616e 6e6f 756e 6369 6e67 2066 6f72 2074  announcing for t
    │ │ │ -00064810: 6869 7320 7472 6163 6b65 720a 0909 0909  his tracker.....
    │ │ │ -00064820: 2f2f 206f 7468 6572 7769 7365 2074 6865  // otherwise the
    │ │ │ -00064830: 2065 6172 6c79 2062 6169 6c20 6f75 7420   early bail out 
    │ │ │ -00064840: 7768 656e 206e 6569 7468 6572 2061 6e6e  when neither ann
    │ │ │ -00064850: 6f75 6e63 655f 746f 5f61 6c6c 5f74 7261  ounce_to_all_tra
    │ │ │ -00064860: 636b 6572 730a 3c2f 7072 653e 3c2f 7464  ckers.
    relevance │ │ │ -000648a0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -000648b0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ -000648e0: 6370 703a 3337 3730 3c2f 613e 3c2f 7464 cpp:3770move this i │ │ │ -00064900: 6e74 6f20 6120 6675 6e63 7469 6f6e 206f nto a function o │ │ │ -00064910: 6e20 7472 6163 6b65 725f 6c69 7374 3c2f n tracker_list

    move │ │ │ -00064970: 2074 6869 7320 696e 746f 2061 2066 756e this into a fun │ │ │ -00064980: 6374 696f 6e20 6f6e 2074 7261 636b 6572 ction on tracker │ │ │ -00064990: 5f6c 6973 743c 2f68 323e 3c68 343e 2e2e _list

    .. │ │ │ -000649a0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -000649b0: 3a33 3737 303c 2f68 343e 3c70 7265 2073 :3770

    .., struct t
    │ │ │ -00064a00: 7261 636b 6572 5f72 6573 706f 6e73 6520  racker_response 
    │ │ │ -00064a10: 636f 6e73 7426 616d 703b 2072 6573 7029  const& resp)
    │ │ │ -00064a20: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ -00064a30: 5345 5254 2869 735f 7369 6e67 6c65 5f74  SERT(is_single_t
    │ │ │ -00064a40: 6872 6561 6428 2929 3b0a 0a09 0949 4e56  hread());....INV
    │ │ │ -00064a50: 4152 4941 4e54 5f43 4845 434b 3b0a 0909  ARIANT_CHECK;...
    │ │ │ -00064a60: 544f 5252 454e 545f 4153 5345 5254 2821  TORRENT_ASSERT(!
    │ │ │ -00064a70: 2872 2e6b 696e 6420 2661 6d70 3b20 7472  (r.kind & tr
    │ │ │ -00064a80: 6163 6b65 725f 7265 7175 6573 743a 3a73  acker_request::s
    │ │ │ -00064a90: 6372 6170 655f 7265 7175 6573 7429 293b  crape_request));
    │ │ │ -00064aa0: 0a0a 0909 2f2f 2069 6620 7468 6520 7472  ....// if the tr
    │ │ │ -00064ab0: 6163 6b65 7220 746f 6c64 2075 7320 7768  acker told us wh
    │ │ │ -00064ac0: 6174 206f 7572 2065 7874 6572 6e61 6c20  at our external 
    │ │ │ -00064ad0: 4950 2061 6464 7265 7373 2069 732c 2072  IP address is, r
    │ │ │ -00064ae0: 6563 6f72 6420 6974 2077 6974 680a 0909  ecord it with...
    │ │ │ -00064af0: 2f2f 206f 7574 2065 7874 6572 6e61 6c20  // out external 
    │ │ │ -00064b00: 4950 2063 6f75 6e74 6572 2028 616e 6420  IP counter (and 
    │ │ │ -00064b10: 7061 7373 2061 6c6f 6e67 2074 6865 2049  pass along the I
    │ │ │ -00064b20: 5020 6f66 2074 6865 2074 7261 636b 6572  P of the tracker
    │ │ │ -00064b30: 2074 6f20 6b6e 6f77 0a09 092f 2f20 7768   to know...// wh
    │ │ │ -00064b40: 6f20 746f 2061 7474 7269 6275 7465 2074  o to attribute t
    │ │ │ -00064b50: 6869 7320 766f 7465 2074 6f29 0a09 0969  his vote to)...i
    │ │ │ -00064b60: 6620 2872 6573 702e 6578 7465 726e 616c  f (resp.external
    │ │ │ -00064b70: 5f69 7020 213d 2061 6464 7265 7373 2829  _ip != address()
    │ │ │ -00064b80: 2026 616d 703b 2661 6d70 3b20 2174 7261   && !tra
    │ │ │ -00064b90: 636b 6572 5f69 702e 6973 5f75 6e73 7065  cker_ip.is_unspe
    │ │ │ -00064ba0: 6369 6669 6564 2829 2026 616d 703b 2661  cified() &&a
    │ │ │ -00064bb0: 6d70 3b20 722e 6f75 7467 6f69 6e67 5f73  mp; r.outgoing_s
    │ │ │ -00064bc0: 6f63 6b65 7429 0a09 0909 6d5f 7365 732e  ocket)....m_ses.
    │ │ │ -00064bd0: 7365 745f 6578 7465 726e 616c 5f61 6464  set_external_add
    │ │ │ -00064be0: 7265 7373 2872 2e6f 7574 676f 696e 675f  ress(r.outgoing_
    │ │ │ -00064bf0: 736f 636b 6574 2e67 6574 5f6c 6f63 616c  socket.get_local
    │ │ │ -00064c00: 5f65 6e64 706f 696e 7428 290a 0909 0909  _endpoint().....
    │ │ │ -00064c10: 2c20 7265 7370 2e65 7874 6572 6e61 6c5f  , resp.external_
    │ │ │ -00064c20: 6970 0a09 0909 092c 2061 7578 3a3a 7365  ip....., aux::se
    │ │ │ -00064c30: 7373 696f 6e5f 696e 7465 7266 6163 653a  ssion_interface:
    │ │ │ -00064c40: 3a73 6f75 7263 655f 7472 6163 6b65 722c  :source_tracker,
    │ │ │ -00064c50: 2074 7261 636b 6572 5f69 7029 3b0a 0a09   tracker_ip);...
    │ │ │ -00064c60: 0974 696d 655f 706f 696e 7433 3220 636f  .time_point32 co
    │ │ │ -00064c70: 6e73 7420 6e6f 7720 3d20 6175 783a 3a74  nst now = aux::t
    │ │ │ -00064c80: 696d 655f 6e6f 7733 3228 293b 0a0a 0909  ime_now32();....
    │ │ │ -00064c90: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e  protocol_version
    │ │ │ -00064ca0: 2063 6f6e 7374 2076 203d 2072 2e69 6e66   const v = r.inf
    │ │ │ -00064cb0: 6f5f 6861 7368 203d 3d20 746f 7272 656e  o_hash == torren
    │ │ │ -00064cc0: 745f 6669 6c65 2829 2e69 6e66 6f5f 6861  t_file().info_ha
    │ │ │ -00064cd0: 7368 6573 2829 2e76 310a 0909 093f 2070  shes().v1....? p
    │ │ │ -00064ce0: 726f 746f 636f 6c5f 7665 7273 696f 6e3a  rotocol_version:
    │ │ │ -00064cf0: 3a56 3120 3a20 7072 6f74 6f63 6f6c 5f76  :V1 : protocol_v
    │ │ │ -00064d00: 6572 7369 6f6e 3a3a 5632 3b0a 0a3c 6469  ersion::V2;....aux
    │ │ │ -00064d40: 3a3a 616e 6e6f 756e 6365 5f65 6e74 7279  ::announce_entry
    │ │ │ -00064d50: 2a20 6165 203d 206d 5f74 7261 636b 6572  * ae = m_tracker
    │ │ │ -00064d60: 732e 6669 6e64 5f74 7261 636b 6572 2872  s.find_tracker(r
    │ │ │ -00064d70: 2e75 726c 293b 0a3c 2f64 6976 3e0a 0909  .url);.
    ... │ │ │ -00064d80: 7463 703a 3a65 6e64 706f 696e 7420 6c6f tcp::endpoint lo │ │ │ -00064d90: 6361 6c5f 656e 6470 6f69 6e74 3b0a 0909 cal_endpoint;... │ │ │ -00064da0: 6966 2028 6165 290a 0909 7b0a 0909 0961 if (ae)...{....a │ │ │ -00064db0: 7574 6f2a 2061 6570 203d 2061 652d 2667 uto* aep = ae-&g │ │ │ -00064dc0: 743b 6669 6e64 5f65 6e64 706f 696e 7428 t;find_endpoint( │ │ │ -00064dd0: 722e 6f75 7467 6f69 6e67 5f73 6f63 6b65 r.outgoing_socke │ │ │ -00064de0: 7429 3b0a 0909 0969 6620 2861 6570 290a t);....if (aep). │ │ │ -00064df0: 0909 097b 0a09 0909 0961 7574 6f26 616d ...{.....auto&am │ │ │ -00064e00: 703b 2061 203d 2061 6570 2d26 6774 3b69 p; a = aep->i │ │ │ -00064e10: 6e66 6f5f 6861 7368 6573 5b76 5d3b 0a0a nfo_hashes[v];.. │ │ │ -00064e20: 0909 0909 6c6f 6361 6c5f 656e 6470 6f69 ....local_endpoi │ │ │ -00064e30: 6e74 203d 2061 6570 2d26 6774 3b6c 6f63 nt = aep->loc │ │ │ -00064e40: 616c 5f65 6e64 706f 696e 743b 0a09 0909 al_endpoint;.... │ │ │ -00064e50: 0969 6620 2872 6573 702e 696e 636f 6d70 .if (resp.incomp │ │ │ -00064e60: 6c65 7465 2026 6774 3b3d 2030 2920 612e lete >= 0) a. │ │ │ -00064e70: 7363 7261 7065 5f69 6e63 6f6d 706c 6574 scrape_incomplet │ │ │ -00064e80: 6520 3d20 7265 7370 2e69 6e63 6f6d 706c e = resp.incompl │ │ │ -00064e90: 6574 653b 0a09 0909 0969 6620 2872 6573 ete;.....if (res │ │ │ -00064ea0: 702e 636f 6d70 6c65 7465 2026 6774 3b3d p.complete >= │ │ │ -00064eb0: 2030 2920 612e 7363 7261 7065 5f63 6f6d 0) a.scrape_com │ │ │ -00064ec0: 706c 6574 6520 3d20 7265 7370 2e63 6f6d plete = resp.com │ │ │ -00064ed0: 706c 6574 653b 0a09 0909 0969 6620 2872 plete;.....if (r │ │ │ -00064ee0: 6573 702e 646f 776e 6c6f 6164 6564 2026 esp.downloaded & │ │ │ -00064ef0: 6774 3b3d 2030 2920 612e 7363 7261 7065 gt;= 0) a.scrape │ │ │ -00064f00: 5f64 6f77 6e6c 6f61 6465 6420 3d20 7265 _downloaded = re │ │ │ -00064f10: 7370 2e64 6f77 6e6c 6f61 6465 643b 0a09 sp.downloaded;.. │ │ │ -00064f20: 0909 0969 6620 2821 612e 7374 6172 745f ...if (!a.start_ │ │ │ -00064f30: 7365 6e74 2026 616d 703b 2661 6d70 3b20 sent && │ │ │ -00064f40: 722e 6576 656e 7420 3d3d 2065 7665 6e74 r.event == event │ │ │ -00064f50: 5f74 3a3a 7374 6172 7465 6429 0a09 0909 _t::started).... │ │ │ -00064f60: 0909 612e 7374 6172 745f 7365 6e74 203d ..a.start_sent = │ │ │ -00064f70: 2074 7275 653b 0a09 0909 0969 6620 2821 true;.....if (! │ │ │ -00064f80: 612e 636f 6d70 6c65 7465 5f73 656e 7420 a.complete_sent │ │ │ -00064f90: 2661 6d70 3b26 616d 703b 2072 2e65 7665 && r.eve │ │ │ -00064fa0: 6e74 203d 3d20 6576 656e 745f 743a 3a63 nt == event_t::c │ │ │ -00064fb0: 6f6d 706c 6574 6564 290a 0909 0909 7b0a ompleted).....{. │ │ │ -00064fc0: 0909 0909 0961 2e63 6f6d 706c 6574 655f .....a.complete_ │ │ │ -00064fd0: 7365 6e74 203d 2074 7275 653b 0a09 0909 sent = true;.... │ │ │ -00064fe0: 0909 2f2f 2077 6520 7375 6363 6573 7366 ..// we successf │ │ │ -00064ff0: 756c 6c79 2072 6570 6f72 7465 6420 6576 ully reported ev │ │ │ -00065000: 656e 743d 636f 6d70 6c65 7465 6420 746f ent=completed to │ │ │ -00065010: 206f 6e65 2074 7261 636b 6572 2e20 446f one tracker. Do │ │ │ -00065020: 6e27 740a 0909 0909 092f 2f20 7365 6e64 n't......// send │ │ │ -00065030: 2069 7420 746f 2061 6e79 206f 7468 6572 it to any other │ │ │ -00065040: 206f 6e65 7320 6672 6f6d 206e 6f77 206f ones from now o │ │ │ -00065050: 6e20 2874 6865 7265 206d 6179 2062 6520 n (there may be │ │ │ -00065060: 6f74 6865 720a 0909 0909 092f 2f20 616e other......// an │ │ │ -00065070: 6e6f 756e 6365 7320 6f75 7473 7461 6e64 nounces outstand │ │ │ -00065080: 696e 6720 7269 6768 7420 6e6f 7720 7468 ing right now th │ │ │ -00065090: 6f75 6768 290a 0909 0909 096d 5f63 6f6d ough)......m_com │ │ │ -000650a0: 706c 6574 655f 7365 6e74 203d 2074 7275 plete_sent = tru │ │ │ -000650b0: 653b 0a09 0909 097d 0a09 0909 0961 652d e;.....}.....ae- │ │ │ -000650c0: 2667 743b 7665 7269 6669 6564 203d 2074 >verified = t │ │ │ -000650d0: 7275 653b 0a09 0909 0961 2e6e 6578 745f rue;.....a.next_ │ │ │ -000650e0: 616e 6e6f 756e 6365 203d 206e 6f77 202b announce = now + │ │ │ -000650f0: 2072 6573 702e 696e 7465 7276 616c 3b0a resp.interval;. │ │ │ -00065100: 0909 0909 612e 6d69 6e5f 616e 6e6f 756e ....a.min_announ │ │ │ -00065110: 6365 203d 206e 6f77 202b 2072 6573 702e ce = now + resp. │ │ │ -00065120: 6d69 6e5f 696e 7465 7276 616c 3b0a 0909 min_interval;... │ │ │ -00065130: 0909 612e 7570 6461 7469 6e67 203d 2066 ..a.updating = f │ │ │ -00065140: 616c 7365 3b0a 0909 0909 612e 6661 696c alse;.....a.fail │ │ │ -00065150: 7320 3d20 303b 0a09 0909 0961 2e6c 6173 s = 0;.....a.las │ │ │ -00065160: 745f 6572 726f 722e 636c 6561 7228 293b t_error.clear(); │ │ │ -00065170: 0a09 0909 0961 2e6d 6573 7361 6765 203d .....a.message = │ │ │ -00065180: 2021 7265 7370 2e77 6172 6e69 6e67 5f6d !resp.warning_m │ │ │ -00065190: 6573 7361 6765 2e65 6d70 7479 2829 203f essage.empty() ? │ │ │ -000651a0: 2072 6573 702e 7761 726e 696e 675f 6d65 resp.warning_me │ │ │ -000651b0: 7373 6167 6520 3a20 7374 643a 3a73 7472 ssage : std::str │ │ │ -000651c0: 696e 6728 293b 0a3c 2f70 7265 3e3c 2f74 ing();.
    relevanc │ │ │ -00065200: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ -00065240: 2e63 7070 3a33 3836 343c 2f61 3e3c 2f74 .cpp:3864the destin │ │ │ -00065260: 6174 696f 6e20 7374 7269 6e67 2073 686f ation string sho │ │ │ -00065270: 756c 6420 6265 2062 6173 6536 3420 6465 uld be base64 de │ │ │ -00065280: 636f 6465 6420 616e 6420 7368 6132 3536 coded and sha256 │ │ │ -00065290: 2068 6173 6865 6420 746f 2066 6f72 6d20 hashed to form │ │ │ -000652a0: 7468 6520 6465 7374 696e 6174 696f 6e20 the destination │ │ │ -000652b0: 6164 6472 6573 7320 616e 6420 7374 6f72 address and stor │ │ │ -000652c0: 6520 7468 6174 2069 6e20 7468 6520 6932 e that in the i2 │ │ │ -000652d0: 705f 7065 6572 206f 626a 6563 7420 6469 p_peer object di │ │ │ -000652e0: 7265 6374 6c79 3c2f 7464 3e3c 2f74 723e rectly │ │ │ -000652f0: 3c74 7220 6964 3d22 3233 3222 2073 7479 │ │ │ -00065320: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00065330: 3c68 323e 7468 6520 6465 7374 696e 6174

    the destinat │ │ │ -00065340: 696f 6e20 7374 7269 6e67 2073 686f 756c ion string shoul │ │ │ -00065350: 6420 6265 2062 6173 6536 3420 6465 636f d be base64 deco │ │ │ -00065360: 6465 6420 616e 640a 7368 6132 3536 2068 ded and.sha256 h │ │ │ -00065370: 6173 6865 6420 746f 2066 6f72 6d20 7468 ashed to form th │ │ │ -00065380: 6520 6465 7374 696e 6174 696f 6e20 6164 e destination ad │ │ │ -00065390: 6472 6573 7320 616e 6420 7374 6f72 650a dress and store. │ │ │ -000653a0: 7468 6174 2069 6e20 7468 6520 6932 705f that in the i2p_ │ │ │ -000653b0: 7065 6572 206f 626a 6563 7420 6469 7265 peer object dire │ │ │ -000653c0: 6374 6c79 3c2f 6832 3e3c 6834 3e2e 2e2f ctly

    ../ │ │ │ -000653d0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -000653e0: 3338 3634 3c2f 6834 3e3c 7072 6520 7374 3864

    ..for (auto c
    │ │ │ -00065430: 6f6e 7374 2661 6d70 3b20 6920 3a20 7265  onst& i : re
    │ │ │ -00065440: 7370 2e70 6565 7273 290a 0909 7b0a 0909  sp.peers)...{...
    │ │ │ -00065450: 092f 2f20 646f 6e27 7420 6d61 6b65 2063  .// don't make c
    │ │ │ -00065460: 6f6e 6e65 6374 696f 6e73 2074 6f20 6f75  onnections to ou
    │ │ │ -00065470: 7273 656c 660a 0909 0969 6620 2869 2e70  rself....if (i.p
    │ │ │ -00065480: 6964 203d 3d20 6d5f 7065 6572 5f69 6429  id == m_peer_id)
    │ │ │ -00065490: 0a09 0909 0963 6f6e 7469 6e75 653b 0a0a  .....continue;..
    │ │ │ -000654a0: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ -000654b0: 4932 500a 0909 0969 6620 2872 2e69 3270  I2P....if (r.i2p
    │ │ │ -000654c0: 636f 6e6e 290a 0909 097b 0a09 0909 092f  conn)....{...../
    │ │ │ -000654d0: 2f20 7468 6973 2069 7320 616e 2069 3270  / this is an i2p
    │ │ │ -000654e0: 206e 616d 652c 2077 6520 6e65 6564 2074   name, we need t
    │ │ │ -000654f0: 6f20 7573 6520 7468 6520 5341 4d20 636f  o use the SAM co
    │ │ │ -00065500: 6e6e 6563 7469 6f6e 0a09 0909 092f 2f20  nnection.....// 
    │ │ │ -00065510: 746f 2064 6f20 7468 6520 6e61 6d65 206c  to do the name l
    │ │ │ -00065520: 6f6f 6b75 700a 0909 0909 6966 2028 7374  ookup.....if (st
    │ │ │ -00065530: 7269 6e67 5f65 6e64 735f 7769 7468 2869  ring_ends_with(i
    │ │ │ -00065540: 2e68 6f73 746e 616d 652c 2022 2e69 3270  .hostname, ".i2p
    │ │ │ -00065550: 2229 290a 0909 0909 7b0a 0909 0909 0941  ")).....{......A
    │ │ │ -00065560: 4444 5f4f 5554 5354 414e 4449 4e47 5f41  DD_OUTSTANDING_A
    │ │ │ -00065570: 5359 4e43 2822 746f 7272 656e 743a 3a6f  SYNC("torrent::o
    │ │ │ -00065580: 6e5f 6932 705f 7265 736f 6c76 6522 293b  n_i2p_resolve");
    │ │ │ -00065590: 0a09 0909 0909 722e 6932 7063 6f6e 6e2d  ......r.i2pconn-
    │ │ │ -000655a0: 2667 743b 6173 796e 635f 6e61 6d65 5f6c  >async_name_l
    │ │ │ -000655b0: 6f6f 6b75 7028 692e 686f 7374 6e61 6d65  ookup(i.hostname
    │ │ │ -000655c0: 2e63 5f73 7472 2829 0a09 0909 0909 092c  .c_str().......,
    │ │ │ -000655d0: 205b 7365 6c66 203d 2073 6861 7265 645f   [self = shared_
    │ │ │ -000655e0: 6672 6f6d 5f74 6869 7328 295d 2028 6572  from_this()] (er
    │ │ │ -000655f0: 726f 725f 636f 6465 2063 6f6e 7374 2661  ror_code const&a
    │ │ │ -00065600: 6d70 3b20 6563 2c20 6368 6172 2063 6f6e  mp; ec, char con
    │ │ │ -00065610: 7374 2a20 6465 7374 290a 0909 0909 0909  st* dest).......
    │ │ │ -00065620: 7b20 7365 6c66 2d26 6774 3b74 6f72 7265  { self->torre
    │ │ │ -00065630: 6e74 3a3a 6f6e 5f69 3270 5f72 6573 6f6c  nt::on_i2p_resol
    │ │ │ -00065640: 7665 2865 632c 2064 6573 742c 2070 6565  ve(ec, dest, pee
    │ │ │ -00065650: 725f 696e 666f 3a3a 7472 6163 6b65 7229  r_info::tracker)
    │ │ │ -00065660: 3b20 7d29 3b0a 0909 0909 7d0a 0909 0909  ; });.....}.....
    │ │ │ -00065670: 656c 7365 0a09 0909 097b 0a3c 6469 7620  else.....{.
    .....to │ │ │ -000656b0: 7272 656e 745f 7374 6174 6520 7374 203d rrent_state st = │ │ │ -000656c0: 2067 6574 5f70 6565 725f 6c69 7374 5f73 get_peer_list_s │ │ │ -000656d0: 7461 7465 2829 3b0a 3c2f 6469 763e 0909 tate();.
    .. │ │ │ -000656e0: 0909 096e 6565 645f 7065 6572 5f6c 6973 ...need_peer_lis │ │ │ -000656f0: 7428 293b 0a09 0909 0909 6966 2028 6d5f t();......if (m_ │ │ │ -00065700: 7065 6572 5f6c 6973 742d 2667 743b 6164 peer_list->ad │ │ │ -00065710: 645f 6932 705f 7065 6572 2869 2e68 6f73 d_i2p_peer(i.hos │ │ │ -00065720: 746e 616d 652c 2070 6565 725f 696e 666f tname, peer_info │ │ │ -00065730: 3a3a 7472 6163 6b65 722c 207b 7d2c 2026 ::tracker, {}, & │ │ │ -00065740: 616d 703b 7374 2929 0a09 0909 0909 0973 amp;st)).......s │ │ │ -00065750: 7461 7465 5f75 7064 6174 6564 2829 3b0a tate_updated();. │ │ │ -00065760: 0909 0909 0970 6565 7273 5f65 7261 7365 .....peers_erase │ │ │ -00065770: 6428 7374 2e65 7261 7365 6429 3b0a 0909 d(st.erased);... │ │ │ -00065780: 0909 7d0a 0909 097d 0a09 0909 656c 7365 ..}....}....else │ │ │ -00065790: 0a23 656e 6469 660a 0909 097b 0a09 0909 .#endif....{.... │ │ │ -000657a0: 0941 4444 5f4f 5554 5354 414e 4449 4e47 .ADD_OUTSTANDING │ │ │ -000657b0: 5f41 5359 4e43 2822 746f 7272 656e 743a _ASYNC("torrent: │ │ │ -000657c0: 3a6f 6e5f 7065 6572 5f6e 616d 655f 6c6f :on_peer_name_lo │ │ │ -000657d0: 6f6b 7570 2229 3b0a 0909 0909 6d5f 7365 okup");.....m_se │ │ │ -000657e0: 732e 6765 745f 7265 736f 6c76 6572 2829 s.get_resolver() │ │ │ -000657f0: 2e61 7379 6e63 5f72 6573 6f6c 7665 2869 .async_resolve(i │ │ │ -00065800: 2e68 6f73 746e 616d 652c 2061 7578 3a3a .hostname, aux:: │ │ │ -00065810: 7265 736f 6c76 6572 5f69 6e74 6572 6661 resolver_interfa │ │ │ -00065820: 6365 3a3a 6162 6f72 745f 6f6e 5f73 6875 ce::abort_on_shu │ │ │ -00065830: 7464 6f77 6e0a 0909 0909 092c 2073 7464 tdown......, std │ │ │ -00065840: 3a3a 6269 6e64 2826 616d 703b 746f 7272 ::bind(&torr │ │ │ -00065850: 656e 743a 3a6f 6e5f 7065 6572 5f6e 616d ent::on_peer_nam │ │ │ -00065860: 655f 6c6f 6f6b 7570 2c20 7368 6172 6564 e_lookup, shared │ │ │ -00065870: 5f66 726f 6d5f 7468 6973 2829 2c20 5f31 _from_this(), _1 │ │ │ -00065880: 2c20 5f32 2c20 692e 706f 7274 2c20 7629 , _2, i.port, v) │ │ │ -00065890: 293b 0a09 0909 7d0a 0909 7d0a 0a23 6966 );....}...}..#if │ │ │ -000658a0: 2054 4f52 5245 4e54 5f55 5345 5f49 3250 TORRENT_USE_I2P │ │ │ -000658b0: 0a09 0969 6620 2872 2e69 3270 636f 6e6e ...if (r.i2pconn │ │ │ -000658c0: 290a 0909 7b0a 0909 0966 6f72 2028 6175 )...{....for (au │ │ │ -000658d0: 746f 2063 6f6e 7374 2661 6d70 3b20 6920 to const& i │ │ │ -000658e0: 3a20 7265 7370 2e69 3270 5f70 6565 7273 : resp.i2p_peers │ │ │ -000658f0: 290a 0909 097b 0a09 0909 0961 6464 5f69 )....{.....add_i │ │ │ -00065900: 3270 5f70 6565 7228 692e 6465 7374 696e 2p_peer(i.destin │ │ │ -00065910: 6174 696f 6e2c 2070 6565 725f 696e 666f ation, peer_info │ │ │ -00065920: 3a3a 7472 6163 6b65 7229 3b0a 0909 097d ::tracker);....} │ │ │ -00065930: 0a09 097d 0a23 656e 6469 660a 0a09 092f ...}.#endif..../ │ │ │ -00065940: 2f20 7468 6572 6520 6172 6520 3220 7265 / there are 2 re │ │ │ -00065950: 6173 6f6e 7320 746f 2061 6c6c 6f77 206c asons to allow l │ │ │ -00065960: 6f63 616c 2049 5073 2074 6f20 6265 2072 ocal IPs to be r │ │ │ -00065970: 6574 7572 6e65 6420 6672 6f6d 2061 0a09 eturned from a.. │ │ │ -00065980: 092f 2f20 6e6f 6e2d 6c6f 6361 6c20 7472 .// non-local tr │ │ │ -00065990: 6163 6b65 720a 0909 2f2f 2031 2e20 7265 acker...// 1. re │ │ │ -000659a0: 7472 6163 6b65 7273 2061 7265 2070 6f70 trackers are pop │ │ │ -000659b0: 756c 6172 2069 6e20 7275 7373 6961 2c20 ular in russia, │ │ │ -000659c0: 7768 6572 6520 616e 2049 5350 2072 756e where an ISP run │ │ │ -000659d0: 7320 6120 7472 6163 6b65 7220 7769 7468 s a tracker with │ │ │ -000659e0: 696e 0a09 092f 2f20 2020 2074 6865 2041 in...// the A │ │ │ -000659f0: 5320 2862 7574 206e 6f74 206f 6e20 7468 S (but not on th │ │ │ -00065a00: 6520 6c6f 6361 6c20 6e65 7477 6f72 6b29 e local network) │ │ │ -00065a10: 2067 6976 696e 6720 6f75 7420 7065 6572 giving out peer │ │ │ -00065a20: 7320 6f6e 6c79 2066 726f 6d20 7468 650a s only from the. │ │ │ -00065a30: 0909 2f2f 2020 2020 6c6f 6361 6c20 6e65 ..// local ne │ │ │ -00065a40: 7477 6f72 6b0a 3c2f 7072 653e 3c2f 7464 twork.
    relevance │ │ │ -00065a80: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00065a90: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ -00065ac0: 6370 703a 3431 3838 3c2f 613e 3c2f 7464 cpp:4188store i2p a │ │ │ -00065ae0: 6464 7265 7373 6573 2061 7320 6120 3332 ddresses as a 32 │ │ │ -00065af0: 2062 7974 6520 7368 6132 3536 2068 6173 byte sha256 has │ │ │ -00065b00: 6820 696e 2074 6865 2069 3270 5f70 6565 h in the i2p_pee │ │ │ -00065b10: 7220 6f62 6a65 6374 2c20 7261 7468 6572 r object, rather │ │ │ -00065b20: 2074 6861 6e20 7265 736f 6c76 696e 6720 than resolving │ │ │ -00065b30: 6974 2069 6e74 6f20 7468 6520 6675 6c6c it into the full │ │ │ -00065b40: 2076 6173 6536 3420 6465 7374 696e 6174 vase64 destinat │ │ │ -00065b50: 696f 6e2e 2057 6520 7368 6f75 6c64 206b ion. We should k │ │ │ -00065b60: 6565 7020 7468 6520 6675 6c6c 2064 6573 eep the full des │ │ │ -00065b70: 7469 6e61 7469 6f6e 2061 7320 6120 6361 tination as a ca │ │ │ -00065b80: 6368 6520 696e 2074 6865 2069 3270 5f70 che in the i2p_p │ │ │ -00065b90: 6565 7220 6f62 6a65 6374 2073 7469 6c6c eer object still │ │ │ -00065ba0: 2e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 .

    s │ │ │ -00065bf0: 746f 7265 2069 3270 2061 6464 7265 7373 tore i2p address │ │ │ -00065c00: 6573 2061 7320 6120 3332 2062 7974 6520 es as a 32 byte │ │ │ -00065c10: 7368 6132 3536 2068 6173 6820 696e 2074 sha256 hash in t │ │ │ -00065c20: 6865 0a69 3270 5f70 6565 7220 6f62 6a65 he.i2p_peer obje │ │ │ -00065c30: 6374 2c20 7261 7468 6572 2074 6861 6e20 ct, rather than │ │ │ -00065c40: 7265 736f 6c76 696e 6720 6974 2069 6e74 resolving it int │ │ │ -00065c50: 6f20 7468 6520 6675 6c6c 2076 6173 6536 o the full vase6 │ │ │ -00065c60: 340a 6465 7374 696e 6174 696f 6e2e 2057 4.destination. W │ │ │ -00065c70: 6520 7368 6f75 6c64 206b 6565 7020 7468 e should keep th │ │ │ -00065c80: 6520 6675 6c6c 2064 6573 7469 6e61 7469 e full destinati │ │ │ -00065c90: 6f6e 2061 7320 6120 6361 6368 6520 696e on as a cache in │ │ │ -00065ca0: 2074 6865 0a69 3270 5f70 6565 7220 6f62 the.i2p_peer ob │ │ │ -00065cb0: 6a65 6374 2073 7469 6c6c 2e3c 2f68 323e ject still.

    │ │ │ -00065cc0: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ -00065cd0: 6e74 2e63 7070 3a34 3138 383c 2f68 343e nt.cpp:4188

    │ │ │ -00065ce0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    #ifnde
    │ │ │ -00065d20: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -00065d30: 455f 4c4f 4747 494e 470a 0909 656c 7365  E_LOGGING...else
    │ │ │ -00065d40: 0a09 097b 0a09 0909 6465 6275 675f 6c6f  ...{....debug_lo
    │ │ │ -00065d50: 6728 222a 2a2a 2066 6f75 6e64 206e 6f20  g("*** found no 
    │ │ │ -00065d60: 7472 6163 6b65 7220 656e 6470 6f69 6e74  tracker endpoint
    │ │ │ -00065d70: 7320 746f 2061 6e6e 6f75 6e63 6522 293b  s to announce");
    │ │ │ -00065d80: 0a09 097d 0a23 656e 6469 660a 097d 0a0a  ...}.#endif..}..
    │ │ │ -00065d90: 2369 6620 544f 5252 454e 545f 4142 495f  #if TORRENT_ABI_
    │ │ │ -00065da0: 5645 5253 494f 4e20 3d3d 2031 0a09 766f  VERSION == 1..vo
    │ │ │ -00065db0: 6964 2074 6f72 7265 6e74 3a3a 7365 745f  id torrent::set_
    │ │ │ -00065dc0: 7472 6163 6b65 725f 6c6f 6769 6e28 7374  tracker_login(st
    │ │ │ -00065dd0: 643a 3a73 7472 696e 6720 636f 6e73 7426  d::string const&
    │ │ │ -00065de0: 616d 703b 206e 616d 650a 0909 2c20 7374  amp; name..., st
    │ │ │ -00065df0: 643a 3a73 7472 696e 6720 636f 6e73 7426  d::string const&
    │ │ │ -00065e00: 616d 703b 2070 7729 0a09 7b0a 0909 6d5f  amp; pw)..{...m_
    │ │ │ -00065e10: 7573 6572 6e61 6d65 203d 206e 616d 653b  username = name;
    │ │ │ -00065e20: 0a09 096d 5f70 6173 7377 6f72 6420 3d20  ...m_password = 
    │ │ │ -00065e30: 7077 3b0a 097d 0a23 656e 6469 660a 0a23  pw;..}.#endif..#
    │ │ │ -00065e40: 6966 2054 4f52 5245 4e54 5f55 5345 5f49  if TORRENT_USE_I
    │ │ │ -00065e50: 3250 0a09 766f 6964 2074 6f72 7265 6e74  2P..void torrent
    │ │ │ -00065e60: 3a3a 6164 645f 6932 705f 7065 6572 2873  ::add_i2p_peer(s
    │ │ │ -00065e70: 6861 3235 365f 6861 7368 2063 6f6e 7374  ha256_hash const
    │ │ │ -00065e80: 2661 6d70 3b20 6465 7374 2c20 7065 6572  & dest, peer
    │ │ │ -00065e90: 5f73 6f75 7263 655f 666c 6167 735f 7420  _source_flags_t 
    │ │ │ -00065ea0: 636f 6e73 7420 736f 7572 6365 290a 097b  const source)..{
    │ │ │ -00065eb0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00065ee0: 0969 3270 5f63 6f6e 6e65 6374 696f 6e26 .i2p_connection& │ │ │ -00065ef0: 616d 703b 2069 3270 636f 6e6e 203d 2073 amp; i2pconn = s │ │ │ -00065f00: 6573 7369 6f6e 2829 2e69 3270 5f63 6f6e ession().i2p_con │ │ │ -00065f10: 6e28 293b 0a3c 2f64 6976 3e09 0969 6620 n();.
    ..if │ │ │ -00065f20: 2821 6932 7063 6f6e 6e2e 6973 5f6f 7065 (!i2pconn.is_ope │ │ │ -00065f30: 6e28 2929 2072 6574 7572 6e3b 0a0a 0909 n()) return;.... │ │ │ -00065f40: 7374 643a 3a73 7472 696e 6720 6465 7374 std::string dest │ │ │ -00065f50: 696e 6174 696f 6e20 3d20 6261 7365 3332 ination = base32 │ │ │ -00065f60: 656e 636f 6465 5f69 3270 2864 6573 7429 encode_i2p(dest) │ │ │ -00065f70: 3b0a 0909 6465 7374 696e 6174 696f 6e20 ;...destination │ │ │ -00065f80: 2b3d 2022 2e62 3332 2e69 3270 223b 0a0a += ".b32.i2p";.. │ │ │ -00065f90: 0909 4144 445f 4f55 5453 5441 4e44 494e ..ADD_OUTSTANDIN │ │ │ -00065fa0: 475f 4153 594e 4328 2274 6f72 7265 6e74 G_ASYNC("torrent │ │ │ -00065fb0: 3a3a 6f6e 5f69 3270 5f72 6573 6f6c 7665 ::on_i2p_resolve │ │ │ -00065fc0: 2229 3b0a 0909 6932 7063 6f6e 6e2e 6173 ");...i2pconn.as │ │ │ -00065fd0: 796e 635f 6e61 6d65 5f6c 6f6f 6b75 7028 ync_name_lookup( │ │ │ -00065fe0: 6465 7374 696e 6174 696f 6e2e 635f 7374 destination.c_st │ │ │ -00065ff0: 7228 290a 0909 092c 205b 7365 6c66 203d r()...., [self = │ │ │ -00066000: 2073 6861 7265 645f 6672 6f6d 5f74 6869 shared_from_thi │ │ │ -00066010: 7328 292c 2073 6f75 7263 655d 2028 6572 s(), source] (er │ │ │ -00066020: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ -00066030: 6d70 3b20 6563 2c20 6368 6172 2063 6f6e mp; ec, char con │ │ │ -00066040: 7374 2a20 6429 0a09 0909 7b20 7365 6c66 st* d)....{ self │ │ │ -00066050: 2d26 6774 3b74 6f72 7265 6e74 3a3a 6f6e ->torrent::on │ │ │ -00066060: 5f69 3270 5f72 6573 6f6c 7665 2865 632c _i2p_resolve(ec, │ │ │ -00066070: 2064 2c20 736f 7572 6365 293b 207d 293b d, source); }); │ │ │ -00066080: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265 ..}...void torre │ │ │ -00066090: 6e74 3a3a 6f6e 5f69 3270 5f72 6573 6f6c nt::on_i2p_resol │ │ │ -000660a0: 7665 2865 7272 6f72 5f63 6f64 6520 636f ve(error_code co │ │ │ -000660b0: 6e73 7426 616d 703b 2065 632c 2063 6861 nst& ec, cha │ │ │ -000660c0: 7220 636f 6e73 742a 2064 6573 742c 2070 r const* dest, p │ │ │ -000660d0: 6565 725f 736f 7572 6365 5f66 6c61 6773 eer_source_flags │ │ │ -000660e0: 5f74 2063 6f6e 7374 2073 6f75 7263 6529 _t const source) │ │ │ -000660f0: 2074 7279 0a09 7b0a 0909 544f 5252 454e try..{...TORREN │ │ │ -00066100: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ -00066110: 6c65 5f74 6872 6561 6428 2929 3b0a 0a09 le_thread());... │ │ │ -00066120: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ -00066130: 3b0a 0a09 0943 4f4d 504c 4554 455f 4153 ;....COMPLETE_AS │ │ │ -00066140: 594e 4328 2274 6f72 7265 6e74 3a3a 6f6e YNC("torrent::on │ │ │ -00066150: 5f69 3270 5f72 6573 6f6c 7665 2229 3b0a _i2p_resolve");. │ │ │ -00066160: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -00066170: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ -00066180: 0909 6966 2028 6563 2026 616d 703b 2661 ..if (ec &&a │ │ │ -00066190: 6d70 3b20 7368 6f75 6c64 5f6c 6f67 2829 mp; should_log() │ │ │ -000661a0: 290a 0909 0964 6562 7567 5f6c 6f67 2822 )....debug_log(" │ │ │ -000661b0: 6932 705f 7265 736f 6c76 6520 6572 726f i2p_resolve erro │ │ │ -000661c0: 723a 2025 7322 2c20 6563 2e6d 6573 7361 r: %s", ec.messa │ │ │ -000661d0: 6765 2829 2e63 5f73 7472 2829 293b 0a23 ge().c_str());.# │ │ │ -000661e0: 656e 6469 660a 0909 6966 2028 6563 207c endif...if (ec | │ │ │ -000661f0: 7c20 6d5f 6162 6f72 7420 7c7c 206d 5f73 | m_abort || m_s │ │ │ -00066200: 6573 2e69 735f 6162 6f72 7465 6428 2929 es.is_aborted()) │ │ │ -00066210: 2072 6574 7572 6e3b 0a0a 0909 6e65 6564 return;....need │ │ │ -00066220: 5f70 6565 725f 6c69 7374 2829 3b0a 0909 _peer_list();... │ │ │ -00066230: 746f 7272 656e 745f 7374 6174 6520 7374 torrent_state st │ │ │ -00066240: 203d 2067 6574 5f70 6565 725f 6c69 7374 = get_peer_list │ │ │ -00066250: 5f73 7461 7465 2829 3b0a 0909 6966 2028 _state();...if ( │ │ │ -00066260: 6d5f 7065 6572 5f6c 6973 742d 2667 743b m_peer_list-> │ │ │ -00066270: 6164 645f 6932 705f 7065 6572 2864 6573 add_i2p_peer(des │ │ │ -00066280: 742c 2073 6f75 7263 652c 207b 7d2c 2026 t, source, {}, & │ │ │ -00066290: 616d 703b 7374 2929 0a09 0909 7374 6174 amp;st))....stat │ │ │ -000662a0: 655f 7570 6461 7465 6428 293b 0a09 0970 e_updated();...p │ │ │ -000662b0: 6565 7273 5f65 7261 7365 6428 7374 2e65 eers_erased(st.e │ │ │ -000662c0: 7261 7365 6429 3b0a 0a3c 2f70 7265 3e3c rased);..
    < │ │ │ -000662d0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00066300: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00066310: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -00066340: 6e74 2e63 7070 3a34 3234 353c 2f61 3e3c nt.cpp:4245< │ │ │ -00066350: 2f74 643e 3c74 643e 6164 6420 6f6e 6520 /td>add one │ │ │ -00066360: 7065 6572 2070 6572 2049 5020 7468 6520 peer per IP the │ │ │ -00066370: 686f 7374 6e61 6d65 2072 6573 6f6c 7665 hostname resolve │ │ │ -00066380: 7320 746f 3c2f 7464 3e3c 2f74 723e 3c74 s toadd one peer p │ │ │ -000663e0: 6572 2049 5020 7468 6520 686f 7374 6e61 er IP the hostna │ │ │ -000663f0: 6d65 2072 6573 6f6c 7665 7320 746f 3c2f me resolves to

    ../src/to │ │ │ -00066410: 7272 656e 742e 6370 703a 3432 3435 3c2f rrent.cpp:4245
    .ca
    │ │ │ -00066460: 7463 6820 282e 2e2e 2920 7b20 6861 6e64  tch (...) { hand
    │ │ │ -00066470: 6c65 5f65 7863 6570 7469 6f6e 2829 3b20  le_exception(); 
    │ │ │ -00066480: 7d0a 2365 6e64 6966 0a0a 0976 6f69 6420  }.#endif...void 
    │ │ │ -00066490: 746f 7272 656e 743a 3a6f 6e5f 7065 6572  torrent::on_peer
    │ │ │ -000664a0: 5f6e 616d 655f 6c6f 6f6b 7570 2865 7272  _name_lookup(err
    │ │ │ -000664b0: 6f72 5f63 6f64 6520 636f 6e73 7426 616d  or_code const&am
    │ │ │ -000664c0: 703b 2065 0a09 092c 2073 7464 3a3a 7665  p; e..., std::ve
    │ │ │ -000664d0: 6374 6f72 266c 743b 6164 6472 6573 7326  ctor<address&
    │ │ │ -000664e0: 6774 3b20 636f 6e73 7426 616d 703b 2068  gt; const& h
    │ │ │ -000664f0: 6f73 745f 6c69 7374 2c20 696e 7420 636f  ost_list, int co
    │ │ │ -00066500: 6e73 7420 706f 7274 0a09 092c 2070 726f  nst port..., pro
    │ │ │ -00066510: 746f 636f 6c5f 7665 7273 696f 6e20 636f  tocol_version co
    │ │ │ -00066520: 6e73 7420 7629 2074 7279 0a09 7b0a 0909  nst v) try..{...
    │ │ │ -00066530: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ -00066540: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ -00066550: 2929 3b0a 0a09 0949 4e56 4152 4941 4e54  ));....INVARIANT
    │ │ │ -00066560: 5f43 4845 434b 3b0a 0a09 0943 4f4d 504c  _CHECK;....COMPL
    │ │ │ -00066570: 4554 455f 4153 594e 4328 2274 6f72 7265  ETE_ASYNC("torre
    │ │ │ -00066580: 6e74 3a3a 6f6e 5f70 6565 725f 6e61 6d65  nt::on_peer_name
    │ │ │ -00066590: 5f6c 6f6f 6b75 7022 293b 0a0a 2369 666e  _lookup");..#ifn
    │ │ │ -000665a0: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -000665b0: 424c 455f 4c4f 4747 494e 470a 0909 6966  BLE_LOGGING...if
    │ │ │ -000665c0: 2028 6520 2661 6d70 3b26 616d 703b 2073   (e && s
    │ │ │ -000665d0: 686f 756c 645f 6c6f 6728 2929 0a09 0909  hould_log())....
    │ │ │ -000665e0: 6465 6275 675f 6c6f 6728 2270 6565 7220  debug_log("peer 
    │ │ │ -000665f0: 6e61 6d65 206c 6f6f 6b75 7020 6572 726f  name lookup erro
    │ │ │ -00066600: 723a 2025 7322 2c20 652e 6d65 7373 6167  r: %s", e.messag
    │ │ │ -00066610: 6528 292e 635f 7374 7228 2929 3b0a 2365  e().c_str());.#e
    │ │ │ -00066620: 6e64 6966 0a0a 0909 6966 2028 6520 7c7c  ndif....if (e ||
    │ │ │ -00066630: 206d 5f61 626f 7274 207c 7c20 686f 7374   m_abort || host
    │ │ │ -00066640: 5f6c 6973 742e 656d 7074 7928 2920 7c7c  _list.empty() ||
    │ │ │ -00066650: 206d 5f73 6573 2e69 735f 6162 6f72 7465   m_ses.is_aborte
    │ │ │ -00066660: 6428 2929 2072 6574 7572 6e3b 0a0a 3c64  d()) return;....tc
    │ │ │ -000666a0: 703a 3a65 6e64 706f 696e 7420 686f 7374  p::endpoint host
    │ │ │ -000666b0: 2868 6f73 745f 6c69 7374 2e66 726f 6e74  (host_list.front
    │ │ │ -000666c0: 2829 2c20 7374 643a 3a75 696e 7431 365f  (), std::uint16_
    │ │ │ -000666d0: 7428 706f 7274 2929 3b0a 3c2f 6469 763e  t(port));.

    │ │ │ -000666e0: 0a09 0969 6620 286d 5f69 705f 6669 6c74 ...if (m_ip_filt │ │ │ -000666f0: 6572 2026 616d 703b 2661 6d70 3b20 6d5f er && m_ │ │ │ -00066700: 6970 5f66 696c 7465 722d 2667 743b 6163 ip_filter->ac │ │ │ -00066710: 6365 7373 2868 6f73 742e 6164 6472 6573 cess(host.addres │ │ │ -00066720: 7328 2929 2026 616d 703b 2069 705f 6669 s()) & ip_fi │ │ │ -00066730: 6c74 6572 3a3a 626c 6f63 6b65 6429 0a09 lter::blocked).. │ │ │ -00066740: 097b 0a23 6966 6e64 6566 2054 4f52 5245 .{.#ifndef TORRE │ │ │ -00066750: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ -00066760: 4e47 0a09 0909 6966 2028 7368 6f75 6c64 NG....if (should │ │ │ -00066770: 5f6c 6f67 2829 290a 0909 097b 0a09 0909 _log())....{.... │ │ │ -00066780: 0964 6562 7567 5f6c 6f67 2822 626c 6f63 .debug_log("bloc │ │ │ -00066790: 6b65 6420 6970 2066 726f 6d20 7472 6163 ked ip from trac │ │ │ -000667a0: 6b65 723a 2025 7322 2c20 686f 7374 2e61 ker: %s", host.a │ │ │ -000667b0: 6464 7265 7373 2829 2e74 6f5f 7374 7269 ddress().to_stri │ │ │ -000667c0: 6e67 2829 2e63 5f73 7472 2829 293b 0a09 ng().c_str());.. │ │ │ -000667d0: 0909 7d0a 2365 6e64 6966 0a09 0909 6966 ..}.#endif....if │ │ │ -000667e0: 2028 6d5f 7365 732e 616c 6572 7473 2829 (m_ses.alerts() │ │ │ -000667f0: 2e73 686f 756c 645f 706f 7374 266c 743b .should_post< │ │ │ -00066800: 7065 6572 5f62 6c6f 636b 6564 5f61 6c65 peer_blocked_ale │ │ │ -00066810: 7274 2667 743b 2829 290a 0909 0909 6d5f rt>()).....m_ │ │ │ -00066820: 7365 732e 616c 6572 7473 2829 2e65 6d70 ses.alerts().emp │ │ │ -00066830: 6c61 6365 5f61 6c65 7274 266c 743b 7065 lace_alert<pe │ │ │ -00066840: 6572 5f62 6c6f 636b 6564 5f61 6c65 7274 er_blocked_alert │ │ │ -00066850: 2667 743b 2867 6574 5f68 616e 646c 6528 >(get_handle( │ │ │ -00066860: 290a 0909 0909 092c 2068 6f73 742c 2070 )......, host, p │ │ │ -00066870: 6565 725f 626c 6f63 6b65 645f 616c 6572 eer_blocked_aler │ │ │ -00066880: 743a 3a69 705f 6669 6c74 6572 293b 0a09 t::ip_filter);.. │ │ │ -00066890: 0909 7265 7475 726e 3b0a 0909 7d0a 0a09 ..return;...}... │ │ │ -000668a0: 0969 6620 2861 6464 5f70 6565 7228 686f .if (add_peer(ho │ │ │ -000668b0: 7374 2c20 7065 6572 5f69 6e66 6f3a 3a74 st, peer_info::t │ │ │ -000668c0: 7261 636b 6572 2c20 7620 3d3d 2070 726f racker, v == pro │ │ │ -000668d0: 746f 636f 6c5f 7665 7273 696f 6e3a 3a56 tocol_version::V │ │ │ -000668e0: 3220 3f20 7065 785f 6c74 5f76 3220 3a20 2 ? pex_lt_v2 : │ │ │ -000668f0: 7065 785f 666c 6167 735f 7428 3029 2929 pex_flags_t(0))) │ │ │ -00066900: 0a09 097b 0a09 0909 7374 6174 655f 7570 ...{....state_up │ │ │ -00066910: 6461 7465 6428 293b 0a0a 2369 666e 6465 dated();..#ifnde │ │ │ -00066920: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -00066930: 455f 4c4f 4747 494e 470a 0909 0969 6620 E_LOGGING....if │ │ │ -00066940: 2873 686f 756c 645f 6c6f 6728 2929 0a09 (should_log()).. │ │ │ -00066950: 0909 7b0a 0909 0909 6465 6275 675f 6c6f ..{.....debug_lo │ │ │ -00066960: 6728 226e 616d 652d 6c6f 6f6b 7570 2061 g("name-lookup a │ │ │ -00066970: 6464 5f70 6565 7228 2920 5b20 2573 205d dd_peer() [ %s ] │ │ │ -00066980: 2063 6f6e 6e65 6374 2d63 616e 6469 6461 connect-candida │ │ │ -00066990: 7465 733a 2025 6422 0a09 0909 0909 2c20 tes: %d"......, │ │ │ -000669a0: 686f 7374 2e61 6464 7265 7373 2829 2e74 host.address().t │ │ │ -000669b0: 6f5f 7374 7269 6e67 2829 2e63 5f73 7472 o_string().c_str │ │ │ -000669c0: 2829 0a09 0909 0909 2c20 6d5f 7065 6572 ()......, m_peer │ │ │ -000669d0: 5f6c 6973 7420 3f20 6d5f 7065 6572 5f6c _list ? m_peer_l │ │ │ -000669e0: 6973 742d 2667 743b 6e75 6d5f 636f 6e6e ist->num_conn │ │ │ -000669f0: 6563 745f 6361 6e64 6964 6174 6573 2829 ect_candidates() │ │ │ -00066a00: 203a 202d 3129 3b0a 0909 097d 0a23 656e : -1);....}.#en │ │ │ -00066a10: 6469 660a 0909 7d0a 0909 7570 6461 7465 dif...}...update │ │ │ -00066a20: 5f77 616e 745f 7065 6572 7328 293b 0a09 _want_peers();.. │ │ │ -00066a30: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -00066a60: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00066a70: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00066aa0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00066ab0: 3439 3633 3c2f 613e 3c2f 7464 3e3c 7464 4963only do this if │ │ │ -00066ad0: 2074 6865 2070 6965 6365 2073 697a 6520 the piece size │ │ │ -00066ae0: 3e20 3120 626c 6f63 6b73 2054 6869 7320 > 1 blocks This │ │ │ -00066af0: 6973 2061 2076 3220 746f 7272 656e 7420 is a v2 torrent │ │ │ -00066b00: 736f 2077 6520 6361 6e20 7265 7175 6573 so we can reques │ │ │ -00066b10: 7420 6765 7420 626c 6f63 6b20 6c65 7665 t get block leve │ │ │ -00066b20: 6c20 6861 7368 6573 2e3c 2f74 643e 3c2f l hashes.

    only do t │ │ │ -00066b80: 6869 7320 6966 2074 6865 2070 6965 6365 his if the piece │ │ │ -00066b90: 2073 697a 6520 3e20 3120 626c 6f63 6b73 size > 1 blocks │ │ │ -00066ba0: 0a54 6869 7320 6973 2061 2076 3220 746f .This is a v2 to │ │ │ -00066bb0: 7272 656e 7420 736f 2077 6520 6361 6e20 rrent so we can │ │ │ -00066bc0: 7265 7175 6573 7420 6765 7420 626c 6f63 request get bloc │ │ │ -00066bd0: 6b0a 6c65 7665 6c20 6861 7368 6573 2e3c k.level hashes.< │ │ │ -00066be0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ -00066bf0: 6f72 7265 6e74 2e63 7070 3a34 3936 333c orrent.cpp:4963< │ │ │ -00066c00: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00066c40: 7b0a 0909 0973 7464 3a3a 7365 7426 6c74  {....std::set<
    │ │ │ -00066c50: 3b74 6f72 7265 6e74 5f70 6565 722a 2667  ;torrent_peer*&g
    │ │ │ -00066c60: 743b 2072 6574 3b0a 0909 0969 6620 2821  t; ret;....if (!
    │ │ │ -00066c70: 626c 6f63 6b73 2e65 6d70 7479 2829 2026  blocks.empty() &
    │ │ │ -00066c80: 616d 703b 2661 6d70 3b20 2164 6f77 6e6c  amp;& !downl
    │ │ │ -00066c90: 6f61 6465 7273 2e65 6d70 7479 2829 290a  oaders.empty()).
    │ │ │ -00066ca0: 0909 097b 0a09 0909 0966 6f72 2028 6175  ...{.....for (au
    │ │ │ -00066cb0: 746f 2063 6f6e 7374 2062 203a 2062 6c6f  to const b : blo
    │ │ │ -00066cc0: 636b 7329 2072 6574 2e69 6e73 6572 7428  cks) ret.insert(
    │ │ │ -00066cd0: 646f 776e 6c6f 6164 6572 735b 7374 643a  downloaders[std:
    │ │ │ -00066ce0: 3a73 697a 655f 7428 6229 5d29 3b0a 0909  :size_t(b)]);...
    │ │ │ -00066cf0: 097d 0a09 0909 656c 7365 0a09 0909 7b0a  .}....else....{.
    │ │ │ -00066d00: 0909 0909 7374 643a 3a63 6f70 7928 646f  ....std::copy(do
    │ │ │ -00066d10: 776e 6c6f 6164 6572 732e 6265 6769 6e28  wnloaders.begin(
    │ │ │ -00066d20: 292c 2064 6f77 6e6c 6f61 6465 7273 2e65  ), downloaders.e
    │ │ │ -00066d30: 6e64 2829 2c20 7374 643a 3a69 6e73 6572  nd(), std::inser
    │ │ │ -00066d40: 7465 7228 7265 742c 2072 6574 2e62 6567  ter(ret, ret.beg
    │ │ │ -00066d50: 696e 2829 2929 3b0a 0909 097d 0a09 0909  in()));....}....
    │ │ │ -00066d60: 7265 7475 726e 2072 6574 3b0a 0909 7d28  return ret;...}(
    │ │ │ -00066d70: 293b 0a0a 0909 2f2f 2069 6620 7468 6973  );....// if this
    │ │ │ -00066d80: 2070 6965 6365 2077 6173 6e27 7420 646f   piece wasn't do
    │ │ │ -00066d90: 776e 6c6f 6164 6564 2066 726f 6d20 7065  wnloaded from pe
    │ │ │ -00066da0: 6572 732c 2077 6520 6a75 7374 2066 6f75  ers, we just fou
    │ │ │ -00066db0: 6e64 2069 7420 6f6e 2064 6973 6b2e 0a09  nd it on disk...
    │ │ │ -00066dc0: 092f 2f20 496e 2074 6861 7420 6361 7365  .// In that case
    │ │ │ -00066dd0: 2c20 7765 2073 686f 756c 6420 6a75 7374  , we should just
    │ │ │ -00066de0: 2063 6f6e 7369 6465 7220 6974 2061 7320   consider it as 
    │ │ │ -00066df0: 226e 6f74 2d68 6176 6522 2061 6e64 2074  "not-have" and t
    │ │ │ -00066e00: 6865 7265 2773 206e 6f0a 0909 2f2f 206e  here's no...// n
    │ │ │ -00066e10: 6565 6420 746f 2074 7279 2074 6f20 6765  eed to try to ge
    │ │ │ -00066e20: 7420 6869 6768 6572 2066 6964 656c 6974  t higher fidelit
    │ │ │ -00066e30: 7920 6861 7368 6573 2028 7965 7429 0a09  y hashes (yet)..
    │ │ │ -00066e40: 0962 6f6f 6c20 636f 6e73 7420 666f 756e  .bool const foun
    │ │ │ -00066e50: 645f 6f6e 5f64 6973 6b20 3d20 7065 6572  d_on_disk = peer
    │ │ │ -00066e60: 732e 7369 7a65 2829 203d 3d20 3120 2661  s.size() == 1 &a
    │ │ │ -00066e70: 6d70 3b26 616d 703b 2070 6565 7273 2e63  mp;& peers.c
    │ │ │ -00066e80: 6f75 6e74 286e 756c 6c70 7472 293b 0a0a  ount(nullptr);..
    │ │ │ -00066e90: 0909 6966 2028 746f 7272 656e 745f 6669  ..if (torrent_fi
    │ │ │ -00066ea0: 6c65 2829 2e69 6e66 6f5f 6861 7368 6573  le().info_hashes
    │ │ │ -00066eb0: 2829 2e68 6173 5f76 3228 2920 2661 6d70  ().has_v2() &
    │ │ │ -00066ec0: 3b26 616d 703b 2062 6c6f 636b 732e 656d  ;& blocks.em
    │ │ │ -00066ed0: 7074 7928 2920 2661 6d70 3b26 616d 703b  pty() &&
    │ │ │ -00066ee0: 2021 666f 756e 645f 6f6e 5f64 6973 6b29   !found_on_disk)
    │ │ │ -00066ef0: 0a09 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    ...verify_blo │ │ │ -00066f30: 636b 5f68 6173 6865 7328 696e 6465 7829 ck_hashes(index) │ │ │ -00066f40: 3b0a 3c2f 6469 763e 0909 7d0a 0a09 092f ;.
    ..}..../ │ │ │ -00066f50: 2f20 7468 6520 6265 6c6f 7720 636f 6465 / the below code │ │ │ -00066f60: 2069 7320 7065 6e61 6c69 7a69 6e67 2070 is penalizing p │ │ │ -00066f70: 6565 7273 2074 6861 7420 7365 6e74 2075 eers that sent u │ │ │ -00066f80: 7365 2062 6164 2064 6174 612e 0a09 092f se bad data..../ │ │ │ -00066f90: 2f20 696e 6372 6561 7365 2074 6865 2074 / increase the t │ │ │ -00066fa0: 6f74 616c 2061 6d6f 756e 7420 6f66 2066 otal amount of f │ │ │ -00066fb0: 6169 6c65 6420 6279 7465 730a 0909 6966 ailed bytes...if │ │ │ -00066fc0: 2028 2166 6f75 6e64 5f6f 6e5f 6469 736b (!found_on_disk │ │ │ -00066fd0: 290a 0909 7b0a 0909 0969 6620 2862 6c6f )...{....if (blo │ │ │ -00066fe0: 636b 732e 656d 7074 7928 2929 0a09 0909 cks.empty()).... │ │ │ -00066ff0: 0961 6464 5f66 6169 6c65 645f 6279 7465 .add_failed_byte │ │ │ -00067000: 7328 6d5f 746f 7272 656e 745f 6669 6c65 s(m_torrent_file │ │ │ -00067010: 2d26 6774 3b70 6965 6365 5f73 697a 6528 ->piece_size( │ │ │ -00067020: 696e 6465 7829 293b 0a09 0909 656c 7365 index));....else │ │ │ -00067030: 0a09 0909 0961 6464 5f66 6169 6c65 645f .....add_failed_ │ │ │ -00067040: 6279 7465 7328 7374 6174 6963 5f63 6173 bytes(static_cas │ │ │ -00067050: 7426 6c74 3b69 6e74 2667 743b 2862 6c6f t<int>(blo │ │ │ -00067060: 636b 732e 7369 7a65 2829 2920 2a20 6465 cks.size()) * de │ │ │ -00067070: 6661 756c 745f 626c 6f63 6b5f 7369 7a65 fault_block_size │ │ │ -00067080: 293b 0a0a 2369 666e 6465 6620 544f 5252 );..#ifndef TORR │ │ │ -00067090: 454e 545f 4449 5341 424c 455f 4558 5445 ENT_DISABLE_EXTE │ │ │ -000670a0: 4e53 494f 4e53 0a09 0909 666f 7220 2861 NSIONS....for (a │ │ │ -000670b0: 7574 6f26 616d 703b 2065 7874 203a 206d uto& ext : m │ │ │ -000670c0: 5f65 7874 656e 7369 6f6e 7329 0a09 0909 _extensions).... │ │ │ -000670d0: 7b0a 0909 0909 6578 742d 2667 743b 6f6e {.....ext->on │ │ │ -000670e0: 5f70 6965 6365 5f66 6169 6c65 6428 696e _piece_failed(in │ │ │ -000670f0: 6465 7829 3b0a 0909 097d 0a23 656e 6469 dex);....}.#endi │ │ │ -00067100: 660a 0a09 0909 2f2f 2064 6964 2077 6520 f.....// did we │ │ │ -00067110: 7265 6365 6976 6520 7468 6973 2070 6965 receive this pie │ │ │ -00067120: 6365 2066 726f 6d20 6120 7369 6e67 6c65 ce from a single │ │ │ -00067130: 2070 6565 723f 0a09 0909 2f2f 2069 6620 peer?....// if │ │ │ -00067140: 7765 206b 6e6f 7720 6578 6163 746c 7920 we know exactly │ │ │ -00067150: 7768 6963 6820 626c 6f63 6b73 2066 6169 which blocks fai │ │ │ -00067160: 6c65 6420 7468 6520 6861 7368 2c20 7765 led the hash, we │ │ │ -00067170: 2063 616e 2061 6c73 6f20 6265 2063 6572 can also be cer │ │ │ -00067180: 7461 696e 0a09 0909 2f2f 2074 6861 7420 tain....// that │ │ │ -00067190: 616c 6c20 7065 6572 7320 696e 2074 6865 all peers in the │ │ │ -000671a0: 206c 6973 7420 7365 6e74 2075 7320 6261 list sent us ba │ │ │ -000671b0: 6420 6461 7461 0a09 0909 626f 6f6c 2063 d data....bool c │ │ │ -000671c0: 6f6e 7374 206b 6e6f 776e 5f62 6164 5f70 onst known_bad_p │ │ │ -000671d0: 6565 7220 3d20 7065 6572 732e 7369 7a65 eer = peers.size │ │ │ -000671e0: 2829 203d 3d20 3120 7c7c 2021 626c 6f63 () == 1 || !bloc │ │ │ -000671f0: 6b73 2e65 6d70 7479 2829 3b0a 0a09 0909 ks.empty();..... │ │ │ -00067200: 7065 6e61 6c69 7a65 5f70 6565 7273 2870 penalize_peers(p │ │ │ -00067210: 6565 7273 2c20 696e 6465 782c 206b 6e6f eers, index, kno │ │ │ -00067220: 776e 5f62 6164 5f70 6565 7229 3b0a 0909 wn_bad_peer);... │ │ │ -00067230: 7d0a 0a09 092f 2f20 4966 206d 5f73 746f }....// If m_sto │ │ │ -00067240: 7261 6765 2069 736e 2774 2073 6574 2068 rage isn't set h │ │ │ -00067250: 6572 652c 2069 7420 6d65 616e 7320 7765 ere, it means we │ │ │ -00067260: 2772 6520 7368 7574 7469 6e67 2064 6f77 're shutting dow │ │ │ -00067270: 6e0a 0909 6966 2028 6d5f 7374 6f72 6167 n...if (m_storag │ │ │ -00067280: 6529 0a09 097b 0a09 0909 2f2f 2069 7420 e)...{....// it │ │ │ -00067290: 646f 6573 6e27 7420 6d61 6b65 206d 7563 doesn't make muc │ │ │ -000672a0: 6820 7365 6e73 6520 746f 2066 6169 6c20 h sense to fail │ │ │ -000672b0: 746f 2068 6173 6820 6120 7069 6563 650a to hash a piece. │ │ │ -000672c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000672d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00067300: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00067330: 632f 746f 7272 656e 742e 6370 703a 3739 c/torrent.cpp:79 │ │ │ -00067340: 3335 3c2f 613e 3c2f 7464 3e3c 7464 3e63 35c │ │ │ -00067350: 6f6d 6520 7570 2077 6974 6820 6120 6265 ome up with a be │ │ │ -00067360: 7474 6572 2077 6179 206f 6620 646f 696e tter way of doin │ │ │ -00067370: 6720 7468 6973 2c20 696e 7374 6561 6420 g this, instead │ │ │ -00067380: 6f66 2061 6e20 696d 6d65 6469 6174 656c of an immediatel │ │ │ -00067390: 7920 696e 766f 6b65 6420 6c61 6d62 6461 y invoked lambda │ │ │ -000673a0: 2065 7870 7265 7373 696f 6e2e 3c2f 7464 expression.

    come u │ │ │ -00067400: 7020 7769 7468 2061 2062 6574 7465 7220 p with a better │ │ │ -00067410: 7761 7920 6f66 2064 6f69 6e67 2074 6869 way of doing thi │ │ │ -00067420: 732c 2069 6e73 7465 6164 206f 6620 616e s, instead of an │ │ │ -00067430: 0a69 6d6d 6564 6961 7465 6c79 2069 6e76 .immediately inv │ │ │ -00067440: 6f6b 6564 206c 616d 6264 6120 6578 7072 oked lambda expr │ │ │ -00067450: 6573 7369 6f6e 2e3c 2f68 323e 3c68 343e ession.

    │ │ │ -00067460: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ -00067470: 7070 3a37 3933 353c 2f68 343e 3c70 7265 pp:7935

    .....|| pe
    │ │ │ -000674c0: 6572 696e 666f 2d26 6774 3b63 6f6e 6669  erinfo->confi
    │ │ │ -000674d0: 726d 6564 5f73 7570 706f 7274 735f 7574  rmed_supports_ut
    │ │ │ -000674e0: 7029 290a 0909 097b 0a09 0909 0973 6d20  p))....{.....sm 
    │ │ │ -000674f0: 3d20 6d5f 7365 732e 7574 705f 736f 636b  = m_ses.utp_sock
    │ │ │ -00067500: 6574 5f6d 616e 6167 6572 2829 3b0a 0909  et_manager();...
    │ │ │ -00067510: 097d 0a0a 0909 092f 2f20 646f 6e27 7420  .}.....// don't 
    │ │ │ -00067520: 6d61 6b65 2061 2054 4350 2063 6f6e 6e65  make a TCP conne
    │ │ │ -00067530: 6374 696f 6e20 6966 2069 7427 7320 6469  ction if it's di
    │ │ │ -00067540: 7361 626c 6564 0a09 0909 6966 2028 736d  sabled....if (sm
    │ │ │ -00067550: 203d 3d20 6e75 6c6c 7074 7220 2661 6d70   == nullptr &
    │ │ │ -00067560: 3b26 616d 703b 2021 7365 7474 696e 6773  ;& !settings
    │ │ │ -00067570: 2829 2e67 6574 5f62 6f6f 6c28 7365 7474  ().get_bool(sett
    │ │ │ -00067580: 696e 6773 5f70 6163 6b3a 3a65 6e61 626c  ings_pack::enabl
    │ │ │ -00067590: 655f 6f75 7467 6f69 6e67 5f74 6370 2929  e_outgoing_tcp))
    │ │ │ -000675a0: 0a09 0909 7b0a 2369 666e 6465 6620 544f  ....{.#ifndef TO
    │ │ │ -000675b0: 5252 454e 545f 4449 5341 424c 455f 4c4f  RRENT_DISABLE_LO
    │ │ │ -000675c0: 4747 494e 470a 0909 0909 6966 2028 7368  GGING.....if (sh
    │ │ │ -000675d0: 6f75 6c64 5f6c 6f67 2829 290a 0909 0909  ould_log()).....
    │ │ │ -000675e0: 7b0a 0909 0909 0964 6562 7567 5f6c 6f67  {......debug_log
    │ │ │ -000675f0: 2822 6469 7363 6172 6469 6e67 2070 6565  ("discarding pee
    │ │ │ -00067600: 7220 5c22 2573 5c22 3a20 5443 5020 636f  r \"%s\": TCP co
    │ │ │ -00067610: 6e6e 6563 7469 6f6e 7320 6469 7361 626c  nnections disabl
    │ │ │ -00067620: 6564 2022 0a09 0909 0909 0922 5b20 7375  ed "......."[ su
    │ │ │ -00067630: 7070 6f72 7473 2d75 7470 3a20 2564 205d  pports-utp: %d ]
    │ │ │ -00067640: 222c 2070 6565 7269 6e66 6f2d 2667 743b  ", peerinfo->
    │ │ │ -00067650: 746f 5f73 7472 696e 6728 292e 635f 7374  to_string().c_st
    │ │ │ -00067660: 7228 290a 0909 0909 0909 2c20 7065 6572  r()......., peer
    │ │ │ -00067670: 696e 666f 2d26 6774 3b73 7570 706f 7274  info->support
    │ │ │ -00067680: 735f 7574 7029 3b0a 0909 0909 7d0a 2365  s_utp);.....}.#e
    │ │ │ -00067690: 6e64 6966 0a09 0909 0972 6574 7572 6e20  ndif.....return 
    │ │ │ -000676a0: 6661 6c73 653b 0a09 0909 7d0a 0909 7d0a  false;....}...}.
    │ │ │ -000676b0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000676e0: 0961 7578 3a3a 736f 636b 6574 5f74 7970 .aux::socket_typ │ │ │ -000676f0: 6520 7320 3d20 5b26 616d 703b 5d20 7b0a e s = [&] {. │ │ │ -00067700: 3c2f 6469 763e 0a23 6966 2054 4f52 5245
    .#if TORRE │ │ │ -00067710: 4e54 5f55 5345 5f49 3250 0a09 0969 6620 NT_USE_I2P...if │ │ │ -00067720: 2870 6565 7269 6e66 6f2d 2667 743b 6973 (peerinfo->is │ │ │ -00067730: 5f69 3270 5f61 6464 7229 0a09 097b 0a09 _i2p_addr)...{.. │ │ │ -00067740: 0909 2f2f 2049 7427 7320 6e6f 7420 656e ..// It's not en │ │ │ -00067750: 7469 7265 6c79 206f 6276 696f 7573 2077 tirely obvious w │ │ │ -00067760: 6879 2074 6869 7320 7065 6572 2063 6f6e hy this peer con │ │ │ -00067770: 6e65 6374 696f 6e20 6973 206e 6f74 206d nection is not m │ │ │ -00067780: 6172 6b65 6420 6173 0a09 0909 2f2f 206f arked as....// o │ │ │ -00067790: 6e65 2e20 5468 6520 6d61 696e 2066 6561 ne. The main fea │ │ │ -000677a0: 7475 7265 206f 6620 6120 7065 6572 2063 ture of a peer c │ │ │ -000677b0: 6f6e 6e65 6374 696f 6e20 6973 2074 6861 onnection is tha │ │ │ -000677c0: 7420 7768 6574 6865 7220 6f72 206e 6f74 t whether or not │ │ │ -000677d0: 2077 650a 0909 092f 2f20 7072 6f78 7920 we....// proxy │ │ │ -000677e0: 6974 2069 7320 636f 6e66 6967 7572 6162 it is configurab │ │ │ -000677f0: 6c65 2e20 5768 656e 2077 6520 7573 6520 le. When we use │ │ │ -00067800: 6932 702c 2077 6520 7761 6e74 2074 6f20 i2p, we want to │ │ │ -00067810: 616c 7761 7973 2070 726f 780a 0909 092f always prox..../ │ │ │ -00067820: 2f20 6576 6572 7974 6869 6e67 2076 6961 / everything via │ │ │ -00067830: 2069 3270 2e0a 0a09 0909 6175 783a 3a70 i2p......aux::p │ │ │ -00067840: 726f 7879 5f73 6574 7469 6e67 7320 7072 roxy_settings pr │ │ │ -00067850: 6f78 793b 0a09 0909 7072 6f78 792e 686f oxy;....proxy.ho │ │ │ -00067860: 7374 6e61 6d65 203d 2073 6574 7469 6e67 stname = setting │ │ │ -00067870: 7328 292e 6765 745f 7374 7228 7365 7474 s().get_str(sett │ │ │ -00067880: 696e 6773 5f70 6163 6b3a 3a69 3270 5f68 ings_pack::i2p_h │ │ │ -00067890: 6f73 746e 616d 6529 3b0a 0909 0970 726f ostname);....pro │ │ │ -000678a0: 7879 2e70 6f72 7420 3d20 7374 643a 3a75 xy.port = std::u │ │ │ -000678b0: 696e 7431 365f 7428 7365 7474 696e 6773 int16_t(settings │ │ │ -000678c0: 2829 2e67 6574 5f69 6e74 2873 6574 7469 ().get_int(setti │ │ │ -000678d0: 6e67 735f 7061 636b 3a3a 6932 705f 706f ngs_pack::i2p_po │ │ │ -000678e0: 7274 2929 3b0a 0909 0970 726f 7879 2e74 rt));....proxy.t │ │ │ -000678f0: 7970 6520 3d20 7365 7474 696e 6773 5f70 ype = settings_p │ │ │ -00067900: 6163 6b3a 3a69 3270 5f70 726f 7879 3b0a ack::i2p_proxy;. │ │ │ -00067910: 0a09 0909 6175 783a 3a73 6f63 6b65 745f ....aux::socket_ │ │ │ -00067920: 7479 7065 2072 6574 203d 2069 6e73 7461 type ret = insta │ │ │ -00067930: 6e74 6961 7465 5f63 6f6e 6e65 6374 696f ntiate_connectio │ │ │ -00067940: 6e28 6d5f 7365 732e 6765 745f 636f 6e74 n(m_ses.get_cont │ │ │ -00067950: 6578 7428 290a 0909 0909 2c20 7072 6f78 ext()....., prox │ │ │ -00067960: 792c 206e 756c 6c70 7472 2c20 6e75 6c6c y, nullptr, null │ │ │ -00067970: 7074 722c 2066 616c 7365 2c20 6661 6c73 ptr, false, fals │ │ │ -00067980: 6529 3b0a 0909 0961 7574 6f26 616d 703b e);....auto& │ │ │ -00067990: 2073 7472 203d 2073 7464 3a3a 6765 7426 str = std::get& │ │ │ -000679a0: 6c74 3b69 3270 5f73 7472 6561 6d26 6774 lt;i2p_stream> │ │ │ -000679b0: 3b28 7265 7429 3b0a 0909 0973 7472 2e73 ;(ret);....str.s │ │ │ -000679c0: 6574 5f6c 6f63 616c 5f69 3270 5f65 6e64 et_local_i2p_end │ │ │ -000679d0: 706f 696e 7428 6d5f 7365 732e 6c6f 6361 point(m_ses.loca │ │ │ -000679e0: 6c5f 6932 705f 656e 6470 6f69 6e74 2829 l_i2p_endpoint() │ │ │ -000679f0: 293b 0a09 0909 7374 722e 7365 745f 6465 );....str.set_de │ │ │ -00067a00: 7374 696e 6174 696f 6e28 7374 6174 6963 stination(static │ │ │ -00067a10: 5f63 6173 7426 6c74 3b69 3270 5f70 6565 _cast<i2p_pee │ │ │ -00067a20: 722a 2667 743b 2870 6565 7269 6e66 6f29 r*>(peerinfo) │ │ │ -00067a30: 2d26 6774 3b64 6573 7428 2929 3b0a 0909 ->dest());... │ │ │ -00067a40: 0973 7472 2e73 6574 5f63 6f6d 6d61 6e64 .str.set_command │ │ │ -00067a50: 2869 3270 5f73 7472 6561 6d3a 3a63 6d64 (i2p_stream::cmd │ │ │ -00067a60: 5f63 6f6e 6e65 6374 293b 0a09 0909 7374 _connect);....st │ │ │ -00067a70: 722e 7365 745f 7365 7373 696f 6e5f 6964 r.set_session_id │ │ │ -00067a80: 286d 5f73 6573 2e69 3270 5f73 6573 7369 (m_ses.i2p_sessi │ │ │ -00067a90: 6f6e 2829 293b 0a09 0909 7265 7475 726e on());....return │ │ │ -00067aa0: 2072 6574 3b0a 0909 7d0a 0909 656c 7365 ret;...}...else │ │ │ -00067ab0: 0a23 656e 6469 660a 0909 7b0a 0909 0976 .#endif...{....v │ │ │ -00067ac0: 6f69 642a 2075 7365 7264 6174 6120 3d20 oid* userdata = │ │ │ -00067ad0: 6e75 6c6c 7074 723b 0a23 6966 6465 6620 nullptr;.#ifdef │ │ │ -00067ae0: 544f 5252 454e 545f 5353 4c5f 5045 4552 TORRENT_SSL_PEER │ │ │ -00067af0: 530a 0909 0969 6620 2869 735f 7373 6c5f S....if (is_ssl_ │ │ │ -00067b00: 746f 7272 656e 7428 2929 0a09 0909 7b0a torrent())....{. │ │ │ -00067b10: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00067b20: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00067b50: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00067b80: 632f 746f 7272 656e 742e 6370 703a 3936 c/torrent.cpp:96 │ │ │ -00067b90: 3232 3c2f 613e 3c2f 7464 3e3c 7464 3e70 22p │ │ │ -00067ba0: 6572 6861 7073 2030 2073 686f 756c 6420 erhaps 0 should │ │ │ -00067bb0: 6163 7475 616c 6c79 206d 6561 6e20 303c actually mean 0< │ │ │ -00067bc0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    per │ │ │ -00067c10: 6861 7073 2030 2073 686f 756c 6420 6163 haps 0 should ac │ │ │ -00067c20: 7475 616c 6c79 206d 6561 6e20 303c 2f68 tually mean 0

    ../src/tor │ │ │ -00067c40: 7265 6e74 2e63 7070 3a39 3632 323c 2f68 rent.cpp:9622
    ..//
    │ │ │ -00067c90: 2066 696e 6973 6865 6420 746f 7272 656e   finished torren
    │ │ │ -00067ca0: 7473 206d 6179 206e 6f74 2063 6861 6e67  ts may not chang
    │ │ │ -00067cb0: 6520 7468 6569 7220 7175 6575 6520 706f  e their queue po
    │ │ │ -00067cc0: 7369 7469 6f6e 732c 2061 7320 6974 2773  sitions, as it's
    │ │ │ -00067cd0: 2073 6574 2074 6f0a 0909 2f2f 202d 310a   set to...// -1.
    │ │ │ -00067ce0: 0909 6966 2028 286d 5f61 626f 7274 207c  ..if ((m_abort |
    │ │ │ -00067cf0: 7c20 6973 5f66 696e 6973 6865 6428 2929  | is_finished())
    │ │ │ -00067d00: 2026 616d 703b 2661 6d70 3b20 7020 213d   && p !=
    │ │ │ -00067d10: 206e 6f5f 706f 7329 2072 6574 7572 6e3b   no_pos) return;
    │ │ │ -00067d20: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -00067d30: 5254 2828 7020 3d3d 206e 6f5f 706f 7329  RT((p == no_pos)
    │ │ │ -00067d40: 203d 3d20 6973 5f66 696e 6973 6865 6428   == is_finished(
    │ │ │ -00067d50: 290a 0909 097c 7c20 2821 6d5f 6175 746f  )....|| (!m_auto
    │ │ │ -00067d60: 5f6d 616e 6167 6564 2026 616d 703b 2661  _managed &&a
    │ │ │ -00067d70: 6d70 3b20 7020 3d3d 206e 6f5f 706f 7329  mp; p == no_pos)
    │ │ │ -00067d80: 0a09 0909 7c7c 2028 6d5f 6162 6f72 7420  ....|| (m_abort 
    │ │ │ -00067d90: 2661 6d70 3b26 616d 703b 2070 203d 3d20  && p == 
    │ │ │ -00067da0: 6e6f 5f70 6f73 290a 0909 097c 7c20 2821  no_pos)....|| (!
    │ │ │ -00067db0: 6d5f 6164 6465 6420 2661 6d70 3b26 616d  m_added &&am
    │ │ │ -00067dc0: 703b 2070 203d 3d20 6e6f 5f70 6f73 2929  p; p == no_pos))
    │ │ │ -00067dd0: 3b0a 0909 6966 2028 7020 3d3d 206d 5f73  ;...if (p == m_s
    │ │ │ -00067de0: 6571 7565 6e63 655f 6e75 6d62 6572 2920  equence_number) 
    │ │ │ -00067df0: 7265 7475 726e 3b0a 0a09 0954 4f52 5245  return;....TORRE
    │ │ │ -00067e00: 4e54 5f41 5353 4552 5428 7020 2667 743b  NT_ASSERT(p >
    │ │ │ -00067e10: 3d20 6e6f 5f70 6f73 293b 0a0a 0909 7374  = no_pos);....st
    │ │ │ -00067e20: 6174 655f 7570 6461 7465 6428 293b 0a0a  ate_updated();..
    │ │ │ -00067e30: 0909 6d5f 7365 732e 7365 745f 7175 6575  ..m_ses.set_queu
    │ │ │ -00067e40: 655f 706f 7369 7469 6f6e 2874 6869 732c  e_position(this,
    │ │ │ -00067e50: 2070 293b 0a09 7d0a 0a09 766f 6964 2074   p);..}...void t
    │ │ │ -00067e60: 6f72 7265 6e74 3a3a 7365 745f 6d61 785f  orrent::set_max_
    │ │ │ -00067e70: 7570 6c6f 6164 7328 696e 7420 6c69 6d69  uploads(int limi
    │ │ │ -00067e80: 742c 2062 6f6f 6c20 636f 6e73 7420 7374  t, bool const st
    │ │ │ -00067e90: 6174 655f 7570 6461 7465 290a 097b 0a09  ate_update)..{..
    │ │ │ -00067ea0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -00067eb0: 6973 5f73 696e 676c 655f 7468 7265 6164  is_single_thread
    │ │ │ -00067ec0: 2829 293b 0a3c 6469 7620 7374 796c 653d  ());.
    ..if (limit & │ │ │ -00067f00: 6c74 3b3d 2030 2920 6c69 6d69 7420 3d20 lt;= 0) limit = │ │ │ -00067f10: 2831 2026 6c74 3b26 6c74 3b20 3234 2920 (1 << 24) │ │ │ -00067f20: 2d20 313b 0a3c 2f64 6976 3e09 0969 6620 - 1;.
    ..if │ │ │ -00067f30: 2869 6e74 286d 5f6d 6178 5f75 706c 6f61 (int(m_max_uploa │ │ │ -00067f40: 6473 2920 3d3d 206c 696d 6974 2920 7265 ds) == limit) re │ │ │ -00067f50: 7475 726e 3b0a 0909 6966 2028 7374 6174 turn;...if (stat │ │ │ -00067f60: 655f 7570 6461 7465 2920 7374 6174 655f e_update) state_ │ │ │ -00067f70: 7570 6461 7465 6428 293b 0a09 096d 5f6d updated();...m_m │ │ │ -00067f80: 6178 5f75 706c 6f61 6473 203d 2061 7578 ax_uploads = aux │ │ │ -00067f90: 3a3a 6e75 6d65 7269 635f 6361 7374 266c ::numeric_cast&l │ │ │ -00067fa0: 743b 7374 643a 3a75 696e 7433 325f 7426 t;std::uint32_t& │ │ │ -00067fb0: 6774 3b28 6c69 6d69 7429 3b0a 2369 666e gt;(limit);.#ifn │ │ │ -00067fc0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00067fd0: 424c 455f 4c4f 4747 494e 470a 0909 6966 BLE_LOGGING...if │ │ │ -00067fe0: 2028 7368 6f75 6c64 5f6c 6f67 2829 2026 (should_log() & │ │ │ -00067ff0: 616d 703b 2661 6d70 3b20 7374 6174 655f amp;& state_ │ │ │ -00068000: 7570 6461 7465 290a 0909 0964 6562 7567 update)....debug │ │ │ -00068010: 5f6c 6f67 2822 2a2a 2a20 7365 742d 6d61 _log("*** set-ma │ │ │ -00068020: 782d 7570 6c6f 6164 733a 2025 6422 2c20 x-uploads: %d", │ │ │ -00068030: 6d5f 6d61 785f 7570 6c6f 6164 7329 3b0a m_max_uploads);. │ │ │ -00068040: 2365 6e64 6966 0a0a 0909 6966 2028 7374 #endif....if (st │ │ │ -00068050: 6174 655f 7570 6461 7465 290a 0909 0973 ate_update)....s │ │ │ -00068060: 6574 5f6e 6565 645f 7361 7665 5f72 6573 et_need_save_res │ │ │ -00068070: 756d 6528 746f 7272 656e 745f 6861 6e64 ume(torrent_hand │ │ │ -00068080: 6c65 3a3a 6966 5f63 6f6e 6669 675f 6368 le::if_config_ch │ │ │ -00068090: 616e 6765 6429 3b0a 097d 0a0a 0976 6f69 anged);..}...voi │ │ │ -000680a0: 6420 746f 7272 656e 743a 3a73 6574 5f6d d torrent::set_m │ │ │ -000680b0: 6178 5f63 6f6e 6e65 6374 696f 6e73 2869 ax_connections(i │ │ │ -000680c0: 6e74 206c 696d 6974 2c20 626f 6f6c 2063 nt limit, bool c │ │ │ -000680d0: 6f6e 7374 2073 7461 7465 5f75 7064 6174 onst state_updat │ │ │ -000680e0: 6529 0a09 7b0a 0909 544f 5252 454e 545f e)..{...TORRENT_ │ │ │ -000680f0: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ -00068100: 5f74 6872 6561 6428 2929 3b0a 3c2f 7072 _thread());.rel │ │ │ -00068140: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ -00068180: 7272 656e 742e 6370 703a 3936 3339 3c2f rrent.cpp:9639perha │ │ │ -000681a0: 7073 2030 2073 686f 756c 6420 6163 7475 ps 0 should actu │ │ │ -000681b0: 616c 6c79 206d 6561 6e20 303c 2f74 643e ally mean 0 │ │ │ -000681c0: 3c2f 7472 3e3c 7472 2069 643d 2232 3338

    perhaps │ │ │ -00068210: 2030 2073 686f 756c 6420 6163 7475 616c 0 should actual │ │ │ -00068220: 6c79 206d 6561 6e20 303c 2f68 323e 3c68 ly mean 0

    ../src/torrent │ │ │ -00068240: 2e63 7070 3a39 3633 393c 2f68 343e 3c70 .cpp:9639

    ..void t │ │ │ -00068290: 6f72 7265 6e74 3a3a 7365 745f 6d61 785f orrent::set_max_ │ │ │ -000682a0: 7570 6c6f 6164 7328 696e 7420 6c69 6d69 uploads(int limi │ │ │ -000682b0: 742c 2062 6f6f 6c20 636f 6e73 7420 7374 t, bool const st │ │ │ -000682c0: 6174 655f 7570 6461 7465 290a 097b 0a09 ate_update)..{.. │ │ │ -000682d0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -000682e0: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ -000682f0: 2829 293b 0a09 0969 6620 286c 696d 6974 ());...if (limit │ │ │ -00068300: 2026 6c74 3b3d 2030 2920 6c69 6d69 7420 <= 0) limit │ │ │ -00068310: 3d20 2831 2026 6c74 3b26 6c74 3b20 3234 = (1 << 24 │ │ │ -00068320: 2920 2d20 313b 0a09 0969 6620 2869 6e74 ) - 1;...if (int │ │ │ -00068330: 286d 5f6d 6178 5f75 706c 6f61 6473 2920 (m_max_uploads) │ │ │ -00068340: 3d3d 206c 696d 6974 2920 7265 7475 726e == limit) return │ │ │ -00068350: 3b0a 0909 6966 2028 7374 6174 655f 7570 ;...if (state_up │ │ │ -00068360: 6461 7465 2920 7374 6174 655f 7570 6461 date) state_upda │ │ │ -00068370: 7465 6428 293b 0a09 096d 5f6d 6178 5f75 ted();...m_max_u │ │ │ -00068380: 706c 6f61 6473 203d 2061 7578 3a3a 6e75 ploads = aux::nu │ │ │ -00068390: 6d65 7269 635f 6361 7374 266c 743b 7374 meric_cast<st │ │ │ -000683a0: 643a 3a75 696e 7433 325f 7426 6774 3b28 d::uint32_t>( │ │ │ -000683b0: 6c69 6d69 7429 3b0a 2369 666e 6465 6620 limit);.#ifndef │ │ │ -000683c0: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -000683d0: 4c4f 4747 494e 470a 0909 6966 2028 7368 LOGGING...if (sh │ │ │ -000683e0: 6f75 6c64 5f6c 6f67 2829 2026 616d 703b ould_log() & │ │ │ -000683f0: 2661 6d70 3b20 7374 6174 655f 7570 6461 & state_upda │ │ │ -00068400: 7465 290a 0909 0964 6562 7567 5f6c 6f67 te)....debug_log │ │ │ -00068410: 2822 2a2a 2a20 7365 742d 6d61 782d 7570 ("*** set-max-up │ │ │ -00068420: 6c6f 6164 733a 2025 6422 2c20 6d5f 6d61 loads: %d", m_ma │ │ │ -00068430: 785f 7570 6c6f 6164 7329 3b0a 2365 6e64 x_uploads);.#end │ │ │ -00068440: 6966 0a0a 0909 6966 2028 7374 6174 655f if....if (state_ │ │ │ -00068450: 7570 6461 7465 290a 0909 0973 6574 5f6e update)....set_n │ │ │ -00068460: 6565 645f 7361 7665 5f72 6573 756d 6528 eed_save_resume( │ │ │ -00068470: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ -00068480: 6966 5f63 6f6e 6669 675f 6368 616e 6765 if_config_change │ │ │ -00068490: 6429 3b0a 097d 0a0a 0976 6f69 6420 746f d);..}...void to │ │ │ -000684a0: 7272 656e 743a 3a73 6574 5f6d 6178 5f63 rrent::set_max_c │ │ │ -000684b0: 6f6e 6e65 6374 696f 6e73 2869 6e74 206c onnections(int l │ │ │ -000684c0: 696d 6974 2c20 626f 6f6c 2063 6f6e 7374 imit, bool const │ │ │ -000684d0: 2073 7461 7465 5f75 7064 6174 6529 0a09 state_update).. │ │ │ -000684e0: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ -000684f0: 5254 2869 735f 7369 6e67 6c65 5f74 6872 RT(is_single_thr │ │ │ -00068500: 6561 6428 2929 3b0a 3c64 6976 2073 7479 ead());.

    .. │ │ │ -00068570: 6966 2028 696e 7428 6d5f 6d61 785f 636f if (int(m_max_co │ │ │ -00068580: 6e6e 6563 7469 6f6e 7329 203d 3d20 6c69 nnections) == li │ │ │ -00068590: 6d69 7429 2072 6574 7572 6e3b 0a09 0969 mit) return;...i │ │ │ -000685a0: 6620 2873 7461 7465 5f75 7064 6174 6529 f (state_update) │ │ │ -000685b0: 2073 7461 7465 5f75 7064 6174 6564 2829 state_updated() │ │ │ -000685c0: 3b0a 0909 6d5f 6d61 785f 636f 6e6e 6563 ;...m_max_connec │ │ │ -000685d0: 7469 6f6e 7320 3d20 6175 783a 3a6e 756d tions = aux::num │ │ │ -000685e0: 6572 6963 5f63 6173 7426 6c74 3b73 7464 eric_cast<std │ │ │ -000685f0: 3a3a 7569 6e74 3332 5f74 2667 743b 286c ::uint32_t>(l │ │ │ -00068600: 696d 6974 293b 0a09 0975 7064 6174 655f imit);...update_ │ │ │ -00068610: 7761 6e74 5f70 6565 7273 2829 3b0a 0a23 want_peers();..# │ │ │ -00068620: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ -00068630: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ -00068640: 0969 6620 2873 686f 756c 645f 6c6f 6728 .if (should_log( │ │ │ -00068650: 2920 2661 6d70 3b26 616d 703b 2073 7461 ) && sta │ │ │ -00068660: 7465 5f75 7064 6174 6529 0a09 0909 6465 te_update)....de │ │ │ -00068670: 6275 675f 6c6f 6728 222a 2a2a 2073 6574 bug_log("*** set │ │ │ -00068680: 2d6d 6178 2d63 6f6e 6e65 6374 696f 6e73 -max-connections │ │ │ -00068690: 3a20 2564 222c 206d 5f6d 6178 5f63 6f6e : %d", m_max_con │ │ │ -000686a0: 6e65 6374 696f 6e73 293b 0a23 656e 6469 nections);.#endi │ │ │ -000686b0: 660a 0a09 0969 6620 286e 756d 5f70 6565 f....if (num_pee │ │ │ -000686c0: 7273 2829 2026 6774 3b20 696e 7428 6d5f rs() > int(m_ │ │ │ -000686d0: 6d61 785f 636f 6e6e 6563 7469 6f6e 7329 max_connections) │ │ │ -000686e0: 290a 0909 7b0a 0909 0964 6973 636f 6e6e )...{....disconn │ │ │ -000686f0: 6563 745f 7065 6572 7328 6e75 6d5f 7065 ect_peers(num_pe │ │ │ -00068700: 6572 7328 2920 2d20 6d5f 6d61 785f 636f ers() - m_max_co │ │ │ -00068710: 6e6e 6563 7469 6f6e 730a 0909 0909 2c20 nnections....., │ │ │ -00068720: 6572 726f 7273 3a3a 746f 6f5f 6d61 6e79 errors::too_many │ │ │ -00068730: 5f63 6f6e 6e65 6374 696f 6e73 293b 0a09 _connections);.. │ │ │ -00068740: 097d 0a0a 0909 6966 2028 7374 6174 655f .}....if (state_ │ │ │ -00068750: 7570 6461 7465 290a 0909 0973 6574 5f6e update)....set_n │ │ │ -00068760: 6565 645f 7361 7665 5f72 6573 756d 6528 eed_save_resume( │ │ │ -00068770: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ -00068780: 6966 5f63 6f6e 6669 675f 6368 616e 6765 if_config_change │ │ │ -00068790: 6429 3b0a 097d 0a0a 0976 6f69 6420 746f d);..}...void to │ │ │ -000687a0: 7272 656e 743a 3a73 6574 5f75 706c 6f61 rrent::set_uploa │ │ │ -000687b0: 645f 6c69 6d69 7428 696e 7420 636f 6e73 d_limit(int cons │ │ │ -000687c0: 7420 6c69 6d69 7429 0a09 7b0a 0909 7365 t limit)..{...se │ │ │ -000687d0: 745f 6c69 6d69 745f 696d 706c 286c 696d t_limit_impl(lim │ │ │ -000687e0: 6974 2c20 7065 6572 5f63 6f6e 6e65 6374 it, peer_connect │ │ │ -000687f0: 696f 6e3a 3a75 706c 6f61 645f 6368 616e ion::upload_chan │ │ │ -00068800: 6e65 6c29 3b0a 2369 666e 6465 6620 544f nel);.#ifndef TO │ │ │ -00068810: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ -00068820: 4747 494e 470a 0909 6465 6275 675f 6c6f GGING...debug_lo │ │ │ -00068830: 6728 222a 2a2a 2073 6574 2d75 706c 6f61 g("*** set-uploa │ │ │ -00068840: 642d 6c69 6d69 743a 2025 6422 2c20 6c69 d-limit: %d", li │ │ │ -00068850: 6d69 7429 3b0a 2365 6e64 6966 0a09 7d0a mit);.#endif..}. │ │ │ -00068860: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a ..void torrent:: │ │ │ -00068870: 7365 745f 646f 776e 6c6f 6164 5f6c 696d set_download_lim │ │ │ -00068880: 6974 2869 6e74 2063 6f6e 7374 206c 696d it(int const lim │ │ │ -00068890: 6974 290a 097b 0a3c 2f70 7265 3e3c 2f74 it)..{.relevanc │ │ │ -000688d0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ -00068910: 2e63 7070 3a31 3135 3532 3c2f 613e 3c2f .cpp:11552instead o │ │ │ -00068930: 6620 7265 736f 7274 696e 6720 7468 6520 f resorting the │ │ │ -00068940: 7768 6f6c 6520 6c69 7374 2c20 696e 7365 whole list, inse │ │ │ -00068950: 7274 2074 6865 2070 6565 7273 2064 6972 rt the peers dir │ │ │ -00068960: 6563 746c 7920 696e 746f 2074 6865 2072 ectly into the r │ │ │ -00068970: 6967 6874 2070 6c61 6365 3c2f 7464 3e3c ight place< │ │ │ -00068980: 2f74 723e 3c74 7220 6964 3d22 3233 3922 /tr>

    instead │ │ │ -000689d0: 6f66 2072 6573 6f72 7469 6e67 2074 6865 of resorting the │ │ │ -000689e0: 2077 686f 6c65 206c 6973 742c 2069 6e73 whole list, ins │ │ │ -000689f0: 6572 7420 7468 6520 7065 6572 730a 6469 ert the peers.di │ │ │ -00068a00: 7265 6374 6c79 2069 6e74 6f20 7468 6520 rectly into the │ │ │ -00068a10: 7269 6768 7420 706c 6163 653c 2f68 323e right place

    │ │ │ -00068a20: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ -00068a30: 6e74 2e63 7070 3a31 3135 3532 3c2f 6834 nt.cpp:11552

    ....s
    │ │ │ -00068a80: 7464 3a3a 7072 696e 7466 2822 7469 6d65  td::printf("time
    │ │ │ -00068a90: 6420 6f75 7420 5b61 7665 7261 6765 2d70  d out [average-p
    │ │ │ -00068aa0: 6965 6365 2d74 696d 653a 2025 6420 6d73  iece-time: %d ms
    │ │ │ -00068ab0: 205d 5c6e 220a 0909 0909 092c 206d 5f61   ]\n"......, m_a
    │ │ │ -00068ac0: 7665 7261 6765 5f70 6965 6365 5f74 696d  verage_piece_tim
    │ │ │ -00068ad0: 6529 3b0a 2365 6e64 6966 0a09 0909 7d0a  e);.#endif....}.
    │ │ │ -00068ae0: 0a09 0909 2f2f 2070 6963 6b20 616c 6c20  ....// pick all 
    │ │ │ -00068af0: 626c 6f63 6b73 2066 6f72 2074 6869 7320  blocks for this 
    │ │ │ -00068b00: 7069 6563 652e 2074 6865 2070 6565 7273  piece. the peers
    │ │ │ -00068b10: 206c 6973 7420 6973 206b 6570 7420 7570   list is kept up
    │ │ │ -00068b20: 2074 6f20 6461 7465 0a09 0909 2f2f 2061   to date....// a
    │ │ │ -00068b30: 6e64 2073 6f72 7465 642e 2077 6865 6e20  nd sorted. when 
    │ │ │ -00068b40: 7765 2069 7373 7565 2061 2072 6571 7565  we issue a reque
    │ │ │ -00068b50: 7374 2074 6f20 6120 7065 6572 2c20 6974  st to a peer, it
    │ │ │ -00068b60: 7320 646f 776e 6c6f 6164 2071 7565 7565  s download queue
    │ │ │ -00068b70: 0a09 0909 2f2f 2074 696d 6520 7769 6c6c  ....// time will
    │ │ │ -00068b80: 2069 6e63 7265 6173 6520 616e 6420 6974   increase and it
    │ │ │ -00068b90: 206d 6179 206e 6565 6420 746f 2062 6520   may need to be 
    │ │ │ -00068ba0: 6275 6d70 6564 2069 6e20 7468 6520 7065  bumped in the pe
    │ │ │ -00068bb0: 6572 7320 6c69 7374 2c0a 0909 092f 2f20  ers list,....// 
    │ │ │ -00068bc0: 7369 6e63 6520 6974 2773 206f 7264 6572  since it's order
    │ │ │ -00068bd0: 6564 2062 7920 646f 776e 6c6f 6164 2071  ed by download q
    │ │ │ -00068be0: 7565 7565 2074 696d 650a 0909 0970 6963  ueue time....pic
    │ │ │ -00068bf0: 6b5f 7469 6d65 5f63 7269 7469 6361 6c5f  k_time_critical_
    │ │ │ -00068c00: 626c 6f63 6b28 7065 6572 732c 2069 676e  block(peers, ign
    │ │ │ -00068c10: 6f72 655f 7065 6572 730a 0909 0909 2c20  ore_peers....., 
    │ │ │ -00068c20: 7065 6572 735f 7769 7468 5f72 6571 7565  peers_with_reque
    │ │ │ -00068c30: 7374 730a 0909 0909 2c20 7069 2c20 2661  sts....., pi, &a
    │ │ │ -00068c40: 6d70 3b69 2c20 6d5f 7069 636b 6572 2e67  mp;i, m_picker.g
    │ │ │ -00068c50: 6574 2829 0a09 0909 092c 2062 6c6f 636b  et()....., block
    │ │ │ -00068c60: 735f 696e 5f70 6965 6365 2c20 7469 6d65  s_in_piece, time
    │ │ │ -00068c70: 645f 6f75 7429 3b0a 0a09 0909 2f2f 2070  d_out);.....// p
    │ │ │ -00068c80: 7574 2062 6163 6b20 7468 6520 7065 6572  ut back the peer
    │ │ │ -00068c90: 7320 7765 2069 676e 6f72 6564 2069 6e74  s we ignored int
    │ │ │ -00068ca0: 6f20 7468 6520 7065 6572 206c 6973 7420  o the peer list 
    │ │ │ -00068cb0: 666f 7220 7468 6520 6e65 7874 2070 6965  for the next pie
    │ │ │ -00068cc0: 6365 0a09 0909 6966 2028 2169 676e 6f72  ce....if (!ignor
    │ │ │ -00068cd0: 655f 7065 6572 732e 656d 7074 7928 2929  e_peers.empty())
    │ │ │ -00068ce0: 0a09 0909 7b0a 0909 0909 7065 6572 732e  ....{.....peers.
    │ │ │ -00068cf0: 696e 7365 7274 2870 6565 7273 2e62 6567  insert(peers.beg
    │ │ │ -00068d00: 696e 2829 2c20 6967 6e6f 7265 5f70 6565  in(), ignore_pee
    │ │ │ -00068d10: 7273 2e62 6567 696e 2829 2c20 6967 6e6f  rs.begin(), igno
    │ │ │ -00068d20: 7265 5f70 6565 7273 2e65 6e64 2829 293b  re_peers.end());
    │ │ │ -00068d30: 0a09 0909 0969 676e 6f72 655f 7065 6572  .....ignore_peer
    │ │ │ -00068d40: 732e 636c 6561 7228 293b 0a0a 3c64 6976  s.clear();..
    ....st │ │ │ -00068d80: 643a 3a73 6f72 7428 7065 6572 732e 6265 d::sort(peers.be │ │ │ -00068d90: 6769 6e28 292c 2070 6565 7273 2e65 6e64 gin(), peers.end │ │ │ -00068da0: 2829 0a3c 2f64 6976 3e09 0909 0909 2c20 ().
    ....., │ │ │ -00068db0: 5b5d 2028 7065 6572 5f63 6f6e 6e65 6374 [] (peer_connect │ │ │ -00068dc0: 696f 6e20 636f 6e73 742a 206c 6873 2c20 ion const* lhs, │ │ │ -00068dd0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e20 peer_connection │ │ │ -00068de0: 636f 6e73 742a 2072 6873 290a 0909 0909 const* rhs)..... │ │ │ -00068df0: 097b 2072 6574 7572 6e20 6c68 732d 2667 .{ return lhs-&g │ │ │ -00068e00: 743b 646f 776e 6c6f 6164 5f71 7565 7565 t;download_queue │ │ │ -00068e10: 5f74 696d 6528 3136 2a31 3032 3429 2026 _time(16*1024) & │ │ │ -00068e20: 6c74 3b20 7268 732d 2667 743b 646f 776e lt; rhs->down │ │ │ -00068e30: 6c6f 6164 5f71 7565 7565 5f74 696d 6528 load_queue_time( │ │ │ -00068e40: 3136 2a31 3032 3429 3b20 7d29 3b0a 0909 16*1024); });... │ │ │ -00068e50: 097d 0a0a 0909 092f 2f20 6966 2074 6869 .}.....// if thi │ │ │ -00068e60: 7320 7065 6572 2773 2064 6f77 6e6c 6f61 s peer's downloa │ │ │ -00068e70: 6420 7469 6d65 2065 7863 6565 6473 2032 d time exceeds 2 │ │ │ -00068e80: 2073 6563 6f6e 6473 2c20 7765 2772 6520 seconds, we're │ │ │ -00068e90: 646f 6e65 2e0a 0909 092f 2f20 5765 2064 done.....// We d │ │ │ -00068ea0: 6f6e 2774 2077 616e 7420 746f 2062 7569 on't want to bui │ │ │ -00068eb0: 6c64 2075 6e72 6561 736f 6e61 626c 7920 ld unreasonably │ │ │ -00068ec0: 6c6f 6e67 2072 6571 7565 7374 2071 7565 long request que │ │ │ -00068ed0: 7565 730a 0909 0969 6620 2821 7065 6572 ues....if (!peer │ │ │ -00068ee0: 732e 656d 7074 7928 2920 2661 6d70 3b26 s.empty() && │ │ │ -00068ef0: 616d 703b 2070 6565 7273 5b30 5d2d 2667 amp; peers[0]-&g │ │ │ -00068f00: 743b 646f 776e 6c6f 6164 5f71 7565 7565 t;download_queue │ │ │ -00068f10: 5f74 696d 6528 2920 2667 743b 206d 696c _time() > mil │ │ │ -00068f20: 6c69 7365 636f 6e64 7328 3230 3030 2929 liseconds(2000)) │ │ │ -00068f30: 0a09 0909 0962 7265 616b 3b0a 0909 7d0a .....break;...}. │ │ │ -00068f40: 0a09 092f 2f20 636f 6d6d 6974 2061 6c6c ...// commit all │ │ │ -00068f50: 2074 6865 2074 696d 6520 6372 6974 6963 the time critic │ │ │ -00068f60: 616c 2072 6571 7565 7374 730a 0909 666f al requests...fo │ │ │ -00068f70: 7220 2861 7574 6f2a 2070 203a 2070 6565 r (auto* p : pee │ │ │ -00068f80: 7273 5f77 6974 685f 7265 7175 6573 7473 rs_with_requests │ │ │ -00068f90: 290a 0909 7b0a 0909 0970 2d26 6774 3b73 )...{....p->s │ │ │ -00068fa0: 656e 645f 626c 6f63 6b5f 7265 7175 6573 end_block_reques │ │ │ -00068fb0: 7473 2829 3b0a 0909 7d0a 097d 0a23 656e ts();...}..}.#en │ │ │ -00068fc0: 6469 6620 2f2f 2054 4f52 5245 4e54 5f44 dif // TORRENT_D │ │ │ -00068fd0: 4953 4142 4c45 5f53 5452 4541 4d49 4e47 ISABLE_STREAMING │ │ │ -00068fe0: 0a0a 0973 7464 3a3a 7365 7426 6c74 3b73 ...std::set<s │ │ │ -00068ff0: 7464 3a3a 7374 7269 6e67 2667 743b 2074 td::string> t │ │ │ -00069000: 6f72 7265 6e74 3a3a 7765 625f 7365 6564 orrent::web_seed │ │ │ -00069010: 7328 2920 636f 6e73 740a 097b 0a09 0954 s() const..{...T │ │ │ -00069020: 4f52 5245 4e54 5f41 5353 4552 5428 6973 ORRENT_ASSERT(is │ │ │ -00069030: 5f73 696e 676c 655f 7468 7265 6164 2829 _single_thread() │ │ │ -00069040: 293b 0a09 0973 7464 3a3a 7365 7426 6c74 );...std::set< │ │ │ -00069050: 3b73 7464 3a3a 7374 7269 6e67 2667 743b ;std::string> │ │ │ -00069060: 2072 6574 3b0a 0909 666f 7220 2861 7574 ret;...for (aut │ │ │ -00069070: 6f20 636f 6e73 7426 616d 703b 2073 203a o const& s : │ │ │ -00069080: 206d 5f77 6562 5f73 6565 6473 290a 0909 m_web_seeds)... │ │ │ -00069090: 7b0a 0909 0969 6620 2873 2e70 6565 725f {....if (s.peer_ │ │ │ -000690a0: 696e 666f 2e62 616e 6e65 6429 2063 6f6e info.banned) con │ │ │ -000690b0: 7469 6e75 653b 0a09 0909 6966 2028 732e tinue;....if (s. │ │ │ -000690c0: 7265 6d6f 7665 6429 2063 6f6e 7469 6e75 removed) continu │ │ │ -000690d0: 653b 0a09 0909 7265 742e 696e 7365 7274 e;....ret.insert │ │ │ -000690e0: 2873 2e75 726c 293b 0a09 097d 0a09 0972 (s.url);...}...r │ │ │ -000690f0: 6574 7572 6e20 7265 743b 0a09 7d0a 3c2f eturn ret;..}.r │ │ │ -00069130: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00069140: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00069170: 656e 756d 5f6e 6574 2e63 7070 3a32 3436 enum_net.cpp:246 │ │ │ -00069180: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6620 if │ │ │ -00069190: 7765 2067 6574 2068 6572 652c 2074 6865 we get here, the │ │ │ -000691a0: 2063 616c 6c65 7220 7374 696c 6c20 6173 caller still as │ │ │ -000691b0: 7375 6d65 7320 7468 6520 6572 726f 7220 sumes the error │ │ │ -000691c0: 636f 6465 2069 7320 7265 706f 7274 6564 code is reported │ │ │ -000691d0: 2076 6961 2065 7272 6e6f 3c2f 7464 3e3c via errno< │ │ │ -000691e0: 2f74 723e 3c74 7220 6964 3d22 3234 3022 /tr>

    if we ge │ │ │ -00069230: 7420 6865 7265 2c20 7468 6520 6361 6c6c t here, the call │ │ │ -00069240: 6572 2073 7469 6c6c 2061 7373 756d 6573 er still assumes │ │ │ -00069250: 2074 6865 2065 7272 6f72 2063 6f64 650a the error code. │ │ │ -00069260: 6973 2072 6570 6f72 7465 6420 7669 6120 is reported via │ │ │ -00069270: 6572 726e 6f3c 2f68 323e 3c68 343e 2e2e errno

    .. │ │ │ -00069280: 2f73 7263 2f65 6e75 6d5f 6e65 742e 6370 /src/enum_net.cp │ │ │ -00069290: 703a 3234 363c 2f68 343e 3c70 7265 2073 p:246

    ..;..}.#endi
    │ │ │ -000692e0: 660a 0a23 6966 2054 4f52 5245 4e54 5f55  f..#if TORRENT_U
    │ │ │ -000692f0: 5345 5f4e 4554 4c49 4e4b 0a0a 0969 6e74  SE_NETLINK...int
    │ │ │ -00069300: 2072 6561 645f 6e6c 5f73 6f63 6b28 696e   read_nl_sock(in
    │ │ │ -00069310: 7420 736f 636b 2c20 7374 643a 3a75 696e  t sock, std::uin
    │ │ │ -00069320: 7433 325f 7420 636f 6e73 7420 7365 712c  t32_t const seq,
    │ │ │ -00069330: 2073 7464 3a3a 7569 6e74 3332 5f74 2063   std::uint32_t c
    │ │ │ -00069340: 6f6e 7374 2070 6964 0a09 092c 2073 7464  onst pid..., std
    │ │ │ -00069350: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f  ::function<vo
    │ │ │ -00069360: 6964 286e 6c6d 7367 6864 7220 636f 6e73  id(nlmsghdr cons
    │ │ │ -00069370: 742a 2926 6774 3b20 6f6e 5f6d 7367 290a  t*)> on_msg).
    │ │ │ -00069380: 097b 0a09 0973 7464 3a3a 6172 7261 7926  .{...std::array&
    │ │ │ -00069390: 6c74 3b63 6861 722c 2034 3039 3626 6774  lt;char, 4096>
    │ │ │ -000693a0: 3b20 6275 663b 0a09 0966 6f72 2028 3b3b  ; buf;...for (;;
    │ │ │ -000693b0: 290a 0909 7b0a 0909 0969 6e74 2063 6f6e  )...{....int con
    │ │ │ -000693c0: 7374 2072 6561 645f 6c65 6e20 3d20 696e  st read_len = in
    │ │ │ -000693d0: 7428 7265 6376 2873 6f63 6b2c 2062 7566  t(recv(sock, buf
    │ │ │ -000693e0: 2e64 6174 6128 292c 2062 7566 2e73 697a  .data(), buf.siz
    │ │ │ -000693f0: 6528 292c 2030 2929 3b0a 0909 0969 6620  e(), 0));....if 
    │ │ │ -00069400: 2872 6561 645f 6c65 6e20 266c 743b 2030  (read_len < 0
    │ │ │ -00069410: 2920 7265 7475 726e 202d 313b 0a0a 0909  ) return -1;....
    │ │ │ -00069420: 0961 7574 6f20 636f 6e73 742a 206e 6c5f  .auto const* nl_
    │ │ │ -00069430: 6864 7220 3d20 7265 696e 7465 7270 7265  hdr = reinterpre
    │ │ │ -00069440: 745f 6361 7374 266c 743b 6e6c 6d73 6768  t_cast<nlmsgh
    │ │ │ -00069450: 6472 2063 6f6e 7374 2a26 6774 3b28 6275  dr const*>(bu
    │ │ │ -00069460: 662e 6461 7461 2829 293b 0a09 0909 696e  f.data());....in
    │ │ │ -00069470: 7420 6c65 6e20 3d20 7265 6164 5f6c 656e  t len = read_len
    │ │ │ -00069480: 3b0a 0a09 0909 666f 7220 283b 206c 656e  ;.....for (; len
    │ │ │ -00069490: 2026 6774 3b20 3020 2661 6d70 3b26 616d   > 0 &&am
    │ │ │ -000694a0: 703b 2061 7578 3a3a 6e6c 6d73 675f 6f6b  p; aux::nlmsg_ok
    │ │ │ -000694b0: 286e 6c5f 6864 722c 206c 656e 293b 206e  (nl_hdr, len); n
    │ │ │ -000694c0: 6c5f 6864 7220 3d20 6175 783a 3a6e 6c6d  l_hdr = aux::nlm
    │ │ │ -000694d0: 7367 5f6e 6578 7428 6e6c 5f68 6472 2c20  sg_next(nl_hdr, 
    │ │ │ -000694e0: 6c65 6e29 290a 0909 097b 0a3c 6469 7620  len))....{.
    ....if │ │ │ -00069520: 2828 6175 783a 3a6e 6c6d 7367 5f6f 6b28 ((aux::nlmsg_ok( │ │ │ -00069530: 6e6c 5f68 6472 2c20 7265 6164 5f6c 656e nl_hdr, read_len │ │ │ -00069540: 2920 3d3d 2030 2920 7c7c 2028 6e6c 5f68 ) == 0) || (nl_h │ │ │ -00069550: 6472 2d26 6774 3b6e 6c6d 7367 5f74 7970 dr->nlmsg_typ │ │ │ -00069560: 6520 3d3d 204e 4c4d 5347 5f45 5252 4f52 e == NLMSG_ERROR │ │ │ -00069570: 2929 0a3c 2f64 6976 3e09 0909 0909 7265 )).
    .....re │ │ │ -00069580: 7475 726e 202d 313b 0a09 0909 092f 2f20 turn -1;.....// │ │ │ -00069590: 7468 6973 2066 756e 6374 696f 6e20 646f this function do │ │ │ -000695a0: 6573 6e27 7420 6861 6e64 6c65 206d 756c esn't handle mul │ │ │ -000695b0: 7469 706c 6520 7265 7175 6573 7473 2061 tiple requests a │ │ │ -000695c0: 7420 7468 6520 7361 6d65 2074 696d 650a t the same time. │ │ │ -000695d0: 0909 0909 2f2f 2073 6f20 7265 706f 7274 ....// so report │ │ │ -000695e0: 2061 6e20 6572 726f 7220 6966 2074 6865 an error if the │ │ │ -000695f0: 206d 6573 7361 6765 2064 6f65 7320 6e6f message does no │ │ │ -00069600: 7420 6861 7665 2074 6865 2065 7870 6563 t have the expec │ │ │ -00069610: 7465 6420 7365 7120 616e 6420 7069 640a ted seq and pid. │ │ │ -00069620: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00069630: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00069660: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00069690: 632f 656e 756d 5f6e 6574 2e63 7070 3a32 c/enum_net.cpp:2 │ │ │ -000696a0: 3532 3c2f 613e 3c2f 7464 3e3c 7464 3e69 52i │ │ │ -000696b0: 6620 7765 2067 6574 2068 6572 652c 2074 f we get here, t │ │ │ -000696c0: 6865 2063 616c 6c65 7220 7374 696c 6c20 he caller still │ │ │ -000696d0: 6173 7375 6d65 7320 7468 6520 6572 726f assumes the erro │ │ │ -000696e0: 7220 636f 6465 2069 7320 7265 706f 7274 r code is report │ │ │ -000696f0: 6564 2076 6961 2065 7272 6e6f 3c2f 7464 ed via errno

    if we │ │ │ -00069750: 6765 7420 6865 7265 2c20 7468 6520 6361 get here, the ca │ │ │ -00069760: 6c6c 6572 2073 7469 6c6c 2061 7373 756d ller still assum │ │ │ -00069770: 6573 2074 6865 2065 7272 6f72 2063 6f64 es the error cod │ │ │ -00069780: 650a 6973 2072 6570 6f72 7465 6420 7669 e.is reported vi │ │ │ -00069790: 6120 6572 726e 6f3c 2f68 323e 3c68 343e a errno

    │ │ │ -000697a0: 2e2e 2f73 7263 2f65 6e75 6d5f 6e65 742e ../src/enum_net. │ │ │ -000697b0: 6370 703a 3235 323c 2f68 343e 3c70 7265 cpp:252

    #if TORREN
    │ │ │ -00069800: 545f 5553 455f 4e45 544c 494e 4b0a 0a09  T_USE_NETLINK...
    │ │ │ -00069810: 696e 7420 7265 6164 5f6e 6c5f 736f 636b  int read_nl_sock
    │ │ │ -00069820: 2869 6e74 2073 6f63 6b2c 2073 7464 3a3a  (int sock, std::
    │ │ │ -00069830: 7569 6e74 3332 5f74 2063 6f6e 7374 2073  uint32_t const s
    │ │ │ -00069840: 6571 2c20 7374 643a 3a75 696e 7433 325f  eq, std::uint32_
    │ │ │ -00069850: 7420 636f 6e73 7420 7069 640a 0909 2c20  t const pid..., 
    │ │ │ -00069860: 7374 643a 3a66 756e 6374 696f 6e26 6c74  std::function<
    │ │ │ -00069870: 3b76 6f69 6428 6e6c 6d73 6768 6472 2063  ;void(nlmsghdr c
    │ │ │ -00069880: 6f6e 7374 2a29 2667 743b 206f 6e5f 6d73  onst*)> on_ms
    │ │ │ -00069890: 6729 0a09 7b0a 0909 7374 643a 3a61 7272  g)..{...std::arr
    │ │ │ -000698a0: 6179 266c 743b 6368 6172 2c20 3430 3936  ay<char, 4096
    │ │ │ -000698b0: 2667 743b 2062 7566 3b0a 0909 666f 7220  > buf;...for 
    │ │ │ -000698c0: 283b 3b29 0a09 097b 0a09 0909 696e 7420  (;;)...{....int 
    │ │ │ -000698d0: 636f 6e73 7420 7265 6164 5f6c 656e 203d  const read_len =
    │ │ │ -000698e0: 2069 6e74 2872 6563 7628 736f 636b 2c20   int(recv(sock, 
    │ │ │ -000698f0: 6275 662e 6461 7461 2829 2c20 6275 662e  buf.data(), buf.
    │ │ │ -00069900: 7369 7a65 2829 2c20 3029 293b 0a09 0909  size(), 0));....
    │ │ │ -00069910: 6966 2028 7265 6164 5f6c 656e 2026 6c74  if (read_len <
    │ │ │ -00069920: 3b20 3029 2072 6574 7572 6e20 2d31 3b0a  ; 0) return -1;.
    │ │ │ -00069930: 0a09 0909 6175 746f 2063 6f6e 7374 2a20  ....auto const* 
    │ │ │ -00069940: 6e6c 5f68 6472 203d 2072 6569 6e74 6572  nl_hdr = reinter
    │ │ │ -00069950: 7072 6574 5f63 6173 7426 6c74 3b6e 6c6d  pret_cast<nlm
    │ │ │ -00069960: 7367 6864 7220 636f 6e73 742a 2667 743b  sghdr const*>
    │ │ │ -00069970: 2862 7566 2e64 6174 6128 2929 3b0a 0909  (buf.data());...
    │ │ │ -00069980: 0969 6e74 206c 656e 203d 2072 6561 645f  .int len = read_
    │ │ │ -00069990: 6c65 6e3b 0a0a 0909 0966 6f72 2028 3b20  len;.....for (; 
    │ │ │ -000699a0: 6c65 6e20 2667 743b 2030 2026 616d 703b  len > 0 &
    │ │ │ -000699b0: 2661 6d70 3b20 6175 783a 3a6e 6c6d 7367  & aux::nlmsg
    │ │ │ -000699c0: 5f6f 6b28 6e6c 5f68 6472 2c20 6c65 6e29  _ok(nl_hdr, len)
    │ │ │ -000699d0: 3b20 6e6c 5f68 6472 203d 2061 7578 3a3a  ; nl_hdr = aux::
    │ │ │ -000699e0: 6e6c 6d73 675f 6e65 7874 286e 6c5f 6864  nlmsg_next(nl_hd
    │ │ │ -000699f0: 722c 206c 656e 2929 0a09 0909 7b0a 0909  r, len))....{...
    │ │ │ -00069a00: 0909 6966 2028 2861 7578 3a3a 6e6c 6d73  ..if ((aux::nlms
    │ │ │ -00069a10: 675f 6f6b 286e 6c5f 6864 722c 2072 6561  g_ok(nl_hdr, rea
    │ │ │ -00069a20: 645f 6c65 6e29 203d 3d20 3029 207c 7c20  d_len) == 0) || 
    │ │ │ -00069a30: 286e 6c5f 6864 722d 2667 743b 6e6c 6d73  (nl_hdr->nlms
    │ │ │ -00069a40: 675f 7479 7065 203d 3d20 4e4c 4d53 475f  g_type == NLMSG_
    │ │ │ -00069a50: 4552 524f 5229 290a 0909 0909 0972 6574  ERROR))......ret
    │ │ │ -00069a60: 7572 6e20 2d31 3b0a 0909 0909 2f2f 2074  urn -1;.....// t
    │ │ │ -00069a70: 6869 7320 6675 6e63 7469 6f6e 2064 6f65  his function doe
    │ │ │ -00069a80: 736e 2774 2068 616e 646c 6520 6d75 6c74  sn't handle mult
    │ │ │ -00069a90: 6970 6c65 2072 6571 7565 7374 7320 6174  iple requests at
    │ │ │ -00069aa0: 2074 6865 2073 616d 6520 7469 6d65 0a09   the same time..
    │ │ │ -00069ab0: 0909 092f 2f20 736f 2072 6570 6f72 7420  ...// so report 
    │ │ │ -00069ac0: 616e 2065 7272 6f72 2069 6620 7468 6520  an error if the 
    │ │ │ -00069ad0: 6d65 7373 6167 6520 646f 6573 206e 6f74  message does not
    │ │ │ -00069ae0: 2068 6176 6520 7468 6520 6578 7065 6374   have the expect
    │ │ │ -00069af0: 6564 2073 6571 2061 6e64 2070 6964 0a3c  ed seq and pid.<
    │ │ │ -00069b00: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00069b10: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00069b20: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ -00069b30: 0969 6620 286e 6c5f 6864 722d 2667 743b  .if (nl_hdr->
    │ │ │ -00069b40: 6e6c 6d73 675f 7365 7120 213d 2073 6571  nlmsg_seq != seq
    │ │ │ -00069b50: 207c 7c20 6e6c 5f68 6472 2d26 6774 3b6e   || nl_hdr->n
    │ │ │ -00069b60: 6c6d 7367 5f70 6964 2021 3d20 7069 6429  lmsg_pid != pid)
    │ │ │ -00069b70: 0a3c 2f64 6976 3e09 0909 0909 7265 7475  .
    .....retu │ │ │ -00069b80: 726e 202d 313b 0a0a 0909 0909 6966 2028 rn -1;......if ( │ │ │ -00069b90: 6e6c 5f68 6472 2d26 6774 3b6e 6c6d 7367 nl_hdr->nlmsg │ │ │ -00069ba0: 5f74 7970 6520 3d3d 204e 4c4d 5347 5f44 _type == NLMSG_D │ │ │ -00069bb0: 4f4e 4529 2072 6574 7572 6e20 303b 0a0a ONE) return 0;.. │ │ │ -00069bc0: 0909 0909 6f6e 5f6d 7367 286e 6c5f 6864 ....on_msg(nl_hd │ │ │ -00069bd0: 7229 3b0a 0a09 0909 0969 6620 2828 6e6c r);......if ((nl │ │ │ -00069be0: 5f68 6472 2d26 6774 3b6e 6c6d 7367 5f66 _hdr->nlmsg_f │ │ │ -00069bf0: 6c61 6773 2026 616d 703b 204e 4c4d 5f46 lags & NLM_F │ │ │ -00069c00: 5f4d 554c 5449 2920 3d3d 2030 2920 7265 _MULTI) == 0) re │ │ │ -00069c10: 7475 726e 2030 3b0a 0909 097d 0a09 097d turn 0;....}...} │ │ │ -00069c20: 0a2f 2f09 0972 6574 7572 6e20 303b 0a09 .//..return 0;.. │ │ │ -00069c30: 7d0a 0a09 696e 7420 6e6c 5f64 756d 705f }...int nl_dump_ │ │ │ -00069c40: 7265 7175 6573 7428 696e 7420 636f 6e73 request(int cons │ │ │ -00069c50: 7420 736f 636b 2c20 7374 643a 3a75 696e t sock, std::uin │ │ │ -00069c60: 7433 325f 7420 636f 6e73 7420 7365 710a t32_t const seq. │ │ │ -00069c70: 0909 2c20 6e6c 6d73 6768 6472 2a20 636f .., nlmsghdr* co │ │ │ -00069c80: 6e73 7420 7265 7175 6573 745f 6d73 672c nst request_msg, │ │ │ -00069c90: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c std::function&l │ │ │ -00069ca0: 743b 766f 6964 286e 6c6d 7367 6864 7220 t;void(nlmsghdr │ │ │ -00069cb0: 636f 6e73 742a 2926 6774 3b20 6f6e 5f6d const*)> on_m │ │ │ -00069cc0: 7367 290a 097b 0a09 0972 6571 7565 7374 sg)..{...request │ │ │ -00069cd0: 5f6d 7367 2d26 6774 3b6e 6c6d 7367 5f66 _msg->nlmsg_f │ │ │ -00069ce0: 6c61 6773 203d 204e 4c4d 5f46 5f44 554d lags = NLM_F_DUM │ │ │ -00069cf0: 5020 7c20 4e4c 4d5f 465f 5245 5155 4553 P | NLM_F_REQUES │ │ │ -00069d00: 543b 0a09 0972 6571 7565 7374 5f6d 7367 T;...request_msg │ │ │ -00069d10: 2d26 6774 3b6e 6c6d 7367 5f73 6571 203d ->nlmsg_seq = │ │ │ -00069d20: 2073 6571 3b0a 0909 2f2f 2069 6e20 7468 seq;...// in th │ │ │ -00069d30: 656f 7279 206e 6c6d 7367 5f70 6964 2073 eory nlmsg_pid s │ │ │ -00069d40: 686f 756c 6420 6265 2073 6574 2074 6f20 hould be set to │ │ │ -00069d50: 7468 6520 6e65 746c 696e 6b20 706f 7274 the netlink port │ │ │ -00069d60: 2049 4420 284e 4f54 2074 6865 2070 726f ID (NOT the pro │ │ │ -00069d70: 6365 7373 2049 4429 0a09 092f 2f20 6f66 cess ID)...// of │ │ │ -00069d80: 2074 6865 2073 656e 6465 722c 2062 7574 the sender, but │ │ │ -00069d90: 2074 6865 206b 6572 6e65 6c20 6967 6e6f the kernel igno │ │ │ -00069da0: 7265 7320 7468 6973 2066 6965 6c64 2073 res this field s │ │ │ -00069db0: 6f20 6974 2069 7320 7479 7069 6361 6c6c o it is typicall │ │ │ -00069dc0: 7920 7365 7420 746f 0a09 092f 2f20 7a65 y set to...// ze │ │ │ -00069dd0: 726f 0a09 0972 6571 7565 7374 5f6d 7367 ro...request_msg │ │ │ -00069de0: 2d26 6774 3b6e 6c6d 7367 5f70 6964 203d ->nlmsg_pid = │ │ │ -00069df0: 2030 3b0a 0a09 0969 6620 283a 3a73 656e 0;....if (::sen │ │ │ -00069e00: 6428 736f 636b 2c20 7265 7175 6573 745f d(sock, request_ │ │ │ -00069e10: 6d73 672c 2072 6571 7565 7374 5f6d 7367 msg, request_msg │ │ │ -00069e20: 2d26 6774 3b6e 6c6d 7367 5f6c 656e 2c20 ->nlmsg_len, │ │ │ -00069e30: 3029 2026 6c74 3b20 3029 0a09 0909 7265 0) < 0)....re │ │ │ -00069e40: 7475 726e 202d 313b 0a0a 0909 2f2f 2067 turn -1;....// g │ │ │ -00069e50: 6574 2074 6865 2073 6f63 6b65 7427 7320 et the socket's │ │ │ -00069e60: 706f 7274 2049 4420 736f 2074 6861 7420 port ID so that │ │ │ -00069e70: 7765 2063 616e 2076 6572 6966 7920 6974 we can verify it │ │ │ -00069e80: 2069 6e20 7468 6520 7265 7370 6f6e 7365 in the response │ │ │ -00069e90: 0a09 0973 6f63 6b61 6464 725f 6e6c 2073 ...sockaddr_nl s │ │ │ -00069ea0: 6f63 6b5f 6164 6472 3b0a 0909 736f 636b ock_addr;...sock │ │ │ -00069eb0: 6c65 6e5f 7420 736f 636b 5f61 6464 725f len_t sock_addr_ │ │ │ -00069ec0: 6c65 6e20 3d20 7369 7a65 6f66 2873 6f63 len = sizeof(soc │ │ │ -00069ed0: 6b5f 6164 6472 293b 0a09 0969 6620 283a k_addr);...if (: │ │ │ -00069ee0: 3a67 6574 736f 636b 6e61 6d65 2873 6f63 :getsockname(soc │ │ │ -00069ef0: 6b2c 2072 6569 6e74 6572 7072 6574 5f63 k, reinterpret_c │ │ │ -00069f00: 6173 7426 6c74 3b73 6f63 6b61 6464 722a ast<sockaddr* │ │ │ -00069f10: 2667 743b 2826 616d 703b 736f 636b 5f61 >(&sock_a │ │ │ -00069f20: 6464 7229 2c20 2661 6d70 3b73 6f63 6b5f ddr), &sock_ │ │ │ -00069f30: 6164 6472 5f6c 656e 2920 266c 743b 2030 addr_len) < 0 │ │ │ -00069f40: 290a 0909 0972 6574 7572 6e20 2d31 3b0a )....return -1;. │ │ │ -00069f50: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ -00069f60: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00069f90: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00069fc0: 632f 6669 6e67 6572 7072 696e 742e 6370 c/fingerprint.cp │ │ │ -00069fd0: 703a 3535 3c2f 613e 3c2f 7464 3e3c 7464 p:55the fingerprint │ │ │ -00069ff0: 2063 6f6e 7374 7275 6374 6f72 2073 686f constructor sho │ │ │ -0006a000: 756c 6420 7461 6b65 2061 2073 7472 696e uld take a strin │ │ │ -0006a010: 675f 7669 6577 3c2f 7464 3e3c 2f74 723e g_view │ │ │ -0006a020: 3c74 7220 6964 3d22 3234 3222 2073 7479 │ │ │ -0006a050: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006a060: 3c68 323e 7468 6520 6669 6e67 6572 7072

    the fingerpr │ │ │ -0006a070: 696e 7420 636f 6e73 7472 7563 746f 7220 int constructor │ │ │ -0006a080: 7368 6f75 6c64 2074 616b 6520 6120 7374 should take a st │ │ │ -0006a090: 7269 6e67 5f76 6965 773c 2f68 323e 3c68 ring_view

    ../src/fingerp │ │ │ -0006a0b0: 7269 6e74 2e63 7070 3a35 353c 2f68 343e rint.cpp:55 │ │ │ -0006a0c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..TORR
    │ │ │ -0006a100: 454e 545f 4153 5345 5254 5f50 5245 434f  ENT_ASSERT_PRECO
    │ │ │ -0006a110: 4e44 286d 696e 6f72 2026 6774 3b3d 2030  ND(minor >= 0
    │ │ │ -0006a120: 293b 0a09 0954 4f52 5245 4e54 5f41 5353  );...TORRENT_ASS
    │ │ │ -0006a130: 4552 545f 5052 4543 4f4e 4428 7265 7669  ERT_PRECOND(revi
    │ │ │ -0006a140: 7369 6f6e 2026 6774 3b3d 2030 293b 0a09  sion >= 0);..
    │ │ │ -0006a150: 0954 4f52 5245 4e54 5f41 5353 4552 545f  .TORRENT_ASSERT_
    │ │ │ -0006a160: 5052 4543 4f4e 4428 7461 6720 2667 743b  PRECOND(tag >
    │ │ │ -0006a170: 3d20 3029 3b0a 0909 544f 5252 454e 545f  = 0);...TORRENT_
    │ │ │ -0006a180: 4153 5345 5254 5f50 5245 434f 4e44 286e  ASSERT_PRECOND(n
    │ │ │ -0006a190: 616d 652e 7369 7a65 2829 203d 3d20 3229  ame.size() == 2)
    │ │ │ -0006a1a0: 3b0a 0909 6966 2028 6e61 6d65 2e73 697a  ;...if (name.siz
    │ │ │ -0006a1b0: 6528 2920 266c 743b 2032 2920 6e61 6d65  e() < 2) name
    │ │ │ -0006a1c0: 203d 2022 2d2d 223b 0a0a 0909 7374 643a   = "--";....std:
    │ │ │ -0006a1d0: 3a73 7472 696e 6720 7265 743b 0a09 0972  :string ret;...r
    │ │ │ -0006a1e0: 6574 2e72 6573 697a 6528 3829 3b0a 0909  et.resize(8);...
    │ │ │ -0006a1f0: 7265 745b 305d 203d 2027 2d27 3b0a 0909  ret[0] = '-';...
    │ │ │ -0006a200: 7265 745b 315d 203d 206e 616d 655b 305d  ret[1] = name[0]
    │ │ │ -0006a210: 3b0a 0909 7265 745b 325d 203d 206e 616d  ;...ret[2] = nam
    │ │ │ -0006a220: 655b 315d 3b0a 0909 7265 745b 335d 203d  e[1];...ret[3] =
    │ │ │ -0006a230: 2076 6572 7369 6f6e 5f74 6f5f 6368 6172   version_to_char
    │ │ │ -0006a240: 286d 616a 6f72 293b 0a09 0972 6574 5b34  (major);...ret[4
    │ │ │ -0006a250: 5d20 3d20 7665 7273 696f 6e5f 746f 5f63  ] = version_to_c
    │ │ │ -0006a260: 6861 7228 6d69 6e6f 7229 3b0a 0909 7265  har(minor);...re
    │ │ │ -0006a270: 745b 355d 203d 2076 6572 7369 6f6e 5f74  t[5] = version_t
    │ │ │ -0006a280: 6f5f 6368 6172 2872 6576 6973 696f 6e29  o_char(revision)
    │ │ │ -0006a290: 3b0a 0909 7265 745b 365d 203d 2076 6572  ;...ret[6] = ver
    │ │ │ -0006a2a0: 7369 6f6e 5f74 6f5f 6368 6172 2874 6167  sion_to_char(tag
    │ │ │ -0006a2b0: 293b 0a09 0972 6574 5b37 5d20 3d20 272d  );...ret[7] = '-
    │ │ │ -0006a2c0: 273b 0a09 0972 6574 7572 6e20 7265 743b  ';...return ret;
    │ │ │ -0006a2d0: 0a09 7d0a 0a23 6966 6465 6620 5f5f 636c  ..}..#ifdef __cl
    │ │ │ -0006a2e0: 616e 675f 5f0a 3c64 6976 2073 7479 6c65  ang__.
    #pragma clan │ │ │ -0006a320: 6720 6469 6167 6e6f 7374 6963 2070 7573 g diagnostic pus │ │ │ -0006a330: 680a 3c2f 6469 763e 2370 7261 676d 6120 h.
    #pragma │ │ │ -0006a340: 636c 616e 6720 6469 6167 6e6f 7374 6963 clang diagnostic │ │ │ -0006a350: 2069 676e 6f72 6564 2022 2d57 756e 6b6e ignored "-Wunkn │ │ │ -0006a360: 6f77 6e2d 7761 726e 696e 672d 6f70 7469 own-warning-opti │ │ │ -0006a370: 6f6e 220a 2370 7261 676d 6120 636c 616e on".#pragma clan │ │ │ -0006a380: 6720 6469 6167 6e6f 7374 6963 2069 676e g diagnostic ign │ │ │ -0006a390: 6f72 6564 2022 2d57 756e 7361 6665 2d62 ored "-Wunsafe-b │ │ │ -0006a3a0: 7566 6665 722d 7573 6167 6522 0a23 656e uffer-usage".#en │ │ │ -0006a3b0: 6469 660a 0a09 6669 6e67 6572 7072 696e dif...fingerprin │ │ │ -0006a3c0: 743a 3a66 696e 6765 7270 7269 6e74 2863 t::fingerprint(c │ │ │ -0006a3d0: 6f6e 7374 2063 6861 722a 2069 645f 7374 onst char* id_st │ │ │ -0006a3e0: 7269 6e67 2c20 696e 7420 6d61 6a6f 722c ring, int major, │ │ │ -0006a3f0: 2069 6e74 206d 696e 6f72 0a09 092c 2069 int minor..., i │ │ │ -0006a400: 6e74 2072 6576 6973 696f 6e2c 2069 6e74 nt revision, int │ │ │ -0006a410: 2074 6167 290a 0909 3a20 6d61 6a6f 725f tag)...: major_ │ │ │ -0006a420: 7665 7273 696f 6e28 6d61 6a6f 7229 0a09 version(major).. │ │ │ -0006a430: 092c 206d 696e 6f72 5f76 6572 7369 6f6e ., minor_version │ │ │ -0006a440: 286d 696e 6f72 290a 0909 2c20 7265 7669 (minor)..., revi │ │ │ -0006a450: 7369 6f6e 5f76 6572 7369 6f6e 2872 6576 sion_version(rev │ │ │ -0006a460: 6973 696f 6e29 0a09 092c 2074 6167 5f76 ision)..., tag_v │ │ │ -0006a470: 6572 7369 6f6e 2874 6167 290a 097b 0a09 ersion(tag)..{.. │ │ │ -0006a480: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0006a490: 6964 5f73 7472 696e 6729 3b0a 0909 544f id_string);...TO │ │ │ -0006a4a0: 5252 454e 545f 4153 5345 5254 286d 616a RRENT_ASSERT(maj │ │ │ -0006a4b0: 6f72 2026 6774 3b3d 2030 293b 0a09 0954 or >= 0);...T │ │ │ -0006a4c0: 4f52 5245 4e54 5f41 5353 4552 5428 6d69 ORRENT_ASSERT(mi │ │ │ -0006a4d0: 6e6f 7220 2667 743b 3d20 3029 3b0a 0909 nor >= 0);... │ │ │ -0006a4e0: 544f 5252 454e 545f 4153 5345 5254 2872 TORRENT_ASSERT(r │ │ │ -0006a4f0: 6576 6973 696f 6e20 2667 743b 3d20 3029 evision >= 0) │ │ │ -0006a500: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ -0006a510: 5254 2874 6167 2026 6774 3b3d 2030 293b RT(tag >= 0); │ │ │ -0006a520: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0006a530: 5428 7374 643a 3a73 7472 6c65 6e28 6964 T(std::strlen(id │ │ │ -0006a540: 5f73 7472 696e 6729 203d 3d20 3229 3b0a _string) == 2);. │ │ │ -0006a550: 0909 6e61 6d65 5b30 5d20 3d20 6964 5f73 ..name[0] = id_s │ │ │ -0006a560: 7472 696e 675b 305d 3b0a 0909 6e61 6d65 tring[0];...name │ │ │ -0006a570: 5b31 5d20 3d20 6964 5f73 7472 696e 675b [1] = id_string[ │ │ │ -0006a580: 315d 3b0a 097d 0a0a 2369 6664 6566 205f 1];..}..#ifdef _ │ │ │ -0006a590: 5f63 6c61 6e67 5f5f 0a23 7072 6167 6d61 _clang__.#pragma │ │ │ -0006a5a0: 2063 6c61 6e67 2064 6961 676e 6f73 7469 clang diagnosti │ │ │ -0006a5b0: 6320 706f 700a 2365 6e64 6966 0a0a 2369 c pop.#endif..#i │ │ │ -0006a5c0: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -0006a5d0: 5253 494f 4e20 3d3d 2031 0a09 7374 643a RSION == 1..std: │ │ │ -0006a5e0: 3a73 7472 696e 6720 6669 6e67 6572 7072 :string fingerpr │ │ │ -0006a5f0: 696e 743a 3a74 6f5f 7374 7269 6e67 2829 int::to_string() │ │ │ -0006a600: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475 const..{...retu │ │ │ -0006a610: 726e 2067 656e 6572 6174 655f 6669 6e67 rn generate_fing │ │ │ -0006a620: 6572 7072 696e 7428 7374 643a 3a73 7472 erprint(std::str │ │ │ -0006a630: 696e 6728 6e61 6d65 2c20 3229 2c20 6d61 ing(name, 2), ma │ │ │ -0006a640: 6a6f 725f 7665 7273 696f 6e2c 206d 696e jor_version, min │ │ │ -0006a650: 6f72 5f76 6572 7369 6f6e 0a09 0909 2c20 or_version...., │ │ │ -0006a660: 7265 7669 7369 6f6e 5f76 6572 7369 6f6e revision_version │ │ │ -0006a670: 2c20 7461 675f 7665 7273 696f 6e29 3b0a , tag_version);. │ │ │ -0006a680: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0006a690: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006a6c0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0006a6f0: 632f 7065 7266 6f72 6d61 6e63 655f 636f c/performance_co │ │ │ -0006a700: 756e 7465 7273 2e63 7070 3a31 373c 2f61 unters.cpp:17move s │ │ │ -0006a720: 7461 7473 5f63 6f75 6e74 6572 5f74 206f tats_counter_t o │ │ │ -0006a730: 7574 206f 6620 636f 756e 7465 7273 3c2f ut of counters

    move │ │ │ -0006a790: 2073 7461 7473 5f63 6f75 6e74 6572 5f74 stats_counter_t │ │ │ -0006a7a0: 206f 7574 206f 6620 636f 756e 7465 7273 out of counters │ │ │ -0006a7b0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0006a7c0: 7065 7266 6f72 6d61 6e63 655f 636f 756e performance_coun │ │ │ -0006a7d0: 7465 7273 2e63 7070 3a31 373c 2f68 343e ters.cpp:17

    │ │ │ -0006a7e0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    
    │ │ │ -0006a820: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374  relev
    │ │ │ -0006a850: 616e 6365 266e 6273 703b 303c 2f74 643e  ance 0
    │ │ │ -0006a860: 3c74 643e 3c61 2068 7265 663d 226a 6176  ../src/perf
    │ │ │ -0006a890: 6f72 6d61 6e63 655f 636f 756e 7465 7273  ormance_counters
    │ │ │ -0006a8a0: 2e63 7070 3a31 383c 2f61 3e3c 2f74 643e  .cpp:18
    │ │ │ -0006a8b0: 3c74 643e 7368 6f75 6c64 2062 6974 746f  should bitto
    │ │ │ -0006a8c0: 7272 656e 7420 6b65 6570 2d61 6c69 7665  rrent keep-alive
    │ │ │ -0006a8d0: 206d 6573 7361 6765 7320 6861 7665 2061   messages have a
    │ │ │ -0006a8e0: 2063 6f75 6e74 6572 2074 6f6f 3f3c 2f74   counter too?

    shoul │ │ │ -0006a940: 6420 6269 7474 6f72 7265 6e74 206b 6565 d bittorrent kee │ │ │ -0006a950: 702d 616c 6976 6520 6d65 7373 6167 6573 p-alive messages │ │ │ -0006a960: 2068 6176 6520 6120 636f 756e 7465 7220 have a counter │ │ │ -0006a970: 746f 6f3f 3c2f 6832 3e3c 6834 3e2e 2e2f too?

    ../ │ │ │ -0006a980: 7372 632f 7065 7266 6f72 6d61 6e63 655f src/performance_ │ │ │ -0006a990: 636f 756e 7465 7273 2e63 7070 3a31 383c counters.cpp:18< │ │ │ -0006a9a0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ -0006aa10: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -0006aa20: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ -0006aa50: 7065 7266 6f72 6d61 6e63 655f 636f 756e  performance_coun
    │ │ │ -0006aa60: 7465 7273 2e63 7070 3a31 393c 2f61 3e3c  ters.cpp:19<
    │ │ │ -0006aa70: 2f74 643e 3c74 643e 4974 2077 6f75 6c64  /td>It would
    │ │ │ -0006aa80: 2062 6520 6e69 6365 2069 6620 7468 6973   be nice if this
    │ │ │ -0006aa90: 2063 6f75 6c64 2062 6520 616e 2069 6e74   could be an int
    │ │ │ -0006aaa0: 6572 6e61 6c20 7479 7065 2e20 6465 6661  ernal type. defa
    │ │ │ -0006aab0: 756c 745f 6469 736b 5f63 6f6e 7374 7275  ult_disk_constru
    │ │ │ -0006aac0: 6374 6f72 2064 6570 656e 6473 206f 6e20  ctor depends on 
    │ │ │ -0006aad0: 6974 206e 6f77 3c2f 7464 3e3c 2f74 723e  it now
    │ │ │ -0006aae0: 3c74 7220 6964 3d22 3234 3522 2073 7479  
    │ │ │ -0006ab10: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ -0006ab20: 3c68 323e 4974 2077 6f75 6c64 2062 6520  

    It would be │ │ │ -0006ab30: 6e69 6365 2069 6620 7468 6973 2063 6f75 nice if this cou │ │ │ -0006ab40: 6c64 2062 6520 616e 2069 6e74 6572 6e61 ld be an interna │ │ │ -0006ab50: 6c20 7479 7065 2e20 6465 6661 756c 745f l type. default_ │ │ │ -0006ab60: 6469 736b 5f63 6f6e 7374 7275 6374 6f72 disk_constructor │ │ │ -0006ab70: 2064 6570 656e 6473 206f 6e20 6974 206e depends on it n │ │ │ -0006ab80: 6f77 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ow

    ../sr │ │ │ -0006ab90: 632f 7065 7266 6f72 6d61 6e63 655f 636f c/performance_co │ │ │ -0006aba0: 756e 7465 7273 2e63 7070 3a31 393c 2f68 unters.cpp:19
    #end
    │ │ │ -0006abf0: 6966 202f 2f20 544f 5252 454e 545f 4142  if // TORRENT_AB
    │ │ │ -0006ac00: 495f 5645 5253 494f 4e0a 0a7d 0a0a 2f2a  I_VERSION..}../*
    │ │ │ -0006ac10: 0a0a 436f 7079 7269 6768 7420 2863 2920  ..Copyright (c) 
    │ │ │ -0006ac20: 3230 3130 2c20 3230 3133 2d32 3032 302c  2010, 2013-2020,
    │ │ │ -0006ac30: 2041 7276 6964 204e 6f72 6265 7267 0a43   Arvid Norberg.C
    │ │ │ -0006ac40: 6f70 7972 6967 6874 2028 6329 2032 3031  opyright (c) 201
    │ │ │ -0006ac50: 362d 3230 3137 2c20 416c 6465 6e20 546f  6-2017, Alden To
    │ │ │ -0006ac60: 7272 6573 0a41 6c6c 2072 6967 6874 7320  rres.All rights 
    │ │ │ -0006ac70: 7265 7365 7276 6564 2e0a 0a59 6f75 206d  reserved...You m
    │ │ │ -0006ac80: 6179 2075 7365 2c20 6469 7374 7269 6275  ay use, distribu
    │ │ │ -0006ac90: 7465 2061 6e64 206d 6f64 6966 7920 7468  te and modify th
    │ │ │ -0006aca0: 6973 2063 6f64 6520 756e 6465 7220 7468  is code under th
    │ │ │ -0006acb0: 6520 7465 726d 7320 6f66 2074 6865 2042  e terms of the B
    │ │ │ -0006acc0: 5344 206c 6963 656e 7365 2c0a 7365 6520  SD license,.see 
    │ │ │ -0006acd0: 4c49 4345 4e53 4520 6669 6c65 2e0a 2a2f  LICENSE file..*/
    │ │ │ -0006ace0: 0a0a 2369 6e63 6c75 6465 2022 6c69 6274  ..#include "libt
    │ │ │ -0006acf0: 6f72 7265 6e74 2f70 6572 666f 726d 616e  orrent/performan
    │ │ │ -0006ad00: 6365 5f63 6f75 6e74 6572 732e 6870 7022  ce_counters.hpp"
    │ │ │ -0006ad10: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -0006ad20: 7272 656e 742f 6173 7365 7274 2e68 7070  rrent/assert.hpp
    │ │ │ -0006ad30: 220a 2369 6e63 6c75 6465 2026 6c74 3b63  ".#include <c
    │ │ │ -0006ad40: 7374 7269 6e67 2667 743b 202f 2f20 666f  string> // fo
    │ │ │ -0006ad50: 7220 6d65 6d73 6574 0a0a 6e61 6d65 7370  r memset..namesp
    │ │ │ -0006ad60: 6163 6520 6c69 6274 6f72 7265 6e74 207b  ace libtorrent {
    │ │ │ -0006ad70: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0006ada0: 0963 6f75 6e74 6572 733a 3a63 6f75 6e74 .counters::count │ │ │ -0006adb0: 6572 7328 2920 544f 5252 454e 545f 434f ers() TORRENT_CO │ │ │ -0006adc0: 554e 5445 525f 4e4f 4558 4345 5054 0a3c UNTER_NOEXCEPT.< │ │ │ -0006add0: 2f64 6976 3e09 7b0a 2369 6664 6566 2041 /div>.{.#ifdef A │ │ │ -0006ade0: 544f 4d49 435f 4c4c 4f4e 475f 4c4f 434b TOMIC_LLONG_LOCK │ │ │ -0006adf0: 5f46 5245 450a 0909 666f 7220 2861 7574 _FREE...for (aut │ │ │ -0006ae00: 6f26 616d 703b 2063 6f75 6e74 6572 203a o& counter : │ │ │ -0006ae10: 206d 5f73 7461 7473 5f63 6f75 6e74 6572 m_stats_counter │ │ │ -0006ae20: 290a 0909 0963 6f75 6e74 6572 2e73 746f )....counter.sto │ │ │ -0006ae30: 7265 2830 2c20 7374 643a 3a6d 656d 6f72 re(0, std::memor │ │ │ -0006ae40: 795f 6f72 6465 725f 7265 6c61 7865 6429 y_order_relaxed) │ │ │ -0006ae50: 3b0a 2365 6c73 650a 0909 6d5f 7374 6174 ;.#else...m_stat │ │ │ -0006ae60: 735f 636f 756e 7465 722e 6669 6c6c 2830 s_counter.fill(0 │ │ │ -0006ae70: 293b 0a23 656e 6469 660a 097d 0a0a 0963 );.#endif..}...c │ │ │ -0006ae80: 6f75 6e74 6572 733a 3a63 6f75 6e74 6572 ounters::counter │ │ │ -0006ae90: 7328 636f 756e 7465 7273 2063 6f6e 7374 s(counters const │ │ │ -0006aea0: 2661 6d70 3b20 6329 2054 4f52 5245 4e54 & c) TORRENT │ │ │ -0006aeb0: 5f43 4f55 4e54 4552 5f4e 4f45 5843 4550 _COUNTER_NOEXCEP │ │ │ -0006aec0: 540a 097b 0a23 6966 6465 6620 4154 4f4d T..{.#ifdef ATOM │ │ │ -0006aed0: 4943 5f4c 4c4f 4e47 5f4c 4f43 4b5f 4652 IC_LLONG_LOCK_FR │ │ │ -0006aee0: 4545 0a09 0966 6f72 2028 696e 7420 6920 EE...for (int i │ │ │ -0006aef0: 3d20 303b 2069 2026 6c74 3b20 6d5f 7374 = 0; i < m_st │ │ │ -0006af00: 6174 735f 636f 756e 7465 722e 656e 645f ats_counter.end_ │ │ │ -0006af10: 696e 6465 7828 293b 202b 2b69 290a 0909 index(); ++i)... │ │ │ -0006af20: 096d 5f73 7461 7473 5f63 6f75 6e74 6572 .m_stats_counter │ │ │ -0006af30: 5b69 5d2e 7374 6f72 6528 0a09 0909 0963 [i].store(.....c │ │ │ -0006af40: 2e6d 5f73 7461 7473 5f63 6f75 6e74 6572 .m_stats_counter │ │ │ -0006af50: 5b69 5d2e 6c6f 6164 2873 7464 3a3a 6d65 [i].load(std::me │ │ │ -0006af60: 6d6f 7279 5f6f 7264 6572 5f72 656c 6178 mory_order_relax │ │ │ -0006af70: 6564 290a 0909 0909 092c 2073 7464 3a3a ed)......, std:: │ │ │ -0006af80: 6d65 6d6f 7279 5f6f 7264 6572 5f72 656c memory_order_rel │ │ │ -0006af90: 6178 6564 293b 0a23 656c 7365 0a09 0973 axed);.#else...s │ │ │ -0006afa0: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c td::lock_guard&l │ │ │ -0006afb0: 743b 7374 643a 3a6d 7574 6578 2667 743b t;std::mutex> │ │ │ -0006afc0: 206c 2863 2e6d 5f6d 7574 6578 293b 0a09 l(c.m_mutex);.. │ │ │ -0006afd0: 096d 5f73 7461 7473 5f63 6f75 6e74 6572 .m_stats_counter │ │ │ -0006afe0: 203d 2063 2e6d 5f73 7461 7473 5f63 6f75 = c.m_stats_cou │ │ │ -0006aff0: 6e74 6572 3b0a 2365 6e64 6966 0a09 7d0a nter;.#endif..}. │ │ │ -0006b000: 0a09 636f 756e 7465 7273 2661 6d70 3b20 ..counters& │ │ │ -0006b010: 636f 756e 7465 7273 3a3a 6f70 6572 6174 counters::operat │ │ │ -0006b020: 6f72 3d28 636f 756e 7465 7273 2063 6f6e or=(counters con │ │ │ -0006b030: 7374 2661 6d70 3b20 6329 2026 616d 703b st& c) & │ │ │ -0006b040: 2054 4f52 5245 4e54 5f43 4f55 4e54 4552 TORRENT_COUNTER │ │ │ -0006b050: 5f4e 4f45 5843 4550 540a 097b 0a09 0969 _NOEXCEPT..{...i │ │ │ -0006b060: 6620 2826 616d 703b 6320 3d3d 2074 6869 f (&c == thi │ │ │ -0006b070: 7329 2072 6574 7572 6e20 2a74 6869 733b s) return *this; │ │ │ -0006b080: 0a23 6966 6465 6620 4154 4f4d 4943 5f4c .#ifdef ATOMIC_L │ │ │ -0006b090: 4c4f 4e47 5f4c 4f43 4b5f 4652 4545 0a09 LONG_LOCK_FREE.. │ │ │ -0006b0a0: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ -0006b0b0: 2069 2026 6c74 3b20 6d5f 7374 6174 735f i < m_stats_ │ │ │ -0006b0c0: 636f 756e 7465 722e 656e 645f 696e 6465 counter.end_inde │ │ │ -0006b0d0: 7828 293b 202b 2b69 290a 0909 096d 5f73 x(); ++i)....m_s │ │ │ -0006b0e0: 7461 7473 5f63 6f75 6e74 6572 5b69 5d2e tats_counter[i]. │ │ │ -0006b0f0: 7374 6f72 6528 0a09 0909 0963 2e6d 5f73 store(.....c.m_s │ │ │ -0006b100: 7461 7473 5f63 6f75 6e74 6572 5b69 5d2e tats_counter[i]. │ │ │ -0006b110: 6c6f 6164 2873 7464 3a3a 6d65 6d6f 7279 load(std::memory │ │ │ -0006b120: 5f6f 7264 6572 5f72 656c 6178 6564 290a _order_relaxed). │ │ │ -0006b130: 0909 0909 092c 2073 7464 3a3a 6d65 6d6f ....., std::memo │ │ │ -0006b140: 7279 5f6f 7264 6572 5f72 656c 6178 6564 ry_order_relaxed │ │ │ -0006b150: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -0006b180: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0006b190: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0006b1c0: 2f73 7263 2f6b 6164 656d 6c69 612f 6974 /src/kademlia/it │ │ │ -0006b1d0: 656d 2e63 7070 3a31 3333 3c2f 613e 3c2f em.cpp:133implement │ │ │ -0006b1f0: 2063 746f 7220 666f 7220 656e 7472 7920 ctor for entry │ │ │ -0006b200: 6672 6f6d 2062 6465 636f 6465 5f6e 6f64 from bdecode_nod │ │ │ -0006b210: 653f 3c2f 7464 3e3c 2f74 723e 3c74 7220 e?

    │ │ │ -0006b260: 696d 706c 656d 656e 7420 6374 6f72 2066 implement ctor f │ │ │ -0006b270: 6f72 2065 6e74 7279 2066 726f 6d20 6264 or entry from bd │ │ │ -0006b280: 6563 6f64 655f 6e6f 6465 3f3c 2f68 323e ecode_node?

    │ │ │ -0006b290: 3c68 343e 2e2e 2f73 7263 2f6b 6164 656d

    ../src/kadem │ │ │ -0006b2a0: 6c69 612f 6974 656d 2e63 7070 3a31 3333 lia/item.cpp:133 │ │ │ -0006b2b0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0006b2f0: 2c20 7365 6372 6574 5f6b 6579 2063 6f6e  , secret_key con
    │ │ │ -0006b300: 7374 2661 6d70 3b20 736b 290a 7b0a 0963  st& sk).{..c
    │ │ │ -0006b310: 6861 7220 7374 725b 3132 3030 5d3b 0a09  har str[1200];..
    │ │ │ -0006b320: 696e 7420 636f 6e73 7420 6c65 6e20 3d20  int const len = 
    │ │ │ -0006b330: 6361 6e6f 6e69 6361 6c5f 7374 7269 6e67  canonical_string
    │ │ │ -0006b340: 2876 2c20 7365 712c 2073 616c 742c 2073  (v, seq, salt, s
    │ │ │ -0006b350: 7472 293b 0a0a 0972 6574 7572 6e20 6564  tr);...return ed
    │ │ │ -0006b360: 3235 3531 395f 7369 676e 287b 7374 722c  25519_sign({str,
    │ │ │ -0006b370: 206c 656e 7d2c 2070 6b2c 2073 6b29 3b0a   len}, pk, sk);.
    │ │ │ -0006b380: 7d0a 0a69 7465 6d3a 3a69 7465 6d28 7075  }..item::item(pu
    │ │ │ -0006b390: 626c 6963 5f6b 6579 2063 6f6e 7374 2661  blic_key const&a
    │ │ │ -0006b3a0: 6d70 3b20 706b 2c20 7370 616e 266c 743b  mp; pk, span<
    │ │ │ -0006b3b0: 6368 6172 2063 6f6e 7374 2667 743b 2073  char const> s
    │ │ │ -0006b3c0: 616c 7429 0a09 3a20 6d5f 7361 6c74 2873  alt)..: m_salt(s
    │ │ │ -0006b3d0: 616c 742e 6461 7461 2829 2c20 7374 6174  alt.data(), stat
    │ │ │ -0006b3e0: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a  ic_cast<std::
    │ │ │ -0006b3f0: 7369 7a65 5f74 2667 743b 2873 616c 742e  size_t>(salt.
    │ │ │ -0006b400: 7369 7a65 2829 2929 0a09 2c20 6d5f 706b  size())).., m_pk
    │ │ │ -0006b410: 2870 6b29 0a09 2c20 6d5f 6d75 7461 626c  (pk).., m_mutabl
    │ │ │ -0006b420: 6528 7472 7565 290a 7b7d 0a0a 6974 656d  e(true).{}..item
    │ │ │ -0006b430: 3a3a 6974 656d 2865 6e74 7279 2076 290a  ::item(entry v).
    │ │ │ -0006b440: 093a 206d 5f76 616c 7565 2873 7464 3a3a  .: m_value(std::
    │ │ │ -0006b450: 6d6f 7665 2876 2929 0a7b 7d0a 0a69 7465  move(v)).{}..ite
    │ │ │ -0006b460: 6d3a 3a69 7465 6d28 6264 6563 6f64 655f  m::item(bdecode_
    │ │ │ -0006b470: 6e6f 6465 2063 6f6e 7374 2661 6d70 3b20  node const& 
    │ │ │ -0006b480: 7629 0a7b 0a3c 6469 7620 7374 796c 653d  v).{.
    .m_value = v; │ │ │ -0006b4c0: 0a3c 2f64 6976 3e7d 0a0a 6974 656d 3a3a .
    }..item:: │ │ │ -0006b4d0: 6974 656d 2865 6e74 7279 2076 2c20 7370 item(entry v, sp │ │ │ -0006b4e0: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ -0006b4f0: 2667 743b 2073 616c 740a 092c 2073 6571 > salt.., seq │ │ │ -0006b500: 7565 6e63 655f 6e75 6d62 6572 2063 6f6e uence_number con │ │ │ -0006b510: 7374 2073 6571 2c20 7075 626c 6963 5f6b st seq, public_k │ │ │ -0006b520: 6579 2063 6f6e 7374 2661 6d70 3b20 706b ey const& pk │ │ │ -0006b530: 2c20 7365 6372 6574 5f6b 6579 2063 6f6e , secret_key con │ │ │ -0006b540: 7374 2661 6d70 3b20 736b 290a 7b0a 0961 st& sk).{..a │ │ │ -0006b550: 7373 6967 6e28 7374 643a 3a6d 6f76 6528 ssign(std::move( │ │ │ -0006b560: 7629 2c20 7361 6c74 2c20 7365 712c 2070 v), salt, seq, p │ │ │ -0006b570: 6b2c 2073 6b29 3b0a 7d0a 0a76 6f69 6420 k, sk);.}..void │ │ │ -0006b580: 6974 656d 3a3a 6173 7369 676e 2865 6e74 item::assign(ent │ │ │ -0006b590: 7279 2076 290a 7b0a 096d 5f6d 7574 6162 ry v).{..m_mutab │ │ │ -0006b5a0: 6c65 203d 2066 616c 7365 3b0a 096d 5f76 le = false;..m_v │ │ │ -0006b5b0: 616c 7565 203d 2073 7464 3a3a 6d6f 7665 alue = std::move │ │ │ -0006b5c0: 2876 293b 0a7d 0a0a 766f 6964 2069 7465 (v);.}..void ite │ │ │ -0006b5d0: 6d3a 3a61 7373 6967 6e28 656e 7472 7920 m::assign(entry │ │ │ -0006b5e0: 762c 2073 7061 6e26 6c74 3b63 6861 7220 v, span<char │ │ │ -0006b5f0: 636f 6e73 7426 6774 3b20 7361 6c74 0a09 const> salt.. │ │ │ -0006b600: 2c20 7365 7175 656e 6365 5f6e 756d 6265 , sequence_numbe │ │ │ -0006b610: 7220 636f 6e73 7420 7365 712c 2070 7562 r const seq, pub │ │ │ -0006b620: 6c69 635f 6b65 7920 636f 6e73 7426 616d lic_key const&am │ │ │ -0006b630: 703b 2070 6b2c 2073 6563 7265 745f 6b65 p; pk, secret_ke │ │ │ -0006b640: 7920 636f 6e73 7426 616d 703b 2073 6b29 y const& sk) │ │ │ -0006b650: 0a7b 0a09 7374 643a 3a61 7272 6179 266c .{..std::array&l │ │ │ -0006b660: 743b 6368 6172 2c20 3130 3030 2667 743b t;char, 1000> │ │ │ -0006b670: 2062 7566 6665 723b 0a09 696e 7420 636f buffer;..int co │ │ │ -0006b680: 6e73 7420 6273 697a 6520 3d20 6265 6e63 nst bsize = benc │ │ │ -0006b690: 6f64 6528 6275 6666 6572 2e62 6567 696e ode(buffer.begin │ │ │ -0006b6a0: 2829 2c20 7629 3b0a 0954 4f52 5245 4e54 (), v);..TORRENT │ │ │ -0006b6b0: 5f41 5353 4552 5428 6273 697a 6520 266c _ASSERT(bsize &l │ │ │ -0006b6c0: 743b 3d20 3130 3030 293b 0a09 6d5f 7369 t;= 1000);..m_si │ │ │ -0006b6d0: 6720 3d20 7369 676e 5f6d 7574 6162 6c65 g = sign_mutable │ │ │ -0006b6e0: 5f69 7465 6d28 7370 616e 266c 743b 6368 _item(span<ch │ │ │ -0006b6f0: 6172 2063 6f6e 7374 2667 743b 2862 7566 ar const>(buf │ │ │ -0006b700: 6665 7229 2e66 6972 7374 2862 7369 7a65 fer).first(bsize │ │ │ -0006b710: 290a 0909 2c20 7361 6c74 2c20 7365 712c )..., salt, seq, │ │ │ -0006b720: 2070 6b2c 2073 6b29 3b0a 096d 5f73 616c pk, sk);..m_sal │ │ │ -0006b730: 742e 6173 7369 676e 2873 616c 742e 6461 t.assign(salt.da │ │ │ -0006b740: 7461 2829 2c20 7374 6174 6963 5f63 6173 ta(), static_cas │ │ │ -0006b750: 7426 6c74 3b73 7464 3a3a 7369 7a65 5f74 t<std::size_t │ │ │ -0006b760: 2667 743b 2873 616c 742e 7369 7a65 2829 >(salt.size() │ │ │ -0006b770: 2929 3b0a 096d 5f70 6b20 3d20 706b 3b0a ));..m_pk = pk;. │ │ │ -0006b780: 096d 5f73 6571 203d 2073 6571 3b0a 096d .m_seq = seq;..m │ │ │ -0006b790: 5f6d 7574 6162 6c65 203d 2074 7275 653b _mutable = true; │ │ │ -0006b7a0: 0a09 6d5f 7661 6c75 6520 3d20 7374 643a ..m_value = std: │ │ │ -0006b7b0: 3a6d 6f76 6528 7629 3b0a 7d0a 0a76 6f69 :move(v);.}..voi │ │ │ -0006b7c0: 6420 6974 656d 3a3a 6173 7369 676e 2862 d item::assign(b │ │ │ -0006b7d0: 6465 636f 6465 5f6e 6f64 6520 636f 6e73 decode_node cons │ │ │ -0006b7e0: 7426 616d 703b 2076 290a 3c2f 7072 653e t& v).
    │ │ │ -0006b7f0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006b820: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006b830: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/kade │ │ │ -0006b860: 6d6c 6961 2f6e 6f64 655f 6964 2e63 7070 mlia/node_id.cpp │ │ │ -0006b870: 3a34 333c 2f61 3e3c 2f74 643e 3c74 643e :43 │ │ │ -0006b880: 6974 2773 2061 206c 6974 746c 6520 6269 it's a little bi │ │ │ -0006b890: 7420 7765 6972 6420 746f 2072 6574 7572 t weird to retur │ │ │ -0006b8a0: 6e20 3135 3920 2d20 6c65 6164 696e 6720 n 159 - leading │ │ │ -0006b8b0: 7a65 726f 6573 2e20 4974 2073 686f 756c zeroes. It shoul │ │ │ -0006b8c0: 6420 7072 6f62 6162 6c79 2062 6520 3136 d probably be 16 │ │ │ -0006b8d0: 3020 2d20 6c65 6164 696e 6720 7a65 726f 0 - leading zero │ │ │ -0006b8e0: 6573 2c20 6275 7420 616c 6c20 6f74 6865 es, but all othe │ │ │ -0006b8f0: 7220 636f 6465 2069 6e20 6865 7265 2069 r code in here i │ │ │ -0006b900: 7320 7475 6e65 6420 746f 2074 6869 7320 s tuned to this │ │ │ -0006b910: 6578 7065 6374 6174 696f 6e20 6e6f 772c expectation now, │ │ │ -0006b920: 2061 6e64 2069 7420 646f 6573 6e27 7420 and it doesn't │ │ │ -0006b930: 7265 616c 6c79 206d 6174 7465 7220 286f really matter (o │ │ │ -0006b940: 7468 6572 2074 6861 6e20 636f 6d70 6c65 ther than comple │ │ │ -0006b950: 7869 7479 293c 2f74 643e 3c2f 7472 3e3c xity)< │ │ │ -0006b960: 7472 2069 643d 2232 3437 2220 7374 796c tr id="247" styl │ │ │ -0006b970: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0006b980: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0006b990: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0006b9a0: 6832 3e69 7427 7320 6120 6c69 7474 6c65 h2>it's a little │ │ │ -0006b9b0: 2062 6974 2077 6569 7264 2074 6f20 7265 bit weird to re │ │ │ -0006b9c0: 7475 726e 2031 3539 202d 206c 6561 6469 turn 159 - leadi │ │ │ -0006b9d0: 6e67 207a 6572 6f65 732e 2049 7420 7368 ng zeroes. It sh │ │ │ -0006b9e0: 6f75 6c64 0a70 726f 6261 626c 7920 6265 ould.probably be │ │ │ -0006b9f0: 2031 3630 202d 206c 6561 6469 6e67 207a 160 - leading z │ │ │ -0006ba00: 6572 6f65 732c 2062 7574 2061 6c6c 206f eroes, but all o │ │ │ -0006ba10: 7468 6572 2063 6f64 6520 696e 2068 6572 ther code in her │ │ │ -0006ba20: 6520 6973 2074 756e 6564 2074 6f0a 7468 e is tuned to.th │ │ │ -0006ba30: 6973 2065 7870 6563 7461 7469 6f6e 206e is expectation n │ │ │ -0006ba40: 6f77 2c20 616e 6420 6974 2064 6f65 736e ow, and it doesn │ │ │ -0006ba50: 2774 2072 6561 6c6c 7920 6d61 7474 6572 't really matter │ │ │ -0006ba60: 2028 6f74 6865 7220 7468 616e 2063 6f6d (other than com │ │ │ -0006ba70: 706c 6578 6974 7929 3c2f 6832 3e3c 6834 plexity)

    ../src/kademlia │ │ │ -0006ba90: 2f6e 6f64 655f 6964 2e63 7070 3a34 333c /node_id.cpp:43< │ │ │ -0006baa0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ -0006bae0: 2f20 7265 7475 726e 7320 7468 6520 6469  / returns the di
    │ │ │ -0006baf0: 7374 616e 6365 2062 6574 7765 656e 2074  stance between t
    │ │ │ -0006bb00: 6865 2074 776f 206e 6f64 6573 0a2f 2f20  he two nodes.// 
    │ │ │ -0006bb10: 7573 696e 6720 7468 6520 6b61 6465 6d6c  using the kademl
    │ │ │ -0006bb20: 6961 2058 4f52 2d6d 6574 7269 630a 6e6f  ia XOR-metric.no
    │ │ │ -0006bb30: 6465 5f69 6420 6469 7374 616e 6365 286e  de_id distance(n
    │ │ │ -0006bb40: 6f64 655f 6964 2063 6f6e 7374 2661 6d70  ode_id const&
    │ │ │ -0006bb50: 3b20 6e31 2c20 6e6f 6465 5f69 6420 636f  ; n1, node_id co
    │ │ │ -0006bb60: 6e73 7426 616d 703b 206e 3229 0a7b 0a09  nst& n2).{..
    │ │ │ -0006bb70: 7265 7475 726e 206e 3120 5e20 6e32 3b0a  return n1 ^ n2;.
    │ │ │ -0006bb80: 7d0a 0a2f 2f20 7265 7475 726e 7320 7472  }..// returns tr
    │ │ │ -0006bb90: 7565 2069 663a 2064 6973 7461 6e63 6528  ue if: distance(
    │ │ │ -0006bba0: 6e31 2c20 7265 6629 2026 6c74 3b20 6469  n1, ref) < di
    │ │ │ -0006bbb0: 7374 616e 6365 286e 322c 2072 6566 290a  stance(n2, ref).
    │ │ │ -0006bbc0: 626f 6f6c 2063 6f6d 7061 7265 5f72 6566  bool compare_ref
    │ │ │ -0006bbd0: 286e 6f64 655f 6964 2063 6f6e 7374 2661  (node_id const&a
    │ │ │ -0006bbe0: 6d70 3b20 6e31 2c20 6e6f 6465 5f69 6420  mp; n1, node_id 
    │ │ │ -0006bbf0: 636f 6e73 7426 616d 703b 206e 322c 206e  const& n2, n
    │ │ │ -0006bc00: 6f64 655f 6964 2063 6f6e 7374 2661 6d70  ode_id const&
    │ │ │ -0006bc10: 3b20 7265 6629 0a7b 0a09 6e6f 6465 5f69  ; ref).{..node_i
    │ │ │ -0006bc20: 6420 636f 6e73 7420 6c68 7320 3d20 6e31  d const lhs = n1
    │ │ │ -0006bc30: 205e 2072 6566 3b0a 096e 6f64 655f 6964   ^ ref;..node_id
    │ │ │ -0006bc40: 2063 6f6e 7374 2072 6873 203d 206e 3220   const rhs = n2 
    │ │ │ -0006bc50: 5e20 7265 663b 0a09 7265 7475 726e 206c  ^ ref;..return l
    │ │ │ -0006bc60: 6873 2026 6c74 3b20 7268 733b 0a7d 0a0a  hs < rhs;.}..
    │ │ │ -0006bc70: 2f2f 2072 6574 7572 6e73 206e 2069 6e3a  // returns n in:
    │ │ │ -0006bc80: 2032 5e6e 2026 6c74 3b3d 2064 6973 7461   2^n <= dista
    │ │ │ -0006bc90: 6e63 6528 6e31 2c20 6e32 2920 266c 743b  nce(n1, n2) <
    │ │ │ -0006bca0: 2032 5e28 6e2b 3129 0a2f 2f20 7573 6566   2^(n+1).// usef
    │ │ │ -0006bcb0: 756c 2066 6f72 2066 696e 6469 6e67 206f  ul for finding o
    │ │ │ -0006bcc0: 7574 2077 6869 6368 2062 7563 6b65 7420  ut which bucket 
    │ │ │ -0006bcd0: 6120 6e6f 6465 2062 656c 6f6e 6773 2074  a node belongs t
    │ │ │ -0006bce0: 6f0a 696e 7420 6469 7374 616e 6365 5f65  o.int distance_e
    │ │ │ -0006bcf0: 7870 286e 6f64 655f 6964 2063 6f6e 7374  xp(node_id const
    │ │ │ -0006bd00: 2661 6d70 3b20 6e31 2c20 6e6f 6465 5f69  & n1, node_i
    │ │ │ -0006bd10: 6420 636f 6e73 7426 616d 703b 206e 3229  d const& n2)
    │ │ │ -0006bd20: 0a7b 0a3c 6469 7620 7374 796c 653d 2262  .{.
    .return std::ma │ │ │ -0006bd60: 7828 3135 3920 2d20 6469 7374 616e 6365 x(159 - distance │ │ │ -0006bd70: 286e 312c 206e 3229 2e63 6f75 6e74 5f6c (n1, n2).count_l │ │ │ -0006bd80: 6561 6469 6e67 5f7a 6572 6f65 7328 292c eading_zeroes(), │ │ │ -0006bd90: 2030 293b 0a3c 2f64 6976 3e7d 0a0a 696e 0);.
    }..in │ │ │ -0006bda0: 7420 6d69 6e5f 6469 7374 616e 6365 5f65 t min_distance_e │ │ │ -0006bdb0: 7870 286e 6f64 655f 6964 2063 6f6e 7374 xp(node_id const │ │ │ -0006bdc0: 2661 6d70 3b20 6e31 2c20 7374 643a 3a76 & n1, std::v │ │ │ -0006bdd0: 6563 746f 7226 6c74 3b6e 6f64 655f 6964 ector<node_id │ │ │ -0006bde0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ -0006bdf0: 6964 7329 0a7b 0a09 544f 5252 454e 545f ids).{..TORRENT_ │ │ │ -0006be00: 4153 5345 5254 2869 6473 2e73 697a 6528 ASSERT(ids.size( │ │ │ -0006be10: 2920 2667 743b 2030 293b 0a0a 0969 6e74 ) > 0);...int │ │ │ -0006be20: 206d 696e 203d 2031 3630 3b20 2f2f 2073 min = 160; // s │ │ │ -0006be30: 6565 2064 6973 7461 6e63 655f 6578 7020 ee distance_exp │ │ │ -0006be40: 666f 7220 7468 6520 7768 7920 6f66 2074 for the why of t │ │ │ -0006be50: 6869 7320 636f 6e73 7461 6e74 0a09 666f his constant..fo │ │ │ -0006be60: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ -0006be70: 703b 206e 6f64 655f 6964 203a 2069 6473 p; node_id : ids │ │ │ -0006be80: 290a 097b 0a09 096d 696e 203d 2073 7464 )..{...min = std │ │ │ -0006be90: 3a3a 6d69 6e28 6d69 6e2c 2064 6973 7461 ::min(min, dista │ │ │ -0006bea0: 6e63 655f 6578 7028 6e31 2c20 6e6f 6465 nce_exp(n1, node │ │ │ -0006beb0: 5f69 6429 293b 0a09 7d0a 0a09 7265 7475 _id));..}...retu │ │ │ -0006bec0: 726e 206d 696e 3b0a 7d0a 0a6e 6f64 655f rn min;.}..node_ │ │ │ -0006bed0: 6964 2067 656e 6572 6174 655f 6964 5f69 id generate_id_i │ │ │ -0006bee0: 6d70 6c28 6164 6472 6573 7320 636f 6e73 mpl(address cons │ │ │ -0006bef0: 7426 616d 703b 2069 705f 2c20 7374 643a t& ip_, std: │ │ │ -0006bf00: 3a75 696e 7433 325f 7420 7229 0a7b 0a09 :uint32_t r).{.. │ │ │ -0006bf10: 7374 643a 3a75 696e 7438 5f74 2a20 6970 std::uint8_t* ip │ │ │ -0006bf20: 203d 206e 756c 6c70 7472 3b0a 0a09 7374 = nullptr;...st │ │ │ -0006bf30: 6174 6963 2073 7464 3a3a 7569 6e74 385f atic std::uint8_ │ │ │ -0006bf40: 7420 636f 6e73 7420 7634 6d61 736b 5b5d t const v4mask[] │ │ │ -0006bf50: 203d 207b 2030 7830 332c 2030 7830 662c = { 0x03, 0x0f, │ │ │ -0006bf60: 2030 7833 662c 2030 7866 6620 7d3b 0a09 0x3f, 0xff };.. │ │ │ -0006bf70: 7374 6174 6963 2073 7464 3a3a 7569 6e74 static std::uint │ │ │ -0006bf80: 385f 7420 636f 6e73 7420 7636 6d61 736b 8_t const v6mask │ │ │ -0006bf90: 5b5d 203d 207b 2030 7830 312c 2030 7830 [] = { 0x01, 0x0 │ │ │ -0006bfa0: 332c 2030 7830 372c 2030 7830 662c 2030 3, 0x07, 0x0f, 0 │ │ │ -0006bfb0: 7831 662c 2030 7833 662c 2030 7837 662c x1f, 0x3f, 0x7f, │ │ │ -0006bfc0: 2030 7866 6620 7d3b 0a09 7374 643a 3a75 0xff };..std::u │ │ │ -0006bfd0: 696e 7438 5f74 2063 6f6e 7374 2a20 6d61 int8_t const* ma │ │ │ -0006bfe0: 736b 203d 206e 756c 6c70 7472 3b0a 0969 sk = nullptr;..i │ │ │ -0006bff0: 6e74 206e 756d 5f6f 6374 6574 7320 3d20 nt num_octets = │ │ │ -0006c000: 303b 0a0a 0961 6464 7265 7373 5f76 343a 0;...address_v4: │ │ │ -0006c010: 3a62 7974 6573 5f74 7970 6520 6234 7b7d :bytes_type b4{} │ │ │ -0006c020: 3b0a 0961 6464 7265 7373 5f76 363a 3a62 ;..address_v6::b │ │ │ -0006c030: 7974 6573 5f74 7970 6520 6236 7b7d 3b0a ytes_type b6{};. │ │ │ -0006c040: 0969 6620 2869 705f 2e69 735f 7636 2829 .if (ip_.is_v6() │ │ │ -0006c050: 290a 097b 0a09 0962 3620 3d20 6970 5f2e )..{...b6 = ip_. │ │ │ -0006c060: 746f 5f76 3628 292e 746f 5f62 7974 6573 to_v6().to_bytes │ │ │ -0006c070: 2829 3b0a 0909 6970 203d 2062 362e 6461 ();...ip = b6.da │ │ │ -0006c080: 7461 2829 3b0a 3c2f 7072 653e 3c2f 7464 ta();.
    relevance │ │ │ -0006c0c0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0006c0d0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/kademlia │ │ │ -0006c100: 2f70 7574 5f64 6174 612e 6370 703a 3639 /put_data.cpp:69 │ │ │ -0006c110: 3c2f 613e 3c2f 7464 3e3c 7464 3e77 6861 wha │ │ │ -0006c120: 7420 6966 206f 2069 7320 6e6f 7420 616e t if o is not an │ │ │ -0006c130: 2069 6e73 7461 6e63 6520 6f66 2070 7574 instance of put │ │ │ -0006c140: 5f64 6174 615f 6f62 7365 7276 6572 3f20 _data_observer? │ │ │ -0006c150: 5468 6973 206e 6565 6420 746f 2062 6520 This need to be │ │ │ -0006c160: 7265 6465 7369 676e 6564 2066 6f72 2062 redesigned for b │ │ │ -0006c170: 6574 7465 7220 7479 7065 2073 6166 6574 etter type safet │ │ │ -0006c180: 792e 3c2f 7464 3e3c 2f74 723e 3c74 7220 y.

    │ │ │ -0006c1d0: 7768 6174 2069 6620 6f20 6973 206e 6f74 what if o is not │ │ │ -0006c1e0: 2061 6e20 696e 7374 616e 6365 206f 6620 an instance of │ │ │ -0006c1f0: 7075 745f 6461 7461 5f6f 6273 6572 7665 put_data_observe │ │ │ -0006c200: 723f 2054 6869 7320 6e65 6564 2074 6f20 r? This need to │ │ │ -0006c210: 6265 0a72 6564 6573 6967 6e65 6420 666f be.redesigned fo │ │ │ -0006c220: 7220 6265 7474 6572 2074 7970 6520 7361 r better type sa │ │ │ -0006c230: 6665 7479 2e3c 2f68 323e 3c68 343e 2e2e fety.

    .. │ │ │ -0006c240: 2f73 7263 2f6b 6164 656d 6c69 612f 7075 /src/kademlia/pu │ │ │ -0006c250: 745f 6461 7461 2e63 7070 3a36 393c 2f68 t_data.cpp:69
    .}.}
    │ │ │ -0006c2a0: 0a0a 766f 6964 2070 7574 5f64 6174 613a  ..void put_data:
    │ │ │ -0006c2b0: 3a64 6f6e 6528 290a 7b0a 096d 5f64 6f6e  :done().{..m_don
    │ │ │ -0006c2c0: 6520 3d20 7472 7565 3b0a 0a23 6966 6e64  e = true;..#ifnd
    │ │ │ -0006c2d0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -0006c2e0: 4c45 5f4c 4f47 4749 4e47 0a09 6765 745f  LE_LOGGING..get_
    │ │ │ -0006c2f0: 6e6f 6465 2829 2e6f 6273 6572 7665 7228  node().observer(
    │ │ │ -0006c300: 292d 2667 743b 6c6f 6728 6468 745f 6c6f  )->log(dht_lo
    │ │ │ -0006c310: 6767 6572 3a3a 7472 6176 6572 7361 6c2c  gger::traversal,
    │ │ │ -0006c320: 2022 5b25 755d 2025 7320 444f 4e45 2c20   "[%u] %s DONE, 
    │ │ │ -0006c330: 7265 7370 6f6e 7365 2025 642c 2074 696d  response %d, tim
    │ │ │ -0006c340: 656f 7574 2025 6422 0a09 092c 2069 6428  eout %d"..., id(
    │ │ │ -0006c350: 292c 206e 616d 6528 292c 206e 756d 5f72  ), name(), num_r
    │ │ │ -0006c360: 6573 706f 6e73 6573 2829 2c20 6e75 6d5f  esponses(), num_
    │ │ │ -0006c370: 7469 6d65 6f75 7473 2829 293b 0a23 656e  timeouts());.#en
    │ │ │ -0006c380: 6469 660a 0a09 6d5f 7075 745f 6361 6c6c  dif...m_put_call
    │ │ │ -0006c390: 6261 636b 286d 5f64 6174 612c 206e 756d  back(m_data, num
    │ │ │ -0006c3a0: 5f72 6573 706f 6e73 6573 2829 293b 0a09  _responses());..
    │ │ │ -0006c3b0: 7472 6176 6572 7361 6c5f 616c 676f 7269  traversal_algori
    │ │ │ -0006c3c0: 7468 6d3a 3a64 6f6e 6528 293b 0a7d 0a0a  thm::done();.}..
    │ │ │ -0006c3d0: 626f 6f6c 2070 7574 5f64 6174 613a 3a69  bool put_data::i
    │ │ │ -0006c3e0: 6e76 6f6b 6528 6f62 7365 7276 6572 5f70  nvoke(observer_p
    │ │ │ -0006c3f0: 7472 206f 290a 7b0a 0969 6620 286d 5f64  tr o).{..if (m_d
    │ │ │ -0006c400: 6f6e 6529 2072 6574 7572 6e20 6661 6c73  one) return fals
    │ │ │ -0006c410: 653b 0a0a 3c64 6976 2073 7479 6c65 3d22  e;..
    .auto* po = st │ │ │ -0006c450: 6174 6963 5f63 6173 7426 6c74 3b70 7574 atic_cast<put │ │ │ -0006c460: 5f64 6174 615f 6f62 7365 7276 6572 2a26 _data_observer*& │ │ │ -0006c470: 6774 3b28 6f2e 6765 7428 2929 3b0a 3c2f gt;(o.get());...entry e;.. │ │ │ -0006c490: 655b 2279 225d 203d 2022 7122 3b0a 0965 e["y"] = "q";..e │ │ │ -0006c4a0: 5b22 7122 5d20 3d20 2270 7574 223b 0a09 ["q"] = "put";.. │ │ │ -0006c4b0: 656e 7472 7926 616d 703b 2061 203d 2065 entry& a = e │ │ │ -0006c4c0: 5b22 6122 5d3b 0a09 615b 2276 225d 203d ["a"];..a["v"] = │ │ │ -0006c4d0: 206d 5f64 6174 612e 7661 6c75 6528 293b m_data.value(); │ │ │ -0006c4e0: 0a09 615b 2274 6f6b 656e 225d 203d 2070 ..a["token"] = p │ │ │ -0006c4f0: 6f2d 2667 743b 6d5f 746f 6b65 6e3b 0a09 o->m_token;.. │ │ │ -0006c500: 6966 2028 6d5f 6461 7461 2e69 735f 6d75 if (m_data.is_mu │ │ │ -0006c510: 7461 626c 6528 2929 0a09 7b0a 0909 615b table())..{...a[ │ │ │ -0006c520: 226b 225d 203d 206d 5f64 6174 612e 706b "k"] = m_data.pk │ │ │ -0006c530: 2829 2e62 7974 6573 3b0a 0909 615b 2273 ().bytes;...a["s │ │ │ -0006c540: 6571 225d 203d 206d 5f64 6174 612e 7365 eq"] = m_data.se │ │ │ -0006c550: 7128 292e 7661 6c75 653b 0a09 0961 5b22 q().value;...a[" │ │ │ -0006c560: 7369 6722 5d20 3d20 6d5f 6461 7461 2e73 sig"] = m_data.s │ │ │ -0006c570: 6967 2829 2e62 7974 6573 3b0a 0909 6966 ig().bytes;...if │ │ │ -0006c580: 2028 216d 5f64 6174 612e 7361 6c74 2829 (!m_data.salt() │ │ │ -0006c590: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ -0006c5a0: 0961 5b22 7361 6c74 225d 203d 206d 5f64 .a["salt"] = m_d │ │ │ -0006c5b0: 6174 612e 7361 6c74 2829 3b0a 0909 7d0a ata.salt();...}. │ │ │ -0006c5c0: 097d 0a0a 096d 5f6e 6f64 652e 7374 6174 .}...m_node.stat │ │ │ -0006c5d0: 735f 636f 756e 7465 7273 2829 2e69 6e63 s_counters().inc │ │ │ -0006c5e0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ -0006c5f0: 6f75 6e74 6572 733a 3a64 6874 5f70 7574 ounters::dht_put │ │ │ -0006c600: 5f6f 7574 293b 0a0a 0972 6574 7572 6e20 _out);...return │ │ │ -0006c610: 6d5f 6e6f 6465 2e6d 5f72 7063 2e69 6e76 m_node.m_rpc.inv │ │ │ -0006c620: 6f6b 6528 652c 206f 2d26 6774 3b74 6172 oke(e, o->tar │ │ │ -0006c630: 6765 745f 6570 2829 2c20 6f29 3b0a 7d0a get_ep(), o);.}. │ │ │ -0006c640: 0a7d 207d 202f 2f20 6e61 6d65 7370 6163 .} } // namespac │ │ │ -0006c650: 6520 6c69 6274 6f72 7265 6e74 3a3a 6468 e libtorrent::dh │ │ │ -0006c660: 740a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 t.
    < │ │ │ -0006c690: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006c6a0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006c6d0: 7372 632f 6b61 6465 6d6c 6961 2f72 6f75 src/kademlia/rou │ │ │ -0006c6e0: 7469 6e67 5f74 6162 6c65 2e63 7070 3a32 ting_table.cpp:2 │ │ │ -0006c6f0: 3634 3c2f 613e 3c2f 7464 3e3c 7464 3e54 64T │ │ │ -0006c700: 6869 7320 6973 2074 656d 706f 7261 7279 his is temporary │ │ │ -0006c710: 2e20 466f 7220 6e6f 772c 206f 6e6c 7920 . For now, only │ │ │ -0006c720: 7265 706f 7274 2074 6865 206c 6172 6765 report the large │ │ │ -0006c730: 7374 2072 6f75 7469 6e67 2074 6162 6c65 st routing table │ │ │ -0006c740: 2028 6f66 2070 6f74 656e 7469 616c 6c79 (of potentially │ │ │ -0006c750: 206d 756c 7469 706c 6520 6f6e 6573 2c20 multiple ones, │ │ │ -0006c760: 666f 7220 6d75 6c74 692d 686f 6d65 6420 for multi-homed │ │ │ -0006c770: 7379 7374 656d 7329 2069 6e20 6e65 7874 systems) in next │ │ │ -0006c780: 206d 616a 6f72 2076 6572 7369 6f6e 2c20 major version, │ │ │ -0006c790: 6272 6561 6b20 7468 6520 4142 4920 616e break the ABI an │ │ │ -0006c7a0: 6420 7375 7070 6f72 7420 7265 706f 7274 d support report │ │ │ -0006c7b0: 696e 6720 616c 6c20 6f66 2074 6865 6d20 ing all of them │ │ │ -0006c7c0: 696e 2074 6865 2064 6874 5f73 7461 7473 in the dht_stats │ │ │ -0006c7d0: 5f61 6c65 7274 3c2f 7464 3e3c 2f74 723e _alert │ │ │ -0006c7e0: 3c74 7220 6964 3d22 3234 3922 2073 7479 │ │ │ -0006c810: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006c820: 3c68 323e 5468 6973 2069 7320 7465 6d70

    This is temp │ │ │ -0006c830: 6f72 6172 792e 2046 6f72 206e 6f77 2c20 orary. For now, │ │ │ -0006c840: 6f6e 6c79 2072 6570 6f72 7420 7468 6520 only report the │ │ │ -0006c850: 6c61 7267 6573 7420 726f 7574 696e 6720 largest routing │ │ │ -0006c860: 7461 626c 650a 286f 6620 706f 7465 6e74 table.(of potent │ │ │ -0006c870: 6961 6c6c 7920 6d75 6c74 6970 6c65 206f ially multiple o │ │ │ -0006c880: 6e65 732c 2066 6f72 206d 756c 7469 2d68 nes, for multi-h │ │ │ -0006c890: 6f6d 6564 2073 7973 7465 6d73 290a 696e omed systems).in │ │ │ -0006c8a0: 206e 6578 7420 6d61 6a6f 7220 7665 7273 next major vers │ │ │ -0006c8b0: 696f 6e2c 2062 7265 616b 2074 6865 2041 ion, break the A │ │ │ -0006c8c0: 4249 2061 6e64 2073 7570 706f 7274 2072 BI and support r │ │ │ -0006c8d0: 6570 6f72 7469 6e67 2061 6c6c 206f 6620 eporting all of │ │ │ -0006c8e0: 7468 656d 2069 6e0a 7468 6520 6468 745f them in.the dht_ │ │ │ -0006c8f0: 7374 6174 735f 616c 6572 743c 2f68 323e stats_alert

    │ │ │ -0006c900: 3c68 343e 2e2e 2f73 7263 2f6b 6164 656d

    ../src/kadem │ │ │ -0006c910: 6c69 612f 726f 7574 696e 675f 7461 626c lia/routing_tabl │ │ │ -0006c920: 652e 6370 703a 3236 343c 2f68 343e 3c70 e.cpp:264

    ., m_buc │ │ │ -0006c970: 6b65 745f 7369 7a65 2862 7563 6b65 745f ket_size(bucket_ │ │ │ -0006c980: 7369 7a65 290a 7b0a 092f 2f20 6275 636b size).{..// buck │ │ │ -0006c990: 6574 2073 697a 6573 206d 7573 7420 6265 et sizes must be │ │ │ -0006c9a0: 2061 2070 6f77 6572 206f 6620 320a 0954 a power of 2..T │ │ │ -0006c9b0: 4f52 5245 4e54 5f41 5353 4552 545f 5641 ORRENT_ASSERT_VA │ │ │ -0006c9c0: 4c28 2828 6275 636b 6574 5f73 697a 6520 L(((bucket_size │ │ │ -0006c9d0: 2d20 3129 2026 616d 703b 2062 7563 6b65 - 1) & bucke │ │ │ -0006c9e0: 745f 7369 7a65 2920 3d3d 2030 2c20 6275 t_size) == 0, bu │ │ │ -0006c9f0: 636b 6574 5f73 697a 6529 3b0a 0954 4f52 cket_size);..TOR │ │ │ -0006ca00: 5245 4e54 5f55 4e55 5345 4428 6c6f 6729 RENT_UNUSED(log) │ │ │ -0006ca10: 3b0a 096d 5f62 7563 6b65 7473 2e72 6573 ;..m_buckets.res │ │ │ -0006ca20: 6572 7665 2833 3029 3b0a 7d0a 0a69 6e74 erve(30);.}..int │ │ │ -0006ca30: 2072 6f75 7469 6e67 5f74 6162 6c65 3a3a routing_table:: │ │ │ -0006ca40: 6275 636b 6574 5f6c 696d 6974 2869 6e74 bucket_limit(int │ │ │ -0006ca50: 2062 7563 6b65 7429 2063 6f6e 7374 0a7b bucket) const.{ │ │ │ -0006ca60: 0a09 6966 2028 216d 5f73 6574 7469 6e67 ..if (!m_setting │ │ │ -0006ca70: 732e 6765 745f 626f 6f6c 2873 6574 7469 s.get_bool(setti │ │ │ -0006ca80: 6e67 735f 7061 636b 3a3a 6468 745f 6578 ngs_pack::dht_ex │ │ │ -0006ca90: 7465 6e64 6564 5f72 6f75 7469 6e67 5f74 tended_routing_t │ │ │ -0006caa0: 6162 6c65 2929 2072 6574 7572 6e20 6d5f able)) return m_ │ │ │ -0006cab0: 6275 636b 6574 5f73 697a 653b 0a0a 0973 bucket_size;...s │ │ │ -0006cac0: 7461 7469 6320 636f 6e73 7420 6175 783a tatic const aux: │ │ │ -0006cad0: 3a61 7272 6179 266c 743b 696e 742c 2034 :array<int, 4 │ │ │ -0006cae0: 2667 743b 2073 697a 655f 6578 6365 7074 > size_except │ │ │ -0006caf0: 696f 6e73 7b7b 7b31 362c 2038 2c20 342c ions{{{16, 8, 4, │ │ │ -0006cb00: 2032 7d7d 7d3b 0a09 6966 2028 6275 636b 2}}};..if (buck │ │ │ -0006cb10: 6574 2026 6c74 3b20 7369 7a65 5f65 7863 et < size_exc │ │ │ -0006cb20: 6570 7469 6f6e 732e 656e 645f 696e 6465 eptions.end_inde │ │ │ -0006cb30: 7828 2929 0a09 0972 6574 7572 6e20 6d5f x())...return m_ │ │ │ -0006cb40: 6275 636b 6574 5f73 697a 6520 2a20 7369 bucket_size * si │ │ │ -0006cb50: 7a65 5f65 7863 6570 7469 6f6e 735b 6275 ze_exceptions[bu │ │ │ -0006cb60: 636b 6574 5d3b 0a09 7265 7475 726e 206d cket];..return m │ │ │ -0006cb70: 5f62 7563 6b65 745f 7369 7a65 3b0a 7d0a _bucket_size;.}. │ │ │ -0006cb80: 0a76 6f69 6420 726f 7574 696e 675f 7461 .void routing_ta │ │ │ -0006cb90: 626c 653a 3a73 7461 7475 7328 7374 643a ble::status(std: │ │ │ -0006cba0: 3a76 6563 746f 7226 6c74 3b64 6874 5f72 :vector<dht_r │ │ │ -0006cbb0: 6f75 7469 6e67 5f62 7563 6b65 7426 6774 outing_bucket> │ │ │ -0006cbc0: 3b26 616d 703b 2073 2920 636f 6e73 740a ;& s) const. │ │ │ -0006cbd0: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261 {.

    │ │ │ -0006cc00: 0969 6620 2873 2e73 697a 6528 2920 2667 .if (s.size() &g │ │ │ -0006cc10: 743b 206d 5f62 7563 6b65 7473 2e73 697a t; m_buckets.siz │ │ │ -0006cc20: 6528 2929 2072 6574 7572 6e3b 0a3c 2f64 e()) return;..s.clear();.. │ │ │ -0006cc40: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ -0006cc50: 616d 703b 2069 203a 206d 5f62 7563 6b65 amp; i : m_bucke │ │ │ -0006cc60: 7473 290a 097b 0a09 0964 6874 5f72 6f75 ts)..{...dht_rou │ │ │ -0006cc70: 7469 6e67 5f62 7563 6b65 7420 623b 0a09 ting_bucket b;.. │ │ │ -0006cc80: 0962 2e6e 756d 5f6e 6f64 6573 203d 2069 .b.num_nodes = i │ │ │ -0006cc90: 6e74 2869 2e6c 6976 655f 6e6f 6465 732e nt(i.live_nodes. │ │ │ -0006cca0: 7369 7a65 2829 293b 0a09 0962 2e6e 756d size());...b.num │ │ │ -0006ccb0: 5f72 6570 6c61 6365 6d65 6e74 7320 3d20 _replacements = │ │ │ -0006ccc0: 696e 7428 692e 7265 706c 6163 656d 656e int(i.replacemen │ │ │ -0006ccd0: 7473 2e73 697a 6528 2929 3b0a 0909 732e ts.size());...s. │ │ │ -0006cce0: 7075 7368 5f62 6163 6b28 6229 3b0a 097d push_back(b);..} │ │ │ -0006ccf0: 0a7d 0a0a 2369 6620 544f 5252 454e 545f .}..#if TORRENT_ │ │ │ -0006cd00: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ -0006cd10: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -0006cd50: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0006cd80: 7263 2f6b 6164 656d 6c69 612f 726f 7574 rc/kademlia/rout │ │ │ -0006cd90: 696e 675f 7461 626c 652e 6370 703a 3238 ing_table.cpp:28 │ │ │ -0006cda0: 363c 2f61 3e3c 2f74 643e 3c74 643e 6172 6ar │ │ │ -0006cdb0: 7669 646e 206e 6f74 6520 7768 656e 2069 vidn note when i │ │ │ -0006cdc0: 7427 7320 6163 726f 7373 2049 5076 3420 t's across IPv4 │ │ │ -0006cdd0: 616e 6420 4950 7636 2c20 6164 6469 6e67 and IPv6, adding │ │ │ -0006cde0: 2028 6468 745f 676c 6f62 616c 5f6e 6f64 (dht_global_nod │ │ │ -0006cdf0: 6573 2920 776f 756c 6420 6d61 6b65 2073 es) would make s │ │ │ -0006ce00: 656e 7365 2e20 696e 2074 6865 2066 7574 ense. in the fut │ │ │ -0006ce10: 7572 6520 7468 6f75 6768 2c20 7768 6572 ure though, wher │ │ │ -0006ce20: 6520 7765 206d 6179 2068 6176 6520 6f6e e we may have on │ │ │ -0006ce30: 6520 4448 5420 6e6f 6465 2070 6572 2065 e DHT node per e │ │ │ -0006ce40: 7874 6572 6e61 6c20 696e 7465 7266 6163 xternal interfac │ │ │ -0006ce50: 6520 2877 6869 6368 206d 6179 2062 6520 e (which may be │ │ │ -0006ce60: 6d75 6c74 6970 6c65 206f 6620 7468 6520 multiple of the │ │ │ -0006ce70: 7361 6d65 2061 6464 7265 7373 2066 616d same address fam │ │ │ -0006ce80: 696c 7929 2c20 7468 656e 2069 7420 6265 ily), then it be │ │ │ -0006ce90: 636f 6d65 7320 6120 6269 7420 7472 6963 comes a bit tric │ │ │ -0006cea0: 6b69 6572 3c2f 7464 3e3c 2f74 723e 3c74 kierarvidn note.wh │ │ │ -0006cf00: 656e 2069 7427 7320 6163 726f 7373 2049 en it's across I │ │ │ -0006cf10: 5076 3420 616e 6420 4950 7636 2c20 6164 Pv4 and IPv6, ad │ │ │ -0006cf20: 6469 6e67 2028 6468 745f 676c 6f62 616c ding (dht_global │ │ │ -0006cf30: 5f6e 6f64 6573 2920 776f 756c 640a 6d61 _nodes) would.ma │ │ │ -0006cf40: 6b65 2073 656e 7365 2e20 696e 2074 6865 ke sense. in the │ │ │ -0006cf50: 2066 7574 7572 6520 7468 6f75 6768 2c20 future though, │ │ │ -0006cf60: 7768 6572 6520 7765 206d 6179 2068 6176 where we may hav │ │ │ -0006cf70: 6520 6f6e 6520 4448 5420 6e6f 6465 0a70 e one DHT node.p │ │ │ -0006cf80: 6572 2065 7874 6572 6e61 6c20 696e 7465 er external inte │ │ │ -0006cf90: 7266 6163 6520 2877 6869 6368 206d 6179 rface (which may │ │ │ -0006cfa0: 2062 6520 6d75 6c74 6970 6c65 206f 6620 be multiple of │ │ │ -0006cfb0: 7468 6520 7361 6d65 2061 6464 7265 7373 the same address │ │ │ -0006cfc0: 0a66 616d 696c 7929 2c20 7468 656e 2069 .family), then i │ │ │ -0006cfd0: 7420 6265 636f 6d65 7320 6120 6269 7420 t becomes a bit │ │ │ -0006cfe0: 7472 6963 6b69 6572 3c2f 6832 3e3c 6834 trickier

    ../src/kademlia │ │ │ -0006d000: 2f72 6f75 7469 6e67 5f74 6162 6c65 2e63 /routing_table.c │ │ │ -0006d010: 7070 3a32 3836 3c2f 6834 3e3c 7072 6520 pp:286

    .void routi
    │ │ │ -0006d060: 6e67 5f74 6162 6c65 3a3a 7374 6174 7573  ng_table::status
    │ │ │ -0006d070: 2873 7464 3a3a 7665 6374 6f72 266c 743b  (std::vector<
    │ │ │ -0006d080: 6468 745f 726f 7574 696e 675f 6275 636b  dht_routing_buck
    │ │ │ -0006d090: 6574 2667 743b 2661 6d70 3b20 7329 2063  et>& s) c
    │ │ │ -0006d0a0: 6f6e 7374 0a7b 0a09 6966 2028 732e 7369  onst.{..if (s.si
    │ │ │ -0006d0b0: 7a65 2829 2026 6774 3b20 6d5f 6275 636b  ze() > m_buck
    │ │ │ -0006d0c0: 6574 732e 7369 7a65 2829 2920 7265 7475  ets.size()) retu
    │ │ │ -0006d0d0: 726e 3b0a 0973 2e63 6c65 6172 2829 3b0a  rn;..s.clear();.
    │ │ │ -0006d0e0: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ -0006d0f0: 2661 6d70 3b20 6920 3a20 6d5f 6275 636b  & i : m_buck
    │ │ │ -0006d100: 6574 7329 0a09 7b0a 0909 6468 745f 726f  ets)..{...dht_ro
    │ │ │ -0006d110: 7574 696e 675f 6275 636b 6574 2062 3b0a  uting_bucket b;.
    │ │ │ -0006d120: 0909 622e 6e75 6d5f 6e6f 6465 7320 3d20  ..b.num_nodes = 
    │ │ │ -0006d130: 696e 7428 692e 6c69 7665 5f6e 6f64 6573  int(i.live_nodes
    │ │ │ -0006d140: 2e73 697a 6528 2929 3b0a 0909 622e 6e75  .size());...b.nu
    │ │ │ -0006d150: 6d5f 7265 706c 6163 656d 656e 7473 203d  m_replacements =
    │ │ │ -0006d160: 2069 6e74 2869 2e72 6570 6c61 6365 6d65   int(i.replaceme
    │ │ │ -0006d170: 6e74 732e 7369 7a65 2829 293b 0a09 0973  nts.size());...s
    │ │ │ -0006d180: 2e70 7573 685f 6261 636b 2862 293b 0a09  .push_back(b);..
    │ │ │ -0006d190: 7d0a 7d0a 0a23 6966 2054 4f52 5245 4e54  }.}..#if TORRENT
    │ │ │ -0006d1a0: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20  _ABI_VERSION == 
    │ │ │ -0006d1b0: 310a 766f 6964 2072 6f75 7469 6e67 5f74  1.void routing_t
    │ │ │ -0006d1c0: 6162 6c65 3a3a 7374 6174 7573 2873 6573  able::status(ses
    │ │ │ -0006d1d0: 7369 6f6e 5f73 7461 7475 7326 616d 703b  sion_status&
    │ │ │ -0006d1e0: 2073 2920 636f 6e73 740a 7b0a 0961 7574   s) const.{..aut
    │ │ │ -0006d1f0: 6f20 636f 6e73 7420 5b64 6874 5f6e 6f64  o const [dht_nod
    │ │ │ -0006d200: 6573 2c20 6468 745f 6e6f 6465 5f63 6163  es, dht_node_cac
    │ │ │ -0006d210: 6865 2c20 6967 6e6f 7265 5d20 3d20 7369  he, ignore] = si
    │ │ │ -0006d220: 7a65 2829 3b0a 0973 2e64 6874 5f6e 6f64  ze();..s.dht_nod
    │ │ │ -0006d230: 6573 202b 3d20 6468 745f 6e6f 6465 733b  es += dht_nodes;
    │ │ │ -0006d240: 0a09 732e 6468 745f 6e6f 6465 5f63 6163  ..s.dht_node_cac
    │ │ │ -0006d250: 6865 202b 3d20 6468 745f 6e6f 6465 5f63  he += dht_node_c
    │ │ │ -0006d260: 6163 6865 3b0a 3c64 6976 2073 7479 6c65  ache;.
    .s.dht_globa │ │ │ -0006d2a0: 6c5f 6e6f 6465 7320 2b3d 206e 756d 5f67 l_nodes += num_g │ │ │ -0006d2b0: 6c6f 6261 6c5f 6e6f 6465 7328 293b 0a3c lobal_nodes();.< │ │ │ -0006d2c0: 2f64 6976 3e0a 0966 6f72 2028 6175 746f /div>..for (auto │ │ │ -0006d2d0: 2063 6f6e 7374 2661 6d70 3b20 6920 3a20 const& i : │ │ │ -0006d2e0: 6d5f 6275 636b 6574 7329 0a09 7b0a 0909 m_buckets)..{... │ │ │ -0006d2f0: 6468 745f 726f 7574 696e 675f 6275 636b dht_routing_buck │ │ │ -0006d300: 6574 2062 3b0a 0909 622e 6e75 6d5f 6e6f et b;...b.num_no │ │ │ -0006d310: 6465 7320 3d20 696e 7428 692e 6c69 7665 des = int(i.live │ │ │ -0006d320: 5f6e 6f64 6573 2e73 697a 6528 2929 3b0a _nodes.size());. │ │ │ -0006d330: 0909 622e 6e75 6d5f 7265 706c 6163 656d ..b.num_replacem │ │ │ -0006d340: 656e 7473 203d 2069 6e74 2869 2e72 6570 ents = int(i.rep │ │ │ -0006d350: 6c61 6365 6d65 6e74 732e 7369 7a65 2829 lacements.size() │ │ │ -0006d360: 293b 0a09 0962 2e6c 6173 745f 6163 7469 );...b.last_acti │ │ │ -0006d370: 7665 203d 2030 3b0a 0909 732e 6468 745f ve = 0;...s.dht_ │ │ │ -0006d380: 726f 7574 696e 675f 7461 626c 652e 7075 routing_table.pu │ │ │ -0006d390: 7368 5f62 6163 6b28 6229 3b0a 097d 0a7d sh_back(b);..}.} │ │ │ -0006d3a0: 0a23 656e 6469 660a 0a73 7464 3a3a 7475 .#endif..std::tu │ │ │ -0006d3b0: 706c 6526 6c74 3b69 6e74 2c20 696e 742c ple<int, int, │ │ │ -0006d3c0: 2069 6e74 2667 743b 2072 6f75 7469 6e67 int> routing │ │ │ -0006d3d0: 5f74 6162 6c65 3a3a 7369 7a65 2829 2063 _table::size() c │ │ │ -0006d3e0: 6f6e 7374 0a7b 0a09 696e 7420 6e6f 6465 onst.{..int node │ │ │ -0006d3f0: 7320 3d20 303b 0a09 696e 7420 7265 706c s = 0;..int repl │ │ │ -0006d400: 6163 656d 656e 7473 203d 2030 3b0a 0969 acements = 0;..i │ │ │ -0006d410: 6e74 2063 6f6e 6669 726d 6564 203d 2030 nt confirmed = 0 │ │ │ -0006d420: 3b0a 0966 6f72 2028 6175 746f 2063 6f6e ;..for (auto con │ │ │ -0006d430: 7374 2661 6d70 3b20 6920 3a20 6d5f 6275 st& i : m_bu │ │ │ -0006d440: 636b 6574 7329 0a09 7b0a 0909 6e6f 6465 ckets)..{...node │ │ │ -0006d450: 7320 2b3d 2069 6e74 2869 2e6c 6976 655f s += int(i.live_ │ │ │ -0006d460: 6e6f 6465 732e 7369 7a65 2829 293b 0a09 nodes.size());.. │ │ │ -0006d470: 0963 6f6e 6669 726d 6564 202b 3d20 7374 .confirmed += st │ │ │ -0006d480: 6174 6963 5f63 6173 7426 6c74 3b69 6e74 atic_cast<int │ │ │ -0006d490: 2667 743b 2873 7464 3a3a 636f 756e 745f >(std::count_ │ │ │ -0006d4a0: 6966 2869 2e6c 6976 655f 6e6f 6465 732e if(i.live_nodes. │ │ │ -0006d4b0: 6265 6769 6e28 292c 2069 2e6c 6976 655f begin(), i.live_ │ │ │ -0006d4c0: 6e6f 6465 732e 656e 6428 290a 0909 092c nodes.end()...., │ │ │ -0006d4d0: 205b 5d28 6e6f 6465 5f65 6e74 7279 2063 [](node_entry c │ │ │ -0006d4e0: 6f6e 7374 2661 6d70 3b20 6b29 207b 2072 onst& k) { r │ │ │ -0006d4f0: 6574 7572 6e20 6b2e 636f 6e66 6972 6d65 eturn k.confirme │ │ │ -0006d500: 6428 293b 207d 2029 293b 0a0a 0909 7265 d(); } ));....re │ │ │ -0006d510: 706c 6163 656d 656e 7473 202b 3d20 696e placements += in │ │ │ -0006d520: 7428 692e 7265 706c 6163 656d 656e 7473 t(i.replacements │ │ │ -0006d530: 2e73 697a 6528 2929 3b0a 097d 0a09 7265 .size());..}..re │ │ │ -0006d540: 7475 726e 2073 7464 3a3a 6d61 6b65 5f74 turn std::make_t │ │ │ -0006d550: 7570 6c65 286e 6f64 6573 2c20 7265 706c uple(nodes, repl │ │ │ -0006d560: 6163 656d 656e 7473 2c20 636f 6e66 6972 acements, confir │ │ │ -0006d570: 6d65 6429 3b0a 7d0a 0a73 7464 3a3a 696e med);.}..std::in │ │ │ -0006d580: 7436 345f 7420 726f 7574 696e 675f 7461 t64_t routing_ta │ │ │ -0006d590: 626c 653a 3a6e 756d 5f67 6c6f 6261 6c5f ble::num_global_ │ │ │ -0006d5a0: 6e6f 6465 7328 2920 636f 6e73 740a 7b0a nodes() const.{. │ │ │ -0006d5b0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0006d5c0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006d5f0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0006d620: 632f 6b61 6465 6d6c 6961 2f72 6f75 7469 c/kademlia/routi │ │ │ -0006d630: 6e67 5f74 6162 6c65 2e63 7070 3a34 3838 ng_table.cpp:488 │ │ │ -0006d640: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ -0006d650: 7320 6e65 6564 2074 6f20 7461 6b65 2062 s need to take b │ │ │ -0006d660: 7563 6b65 7420 2270 7265 6669 7822 2069 ucket "prefix" i │ │ │ -0006d670: 6e74 6f20 6163 636f 756e 742e 2049 7420 nto account. It │ │ │ -0006d680: 7368 6f75 6c64 2062 6520 756e 6966 6965 should be unifie │ │ │ -0006d690: 6420 7769 7468 2061 6464 5f6e 6f64 655f d with add_node_ │ │ │ -0006d6a0: 696d 706c 2829 3c2f 7464 3e3c 2f74 723e impl() │ │ │ -0006d6b0: 3c74 7220 6964 3d22 3235 3122 2073 7479 │ │ │ -0006d6e0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006d6f0: 3c68 323e 7468 6973 206e 6565 6420 746f

    this need to │ │ │ -0006d700: 2074 616b 6520 6275 636b 6574 2022 7072 take bucket "pr │ │ │ -0006d710: 6566 6978 2220 696e 746f 2061 6363 6f75 efix" into accou │ │ │ -0006d720: 6e74 2e20 4974 2073 686f 756c 6420 6265 nt. It should be │ │ │ -0006d730: 2075 6e69 6669 6564 0a77 6974 6820 6164 unified.with ad │ │ │ -0006d740: 645f 6e6f 6465 5f69 6d70 6c28 293c 2f68 d_node_impl()

    ../src/kad │ │ │ -0006d760: 656d 6c69 612f 726f 7574 696e 675f 7461 emlia/routing_ta │ │ │ -0006d770: 626c 652e 6370 703a 3438 383c 2f68 343e ble.cpp:488

    │ │ │ -0006d780: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    {..for
    │ │ │ -0006d7c0: 2028 6175 746f 2069 203d 206d 5f62 7563   (auto i = m_buc
    │ │ │ -0006d7d0: 6b65 7473 2e62 6567 696e 2829 202c 2065  kets.begin() , e
    │ │ │ -0006d7e0: 6e64 286d 5f62 7563 6b65 7473 2e65 6e64  nd(m_buckets.end
    │ │ │ -0006d7f0: 2829 293b 2069 2021 3d20 656e 643b 202b  ()); i != end; +
    │ │ │ -0006d800: 2b69 290a 097b 0a09 0966 6f72 2028 6175  +i)..{...for (au
    │ │ │ -0006d810: 746f 206a 203d 2069 2d26 6774 3b72 6570  to j = i->rep
    │ │ │ -0006d820: 6c61 6365 6d65 6e74 732e 6265 6769 6e28  lacements.begin(
    │ │ │ -0006d830: 293b 206a 2021 3d20 692d 2667 743b 7265  ); j != i->re
    │ │ │ -0006d840: 706c 6163 656d 656e 7473 2e65 6e64 2829  placements.end()
    │ │ │ -0006d850: 3b20 2b2b 6a29 0a09 097b 0a09 0909 6966  ; ++j)...{....if
    │ │ │ -0006d860: 2028 6a2d 2667 743b 6164 6472 2829 2021   (j->addr() !
    │ │ │ -0006d870: 3d20 6570 2e61 6464 7265 7373 2829 2920  = ep.address()) 
    │ │ │ -0006d880: 636f 6e74 696e 7565 3b0a 0909 0969 6620  continue;....if 
    │ │ │ -0006d890: 286a 2d26 6774 3b70 6f72 7428 2920 213d  (j->port() !=
    │ │ │ -0006d8a0: 2065 702e 706f 7274 2829 2920 636f 6e74   ep.port()) cont
    │ │ │ -0006d8b0: 696e 7565 3b0a 0909 0972 6574 7572 6e20  inue;....return 
    │ │ │ -0006d8c0: 7374 643a 3a6d 616b 655f 7475 706c 6528  std::make_tuple(
    │ │ │ -0006d8d0: 2661 6d70 3b2a 6a2c 2069 2c20 2661 6d70  &*j, i, &
    │ │ │ -0006d8e0: 3b69 2d26 6774 3b72 6570 6c61 6365 6d65  ;i->replaceme
    │ │ │ -0006d8f0: 6e74 7329 3b0a 0909 7d0a 0909 666f 7220  nts);...}...for 
    │ │ │ -0006d900: 2861 7574 6f20 6a20 3d20 692d 2667 743b  (auto j = i->
    │ │ │ -0006d910: 6c69 7665 5f6e 6f64 6573 2e62 6567 696e  live_nodes.begin
    │ │ │ -0006d920: 2829 3b20 6a20 213d 2069 2d26 6774 3b6c  (); j != i->l
    │ │ │ -0006d930: 6976 655f 6e6f 6465 732e 656e 6428 293b  ive_nodes.end();
    │ │ │ -0006d940: 202b 2b6a 290a 0909 7b0a 0909 0969 6620   ++j)...{....if 
    │ │ │ -0006d950: 286a 2d26 6774 3b61 6464 7228 2920 213d  (j->addr() !=
    │ │ │ -0006d960: 2065 702e 6164 6472 6573 7328 2929 2063   ep.address()) c
    │ │ │ -0006d970: 6f6e 7469 6e75 653b 0a09 0909 6966 2028  ontinue;....if (
    │ │ │ -0006d980: 6a2d 2667 743b 706f 7274 2829 2021 3d20  j->port() != 
    │ │ │ -0006d990: 6570 2e70 6f72 7428 2929 2063 6f6e 7469  ep.port()) conti
    │ │ │ -0006d9a0: 6e75 653b 0a09 0909 7265 7475 726e 2073  nue;....return s
    │ │ │ -0006d9b0: 7464 3a3a 6d61 6b65 5f74 7570 6c65 2826  td::make_tuple(&
    │ │ │ -0006d9c0: 616d 703b 2a6a 2c20 692c 2026 616d 703b  amp;*j, i, &
    │ │ │ -0006d9d0: 692d 2667 743b 6c69 7665 5f6e 6f64 6573  i->live_nodes
    │ │ │ -0006d9e0: 293b 0a09 097d 0a09 7d0a 0972 6574 7572  );...}..}..retur
    │ │ │ -0006d9f0: 6e20 7374 643a 3a74 7570 6c65 266c 743b  n std::tuple<
    │ │ │ -0006da00: 6e6f 6465 5f65 6e74 7279 2a2c 2072 6f75  node_entry*, rou
    │ │ │ -0006da10: 7469 6e67 5f74 6162 6c65 3a3a 7461 626c  ting_table::tabl
    │ │ │ -0006da20: 655f 743a 3a69 7465 7261 746f 722c 2062  e_t::iterator, b
    │ │ │ -0006da30: 7563 6b65 745f 742a 2667 743b 0a09 7b6e  ucket_t*>..{n
    │ │ │ -0006da40: 756c 6c70 7472 2c20 6d5f 6275 636b 6574  ullptr, m_bucket
    │ │ │ -0006da50: 732e 656e 6428 292c 206e 756c 6c70 7472  s.end(), nullptr
    │ │ │ -0006da60: 7d3b 0a7d 0a0a 3c64 6976 2073 7479 6c65  };.}..
    void routing │ │ │ -0006daa0: 5f74 6162 6c65 3a3a 6669 6c6c 5f66 726f _table::fill_fro │ │ │ -0006dab0: 6d5f 7265 706c 6163 656d 656e 7473 2874 m_replacements(t │ │ │ -0006dac0: 6162 6c65 5f74 3a3a 6974 6572 6174 6f72 able_t::iterator │ │ │ -0006dad0: 2062 7563 6b65 7429 0a3c 2f64 6976 3e7b bucket).
    { │ │ │ -0006dae0: 0a09 6275 636b 6574 5f74 2661 6d70 3b20 ..bucket_t& │ │ │ -0006daf0: 6220 3d20 6275 636b 6574 2d26 6774 3b6c b = bucket->l │ │ │ -0006db00: 6976 655f 6e6f 6465 733b 0a09 6275 636b ive_nodes;..buck │ │ │ -0006db10: 6574 5f74 2661 6d70 3b20 7262 203d 2062 et_t& rb = b │ │ │ -0006db20: 7563 6b65 742d 2667 743b 7265 706c 6163 ucket->replac │ │ │ -0006db30: 656d 656e 7473 3b0a 0969 6e74 2063 6f6e ements;..int con │ │ │ -0006db40: 7374 2062 7563 6b65 745f 7369 7a65 203d st bucket_size = │ │ │ -0006db50: 2062 7563 6b65 745f 6c69 6d69 7428 696e bucket_limit(in │ │ │ -0006db60: 7428 7374 643a 3a64 6973 7461 6e63 6528 t(std::distance( │ │ │ -0006db70: 6d5f 6275 636b 6574 732e 6265 6769 6e28 m_buckets.begin( │ │ │ -0006db80: 292c 2062 7563 6b65 7429 2929 3b0a 0a09 ), bucket)));... │ │ │ -0006db90: 6966 2028 696e 7428 622e 7369 7a65 2829 if (int(b.size() │ │ │ -0006dba0: 2920 2667 743b 3d20 6275 636b 6574 5f73 ) >= bucket_s │ │ │ -0006dbb0: 697a 6529 2072 6574 7572 6e3b 0a0a 092f ize) return;.../ │ │ │ -0006dbc0: 2f20 736f 7274 2062 7920 5254 5420 6669 / sort by RTT fi │ │ │ -0006dbd0: 7273 742c 2074 6f20 6669 6e64 2074 6865 rst, to find the │ │ │ -0006dbe0: 206e 6f64 6520 7769 7468 2074 6865 206c node with the l │ │ │ -0006dbf0: 6f77 6573 740a 092f 2f20 5254 5420 7468 owest..// RTT th │ │ │ -0006dc00: 6174 2069 7320 7069 6e67 6564 0a09 7374 at is pinged..st │ │ │ -0006dc10: 643a 3a73 6f72 7428 7262 2e62 6567 696e d::sort(rb.begin │ │ │ -0006dc20: 2829 2c20 7262 2e65 6e64 2829 293b 0a0a (), rb.end());.. │ │ │ -0006dc30: 0977 6869 6c65 2028 696e 7428 622e 7369 .while (int(b.si │ │ │ -0006dc40: 7a65 2829 2920 266c 743b 2062 7563 6b65 ze()) < bucke │ │ │ -0006dc50: 745f 7369 7a65 2026 616d 703b 2661 6d70 t_size && │ │ │ -0006dc60: 3b20 2172 622e 656d 7074 7928 2929 0a09 ; !rb.empty()).. │ │ │ -0006dc70: 7b0a 0909 6175 746f 206a 203d 2073 7464 {...auto j = std │ │ │ -0006dc80: 3a3a 6669 6e64 5f69 6628 7262 2e62 6567 ::find_if(rb.beg │ │ │ -0006dc90: 696e 2829 2c20 7262 2e65 6e64 2829 2c20 in(), rb.end(), │ │ │ -0006dca0: 7374 643a 3a62 696e 6428 2661 6d70 3b6e std::bind(&n │ │ │ -0006dcb0: 6f64 655f 656e 7472 793a 3a70 696e 6765 ode_entry::pinge │ │ │ -0006dcc0: 642c 205f 3129 293b 0a09 0969 6620 286a d, _1));...if (j │ │ │ -0006dcd0: 203d 3d20 7262 2e65 6e64 2829 2920 6272 == rb.end()) br │ │ │ -0006dce0: 6561 6b3b 0a09 0962 2e70 7573 685f 6261 eak;...b.push_ba │ │ │ -0006dcf0: 636b 282a 6a29 3b0a 0909 7262 2e65 7261 ck(*j);...rb.era │ │ │ -0006dd00: 7365 286a 293b 0a09 7d0a 7d0a 0a76 6f69 se(j);..}.}..voi │ │ │ -0006dd10: 6420 726f 7574 696e 675f 7461 626c 653a d routing_table: │ │ │ -0006dd20: 3a70 7275 6e65 5f65 6d70 7479 5f62 7563 :prune_empty_buc │ │ │ -0006dd30: 6b65 7428 290a 7b0a 0969 6620 286d 5f62 ket().{..if (m_b │ │ │ -0006dd40: 7563 6b65 7473 2e62 6163 6b28 292e 6c69 uckets.back().li │ │ │ -0006dd50: 7665 5f6e 6f64 6573 2e65 6d70 7479 2829 ve_nodes.empty() │ │ │ -0006dd60: 0a09 0926 616d 703b 2661 6d70 3b20 6d5f ...&& m_ │ │ │ -0006dd70: 6275 636b 6574 732e 6261 636b 2829 2e72 buckets.back().r │ │ │ -0006dd80: 6570 6c61 6365 6d65 6e74 732e 656d 7074 eplacements.empt │ │ │ -0006dd90: 7928 2929 0a09 7b0a 0909 6d5f 6275 636b y())..{...m_buck │ │ │ -0006dda0: 6574 732e 6572 6173 6528 6d5f 6275 636b ets.erase(m_buck │ │ │ -0006ddb0: 6574 732e 656e 6428 2920 2d20 3129 3b0a ets.end() - 1);. │ │ │ -0006ddc0: 097d 0a7d 0a0a 766f 6964 2072 6f75 7469 .}.}..void routi │ │ │ -0006ddd0: 6e67 5f74 6162 6c65 3a3a 7265 6d6f 7665 ng_table::remove │ │ │ -0006dde0: 5f6e 6f64 6528 6e6f 6465 5f65 6e74 7279 _node(node_entry │ │ │ -0006ddf0: 2a20 6e2c 2062 7563 6b65 745f 742a 2062 * n, bucket_t* b │ │ │ -0006de00: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ -0006de30: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006de40: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006de70: 7372 632f 6b61 6465 6d6c 6961 2f64 6874 src/kademlia/dht │ │ │ -0006de80: 5f74 7261 636b 6572 2e63 7070 3a32 3934 _tracker.cpp:294 │ │ │ -0006de90: 3c2f 613e 3c2f 7464 3e3c 7464 3e70 6963 pic │ │ │ -0006dea0: 6b20 7468 6520 636c 6f73 6573 7420 6e6f k the closest no │ │ │ -0006deb0: 6465 2072 6174 6865 7220 7468 616e 2074 de rather than t │ │ │ -0006dec0: 6865 2066 6972 7374 3c2f 7464 3e3c 2f74 he first

    pick the c │ │ │ -0006df20: 6c6f 7365 7374 206e 6f64 6520 7261 7468 losest node rath │ │ │ -0006df30: 6572 2074 6861 6e20 7468 6520 6669 7273 er than the firs │ │ │ -0006df40: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ -0006df50: 2f6b 6164 656d 6c69 612f 6468 745f 7472 /kademlia/dht_tr │ │ │ -0006df60: 6163 6b65 722e 6370 703a 3239 343c 2f68 acker.cpp:294
    .#if
    │ │ │ -0006dfb0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -0006dfc0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 096d  ABLE_LOGGING...m
    │ │ │ -0006dfd0: 5f6c 6f67 2d26 6774 3b6c 6f67 2864 6874  _log->log(dht
    │ │ │ -0006dfe0: 5f6c 6f67 6765 723a 3a74 7261 636b 6572  _logger::tracker
    │ │ │ -0006dff0: 2c20 222a 2a2a 206e 6577 2077 7269 7465  , "*** new write
    │ │ │ -0006e000: 206b 6579 2a2a 2a20 2564 206e 6f64 6573   key*** %d nodes
    │ │ │ -0006e010: 220a 0909 092c 2069 6e74 286d 5f6e 6f64  "...., int(m_nod
    │ │ │ -0006e020: 6573 2e73 697a 6528 2929 293b 0a23 656e  es.size()));.#en
    │ │ │ -0006e030: 6469 660a 097d 0a0a 0976 6f69 6420 6468  dif..}...void dh
    │ │ │ -0006e040: 745f 7472 6163 6b65 723a 3a75 7064 6174  t_tracker::updat
    │ │ │ -0006e050: 655f 7374 6f72 6167 655f 6e6f 6465 5f69  e_storage_node_i
    │ │ │ -0006e060: 6473 2829 0a09 7b0a 0909 7374 643a 3a76  ds()..{...std::v
    │ │ │ -0006e070: 6563 746f 7226 6c74 3b73 6861 315f 6861  ector<sha1_ha
    │ │ │ -0006e080: 7368 2667 743b 2069 6473 3b0a 0909 666f  sh> ids;...fo
    │ │ │ -0006e090: 7220 2861 7574 6f26 616d 703b 206e 203a  r (auto& n :
    │ │ │ -0006e0a0: 206d 5f6e 6f64 6573 290a 0909 0969 6473   m_nodes)....ids
    │ │ │ -0006e0b0: 2e70 7573 685f 6261 636b 286e 2e73 6563  .push_back(n.sec
    │ │ │ -0006e0c0: 6f6e 642e 6468 742e 6e69 6428 2929 3b0a  ond.dht.nid());.
    │ │ │ -0006e0d0: 0909 6d5f 7374 6f72 6167 652e 7570 6461  ..m_storage.upda
    │ │ │ -0006e0e0: 7465 5f6e 6f64 655f 6964 7328 6964 7329  te_node_ids(ids)
    │ │ │ -0006e0f0: 3b0a 097d 0a0a 096e 6f64 652a 2064 6874  ;..}...node* dht
    │ │ │ -0006e100: 5f74 7261 636b 6572 3a3a 6765 745f 6e6f  _tracker::get_no
    │ │ │ -0006e110: 6465 286e 6f64 655f 6964 2063 6f6e 7374  de(node_id const
    │ │ │ -0006e120: 2661 6d70 3b20 6964 2c20 7374 7269 6e67  & id, string
    │ │ │ -0006e130: 5f76 6965 7720 2066 616d 696c 795f 6e61  _view  family_na
    │ │ │ -0006e140: 6d65 290a 097b 0a09 0954 4f52 5245 4e54  me)..{...TORRENT
    │ │ │ -0006e150: 5f55 4e55 5345 4428 6964 293b 0a09 0966  _UNUSED(id);...f
    │ │ │ -0006e160: 6f72 2028 6175 746f 2661 6d70 3b20 6e20  or (auto& n 
    │ │ │ -0006e170: 3a20 6d5f 6e6f 6465 7329 0a09 097b 0a3c  : m_nodes)...{.<
    │ │ │ -0006e180: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0006e190: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0006e1a0: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ -0006e1b0: 6966 2028 6e2e 7365 636f 6e64 2e64 6874  if (n.second.dht
    │ │ │ -0006e1c0: 2e70 726f 746f 636f 6c5f 6661 6d69 6c79  .protocol_family
    │ │ │ -0006e1d0: 5f6e 616d 6528 2920 3d3d 2066 616d 696c  _name() == famil
    │ │ │ -0006e1e0: 795f 6e61 6d65 290a 3c2f 6469 763e 0909  y_name).

    .. │ │ │ -0006e1f0: 0909 7265 7475 726e 2026 616d 703b 6e2e ..return &n. │ │ │ -0006e200: 7365 636f 6e64 2e64 6874 3b0a 0909 7d0a second.dht;...}. │ │ │ -0006e210: 0a09 0972 6574 7572 6e20 6e75 6c6c 7074 ...return nullpt │ │ │ -0006e220: 723b 0a09 7d0a 0a09 766f 6964 2064 6874 r;..}...void dht │ │ │ -0006e230: 5f74 7261 636b 6572 3a3a 6765 745f 7065 _tracker::get_pe │ │ │ -0006e240: 6572 7328 7368 6131 5f68 6173 6820 636f ers(sha1_hash co │ │ │ -0006e250: 6e73 7426 616d 703b 2069 680a 0909 2c20 nst& ih..., │ │ │ -0006e260: 7374 643a 3a66 756e 6374 696f 6e26 6c74 std::function< │ │ │ -0006e270: 3b76 6f69 6428 7374 643a 3a76 6563 746f ;void(std::vecto │ │ │ -0006e280: 7226 6c74 3b74 6370 3a3a 656e 6470 6f69 r<tcp::endpoi │ │ │ -0006e290: 6e74 2667 743b 2063 6f6e 7374 2661 6d70 nt> const& │ │ │ -0006e2a0: 3b29 2667 743b 2066 290a 097b 0a09 0966 ;)> f)..{...f │ │ │ -0006e2b0: 6f72 2028 6175 746f 2661 6d70 3b20 6e20 or (auto& n │ │ │ -0006e2c0: 3a20 6d5f 6e6f 6465 7329 0a09 0909 6e2e : m_nodes)....n. │ │ │ -0006e2d0: 7365 636f 6e64 2e64 6874 2e67 6574 5f70 second.dht.get_p │ │ │ -0006e2e0: 6565 7273 2869 682c 2066 2c20 7b7d 2c20 eers(ih, f, {}, │ │ │ -0006e2f0: 7b7d 293b 0a09 7d0a 0a09 766f 6964 2064 {});..}...void d │ │ │ -0006e300: 6874 5f74 7261 636b 6572 3a3a 616e 6e6f ht_tracker::anno │ │ │ -0006e310: 756e 6365 2873 6861 315f 6861 7368 2063 unce(sha1_hash c │ │ │ -0006e320: 6f6e 7374 2661 6d70 3b20 6968 2c20 696e onst& ih, in │ │ │ -0006e330: 7420 6c69 7374 656e 5f70 6f72 740a 0909 t listen_port... │ │ │ -0006e340: 2c20 616e 6e6f 756e 6365 5f66 6c61 6773 , announce_flags │ │ │ -0006e350: 5f74 2063 6f6e 7374 2066 6c61 6773 0a09 _t const flags.. │ │ │ -0006e360: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ -0006e370: 266c 743b 766f 6964 2873 7464 3a3a 7665 <void(std::ve │ │ │ -0006e380: 6374 6f72 266c 743b 7463 703a 3a65 6e64 ctor<tcp::end │ │ │ -0006e390: 706f 696e 7426 6774 3b20 636f 6e73 7426 point> const& │ │ │ -0006e3a0: 616d 703b 2926 6774 3b20 6629 0a09 7b0a amp;)> f)..{. │ │ │ -0006e3b0: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -0006e3c0: 206e 203a 206d 5f6e 6f64 6573 290a 0909 n : m_nodes)... │ │ │ -0006e3d0: 096e 2e73 6563 6f6e 642e 6468 742e 616e .n.second.dht.an │ │ │ -0006e3e0: 6e6f 756e 6365 2869 682c 206c 6973 7465 nounce(ih, liste │ │ │ -0006e3f0: 6e5f 706f 7274 2c20 666c 6167 732c 2066 n_port, flags, f │ │ │ -0006e400: 293b 0a09 7d0a 0a09 766f 6964 2064 6874 );..}...void dht │ │ │ -0006e410: 5f74 7261 636b 6572 3a3a 7361 6d70 6c65 _tracker::sample │ │ │ -0006e420: 5f69 6e66 6f68 6173 6865 7328 7564 703a _infohashes(udp: │ │ │ -0006e430: 3a65 6e64 706f 696e 7420 636f 6e73 7426 :endpoint const& │ │ │ -0006e440: 616d 703b 2065 702c 2073 6861 315f 6861 amp; ep, sha1_ha │ │ │ -0006e450: 7368 2063 6f6e 7374 2661 6d70 3b20 7461 sh const& ta │ │ │ -0006e460: 7267 6574 0a09 092c 2073 7464 3a3a 6675 rget..., std::fu │ │ │ -0006e470: 6e63 7469 6f6e 266c 743b 766f 6964 286e nction<void(n │ │ │ -0006e480: 6f64 655f 6964 0a09 0909 2c20 7469 6d65 ode_id...., time │ │ │ -0006e490: 5f64 7572 6174 696f 6e0a 0909 092c 2069 _duration...., i │ │ │ -0006e4a0: 6e74 2c20 7374 643a 3a76 6563 746f 7226 nt, std::vector& │ │ │ -0006e4b0: 6c74 3b73 6861 315f 6861 7368 2667 743b lt;sha1_hash> │ │ │ -0006e4c0: 0a09 0909 2c20 7374 643a 3a76 6563 746f ...., std::vecto │ │ │ -0006e4d0: 7226 6c74 3b73 7464 3a3a 7061 6972 266c r<std::pair&l │ │ │ -0006e4e0: 743b 7368 6131 5f68 6173 682c 2075 6470 t;sha1_hash, udp │ │ │ -0006e4f0: 3a3a 656e 6470 6f69 6e74 2667 743b 2667 ::endpoint>&g │ │ │ -0006e500: 743b 2926 6774 3b20 6629 0a09 7b0a 0909 t;)> f)..{... │ │ │ -0006e510: 666f 7220 2861 7574 6f26 616d 703b 206e for (auto& n │ │ │ -0006e520: 203a 206d 5f6e 6f64 6573 290a 0909 7b0a : m_nodes)...{. │ │ │ -0006e530: 0909 0969 6620 2865 702e 7072 6f74 6f63 ...if (ep.protoc │ │ │ -0006e540: 6f6c 2829 2021 3d20 286e 2e66 6972 7374 ol() != (n.first │ │ │ -0006e550: 2e67 6574 5f65 7874 6572 6e61 6c5f 6164 .get_external_ad │ │ │ -0006e560: 6472 6573 7328 292e 6973 5f76 3428 2920 dress().is_v4() │ │ │ -0006e570: 3f20 7564 703a 3a76 3428 2920 3a20 7564 ? udp::v4() : ud │ │ │ -0006e580: 703a 3a76 3628 2929 290a 3c2f 7072 653e p::v6())). │ │ │ -0006e590: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006e5c0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006e5d0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/kade │ │ │ -0006e600: 6d6c 6961 2f6e 6f64 652e 6370 703a 3131 mlia/node.cpp:11 │ │ │ -0006e610: 3638 3c2f 613e 3c2f 7464 3e3c 7464 3e6b 68k │ │ │ -0006e620: 6565 7020 7468 6520 7265 7475 726e 6564 eep the returned │ │ │ -0006e630: 2076 616c 7565 2074 6f20 7061 7373 2061 value to pass a │ │ │ -0006e640: 7320 6120 6c69 6d69 7420 746f 2077 7269 s a limit to wri │ │ │ -0006e650: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ -0006e660: 2077 6865 6e20 696d 706c 656d 656e 7465 when implemente │ │ │ -0006e670: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    k │ │ │ -0006e6c0: 6565 7020 7468 6520 7265 7475 726e 6564 eep the returned │ │ │ -0006e6d0: 2076 616c 7565 2074 6f20 7061 7373 2061 value to pass a │ │ │ -0006e6e0: 7320 6120 6c69 6d69 740a 746f 2077 7269 s a limit.to wri │ │ │ -0006e6f0: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ -0006e700: 2077 6865 6e20 696d 706c 656d 656e 7465 when implemente │ │ │ -0006e710: 643c 2f68 323e 3c68 343e 2e2e 2f73 7263 d

    ../src │ │ │ -0006e720: 2f6b 6164 656d 6c69 612f 6e6f 6465 2e63 /kademlia/node.c │ │ │ -0006e730: 7070 3a31 3136 383c 2f68 343e 3c70 7265 pp:1168

    ..}..}..el
    │ │ │ -0006e780: 7365 2069 6620 2871 7565 7279 203d 3d20  se if (query == 
    │ │ │ -0006e790: 2273 616d 706c 655f 696e 666f 6861 7368  "sample_infohash
    │ │ │ -0006e7a0: 6573 2229 0a09 7b0a 0909 7374 6174 6963  es")..{...static
    │ │ │ -0006e7b0: 206b 6579 5f64 6573 635f 7420 636f 6e73   key_desc_t cons
    │ │ │ -0006e7c0: 7420 6d73 675f 6465 7363 5b5d 203d 207b  t msg_desc[] = {
    │ │ │ -0006e7d0: 0a09 0909 7b22 7461 7267 6574 222c 2062  ....{"target", b
    │ │ │ -0006e7e0: 6465 636f 6465 5f6e 6f64 653a 3a73 7472  decode_node::str
    │ │ │ -0006e7f0: 696e 675f 742c 2032 302c 2030 7d2c 0a09  ing_t, 20, 0},..
    │ │ │ -0006e800: 0909 7b22 7761 6e74 222c 2062 6465 636f  ..{"want", bdeco
    │ │ │ -0006e810: 6465 5f6e 6f64 653a 3a6c 6973 745f 742c  de_node::list_t,
    │ │ │ -0006e820: 2030 2c20 6b65 795f 6465 7363 5f74 3a3a   0, key_desc_t::
    │ │ │ -0006e830: 6f70 7469 6f6e 616c 7d2c 0a09 097d 3b0a  optional},...};.
    │ │ │ -0006e840: 0a09 0962 6465 636f 6465 5f6e 6f64 6520  ...bdecode_node 
    │ │ │ -0006e850: 6d73 675f 6b65 7973 5b32 5d3b 0a09 0969  msg_keys[2];...i
    │ │ │ -0006e860: 6620 2821 7665 7269 6679 5f6d 6573 7361  f (!verify_messa
    │ │ │ -0006e870: 6765 2861 7267 5f65 6e74 2c20 6d73 675f  ge(arg_ent, msg_
    │ │ │ -0006e880: 6465 7363 2c20 6d73 675f 6b65 7973 2c20  desc, msg_keys, 
    │ │ │ -0006e890: 6572 726f 725f 7374 7269 6e67 2929 0a09  error_string))..
    │ │ │ -0006e8a0: 097b 0a09 0909 6d5f 636f 756e 7465 7273  .{....m_counters
    │ │ │ -0006e8b0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ -0006e8c0: 6572 2863 6f75 6e74 6572 733a 3a64 6874  er(counters::dht
    │ │ │ -0006e8d0: 5f69 6e76 616c 6964 5f73 616d 706c 655f  _invalid_sample_
    │ │ │ -0006e8e0: 696e 666f 6861 7368 6573 293b 0a09 0909  infohashes);....
    │ │ │ -0006e8f0: 696e 636f 6d69 6e67 5f65 7272 6f72 2865  incoming_error(e
    │ │ │ -0006e900: 2c20 6572 726f 725f 7374 7269 6e67 293b  , error_string);
    │ │ │ -0006e910: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a  ....return;...}.
    │ │ │ -0006e920: 0a09 096d 5f63 6f75 6e74 6572 732e 696e  ...m_counters.in
    │ │ │ -0006e930: 635f 7374 6174 735f 636f 756e 7465 7228  c_stats_counter(
    │ │ │ -0006e940: 636f 756e 7465 7273 3a3a 6468 745f 7361  counters::dht_sa
    │ │ │ -0006e950: 6d70 6c65 5f69 6e66 6f68 6173 6865 735f  mple_infohashes_
    │ │ │ -0006e960: 696e 293b 0a09 0973 6861 315f 6861 7368  in);...sha1_hash
    │ │ │ -0006e970: 2063 6f6e 7374 2074 6172 6765 7428 6d73   const target(ms
    │ │ │ -0006e980: 675f 6b65 7973 5b30 5d2e 7374 7269 6e67  g_keys[0].string
    │ │ │ -0006e990: 5f70 7472 2829 293b 0a0a 3c64 6976 2073  _ptr());..
    ..m_stor │ │ │ -0006e9d0: 6167 652e 6765 745f 696e 666f 6861 7368 age.get_infohash │ │ │ -0006e9e0: 6573 5f73 616d 706c 6528 7265 706c 7929 es_sample(reply) │ │ │ -0006e9f0: 3b0a 3c2f 6469 763e 0a09 0977 7269 7465 ;.
    ...write │ │ │ -0006ea00: 5f6e 6f64 6573 5f65 6e74 7269 6573 2874 _nodes_entries(t │ │ │ -0006ea10: 6172 6765 742c 206d 7367 5f6b 6579 735b arget, msg_keys[ │ │ │ -0006ea20: 315d 2c20 7265 706c 7929 3b0a 097d 0a09 1], reply);..}.. │ │ │ -0006ea30: 656c 7365 0a09 7b0a 0909 2f2f 2069 6620 else..{...// if │ │ │ -0006ea40: 7765 2064 6f6e 2774 2072 6563 6f67 6e69 we don't recogni │ │ │ -0006ea50: 7a65 2074 6865 206d 6573 7361 6765 2062 ze the message b │ │ │ -0006ea60: 7574 2074 6865 7265 2773 2061 0a09 092f ut there's a.../ │ │ │ -0006ea70: 2f20 2774 6172 6765 7427 206f 7220 2769 / 'target' or 'i │ │ │ -0006ea80: 6e66 6f5f 6861 7368 2720 696e 2074 6865 nfo_hash' in the │ │ │ -0006ea90: 2061 7267 756d 656e 7473 2c20 7472 6561 arguments, trea │ │ │ -0006eaa0: 7420 6974 0a09 092f 2f20 6173 2066 696e t it...// as fin │ │ │ -0006eab0: 645f 6e6f 6465 2074 6f20 6265 2066 7574 d_node to be fut │ │ │ -0006eac0: 7572 6520 636f 6d70 6174 6962 6c65 0a09 ure compatible.. │ │ │ -0006ead0: 0962 6465 636f 6465 5f6e 6f64 6520 7461 .bdecode_node ta │ │ │ -0006eae0: 7267 6574 5f65 6e74 203d 2061 7267 5f65 rget_ent = arg_e │ │ │ -0006eaf0: 6e74 2e64 6963 745f 6669 6e64 5f73 7472 nt.dict_find_str │ │ │ -0006eb00: 696e 6728 2274 6172 6765 7422 293b 0a09 ing("target");.. │ │ │ -0006eb10: 0969 6620 2821 7461 7267 6574 5f65 6e74 .if (!target_ent │ │ │ -0006eb20: 207c 7c20 7461 7267 6574 5f65 6e74 2e73 || target_ent.s │ │ │ -0006eb30: 7472 696e 675f 6c65 6e67 7468 2829 2021 tring_length() ! │ │ │ -0006eb40: 3d20 3230 290a 0909 7b0a 0909 0974 6172 = 20)...{....tar │ │ │ -0006eb50: 6765 745f 656e 7420 3d20 6172 675f 656e get_ent = arg_en │ │ │ -0006eb60: 742e 6469 6374 5f66 696e 645f 7374 7269 t.dict_find_stri │ │ │ -0006eb70: 6e67 2822 696e 666f 5f68 6173 6822 293b ng("info_hash"); │ │ │ -0006eb80: 0a09 0909 6966 2028 2174 6172 6765 745f ....if (!target_ │ │ │ -0006eb90: 656e 7420 7c7c 2074 6172 6765 745f 656e ent || target_en │ │ │ -0006eba0: 742e 7374 7269 6e67 5f6c 656e 6774 6828 t.string_length( │ │ │ -0006ebb0: 2920 213d 2032 3029 0a09 0909 7b0a 0909 ) != 20)....{... │ │ │ -0006ebc0: 0909 696e 636f 6d69 6e67 5f65 7272 6f72 ..incoming_error │ │ │ -0006ebd0: 2865 2c20 2275 6e6b 6e6f 776e 206d 6573 (e, "unknown mes │ │ │ -0006ebe0: 7361 6765 2229 3b0a 0909 0909 7265 7475 sage");.....retu │ │ │ -0006ebf0: 726e 3b0a 0909 097d 0a09 097d 0a0a 0909 rn;....}...}.... │ │ │ -0006ec00: 7368 6131 5f68 6173 6820 636f 6e73 7420 sha1_hash const │ │ │ -0006ec10: 7461 7267 6574 2874 6172 6765 745f 656e target(target_en │ │ │ -0006ec20: 742e 7374 7269 6e67 5f70 7472 2829 293b t.string_ptr()); │ │ │ -0006ec30: 0a09 092f 2f20 616c 7761 7973 2072 6574 ...// always ret │ │ │ -0006ec40: 7572 6e20 6e6f 6465 7320 6173 2077 656c urn nodes as wel │ │ │ -0006ec50: 6c20 6173 2070 6565 7273 0a09 0977 7269 l as peers...wri │ │ │ -0006ec60: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ -0006ec70: 2874 6172 6765 742c 2061 7267 5f65 6e74 (target, arg_ent │ │ │ -0006ec80: 2e64 6963 745f 6669 6e64 5f6c 6973 7428 .dict_find_list( │ │ │ -0006ec90: 2277 616e 7422 292c 2072 6570 6c79 293b "want"), reply); │ │ │ -0006eca0: 0a09 7d0a 7d0a 0a3c 2f70 7265 3e3c 2f74 ..}.}..
    relevanc │ │ │ -0006ece0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/kademli │ │ │ -0006ed20: 612f 6e6f 6465 2e63 7070 3a31 3139 363c a/node.cpp:1196< │ │ │ -0006ed30: 2f61 3e3c 2f74 643e 3c74 643e 6c69 6d69 /a>limi │ │ │ -0006ed40: 7420 6e75 6d62 6572 206f 6620 656e 7472 t number of entr │ │ │ -0006ed50: 6965 7320 696e 2074 6865 2072 6573 756c ies in the resul │ │ │ -0006ed60: 743c 2f74 643e 3c2f 7472 3e3c 7472 2069 t

    l │ │ │ -0006edb0: 696d 6974 206e 756d 6265 7220 6f66 2065 imit number of e │ │ │ -0006edc0: 6e74 7269 6573 2069 6e20 7468 6520 7265 ntries in the re │ │ │ -0006edd0: 7375 6c74 3c2f 6832 3e3c 6834 3e2e 2e2f sult

    ../ │ │ │ -0006ede0: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ -0006edf0: 652e 6370 703a 3131 3936 3c2f 6834 3e3c e.cpp:1196

    < │ │ │ -0006ee00: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0006ee10: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0006ee20: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0006ee30: 7820 2364 6464 3b22 3e09 092f 2f20 6966 x #ddd;">..// if │ │ │ -0006ee40: 2077 6520 646f 6e27 7420 7265 636f 676e we don't recogn │ │ │ -0006ee50: 697a 6520 7468 6520 6d65 7373 6167 6520 ize the message │ │ │ -0006ee60: 6275 7420 7468 6572 6527 7320 610a 0909 but there's a... │ │ │ -0006ee70: 2f2f 2027 7461 7267 6574 2720 6f72 2027 // 'target' or ' │ │ │ -0006ee80: 696e 666f 5f68 6173 6827 2069 6e20 7468 info_hash' in th │ │ │ -0006ee90: 6520 6172 6775 6d65 6e74 732c 2074 7265 e arguments, tre │ │ │ -0006eea0: 6174 2069 740a 0909 2f2f 2061 7320 6669 at it...// as fi │ │ │ -0006eeb0: 6e64 5f6e 6f64 6520 746f 2062 6520 6675 nd_node to be fu │ │ │ -0006eec0: 7475 7265 2063 6f6d 7061 7469 626c 650a ture compatible. │ │ │ -0006eed0: 0909 6264 6563 6f64 655f 6e6f 6465 2074 ..bdecode_node t │ │ │ -0006eee0: 6172 6765 745f 656e 7420 3d20 6172 675f arget_ent = arg_ │ │ │ -0006eef0: 656e 742e 6469 6374 5f66 696e 645f 7374 ent.dict_find_st │ │ │ -0006ef00: 7269 6e67 2822 7461 7267 6574 2229 3b0a ring("target");. │ │ │ -0006ef10: 0909 6966 2028 2174 6172 6765 745f 656e ..if (!target_en │ │ │ -0006ef20: 7420 7c7c 2074 6172 6765 745f 656e 742e t || target_ent. │ │ │ -0006ef30: 7374 7269 6e67 5f6c 656e 6774 6828 2920 string_length() │ │ │ -0006ef40: 213d 2032 3029 0a09 097b 0a09 0909 7461 != 20)...{....ta │ │ │ -0006ef50: 7267 6574 5f65 6e74 203d 2061 7267 5f65 rget_ent = arg_e │ │ │ -0006ef60: 6e74 2e64 6963 745f 6669 6e64 5f73 7472 nt.dict_find_str │ │ │ -0006ef70: 696e 6728 2269 6e66 6f5f 6861 7368 2229 ing("info_hash") │ │ │ -0006ef80: 3b0a 0909 0969 6620 2821 7461 7267 6574 ;....if (!target │ │ │ -0006ef90: 5f65 6e74 207c 7c20 7461 7267 6574 5f65 _ent || target_e │ │ │ -0006efa0: 6e74 2e73 7472 696e 675f 6c65 6e67 7468 nt.string_length │ │ │ -0006efb0: 2829 2021 3d20 3230 290a 0909 097b 0a09 () != 20)....{.. │ │ │ -0006efc0: 0909 0969 6e63 6f6d 696e 675f 6572 726f ...incoming_erro │ │ │ -0006efd0: 7228 652c 2022 756e 6b6e 6f77 6e20 6d65 r(e, "unknown me │ │ │ -0006efe0: 7373 6167 6522 293b 0a09 0909 0972 6574 ssage");.....ret │ │ │ -0006eff0: 7572 6e3b 0a09 0909 7d0a 0909 7d0a 0a09 urn;....}...}... │ │ │ -0006f000: 0973 6861 315f 6861 7368 2063 6f6e 7374 .sha1_hash const │ │ │ -0006f010: 2074 6172 6765 7428 7461 7267 6574 5f65 target(target_e │ │ │ -0006f020: 6e74 2e73 7472 696e 675f 7074 7228 2929 nt.string_ptr()) │ │ │ -0006f030: 3b0a 0909 2f2f 2061 6c77 6179 7320 7265 ;...// always re │ │ │ -0006f040: 7475 726e 206e 6f64 6573 2061 7320 7765 turn nodes as we │ │ │ -0006f050: 6c6c 2061 7320 7065 6572 730a 0909 7772 ll as peers...wr │ │ │ -0006f060: 6974 655f 6e6f 6465 735f 656e 7472 6965 ite_nodes_entrie │ │ │ -0006f070: 7328 7461 7267 6574 2c20 6172 675f 656e s(target, arg_en │ │ │ -0006f080: 742e 6469 6374 5f66 696e 645f 6c69 7374 t.dict_find_list │ │ │ -0006f090: 2822 7761 6e74 2229 2c20 7265 706c 7929 ("want"), reply) │ │ │ -0006f0a0: 3b0a 097d 0a7d 0a0a 3c64 6976 2073 7479 ;..}.}..
    void node: │ │ │ -0006f0e0: 3a77 7269 7465 5f6e 6f64 6573 5f65 6e74 :write_nodes_ent │ │ │ -0006f0f0: 7269 6573 2873 6861 315f 6861 7368 2063 ries(sha1_hash c │ │ │ -0006f100: 6f6e 7374 2661 6d70 3b20 696e 666f 5f68 onst& info_h │ │ │ -0006f110: 6173 680a 3c2f 6469 763e 092c 2062 6465 ash.
    ., bde │ │ │ -0006f120: 636f 6465 5f6e 6f64 6520 636f 6e73 7426 code_node const& │ │ │ -0006f130: 616d 703b 2077 616e 742c 2065 6e74 7279 amp; want, entry │ │ │ -0006f140: 2661 6d70 3b20 7229 0a7b 0a09 2f2f 2069 & r).{..// i │ │ │ -0006f150: 6620 6e6f 2077 616e 7473 2065 6e74 7279 f no wants entry │ │ │ -0006f160: 2077 6173 2073 7065 6369 6669 6564 2c20 was specified, │ │ │ -0006f170: 696e 636c 7564 6520 6120 6e6f 6465 730a include a nodes. │ │ │ -0006f180: 092f 2f20 656e 7472 7920 6261 7365 6420 .// entry based │ │ │ -0006f190: 6f6e 2074 6865 2070 726f 746f 636f 6c20 on the protocol │ │ │ -0006f1a0: 7468 6520 7265 7175 6573 7420 6361 6d65 the request came │ │ │ -0006f1b0: 2069 6e20 7769 7468 0a09 6966 2028 7761 in with..if (wa │ │ │ -0006f1c0: 6e74 2e74 7970 6528 2920 213d 2062 6465 nt.type() != bde │ │ │ -0006f1d0: 636f 6465 5f6e 6f64 653a 3a6c 6973 745f code_node::list_ │ │ │ -0006f1e0: 7429 0a09 7b0a 0909 7374 643a 3a76 6563 t)..{...std::vec │ │ │ -0006f1f0: 746f 7226 6c74 3b6e 6f64 655f 656e 7472 tor<node_entr │ │ │ -0006f200: 7926 6774 3b20 636f 6e73 7420 6e20 3d20 y> const n = │ │ │ -0006f210: 6d5f 7461 626c 652e 6669 6e64 5f6e 6f64 m_table.find_nod │ │ │ -0006f220: 6528 696e 666f 5f68 6173 682c 207b 7d29 e(info_hash, {}) │ │ │ -0006f230: 3b0a 0909 725b 7072 6f74 6f63 6f6c 5f6e ;...r[protocol_n │ │ │ -0006f240: 6f64 6573 5f6b 6579 2829 5d20 3d20 7772 odes_key()] = wr │ │ │ -0006f250: 6974 655f 6e6f 6465 735f 656e 7472 7928 ite_nodes_entry( │ │ │ -0006f260: 6e29 3b0a 0909 7265 7475 726e 3b0a 097d n);...return;..} │ │ │ -0006f270: 0a0a 092f 2f20 6966 2074 6865 7265 2069 ...// if there i │ │ │ -0006f280: 7320 6120 7761 6e74 7320 656e 7472 7920 s a wants entry │ │ │ -0006f290: 7468 656e 2077 6520 6d61 7920 6e65 6564 then we may need │ │ │ -0006f2a0: 2074 6f20 7265 6163 6820 696e 746f 0a09 to reach into.. │ │ │ -0006f2b0: 2f2f 2061 6e6f 7468 6572 206e 6f64 6527 // another node' │ │ │ -0006f2c0: 7320 726f 7574 696e 6720 7461 626c 6520 s routing table │ │ │ -0006f2d0: 746f 2067 6574 206e 6f64 6573 206f 6620 to get nodes of │ │ │ -0006f2e0: 7468 6520 7265 7175 6573 7465 6420 7479 the requested ty │ │ │ -0006f2f0: 7065 0a09 2f2f 2077 6520 7573 6520 6120 pe..// we use a │ │ │ -0006f300: 6d61 7020 6d61 696e 7461 696e 6564 2062 map maintained b │ │ │ -0006f310: 7920 7468 6520 6f77 6e69 6e67 2064 6874 y the owning dht │ │ │ -0006f320: 5f74 7261 636b 6572 2074 6f20 6669 6e64 _tracker to find │ │ │ -0006f330: 2074 6865 0a09 2f2f 206e 6f64 6520 6173 the..// node as │ │ │ -0006f340: 736f 6369 6174 6564 2077 6974 6820 6561 sociated with ea │ │ │ -0006f350: 6368 2073 7472 696e 6720 696e 2074 6865 ch string in the │ │ │ -0006f360: 2077 616e 7420 6c69 7374 2c20 7768 6963 want list, whic │ │ │ -0006f370: 6820 6d61 790a 092f 2f20 696e 636c 7564 h may..// includ │ │ │ -0006f380: 6520 7468 6973 206e 6f64 650a 0966 6f72 e this node..for │ │ │ -0006f390: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ -0006f3a0: 6c74 3b20 7761 6e74 2e6c 6973 745f 7369 lt; want.list_si │ │ │ -0006f3b0: 7a65 2829 3b20 2b2b 6929 0a09 7b0a 0909 ze(); ++i)..{... │ │ │ -0006f3c0: 6264 6563 6f64 655f 6e6f 6465 2077 616e bdecode_node wan │ │ │ -0006f3d0: 7465 6420 3d20 7761 6e74 2e6c 6973 745f ted = want.list_ │ │ │ -0006f3e0: 6174 2869 293b 0a09 0969 6620 2877 616e at(i);...if (wan │ │ │ -0006f3f0: 7465 642e 7479 7065 2829 2021 3d20 6264 ted.type() != bd │ │ │ -0006f400: 6563 6f64 655f 6e6f 6465 3a3a 7374 7269 ecode_node::stri │ │ │ -0006f410: 6e67 5f74 290a 0909 0963 6f6e 7469 6e75 ng_t)....continu │ │ │ -0006f420: 653b 0a09 096e 6f64 652a 2077 616e 7465 e;...node* wante │ │ │ -0006f430: 645f 6e6f 6465 203d 206d 5f67 6574 5f66 d_node = m_get_f │ │ │ -0006f440: 6f72 6569 676e 5f6e 6f64 6528 696e 666f oreign_node(info │ │ │ -0006f450: 5f68 6173 682c 2077 616e 7465 642e 7374 _hash, wanted.st │ │ │ -0006f460: 7269 6e67 5f76 616c 7565 2829 293b 0a09 ring_value());.. │ │ │ -0006f470: 0969 6620 2821 7761 6e74 6564 5f6e 6f64 .if (!wanted_nod │ │ │ -0006f480: 6529 2063 6f6e 7469 6e75 653b 0a09 0973 e) continue;...s │ │ │ -0006f490: 7464 3a3a 7665 6374 6f72 266c 743b 6e6f td::vector<no │ │ │ -0006f4a0: 6465 5f65 6e74 7279 2667 743b 2063 6f6e de_entry> con │ │ │ -0006f4b0: 7374 206e 203d 2077 616e 7465 645f 6e6f st n = wanted_no │ │ │ -0006f4c0: 6465 2d26 6774 3b6d 5f74 6162 6c65 2e66 de->m_table.f │ │ │ -0006f4d0: 696e 645f 6e6f 6465 2869 6e66 6f5f 6861 ind_node(info_ha │ │ │ -0006f4e0: 7368 2c20 7b7d 293b 0a09 0972 5b77 616e sh, {});...r[wan │ │ │ -0006f4f0: 7465 645f 6e6f 6465 2d26 6774 3b70 726f ted_node->pro │ │ │ -0006f500: 746f 636f 6c5f 6e6f 6465 735f 6b65 7928 tocol_nodes_key( │ │ │ -0006f510: 295d 203d 2077 7269 7465 5f6e 6f64 6573 )] = write_nodes │ │ │ -0006f520: 5f65 6e74 7279 286e 293b 0a09 7d0a 7d0a _entry(n);..}.}. │ │ │ -0006f530: 0a6e 6f64 653a 3a70 726f 746f 636f 6c5f .node::protocol_ │ │ │ -0006f540: 6465 7363 7269 7074 6f72 2063 6f6e 7374 descriptor const │ │ │ -0006f550: 2661 6d70 3b20 6e6f 6465 3a3a 6d61 705f & node::map_ │ │ │ -0006f560: 7072 6f74 6f63 6f6c 5f74 6f5f 6465 7363 protocol_to_desc │ │ │ -0006f570: 7269 7074 6f72 2875 6470 2063 6f6e 7374 riptor(udp const │ │ │ -0006f580: 2070 726f 746f 636f 6c29 0a7b 0a3c 2f70 protocol).{.

    re │ │ │ -0006f5c0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ -0006f600: 6465 2f6c 6962 746f 7272 656e 742f 6669 de/libtorrent/fi │ │ │ -0006f610: 6c65 5f73 746f 7261 6765 2e68 7070 3a37 le_storage.hpp:7 │ │ │ -0006f620: 3035 3c2f 613e 3c2f 7464 3e3c 7464 3e63 05c │ │ │ -0006f630: 616e 2077 6520 7265 6d6f 7665 2073 6574 an we remove set │ │ │ -0006f640: 5f6e 616d 653f 3c2f 7464 3e3c 2f74 723e _name? │ │ │ -0006f650: 3c74 7220 6964 3d22 3235 3522 2073 7479 │ │ │ -0006f680: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006f690: 3c68 323e 6361 6e20 7765 2072 656d 6f76

    can we remov │ │ │ -0006f6a0: 6520 7365 745f 6e61 6d65 3f3c 2f68 323e e set_name?

    │ │ │ -0006f6b0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -0006f6c0: 6962 746f 7272 656e 742f 6669 6c65 5f73 ibtorrent/file_s │ │ │ -0006f6d0: 746f 7261 6765 2e68 7070 3a37 3035 3c2f torage.hpp:705
    #en
    │ │ │ -0006f720: 6469 660a 0909 092c 2073 7464 3a3a 696e  dif...., std::in
    │ │ │ -0006f730: 7436 345f 7420 636f 6e73 7420 6d74 696d  t64_t const mtim
    │ │ │ -0006f740: 652c 2073 7472 696e 675f 7669 6577 2063  e, string_view c
    │ │ │ -0006f750: 6f6e 7374 2073 796d 6c69 6e6b 5f70 6174  onst symlink_pat
    │ │ │ -0006f760: 680a 0909 092c 2063 6861 7220 636f 6e73  h...., char cons
    │ │ │ -0006f770: 742a 2072 6f6f 745f 6861 7368 293b 0a0a  t* root_hash);..
    │ │ │ -0006f780: 0909 7374 643a 3a73 7472 696e 6720 696e  ..std::string in
    │ │ │ -0006f790: 7465 726e 616c 5f66 696c 655f 7061 7468  ternal_file_path
    │ │ │ -0006f7a0: 2866 696c 655f 696e 6465 785f 7420 696e  (file_index_t in
    │ │ │ -0006f7b0: 6465 7829 2063 6f6e 7374 3b0a 0909 6669  dex) const;...fi
    │ │ │ -0006f7c0: 6c65 5f69 6e64 6578 5f74 206c 6173 745f  le_index_t last_
    │ │ │ -0006f7d0: 6669 6c65 2829 2063 6f6e 7374 206e 6f65  file() const noe
    │ │ │ -0006f7e0: 7863 6570 743b 0a0a 0909 6175 783a 3a70  xcept;....aux::p
    │ │ │ -0006f7f0: 6174 685f 696e 6465 785f 7420 6765 745f  ath_index_t get_
    │ │ │ -0006f800: 6f72 5f61 6464 5f70 6174 6828 7374 7269  or_add_path(stri
    │ │ │ -0006f810: 6e67 5f76 6965 7720 7061 7468 293b 0a0a  ng_view path);..
    │ │ │ -0006f820: 0909 2f2f 2074 6865 206e 756d 6265 7220  ..// the number 
    │ │ │ -0006f830: 6f66 2062 7974 6573 2069 6e20 6120 7265  of bytes in a re
    │ │ │ -0006f840: 6775 6c61 7220 7069 6563 650a 0909 2f2f  gular piece...//
    │ │ │ -0006f850: 2028 692e 652e 206e 6f74 2074 6865 2070   (i.e. not the p
    │ │ │ -0006f860: 6f74 656e 7469 616c 6c79 2074 7275 6e63  otentially trunc
    │ │ │ -0006f870: 6174 6564 206c 6173 7420 7069 6563 6529  ated last piece)
    │ │ │ -0006f880: 0a09 0969 6e74 206d 5f70 6965 6365 5f6c  ...int m_piece_l
    │ │ │ -0006f890: 656e 6774 6820 3d20 303b 0a0a 0909 2f2f  ength = 0;....//
    │ │ │ -0006f8a0: 2074 6865 206e 756d 6265 7220 6f66 2070   the number of p
    │ │ │ -0006f8b0: 6965 6365 7320 696e 2074 6865 2074 6f72  ieces in the tor
    │ │ │ -0006f8c0: 7265 6e74 0a09 0969 6e74 206d 5f6e 756d  rent...int m_num
    │ │ │ -0006f8d0: 5f70 6965 6365 7320 3d20 303b 0a0a 0909  _pieces = 0;....
    │ │ │ -0006f8e0: 2f2f 2077 6865 7468 6572 2074 6869 7320  // whether this 
    │ │ │ -0006f8f0: 6973 2061 2076 3220 746f 7272 656e 7420  is a v2 torrent 
    │ │ │ -0006f900: 6f72 206e 6f74 2e20 4164 6469 7469 6f6e  or not. Addition
    │ │ │ -0006f910: 616c 2072 6571 7569 7265 6d65 6e74 7320  al requirements 
    │ │ │ -0006f920: 6170 706c 7920 746f 0a09 092f 2f20 7632  apply to...// v2
    │ │ │ -0006f930: 2074 6f72 7265 6e74 730a 0909 626f 6f6c   torrents...bool
    │ │ │ -0006f940: 206d 5f76 3220 3d20 6661 6c73 653b 0a0a   m_v2 = false;..
    │ │ │ -0006f950: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0006f980: 766f 6964 2075 7064 6174 655f 7061 7468 void update_path │ │ │ -0006f990: 5f69 6e64 6578 2861 7578 3a3a 6669 6c65 _index(aux::file │ │ │ -0006f9a0: 5f65 6e74 7279 2661 6d70 3b20 652c 2073 _entry& e, s │ │ │ -0006f9b0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ -0006f9c0: 2661 6d70 3b20 7061 7468 0a3c 2f64 6976 & path.
    ..., bool set_n │ │ │ -0006f9e0: 616d 6520 3d20 7472 7565 293b 0a0a 0909 ame = true);.... │ │ │ -0006f9f0: 2f2f 2074 6865 206c 6973 7420 6f66 2066 // the list of f │ │ │ -0006fa00: 696c 6573 2074 6861 7420 7468 6973 2074 iles that this t │ │ │ -0006fa10: 6f72 7265 6e74 2063 6f6e 7369 7374 7320 orrent consists │ │ │ -0006fa20: 6f66 0a09 0961 7578 3a3a 7665 6374 6f72 of...aux::vector │ │ │ -0006fa30: 266c 743b 6175 783a 3a66 696c 655f 656e <aux::file_en │ │ │ -0006fa40: 7472 792c 2066 696c 655f 696e 6465 785f try, file_index_ │ │ │ -0006fa50: 7426 6774 3b20 6d5f 6669 6c65 733b 0a0a t> m_files;.. │ │ │ -0006fa60: 2369 6620 544f 5252 454e 545f 4142 495f #if TORRENT_ABI_ │ │ │ -0006fa70: 5645 5253 494f 4e20 266c 743b 2034 0a09 VERSION < 4.. │ │ │ -0006fa80: 092f 2f20 6966 2074 6865 7265 2061 7265 .// if there are │ │ │ -0006fa90: 2073 6861 3120 6861 7368 6573 2066 6f72 sha1 hashes for │ │ │ -0006faa0: 2065 6163 6820 696e 6469 7669 6475 616c each individual │ │ │ -0006fab0: 2066 696c 6520 7468 6572 6520 6172 6520 file there are │ │ │ -0006fac0: 6173 206d 616e 790a 0909 2f2f 2065 6e74 as many...// ent │ │ │ -0006fad0: 7269 6573 2069 6e20 7468 6973 2061 7272 ries in this arr │ │ │ -0006fae0: 6179 2061 7320 7468 6520 6d5f 6669 6c65 ay as the m_file │ │ │ -0006faf0: 7320 6172 7261 792e 2045 6163 6820 656e s array. Each en │ │ │ -0006fb00: 7472 7920 696e 206d 5f66 696c 6573 2068 try in m_files h │ │ │ -0006fb10: 6173 0a09 092f 2f20 6120 636f 7272 6573 as...// a corres │ │ │ -0006fb20: 706f 6e64 696e 6720 6861 7368 2070 6f69 ponding hash poi │ │ │ -0006fb30: 6e74 6572 2069 6e20 7468 6973 2061 7272 nter in this arr │ │ │ -0006fb40: 6179 2e20 5468 6520 7265 6173 6f6e 2074 ay. The reason t │ │ │ -0006fb50: 6f20 7370 6c69 7420 6974 2075 700a 0909 o split it up... │ │ │ -0006fb60: 2f2f 2069 6e20 7365 7061 7261 7465 2061 // in separate a │ │ │ -0006fb70: 7272 6179 7320 6973 2074 6f20 7361 7665 rrays is to save │ │ │ -0006fb80: 206d 656d 6f72 7920 696e 2063 6173 6520 memory in case │ │ │ -0006fb90: 7468 6520 746f 7272 656e 7420 646f 6573 the torrent does │ │ │ -0006fba0: 6e27 7420 6861 7665 0a09 092f 2f20 6669 n't have...// fi │ │ │ -0006fbb0: 6c65 2068 6173 6865 730a 0909 2f2f 2074 le hashes...// t │ │ │ -0006fbc0: 6865 2070 6f69 6e74 6572 7320 696e 2074 he pointers in t │ │ │ -0006fbd0: 6869 7320 7665 6374 6f72 2061 7265 2070 his vector are p │ │ │ -0006fbe0: 6f69 6e74 696e 6720 696e 746f 2074 6865 ointing into the │ │ │ -0006fbf0: 202e 746f 7272 656e 7420 6669 6c65 2069 .torrent file i │ │ │ -0006fc00: 6e0a 0909 2f2f 206d 656d 6f72 7920 7768 n...// memory wh │ │ │ -0006fc10: 6963 6820 6973 205f 6e6f 745f 206f 776e ich is _not_ own │ │ │ -0006fc20: 6564 2062 7920 7468 6973 2066 696c 655f ed by this file_ │ │ │ -0006fc30: 7374 6f72 6167 6520 6f62 6a65 6374 2e20 storage object. │ │ │ -0006fc40: 4974 2773 2073 696d 706c 790a 0909 2f2f It's simply...// │ │ │ -0006fc50: 2061 206e 6f6e 2d6f 776e 696e 6720 706f a non-owning po │ │ │ -0006fc60: 696e 7465 722e 2049 7420 6973 2074 6865 inter. It is the │ │ │ -0006fc70: 2075 7365 7227 7320 7265 7370 6f6e 7369 user's responsi │ │ │ -0006fc80: 6269 6c69 7479 2074 6861 7420 7468 6520 bility that the │ │ │ -0006fc90: 6861 7368 0a09 092f 2f20 7374 6179 7320 hash...// stays │ │ │ -0006fca0: 7661 6c69 6420 7468 726f 7567 686f 7574 valid throughout │ │ │ -0006fcb0: 2074 6865 206c 6966 6574 696d 6520 6f66 the lifetime of │ │ │ -0006fcc0: 2074 6869 7320 6669 6c65 5f73 746f 7261 this file_stora │ │ │ -0006fcd0: 6765 206f 626a 6563 742e 0a09 0961 7578 ge object....aux │ │ │ -0006fce0: 3a3a 7665 6374 6f72 266c 743b 6368 6172 ::vector<char │ │ │ -0006fcf0: 2063 6f6e 7374 2a2c 2066 696c 655f 696e const*, file_in │ │ │ -0006fd00: 6465 785f 7426 6774 3b20 6d5f 6669 6c65 dex_t> m_file │ │ │ -0006fd10: 5f68 6173 6865 733b 0a23 656e 6469 660a _hashes;.#endif. │ │ │ -0006fd20: 0a09 092f 2f20 666f 7220 6669 6c65 7320 ...// for files │ │ │ -0006fd30: 7468 6174 2061 7265 2073 796d 6c69 6e6b that are symlink │ │ │ -0006fd40: 732c 2074 6865 2073 796d 6c69 6e6b 0a09 s, the symlink.. │ │ │ -0006fd50: 092f 2f20 7061 7468 5f69 6e64 6578 2069 .// path_index i │ │ │ -0006fd60: 6e20 7468 6520 6175 783a 3a66 696c 655f n the aux::file_ │ │ │ -0006fd70: 656e 7472 7920 696e 6465 7865 730a 0909 entry indexes... │ │ │ -0006fd80: 2f2f 2074 6869 7320 7665 6374 6f72 206f // this vector o │ │ │ -0006fd90: 6620 7374 7269 6e67 730a 0909 7374 643a f strings...std: │ │ │ -0006fda0: 3a76 6563 746f 7226 6c74 3b73 7464 3a3a :vector<std:: │ │ │ -0006fdb0: 7374 7269 6e67 2667 743b 206d 5f73 796d string> m_sym │ │ │ -0006fdc0: 6c69 6e6b 733b 0a0a 0909 2f2f 2074 6865 links;....// the │ │ │ -0006fdd0: 206d 6f64 6966 6963 6174 696f 6e20 7469 modification ti │ │ │ -0006fde0: 6d65 7320 6f66 2065 6163 6820 6669 6c65 mes of each file │ │ │ -0006fdf0: 2e20 5468 6973 2076 6563 746f 720a 0909 . This vector... │ │ │ -0006fe00: 2f2f 2069 7320 656d 7074 7920 6966 206e // is empty if n │ │ │ -0006fe10: 6f20 6669 6c65 2068 6176 6520 6120 6d6f o file have a mo │ │ │ -0006fe20: 6469 6669 6361 7469 6f6e 2074 696d 652e dification time. │ │ │ -0006fe30: 0a09 092f 2f20 6561 6368 2065 6c65 6d65 ...// each eleme │ │ │ -0006fe40: 6e74 2063 6f72 7265 7370 6f6e 6473 2074 nt corresponds t │ │ │ -0006fe50: 6f20 7468 6520 6669 6c65 2077 6974 6820 o the file with │ │ │ -0006fe60: 7468 6520 7361 6d65 0a09 092f 2f20 696e the same...// in │ │ │ -0006fe70: 6465 7820 696e 206d 5f66 696c 6573 0a09 dex in m_files.. │ │ │ -0006fe80: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ -0006fe90: 7374 643a 3a74 696d 655f 742c 2066 696c std::time_t, fil │ │ │ -0006fea0: 655f 696e 6465 785f 7426 6774 3b20 6d5f e_index_t> m_ │ │ │ -0006feb0: 6d74 696d 653b 0a0a 0909 2f2f 2061 6c6c mtime;....// all │ │ │ -0006fec0: 2075 6e69 7175 6520 7061 7468 7320 6669 unique paths fi │ │ │ -0006fed0: 6c65 7320 6861 7665 2e20 5468 6520 6175 les have. The au │ │ │ -0006fee0: 783a 3a66 696c 655f 656e 7472 793a 3a70 x::file_entry::p │ │ │ -0006fef0: 6174 685f 696e 6465 780a 3c2f 7072 653e ath_index.
    │ │ │ -0006ff00: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006ff30: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006ff40: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -0006ff70: 6c69 6274 6f72 7265 6e74 2f73 6f63 6b65 libtorrent/socke │ │ │ -0006ff80: 745f 7479 7065 2e68 7070 3a33 393c 2f61 t_type.hpp:39move t │ │ │ -0006ffa0: 6f20 6175 783c 2f74 643e 3c2f 7472 3e3c o aux< │ │ │ -0006ffb0: 7472 2069 643d 2232 3536 2220 7374 796c tr id="256" styl │ │ │ -0006ffc0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0006ffd0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0006ffe0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0006fff0: 6832 3e6d 6f76 6520 746f 2061 7578 3c2f h2>move to aux

    ../includ │ │ │ -00070010: 652f 6c69 6274 6f72 7265 6e74 2f73 6f63 e/libtorrent/soc │ │ │ -00070020: 6b65 745f 7479 7065 2e68 7070 3a33 393c ket_type.hpp:39< │ │ │ -00070030: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ -00070070: 2f20 4120 7479 7065 2064 6573 6372 6962  / A type describ
    │ │ │ -00070080: 696e 6720 6b69 6e64 7320 6f66 2073 6f63  ing kinds of soc
    │ │ │ -00070090: 6b65 7473 2069 6e76 6f6c 7665 6420 696e  kets involved in
    │ │ │ -000700a0: 2076 6172 696f 7573 206f 7065 7261 7469   various operati
    │ │ │ -000700b0: 6f6e 7320 6f72 2065 7665 6e74 732e 0a65  ons or events..e
    │ │ │ -000700c0: 6e75 6d20 636c 6173 7320 736f 636b 6574  num class socket
    │ │ │ -000700d0: 5f74 7970 655f 7420 3a20 7374 643a 3a75  _type_t : std::u
    │ │ │ -000700e0: 696e 7438 5f74 207b 0a09 7463 702c 0a09  int8_t {..tcp,..
    │ │ │ -000700f0: 736f 636b 7335 2c0a 0968 7474 702c 0a09  socks5,..http,..
    │ │ │ -00070100: 7574 702c 0a09 6932 702c 0a09 7274 632c  utp,..i2p,..rtc,
    │ │ │ -00070110: 0a09 7463 705f 7373 6c2c 0a09 736f 636b  ..tcp_ssl,..sock
    │ │ │ -00070120: 7335 5f73 736c 2c0a 0968 7474 705f 7373  s5_ssl,..http_ss
    │ │ │ -00070130: 6c2c 0a09 7574 705f 7373 6c2c 0a0a 2369  l,..utp_ssl,..#i
    │ │ │ -00070140: 6620 544f 5252 454e 545f 4142 495f 5645  f TORRENT_ABI_VE
    │ │ │ -00070150: 5253 494f 4e20 266c 743b 3d20 320a 0975  RSION <= 2..u
    │ │ │ -00070160: 6470 2054 4f52 5245 4e54 5f44 4550 5245  dp TORRENT_DEPRE
    │ │ │ -00070170: 4341 5445 445f 454e 554d 203d 2075 7470  CATED_ENUM = utp
    │ │ │ -00070180: 2c0a 2365 6e64 6966 0a7d 3b0a 0a2f 2f20  ,.#endif.};..// 
    │ │ │ -00070190: 7265 7475 726e 2061 2073 686f 7274 2068  return a short h
    │ │ │ -000701a0: 756d 616e 2072 6561 6461 626c 6520 6e61  uman readable na
    │ │ │ -000701b0: 6d65 2066 6f72 2074 7970 6573 206f 6620  me for types of 
    │ │ │ -000701c0: 736f 636b 6574 0a3c 6469 7620 7374 796c  socket.
    char const* │ │ │ -00070200: 2073 6f63 6b65 745f 7479 7065 5f6e 616d socket_type_nam │ │ │ -00070210: 6528 736f 636b 6574 5f74 7970 655f 7429 e(socket_type_t) │ │ │ -00070220: 3b0a 3c2f 6469 763e 0a7d 0a0a 2365 6e64 ;.
    .}..#end │ │ │ -00070230: 6966 0a3c 2f70 7265 3e3c 2f74 643e 3c2f if.
    │ │ │ -00070260: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00070270: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -000702a0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -000702b0: 656e 742f 7065 7266 6f72 6d61 6e63 655f ent/performance_ │ │ │ -000702c0: 636f 756e 7465 7273 2e68 7070 3a35 3230 counters.hpp:520 │ │ │ -000702d0: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 6f6d som │ │ │ -000702e0: 6520 7370 6163 6520 636f 756c 6420 6265 e space could be │ │ │ -000702f0: 2073 6176 6564 2068 6572 6520 6279 206d saved here by m │ │ │ -00070300: 616b 696e 6720 6761 7567 6573 2033 3220 aking gauges 32 │ │ │ -00070310: 6269 7473 3c2f 7464 3e3c 2f74 723e 3c74 bitssome space cou │ │ │ -00070370: 6c64 2062 6520 7361 7665 6420 6865 7265 ld be saved here │ │ │ -00070380: 2062 7920 6d61 6b69 6e67 2067 6175 6765 by making gauge │ │ │ -00070390: 7320 3332 2062 6974 733c 2f68 323e 3c68 s 32 bits

    ../include/lib │ │ │ -000703b0: 746f 7272 656e 742f 7065 7266 6f72 6d61 torrent/performa │ │ │ -000703c0: 6e63 655f 636f 756e 7465 7273 2e68 7070 nce_counters.hpp │ │ │ -000703d0: 3a35 3230 3c2f 6834 3e3c 7072 6520 7374 :520
    
    │ │ │ -00070440: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ -00070450: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ -00070480: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272  /include/libtorr
    │ │ │ -00070490: 656e 742f 7065 7266 6f72 6d61 6e63 655f  ent/performance_
    │ │ │ -000704a0: 636f 756e 7465 7273 2e68 7070 3a35 3231  counters.hpp:521
    │ │ │ -000704b0: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6573  res
    │ │ │ -000704c0: 746f 7265 2074 6865 7365 2074 6f20 7265  tore these to re
    │ │ │ -000704d0: 6775 6c61 7220 696e 7465 6765 7273 2e20  gular integers. 
    │ │ │ -000704e0: 496e 7374 6561 6420 6861 7665 206f 6e65  Instead have one
    │ │ │ -000704f0: 2063 6f70 7920 6f66 2074 6865 2063 6f75   copy of the cou
    │ │ │ -00070500: 6e74 6572 7320 7065 7220 7468 7265 6164  nters per thread
    │ │ │ -00070510: 2061 6e64 2063 6f6c 6c65 6374 2074 6865   and collect the
    │ │ │ -00070520: 6d20 6174 2063 6f6e 7665 6e69 656e 7420  m at convenient 
    │ │ │ -00070530: 7379 6e63 6872 6f6e 697a 6174 696f 6e20  synchronization 
    │ │ │ -00070540: 706f 696e 7473 3c2f 7464 3e3c 2f74 723e  points
    │ │ │ -00070550: 3c74 7220 6964 3d22 3235 3822 2073 7479  
    │ │ │ -00070580: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ -00070590: 3c68 323e 7265 7374 6f72 6520 7468 6573  

    restore thes │ │ │ -000705a0: 6520 746f 2072 6567 756c 6172 2069 6e74 e to regular int │ │ │ -000705b0: 6567 6572 732e 2049 6e73 7465 6164 2068 egers. Instead h │ │ │ -000705c0: 6176 6520 6f6e 6520 636f 7079 0a6f 6620 ave one copy.of │ │ │ -000705d0: 7468 6520 636f 756e 7465 7273 2070 6572 the counters per │ │ │ -000705e0: 2074 6872 6561 6420 616e 6420 636f 6c6c thread and coll │ │ │ -000705f0: 6563 7420 7468 656d 2061 7420 636f 6e76 ect them at conv │ │ │ -00070600: 656e 6965 6e74 0a73 796e 6368 726f 6e69 enient.synchroni │ │ │ -00070610: 7a61 7469 6f6e 2070 6f69 6e74 733c 2f68 zation points

    ../include │ │ │ -00070630: 2f6c 6962 746f 7272 656e 742f 7065 7266 /libtorrent/perf │ │ │ -00070640: 6f72 6d61 6e63 655f 636f 756e 7465 7273 ormance_counters │ │ │ -00070650: 2e68 7070 3a35 3231 3c2f 6834 3e3c 7072 .hpp:521

    ..counter │ │ │ -000706a0: 7328 636f 756e 7465 7273 2063 6f6e 7374 s(counters const │ │ │ -000706b0: 2661 6d70 3b29 2054 4f52 5245 4e54 5f43 &) TORRENT_C │ │ │ -000706c0: 4f55 4e54 4552 5f4e 4f45 5843 4550 543b OUNTER_NOEXCEPT; │ │ │ -000706d0: 0a09 0963 6f75 6e74 6572 7326 616d 703b ...counters& │ │ │ -000706e0: 206f 7065 7261 746f 723d 2863 6f75 6e74 operator=(count │ │ │ -000706f0: 6572 7320 636f 6e73 7426 616d 703b 2920 ers const&) │ │ │ -00070700: 2661 6d70 3b20 544f 5252 454e 545f 434f & TORRENT_CO │ │ │ -00070710: 554e 5445 525f 4e4f 4558 4345 5054 3b0a UNTER_NOEXCEPT;. │ │ │ -00070720: 0a09 092f 2f20 696e 6372 656d 656e 7473 ...// increments │ │ │ -00070730: 2074 6865 2063 6f75 6e74 6572 206f 7220 the counter or │ │ │ -00070740: 6761 7567 6520 6060 6360 6020 2861 6e20 gauge ``c`` (an │ │ │ -00070750: 696e 6465 7820 696e 746f 2074 6865 2063 index into the c │ │ │ -00070760: 6f75 6e74 6572 0a09 092f 2f20 6172 7261 ounter...// arra │ │ │ -00070770: 7929 2062 7920 6060 7661 6c75 6560 6020 y) by ``value`` │ │ │ -00070780: 616e 6420 7265 7475 726e 7320 7468 6520 and returns the │ │ │ -00070790: 6e65 7720 7661 6c75 652e 0a09 0973 7464 new value....std │ │ │ -000707a0: 3a3a 696e 7436 345f 7420 696e 635f 7374 ::int64_t inc_st │ │ │ -000707b0: 6174 735f 636f 756e 7465 7228 696e 7420 ats_counter(int │ │ │ -000707c0: 632c 2073 7464 3a3a 696e 7436 345f 7420 c, std::int64_t │ │ │ -000707d0: 7661 6c75 6520 3d20 3129 2054 4f52 5245 value = 1) TORRE │ │ │ -000707e0: 4e54 5f43 4f55 4e54 4552 5f4e 4f45 5843 NT_COUNTER_NOEXC │ │ │ -000707f0: 4550 543b 0a0a 0909 2f2f 2072 6574 7572 EPT;....// retur │ │ │ -00070800: 6e73 2074 6865 2063 7572 7265 6e74 2076 ns the current v │ │ │ -00070810: 616c 7565 206f 6620 636f 756e 7465 7220 alue of counter │ │ │ -00070820: 6f72 2067 6175 6765 2060 6069 6060 2028 or gauge ``i`` ( │ │ │ -00070830: 616e 2069 6e64 6578 2069 6e74 6f0a 0909 an index into... │ │ │ -00070840: 2f2f 2074 6865 2063 6f75 6e74 6572 2061 // the counter a │ │ │ -00070850: 7272 6179 292e 0a09 0973 7464 3a3a 696e rray)....std::in │ │ │ -00070860: 7436 345f 7420 6f70 6572 6174 6f72 5b5d t64_t operator[] │ │ │ -00070870: 2869 6e74 2069 2920 636f 6e73 7420 544f (int i) const TO │ │ │ -00070880: 5252 454e 545f 434f 554e 5445 525f 4e4f RRENT_COUNTER_NO │ │ │ -00070890: 4558 4345 5054 3b0a 0a09 092f 2f20 6f76 EXCEPT;....// ov │ │ │ -000708a0: 6572 7772 6974 6573 2074 6865 2076 616c erwrites the val │ │ │ -000708b0: 7565 206f 6620 636f 756e 7465 7220 6f72 ue of counter or │ │ │ -000708c0: 2067 6175 6765 2060 6063 6060 2028 616e gauge ``c`` (an │ │ │ -000708d0: 2069 6e64 6578 2069 6e74 6f0a 0909 2f2f index into...// │ │ │ -000708e0: 2074 6865 2063 6f75 6e74 6572 2061 7272 the counter arr │ │ │ -000708f0: 6179 292e 2060 6062 6c65 6e64 5f73 7461 ay). ``blend_sta │ │ │ -00070900: 7473 5f63 6f75 6e74 6572 2829 6060 2061 ts_counter()`` a │ │ │ -00070910: 646a 7573 7473 2074 6865 2073 7461 7420 djusts the stat │ │ │ -00070920: 7661 6c75 650a 0909 2f2f 2074 6f77 6172 value...// towar │ │ │ -00070930: 6420 7468 6520 7370 6563 6966 6965 6420 d the specified │ │ │ -00070940: 6060 7661 6c75 6560 602c 2060 6072 6174 ``value``, ``rat │ │ │ -00070950: 696f 6060 2073 7065 6369 6669 6573 2074 io`` specifies t │ │ │ -00070960: 6865 2070 6572 6365 6e74 206f 660a 0909 he percent of... │ │ │ -00070970: 2f2f 2074 6865 206e 6577 2076 616c 7565 // the new value │ │ │ -00070980: 2073 686f 756c 6420 6265 2069 6e66 6c75 should be influ │ │ │ -00070990: 656e 6365 6420 6279 2060 6076 616c 7565 enced by ``value │ │ │ -000709a0: 6060 2e0a 0909 766f 6964 2073 6574 5f76 ``....void set_v │ │ │ -000709b0: 616c 7565 2869 6e74 2063 2c20 7374 643a alue(int c, std: │ │ │ -000709c0: 3a69 6e74 3634 5f74 2076 616c 7565 2920 :int64_t value) │ │ │ -000709d0: 544f 5252 454e 545f 434f 554e 5445 525f TORRENT_COUNTER_ │ │ │ -000709e0: 4e4f 4558 4345 5054 3b0a 0909 766f 6964 NOEXCEPT;...void │ │ │ -000709f0: 2062 6c65 6e64 5f73 7461 7473 5f63 6f75 blend_stats_cou │ │ │ -00070a00: 6e74 6572 2869 6e74 2063 2c20 7374 643a nter(int c, std: │ │ │ -00070a10: 3a69 6e74 3634 5f74 2076 616c 7565 2c20 :int64_t value, │ │ │ -00070a20: 696e 7420 7261 7469 6f29 2054 4f52 5245 int ratio) TORRE │ │ │ -00070a30: 4e54 5f43 4f55 4e54 4552 5f4e 4f45 5843 NT_COUNTER_NOEXC │ │ │ -00070a40: 4550 543b 0a0a 0970 7269 7661 7465 3a0a EPT;...private:. │ │ │ -00070a50: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    # │ │ │ -00070a80: 6966 6465 6620 4154 4f4d 4943 5f4c 4c4f ifdef ATOMIC_LLO │ │ │ -00070a90: 4e47 5f4c 4f43 4b5f 4652 4545 0a3c 2f64 NG_LOCK_FREE...aux::array& │ │ │ -00070ab0: 6c74 3b73 7464 3a3a 6174 6f6d 6963 266c lt;std::atomic&l │ │ │ -00070ac0: 743b 7374 643a 3a69 6e74 3634 5f74 2667 t;std::int64_t&g │ │ │ -00070ad0: 743b 2c20 6e75 6d5f 636f 756e 7465 7273 t;, num_counters │ │ │ -00070ae0: 2667 743b 206d 5f73 7461 7473 5f63 6f75 > m_stats_cou │ │ │ -00070af0: 6e74 6572 3b0a 2365 6c73 650a 0909 2f2f nter;.#else...// │ │ │ -00070b00: 2069 6620 7468 6520 6174 6f6d 6963 2074 if the atomic t │ │ │ -00070b10: 7970 6520 6973 6e27 7420 6c6f 636b 2d66 ype isn't lock-f │ │ │ -00070b20: 7265 652c 2075 7365 2061 2073 696e 676c ree, use a singl │ │ │ -00070b30: 6520 6c6f 636b 2069 6e73 7465 6164 2c20 e lock instead, │ │ │ -00070b40: 666f 720a 0909 2f2f 2074 6865 2077 686f for...// the who │ │ │ -00070b50: 6c65 2061 7272 6179 0a09 096d 7574 6162 le array...mutab │ │ │ -00070b60: 6c65 2073 7464 3a3a 6d75 7465 7820 6d5f le std::mutex m_ │ │ │ -00070b70: 6d75 7465 783b 0a09 0961 7578 3a3a 6172 mutex;...aux::ar │ │ │ -00070b80: 7261 7926 6c74 3b73 7464 3a3a 696e 7436 ray<std::int6 │ │ │ -00070b90: 345f 742c 206e 756d 5f63 6f75 6e74 6572 4_t, num_counter │ │ │ -00070ba0: 7326 6774 3b20 6d5f 7374 6174 735f 636f s> m_stats_co │ │ │ -00070bb0: 756e 7465 723b 0a23 656e 6469 660a 097d unter;.#endif..} │ │ │ -00070bc0: 3b0a 7d0a 0a23 656e 6469 660a 3c2f 7072 ;.}..#endif.rel │ │ │ -00070c00: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -00070c40: 652f 6c69 6274 6f72 7265 6e74 2f75 706e e/libtorrent/upn │ │ │ -00070c50: 702e 6870 703a 3134 323c 2f61 3e3c 2f74 p.hpp:142support us │ │ │ -00070c70: 696e 6720 7468 6520 7769 6e64 6f77 7320 ing the windows │ │ │ -00070c80: 4150 4920 666f 7220 5550 6e50 206f 7065 API for UPnP ope │ │ │ -00070c90: 7261 7469 6f6e 7320 6173 2077 656c 6c3c rations as well< │ │ │ -00070ca0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sup │ │ │ -00070cf0: 706f 7274 2075 7369 6e67 2074 6865 2077 port using the w │ │ │ -00070d00: 696e 646f 7773 2041 5049 2066 6f72 2055 indows API for U │ │ │ -00070d10: 506e 5020 6f70 6572 6174 696f 6e73 2061 PnP operations a │ │ │ -00070d20: 7320 7765 6c6c 3c2f 6832 3e3c 6834 3e2e s well

    . │ │ │ -00070d30: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00070d40: 7265 6e74 2f75 706e 702e 6870 703a 3134 rent/upnp.hpp:14 │ │ │ -00070d50: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ -00070d90: 7b0a 0962 6f6f 6c20 696e 5f65 7272 6f72  {..bool in_error
    │ │ │ -00070da0: 5f63 6f64 6520 3d20 6661 6c73 653b 0a09  _code = false;..
    │ │ │ -00070db0: 626f 6f6c 2065 7869 7420 3d20 6661 6c73  bool exit = fals
    │ │ │ -00070dc0: 653b 0a09 696e 7420 6572 726f 725f 636f  e;..int error_co
    │ │ │ -00070dd0: 6465 203d 202d 313b 0a7d 3b0a 0a73 7472  de = -1;.};..str
    │ │ │ -00070de0: 7563 7420 6970 5f61 6464 7265 7373 5f70  uct ip_address_p
    │ │ │ -00070df0: 6172 7365 5f73 7461 7465 3a20 6572 726f  arse_state: erro
    │ │ │ -00070e00: 725f 636f 6465 5f70 6172 7365 5f73 7461  r_code_parse_sta
    │ │ │ -00070e10: 7465 0a7b 0a09 626f 6f6c 2069 6e5f 6970  te.{..bool in_ip
    │ │ │ -00070e20: 5f61 6464 7265 7373 203d 2066 616c 7365  _address = false
    │ │ │ -00070e30: 3b0a 0973 7464 3a3a 7374 7269 6e67 2069  ;..std::string i
    │ │ │ -00070e40: 705f 6164 6472 6573 733b 0a7d 3b0a 0a54  p_address;.};..T
    │ │ │ -00070e50: 4f52 5245 4e54 5f45 5854 5241 5f45 5850  ORRENT_EXTRA_EXP
    │ │ │ -00070e60: 4f52 5420 766f 6964 2066 696e 645f 636f  ORT void find_co
    │ │ │ -00070e70: 6e74 726f 6c5f 7572 6c28 696e 7420 7479  ntrol_url(int ty
    │ │ │ -00070e80: 7065 2c20 7374 7269 6e67 5f76 6965 772c  pe, string_view,
    │ │ │ -00070e90: 2070 6172 7365 5f73 7461 7465 2661 6d70   parse_state&
    │ │ │ -00070ea0: 3b20 7374 6174 6529 3b0a 0a54 4f52 5245  ; state);..TORRE
    │ │ │ -00070eb0: 4e54 5f45 5854 5241 5f45 5850 4f52 5420  NT_EXTRA_EXPORT 
    │ │ │ -00070ec0: 766f 6964 2066 696e 645f 6572 726f 725f  void find_error_
    │ │ │ -00070ed0: 636f 6465 2869 6e74 2074 7970 652c 2073  code(int type, s
    │ │ │ -00070ee0: 7472 696e 675f 7669 6577 2073 7472 696e  tring_view strin
    │ │ │ -00070ef0: 670a 092c 2065 7272 6f72 5f63 6f64 655f  g.., error_code_
    │ │ │ -00070f00: 7061 7273 655f 7374 6174 6526 616d 703b  parse_state&
    │ │ │ -00070f10: 2073 7461 7465 293b 0a0a 544f 5252 454e   state);..TORREN
    │ │ │ -00070f20: 545f 4558 5452 415f 4558 504f 5254 2076  T_EXTRA_EXPORT v
    │ │ │ -00070f30: 6f69 6420 6669 6e64 5f69 705f 6164 6472  oid find_ip_addr
    │ │ │ -00070f40: 6573 7328 696e 7420 7479 7065 2c20 7374  ess(int type, st
    │ │ │ -00070f50: 7269 6e67 5f76 6965 7720 7374 7269 6e67  ring_view string
    │ │ │ -00070f60: 0a09 2c20 6970 5f61 6464 7265 7373 5f70  .., ip_address_p
    │ │ │ -00070f70: 6172 7365 5f73 7461 7465 2661 6d70 3b20  arse_state& 
    │ │ │ -00070f80: 7374 6174 6529 3b0a 0a3c 6469 7620 7374  state);..
    struct TO │ │ │ -00070fc0: 5252 454e 545f 4558 5452 415f 4558 504f RRENT_EXTRA_EXPO │ │ │ -00070fd0: 5254 2075 706e 7020 6669 6e61 6c0a 3c2f RT upnp final..: std::enab │ │ │ -00070ff0: 6c65 5f73 6861 7265 645f 6672 6f6d 5f74 le_shared_from_t │ │ │ -00071000: 6869 7326 6c74 3b75 706e 7026 6774 3b0a his<upnp>. │ │ │ -00071010: 092c 2061 7578 3a3a 7369 6e67 6c65 5f74 ., aux::single_t │ │ │ -00071020: 6872 6561 6465 640a 7b0a 0975 706e 7028 hreaded.{..upnp( │ │ │ -00071030: 696f 5f63 6f6e 7465 7874 2661 6d70 3b20 io_context& │ │ │ -00071040: 696f 730a 0909 2c20 6175 783a 3a73 6573 ios..., aux::ses │ │ │ -00071050: 7369 6f6e 5f73 6574 7469 6e67 7320 636f sion_settings co │ │ │ -00071060: 6e73 7426 616d 703b 2073 6574 7469 6e67 nst& setting │ │ │ -00071070: 730a 0909 2c20 6175 783a 3a70 6f72 746d s..., aux::portm │ │ │ -00071080: 6170 5f63 616c 6c62 6163 6b26 616d 703b ap_callback& │ │ │ -00071090: 2063 620a 0909 2c20 6164 6472 6573 735f cb..., address_ │ │ │ -000710a0: 7634 206c 6973 7465 6e5f 6164 6472 6573 v4 listen_addres │ │ │ -000710b0: 730a 0909 2c20 6164 6472 6573 735f 7634 s..., address_v4 │ │ │ -000710c0: 206e 6574 6d61 736b 0a09 092c 2073 7464 netmask..., std │ │ │ -000710d0: 3a3a 7374 7269 6e67 206c 6973 7465 6e5f ::string listen_ │ │ │ -000710e0: 6465 7669 6365 0a09 092c 2061 7578 3a3a device..., aux:: │ │ │ -000710f0: 6c69 7374 656e 5f73 6f63 6b65 745f 6861 listen_socket_ha │ │ │ -00071100: 6e64 6c65 206c 7329 3b0a 097e 7570 6e70 ndle ls);..~upnp │ │ │ -00071110: 2829 3b0a 0a09 766f 6964 2073 7461 7274 ();...void start │ │ │ -00071120: 2829 3b0a 0a09 2f2f 2041 7474 656d 7074 ();...// Attempt │ │ │ -00071130: 7320 746f 2061 6464 2061 2070 6f72 7420 s to add a port │ │ │ -00071140: 6d61 7070 696e 6720 666f 7220 7468 6520 mapping for the │ │ │ -00071150: 7370 6563 6966 6965 6420 7072 6f74 6f63 specified protoc │ │ │ -00071160: 6f6c 2e20 5661 6c69 6420 7072 6f74 6f63 ol. Valid protoc │ │ │ -00071170: 6f6c 7320 6172 650a 092f 2f20 6060 7570 ols are..// ``up │ │ │ -00071180: 6e70 3a3a 7463 7060 6020 616e 6420 6060 np::tcp`` and `` │ │ │ -00071190: 7570 6e70 3a3a 7564 7060 6020 666f 7220 upnp::udp`` for │ │ │ -000711a0: 7468 6520 5550 6e50 2063 6c61 7373 2061 the UPnP class a │ │ │ -000711b0: 6e64 2060 606e 6174 706d 703a 3a74 6370 nd ``natpmp::tcp │ │ │ -000711c0: 6060 2061 6e64 0a09 2f2f 2060 606e 6174 `` and..// ``nat │ │ │ -000711d0: 706d 703a 3a75 6470 6060 2066 6f72 2074 pmp::udp`` for t │ │ │ -000711e0: 6865 204e 4154 2d50 4d50 2063 6c61 7373 he NAT-PMP class │ │ │ -000711f0: 2e0a 092f 2f0a 092f 2f20 6060 6578 7465 ...//..// ``exte │ │ │ -00071200: 726e 616c 5f70 6f72 7460 6020 6973 2074 rnal_port`` is t │ │ │ -00071210: 6865 2070 6f72 7420 6f6e 2074 6865 2065 he port on the e │ │ │ -00071220: 7874 6572 6e61 6c20 6164 6472 6573 7320 xternal address │ │ │ -00071230: 7468 6174 2077 696c 6c20 6265 206d 6170 that will be map │ │ │ -00071240: 7065 642e 2054 6869 730a 092f 2f20 6973 ped. This..// is │ │ │ -00071250: 2061 2068 696e 742c 2079 6f75 2061 7265 a hint, you are │ │ │ -00071260: 206e 6f74 2067 7561 7261 6e74 6565 6420 not guaranteed │ │ │ -00071270: 7468 6174 2074 6869 7320 706f 7274 2077 that this port w │ │ │ -00071280: 696c 6c20 6265 2061 7661 696c 6162 6c65 ill be available │ │ │ -00071290: 2c20 616e 6420 6974 206d 6179 0a09 2f2f , and it may..// │ │ │ -000712a0: 2065 6e64 2075 7020 6265 696e 6720 736f end up being so │ │ │ -000712b0: 6d65 7468 696e 6720 656c 7365 2e20 496e mething else. In │ │ │ -000712c0: 2074 6865 2070 6f72 746d 6170 5f61 6c65 the portmap_ale │ │ │ -000712d0: 7274 5f20 6e6f 7469 6669 6361 7469 6f6e rt_ notification │ │ │ -000712e0: 2c20 7468 6520 6163 7475 616c 0a09 2f2f , the actual..// │ │ │ -000712f0: 2065 7874 6572 6e61 6c20 706f 7274 2069 external port i │ │ │ -00071300: 7320 7265 706f 7274 6564 2e0a 092f 2f0a s reported...//. │ │ │ -00071310: 092f 2f20 6060 6c6f 6361 6c5f 706f 7274 .// ``local_port │ │ │ -00071320: 6060 2069 7320 7468 6520 706f 7274 2069 `` is the port i │ │ │ -00071330: 6e20 7468 6520 6c6f 6361 6c20 6d61 6368 n the local mach │ │ │ -00071340: 696e 6520 7468 6174 2074 6865 206d 6170 ine that the map │ │ │ -00071350: 7069 6e67 2073 686f 756c 6420 666f 7277 ping should forw │ │ │ -00071360: 6172 640a 092f 2f20 746f 2e0a 092f 2f0a ard..// to...//. │ │ │ -00071370: 092f 2f20 5468 6520 7265 7475 726e 2076 .// The return v │ │ │ -00071380: 616c 7565 2069 7320 616e 2069 6e64 6578 alue is an index │ │ │ -00071390: 2074 6861 7420 6964 656e 7469 6669 6573 that identifies │ │ │ -000713a0: 2074 6869 7320 706f 7274 206d 6170 7069 this port mappi │ │ │ -000713b0: 6e67 2e20 5468 6973 2069 7320 7573 6564 ng. This is used │ │ │ -000713c0: 0a09 2f2f 2074 6f20 7265 6665 7220 746f ..// to refer to │ │ │ -000713d0: 206d 6170 7069 6e67 7320 7468 6174 2066 mappings that f │ │ │ -000713e0: 6169 6c73 206f 7220 7375 6363 6565 6473 ails or succeeds │ │ │ -000713f0: 2069 6e20 7468 6520 706f 7274 6d61 705f in the portmap_ │ │ │ -00071400: 6572 726f 725f 616c 6572 745f 2061 6e64 error_alert_ and │ │ │ -00071410: 0a09 2f2f 2070 6f72 746d 6170 5f61 6c65 ..// portmap_ale │ │ │ -00071420: 7274 5f20 7265 7370 6563 7469 7665 6c79 rt_ respectively │ │ │ -00071430: 2e20 4966 2054 6865 206d 6170 7069 6e67 . If The mapping │ │ │ -00071440: 2066 6169 6c73 2069 6d6d 6564 6961 7465 fails immediate │ │ │ -00071450: 6c79 2c20 7468 6520 7265 7475 726e 2076 ly, the return v │ │ │ -00071460: 616c 7565 0a09 2f2f 2069 7320 2d31 2c20 alue..// is -1, │ │ │ -00071470: 7768 6963 6820 6d65 616e 7320 6661 696c which means fail │ │ │ -00071480: 7572 652e 2054 6865 7265 2077 696c 6c20 ure. There will │ │ │ -00071490: 6e6f 7420 6265 2061 6e79 2065 7272 6f72 not be any error │ │ │ -000714a0: 2061 6c65 7274 206e 6f74 6966 6963 6174 alert notificat │ │ │ -000714b0: 696f 6e20 666f 720a 3c2f 7072 653e 3c2f ion for.
    relevan │ │ │ -000714f0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -00071530: 6274 6f72 7265 6e74 2f69 6465 6e74 6966 btorrent/identif │ │ │ -00071540: 795f 636c 6965 6e74 2e68 7070 3a32 333c y_client.hpp:23< │ │ │ -00071550: 2f61 3e3c 2f74 643e 3c74 643e 6869 6465 /a>hide │ │ │ -00071560: 2074 6869 7320 6465 636c 6172 6174 696f this declaratio │ │ │ -00071570: 6e20 7768 656e 2064 6570 7265 6361 7465 n when deprecate │ │ │ -00071580: 6420 6675 6e63 7469 6f6e 7320 6172 6520 d functions are │ │ │ -00071590: 6469 7361 626c 6564 2c20 616e 6420 7265 disabled, and re │ │ │ -000715a0: 6d6f 7665 2069 7473 2069 6e74 6572 6e61 move its interna │ │ │ -000715b0: 6c20 7573 653c 2f74 643e 3c2f 7472 3e3c l use< │ │ │ -000715c0: 7472 2069 643d 2232 3630 2220 7374 796c tr id="260" styl │ │ │ -000715d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000715e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000715f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00071600: 6832 3e68 6964 6520 7468 6973 2064 6563 h2>hide this dec │ │ │ -00071610: 6c61 7261 7469 6f6e 2077 6865 6e20 6465 laration when de │ │ │ -00071620: 7072 6563 6174 6564 2066 756e 6374 696f precated functio │ │ │ -00071630: 6e73 2061 7265 2064 6973 6162 6c65 642c ns are disabled, │ │ │ -00071640: 2061 6e64 0a72 656d 6f76 6520 6974 7320 and.remove its │ │ │ -00071650: 696e 7465 726e 616c 2075 7365 3c2f 6832 internal use

    ../include/ │ │ │ -00071670: 6c69 6274 6f72 7265 6e74 2f69 6465 6e74 libtorrent/ident │ │ │ -00071680: 6966 795f 636c 6965 6e74 2e68 7070 3a32 ify_client.hpp:2 │ │ │ -00071690: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -000716d0: 436f 7079 7269 6768 7420 2863 2920 3230  Copyright (c) 20
    │ │ │ -000716e0: 3033 2c20 3230 3036 2c20 3230 3133 2d32  03, 2006, 2013-2
    │ │ │ -000716f0: 3032 312c 2041 7276 6964 204e 6f72 6265  021, Arvid Norbe
    │ │ │ -00071700: 7267 0a43 6f70 7972 6967 6874 2028 6329  rg.Copyright (c)
    │ │ │ -00071710: 2032 3032 302c 2041 6c64 656e 2054 6f72   2020, Alden Tor
    │ │ │ -00071720: 7265 730a 416c 6c20 7269 6768 7473 2072  res.All rights r
    │ │ │ -00071730: 6573 6572 7665 642e 0a0a 596f 7520 6d61  eserved...You ma
    │ │ │ -00071740: 7920 7573 652c 2064 6973 7472 6962 7574  y use, distribut
    │ │ │ -00071750: 6520 616e 6420 6d6f 6469 6679 2074 6869  e and modify thi
    │ │ │ -00071760: 7320 636f 6465 2075 6e64 6572 2074 6865  s code under the
    │ │ │ -00071770: 2074 6572 6d73 206f 6620 7468 6520 4253   terms of the BS
    │ │ │ -00071780: 4420 6c69 6365 6e73 652c 0a73 6565 204c  D license,.see L
    │ │ │ -00071790: 4943 454e 5345 2066 696c 652e 0a2a 2f0a  ICENSE file..*/.
    │ │ │ -000717a0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -000717b0: 5f49 4445 4e54 4946 595f 434c 4945 4e54  _IDENTIFY_CLIENT
    │ │ │ -000717c0: 5f48 5050 5f49 4e43 4c55 4445 440a 2364  _HPP_INCLUDED.#d
    │ │ │ -000717d0: 6566 696e 6520 544f 5252 454e 545f 4944  efine TORRENT_ID
    │ │ │ -000717e0: 454e 5449 4659 5f43 4c49 454e 545f 4850  ENTIFY_CLIENT_HP
    │ │ │ -000717f0: 505f 494e 434c 5544 4544 0a0a 2369 6e63  P_INCLUDED..#inc
    │ │ │ -00071800: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -00071810: 2f63 6f6e 6669 672e 6870 7022 0a0a 2369  /config.hpp"..#i
    │ │ │ -00071820: 6620 544f 5252 454e 545f 4142 495f 5645  f TORRENT_ABI_VE
    │ │ │ -00071830: 5253 494f 4e20 3d3d 2031 0a23 696e 636c  RSION == 1.#incl
    │ │ │ -00071840: 7564 6520 266c 743b 6f70 7469 6f6e 616c  ude <optional
    │ │ │ -00071850: 2667 743b 0a23 656e 6469 660a 0a23 696e  >.#endif..#in
    │ │ │ -00071860: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -00071870: 742f 7065 6572 5f69 642e 6870 7022 0a23  t/peer_id.hpp".#
    │ │ │ -00071880: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00071890: 656e 742f 6669 6e67 6572 7072 696e 742e  ent/fingerprint.
    │ │ │ -000718a0: 6870 7022 0a0a 3c64 6976 2073 7479 6c65  hpp"..
    namespace li │ │ │ -000718e0: 6274 6f72 7265 6e74 207b 0a3c 2f64 6976 btorrent {.
    .namespace aux │ │ │ -00071900: 7b0a 0a09 544f 5252 454e 545f 4558 5452 {...TORRENT_EXTR │ │ │ -00071910: 415f 4558 504f 5254 0a09 7374 643a 3a73 A_EXPORT..std::s │ │ │ -00071920: 7472 696e 6720 6964 656e 7469 6679 5f63 tring identify_c │ │ │ -00071930: 6c69 656e 745f 696d 706c 2863 6f6e 7374 lient_impl(const │ │ │ -00071940: 2070 6565 725f 6964 2661 6d70 3b20 7029 peer_id& p) │ │ │ -00071950: 3b0a 0a7d 0a0a 092f 2f20 7468 6573 6520 ;..}...// these │ │ │ -00071960: 6675 6e63 7469 6f6e 7320 646f 6e27 7420 functions don't │ │ │ -00071970: 7265 616c 6c79 206e 6565 6420 746f 2062 really need to b │ │ │ -00071980: 6520 7075 626c 6963 2e20 5468 6973 206d e public. This m │ │ │ -00071990: 6563 6861 6e69 736d 206f 660a 092f 2f20 echanism of..// │ │ │ -000719a0: 6164 7665 7274 6973 696e 6720 636c 6965 advertising clie │ │ │ -000719b0: 6e74 2073 6f66 7477 6172 6520 616e 6420 nt software and │ │ │ -000719c0: 7665 7273 696f 6e20 6973 2061 6c73 6f20 version is also │ │ │ -000719d0: 6f75 742d 6461 7465 642e 0a0a 092f 2f20 out-dated....// │ │ │ -000719e0: 5468 6973 2066 756e 6374 696f 6e20 6361 This function ca │ │ │ -000719f0: 6e20 6361 6e20 6265 2075 7365 6420 746f n can be used to │ │ │ -00071a00: 2065 7874 7261 6374 2061 2073 7472 696e extract a strin │ │ │ -00071a10: 6720 6465 7363 7269 6269 6e67 2061 2063 g describing a c │ │ │ -00071a20: 6c69 656e 740a 092f 2f20 7665 7273 696f lient..// versio │ │ │ -00071a30: 6e20 6672 6f6d 2069 7473 2070 6565 722d n from its peer- │ │ │ -00071a40: 6964 2e20 4974 2077 696c 6c20 7265 636f id. It will reco │ │ │ -00071a50: 676e 697a 6520 6d6f 7374 2063 6c69 656e gnize most clien │ │ │ -00071a60: 7473 2074 6861 7420 6861 7665 2074 6869 ts that have thi │ │ │ -00071a70: 730a 092f 2f20 6b69 6e64 206f 6620 6964 s..// kind of id │ │ │ -00071a80: 656e 7469 6669 6361 7469 6f6e 2069 6e20 entification in │ │ │ -00071a90: 7468 6520 7065 6572 2d69 642e 0a09 544f the peer-id...TO │ │ │ -00071aa0: 5252 454e 545f 4445 5052 4543 4154 4544 RRENT_DEPRECATED │ │ │ -00071ab0: 5f45 5850 4f52 540a 0973 7464 3a3a 7374 _EXPORT..std::st │ │ │ -00071ac0: 7269 6e67 2069 6465 6e74 6966 795f 636c ring identify_cl │ │ │ -00071ad0: 6965 6e74 2863 6f6e 7374 2070 6565 725f ient(const peer_ │ │ │ -00071ae0: 6964 2661 6d70 3b20 7029 3b0a 0a23 6966 id& p);..#if │ │ │ -00071af0: 2054 4f52 5245 4e54 5f41 4249 5f56 4552 TORRENT_ABI_VER │ │ │ -00071b00: 5349 4f4e 203d 3d20 310a 0a23 696e 636c SION == 1..#incl │ │ │ -00071b10: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ -00071b20: 6175 785f 2f64 6973 6162 6c65 5f64 6570 aux_/disable_dep │ │ │ -00071b30: 7265 6361 7469 6f6e 5f77 6172 6e69 6e67 recation_warning │ │ │ -00071b40: 735f 7075 7368 2e68 7070 220a 0a09 2f2f s_push.hpp"...// │ │ │ -00071b50: 2052 6574 7572 6e73 2061 6e20 6f70 7469 Returns an opti │ │ │ -00071b60: 6f6e 616c 2066 696e 6765 7270 7269 6e74 onal fingerprint │ │ │ -00071b70: 2069 6620 616e 7920 6361 6e20 6265 2069 if any can be i │ │ │ -00071b80: 6465 6e74 6966 6965 6420 6672 6f6d 2074 dentified from t │ │ │ -00071b90: 6865 2070 6565 720a 092f 2f20 6964 2e20 he peer..// id. │ │ │ -00071ba0: 5468 6973 2063 616e 2062 6520 7573 6564 This can be used │ │ │ -00071bb0: 2074 6f20 6175 746f 6d61 7465 2074 6865 to automate the │ │ │ -00071bc0: 2069 6465 6e74 6966 6963 6174 696f 6e20 identification │ │ │ -00071bd0: 6f66 2063 6c69 656e 7473 2e20 4974 2077 of clients. It w │ │ │ -00071be0: 696c 6c0a 092f 2f20 6e6f 7420 6265 2061 ill..// not be a │ │ │ -00071bf0: 626c 6520 746f 2069 6465 6e74 6966 7920 ble to identify │ │ │ -00071c00: 7065 6572 7320 7769 7468 206e 6f6e 2d20 peers with non- │ │ │ -00071c10: 7374 616e 6461 7264 2065 6e63 6f64 696e standard encodin │ │ │ -00071c20: 6773 2e20 4f6e 6c79 2041 7a75 7265 7573 gs. Only Azureus │ │ │ -00071c30: 0a09 2f2f 2073 7479 6c65 2c20 5368 6164 ..// style, Shad │ │ │ -00071c40: 6f77 2773 2073 7479 6c65 2061 6e64 204d ow's style and M │ │ │ -00071c50: 6169 6e6c 696e 6520 7374 796c 652e 0a09 ainline style... │ │ │ -00071c60: 544f 5252 454e 545f 4445 5052 4543 4154 TORRENT_DEPRECAT │ │ │ -00071c70: 4544 5f45 5850 4f52 540a 0973 7464 3a3a ED_EXPORT..std:: │ │ │ -00071c80: 6f70 7469 6f6e 616c 266c 743b 6669 6e67 optional<fing │ │ │ -00071c90: 6572 7072 696e 7426 6774 3b0a 0909 636c erprint>...cl │ │ │ -00071ca0: 6965 6e74 5f66 696e 6765 7270 7269 6e74 ient_fingerprint │ │ │ -00071cb0: 2870 6565 725f 6964 2063 6f6e 7374 2661 (peer_id const&a │ │ │ -00071cc0: 6d70 3b20 7029 3b0a 0a23 696e 636c 7564 mp; p);..#includ │ │ │ -00071cd0: 6520 226c 6962 746f 7272 656e 742f 6175 e "libtorrent/au │ │ │ -00071ce0: 785f 2f64 6973 6162 6c65 5f77 6172 6e69 x_/disable_warni │ │ │ -00071cf0: 6e67 735f 706f 702e 6870 7022 0a3c 2f70 ngs_pop.hpp".

    re │ │ │ -00071d30: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ -00071d70: 6465 2f6c 6962 746f 7272 656e 742f 6932 de/libtorrent/i2 │ │ │ -00071d80: 705f 7374 7265 616d 2e68 7070 3a35 3631 p_stream.hpp:561 │ │ │ -00071d90: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ -00071da0: 6520 7468 6973 2061 2073 7472 696e 675f e this a string_ │ │ │ -00071db0: 7669 6577 3c2f 7464 3e3c 2f74 723e 3c74 viewmake this a st │ │ │ -00071e10: 7269 6e67 5f76 6965 773c 2f68 323e 3c68 ring_view../include/lib │ │ │ -00071e30: 746f 7272 656e 742f 6932 705f 7374 7265 torrent/i2p_stre │ │ │ -00071e40: 616d 2e68 7070 3a35 3631 3c2f 6834 3e3c am.hpp:561< │ │ │ -00071e50: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00071e60: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00071e70: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00071e80: 7820 2364 6464 3b22 3e0a 0909 6368 6172 x #ddd;">...char │ │ │ -00071e90: 2074 6d70 5b32 305d 3b0a 0909 6175 783a tmp[20];...aux: │ │ │ -00071ea0: 3a72 616e 646f 6d5f 6279 7465 7328 746d :random_bytes(tm │ │ │ -00071eb0: 7029 3b0a 0909 6d5f 7365 7373 696f 6e5f p);...m_session_ │ │ │ -00071ec0: 6964 2e72 6573 697a 6528 7369 7a65 6f66 id.resize(sizeof │ │ │ -00071ed0: 2874 6d70 292a 3229 3b0a 0909 6175 783a (tmp)*2);...aux: │ │ │ -00071ee0: 3a74 6f5f 6865 7828 746d 702c 2026 616d :to_hex(tmp, &am │ │ │ -00071ef0: 703b 6d5f 7365 7373 696f 6e5f 6964 5b30 p;m_session_id[0 │ │ │ -00071f00: 5d29 3b0a 0a09 096d 5f73 616d 5f73 6f63 ]);....m_sam_soc │ │ │ -00071f10: 6b65 7420 3d20 7374 643a 3a6d 616b 655f ket = std::make_ │ │ │ -00071f20: 7368 6172 6564 266c 743b 6932 705f 7374 shared<i2p_st │ │ │ -00071f30: 7265 616d 2667 743b 286d 5f69 6f5f 7365 ream>(m_io_se │ │ │ -00071f40: 7276 6963 6529 3b0a 0909 6d5f 7361 6d5f rvice);...m_sam_ │ │ │ -00071f50: 736f 636b 6574 2d26 6774 3b73 6574 5f70 socket->set_p │ │ │ -00071f60: 726f 7879 286d 5f68 6f73 746e 616d 652c roxy(m_hostname, │ │ │ -00071f70: 206d 5f70 6f72 7429 3b0a 0909 6d5f 7361 m_port);...m_sa │ │ │ -00071f80: 6d5f 736f 636b 6574 2d26 6774 3b73 6574 m_socket->set │ │ │ -00071f90: 5f63 6f6d 6d61 6e64 2869 3270 5f73 7472 _command(i2p_str │ │ │ -00071fa0: 6561 6d3a 3a63 6d64 5f63 7265 6174 655f eam::cmd_create_ │ │ │ -00071fb0: 7365 7373 696f 6e29 3b0a 0909 6d5f 7361 session);...m_sa │ │ │ -00071fc0: 6d5f 736f 636b 6574 2d26 6774 3b73 6574 m_socket->set │ │ │ -00071fd0: 5f73 6573 7369 6f6e 5f69 6428 6d5f 7365 _session_id(m_se │ │ │ -00071fe0: 7373 696f 6e5f 6964 2e63 5f73 7472 2829 ssion_id.c_str() │ │ │ -00071ff0: 293b 0a09 096d 5f73 616d 5f73 6f63 6b65 );...m_sam_socke │ │ │ -00072000: 742d 2667 743b 7365 745f 7365 7373 696f t->set_sessio │ │ │ -00072010: 6e5f 6f70 7469 6f6e 7328 7365 7373 696f n_options(sessio │ │ │ -00072020: 6e5f 6f70 7469 6f6e 7329 3b0a 0a09 0941 n_options);....A │ │ │ -00072030: 4444 5f4f 5554 5354 414e 4449 4e47 5f41 DD_OUTSTANDING_A │ │ │ -00072040: 5359 4e43 2822 6932 705f 7374 7265 616d SYNC("i2p_stream │ │ │ -00072050: 3a3a 6f6e 5f73 616d 5f63 6f6e 6e65 6374 ::on_sam_connect │ │ │ -00072060: 2229 3b0a 0909 6d5f 7361 6d5f 736f 636b ");...m_sam_sock │ │ │ -00072070: 6574 2d26 6774 3b61 7379 6e63 5f63 6f6e et->async_con │ │ │ -00072080: 6e65 6374 2874 6370 3a3a 656e 6470 6f69 nect(tcp::endpoi │ │ │ -00072090: 6e74 2829 2c20 6175 783a 3a77 7261 705f nt(), aux::wrap_ │ │ │ -000720a0: 616c 6c6f 6361 746f 7228 0a09 0909 5b74 allocator(....[t │ │ │ -000720b0: 6869 732c 733d 6d5f 7361 6d5f 736f 636b his,s=m_sam_sock │ │ │ -000720c0: 6574 5d28 6572 726f 725f 636f 6465 2063 et](error_code c │ │ │ -000720d0: 6f6e 7374 2661 6d70 3b20 6563 2c20 4861 onst& ec, Ha │ │ │ -000720e0: 6e64 6c65 7220 686e 2920 7b0a 0909 0909 ndler hn) {..... │ │ │ -000720f0: 6f6e 5f73 616d 5f63 6f6e 6e65 6374 2865 on_sam_connect(e │ │ │ -00072100: 632c 2073 2c20 7374 643a 3a6d 6f76 6528 c, s, std::move( │ │ │ -00072110: 686e 2929 3b0a 0909 097d 2c20 7374 643a hn));....}, std: │ │ │ -00072120: 3a6d 6f76 6528 6861 6e64 6c65 7229 2929 :move(handler))) │ │ │ -00072130: 3b0a 097d 0a09 766f 6964 2063 6c6f 7365 ;..}..void close │ │ │ -00072140: 2865 7272 6f72 5f63 6f64 6526 616d 703b (error_code& │ │ │ -00072150: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22 );..
    .char const* s │ │ │ -00072190: 6573 7369 6f6e 5f69 6428 2920 636f 6e73 ession_id() cons │ │ │ -000721a0: 7420 7b20 7265 7475 726e 206d 5f73 6573 t { return m_ses │ │ │ -000721b0: 7369 6f6e 5f69 642e 635f 7374 7228 293b sion_id.c_str(); │ │ │ -000721c0: 207d 0a3c 2f64 6976 3e09 7374 643a 3a73 }.
    .std::s │ │ │ -000721d0: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -000721e0: 206c 6f63 616c 5f65 6e64 706f 696e 7428 local_endpoint( │ │ │ -000721f0: 2920 636f 6e73 7420 7b20 7265 7475 726e ) const { return │ │ │ -00072200: 206d 5f69 3270 5f6c 6f63 616c 5f65 6e64 m_i2p_local_end │ │ │ -00072210: 706f 696e 743b 207d 0a0a 0974 656d 706c point; }...templ │ │ │ -00072220: 6174 6520 266c 743b 7479 7065 6e61 6d65 ate <typename │ │ │ -00072230: 2048 616e 646c 6572 2667 743b 0a09 766f Handler>..vo │ │ │ -00072240: 6964 2061 7379 6e63 5f6e 616d 655f 6c6f id async_name_lo │ │ │ -00072250: 6f6b 7570 2863 6861 7220 636f 6e73 742a okup(char const* │ │ │ -00072260: 206e 616d 652c 2048 616e 646c 6572 2068 name, Handler h │ │ │ -00072270: 616e 646c 6572 290a 097b 0a09 0969 6620 andler)..{...if │ │ │ -00072280: 286d 5f73 7461 7465 203d 3d20 7361 6d5f (m_state == sam_ │ │ │ -00072290: 6964 6c65 2026 616d 703b 2661 6d70 3b20 idle && │ │ │ -000722a0: 6d5f 6e61 6d65 5f6c 6f6f 6b75 702e 656d m_name_lookup.em │ │ │ -000722b0: 7074 7928 2920 2661 6d70 3b26 616d 703b pty() && │ │ │ -000722c0: 2069 735f 6f70 656e 2829 290a 0909 0964 is_open())....d │ │ │ -000722d0: 6f5f 6e61 6d65 5f6c 6f6f 6b75 7028 6e61 o_name_lookup(na │ │ │ -000722e0: 6d65 2c20 7374 643a 3a6d 6f76 6528 6861 me, std::move(ha │ │ │ -000722f0: 6e64 6c65 7229 293b 0a09 0965 6c73 650a ndler));...else. │ │ │ -00072300: 0909 096d 5f6e 616d 655f 6c6f 6f6b 7570 ...m_name_lookup │ │ │ -00072310: 2e65 6d70 6c61 6365 5f62 6163 6b28 7374 .emplace_back(st │ │ │ -00072320: 643a 3a73 7472 696e 6728 6e61 6d65 290a d::string(name). │ │ │ -00072330: 0909 0909 2c20 7374 643a 3a6d 6f76 6528 ...., std::move( │ │ │ -00072340: 6861 6e64 6c65 7229 293b 0a09 7d0a 0a70 handler));..}..p │ │ │ -00072350: 7269 7661 7465 3a0a 0a09 7465 6d70 6c61 rivate:...templa │ │ │ -00072360: 7465 2026 6c74 3b74 7970 656e 616d 6520 te <typename │ │ │ -00072370: 4861 6e64 6c65 7226 6774 3b0a 0976 6f69 Handler>..voi │ │ │ -00072380: 6420 6f6e 5f73 616d 5f63 6f6e 6e65 6374 d on_sam_connect │ │ │ -00072390: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ -000723a0: 7426 616d 703b 2065 632c 2073 7464 3a3a t& ec, std:: │ │ │ -000723b0: 7368 6172 6564 5f70 7472 266c 743b 6932 shared_ptr<i2 │ │ │ -000723c0: 705f 7374 7265 616d 2667 743b 2c20 4861 p_stream>, Ha │ │ │ -000723d0: 6e64 6c65 7220 6829 0a09 7b0a 0909 434f ndler h)..{...CO │ │ │ -000723e0: 4d50 4c45 5445 5f41 5359 4e43 2822 6932 MPLETE_ASYNC("i2 │ │ │ -000723f0: 705f 7374 7265 616d 3a3a 6f6e 5f73 616d p_stream::on_sam │ │ │ -00072400: 5f63 6f6e 6e65 6374 2229 3b0a 0909 6d5f _connect");...m_ │ │ │ -00072410: 7374 6174 6520 3d20 7361 6d5f 6964 6c65 state = sam_idle │ │ │ -00072420: 3b0a 0a09 0969 6620 2865 6329 0a09 097b ;....if (ec)...{ │ │ │ -00072430: 0a09 0909 6828 6563 293b 0a09 0909 7265 ....h(ec);....re │ │ │ -00072440: 7475 726e 3b0a 0909 7d0a 0a09 0964 6f5f turn;...}....do_ │ │ │ -00072450: 6e61 6d65 5f6c 6f6f 6b75 7028 224d 4522 name_lookup("ME" │ │ │ -00072460: 2c20 6175 783a 3a77 7261 705f 616c 6c6f , aux::wrap_allo │ │ │ -00072470: 6361 746f 7228 0a09 0909 5b74 6869 735d cator(....[this] │ │ │ -00072480: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ -00072490: 7426 616d 703b 2065 2c20 6368 6172 2063 t& e, char c │ │ │ -000724a0: 6f6e 7374 2a20 6473 742c 2048 616e 646c onst* dst, Handl │ │ │ -000724b0: 6572 2068 6e29 207b 0a09 0909 0973 6574 er hn) {.....set │ │ │ -000724c0: 5f6c 6f63 616c 5f65 6e64 706f 696e 7428 _local_endpoint( │ │ │ -000724d0: 652c 2064 7374 2c20 7374 643a 3a6d 6f76 e, dst, std::mov │ │ │ -000724e0: 6528 686e 2929 3b0a 0909 097d 2c20 7374 e(hn));....}, st │ │ │ -000724f0: 643a 3a6d 6f76 6528 6829 2929 3b0a 3c2f d::move(h)));.r │ │ │ -00072530: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00072540: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00072570: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ -00072580: 6565 725f 636f 6e6e 6563 7469 6f6e 5f69 eer_connection_i │ │ │ -00072590: 6e74 6572 6661 6365 2e68 7070 3a34 313c nterface.hpp:41< │ │ │ -000725a0: 2f61 3e3c 2f74 643e 3c74 643e 6d61 6b65 /a>make │ │ │ -000725b0: 2074 6869 7320 696e 7465 7266 6163 6520 this interface │ │ │ -000725c0: 736d 616c 6c65 7221 3c2f 7464 3e3c 2f74 smaller!

    make this │ │ │ -00072620: 696e 7465 7266 6163 6520 736d 616c 6c65 interface smalle │ │ │ -00072630: 7221 3c2f 6832 3e3c 6834 3e2e 2e2f 696e r!

    ../in │ │ │ -00072640: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00072650: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ -00072660: 5f69 6e74 6572 6661 6365 2e68 7070 3a34 _interface.hpp:4 │ │ │ -00072670: 313c 2f68 343e 3c70 7265 2073 7479 6c65 1

    │ │ │ -000726b0: 6e61 6d65 7370 6163 6520 6c69 6274 6f72  namespace libtor
    │ │ │ -000726c0: 7265 6e74 207b 0a0a 096e 616d 6573 7061  rent {...namespa
    │ │ │ -000726d0: 6365 2061 7578 207b 0a09 0973 7472 7563  ce aux {...struc
    │ │ │ -000726e0: 7420 746f 7272 656e 745f 7065 6572 3b0a  t torrent_peer;.
    │ │ │ -000726f0: 0909 636c 6173 7320 7374 6174 3b0a 097d  ..class stat;..}
    │ │ │ -00072700: 0a0a 092f 2f20 636c 6173 7369 6669 6573  ...// classifies
    │ │ │ -00072710: 2061 2070 6565 7220 636f 6e6e 6563 7469   a peer connecti
    │ │ │ -00072720: 6f6e 2062 7920 7468 6520 7072 6f74 6f63  on by the protoc
    │ │ │ -00072730: 6f6c 2069 7420 7370 6561 6b73 2e0a 0965  ol it speaks...e
    │ │ │ -00072740: 6e75 6d20 636c 6173 7320 636f 6e6e 6563  num class connec
    │ │ │ -00072750: 7469 6f6e 5f74 7970 6520 3a20 7374 643a  tion_type : std:
    │ │ │ -00072760: 3a75 696e 7438 5f74 0a09 7b0a 0909 2f2f  :uint8_t..{...//
    │ │ │ -00072770: 2074 6869 7320 6973 2061 2072 6567 756c   this is a regul
    │ │ │ -00072780: 6172 2062 6974 746f 7272 656e 7420 7065  ar bittorrent pe
    │ │ │ -00072790: 6572 2063 6f6e 6e65 6374 696f 6e0a 0909  er connection...
    │ │ │ -000727a0: 6269 7474 6f72 7265 6e74 2c0a 0909 2f2f  bittorrent,...//
    │ │ │ -000727b0: 2042 4550 2031 3920 7765 6220 7365 6564   BEP 19 web seed
    │ │ │ -000727c0: 0a09 0975 726c 5f73 6565 642c 0a09 092f  ...url_seed,.../
    │ │ │ -000727d0: 2f20 4245 5020 3137 2077 6562 2073 6565  / BEP 17 web see
    │ │ │ -000727e0: 6420 286e 6f20 6c6f 6e67 6572 2073 7570  d (no longer sup
    │ │ │ -000727f0: 706f 7274 6564 290a 0909 6874 7470 5f73  ported)...http_s
    │ │ │ -00072800: 6565 640a 097d 3b0a 0a09 7573 696e 6720  eed..};...using 
    │ │ │ -00072810: 6469 7363 6f6e 6e65 6374 5f73 6576 6572  disconnect_sever
    │ │ │ -00072820: 6974 795f 7420 3d20 6175 783a 3a73 7472  ity_t = aux::str
    │ │ │ -00072830: 6f6e 675f 7479 7065 6465 6626 6c74 3b73  ong_typedef<s
    │ │ │ -00072840: 7464 3a3a 7569 6e74 385f 742c 2073 7472  td::uint8_t, str
    │ │ │ -00072850: 7563 7420 6469 7363 6f6e 6e65 6374 5f73  uct disconnect_s
    │ │ │ -00072860: 6576 6572 6974 795f 7461 6726 6774 3b3b  everity_tag>;
    │ │ │ -00072870: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -000728a0: 0973 7472 7563 7420 544f 5252 454e 545f .struct TORRENT_ │ │ │ -000728b0: 4558 5452 415f 4558 504f 5254 2070 6565 EXTRA_EXPORT pee │ │ │ -000728c0: 725f 636f 6e6e 6563 7469 6f6e 5f69 6e74 r_connection_int │ │ │ -000728d0: 6572 6661 6365 0a3c 2f64 6976 3e09 7b0a erface.
    .{. │ │ │ -000728e0: 0909 7374 6174 6963 2069 6e6c 696e 6520 ..static inline │ │ │ -000728f0: 636f 6e73 7465 7870 7220 6469 7363 6f6e constexpr discon │ │ │ -00072900: 6e65 6374 5f73 6576 6572 6974 795f 7420 nect_severity_t │ │ │ -00072910: 6e6f 726d 616c 7b30 7d3b 0a09 0973 7461 normal{0};...sta │ │ │ -00072920: 7469 6320 696e 6c69 6e65 2063 6f6e 7374 tic inline const │ │ │ -00072930: 6578 7072 2064 6973 636f 6e6e 6563 745f expr disconnect_ │ │ │ -00072940: 7365 7665 7269 7479 5f74 2066 6169 6c75 severity_t failu │ │ │ -00072950: 7265 7b31 7d3b 0a09 0973 7461 7469 6320 re{1};...static │ │ │ -00072960: 696e 6c69 6e65 2063 6f6e 7374 6578 7072 inline constexpr │ │ │ -00072970: 2064 6973 636f 6e6e 6563 745f 7365 7665 disconnect_seve │ │ │ -00072980: 7269 7479 5f74 2070 6565 725f 6572 726f rity_t peer_erro │ │ │ -00072990: 727b 327d 3b0a 0a23 6966 2054 4f52 5245 r{2};..#if TORRE │ │ │ -000729a0: 4e54 5f55 5345 5f49 3250 0a09 0976 6972 NT_USE_I2P...vir │ │ │ -000729b0: 7475 616c 2073 7464 3a3a 7374 7269 6e67 tual std::string │ │ │ -000729c0: 2063 6f6e 7374 2661 6d70 3b20 6465 7374 const& dest │ │ │ -000729d0: 696e 6174 696f 6e28 2920 636f 6e73 7420 ination() const │ │ │ -000729e0: 3d20 303b 0a09 0976 6972 7475 616c 2073 = 0;...virtual s │ │ │ -000729f0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ -00072a00: 2661 6d70 3b20 6c6f 6361 6c5f 6932 705f & local_i2p_ │ │ │ -00072a10: 656e 6470 6f69 6e74 2829 2063 6f6e 7374 endpoint() const │ │ │ -00072a20: 203d 2030 3b0a 2365 6e64 6966 0a09 0976 = 0;.#endif...v │ │ │ -00072a30: 6972 7475 616c 2074 6370 3a3a 656e 6470 irtual tcp::endp │ │ │ -00072a40: 6f69 6e74 2063 6f6e 7374 2661 6d70 3b20 oint const& │ │ │ -00072a50: 7265 6d6f 7465 2829 2063 6f6e 7374 203d remote() const = │ │ │ -00072a60: 2030 3b0a 0909 7669 7274 7561 6c20 7463 0;...virtual tc │ │ │ -00072a70: 703a 3a65 6e64 706f 696e 7420 6c6f 6361 p::endpoint loca │ │ │ -00072a80: 6c5f 656e 6470 6f69 6e74 2829 2063 6f6e l_endpoint() con │ │ │ -00072a90: 7374 203d 2030 3b0a 0909 7669 7274 7561 st = 0;...virtua │ │ │ -00072aa0: 6c20 766f 6964 2064 6973 636f 6e6e 6563 l void disconnec │ │ │ -00072ab0: 7428 6572 726f 725f 636f 6465 2063 6f6e t(error_code con │ │ │ -00072ac0: 7374 2661 6d70 3b20 6563 0a09 0909 2c20 st& ec...., │ │ │ -00072ad0: 6f70 6572 6174 696f 6e5f 7420 6f70 2c20 operation_t op, │ │ │ -00072ae0: 6469 7363 6f6e 6e65 6374 5f73 6576 6572 disconnect_sever │ │ │ -00072af0: 6974 795f 7420 3d20 7065 6572 5f63 6f6e ity_t = peer_con │ │ │ -00072b00: 6e65 6374 696f 6e5f 696e 7465 7266 6163 nection_interfac │ │ │ -00072b10: 653a 3a6e 6f72 6d61 6c29 203d 2030 3b0a e::normal) = 0;. │ │ │ -00072b20: 0909 7669 7274 7561 6c20 7065 6572 5f69 ..virtual peer_i │ │ │ -00072b30: 6420 636f 6e73 7426 616d 703b 2070 6964 d const& pid │ │ │ -00072b40: 2829 2063 6f6e 7374 203d 2030 3b0a 0909 () const = 0;... │ │ │ -00072b50: 7669 7274 7561 6c20 7065 6572 5f69 6420 virtual peer_id │ │ │ -00072b60: 6f75 725f 7069 6428 2920 636f 6e73 7420 our_pid() const │ │ │ -00072b70: 3d20 303b 0a09 0976 6972 7475 616c 2076 = 0;...virtual v │ │ │ -00072b80: 6f69 6420 7365 745f 686f 6c65 7075 6e63 oid set_holepunc │ │ │ -00072b90: 685f 6d6f 6465 2829 203d 2030 3b0a 0909 h_mode() = 0;... │ │ │ -00072ba0: 7669 7274 7561 6c20 6175 783a 3a74 6f72 virtual aux::tor │ │ │ -00072bb0: 7265 6e74 5f70 6565 722a 2070 6565 725f rent_peer* peer_ │ │ │ -00072bc0: 696e 666f 5f73 7472 7563 7428 2920 636f info_struct() co │ │ │ -00072bd0: 6e73 7420 3d20 303b 0a09 0976 6972 7475 nst = 0;...virtu │ │ │ -00072be0: 616c 2076 6f69 6420 7365 745f 7065 6572 al void set_peer │ │ │ -00072bf0: 5f69 6e66 6f28 6175 783a 3a74 6f72 7265 _info(aux::torre │ │ │ -00072c00: 6e74 5f70 6565 722a 2070 6929 203d 2030 nt_peer* pi) = 0 │ │ │ -00072c10: 3b0a 0909 7669 7274 7561 6c20 626f 6f6c ;...virtual bool │ │ │ -00072c20: 2069 735f 6f75 7467 6f69 6e67 2829 2063 is_outgoing() c │ │ │ -00072c30: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00072c40: 7561 6c20 766f 6964 2061 6464 5f73 7461 ual void add_sta │ │ │ -00072c50: 7428 7374 643a 3a69 6e74 3634 5f74 2064 t(std::int64_t d │ │ │ -00072c60: 6f77 6e6c 6f61 6465 642c 2073 7464 3a3a ownloaded, std:: │ │ │ -00072c70: 696e 7436 345f 7420 7570 6c6f 6164 6564 int64_t uploaded │ │ │ -00072c80: 2920 3d20 303b 0a09 0976 6972 7475 616c ) = 0;...virtual │ │ │ -00072c90: 2062 6f6f 6c20 6661 7374 5f72 6563 6f6e bool fast_recon │ │ │ -00072ca0: 6e65 6374 2829 2063 6f6e 7374 203d 2030 nect() const = 0 │ │ │ -00072cb0: 3b0a 0909 7669 7274 7561 6c20 626f 6f6c ;...virtual bool │ │ │ -00072cc0: 2069 735f 6368 6f6b 6564 2829 2063 6f6e is_choked() con │ │ │ -00072cd0: 7374 203d 2030 3b0a 0909 7669 7274 7561 st = 0;...virtua │ │ │ -00072ce0: 6c20 626f 6f6c 2066 6169 6c65 6428 2920 l bool failed() │ │ │ -00072cf0: 636f 6e73 7420 3d20 303b 0a09 0976 6972 const = 0;...vir │ │ │ -00072d00: 7475 616c 2061 7578 3a3a 7374 6174 2063 tual aux::stat c │ │ │ -00072d10: 6f6e 7374 2661 6d70 3b20 7374 6174 6973 onst& statis │ │ │ -00072d20: 7469 6373 2829 2063 6f6e 7374 203d 2030 tics() const = 0 │ │ │ -00072d30: 3b0a 0909 7669 7274 7561 6c20 766f 6964 ;...virtual void │ │ │ -00072d40: 2067 6574 5f70 6565 725f 696e 666f 2870 get_peer_info(p │ │ │ -00072d50: 6565 725f 696e 666f 2661 6d70 3b20 7029 eer_info& p) │ │ │ -00072d60: 2063 6f6e 7374 203d 2030 3b0a 2369 666e const = 0;.#ifn │ │ │ -00072d70: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ -00072d80: 424c 455f 4c4f 4747 494e 470a 0909 7669 BLE_LOGGING...vi │ │ │ -00072d90: 7274 7561 6c20 626f 6f6c 2073 686f 756c rtual bool shoul │ │ │ -00072da0: 645f 6c6f 6728 7065 6572 5f6c 6f67 5f61 d_log(peer_log_a │ │ │ -00072db0: 6c65 7274 3a3a 6469 7265 6374 696f 6e5f lert::direction_ │ │ │ -00072dc0: 7420 6469 7265 6374 696f 6e29 2063 6f6e t direction) con │ │ │ -00072dd0: 7374 203d 2030 3b0a 0909 7669 7274 7561 st = 0;...virtua │ │ │ -00072de0: 6c20 766f 6964 2070 6565 725f 6c6f 6728 l void peer_log( │ │ │ -00072df0: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a peer_log_alert:: │ │ │ -00072e00: 6469 7265 6374 696f 6e5f 7420 6469 7265 direction_t dire │ │ │ -00072e10: 6374 696f 6e0a 0909 092c 2070 6565 725f ction...., peer_ │ │ │ -00072e20: 6c6f 675f 616c 6572 743a 3a65 7665 6e74 log_alert::event │ │ │ -00072e30: 5f74 2065 7665 6e74 2c20 6368 6172 2063 _t event, char c │ │ │ -00072e40: 6f6e 7374 2a20 666d 7420 3d20 2222 2c20 onst* fmt = "", │ │ │ -00072e50: 2e2e 2e29 2063 6f6e 7374 206e 6f65 7863 ...) const noexc │ │ │ -00072e60: 6570 7420 544f 5252 454e 545f 464f 524d ept TORRENT_FORM │ │ │ -00072e70: 4154 2834 2c35 2920 3d20 303b 0a23 656e AT(4,5) = 0;.#en │ │ │ -00072e80: 6469 660a 3c2f 7072 653e 3c2f 7464 3e3c dif.
    < │ │ │ -00072e90: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00072ec0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00072ef0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00072f00: 7265 6e74 2f73 6f63 6b73 355f 7374 7265 rent/socks5_stre │ │ │ -00072f10: 616d 2e68 7070 3a31 3736 3c2f 613e 3c2f am.hpp:176we could │ │ │ -00072f30: 6269 6e64 2074 6865 2073 6f63 6b65 7420 bind the socket │ │ │ -00072f40: 6865 7265 2c20 7369 6e63 6520 7765 206b here, since we k │ │ │ -00072f50: 6e6f 7720 7768 6174 2074 6865 2074 6172 now what the tar │ │ │ -00072f60: 6765 7420 656e 6470 6f69 6e74 2069 7320 get endpoint is │ │ │ -00072f70: 6f66 2074 6865 2070 726f 7879 3c2f 7464 of the proxy

    we cou │ │ │ -00072fd0: 6c64 2062 696e 6420 7468 6520 736f 636b ld bind the sock │ │ │ -00072fe0: 6574 2068 6572 652c 2073 696e 6365 2077 et here, since w │ │ │ -00072ff0: 6520 6b6e 6f77 2077 6861 7420 7468 650a e know what the. │ │ │ -00073000: 7461 7267 6574 2065 6e64 706f 696e 7420 target endpoint │ │ │ -00073010: 6973 206f 6620 7468 6520 7072 6f78 793c is of the proxy< │ │ │ -00073020: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -00073030: 6465 2f6c 6962 746f 7272 656e 742f 736f de/libtorrent/so │ │ │ -00073040: 636b 7335 5f73 7472 6561 6d2e 6870 703a cks5_stream.hpp: │ │ │ -00073050: 3137 363c 2f68 343e 3c70 7265 2073 7479 176

    ...}, std::mov
    │ │ │ -000730a0: 6528 6861 6e64 6c65 7229 2929 3b0a 097d  e(handler)));..}
    │ │ │ -000730b0: 0a0a 7072 6976 6174 653a 0a0a 0974 656d  ..private:...tem
    │ │ │ -000730c0: 706c 6174 6520 266c 743b 7479 7065 6e61  plate <typena
    │ │ │ -000730d0: 6d65 2048 616e 646c 6572 2667 743b 0a09  me Handler>..
    │ │ │ -000730e0: 766f 6964 206e 616d 655f 6c6f 6f6b 7570  void name_lookup
    │ │ │ -000730f0: 2865 7272 6f72 5f63 6f64 6520 636f 6e73  (error_code cons
    │ │ │ -00073100: 7426 616d 703b 2065 2c20 7463 703a 3a72  t& e, tcp::r
    │ │ │ -00073110: 6573 6f6c 7665 723a 3a72 6573 756c 7473  esolver::results
    │ │ │ -00073120: 5f74 7970 6520 6970 730a 0909 2c20 4861  _type ips..., Ha
    │ │ │ -00073130: 6e64 6c65 7220 6829 0a09 7b0a 0909 434f  ndler h)..{...CO
    │ │ │ -00073140: 4d50 4c45 5445 5f41 5359 4e43 2822 736f  MPLETE_ASYNC("so
    │ │ │ -00073150: 636b 7335 5f73 7472 6561 6d3a 3a6e 616d  cks5_stream::nam
    │ │ │ -00073160: 655f 6c6f 6f6b 7570 2229 3b0a 0909 6966  e_lookup");...if
    │ │ │ -00073170: 2028 6861 6e64 6c65 5f65 7272 6f72 2865   (handle_error(e
    │ │ │ -00073180: 2c20 7374 643a 3a6d 6f76 6528 6829 2929  , std::move(h)))
    │ │ │ -00073190: 2072 6574 7572 6e3b 0a0a 0909 6175 746f   return;....auto
    │ │ │ -000731a0: 2069 203d 2069 7073 2e62 6567 696e 2829   i = ips.begin()
    │ │ │ -000731b0: 3b0a 0909 6966 2028 216d 5f73 6f63 6b2e  ;...if (!m_sock.
    │ │ │ -000731c0: 6973 5f6f 7065 6e28 2929 0a09 097b 0a09  is_open())...{..
    │ │ │ -000731d0: 0909 6572 726f 725f 636f 6465 2065 633b  ..error_code ec;
    │ │ │ -000731e0: 0a09 0909 6d5f 736f 636b 2e6f 7065 6e28  ....m_sock.open(
    │ │ │ -000731f0: 692d 2667 743b 656e 6470 6f69 6e74 2829  i->endpoint()
    │ │ │ -00073200: 2e70 726f 746f 636f 6c28 292c 2065 6329  .protocol(), ec)
    │ │ │ -00073210: 3b0a 0909 0969 6620 2868 616e 646c 655f  ;....if (handle_
    │ │ │ -00073220: 6572 726f 7228 6563 2c20 7374 643a 3a6d  error(ec, std::m
    │ │ │ -00073230: 6f76 6528 6829 2929 2072 6574 7572 6e3b  ove(h))) return;
    │ │ │ -00073240: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..ADD_OUTSTA │ │ │ -00073280: 4e44 494e 475f 4153 594e 4328 2273 6f63 NDING_ASYNC("soc │ │ │ -00073290: 6b73 355f 7374 7265 616d 3a3a 636f 6e6e ks5_stream::conn │ │ │ -000732a0: 6563 7465 6422 293b 0a3c 2f64 6976 3e09 ected");.
    . │ │ │ -000732b0: 096d 5f73 6f63 6b2e 6173 796e 635f 636f .m_sock.async_co │ │ │ -000732c0: 6e6e 6563 7428 692d 2667 743b 656e 6470 nnect(i->endp │ │ │ -000732d0: 6f69 6e74 2829 2c20 6175 783a 3a77 7261 oint(), aux::wra │ │ │ -000732e0: 705f 616c 6c6f 6361 746f 7228 0a09 0909 p_allocator(.... │ │ │ -000732f0: 5b74 6869 735d 2865 7272 6f72 5f63 6f64 [this](error_cod │ │ │ -00073300: 6520 636f 6e73 7426 616d 703b 2065 632c e const& ec, │ │ │ -00073310: 2048 616e 646c 6572 2068 6e29 0a09 0909 Handler hn).... │ │ │ -00073320: 7b20 636f 6e6e 6563 7465 6428 6563 2c20 { connected(ec, │ │ │ -00073330: 7374 643a 3a6d 6f76 6528 686e 2929 3b20 std::move(hn)); │ │ │ -00073340: 7d2c 2073 7464 3a3a 6d6f 7665 2868 2929 }, std::move(h)) │ │ │ -00073350: 293b 0a09 7d0a 0a09 7465 6d70 6c61 7465 );..}...template │ │ │ -00073360: 2026 6c74 3b74 7970 656e 616d 6520 4861 <typename Ha │ │ │ -00073370: 6e64 6c65 7226 6774 3b0a 0976 6f69 6420 ndler>..void │ │ │ -00073380: 636f 6e6e 6563 7465 6428 6572 726f 725f connected(error_ │ │ │ -00073390: 636f 6465 2063 6f6e 7374 2661 6d70 3b20 code const& │ │ │ -000733a0: 652c 2048 616e 646c 6572 2068 290a 097b e, Handler h)..{ │ │ │ -000733b0: 0a09 0943 4f4d 504c 4554 455f 4153 594e ...COMPLETE_ASYN │ │ │ -000733c0: 4328 2273 6f63 6b73 355f 7374 7265 616d C("socks5_stream │ │ │ -000733d0: 3a3a 636f 6e6e 6563 7465 6422 293b 0a09 ::connected");.. │ │ │ -000733e0: 0969 6620 2868 616e 646c 655f 6572 726f .if (handle_erro │ │ │ -000733f0: 7228 652c 2073 7464 3a3a 6d6f 7665 2868 r(e, std::move(h │ │ │ -00073400: 2929 2920 7265 7475 726e 3b0a 0a09 0975 ))) return;....u │ │ │ -00073410: 7369 6e67 206e 616d 6573 7061 6365 206c sing namespace l │ │ │ -00073420: 6962 746f 7272 656e 743a 3a61 7578 3b0a ibtorrent::aux;. │ │ │ -00073430: 0909 6966 2028 6d5f 7665 7273 696f 6e20 ..if (m_version │ │ │ -00073440: 3d3d 2035 290a 0909 7b0a 0909 092f 2f20 == 5)...{....// │ │ │ -00073450: 7365 6e64 2053 4f43 4b53 3520 6175 7468 send SOCKS5 auth │ │ │ -00073460: 656e 7469 6361 7469 6f6e 206d 6574 686f entication metho │ │ │ -00073470: 6473 0a09 0909 6d5f 6275 6666 6572 2e72 ds....m_buffer.r │ │ │ -00073480: 6573 697a 6528 6d5f 7573 6572 2e65 6d70 esize(m_user.emp │ │ │ -00073490: 7479 2829 3f33 3a34 293b 0a09 0909 6368 ty()?3:4);....ch │ │ │ -000734a0: 6172 2a20 7020 3d20 2661 6d70 3b6d 5f62 ar* p = &m_b │ │ │ -000734b0: 7566 6665 725b 305d 3b0a 0909 0977 7269 uffer[0];....wri │ │ │ -000734c0: 7465 5f75 696e 7438 2835 2c20 7029 3b20 te_uint8(5, p); │ │ │ -000734d0: 2f2f 2053 4f43 4b53 2056 4552 5349 4f4e // SOCKS VERSION │ │ │ -000734e0: 2035 0a09 0909 6966 2028 6d5f 7573 6572 5....if (m_user │ │ │ -000734f0: 2e65 6d70 7479 2829 290a 0909 097b 0a09 .empty())....{.. │ │ │ -00073500: 0909 0977 7269 7465 5f75 696e 7438 2831 ...write_uint8(1 │ │ │ -00073510: 2c20 7029 3b20 2f2f 2031 2061 7574 6865 , p); // 1 authe │ │ │ -00073520: 6e74 6963 6174 696f 6e20 6d65 7468 6f64 ntication method │ │ │ -00073530: 2028 6e6f 2061 7574 6829 0a09 0909 0977 (no auth).....w │ │ │ -00073540: 7269 7465 5f75 696e 7438 2830 2c20 7029 rite_uint8(0, p) │ │ │ -00073550: 3b20 2f2f 206e 6f20 6175 7468 656e 7469 ; // no authenti │ │ │ -00073560: 6361 7469 6f6e 0a09 0909 7d0a 0909 0965 cation....}....e │ │ │ -00073570: 6c73 650a 0909 097b 0a09 0909 0977 7269 lse....{.....wri │ │ │ -00073580: 7465 5f75 696e 7438 2832 2c20 7029 3b20 te_uint8(2, p); │ │ │ -00073590: 2f2f 2032 2061 7574 6865 6e74 6963 6174 // 2 authenticat │ │ │ -000735a0: 696f 6e20 6d65 7468 6f64 730a 0909 0909 ion methods..... │ │ │ -000735b0: 7772 6974 655f 7569 6e74 3828 302c 2070 write_uint8(0, p │ │ │ -000735c0: 293b 202f 2f20 6e6f 2061 7574 6865 6e74 ); // no authent │ │ │ -000735d0: 6963 6174 696f 6e0a 0909 0909 7772 6974 ication.....writ │ │ │ -000735e0: 655f 7569 6e74 3828 322c 2070 293b 202f e_uint8(2, p); / │ │ │ -000735f0: 2f20 7573 6572 6e61 6d65 2f70 6173 7377 / username/passw │ │ │ -00073600: 6f72 640a 0909 097d 0a09 0909 4144 445f ord....}....ADD_ │ │ │ -00073610: 4f55 5453 5441 4e44 494e 475f 4153 594e OUTSTANDING_ASYN │ │ │ -00073620: 4328 2273 6f63 6b73 355f 7374 7265 616d C("socks5_stream │ │ │ -00073630: 3a3a 6861 6e64 7368 616b 6531 2229 3b0a ::handshake1");. │ │ │ -00073640: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00073650: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00073680: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -000736b0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -000736c0: 2f61 6e6e 6f75 6e63 655f 656e 7472 792e /announce_entry. │ │ │ -000736d0: 6870 703a 3539 3c2f 613e 3c2f 7464 3e3c hpp:59< │ │ │ -000736e0: 7464 3e69 6e63 6c75 6465 2074 6865 206e td>include the n │ │ │ -000736f0: 756d 6265 7220 6f66 2070 6565 7273 2072 umber of peers r │ │ │ -00073700: 6563 6569 7665 6420 6672 6f6d 2074 6869 eceived from thi │ │ │ -00073710: 7320 7472 6163 6b65 722c 2061 7420 6c61 s tracker, at la │ │ │ -00073720: 7374 2061 6e6e 6f75 6e63 653c 2f74 643e st announce │ │ │ -00073730: 3c2f 7472 3e3c 7472 2069 643d 2232 3634

    include │ │ │ -00073780: 2074 6865 206e 756d 6265 7220 6f66 2070 the number of p │ │ │ -00073790: 6565 7273 2072 6563 6569 7665 6420 6672 eers received fr │ │ │ -000737a0: 6f6d 2074 6869 7320 7472 6163 6b65 722c om this tracker, │ │ │ -000737b0: 2061 7420 6c61 7374 0a61 6e6e 6f75 6e63 at last.announc │ │ │ -000737c0: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ -000737d0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -000737e0: 616e 6e6f 756e 6365 5f65 6e74 7279 2e68 announce_entry.h │ │ │ -000737f0: 7070 3a35 393c 2f68 343e 3c70 7265 2073 pp:59

    // for each 
    │ │ │ -00073840: 7072 6f74 6f63 6f6c 2076 6572 7369 6f6e  protocol version
    │ │ │ -00073850: 2e0a 7374 7275 6374 2054 4f52 5245 4e54  ..struct TORRENT
    │ │ │ -00073860: 5f45 5850 4f52 5420 616e 6e6f 756e 6365  _EXPORT announce
    │ │ │ -00073870: 5f69 6e66 6f68 6173 680a 7b0a 092f 2f20  _infohash.{..// 
    │ │ │ -00073880: 696e 7465 726e 616c 0a09 544f 5252 454e  internal..TORREN
    │ │ │ -00073890: 545f 554e 4558 504f 5254 2061 6e6e 6f75  T_UNEXPORT annou
    │ │ │ -000738a0: 6e63 655f 696e 666f 6861 7368 2829 3b0a  nce_infohash();.
    │ │ │ -000738b0: 0a09 2f2f 2069 6620 7468 6973 2074 7261  ..// if this tra
    │ │ │ -000738c0: 636b 6572 2068 6173 2072 6574 7572 6e65  cker has returne
    │ │ │ -000738d0: 6420 616e 2065 7272 6f72 206f 7220 7761  d an error or wa
    │ │ │ -000738e0: 726e 696e 6720 6d65 7373 6167 650a 092f  rning message../
    │ │ │ -000738f0: 2f20 7468 6174 206d 6573 7361 6765 2069  / that message i
    │ │ │ -00073900: 7320 7374 6f72 6564 2068 6572 650a 0973  s stored here..s
    │ │ │ -00073910: 7464 3a3a 7374 7269 6e67 206d 6573 7361  td::string messa
    │ │ │ -00073920: 6765 3b0a 0a09 2f2f 2069 6620 7468 6973  ge;...// if this
    │ │ │ -00073930: 2074 7261 636b 6572 2066 6169 6c65 6420   tracker failed 
    │ │ │ -00073940: 7468 6520 6c61 7374 2074 696d 6520 6974  the last time it
    │ │ │ -00073950: 2077 6173 2063 6f6e 7461 6374 6564 0a09   was contacted..
    │ │ │ -00073960: 2f2f 2074 6869 7320 6572 726f 7220 636f  // this error co
    │ │ │ -00073970: 6465 2073 7065 6369 6669 6573 2077 6861  de specifies wha
    │ │ │ -00073980: 7420 6572 726f 7220 6f63 6375 7272 6564  t error occurred
    │ │ │ -00073990: 0a09 6572 726f 725f 636f 6465 206c 6173  ..error_code las
    │ │ │ -000739a0: 745f 6572 726f 723b 0a0a 092f 2f20 7468  t_error;...// th
    │ │ │ -000739b0: 6520 7469 6d65 206f 6620 6e65 7874 2074  e time of next t
    │ │ │ -000739c0: 7261 636b 6572 2061 6e6e 6f75 6e63 650a  racker announce.
    │ │ │ -000739d0: 0974 696d 655f 706f 696e 7433 3220 6e65  .time_point32 ne
    │ │ │ -000739e0: 7874 5f61 6e6e 6f75 6e63 6520 3d20 2874  xt_announce = (t
    │ │ │ -000739f0: 696d 655f 706f 696e 7433 323a 3a6d 696e  ime_point32::min
    │ │ │ -00073a00: 2928 293b 0a0a 092f 2f20 6e6f 2061 6e6e  )();...// no ann
    │ │ │ -00073a10: 6f75 6e63 6573 2062 6566 6f72 6520 7468  ounces before th
    │ │ │ -00073a20: 6973 2074 696d 650a 0974 696d 655f 706f  is time..time_po
    │ │ │ -00073a30: 696e 7433 3220 6d69 6e5f 616e 6e6f 756e  int32 min_announ
    │ │ │ -00073a40: 6365 203d 2028 7469 6d65 5f70 6f69 6e74  ce = (time_point
    │ │ │ -00073a50: 3332 3a3a 6d69 6e29 2829 3b0a 0a3c 6469  32::min)();....// these are 
    │ │ │ -00073aa0: 6569 7468 6572 202d 3120 6f72 2074 6865  either -1 or the
    │ │ │ -00073ab0: 2073 6372 6170 6520 696e 666f 726d 6174   scrape informat
    │ │ │ -00073ac0: 696f 6e20 7468 6973 2074 7261 636b 6572  ion this tracker
    │ │ │ -00073ad0: 206c 6173 740a 092f 2f20 7265 7370 6f6e   last..// respon
    │ │ │ -00073ae0: 6465 6420 7769 7468 2e20 2a69 6e63 6f6d  ded with. *incom
    │ │ │ -00073af0: 706c 6574 652a 2069 7320 7468 6520 6375  plete* is the cu
    │ │ │ -00073b00: 7272 656e 7420 6e75 6d62 6572 206f 6620  rrent number of 
    │ │ │ -00073b10: 646f 776e 6c6f 6164 6572 7320 696e 0a09  downloaders in..
    │ │ │ -00073b20: 2f2f 2074 6865 2073 7761 726d 2c20 2a63  // the swarm, *c
    │ │ │ -00073b30: 6f6d 706c 6574 652a 2069 7320 7468 6520  omplete* is the 
    │ │ │ -00073b40: 6375 7272 656e 7420 6e75 6d62 6572 206f  current number o
    │ │ │ -00073b50: 6620 7365 6564 7320 696e 2074 6865 2073  f seeds in the s
    │ │ │ -00073b60: 7761 726d 2061 6e64 0a09 2f2f 202a 646f  warm and..// *do
    │ │ │ -00073b70: 776e 6c6f 6164 6564 2a20 6973 2074 6865  wnloaded* is the
    │ │ │ -00073b80: 2063 756d 756c 6174 6976 6520 6e75 6d62   cumulative numb
    │ │ │ -00073b90: 6572 206f 6620 636f 6d70 6c65 7465 6420  er of completed 
    │ │ │ -00073ba0: 646f 776e 6c6f 6164 7320 6f66 2074 6869  downloads of thi
    │ │ │ -00073bb0: 730a 092f 2f20 746f 7272 656e 742c 2073  s..// torrent, s
    │ │ │ -00073bc0: 696e 6365 2074 6865 2062 6567 696e 6e69  ince the beginni
    │ │ │ -00073bd0: 6e67 206f 6620 7469 6d65 2028 6672 6f6d  ng of time (from
    │ │ │ -00073be0: 2074 6869 7320 7472 6163 6b65 7227 7320   this tracker's 
    │ │ │ -00073bf0: 706f 696e 7420 6f66 0a09 2f2f 2076 6965  point of..// vie
    │ │ │ -00073c00: 7729 2e0a 0a09 2f2f 2069 6620 7468 6973  w)....// if this
    │ │ │ -00073c10: 2074 7261 636b 6572 2068 6173 2072 6574   tracker has ret
    │ │ │ -00073c20: 7572 6e65 6420 7363 7261 7065 2064 6174  urned scrape dat
    │ │ │ -00073c30: 612c 2074 6865 7365 2066 6965 6c64 7320  a, these fields 
    │ │ │ -00073c40: 6172 6520 6669 6c6c 6564 2069 6e0a 092f  are filled in../
    │ │ │ -00073c50: 2f20 7769 7468 2076 616c 6964 206e 756d  / with valid num
    │ │ │ -00073c60: 6265 7273 2e20 4f74 6865 7277 6973 6520  bers. Otherwise 
    │ │ │ -00073c70: 7468 6579 2061 7265 2073 6574 2074 6f20  they are set to 
    │ │ │ -00073c80: 2d31 2e20 6060 696e 636f 6d70 6c65 7465  -1. ``incomplete
    │ │ │ -00073c90: 6060 2063 6f75 6e74 730a 092f 2f20 7468  `` counts..// th
    │ │ │ -00073ca0: 6520 6e75 6d62 6572 206f 6620 6375 7272  e number of curr
    │ │ │ -00073cb0: 656e 7420 646f 776e 6c6f 6164 6572 732e  ent downloaders.
    │ │ │ -00073cc0: 2060 6063 6f6d 706c 6574 6560 6020 636f   ``complete`` co
    │ │ │ -00073cd0: 756e 7473 2074 6865 206e 756d 6265 7220  unts the number 
    │ │ │ -00073ce0: 6f66 0a09 2f2f 2063 7572 7265 6e74 2070  of..// current p
    │ │ │ -00073cf0: 6565 7273 2063 6f6d 706c 6574 6564 2074  eers completed t
    │ │ │ -00073d00: 6865 2064 6f77 6e6c 6f61 642c 206f 7220  he download, or 
    │ │ │ -00073d10: 2273 6565 6473 222e 2060 6064 6f77 6e6c  "seeds". ``downl
    │ │ │ -00073d20: 6f61 6465 6460 6020 6973 2074 6865 0a09  oaded`` is the..
    │ │ │ -00073d30: 2f2f 2063 756d 756c 6174 6976 6520 6e75  // cumulative nu
    │ │ │ -00073d40: 6d62 6572 206f 6620 636f 6d70 6c65 7465  mber of complete
    │ │ │ -00073d50: 6420 646f 776e 6c6f 6164 732e 0a09 696e  d downloads...in
    │ │ │ -00073d60: 7420 7363 7261 7065 5f69 6e63 6f6d 706c  t scrape_incompl
    │ │ │ -00073d70: 6574 6520 3d20 2d31 3b0a 0969 6e74 2073  ete = -1;..int s
    │ │ │ -00073d80: 6372 6170 655f 636f 6d70 6c65 7465 203d  crape_complete =
    │ │ │ -00073d90: 202d 313b 0a09 696e 7420 7363 7261 7065   -1;..int scrape
    │ │ │ -00073da0: 5f64 6f77 6e6c 6f61 6465 6420 3d20 2d31  _downloaded = -1
    │ │ │ -00073db0: 3b0a 0a09 2f2f 2074 6865 206e 756d 6265  ;...// the numbe
    │ │ │ -00073dc0: 7220 6f66 2074 696d 6573 2069 6e20 6120  r of times in a 
    │ │ │ -00073dd0: 726f 7720 7765 2068 6176 6520 6661 696c  row we have fail
    │ │ │ -00073de0: 6564 2074 6f20 616e 6e6f 756e 6365 2074  ed to announce t
    │ │ │ -00073df0: 6f20 7468 6973 0a09 2f2f 2074 7261 636b  o this..// track
    │ │ │ -00073e00: 6572 2e0a 0973 7464 3a3a 7569 6e74 385f  er...std::uint8_
    │ │ │ -00073e10: 7420 6661 696c 7320 3a20 373b 0a0a 092f  t fails : 7;.../
    │ │ │ -00073e20: 2f20 7472 7565 2077 6869 6c65 2077 6527  / true while we'
    │ │ │ -00073e30: 7265 2077 6169 7469 6e67 2066 6f72 2061  re waiting for a
    │ │ │ -00073e40: 2072 6573 706f 6e73 6520 6672 6f6d 2074   response from t
    │ │ │ -00073e50: 6865 2074 7261 636b 6572 2e0a 0962 6f6f  he tracker...boo
    │ │ │ -00073e60: 6c20 7570 6461 7469 6e67 203a 2031 3b0a  l updating : 1;.
    │ │ │ -00073e70: 0a09 2f2f 2073 6574 2074 6f20 7472 7565  ..// set to true
    │ │ │ -00073e80: 2077 6865 6e20 7765 2067 6574 2061 2076   when we get a v
    │ │ │ -00073e90: 616c 6964 2072 6573 706f 6e73 6520 6672  alid response fr
    │ │ │ -00073ea0: 6f6d 2061 6e20 616e 6e6f 756e 6365 0a09  om an announce..
    │ │ │ -00073eb0: 2f2f 2077 6974 6820 6576 656e 743d 7374  // with event=st
    │ │ │ -00073ec0: 6172 7465 642e 2049 6620 6974 2069 7320  arted. If it is 
    │ │ │ -00073ed0: 7365 742c 2077 6520 776f 6e27 7420 7365  set, we won't se
    │ │ │ -00073ee0: 6e64 2073 7461 7274 2069 6e20 7468 6520  nd start in the 
    │ │ │ -00073ef0: 7375 6273 6571 7565 6e74 0a09 2f2f 2061  subsequent..// a
    │ │ │ -00073f00: 6e6e 6f75 6e63 6573 2e0a 0962 6f6f 6c20  nnounces...bool 
    │ │ │ -00073f10: 7374 6172 745f 7365 6e74 203a 2031 3b0a  start_sent : 1;.
    │ │ │ -00073f20: 0a09 2f2f 2073 6574 2074 6f20 7472 7565  ..// set to true
    │ │ │ -00073f30: 2077 6865 6e20 7765 2073 656e 6420 6120   when we send a 
    │ │ │ -00073f40: 6576 656e 743d 636f 6d70 6c65 7465 642e  event=completed.
    │ │ │ -00073f50: 0a09 626f 6f6c 2063 6f6d 706c 6574 655f  ..bool complete_
    │ │ │ -00073f60: 7365 6e74 203a 2031 3b0a 3c2f 7072 653e  sent : 1;.
    │ │ │ -00073f70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00073fa0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00073fb0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -00073fe0: 6c69 6274 6f72 7265 6e74 2f6b 6164 656d libtorrent/kadem │ │ │ -00073ff0: 6c69 612f 6d73 672e 6870 703a 3634 3c2f lia/msg.hpp:64move │ │ │ -00074010: 7468 6973 2074 6f20 6974 7320 6f77 6e20 this to its own │ │ │ -00074020: 2e68 7070 2f2e 6370 7020 7061 6972 3f3c .hpp/.cpp pair?< │ │ │ -00074030: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    mov │ │ │ -00074080: 6520 7468 6973 2074 6f20 6974 7320 6f77 e this to its ow │ │ │ -00074090: 6e20 2e68 7070 2f2e 6370 7020 7061 6972 n .hpp/.cpp pair │ │ │ -000740a0: 3f3c 2f68 323e 3c68 343e 2e2e 2f69 6e63 ?

    ../inc │ │ │ -000740b0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -000740c0: 6b61 6465 6d6c 6961 2f6d 7367 2e68 7070 kademlia/msg.hpp │ │ │ -000740d0: 3a36 343c 2f68 343e 3c70 7265 2073 7479 :64

    .int flags;...
    │ │ │ -00074120: 656e 756d 207b 0a09 092f 2f20 7468 6973  enum {...// this
    │ │ │ -00074130: 2061 7267 756d 656e 7420 6973 206f 7074   argument is opt
    │ │ │ -00074140: 696f 6e61 6c2c 2070 6172 7369 6e67 2077  ional, parsing w
    │ │ │ -00074150: 696c 6c20 6e6f 740a 0909 2f2f 2066 6169  ill not...// fai
    │ │ │ -00074160: 6c20 6966 2069 7427 7320 6e6f 7420 7072  l if it's not pr
    │ │ │ -00074170: 6573 656e 740a 0909 6f70 7469 6f6e 616c  esent...optional
    │ │ │ -00074180: 203d 2031 2c0a 0909 2f2f 2066 6f72 2064   = 1,...// for d
    │ │ │ -00074190: 6963 7469 6f6e 6172 6965 732c 2074 6865  ictionaries, the
    │ │ │ -000741a0: 2066 6f6c 6c6f 7769 6e67 2065 6e74 7269   following entri
    │ │ │ -000741b0: 6573 2072 6566 6572 0a09 092f 2f20 746f  es refer...// to
    │ │ │ -000741c0: 2063 6869 6c64 206e 6f64 6573 2074 6f20   child nodes to 
    │ │ │ -000741d0: 7468 6973 206e 6f64 652c 2075 7020 756e  this node, up un
    │ │ │ -000741e0: 7469 6c20 616e 6420 696e 636c 7564 696e  til and includin
    │ │ │ -000741f0: 670a 0909 2f2f 2074 6865 206e 6578 7420  g...// the next 
    │ │ │ -00074200: 6974 656d 2074 6861 7420 6861 7320 7468  item that has th
    │ │ │ -00074210: 6520 6c61 7374 5f63 6869 6c64 2066 6c61  e last_child fla
    │ │ │ -00074220: 6720 7365 742e 0a09 092f 2f20 7468 6573  g set....// thes
    │ │ │ -00074230: 6520 666c 6167 7320 6172 6520 6e65 7374  e flags are nest
    │ │ │ -00074240: 6162 6c65 0a09 0970 6172 7365 5f63 6869  able...parse_chi
    │ │ │ -00074250: 6c64 7265 6e20 3d20 322c 0a09 092f 2f20  ldren = 2,...// 
    │ │ │ -00074260: 7468 6973 2069 7320 7468 6520 6c61 7374  this is the last
    │ │ │ -00074270: 2069 7465 6d20 696e 2061 2063 6869 6c64   item in a child
    │ │ │ -00074280: 2064 6963 7469 6f6e 6172 790a 0909 6c61   dictionary...la
    │ │ │ -00074290: 7374 5f63 6869 6c64 203d 2034 2c0a 0909  st_child = 4,...
    │ │ │ -000742a0: 2f2f 2074 6865 2073 697a 6520 6172 6775  // the size argu
    │ │ │ -000742b0: 6d65 6e74 2072 6566 6572 7320 746f 2074  ment refers to t
    │ │ │ -000742c0: 6861 7420 7468 6520 7369 7a65 0a09 092f  hat the size.../
    │ │ │ -000742d0: 2f20 6861 7320 746f 2062 6520 6469 7669  / has to be divi
    │ │ │ -000742e0: 7369 626c 6520 6279 2074 6865 206e 756d  sible by the num
    │ │ │ -000742f0: 6265 722c 2069 6e73 7465 6164 0a09 092f  ber, instead.../
    │ │ │ -00074300: 2f20 6f66 2068 6176 696e 6720 7468 6174  / of having that
    │ │ │ -00074310: 2065 7861 6374 2073 697a 650a 0909 7369   exact size...si
    │ │ │ -00074320: 7a65 5f64 6976 6973 6962 6c65 203d 2038  ze_divisible = 8
    │ │ │ -00074330: 0a09 7d3b 0a7d 3b0a 0a3c 6469 7620 7374  ..};.};..
    TORRENT_E │ │ │ -00074370: 5854 5241 5f45 5850 4f52 5420 626f 6f6c XTRA_EXPORT bool │ │ │ -00074380: 2076 6572 6966 795f 6d65 7373 6167 655f verify_message_ │ │ │ -00074390: 696d 706c 2862 6465 636f 6465 5f6e 6f64 impl(bdecode_nod │ │ │ -000743a0: 6520 636f 6e73 7426 616d 703b 206d 6573 e const& mes │ │ │ -000743b0: 7361 6765 2c20 7370 616e 266c 743b 6b65 sage, span<ke │ │ │ -000743c0: 795f 6465 7363 5f74 2063 6f6e 7374 2667 y_desc_t const&g │ │ │ -000743d0: 743b 2064 6573 630a 3c2f 6469 763e 092c t; desc.
    ., │ │ │ -000743e0: 2073 7061 6e26 6c74 3b62 6465 636f 6465 span<bdecode │ │ │ -000743f0: 5f6e 6f64 6526 6774 3b20 7265 742c 2073 _node> ret, s │ │ │ -00074400: 7061 6e26 6c74 3b63 6861 7226 6774 3b20 pan<char> │ │ │ -00074410: 6572 726f 7229 3b0a 0a2f 2f20 7665 7269 error);..// veri │ │ │ -00074420: 6669 6573 2074 6861 7420 6120 6d65 7373 fies that a mess │ │ │ -00074430: 6167 6520 6861 7320 616c 6c20 7468 6520 age has all the │ │ │ -00074440: 7265 7175 6972 6564 0a2f 2f20 656e 7472 required.// entr │ │ │ -00074450: 6965 7320 616e 6420 7265 7475 726e 7320 ies and returns │ │ │ -00074460: 7468 656d 2069 6e20 7265 740a 7465 6d70 them in ret.temp │ │ │ -00074470: 6c61 7465 2026 6c74 3b69 6e74 2053 697a late <int Siz │ │ │ -00074480: 6526 6774 3b0a 626f 6f6c 2076 6572 6966 e>.bool verif │ │ │ -00074490: 795f 6d65 7373 6167 6528 6264 6563 6f64 y_message(bdecod │ │ │ -000744a0: 655f 6e6f 6465 2063 6f6e 7374 2661 6d70 e_node const& │ │ │ -000744b0: 3b20 6d73 672c 206b 6579 5f64 6573 635f ; msg, key_desc_ │ │ │ -000744c0: 7420 636f 6e73 7420 2826 616d 703b 6465 t const (&de │ │ │ -000744d0: 7363 295b 5369 7a65 5d0a 092c 2062 6465 sc)[Size].., bde │ │ │ -000744e0: 636f 6465 5f6e 6f64 6520 2826 616d 703b code_node (& │ │ │ -000744f0: 7265 7429 5b53 697a 655d 2c20 7370 616e ret)[Size], span │ │ │ -00074500: 266c 743b 6368 6172 2667 743b 2065 7272 <char> err │ │ │ -00074510: 6f72 290a 7b0a 0972 6574 7572 6e20 7665 or).{..return ve │ │ │ -00074520: 7269 6679 5f6d 6573 7361 6765 5f69 6d70 rify_message_imp │ │ │ -00074530: 6c28 6d73 672c 2064 6573 632c 2072 6574 l(msg, desc, ret │ │ │ -00074540: 2c20 6572 726f 7229 3b0a 7d0a 0a7d 0a7d , error);.}..}.} │ │ │ -00074550: 0a0a 2365 6e64 6966 0a3c 2f70 7265 3e3c ..#endif.
    < │ │ │ -00074560: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00074590: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000745a0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../include/l │ │ │ -000745d0: 6962 746f 7272 656e 742f 6b61 6465 6d6c ibtorrent/kademl │ │ │ -000745e0: 6961 2f69 7465 6d2e 6870 703a 3338 3c2f ia/item.hpp:38since │ │ │ -00074600: 2074 6869 7320 6973 2061 2070 7562 6c69 this is a publi │ │ │ -00074610: 6320 6675 6e63 7469 6f6e 2c20 6974 2073 c function, it s │ │ │ -00074620: 686f 756c 6420 7072 6f62 6162 6c79 2062 hould probably b │ │ │ -00074630: 6520 6d6f 7665 6420 6f75 7420 6f66 2074 e moved out of t │ │ │ -00074640: 6869 7320 6865 6164 6572 2061 6e64 2069 his header and i │ │ │ -00074650: 6e74 6f20 6f6e 6520 7769 7468 206f 7468 nto one with oth │ │ │ -00074660: 6572 2070 7562 6c69 6320 6675 6e63 7469 er public functi │ │ │ -00074670: 6f6e 732e 3c2f 7464 3e3c 2f74 723e 3c74 ons.since this is │ │ │ -000746d0: 6120 7075 626c 6963 2066 756e 6374 696f a public functio │ │ │ -000746e0: 6e2c 2069 7420 7368 6f75 6c64 2070 726f n, it should pro │ │ │ -000746f0: 6261 626c 7920 6265 206d 6f76 6564 0a6f bably be moved.o │ │ │ -00074700: 7574 206f 6620 7468 6973 2068 6561 6465 ut of this heade │ │ │ -00074710: 7220 616e 6420 696e 746f 206f 6e65 2077 r and into one w │ │ │ -00074720: 6974 6820 6f74 6865 7220 7075 626c 6963 ith other public │ │ │ -00074730: 2066 756e 6374 696f 6e73 2e3c 2f68 323e functions. │ │ │ -00074740: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00074750: 6962 746f 7272 656e 742f 6b61 6465 6d6c ibtorrent/kademl │ │ │ -00074760: 6961 2f69 7465 6d2e 6870 703a 3338 3c2f ia/item.hpp:38
    #in
    │ │ │ -000747b0: 636c 7564 6520 266c 743b 6c69 6274 6f72  clude <libtor
    │ │ │ -000747c0: 7265 6e74 2f73 7061 6e2e 6870 7026 6774  rent/span.hpp>
    │ │ │ -000747d0: 3b0a 2369 6e63 6c75 6465 2026 6c74 3b6c  ;.#include <l
    │ │ │ -000747e0: 6962 746f 7272 656e 742f 6b61 6465 6d6c  ibtorrent/kademl
    │ │ │ -000747f0: 6961 2f74 7970 6573 2e68 7070 2667 743b  ia/types.hpp>
    │ │ │ -00074800: 0a0a 6e61 6d65 7370 6163 6520 6c69 6274  ..namespace libt
    │ │ │ -00074810: 6f72 7265 6e74 207b 0a6e 616d 6573 7061  orrent {.namespa
    │ │ │ -00074820: 6365 2064 6874 207b 0a0a 2f2f 2063 616c  ce dht {..// cal
    │ │ │ -00074830: 6375 6c61 7465 2074 6865 2074 6172 6765  culate the targe
    │ │ │ -00074840: 7420 6861 7368 2066 6f72 2061 6e20 696d  t hash for an im
    │ │ │ -00074850: 6d75 7461 626c 6520 6974 656d 2e0a 544f  mutable item..TO
    │ │ │ -00074860: 5252 454e 545f 4558 5452 415f 4558 504f  RRENT_EXTRA_EXPO
    │ │ │ -00074870: 5254 2073 6861 315f 6861 7368 2069 7465  RT sha1_hash ite
    │ │ │ -00074880: 6d5f 7461 7267 6574 5f69 6428 7370 616e  m_target_id(span
    │ │ │ -00074890: 266c 743b 6368 6172 2063 6f6e 7374 2667  <char const&g
    │ │ │ -000748a0: 743b 2076 293b 0a0a 2f2f 2063 616c 6375  t; v);..// calcu
    │ │ │ -000748b0: 6c61 7465 2074 6865 2074 6172 6765 7420  late the target 
    │ │ │ -000748c0: 6861 7368 2066 6f72 2061 206d 7574 6162  hash for a mutab
    │ │ │ -000748d0: 6c65 2069 7465 6d2e 0a54 4f52 5245 4e54  le item..TORRENT
    │ │ │ -000748e0: 5f45 5854 5241 5f45 5850 4f52 5420 7368  _EXTRA_EXPORT sh
    │ │ │ -000748f0: 6131 5f68 6173 6820 6974 656d 5f74 6172  a1_hash item_tar
    │ │ │ -00074900: 6765 745f 6964 2873 7061 6e26 6c74 3b63  get_id(span<c
    │ │ │ -00074910: 6861 7220 636f 6e73 7426 6774 3b20 7361  har const> sa
    │ │ │ -00074920: 6c74 0a09 2c20 7075 626c 6963 5f6b 6579  lt.., public_key
    │ │ │ -00074930: 2063 6f6e 7374 2661 6d70 3b20 706b 293b   const& pk);
    │ │ │ -00074940: 0a0a 544f 5252 454e 545f 4558 5452 415f  ..TORRENT_EXTRA_
    │ │ │ -00074950: 4558 504f 5254 2062 6f6f 6c20 7665 7269  EXPORT bool veri
    │ │ │ -00074960: 6679 5f6d 7574 6162 6c65 5f69 7465 6d28  fy_mutable_item(
    │ │ │ -00074970: 0a09 7370 616e 266c 743b 6368 6172 2063  ..span<char c
    │ │ │ -00074980: 6f6e 7374 2667 743b 2076 0a09 2c20 7370  onst> v.., sp
    │ │ │ -00074990: 616e 266c 743b 6368 6172 2063 6f6e 7374  an<char const
    │ │ │ -000749a0: 2667 743b 2073 616c 740a 092c 2073 6571  > salt.., seq
    │ │ │ -000749b0: 7565 6e63 655f 6e75 6d62 6572 2073 6571  uence_number seq
    │ │ │ -000749c0: 0a09 2c20 7075 626c 6963 5f6b 6579 2063  .., public_key c
    │ │ │ -000749d0: 6f6e 7374 2661 6d70 3b20 706b 0a09 2c20  onst& pk.., 
    │ │ │ -000749e0: 7369 676e 6174 7572 6520 636f 6e73 7426  signature const&
    │ │ │ -000749f0: 616d 703b 2073 6967 293b 0a0a 3c64 6976  amp; sig);..
    .
    // given a byte │ │ │ -00074a40: 2072 616e 6765 2060 6076 6060 2061 6e64 range ``v`` and │ │ │ -00074a50: 2061 6e20 6f70 7469 6f6e 616c 2062 7974 an optional byt │ │ │ -00074a60: 6520 7261 6e67 6520 6060 7361 6c74 6060 e range ``salt`` │ │ │ -00074a70: 2c20 610a 2f2f 2073 6571 7565 6e63 6520 , a.// sequence │ │ │ -00074a80: 6e75 6d62 6572 2c20 7075 626c 6963 206b number, public k │ │ │ -00074a90: 6579 2060 6070 6b60 6020 286d 7573 7420 ey ``pk`` (must │ │ │ -00074aa0: 6265 2033 3220 6279 7465 7329 2061 6e64 be 32 bytes) and │ │ │ -00074ab0: 2061 2073 6563 7265 7420 6b65 790a 2f2f a secret key.// │ │ │ -00074ac0: 2060 6073 6b60 6020 286d 7573 7420 6265 ``sk`` (must be │ │ │ -00074ad0: 2036 3420 6279 7465 7329 2c20 7468 6973 64 bytes), this │ │ │ -00074ae0: 2066 756e 6374 696f 6e20 7072 6f64 7563 function produc │ │ │ -00074af0: 6573 2061 2073 6967 6e61 7475 7265 2077 es a signature w │ │ │ -00074b00: 6869 6368 0a2f 2f20 6973 2077 7269 7474 hich.// is writt │ │ │ -00074b10: 656e 2069 6e74 6f20 6120 3634 2062 7974 en into a 64 byt │ │ │ -00074b20: 6520 6275 6666 6572 2070 6f69 6e74 6564 e buffer pointed │ │ │ -00074b30: 2074 6f20 6279 2060 6073 6967 6060 2e20 to by ``sig``. │ │ │ -00074b40: 5468 6520 6361 6c6c 6572 0a2f 2f20 6973 The caller.// is │ │ │ -00074b50: 2072 6573 706f 6e73 6962 6c65 2066 6f72 responsible for │ │ │ -00074b60: 2061 6c6c 6f63 6174 696e 6720 7468 6520 allocating the │ │ │ -00074b70: 6465 7374 696e 6174 696f 6e20 6275 6666 destination buff │ │ │ -00074b80: 6572 2074 6861 7427 7320 7061 7373 6564 er that's passed │ │ │ -00074b90: 2069 6e0a 2f2f 2061 7320 7468 6520 6060 in.// as the `` │ │ │ -00074ba0: 7369 6760 6020 6172 6775 6d65 6e74 2e20 sig`` argument. │ │ │ -00074bb0: 5479 7069 6361 6c6c 7920 6974 2077 6f75 Typically it wou │ │ │ -00074bc0: 6c64 2062 6520 616c 6c6f 6361 7465 6420 ld be allocated │ │ │ -00074bd0: 6f6e 2074 6865 2073 7461 636b 2e0a 544f on the stack..TO │ │ │ -00074be0: 5252 454e 545f 4558 504f 5254 2073 6967 RRENT_EXPORT sig │ │ │ -00074bf0: 6e61 7475 7265 2073 6967 6e5f 6d75 7461 nature sign_muta │ │ │ -00074c00: 626c 655f 6974 656d 280a 0973 7061 6e26 ble_item(..span& │ │ │ -00074c10: 6c74 3b63 6861 7220 636f 6e73 7426 6774 lt;char const> │ │ │ -00074c20: 3b20 760a 092c 2073 7061 6e26 6c74 3b63 ; v.., span<c │ │ │ -00074c30: 6861 7220 636f 6e73 7426 6774 3b20 7361 har const> sa │ │ │ -00074c40: 6c74 0a09 2c20 7365 7175 656e 6365 5f6e lt.., sequence_n │ │ │ -00074c50: 756d 6265 7220 7365 710a 092c 2070 7562 umber seq.., pub │ │ │ -00074c60: 6c69 635f 6b65 7920 636f 6e73 7426 616d lic_key const&am │ │ │ -00074c70: 703b 2070 6b0a 092c 2073 6563 7265 745f p; pk.., secret_ │ │ │ -00074c80: 6b65 7920 636f 6e73 7426 616d 703b 2073 key const& s │ │ │ -00074c90: 6b29 3b0a 0a63 6c61 7373 2054 4f52 5245 k);..class TORRE │ │ │ -00074ca0: 4e54 5f45 5854 5241 5f45 5850 4f52 5420 NT_EXTRA_EXPORT │ │ │ -00074cb0: 6974 656d 0a7b 0a70 7562 6c69 633a 0a09 item.{.public:.. │ │ │ -00074cc0: 6974 656d 2829 207b 7d0a 0969 7465 6d28 item() {}..item( │ │ │ -00074cd0: 7075 626c 6963 5f6b 6579 2063 6f6e 7374 public_key const │ │ │ -00074ce0: 2661 6d70 3b20 706b 2c20 7370 616e 266c & pk, span&l │ │ │ -00074cf0: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ -00074d00: 2073 616c 7429 3b0a 0965 7870 6c69 6369 salt);..explici │ │ │ -00074d10: 7420 6974 656d 2865 6e74 7279 2076 293b t item(entry v); │ │ │ -00074d20: 0a09 6974 656d 2865 6e74 7279 2076 0a09 ..item(entry v.. │ │ │ -00074d30: 092c 2073 7061 6e26 6c74 3b63 6861 7220 ., span<char │ │ │ -00074d40: 636f 6e73 7426 6774 3b20 7361 6c74 0a09 const> salt.. │ │ │ -00074d50: 092c 2073 6571 7565 6e63 655f 6e75 6d62 ., sequence_numb │ │ │ -00074d60: 6572 2073 6571 0a09 092c 2070 7562 6c69 er seq..., publi │ │ │ -00074d70: 635f 6b65 7920 636f 6e73 7426 616d 703b c_key const& │ │ │ -00074d80: 2070 6b0a 0909 2c20 7365 6372 6574 5f6b pk..., secret_k │ │ │ -00074d90: 6579 2063 6f6e 7374 2661 6d70 3b20 736b ey const& sk │ │ │ -00074da0: 293b 0a09 6578 706c 6963 6974 2069 7465 );..explicit ite │ │ │ -00074db0: 6d28 6264 6563 6f64 655f 6e6f 6465 2063 m(bdecode_node c │ │ │ -00074dc0: 6f6e 7374 2661 6d70 3b20 7629 3b0a 0a09 onst& v);... │ │ │ -00074dd0: 766f 6964 2061 7373 6967 6e28 656e 7472 void assign(entr │ │ │ -00074de0: 7920 7629 3b0a 0976 6f69 6420 6173 7369 y v);..void assi │ │ │ -00074df0: 676e 2865 6e74 7279 2076 2c20 7370 616e gn(entry v, span │ │ │ -00074e00: 266c 743b 6368 6172 2063 6f6e 7374 2667 <char const&g │ │ │ -00074e10: 743b 2073 616c 740a 0909 2c20 7365 7175 t; salt..., sequ │ │ │ -00074e20: 656e 6365 5f6e 756d 6265 7220 7365 710a ence_number seq. │ │ │ -00074e30: 0909 2c20 7075 626c 6963 5f6b 6579 2063 .., public_key c │ │ │ -00074e40: 6f6e 7374 2661 6d70 3b20 706b 0a3c 2f70 onst& pk.

    re │ │ │ -00074e80: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ -00074ec0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -00074ed0: 785f 2f68 6173 685f 7069 636b 6572 2e68 x_/hash_picker.h │ │ │ -00074ee0: 7070 3a31 3333 3c2f 613e 3c2f 7464 3e3c pp:133< │ │ │ -00074ef0: 7464 3e73 7570 706f 7274 2062 6174 6368 td>support batch │ │ │ -00074f00: 6564 2061 6464 696e 6720 6f66 2062 6c6f ed adding of blo │ │ │ -00074f10: 636b 2068 6173 6865 7320 666f 7220 7265 ck hashes for re │ │ │ -00074f20: 6475 6365 6420 6f76 6572 6865 6164 3f3c duced overhead?< │ │ │ -00074f30: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sup │ │ │ -00074f80: 706f 7274 2062 6174 6368 6564 2061 6464 port batched add │ │ │ -00074f90: 696e 6720 6f66 2062 6c6f 636b 2068 6173 ing of block has │ │ │ -00074fa0: 6865 7320 666f 7220 7265 6475 6365 6420 hes for reduced │ │ │ -00074fb0: 6f76 6572 6865 6164 3f3c 2f68 323e 3c68 overhead?

    ../include/lib │ │ │ -00074fd0: 746f 7272 656e 742f 6175 785f 2f68 6173 torrent/aux_/has │ │ │ -00074fe0: 685f 7069 636b 6572 2e68 7070 3a31 3333 h_picker.hpp:133 │ │ │ -00074ff0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00075030: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -00075040: 6620 6861 7368 6573 2069 6e20 7468 6520  f hashes in the 
    │ │ │ -00075050: 7261 6e67 650a 0909 696e 7420 636f 756e  range...int coun
    │ │ │ -00075060: 7420 3d20 303b 0a09 0969 6e74 2070 726f  t = 0;...int pro
    │ │ │ -00075070: 6f66 5f6c 6179 6572 7320 3d20 303b 0a09  of_layers = 0;..
    │ │ │ -00075080: 7d3b 0a0a 092f 2f20 7661 6c69 6461 7465  };...// validate
    │ │ │ -00075090: 7320 7468 6520 6861 7368 5f72 6571 7565  s the hash_reque
    │ │ │ -000750a0: 7374 2c20 746f 2065 6e73 7572 6520 6974  st, to ensure it
    │ │ │ -000750b0: 7320 696e 7661 7269 616e 7420 6173 2077  s invariant as w
    │ │ │ -000750c0: 656c 6c20 6173 206d 6174 6368 696e 670a  ell as matching.
    │ │ │ -000750d0: 092f 2f20 7468 6520 746f 7272 656e 7427  .// the torrent'
    │ │ │ -000750e0: 7320 6669 6c65 5f73 746f 7261 6765 2061  s file_storage a
    │ │ │ -000750f0: 6e64 2074 6865 206e 756d 6265 7220 6f66  nd the number of
    │ │ │ -00075100: 2068 6173 6865 7320 6163 636f 6d70 616e   hashes accompan
    │ │ │ -00075110: 7969 6e67 2074 6865 0a09 2f2f 2072 6571  ying the..// req
    │ │ │ -00075120: 7565 7374 0a09 544f 5252 454e 545f 4558  uest..TORRENT_EX
    │ │ │ -00075130: 5452 415f 4558 504f 5254 0a09 626f 6f6c  TRA_EXPORT..bool
    │ │ │ -00075140: 2076 616c 6964 6174 655f 6861 7368 5f72   validate_hash_r
    │ │ │ -00075150: 6571 7565 7374 2868 6173 685f 7265 7175  equest(hash_requ
    │ │ │ -00075160: 6573 7420 636f 6e73 7426 616d 703b 2068  est const& h
    │ │ │ -00075170: 722c 2066 696c 655f 7374 6f72 6167 6520  r, file_storage 
    │ │ │ -00075180: 636f 6e73 7426 616d 703b 2066 7329 3b0a  const& fs);.
    │ │ │ -00075190: 0a09 636c 6173 7320 544f 5252 454e 545f  ..class TORRENT_
    │ │ │ -000751a0: 4558 5452 415f 4558 504f 5254 2068 6173  EXTRA_EXPORT has
    │ │ │ -000751b0: 685f 7069 636b 6572 0a09 7b0a 0970 7562  h_picker..{..pub
    │ │ │ -000751c0: 6c69 633a 0a09 0968 6173 685f 7069 636b  lic:...hash_pick
    │ │ │ -000751d0: 6572 2866 696c 655f 7374 6f72 6167 6520  er(file_storage 
    │ │ │ -000751e0: 636f 6e73 7426 616d 703b 2066 696c 6573  const& files
    │ │ │ -000751f0: 0a09 0909 2c20 6175 783a 3a76 6563 746f  ...., aux::vecto
    │ │ │ -00075200: 7226 6c74 3b61 7578 3a3a 6d65 726b 6c65  r<aux::merkle
    │ │ │ -00075210: 5f74 7265 652c 2066 696c 655f 696e 6465  _tree, file_inde
    │ │ │ -00075220: 785f 7426 6774 3b26 616d 703b 2074 7265  x_t>& tre
    │ │ │ -00075230: 6573 293b 0a0a 0909 6861 7368 5f72 6571  es);....hash_req
    │ │ │ -00075240: 7565 7374 2070 6963 6b5f 6861 7368 6573  uest pick_hashes
    │ │ │ -00075250: 2874 7970 6564 5f62 6974 6669 656c 6426  (typed_bitfield&
    │ │ │ -00075260: 6c74 3b70 6965 6365 5f69 6e64 6578 5f74  lt;piece_index_t
    │ │ │ -00075270: 2667 743b 2063 6f6e 7374 2661 6d70 3b20  > const& 
    │ │ │ -00075280: 7069 6563 6573 293b 0a0a 0909 6164 645f  pieces);....add_
    │ │ │ -00075290: 6861 7368 6573 5f72 6573 756c 7420 6164  hashes_result ad
    │ │ │ -000752a0: 645f 6861 7368 6573 2868 6173 685f 7265  d_hashes(hash_re
    │ │ │ -000752b0: 7175 6573 7420 636f 6e73 7426 616d 703b  quest const&
    │ │ │ -000752c0: 2072 6571 2c20 7370 616e 266c 743b 7368   req, span<sh
    │ │ │ -000752d0: 6132 3536 5f68 6173 6820 636f 6e73 7426  a256_hash const&
    │ │ │ -000752e0: 6774 3b20 6861 7368 6573 293b 0a3c 6469  gt; hashes);...set
    │ │ │ -00075320: 5f62 6c6f 636b 5f68 6173 685f 7265 7375  _block_hash_resu
    │ │ │ -00075330: 6c74 2073 6574 5f62 6c6f 636b 5f68 6173  lt set_block_has
    │ │ │ -00075340: 6828 7069 6563 655f 696e 6465 785f 7420  h(piece_index_t 
    │ │ │ -00075350: 7069 6563 652c 2069 6e74 206f 6666 7365  piece, int offse
    │ │ │ -00075360: 742c 2073 6861 3235 365f 6861 7368 2063  t, sha256_hash c
    │ │ │ -00075370: 6f6e 7374 2661 6d70 3b20 6829 3b0a 3c2f  onst& h);...void hashe
    │ │ │ -00075390: 735f 7265 6a65 6374 6564 2868 6173 685f  s_rejected(hash_
    │ │ │ -000753a0: 7265 7175 6573 7420 636f 6e73 7426 616d  request const&am
    │ │ │ -000753b0: 703b 2072 6571 293b 0a09 0976 6f69 6420  p; req);...void 
    │ │ │ -000753c0: 7665 7269 6679 5f62 6c6f 636b 5f68 6173  verify_block_has
    │ │ │ -000753d0: 6865 7328 7069 6563 655f 696e 6465 785f  hes(piece_index_
    │ │ │ -000753e0: 7420 696e 6465 7829 3b0a 0a09 092f 2f20  t index);....// 
    │ │ │ -000753f0: 646f 2077 6520 6b6e 6f77 2074 6865 2070  do we know the p
    │ │ │ -00075400: 6965 6365 206c 6179 6572 2068 6173 6820  iece layer hash 
    │ │ │ -00075410: 666f 7220 6120 7069 6563 650a 0909 626f  for a piece...bo
    │ │ │ -00075420: 6f6c 2068 6176 655f 6861 7368 2870 6965  ol have_hash(pie
    │ │ │ -00075430: 6365 5f69 6e64 6578 5f74 2069 6e64 6578  ce_index_t index
    │ │ │ -00075440: 2920 636f 6e73 743b 0a09 092f 2f20 646f  ) const;...// do
    │ │ │ -00075450: 2077 6520 6b6e 6f77 2061 6c6c 2074 6865   we know all the
    │ │ │ -00075460: 2062 6c6f 636b 2068 6173 6865 7320 666f   block hashes fo
    │ │ │ -00075470: 7220 6120 6669 6c65 3f0a 0909 626f 6f6c  r a file?...bool
    │ │ │ -00075480: 2068 6176 655f 616c 6c28 6669 6c65 5f69   have_all(file_i
    │ │ │ -00075490: 6e64 6578 5f74 2066 696c 6529 2063 6f6e  ndex_t file) con
    │ │ │ -000754a0: 7374 3b0a 0909 626f 6f6c 2068 6176 655f  st;...bool have_
    │ │ │ -000754b0: 616c 6c28 2920 636f 6e73 743b 0a09 0962  all() const;...b
    │ │ │ -000754c0: 6f6f 6c20 7069 6563 655f 7665 7269 6669  ool piece_verifi
    │ │ │ -000754d0: 6564 2870 6965 6365 5f69 6e64 6578 5f74  ed(piece_index_t
    │ │ │ -000754e0: 2070 6965 6365 2920 636f 6e73 743b 0a0a   piece) const;..
    │ │ │ -000754f0: 0909 696e 7420 7069 6563 655f 6c61 7965  ..int piece_laye
    │ │ │ -00075500: 7228 2920 636f 6e73 7420 7b20 7265 7475  r() const { retu
    │ │ │ -00075510: 726e 206d 5f70 6965 6365 5f6c 6179 6572  rn m_piece_layer
    │ │ │ -00075520: 3b20 7d0a 0a09 7072 6976 6174 653a 0a09  ; }...private:..
    │ │ │ -00075530: 092f 2f20 7265 7475 726e 7320 7468 6520  .// returns the 
    │ │ │ -00075540: 6e75 6d62 6572 206f 6620 7072 6f6f 6620  number of proof 
    │ │ │ -00075550: 6c61 7965 7273 206e 6565 6465 6420 746f  layers needed to
    │ │ │ -00075560: 2076 6572 6966 7920 7468 6520 6e6f 6465   verify the node
    │ │ │ -00075570: 2773 2068 6173 680a 0909 696e 7420 6c61  's hash...int la
    │ │ │ -00075580: 7965 7273 5f74 6f5f 7665 7269 6679 286e  yers_to_verify(n
    │ │ │ -00075590: 6f64 655f 696e 6465 7820 6964 7829 2063  ode_index idx) c
    │ │ │ -000755a0: 6f6e 7374 3b0a 0909 696e 7420 6669 6c65  onst;...int file
    │ │ │ -000755b0: 5f6e 756d 5f6c 6179 6572 7328 6669 6c65  _num_layers(file
    │ │ │ -000755c0: 5f69 6e64 6578 5f74 2069 6478 2920 636f  _index_t idx) co
    │ │ │ -000755d0: 6e73 743b 0a0a 0909 7374 7275 6374 2070  nst;....struct p
    │ │ │ -000755e0: 6965 6365 5f68 6173 685f 7265 7175 6573  iece_hash_reques
    │ │ │ -000755f0: 740a 0909 7b0a 0909 0974 696d 655f 706f  t...{....time_po
    │ │ │ -00075600: 696e 7420 6c61 7374 5f72 6571 7565 7374  int last_request
    │ │ │ -00075610: 203d 206d 696e 5f74 696d 6528 293b 0a09   = min_time();..
    │ │ │ -00075620: 0909 696e 7420 6e75 6d5f 7265 7175 6573  ..int num_reques
    │ │ │ -00075630: 7473 203d 2030 3b0a 0909 0962 6f6f 6c20  ts = 0;....bool 
    │ │ │ -00075640: 6861 7665 203d 2066 616c 7365 3b0a 0909  have = false;...
    │ │ │ -00075650: 7d3b 0a0a 0909 7374 7275 6374 2070 7269  };....struct pri
    │ │ │ -00075660: 6f72 6974 795f 626c 6f63 6b5f 7265 7175  ority_block_requ
    │ │ │ -00075670: 6573 740a 0909 7b0a 0909 0970 7269 6f72  est...{....prior
    │ │ │ -00075680: 6974 795f 626c 6f63 6b5f 7265 7175 6573  ity_block_reques
    │ │ │ -00075690: 7428 6669 6c65 5f69 6e64 6578 5f74 2063  t(file_index_t c
    │ │ │ -000756a0: 6f6e 7374 2066 2c20 696e 7420 636f 6e73  onst f, int cons
    │ │ │ -000756b0: 7420 6229 0a09 0909 093a 2066 696c 6528  t b).....: file(
    │ │ │ -000756c0: 6629 2c20 626c 6f63 6b28 6229 207b 7d0a  f), block(b) {}.
    │ │ │ -000756d0: 0909 0966 696c 655f 696e 6465 785f 7420  ...file_index_t 
    │ │ │ -000756e0: 6669 6c65 3b0a 0909 0969 6e74 2062 6c6f  file;....int blo
    │ │ │ -000756f0: 636b 3b0a 3c2f 7072 653e 3c2f 7464 3e3c  ck;.
    < │ │ │ -00075700: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00075730: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00075760: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00075770: 7265 6e74 2f61 7578 5f2f 7065 6572 2e68 rent/aux_/peer.h │ │ │ -00075780: 7070 3a34 373c 2f61 3e3c 2f74 643e 3c74 pp:47it seems unnec │ │ │ -000757a0: 6573 7361 7279 2074 6f20 7772 6170 2074 essary to wrap t │ │ │ -000757b0: 6869 7320 6932 7020 6164 6472 6573 7320 his i2p address │ │ │ -000757c0: 696e 2061 2073 7472 7563 743c 2f74 643e in a struct │ │ │ -000757d0: 3c2f 7472 3e3c 7472 2069 643d 2232 3638

    it seem │ │ │ -00075820: 7320 756e 6e65 6365 7373 6172 7920 746f s unnecessary to │ │ │ -00075830: 2077 7261 7020 7468 6973 2069 3270 2061 wrap this i2p a │ │ │ -00075840: 6464 7265 7373 2069 6e20 6120 7374 7275 ddress in a stru │ │ │ -00075850: 6374 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ct

    ../in │ │ │ -00075860: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00075870: 2f61 7578 5f2f 7065 6572 2e68 7070 3a34 /aux_/peer.hpp:4 │ │ │ -00075880: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ -000758c0: 0909 626f 6f6c 206f 7065 7261 746f 723d  ..bool operator=
    │ │ │ -000758d0: 3d28 636f 6e73 7420 7065 6572 5f65 6e74  =(const peer_ent
    │ │ │ -000758e0: 7279 2661 6d70 3b20 7029 2063 6f6e 7374  ry& p) const
    │ │ │ -000758f0: 0a09 097b 2072 6574 7572 6e20 7069 6420  ...{ return pid 
    │ │ │ -00075900: 3d3d 2070 2e70 6964 3b20 7d0a 0a09 0962  == p.pid; }....b
    │ │ │ -00075910: 6f6f 6c20 6f70 6572 6174 6f72 266c 743b  ool operator<
    │ │ │ -00075920: 2863 6f6e 7374 2070 6565 725f 656e 7472  (const peer_entr
    │ │ │ -00075930: 7926 616d 703b 2070 2920 636f 6e73 740a  y& p) const.
    │ │ │ -00075940: 0909 7b20 7265 7475 726e 2070 6964 2026  ..{ return pid &
    │ │ │ -00075950: 6c74 3b20 702e 7069 643b 207d 0a09 7d3b  lt; p.pid; }..};
    │ │ │ -00075960: 0a0a 0973 7472 7563 7420 6970 7634 5f70  ...struct ipv4_p
    │ │ │ -00075970: 6565 725f 656e 7472 790a 097b 0a09 0961  eer_entry..{...a
    │ │ │ -00075980: 6464 7265 7373 5f76 343a 3a62 7974 6573  ddress_v4::bytes
    │ │ │ -00075990: 5f74 7970 6520 6970 3b0a 0909 7374 643a  _type ip;...std:
    │ │ │ -000759a0: 3a75 696e 7431 365f 7420 706f 7274 3b0a  :uint16_t port;.
    │ │ │ -000759b0: 097d 3b0a 0a09 7374 7275 6374 2069 7076  .};...struct ipv
    │ │ │ -000759c0: 365f 7065 6572 5f65 6e74 7279 0a09 7b0a  6_peer_entry..{.
    │ │ │ -000759d0: 0909 6164 6472 6573 735f 7636 3a3a 6279  ..address_v6::by
    │ │ │ -000759e0: 7465 735f 7479 7065 2069 703b 0a09 0973  tes_type ip;...s
    │ │ │ -000759f0: 7464 3a3a 7569 6e74 3136 5f74 2070 6f72  td::uint16_t por
    │ │ │ -00075a00: 743b 0a09 7d3b 0a0a 2369 6620 544f 5252  t;..};..#if TORR
    │ │ │ -00075a10: 454e 545f 5553 455f 4932 500a 3c64 6976  ENT_USE_I2P.
    .struc │ │ │ -00075a50: 7420 6932 705f 7065 6572 5f65 6e74 7279 t i2p_peer_entry │ │ │ -00075a60: 0a3c 2f64 6976 3e09 7b0a 0909 7368 6132 .
    .{...sha2 │ │ │ -00075a70: 3536 5f68 6173 6820 6465 7374 696e 6174 56_hash destinat │ │ │ -00075a80: 696f 6e3b 0a09 7d3b 0a23 656e 6469 660a ion;..};.#endif. │ │ │ -00075a90: 7d0a 0a23 656e 6469 6620 2f2f 2054 4f52 }..#endif // TOR │ │ │ -00075aa0: 5245 4e54 5f50 4545 525f 4850 505f 494e RENT_PEER_HPP_IN │ │ │ -00075ab0: 434c 5544 4544 0a3c 2f70 7265 3e3c 2f74 CLUDED.
    relevanc │ │ │ -00075af0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -00075b30: 746f 7272 656e 742f 6175 785f 2f73 6573 torrent/aux_/ses │ │ │ -00075b40: 7369 6f6e 5f69 6d70 6c2e 6870 703a 3234 sion_impl.hpp:24 │ │ │ -00075b50: 333c 2f61 3e3c 2f74 643e 3c74 643e 6d61 3ma │ │ │ -00075b60: 6b65 2074 6865 7365 2064 6972 6563 7420 ke these direct │ │ │ -00075b70: 6d65 6d62 6572 7320 616e 6420 6765 6e65 members and gene │ │ │ -00075b80: 7261 7465 2073 6861 7265 645f 7074 7273 rate shared_ptrs │ │ │ -00075b90: 2074 6f20 7468 656d 2077 6869 6368 2061 to them which a │ │ │ -00075ba0: 6c69 6173 2074 6865 206c 6973 7465 6e5f lias the listen_ │ │ │ -00075bb0: 736f 636b 6574 5f74 2073 6861 7265 645f socket_t shared_ │ │ │ -00075bc0: 7074 723c 2f74 643e 3c2f 7472 3e3c 7472 ptr

    make these dire │ │ │ -00075c20: 6374 206d 656d 6265 7273 2061 6e64 2067 ct members and g │ │ │ -00075c30: 656e 6572 6174 6520 7368 6172 6564 5f70 enerate shared_p │ │ │ -00075c40: 7472 7320 746f 2074 6865 6d0a 7768 6963 trs to them.whic │ │ │ -00075c50: 6820 616c 6961 7320 7468 6520 6c69 7374 h alias the list │ │ │ -00075c60: 656e 5f73 6f63 6b65 745f 7420 7368 6172 en_socket_t shar │ │ │ -00075c70: 6564 5f70 7472 3c2f 6832 3e3c 6834 3e2e ed_ptr

    . │ │ │ -00075c80: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00075c90: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ -00075ca0: 6e5f 696d 706c 2e68 7070 3a32 3433 3c2f n_impl.hpp:243
    ...
    │ │ │ -00075cf0: 6966 2028 7564 705f 736f 636b 2920 7265  if (udp_sock) re
    │ │ │ -00075d00: 7475 726e 2075 6470 5f73 6f63 6b2d 2667  turn udp_sock-&g
    │ │ │ -00075d10: 743b 736f 636b 2e6c 6f63 616c 5f70 6f72  t;sock.local_por
    │ │ │ -00075d20: 7428 293b 0a09 0909 7265 7475 726e 2030  t();....return 0
    │ │ │ -00075d30: 3b0a 0909 7d0a 0a09 092f 2f20 3020 6973  ;...}....// 0 is
    │ │ │ -00075d40: 206e 6174 706d 7020 3120 6973 2075 706e   natpmp 1 is upn
    │ │ │ -00075d50: 700a 0909 2f2f 2074 6865 206f 7264 6572  p...// the order
    │ │ │ -00075d60: 206f 6620 7468 6573 6520 6172 7261 7973   of these arrays
    │ │ │ -00075d70: 2064 6574 6572 6d69 6e65 7320 7468 6520   determines the 
    │ │ │ -00075d80: 7072 696f 7269 7479 2069 6e0a 0909 2f2f  priority in...//
    │ │ │ -00075d90: 2077 6869 6368 2074 6865 6972 2070 6f72   which their por
    │ │ │ -00075da0: 7473 2077 696c 6c20 6265 2061 6e6e 6f75  ts will be annou
    │ │ │ -00075db0: 6e63 6564 2074 6f20 7065 6572 730a 0909  nced to peers...
    │ │ │ -00075dc0: 6175 783a 3a61 7272 6179 266c 743b 6c69  aux::array<li
    │ │ │ -00075dd0: 7374 656e 5f70 6f72 745f 6d61 7070 696e  sten_port_mappin
    │ │ │ -00075de0: 672c 2032 2c20 706f 7274 6d61 705f 7472  g, 2, portmap_tr
    │ │ │ -00075df0: 616e 7370 6f72 7426 6774 3b20 7463 705f  ansport> tcp_
    │ │ │ -00075e00: 706f 7274 5f6d 6170 7069 6e67 3b0a 0909  port_mapping;...
    │ │ │ -00075e10: 6175 783a 3a61 7272 6179 266c 743b 6c69  aux::array<li
    │ │ │ -00075e20: 7374 656e 5f70 6f72 745f 6d61 7070 696e  sten_port_mappin
    │ │ │ -00075e30: 672c 2032 2c20 706f 7274 6d61 705f 7472  g, 2, portmap_tr
    │ │ │ -00075e40: 616e 7370 6f72 7426 6774 3b20 7564 705f  ansport> udp_
    │ │ │ -00075e50: 706f 7274 5f6d 6170 7069 6e67 3b0a 0a09  port_mapping;...
    │ │ │ -00075e60: 092f 2f20 696e 6469 6361 7465 7320 7768  .// indicates wh
    │ │ │ -00075e70: 6574 6865 7220 7468 6973 2069 7320 616e  ether this is an
    │ │ │ -00075e80: 2053 534c 206c 6973 7465 6e20 736f 636b   SSL listen sock
    │ │ │ -00075e90: 6574 206f 7220 6e6f 740a 0909 7472 616e  et or not...tran
    │ │ │ -00075ea0: 7370 6f72 7420 7373 6c20 3d20 7472 616e  sport ssl = tran
    │ │ │ -00075eb0: 7370 6f72 743a 3a70 6c61 696e 7465 7874  sport::plaintext
    │ │ │ -00075ec0: 3b0a 0a09 096c 6973 7465 6e5f 736f 636b  ;....listen_sock
    │ │ │ -00075ed0: 6574 5f66 6c61 6773 5f74 2066 6c61 6773  et_flags_t flags
    │ │ │ -00075ee0: 203d 2061 6363 6570 745f 696e 636f 6d69   = accept_incomi
    │ │ │ -00075ef0: 6e67 3b0a 0a09 092f 2f20 7468 6520 6163  ng;....// the ac
    │ │ │ -00075f00: 7475 616c 2073 6f63 6b65 7473 2028 5443  tual sockets (TC
    │ │ │ -00075f10: 5020 6c69 7374 656e 2073 6f63 6b65 7420  P listen socket 
    │ │ │ -00075f20: 616e 6420 5544 5020 736f 636b 6574 290a  and UDP socket).
    │ │ │ -00075f30: 0909 2f2f 2041 6e20 656e 7472 7920 646f  ..// An entry do
    │ │ │ -00075f40: 6573 206e 6f74 206e 6563 6573 7361 7269  es not necessari
    │ │ │ -00075f50: 6c79 2068 6176 6520 6120 5544 5020 6f72  ly have a UDP or
    │ │ │ -00075f60: 2054 4350 2073 6f63 6b65 742e 204f 6e65   TCP socket. One
    │ │ │ -00075f70: 206f 6620 7468 6573 650a 0909 2f2f 2070   of these...// p
    │ │ │ -00075f80: 6f69 6e74 6572 7320 6d61 7920 6265 206e  ointers may be n
    │ │ │ -00075f90: 756c 6c70 7472 210a 0909 2f2f 2054 6865  ullptr!...// The
    │ │ │ -00075fa0: 7365 206d 7573 7420 6265 2073 6861 7265  se must be share
    │ │ │ -00075fb0: 645f 7074 7220 746f 2061 766f 6964 2061  d_ptr to avoid a
    │ │ │ -00075fc0: 2064 616e 676c 696e 6720 7265 6665 7265   dangling refere
    │ │ │ -00075fd0: 6e63 6520 6966 2061 6e0a 0909 2f2f 2069  nce if an...// i
    │ │ │ -00075fe0: 6e63 6f6d 696e 6720 7061 636b 6574 2069  ncoming packet i
    │ │ │ -00075ff0: 7320 696e 2074 6865 2065 7665 6e74 2071  s in the event q
    │ │ │ -00076000: 7565 7565 2077 6865 6e20 7468 6520 736f  ueue when the so
    │ │ │ -00076010: 636b 6574 2069 7320 6572 6173 6564 0a3c  cket is erased.<
    │ │ │ -00076020: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00076030: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00076040: 7769 6474 683d 2231 3030 2522 3e09 0973  width="100%">..s
    │ │ │ -00076050: 7464 3a3a 7368 6172 6564 5f70 7472 266c  td::shared_ptr&l
    │ │ │ -00076060: 743b 7463 703a 3a61 6363 6570 746f 7226  t;tcp::acceptor&
    │ │ │ -00076070: 6774 3b20 736f 636b 3b0a 3c2f 6469 763e  gt; sock;.

    │ │ │ -00076080: 0909 7374 643a 3a73 6861 7265 645f 7074 ..std::shared_pt │ │ │ -00076090: 7226 6c74 3b61 7578 3a3a 7365 7373 696f r<aux::sessio │ │ │ -000760a0: 6e5f 7564 705f 736f 636b 6574 2667 743b n_udp_socket> │ │ │ -000760b0: 2075 6470 5f73 6f63 6b3b 0a0a 0909 2f2f udp_sock;....// │ │ │ -000760c0: 2073 696e 6365 2075 6470 2070 6163 6b65 since udp packe │ │ │ -000760d0: 7473 2061 7265 2065 7870 6563 7465 6420 ts are expected │ │ │ -000760e0: 746f 2062 6520 6469 7370 6174 6368 6564 to be dispatched │ │ │ -000760f0: 2066 7265 7175 656e 746c 792c 2074 6869 frequently, thi │ │ │ -00076100: 7320 7361 7665 730a 0909 2f2f 2074 696d s saves...// tim │ │ │ -00076110: 6520 6f6e 2068 616e 646c 6572 2061 6c6c e on handler all │ │ │ -00076120: 6f63 6174 696f 6e20 6576 6572 7920 7469 ocation every ti │ │ │ -00076130: 6d65 2077 6520 7265 6164 2061 6761 696e me we read again │ │ │ -00076140: 2e0a 0909 6175 783a 3a68 616e 646c 6572 ....aux::handler │ │ │ -00076150: 5f73 746f 7261 6765 266c 743b 6175 783a _storage<aux: │ │ │ -00076160: 3a75 6470 5f68 616e 646c 6572 5f6d 6178 :udp_handler_max │ │ │ -00076170: 5f73 697a 652c 2061 7578 3a3a 7564 705f _size, aux::udp_ │ │ │ -00076180: 6861 6e64 6c65 7226 6774 3b20 7564 705f handler> udp_ │ │ │ -00076190: 6861 6e64 6c65 725f 7374 6f72 6167 653b handler_storage; │ │ │ -000761a0: 0a0a 0909 7374 643a 3a73 6861 7265 645f ....std::shared_ │ │ │ -000761b0: 7074 7226 6c74 3b6e 6174 706d 7026 6774 ptr<natpmp> │ │ │ -000761c0: 3b20 6e61 7470 6d70 5f6d 6170 7065 723b ; natpmp_mapper; │ │ │ -000761d0: 0a09 0973 7464 3a3a 7368 6172 6564 5f70 ...std::shared_p │ │ │ -000761e0: 7472 266c 743b 7570 6e70 2667 743b 2075 tr<upnp> u │ │ │ -000761f0: 706e 705f 6d61 7070 6572 3b0a 0a09 0973 pnp_mapper;....s │ │ │ -00076200: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ -00076210: 743b 7374 7275 6374 206c 7364 2667 743b t;struct lsd> │ │ │ -00076220: 206c 7364 3b0a 0a09 092f 2f20 7365 7420 lsd;....// set │ │ │ -00076230: 746f 2074 7275 6520 7768 656e 2077 6520 to true when we │ │ │ -00076240: 7265 6365 6976 6520 616e 2069 6e63 6f6d receive an incom │ │ │ -00076250: 696e 6720 636f 6e6e 6563 7469 6f6e 2066 ing connection f │ │ │ -00076260: 726f 6d20 7468 6973 206c 6973 7465 6e0a rom this listen. │ │ │ -00076270: 0909 2f2f 2073 6f63 6b65 740a 0909 626f ..// socket...bo │ │ │ -00076280: 6f6c 2069 6e63 6f6d 696e 675f 636f 6e6e ol incoming_conn │ │ │ -00076290: 6563 7469 6f6e 203d 2066 616c 7365 3b0a ection = false;. │ │ │ -000762a0: 0a09 7072 6976 6174 653a 0a09 092f 2f20 ..private:...// │ │ │ -000762b0: 6e6f 6e2d 6174 6f6d 6963 2069 7320 6669 non-atomic is fi │ │ │ -000762c0: 6e65 3a20 6c69 7374 656e 5f73 6f63 6b65 ne: listen_socke │ │ │ -000762d0: 745f 7420 6973 206f 6e6c 7920 6576 6572 t_t is only ever │ │ │ -000762e0: 2063 6f6e 7374 7275 6374 6564 206f 6e0a constructed on. │ │ │ -000762f0: 0909 2f2f 2074 6865 206e 6574 776f 726b ..// the network │ │ │ -00076300: 2074 6872 6561 642e 0a09 0973 7461 7469 thread....stati │ │ │ -00076310: 6320 7374 643a 3a75 696e 7433 325f 7420 c std::uint32_t │ │ │ -00076320: 6e65 7874 5f69 6428 290a 0909 7b0a 0909 next_id()...{... │ │ │ -00076330: 0973 7461 7469 6320 7374 643a 3a75 696e .static std::uin │ │ │ -00076340: 7433 325f 7420 6e65 7874 203d 2030 3b0a t32_t next = 0;. │ │ │ -00076350: 0909 0972 6574 7572 6e20 2b2b 6e65 7874 ...return ++next │ │ │ -00076360: 3b0a 0909 7d0a 097d 3b0a 0a09 0973 7472 ;...}..};....str │ │ │ -00076370: 7563 7420 544f 5252 454e 545f 4558 5452 uct TORRENT_EXTR │ │ │ -00076380: 415f 4558 504f 5254 206c 6973 7465 6e5f A_EXPORT listen_ │ │ │ -00076390: 656e 6470 6f69 6e74 5f74 0a09 097b 0a09 endpoint_t...{.. │ │ │ -000763a0: 0909 6c69 7374 656e 5f65 6e64 706f 696e ..listen_endpoin │ │ │ -000763b0: 745f 7428 6164 6472 6573 7320 636f 6e73 t_t(address cons │ │ │ -000763c0: 7426 616d 703b 2061 6472 2c20 696e 7420 t& adr, int │ │ │ -000763d0: 702c 2073 7464 3a3a 7374 7269 6e67 2064 p, std::string d │ │ │ -000763e0: 6576 2c20 7472 616e 7370 6f72 7420 730a ev, transport s. │ │ │ -000763f0: 0909 0909 2c20 6c69 7374 656e 5f73 6f63 ...., listen_soc │ │ │ -00076400: 6b65 745f 666c 6167 735f 7420 662c 2061 ket_flags_t f, a │ │ │ -00076410: 6464 7265 7373 2063 6f6e 7374 2661 6d70 ddress const& │ │ │ -00076420: 3b20 6e6d 6173 6b20 3d20 6164 6472 6573 ; nmask = addres │ │ │ -00076430: 737b 7d29 0a09 0909 093a 2061 6464 7228 s{}).....: addr( │ │ │ -00076440: 6164 7229 2c20 6e65 746d 6173 6b28 6e6d adr), netmask(nm │ │ │ -00076450: 6173 6b29 2c20 706f 7274 2870 292c 2064 ask), port(p), d │ │ │ -00076460: 6576 6963 6528 7374 643a 3a6d 6f76 6528 evice(std::move( │ │ │ -00076470: 6465 7629 292c 2073 736c 2873 292c 2066 dev)), ssl(s), f │ │ │ -00076480: 6c61 6773 2866 2920 7b7d 0a3c 2f70 7265 lags(f) {}.rele │ │ │ -000764c0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -00076500: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -00076510: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6870 /session_impl.hp │ │ │ -00076520: 703a 3131 3032 3c2f 613e 3c2f 7464 3e3c p:1102< │ │ │ -00076530: 7464 3e72 6570 6c61 6365 2074 6869 7320 td>replace this │ │ │ -00076540: 6279 2061 2070 726f 7065 7220 6173 696f by a proper asio │ │ │ -00076550: 2074 696d 6572 3c2f 7464 3e3c 2f74 723e timer │ │ │ -00076560: 3c74 7220 6964 3d22 3237 3022 2073 7479 │ │ │ -00076590: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000765a0: 3c68 323e 7265 706c 6163 6520 7468 6973

    replace this │ │ │ -000765b0: 2062 7920 6120 7072 6f70 6572 2061 7369 by a proper asi │ │ │ -000765c0: 6f20 7469 6d65 723c 2f68 323e 3c68 343e o timer

    │ │ │ -000765d0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -000765e0: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ -000765f0: 6f6e 5f69 6d70 6c2e 6870 703a 3131 3032 on_impl.hpp:1102 │ │ │ -00076600: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ -00076640: 6966 6465 6620 544f 5252 454e 545f 5353  ifdef TORRENT_SS
    │ │ │ -00076650: 4c5f 5045 4552 530a 0909 0976 6f69 6420  L_PEERS....void 
    │ │ │ -00076660: 6f6e 5f69 6e63 6f6d 696e 675f 7574 705f  on_incoming_utp_
    │ │ │ -00076670: 7373 6c28 736f 636b 6574 5f74 7970 6520  ssl(socket_type 
    │ │ │ -00076680: 7329 3b0a 0909 0976 6f69 6420 7373 6c5f  s);....void ssl_
    │ │ │ -00076690: 6861 6e64 7368 616b 6528 6572 726f 725f  handshake(error_
    │ │ │ -000766a0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20  code const& 
    │ │ │ -000766b0: 6563 2c20 736f 636b 6574 5f74 7970 652a  ec, socket_type*
    │ │ │ -000766c0: 2073 293b 0a23 656e 6469 660a 0a09 0909   s);.#endif.....
    │ │ │ -000766d0: 2f2f 2072 6f75 6e64 2d72 6f62 696e 2069  // round-robin i
    │ │ │ -000766e0: 6e64 6578 2069 6e74 6f20 6d5f 6f75 7467  ndex into m_outg
    │ │ │ -000766f0: 6f69 6e67 5f69 6e74 6572 6661 6365 730a  oing_interfaces.
    │ │ │ -00076700: 0909 096d 7574 6162 6c65 2073 7464 3a3a  ...mutable std::
    │ │ │ -00076710: 7569 6e74 385f 7420 6d5f 696e 7465 7266  uint8_t m_interf
    │ │ │ -00076720: 6163 655f 696e 6465 7820 3d20 303b 0a0a  ace_index = 0;..
    │ │ │ -00076730: 0909 0973 7464 3a3a 7368 6172 6564 5f70  ...std::shared_p
    │ │ │ -00076740: 7472 266c 743b 6c69 7374 656e 5f73 6f63  tr<listen_soc
    │ │ │ -00076750: 6b65 745f 7426 6774 3b20 7365 7475 705f  ket_t> setup_
    │ │ │ -00076760: 6c69 7374 656e 6572 280a 0909 0909 6c69  listener(.....li
    │ │ │ -00076770: 7374 656e 5f65 6e64 706f 696e 745f 7420  sten_endpoint_t 
    │ │ │ -00076780: 636f 6e73 7426 616d 703b 206c 6570 2c20  const& lep, 
    │ │ │ -00076790: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ -000767a0: 6563 293b 0a0a 2369 666e 6465 6620 544f  ec);..#ifndef TO
    │ │ │ -000767b0: 5252 454e 545f 4449 5341 424c 455f 4448  RRENT_DISABLE_DH
    │ │ │ -000767c0: 540a 0909 0964 6874 3a3a 6468 745f 7374  T....dht::dht_st
    │ │ │ -000767d0: 6174 6520 6d5f 6468 745f 7374 6174 653b  ate m_dht_state;
    │ │ │ -000767e0: 0a23 656e 6469 660a 0a09 0909 2f2f 2074  .#endif.....// t
    │ │ │ -000767f0: 6869 7320 6973 2069 6e69 7469 616c 697a  his is initializ
    │ │ │ -00076800: 6564 2074 6f20 7468 6520 756e 6368 6f6b  ed to the unchok
    │ │ │ -00076810: 655f 696e 7465 7276 616c 0a09 0909 2f2f  e_interval....//
    │ │ │ -00076820: 2073 6573 7369 6f6e 5f73 6574 7469 6e67   session_setting
    │ │ │ -00076830: 2061 6e64 2064 6563 7265 6173 6564 2065   and decreased e
    │ │ │ -00076840: 7665 7279 2073 6563 6f6e 642e 0a09 0909  very second.....
    │ │ │ -00076850: 2f2f 2077 6865 6e20 6974 2072 6561 6368  // when it reach
    │ │ │ -00076860: 6573 207a 6572 6f2c 2069 7420 6973 2072  es zero, it is r
    │ │ │ -00076870: 6573 6574 2074 6f20 7468 650a 0909 092f  eset to the..../
    │ │ │ -00076880: 2f20 756e 6368 6f6b 655f 696e 7465 7276  / unchoke_interv
    │ │ │ -00076890: 616c 2061 6e64 2074 6865 2075 6e63 686f  al and the uncho
    │ │ │ -000768a0: 6b65 2073 6574 2069 730a 0909 092f 2f20  ke set is....// 
    │ │ │ -000768b0: 7265 636f 6d70 7574 6564 2e0a 3c64 6976  recomputed..
    ...int │ │ │ -000768f0: 206d 5f75 6e63 686f 6b65 5f74 696d 655f m_unchoke_time_ │ │ │ -00076900: 7363 616c 6572 203d 2030 3b0a 3c2f 6469 scaler = 0;.....// this is │ │ │ -00076920: 2075 7365 6420 746f 2064 6563 6964 6520 used to decide │ │ │ -00076930: 7768 656e 2074 6f20 7265 6361 6c63 756c when to recalcul │ │ │ -00076940: 6174 6520 7768 6963 680a 0909 092f 2f20 ate which....// │ │ │ -00076950: 746f 7272 656e 7473 2074 6f20 6b65 6570 torrents to keep │ │ │ -00076960: 2071 7565 7565 6420 616e 6420 7768 6963 queued and whic │ │ │ -00076970: 6820 746f 2061 6374 6976 6174 650a 3c2f h to activate.r │ │ │ -000769b0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -000769c0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -000769f0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00076a00: 7578 5f2f 7365 7373 696f 6e5f 696d 706c ux_/session_impl │ │ │ -00076a10: 2e68 7070 3a31 3130 373c 2f61 3e3c 2f74 .hpp:1107replace th │ │ │ -00076a30: 6973 2062 7920 6120 7072 6f70 6572 2061 is by a proper a │ │ │ -00076a40: 7369 6f20 7469 6d65 723c 2f74 643e 3c2f sio timer

    replace t │ │ │ -00076aa0: 6869 7320 6279 2061 2070 726f 7065 7220 his by a proper │ │ │ -00076ab0: 6173 696f 2074 696d 6572 3c2f 6832 3e3c asio timer

    < │ │ │ -00076ac0: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -00076ad0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ -00076ae0: 7373 696f 6e5f 696d 706c 2e68 7070 3a31 ssion_impl.hpp:1 │ │ │ -00076af0: 3130 373c 2f68 343e 3c70 7265 2073 7479 107
    ....// round-r
    │ │ │ -00076b40: 6f62 696e 2069 6e64 6578 2069 6e74 6f20  obin index into 
    │ │ │ -00076b50: 6d5f 6f75 7467 6f69 6e67 5f69 6e74 6572  m_outgoing_inter
    │ │ │ -00076b60: 6661 6365 730a 0909 096d 7574 6162 6c65  faces....mutable
    │ │ │ -00076b70: 2073 7464 3a3a 7569 6e74 385f 7420 6d5f   std::uint8_t m_
    │ │ │ -00076b80: 696e 7465 7266 6163 655f 696e 6465 7820  interface_index 
    │ │ │ -00076b90: 3d20 303b 0a0a 0909 0973 7464 3a3a 7368  = 0;.....std::sh
    │ │ │ -00076ba0: 6172 6564 5f70 7472 266c 743b 6c69 7374  ared_ptr<list
    │ │ │ -00076bb0: 656e 5f73 6f63 6b65 745f 7426 6774 3b20  en_socket_t> 
    │ │ │ -00076bc0: 7365 7475 705f 6c69 7374 656e 6572 280a  setup_listener(.
    │ │ │ -00076bd0: 0909 0909 6c69 7374 656e 5f65 6e64 706f  ....listen_endpo
    │ │ │ -00076be0: 696e 745f 7420 636f 6e73 7426 616d 703b  int_t const&
    │ │ │ -00076bf0: 206c 6570 2c20 6572 726f 725f 636f 6465   lep, error_code
    │ │ │ -00076c00: 2661 6d70 3b20 6563 293b 0a0a 2369 666e  & ec);..#ifn
    │ │ │ -00076c10: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -00076c20: 424c 455f 4448 540a 0909 0964 6874 3a3a  BLE_DHT....dht::
    │ │ │ -00076c30: 6468 745f 7374 6174 6520 6d5f 6468 745f  dht_state m_dht_
    │ │ │ -00076c40: 7374 6174 653b 0a23 656e 6469 660a 0a09  state;.#endif...
    │ │ │ -00076c50: 0909 2f2f 2074 6869 7320 6973 2069 6e69  ..// this is ini
    │ │ │ -00076c60: 7469 616c 697a 6564 2074 6f20 7468 6520  tialized to the 
    │ │ │ -00076c70: 756e 6368 6f6b 655f 696e 7465 7276 616c  unchoke_interval
    │ │ │ -00076c80: 0a09 0909 2f2f 2073 6573 7369 6f6e 5f73  ....// session_s
    │ │ │ -00076c90: 6574 7469 6e67 2061 6e64 2064 6563 7265  etting and decre
    │ │ │ -00076ca0: 6173 6564 2065 7665 7279 2073 6563 6f6e  ased every secon
    │ │ │ -00076cb0: 642e 0a09 0909 2f2f 2077 6865 6e20 6974  d.....// when it
    │ │ │ -00076cc0: 2072 6561 6368 6573 207a 6572 6f2c 2069   reaches zero, i
    │ │ │ -00076cd0: 7420 6973 2072 6573 6574 2074 6f20 7468  t is reset to th
    │ │ │ -00076ce0: 650a 0909 092f 2f20 756e 6368 6f6b 655f  e....// unchoke_
    │ │ │ -00076cf0: 696e 7465 7276 616c 2061 6e64 2074 6865  interval and the
    │ │ │ -00076d00: 2075 6e63 686f 6b65 2073 6574 2069 730a   unchoke set is.
    │ │ │ -00076d10: 0909 092f 2f20 7265 636f 6d70 7574 6564  ...// recomputed
    │ │ │ -00076d20: 2e0a 0909 0969 6e74 206d 5f75 6e63 686f  .....int m_uncho
    │ │ │ -00076d30: 6b65 5f74 696d 655f 7363 616c 6572 203d  ke_time_scaler =
    │ │ │ -00076d40: 2030 3b0a 0a09 0909 2f2f 2074 6869 7320   0;.....// this 
    │ │ │ -00076d50: 6973 2075 7365 6420 746f 2064 6563 6964  is used to decid
    │ │ │ -00076d60: 6520 7768 656e 2074 6f20 7265 6361 6c63  e when to recalc
    │ │ │ -00076d70: 756c 6174 6520 7768 6963 680a 0909 092f  ulate which..../
    │ │ │ -00076d80: 2f20 746f 7272 656e 7473 2074 6f20 6b65  / torrents to ke
    │ │ │ -00076d90: 6570 2071 7565 7565 6420 616e 6420 7768  ep queued and wh
    │ │ │ -00076da0: 6963 6820 746f 2061 6374 6976 6174 650a  ich to activate.
    │ │ │ -00076db0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -00076de0: 0969 6e74 206d 5f61 7574 6f5f 6d61 6e61 .int m_auto_mana │ │ │ -00076df0: 6765 5f74 696d 655f 7363 616c 6572 203d ge_time_scaler = │ │ │ -00076e00: 2030 3b0a 3c2f 6469 763e 0a09 0909 2f2f 0;.
    ....// │ │ │ -00076e10: 2077 6f72 6b73 206c 696b 6520 756e 6368 works like unch │ │ │ -00076e20: 6f6b 655f 7469 6d65 5f73 6361 6c65 7220 oke_time_scaler │ │ │ -00076e30: 6275 7420 6974 0a09 0909 2f2f 2069 7320 but it....// is │ │ │ -00076e40: 6f6e 6c79 2064 6563 7265 6173 6564 2077 only decreased w │ │ │ -00076e50: 6865 6e20 7468 6520 756e 6368 6f6b 6520 hen the unchoke │ │ │ -00076e60: 7365 740a 0909 092f 2f20 6973 2072 6563 set....// is rec │ │ │ -00076e70: 6f6d 7075 7465 642c 2061 6e64 2077 6865 omputed, and whe │ │ │ -00076e80: 6e20 6974 2072 6561 6368 6573 207a 6572 n it reaches zer │ │ │ -00076e90: 6f2c 0a09 0909 2f2f 2074 6865 206f 7074 o,....// the opt │ │ │ -00076ea0: 696d 6973 7469 6320 756e 6368 6f6b 6520 imistic unchoke │ │ │ -00076eb0: 6973 206d 6f76 6564 2074 6f20 616e 6f74 is moved to anot │ │ │ -00076ec0: 6865 7220 7065 6572 2e0a 3c2f 7072 653e her peer..
    │ │ │ -00076ed0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00076f00: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00076f10: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -00076f40: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00076f50: 7365 7373 696f 6e5f 696d 706c 2e68 7070 session_impl.hpp │ │ │ -00076f60: 3a31 3131 343c 2f61 3e3c 2f74 643e 3c74 :1114replace this b │ │ │ -00076f80: 7920 6120 7072 6f70 6572 2061 7369 6f20 y a proper asio │ │ │ -00076f90: 7469 6d65 723c 2f74 643e 3c2f 7472 3e3c timer< │ │ │ -00076fa0: 7472 2069 643d 2232 3732 2220 7374 796c tr id="272" styl │ │ │ -00076fb0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00076fc0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00076fd0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00076fe0: 6832 3e72 6570 6c61 6365 2074 6869 7320 h2>replace this │ │ │ -00076ff0: 6279 2061 2070 726f 7065 7220 6173 696f by a proper asio │ │ │ -00077000: 2074 696d 6572 3c2f 6832 3e3c 6834 3e2e timer

    . │ │ │ -00077010: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00077020: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ -00077030: 6e5f 696d 706c 2e68 7070 3a31 3131 343c n_impl.hpp:1114< │ │ │ -00077040: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .#
    │ │ │ -00077080: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -00077090: 4953 4142 4c45 5f44 4854 0a09 0909 6468  ISABLE_DHT....dh
    │ │ │ -000770a0: 743a 3a64 6874 5f73 7461 7465 206d 5f64  t::dht_state m_d
    │ │ │ -000770b0: 6874 5f73 7461 7465 3b0a 2365 6e64 6966  ht_state;.#endif
    │ │ │ -000770c0: 0a0a 0909 092f 2f20 7468 6973 2069 7320  .....// this is 
    │ │ │ -000770d0: 696e 6974 6961 6c69 7a65 6420 746f 2074  initialized to t
    │ │ │ -000770e0: 6865 2075 6e63 686f 6b65 5f69 6e74 6572  he unchoke_inter
    │ │ │ -000770f0: 7661 6c0a 0909 092f 2f20 7365 7373 696f  val....// sessio
    │ │ │ -00077100: 6e5f 7365 7474 696e 6720 616e 6420 6465  n_setting and de
    │ │ │ -00077110: 6372 6561 7365 6420 6576 6572 7920 7365  creased every se
    │ │ │ -00077120: 636f 6e64 2e0a 0909 092f 2f20 7768 656e  cond.....// when
    │ │ │ -00077130: 2069 7420 7265 6163 6865 7320 7a65 726f   it reaches zero
    │ │ │ -00077140: 2c20 6974 2069 7320 7265 7365 7420 746f  , it is reset to
    │ │ │ -00077150: 2074 6865 0a09 0909 2f2f 2075 6e63 686f   the....// uncho
    │ │ │ -00077160: 6b65 5f69 6e74 6572 7661 6c20 616e 6420  ke_interval and 
    │ │ │ -00077170: 7468 6520 756e 6368 6f6b 6520 7365 7420  the unchoke set 
    │ │ │ -00077180: 6973 0a09 0909 2f2f 2072 6563 6f6d 7075  is....// recompu
    │ │ │ -00077190: 7465 642e 0a09 0909 696e 7420 6d5f 756e  ted.....int m_un
    │ │ │ -000771a0: 6368 6f6b 655f 7469 6d65 5f73 6361 6c65  choke_time_scale
    │ │ │ -000771b0: 7220 3d20 303b 0a0a 0909 092f 2f20 7468  r = 0;.....// th
    │ │ │ -000771c0: 6973 2069 7320 7573 6564 2074 6f20 6465  is is used to de
    │ │ │ -000771d0: 6369 6465 2077 6865 6e20 746f 2072 6563  cide when to rec
    │ │ │ -000771e0: 616c 6375 6c61 7465 2077 6869 6368 0a09  alculate which..
    │ │ │ -000771f0: 0909 2f2f 2074 6f72 7265 6e74 7320 746f  ..// torrents to
    │ │ │ -00077200: 206b 6565 7020 7175 6575 6564 2061 6e64   keep queued and
    │ │ │ -00077210: 2077 6869 6368 2074 6f20 6163 7469 7661   which to activa
    │ │ │ -00077220: 7465 0a09 0909 696e 7420 6d5f 6175 746f  te....int m_auto
    │ │ │ -00077230: 5f6d 616e 6167 655f 7469 6d65 5f73 6361  _manage_time_sca
    │ │ │ -00077240: 6c65 7220 3d20 303b 0a0a 0909 092f 2f20  ler = 0;.....// 
    │ │ │ -00077250: 776f 726b 7320 6c69 6b65 2075 6e63 686f  works like uncho
    │ │ │ -00077260: 6b65 5f74 696d 655f 7363 616c 6572 2062  ke_time_scaler b
    │ │ │ -00077270: 7574 2069 740a 0909 092f 2f20 6973 206f  ut it....// is o
    │ │ │ -00077280: 6e6c 7920 6465 6372 6561 7365 6420 7768  nly decreased wh
    │ │ │ -00077290: 656e 2074 6865 2075 6e63 686f 6b65 2073  en the unchoke s
    │ │ │ -000772a0: 6574 0a09 0909 2f2f 2069 7320 7265 636f  et....// is reco
    │ │ │ -000772b0: 6d70 7574 6564 2c20 616e 6420 7768 656e  mputed, and when
    │ │ │ -000772c0: 2069 7420 7265 6163 6865 7320 7a65 726f   it reaches zero
    │ │ │ -000772d0: 2c0a 0909 092f 2f20 7468 6520 6f70 7469  ,....// the opti
    │ │ │ -000772e0: 6d69 7374 6963 2075 6e63 686f 6b65 2069  mistic unchoke i
    │ │ │ -000772f0: 7320 6d6f 7665 6420 746f 2061 6e6f 7468  s moved to anoth
    │ │ │ -00077300: 6572 2070 6565 722e 0a3c 6469 7620 7374  er peer..
    ...int m_ │ │ │ -00077340: 6f70 7469 6d69 7374 6963 5f75 6e63 686f optimistic_uncho │ │ │ -00077350: 6b65 5f74 696d 655f 7363 616c 6572 203d ke_time_scaler = │ │ │ -00077360: 2030 3b0a 3c2f 6469 763e 0a09 0909 2f2f 0;.
    ....// │ │ │ -00077370: 2077 6f72 6b73 206c 696b 6520 756e 6368 works like unch │ │ │ -00077380: 6f6b 655f 7469 6d65 5f73 6361 6c65 722e oke_time_scaler. │ │ │ -00077390: 2045 6163 6820 7469 6d65 0a09 0909 2f2f Each time....// │ │ │ -000773a0: 2069 7420 7265 6163 6865 7320 302c 2061 it reaches 0, a │ │ │ -000773b0: 6e64 2061 6c6c 2074 6865 2063 6f6e 6e65 nd all the conne │ │ │ -000773c0: 6374 696f 6e73 2061 7265 0a09 0909 2f2f ctions are....// │ │ │ -000773d0: 2075 7365 642c 2074 6865 2077 6f72 7374 used, the worst │ │ │ -000773e0: 2063 6f6e 6e65 6374 696f 6e20 7769 6c6c connection will │ │ │ -000773f0: 2062 6520 6469 7363 6f6e 6e65 6374 6564 be disconnected │ │ │ -00077400: 0a09 0909 2f2f 2066 726f 6d20 7468 6520 ....// from the │ │ │ -00077410: 746f 7272 656e 7420 7769 7468 2074 6865 torrent with the │ │ │ -00077420: 206d 6f73 7420 7065 6572 730a 0909 0969 most peers....i │ │ │ -00077430: 6e74 206d 5f64 6973 636f 6e6e 6563 745f nt m_disconnect_ │ │ │ -00077440: 7469 6d65 5f73 6361 6c65 7220 3d20 3930 time_scaler = 90 │ │ │ -00077450: 3b0a 0a09 0909 2f2f 2077 6865 6e20 7468 ;.....// when th │ │ │ -00077460: 6973 2073 6361 6c65 7220 7265 6163 6865 is scaler reache │ │ │ -00077470: 7320 7a65 726f 2c20 6974 2077 696c 6c0a s zero, it will. │ │ │ -00077480: 0909 092f 2f20 7363 7261 7065 206f 6e65 ...// scrape one │ │ │ -00077490: 206f 6620 7468 6520 6175 746f 206d 616e of the auto man │ │ │ -000774a0: 6167 6564 2c20 7061 7573 6564 2c0a 0909 aged, paused,... │ │ │ -000774b0: 092f 2f20 746f 7272 656e 7473 2e0a 0909 .// torrents.... │ │ │ -000774c0: 0969 6e74 206d 5f61 7574 6f5f 7363 7261 .int m_auto_scra │ │ │ -000774d0: 7065 5f74 696d 655f 7363 616c 6572 203d pe_time_scaler = │ │ │ -000774e0: 2031 3830 3b0a 0a09 0909 2f2f 2073 7461 180;.....// sta │ │ │ -000774f0: 7469 7374 6963 7320 6761 7468 6572 6564 tistics gathered │ │ │ -00077500: 2066 726f 6d20 616c 6c20 746f 7272 656e from all torren │ │ │ -00077510: 7473 2e0a 0909 0973 7461 7420 6d5f 7374 ts.....stat m_st │ │ │ -00077520: 6174 3b0a 0a09 0909 2f2f 2069 6d70 6c65 at;.....// imple │ │ │ -00077530: 6d65 6e74 7320 7365 7373 696f 6e5f 696e ments session_in │ │ │ -00077540: 7465 7266 6163 650a 0909 0976 6f69 6420 terface....void │ │ │ -00077550: 7365 6e74 5f62 7974 6573 2869 6e74 2062 sent_bytes(int b │ │ │ -00077560: 7974 6573 5f70 6179 6c6f 6164 2c20 696e ytes_payload, in │ │ │ -00077570: 7420 6279 7465 735f 7072 6f74 6f63 6f6c t bytes_protocol │ │ │ -00077580: 2920 6f76 6572 7269 6465 3b0a 0909 0976 ) override;....v │ │ │ -00077590: 6f69 6420 7265 6365 6976 6564 5f62 7974 oid received_byt │ │ │ -000775a0: 6573 2869 6e74 2062 7974 6573 5f70 6179 es(int bytes_pay │ │ │ -000775b0: 6c6f 6164 2c20 696e 7420 6279 7465 735f load, int bytes_ │ │ │ -000775c0: 7072 6f74 6f63 6f6c 2920 6f76 6572 7269 protocol) overri │ │ │ -000775d0: 6465 3b0a 0909 0976 6f69 6420 7472 616e de;....void tran │ │ │ -000775e0: 6369 6576 655f 6970 5f70 6163 6b65 7428 cieve_ip_packet( │ │ │ -000775f0: 696e 7420 6279 7465 732c 2062 6f6f 6c20 int bytes, bool │ │ │ -00077600: 6970 7636 2920 6f76 6572 7269 6465 3b0a ipv6) override;. │ │ │ -00077610: 0909 0976 6f69 6420 7365 6e74 5f73 796e ...void sent_syn │ │ │ -00077620: 2862 6f6f 6c20 6970 7636 2920 6f76 6572 (bool ipv6) over │ │ │ -00077630: 7269 6465 3b0a 0909 0976 6f69 6420 7265 ride;....void re │ │ │ -00077640: 6365 6976 6564 5f73 796e 6163 6b28 626f ceived_synack(bo │ │ │ -00077650: 6f6c 2069 7076 3629 206f 7665 7272 6964 ol ipv6) overrid │ │ │ -00077660: 653b 0a0a 2369 6620 544f 5252 454e 545f e;..#if TORRENT_ │ │ │ -00077670: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ -00077680: 0a09 0909 696e 7420 6d5f 7065 616b 5f75 ....int m_peak_u │ │ │ -00077690: 705f 7261 7465 203d 2030 3b0a 2365 6e64 p_rate = 0;.#end │ │ │ -000776a0: 6966 0a0a 0909 0976 6f69 6420 6f6e 5f74 if.....void on_t │ │ │ -000776b0: 6963 6b28 6572 726f 725f 636f 6465 2063 ick(error_code c │ │ │ -000776c0: 6f6e 7374 2661 6d70 3b20 6529 3b0a 0a09 onst& e);... │ │ │ -000776d0: 0909 766f 6964 2074 7279 5f63 6f6e 6e65 ..void try_conne │ │ │ -000776e0: 6374 5f6d 6f72 655f 7065 6572 7328 293b ct_more_peers(); │ │ │ -000776f0: 0a09 0909 766f 6964 2061 7574 6f5f 6d61 ....void auto_ma │ │ │ -00077700: 6e61 6765 5f63 6865 636b 696e 675f 746f nage_checking_to │ │ │ -00077710: 7272 656e 7473 2873 7464 3a3a 7665 6374 rrents(std::vect │ │ │ -00077720: 6f72 266c 743b 746f 7272 656e 742a 2667 or<torrent*&g │ │ │ -00077730: 743b 2661 6d70 3b20 6c69 7374 0a3c 2f70 t;& list.

    re │ │ │ -00077770: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -000777b0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -000777c0: 785f 2f6d 6572 6b6c 655f 7472 6565 2e68 x_/merkle_tree.h │ │ │ -000777d0: 7070 3a36 323c 2f61 3e3c 2f74 643e 3c74 pp:62remove this co │ │ │ -000777f0: 6e73 7472 7563 746f 722e 2044 6f6e 2774 nstructor. Don't │ │ │ -00077800: 2073 7570 706f 7274 2022 756e 696e 6974 support "uninit │ │ │ -00077810: 6961 6c69 7a65 6422 2074 7265 6573 2e20 ialized" trees. │ │ │ -00077820: 5468 6973 2061 6c73 6f20 7265 7175 6972 This also requir │ │ │ -00077830: 6573 206e 6f74 2063 6f6e 7374 7275 6374 es not construct │ │ │ -00077840: 696e 6720 7468 6573 6520 666f 7220 7061 ing these for pa │ │ │ -00077850: 642d 6669 6c65 7320 616e 6420 736d 616c d-files and smal │ │ │ -00077860: 6c20 6669 6c65 7320 6173 2077 656c 6c2e l files as well. │ │ │ -00077870: 2053 6f2c 2061 2073 7061 7273 6520 6861 So, a sparse ha │ │ │ -00077880: 7368 206c 6973 7420 696e 2074 6f72 7265 sh list in torre │ │ │ -00077890: 6e74 5f69 6e66 6f3c 2f74 643e 3c2f 7472 nt_info

    remove this │ │ │ -000778f0: 2063 6f6e 7374 7275 6374 6f72 2e20 446f constructor. Do │ │ │ -00077900: 6e27 7420 7375 7070 6f72 7420 2275 6e69 n't support "uni │ │ │ -00077910: 6e69 7469 616c 697a 6564 2220 7472 6565 nitialized" tree │ │ │ -00077920: 732e 2054 6869 730a 616c 736f 2072 6571 s. This.also req │ │ │ -00077930: 7569 7265 7320 6e6f 7420 636f 6e73 7472 uires not constr │ │ │ -00077940: 7563 7469 6e67 2074 6865 7365 2066 6f72 ucting these for │ │ │ -00077950: 2070 6164 2d66 696c 6573 2061 6e64 2073 pad-files and s │ │ │ -00077960: 6d61 6c6c 2066 696c 6573 2061 730a 7765 mall files as.we │ │ │ -00077970: 6c6c 2e20 536f 2c20 6120 7370 6172 7365 ll. So, a sparse │ │ │ -00077980: 2068 6173 6820 6c69 7374 2069 6e20 746f hash list in to │ │ │ -00077990: 7272 656e 745f 696e 666f 3c2f 6832 3e3c rrent_info

    < │ │ │ -000779a0: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -000779b0: 6274 6f72 7265 6e74 2f61 7578 5f2f 6d65 btorrent/aux_/me │ │ │ -000779c0: 726b 6c65 5f74 7265 652e 6870 703a 3632 rkle_tree.hpp:62 │ │ │ -000779d0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    /
    │ │ │ -00077a10: 2f20 5468 6520 696e 7661 7269 616e 7420  / The invariant 
    │ │ │ -00077a20: 6f66 2074 6865 2074 7265 6520 6973 2074  of the tree is t
    │ │ │ -00077a30: 6861 7420 616c 6c20 696e 7465 7269 6f72  hat all interior
    │ │ │ -00077a40: 206e 6f64 6573 2028 692e 652e 2061 6c6c   nodes (i.e. all
    │ │ │ -00077a50: 2062 7574 2074 6865 2076 6572 790a 2f2f   but the very.//
    │ │ │ -00077a60: 2062 6f74 746f 6d20 6c65 6166 206e 6f64   bottom leaf nod
    │ │ │ -00077a70: 6573 2c20 7265 7072 6573 656e 7469 6e67  es, representing
    │ │ │ -00077a80: 2062 6c6f 636b 2068 6173 6865 7329 2061   block hashes) a
    │ │ │ -00077a90: 7265 2065 6974 6865 7220 7365 7420 616e  re either set an
    │ │ │ -00077aa0: 6420 7661 6c69 642c 206f 720a 2f2f 2063  d valid, or.// c
    │ │ │ -00077ab0: 6c65 6172 2e20 4e6f 2069 6e76 616c 6964  lear. No invalid
    │ │ │ -00077ac0: 2068 6173 6865 7320 6172 6520 616c 6c6f   hashes are allo
    │ │ │ -00077ad0: 7765 642c 2061 6e64 2074 6865 7920 6361  wed, and they ca
    │ │ │ -00077ae0: 6e20 6f6e 6c79 2062 6520 6164 6465 6420  n only be added 
    │ │ │ -00077af0: 6279 2061 6c73 6f0a 2f2f 2070 726f 7669  by also.// provi
    │ │ │ -00077b00: 6469 6e67 2070 726f 6f66 206f 6620 6265  ding proof of be
    │ │ │ -00077b10: 696e 6720 7661 6c69 642e 0a0a 2f2f 2054  ing valid...// T
    │ │ │ -00077b20: 6865 206c 6561 6620 626c 6f63 6b73 206f  he leaf blocks o
    │ │ │ -00077b30: 6e20 7468 6520 6f74 6865 7220 6861 6e64  n the other hand
    │ │ │ -00077b40: 2c20 4d41 5920 6265 2069 6e76 616c 6964  , MAY be invalid
    │ │ │ -00077b50: 2e20 466f 7220 696e 7374 616e 6365 2c20  . For instance, 
    │ │ │ -00077b60: 7768 656e 2061 6464 696e 670a 2f2f 2061  when adding.// a
    │ │ │ -00077b70: 206d 6167 6e65 7420 6c69 6e6b 2066 6f72   magnet link for
    │ │ │ -00077b80: 2061 2074 6f72 7265 6e74 2074 6861 7420   a torrent that 
    │ │ │ -00077b90: 7765 2061 6c72 6561 6479 2068 6176 6520  we already have 
    │ │ │ -00077ba0: 6669 6c65 7320 666f 722e 204f 6e63 6520  files for. Once 
    │ │ │ -00077bb0: 7765 2068 6176 6520 7468 650a 2f2f 206d  we have the.// m
    │ │ │ -00077bc0: 6574 6164 6174 612c 2077 6520 6861 7665  etadata, we have
    │ │ │ -00077bd0: 2066 696c 6573 206f 6e20 6469 736b 2062   files on disk b
    │ │ │ -00077be0: 7574 206e 6f20 6861 7368 6573 2e20 5765  ut no hashes. We
    │ │ │ -00077bf0: 2077 6f6e 2774 206b 6e6f 7720 7768 6574   won't know whet
    │ │ │ -00077c00: 6865 7220 7468 6520 6461 7461 0a2f 2f20  her the data.// 
    │ │ │ -00077c10: 6f6e 2064 6973 6b20 6973 2076 616c 6964  on disk is valid
    │ │ │ -00077c20: 206f 7220 6e6f 742c 2075 6e74 696c 2077   or not, until w
    │ │ │ -00077c30: 6527 7665 2064 6f77 6e6c 6f61 6465 6420  e've downloaded 
    │ │ │ -00077c40: 7468 6520 6861 7368 6573 2074 6f20 7661  the hashes to va
    │ │ │ -00077c50: 6c69 6461 7465 2074 6865 6d2e 0a0a 2f2f  lidate them...//
    │ │ │ -00077c60: 2049 6465 6120 666f 7220 6675 7475 7265   Idea for future
    │ │ │ -00077c70: 2073 7061 6365 206f 7074 696d 697a 6174   space optimizat
    │ │ │ -00077c80: 696f 6e3a 0a2f 2f20 7768 696c 6520 646f  ion:.// while do
    │ │ │ -00077c90: 776e 6c6f 6164 696e 672c 2077 6520 6e65  wnloading, we ne
    │ │ │ -00077ca0: 6564 2074 6f20 7374 6f72 6520 696e 7465  ed to store inte
    │ │ │ -00077cb0: 7269 6f72 206e 6f64 6573 206f 6620 7468  rior nodes of th
    │ │ │ -00077cc0: 6973 2074 7265 652e 2048 6f77 6576 6572  is tree. However
    │ │ │ -00077cd0: 2c20 7765 0a2f 2f20 646f 6e27 7420 6e65  , we.// don't ne
    │ │ │ -00077ce0: 6564 2074 6f20 7374 6f72 6520 7468 6520  ed to store the 
    │ │ │ -00077cf0: 7061 6464 696e 672e 2061 2053 4841 2d32  padding. a SHA-2
    │ │ │ -00077d00: 3536 2069 7320 3332 2062 7974 6573 2e20  56 is 32 bytes. 
    │ │ │ -00077d10: 496e 7374 6561 6420 6f66 2073 746f 7269  Instead of stori
    │ │ │ -00077d20: 6e67 0a2f 2f20 7468 6520 6675 6c6c 2028  ng.// the full (
    │ │ │ -00077d30: 7061 6464 6564 2920 7472 6565 206f 6620  padded) tree of 
    │ │ │ -00077d40: 5348 412d 3235 3620 6861 7368 6573 2c20  SHA-256 hashes, 
    │ │ │ -00077d50: 7374 6f72 6520 7468 6520 6675 6c6c 2074  store the full t
    │ │ │ -00077d60: 7265 6520 6f66 2033 3220 6269 740a 2f2f  ree of 32 bit.//
    │ │ │ -00077d70: 2073 6967 6e65 6420 696e 7465 6765 7273   signed integers
    │ │ │ -00077d80: 2c20 6265 696e 6720 696e 6469 6365 7320  , being indices 
    │ │ │ -00077d90: 696e 746f 2074 6865 2061 6374 7561 6c20  into the actual 
    │ │ │ -00077da0: 7374 6f72 6167 6520 666f 7220 7468 6520  storage for the 
    │ │ │ -00077db0: 7472 6565 2e20 5765 2063 6f75 6c64 0a2f  tree. We could./
    │ │ │ -00077dc0: 2f20 6576 656e 2067 726f 7720 7468 6520  / even grow the 
    │ │ │ -00077dd0: 7374 6f72 6167 6520 6c61 7a69 6c79 2e20  storage lazily. 
    │ │ │ -00077de0: 496e 7374 6561 6420 6f66 2073 746f 7269  Instead of stori
    │ │ │ -00077df0: 6e67 2074 6865 2070 6164 6469 6e67 2068  ng the padding h
    │ │ │ -00077e00: 6173 6865 732c 2075 7365 0a2f 2f20 6e65  ashes, use.// ne
    │ │ │ -00077e10: 6761 7469 7665 2069 6e64 6963 6573 2074  gative indices t
    │ │ │ -00077e20: 6f20 7265 6665 7220 746f 2066 6978 6564  o refer to fixed
    │ │ │ -00077e30: 2053 4841 2d32 3536 2830 292c 2061 6e64   SHA-256(0), and
    │ │ │ -00077e40: 2053 4841 2d32 3536 2853 4841 2d32 3536   SHA-256(SHA-256
    │ │ │ -00077e50: 2830 2929 2061 6e64 2073 6f0a 2f2f 206f  (0)) and so.// o
    │ │ │ -00077e60: 6e0a 7374 7275 6374 2054 4f52 5245 4e54  n.struct TORRENT
    │ │ │ -00077e70: 5f45 5854 5241 5f45 5850 4f52 5420 6d65  _EXTRA_EXPORT me
    │ │ │ -00077e80: 726b 6c65 5f74 7265 650a 7b0a 3c64 6976  rkle_tree.{.
    .merkl │ │ │ -00077ec0: 655f 7472 6565 2829 203d 2064 6566 6175 e_tree() = defau │ │ │ -00077ed0: 6c74 3b0a 3c2f 6469 763e 096d 6572 6b6c lt;.
    .merkl │ │ │ -00077ee0: 655f 7472 6565 2869 6e74 206e 756d 5f62 e_tree(int num_b │ │ │ -00077ef0: 6c6f 636b 732c 2069 6e74 2062 6c6f 636b locks, int block │ │ │ -00077f00: 735f 7065 725f 7069 6563 652c 2063 6861 s_per_piece, cha │ │ │ -00077f10: 7220 636f 6e73 742a 2072 293b 0a0a 0973 r const* r);...s │ │ │ -00077f20: 6861 3235 365f 6861 7368 2072 6f6f 7428 ha256_hash root( │ │ │ -00077f30: 2920 636f 6e73 743b 0a0a 0976 6f69 6420 ) const;...void │ │ │ -00077f40: 6c6f 6164 5f74 7265 6528 7370 616e 266c load_tree(span&l │ │ │ -00077f50: 743b 7368 6132 3536 5f68 6173 6820 636f t;sha256_hash co │ │ │ -00077f60: 6e73 7426 6774 3b20 742c 2062 6974 6669 nst> t, bitfi │ │ │ -00077f70: 656c 6420 636f 6e73 7426 616d 703b 2076 eld const& v │ │ │ -00077f80: 6572 6966 6965 6429 3b0a 0976 6f69 6420 erified);..void │ │ │ -00077f90: 6c6f 6164 5f73 7061 7273 655f 7472 6565 load_sparse_tree │ │ │ -00077fa0: 2873 7061 6e26 6c74 3b73 6861 3235 365f (span<sha256_ │ │ │ -00077fb0: 6861 7368 2063 6f6e 7374 2667 743b 2074 hash const> t │ │ │ -00077fc0: 2c20 6269 7466 6965 6c64 2063 6f6e 7374 , bitfield const │ │ │ -00077fd0: 2661 6d70 3b20 6d61 736b 0a09 092c 2062 & mask..., b │ │ │ -00077fe0: 6974 6669 656c 6420 636f 6e73 7426 616d itfield const&am │ │ │ -00077ff0: 703b 2076 6572 6966 6965 6429 3b0a 0976 p; verified);..v │ │ │ -00078000: 6f69 6420 6c6f 6164 5f76 6572 6966 6965 oid load_verifie │ │ │ -00078010: 645f 6269 7473 2862 6974 6669 656c 6420 d_bits(bitfield │ │ │ -00078020: 636f 6e73 7426 616d 703b 2076 6572 6966 const& verif │ │ │ -00078030: 6965 6429 3b0a 0a09 7374 643a 3a73 697a ied);...std::siz │ │ │ -00078040: 655f 7420 7369 7a65 2829 2063 6f6e 7374 e_t size() const │ │ │ -00078050: 3b0a 0969 6e74 2065 6e64 5f69 6e64 6578 ;..int end_index │ │ │ -00078060: 2829 2063 6f6e 7374 207b 2072 6574 7572 () const { retur │ │ │ -00078070: 6e20 696e 7428 7369 7a65 2829 293b 207d n int(size()); } │ │ │ -00078080: 0a0a 0962 6f6f 6c20 6861 735f 6e6f 6465 ...bool has_node │ │ │ -00078090: 2869 6e74 2069 6478 2920 636f 6e73 743b (int idx) const; │ │ │ -000780a0: 0a0a 0962 6f6f 6c20 636f 6d70 6172 655f ...bool compare_ │ │ │ -000780b0: 6e6f 6465 2869 6e74 2069 6478 2c20 7368 node(int idx, sh │ │ │ -000780c0: 6132 3536 5f68 6173 6820 636f 6e73 7426 a256_hash const& │ │ │ -000780d0: 616d 703b 2068 2920 636f 6e73 743b 0a0a amp; h) const;.. │ │ │ -000780e0: 0973 6861 3235 365f 6861 7368 206f 7065 .sha256_hash ope │ │ │ -000780f0: 7261 746f 725b 5d28 696e 7420 6964 7829 rator[](int idx) │ │ │ -00078100: 2063 6f6e 7374 3b0a 0a09 7374 643a 3a76 const;...std::v │ │ │ -00078110: 6563 746f 7226 6c74 3b73 6861 3235 365f ector<sha256_ │ │ │ -00078120: 6861 7368 2667 743b 2062 7569 6c64 5f76 hash> build_v │ │ │ -00078130: 6563 746f 7228 2920 636f 6e73 743b 0a09 ector() const;.. │ │ │ -00078140: 7374 643a 3a70 6169 7226 6c74 3b73 7464 std::pair<std │ │ │ -00078150: 3a3a 7665 6374 6f72 266c 743b 7368 6132 ::vector<sha2 │ │ │ -00078160: 3536 5f68 6173 6826 6774 3b2c 2062 6974 56_hash>, bit │ │ │ -00078170: 6669 656c 6426 6774 3b20 6275 696c 645f field> build_ │ │ │ -00078180: 7370 6172 7365 5f76 6563 746f 7228 2920 sparse_vector() │ │ │ -00078190: 636f 6e73 743b 0a0a 092f 2f20 6765 7420 const;...// get │ │ │ -000781a0: 6269 7473 2069 6e64 6963 6174 696e 6720 bits indicating │ │ │ -000781b0: 6966 2065 6163 6820 6c65 6166 2068 6173 if each leaf has │ │ │ -000781c0: 6820 6973 2076 6572 6966 6965 640a 0962 h is verified..b │ │ │ -000781d0: 6974 6669 656c 6420 7665 7269 6669 6564 itfield verified │ │ │ -000781e0: 5f6c 6561 6673 2829 2063 6f6e 7374 3b0a _leafs() const;. │ │ │ -000781f0: 0a09 2f2f 2072 6574 7572 6e73 2074 7275 ..// returns tru │ │ │ -00078200: 6520 6966 2074 6865 2065 6e74 6972 6520 e if the entire │ │ │ -00078210: 7472 6565 2069 7320 6b6e 6f77 6e20 616e tree is known an │ │ │ -00078220: 6420 7665 7269 6669 6564 0a09 626f 6f6c d verified..bool │ │ │ -00078230: 2069 735f 636f 6d70 6c65 7465 2829 2063 is_complete() c │ │ │ -00078240: 6f6e 7374 3b0a 0a09 2f2f 2072 6574 7572 onst;...// retur │ │ │ -00078250: 6e73 2074 7275 6520 6966 2061 6c6c 2062 ns true if all b │ │ │ -00078260: 6c6f 636b 2068 6173 6865 7320 696e 2074 lock hashes in t │ │ │ -00078270: 6865 2073 7065 6369 6669 6564 2072 616e he specified ran │ │ │ -00078280: 6765 2068 6176 6520 6265 656e 2076 6572 ge have been ver │ │ │ -00078290: 6966 6965 640a 0962 6f6f 6c20 626c 6f63 ified..bool bloc │ │ │ -000782a0: 6b73 5f76 6572 6966 6965 6428 696e 7420 ks_verified(int │ │ │ -000782b0: 626c 6f63 6b5f 6964 782c 2069 6e74 206e block_idx, int n │ │ │ -000782c0: 756d 5f62 6c6f 636b 7329 2063 6f6e 7374 um_blocks) const │ │ │ -000782d0: 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ;..
    │ │ │ -00078300: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00078310: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00078340: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00078350: 656e 742f 6175 785f 2f6d 6572 6b6c 655f ent/aux_/merkle_ │ │ │ -00078360: 7472 6565 2e68 7070 3a31 3532 3c2f 613e tree.hpp:152 │ │ │ -00078370: 3c2f 7464 3e3c 7464 3e6d 616b 6520 7468 make th │ │ │ -00078380: 6973 2061 2073 7464 3a3a 756e 6971 7565 is a std::unique │ │ │ -00078390: 5f70 7472 3c73 6861 3235 365f 6861 7368 _ptr

    make this a std │ │ │ -00078400: 3a3a 756e 6971 7565 5f70 7472 3c73 6861 ::unique_ptr

    │ │ │ -00078420: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00078430: 6962 746f 7272 656e 742f 6175 785f 2f6d ibtorrent/aux_/m │ │ │ -00078440: 6572 6b6c 655f 7472 6565 2e68 7070 3a31 erkle_tree.hpp:1 │ │ │ -00078450: 3532 3c2f 6834 3e3c 7072 6520 7374 796c 52

    ..int blocks_pe
    │ │ │ -000784a0: 725f 7069 6563 6528 2920 636f 6e73 7420  r_piece() const 
    │ │ │ -000784b0: 7b20 7265 7475 726e 2031 2026 6c74 3b26  { return 1 <&
    │ │ │ -000784c0: 6c74 3b20 6d5f 626c 6f63 6b73 5f70 6572  lt; m_blocks_per
    │ │ │ -000784d0: 5f70 6965 6365 5f6c 6f67 3b20 7d0a 092f  _piece_log; }../
    │ │ │ -000784e0: 2f20 7468 6520 6e75 6d62 6572 2074 7265  / the number tre
    │ │ │ -000784f0: 6520 6c65 7665 6c73 2070 6572 2070 6965  e levels per pie
    │ │ │ -00078500: 6365 2e20 5468 6973 2069 7320 3020 6966  ce. This is 0 if
    │ │ │ -00078510: 2074 6865 2062 6c6f 636b 206c 6179 6572   the block layer
    │ │ │ -00078520: 2069 7320 616c 736f 0a09 2f2f 2074 6865   is also..// the
    │ │ │ -00078530: 2070 6965 6365 206c 6179 6572 2e0a 0969   piece layer...i
    │ │ │ -00078540: 6e74 2070 6965 6365 5f6c 6576 656c 7328  nt piece_levels(
    │ │ │ -00078550: 2920 636f 6e73 7420 7b20 7265 7475 726e  ) const { return
    │ │ │ -00078560: 206d 5f62 6c6f 636b 735f 7065 725f 7069   m_blocks_per_pi
    │ │ │ -00078570: 6563 655f 6c6f 673b 207d 0a0a 0969 6e74  ece_log; }...int
    │ │ │ -00078580: 2062 6c6f 636b 5f6c 6179 6572 5f73 7461   block_layer_sta
    │ │ │ -00078590: 7274 2829 2063 6f6e 7374 3b0a 0969 6e74  rt() const;..int
    │ │ │ -000785a0: 2070 6965 6365 5f6c 6179 6572 5f73 7461   piece_layer_sta
    │ │ │ -000785b0: 7274 2829 2063 6f6e 7374 3b0a 0969 6e74  rt() const;..int
    │ │ │ -000785c0: 206e 756d 5f70 6965 6365 7328 2920 636f   num_pieces() co
    │ │ │ -000785d0: 6e73 743b 0a09 696e 7420 6e75 6d5f 6c65  nst;..int num_le
    │ │ │ -000785e0: 6166 7328 2920 636f 6e73 743b 0a0a 0976  afs() const;...v
    │ │ │ -000785f0: 6f69 6420 6f70 7469 6d69 7a65 5f73 746f  oid optimize_sto
    │ │ │ -00078600: 7261 6765 2829 3b0a 0976 6f69 6420 6f70  rage();..void op
    │ │ │ -00078610: 7469 6d69 7a65 5f73 746f 7261 6765 5f70  timize_storage_p
    │ │ │ -00078620: 6965 6365 5f6c 6179 6572 2829 3b0a 0976  iece_layer();..v
    │ │ │ -00078630: 6f69 6420 616c 6c6f 6361 7465 5f66 756c  oid allocate_ful
    │ │ │ -00078640: 6c28 293b 0a0a 092f 2f20 6120 706f 696e  l();...// a poin
    │ │ │ -00078650: 7465 7220 746f 2074 6865 2072 6f6f 7420  ter to the root 
    │ │ │ -00078660: 6861 7368 2066 6f72 2074 6869 7320 6669  hash for this fi
    │ │ │ -00078670: 6c65 2e0a 0963 6861 7220 636f 6e73 742a  le...char const*
    │ │ │ -00078680: 206d 5f72 6f6f 7420 3d20 6e75 6c6c 7074   m_root = nullpt
    │ │ │ -00078690: 723b 0a0a 092f 2f20 7468 6973 2069 7320  r;...// this is 
    │ │ │ -000786a0: 6569 7468 6572 2074 6865 2066 756c 6c20  either the full 
    │ │ │ -000786b0: 7472 6565 2c20 6f72 2073 6f6d 6520 7370  tree, or some sp
    │ │ │ -000786c0: 6172 7365 2072 6570 7265 7365 6e74 6174  arse representat
    │ │ │ -000786d0: 696f 6e20 6f66 2069 742c 0a09 2f2f 2064  ion of it,..// d
    │ │ │ -000786e0: 6570 656e 6469 6e67 206f 6e20 6d5f 6d6f  epending on m_mo
    │ │ │ -000786f0: 6465 0a3c 6469 7620 7374 796c 653d 2262  de.
    .aux::vector< │ │ │ -00078730: 3b73 6861 3235 365f 6861 7368 2667 743b ;sha256_hash> │ │ │ -00078740: 206d 5f74 7265 653b 0a3c 2f64 6976 3e0a m_tree;.
    . │ │ │ -00078750: 092f 2f20 7768 656e 2074 6865 2066 756c .// when the ful │ │ │ -00078760: 6c20 7472 6565 2069 7320 616c 6c6f 6361 l tree is alloca │ │ │ -00078770: 7465 642c 2074 6869 7320 6861 7320 6f6e ted, this has on │ │ │ -00078780: 6520 6269 7420 666f 7220 6561 6368 2062 e bit for each b │ │ │ -00078790: 6c6f 636b 2068 6173 682e 2061 0a09 2f2f lock hash. a..// │ │ │ -000787a0: 2031 206d 6561 6e73 2077 6520 6861 7665 1 means we have │ │ │ -000787b0: 2076 6572 6966 6965 6420 7468 6520 626c verified the bl │ │ │ -000787c0: 6f63 6b20 6861 7368 2074 6f20 6265 2063 ock hash to be c │ │ │ -000787d0: 6f72 7265 6374 2c20 6f74 6865 7277 6973 orrect, otherwis │ │ │ -000787e0: 6520 7468 6520 626c 6f63 6b0a 092f 2f20 e the block..// │ │ │ -000787f0: 6861 7368 206d 6179 2072 6570 7265 7365 hash may represe │ │ │ -00078800: 6e74 2077 6861 7427 7320 6f6e 2064 6973 nt what's on dis │ │ │ -00078810: 6b2c 2062 7574 2077 6520 6861 7665 6e27 k, but we haven' │ │ │ -00078820: 7420 6265 656e 2061 626c 6520 746f 2076 t been able to v │ │ │ -00078830: 6572 6966 7920 6974 0a09 2f2f 2079 6574 erify it..// yet │ │ │ -00078840: 0a09 6269 7466 6965 6c64 206d 5f62 6c6f ..bitfield m_blo │ │ │ -00078850: 636b 5f76 6572 6966 6965 643b 0a0a 092f ck_verified;.../ │ │ │ -00078860: 2f20 6e75 6d62 6572 206f 6620 626c 6f63 / number of bloc │ │ │ -00078870: 6b73 2069 6e20 7468 6520 6669 6c65 2074 ks in the file t │ │ │ -00078880: 6869 7320 7472 6565 2072 6570 7265 7365 his tree represe │ │ │ -00078890: 6e74 732e 2054 6865 206e 756d 6265 7220 nts. The number │ │ │ -000788a0: 6f66 206c 6561 6673 2069 6e0a 092f 2f20 of leafs in..// │ │ │ -000788b0: 7468 6520 7472 6565 2069 7320 726f 756e the tree is roun │ │ │ -000788c0: 6465 6420 7570 2074 6f20 616e 2065 7665 ded up to an eve │ │ │ -000788d0: 6e20 706f 7765 7220 6f66 2032 2e0a 0969 n power of 2...i │ │ │ -000788e0: 6e74 206d 5f6e 756d 5f62 6c6f 636b 7320 nt m_num_blocks │ │ │ -000788f0: 3d20 303b 0a0a 092f 2f20 7468 6520 6e75 = 0;...// the nu │ │ │ -00078900: 6d62 6572 206f 6620 626c 6f63 6b73 2070 mber of blocks p │ │ │ -00078910: 6572 2070 6965 6365 2c20 7370 6563 6966 er piece, specif │ │ │ -00078920: 6965 6420 6173 2068 6f77 206d 616e 7920 ied as how many │ │ │ -00078930: 7374 6570 7320 746f 2073 6869 6674 0a09 steps to shift.. │ │ │ -00078940: 2f2f 2072 6967 6874 2031 2074 6f20 6765 // right 1 to ge │ │ │ -00078950: 7420 7468 6520 6e75 6d62 6572 206f 6620 t the number of │ │ │ -00078960: 626c 6f63 6b73 2069 6e20 6f6e 6520 7069 blocks in one pi │ │ │ -00078970: 6563 652e 2054 6869 7320 6973 2061 2063 ece. This is a c │ │ │ -00078980: 6f6d 7061 6374 0a09 2f2f 2072 6570 7265 ompact..// repre │ │ │ -00078990: 7365 6e74 6174 696f 6e20 7468 6174 2773 sentation that's │ │ │ -000789a0: 2076 616c 6964 2062 6563 6175 7365 2070 valid because p │ │ │ -000789b0: 6965 6365 7320 6172 6520 616c 7761 7973 ieces are always │ │ │ -000789c0: 2070 6f77 6572 7320 6f66 2032 2e0a 092f powers of 2.../ │ │ │ -000789d0: 2f20 7468 6973 2069 7320 6e65 6365 7373 / this is necess │ │ │ -000789e0: 6172 7920 746f 206b 6e6f 7720 7768 6963 ary to know whic │ │ │ -000789f0: 6820 6c61 7965 7220 696e 2074 6865 2074 h layer in the t │ │ │ -00078a00: 7265 6520 7468 6520 7069 6563 6520 6c61 ree the piece la │ │ │ -00078a10: 7965 7220 6973 2e0a 0973 7464 3a3a 7569 yer is...std::ui │ │ │ -00078a20: 6e74 385f 7420 6d5f 626c 6f63 6b73 5f70 nt8_t m_blocks_p │ │ │ -00078a30: 6572 5f70 6965 6365 5f6c 6f67 203d 2030 er_piece_log = 0 │ │ │ -00078a40: 3b0a 0a09 656e 756d 2063 6c61 7373 206d ;...enum class m │ │ │ -00078a50: 6f64 655f 7420 3a20 7374 643a 3a75 696e ode_t : std::uin │ │ │ -00078a60: 7438 5f74 0a09 7b0a 0909 2f2f 2061 2064 t8_t..{...// a d │ │ │ -00078a70: 6566 6175 6c74 2063 6f6e 7374 7275 6374 efault construct │ │ │ -00078a80: 6564 2074 7265 6520 6973 2074 7275 6c79 ed tree is truly │ │ │ -00078a90: 2065 6d70 7479 2e20 4974 2064 6f65 7320 empty. It does │ │ │ -00078aa0: 6e6f 7420 6576 656e 2068 6176 6520 610a not even have a. │ │ │ -00078ab0: 0909 2f2f 2072 6f6f 7420 6861 7368 0a09 ..// root hash.. │ │ │ -00078ac0: 0975 6e69 6e69 7469 616c 697a 6564 5f74 .uninitialized_t │ │ │ -00078ad0: 7265 652c 0a0a 0909 2f2f 2077 6520 646f ree,....// we do │ │ │ -00078ae0: 6e27 7420 6861 7665 2061 6e79 2068 6173 n't have any has │ │ │ -00078af0: 6865 7320 696e 2074 6869 7320 7472 6565 hes in this tree │ │ │ -00078b00: 2e20 6d5f 7472 6565 2073 686f 756c 6420 . m_tree should │ │ │ -00078b10: 6265 2065 6d70 7479 0a09 092f 2f20 616e be empty...// an │ │ │ -00078b20: 2065 6d70 7479 2074 7265 6520 7374 696c empty tree stil │ │ │ -00078b30: 6c20 616c 7761 7973 2068 6176 6520 7468 l always have th │ │ │ -00078b40: 6520 726f 6f74 2068 6173 6820 2861 7661 e root hash (ava │ │ │ -00078b50: 696c 6162 6c65 2061 7320 726f 6f74 2829 ilable as root() │ │ │ -00078b60: 290a 0909 656d 7074 795f 7472 6565 2c0a )...empty_tree,. │ │ │ -00078b70: 0a09 092f 2f20 696e 2074 6869 7320 6d6f ...// in this mo │ │ │ -00078b80: 6465 2c20 6d5f 7472 6565 2072 6570 7265 de, m_tree repre │ │ │ -00078b90: 7365 6e74 7320 7468 6520 6675 6c6c 2074 sents the full t │ │ │ -00078ba0: 7265 652c 2069 6e63 6c75 6469 6e67 2070 ree, including p │ │ │ -00078bb0: 6164 6469 6e67 2e0a 0909 6675 6c6c 5f74 adding....full_t │ │ │ -00078bc0: 7265 652c 0a0a 3c2f 7072 653e 3c2f 7464 ree,..
    relevance │ │ │ -00078c00: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00078c10: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -00078c40: 6f72 7265 6e74 2f61 7578 5f2f 7265 6164 orrent/aux_/read │ │ │ -00078c50: 7772 6974 652e 6870 703a 3235 353c 2f61 write.hpp:255is it │ │ │ -00078c70: 7265 616c 6c79 206e 6563 6573 7361 7279 really necessary │ │ │ -00078c80: 2074 6f20 6d61 6b65 2074 776f 2063 6f70 to make two cop │ │ │ -00078c90: 6965 7320 6f66 2074 6865 2069 6f76 6563 ies of the iovec │ │ │ -00078ca0: 733f 2054 6865 206c 6f77 2d6c 6576 656c s? The low-level │ │ │ -00078cb0: 2073 7973 7465 6d20 6361 6c6c 2077 696c system call wil │ │ │ -00078cc0: 6c20 6e65 6564 2074 6f20 6d61 6b65 2069 l need to make i │ │ │ -00078cd0: 7473 206f 776e 2063 6f70 7920 6173 2077 ts own copy as w │ │ │ -00078ce0: 656c 6c3c 2f74 643e 3c2f 7472 3e3c 7472 ell

    is it really ne │ │ │ -00078d40: 6365 7373 6172 7920 746f 206d 616b 6520 cessary to make │ │ │ -00078d50: 7477 6f20 636f 7069 6573 206f 6620 7468 two copies of th │ │ │ -00078d60: 6520 696f 7665 6373 3f20 5468 6520 6c6f e iovecs? The lo │ │ │ -00078d70: 772d 6c65 7665 6c0a 7379 7374 656d 2063 w-level.system c │ │ │ -00078d80: 616c 6c20 7769 6c6c 206e 6565 6420 746f all will need to │ │ │ -00078d90: 206d 616b 6520 6974 7320 6f77 6e20 636f make its own co │ │ │ -00078da0: 7079 2061 7320 7765 6c6c 3c2f 6832 3e3c py as well

    < │ │ │ -00078db0: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -00078dc0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7265 btorrent/aux_/re │ │ │ -00078dd0: 6164 7772 6974 652e 6870 703a 3235 353c adwrite.hpp:255< │ │ │ -00078de0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .T
    │ │ │ -00078e20: 4f52 5245 4e54 5f41 5353 4552 5428 7374  ORRENT_ASSERT(st
    │ │ │ -00078e30: 6174 6963 5f63 6173 7426 6c74 3b69 6e74  atic_cast<int
    │ │ │ -00078e40: 2667 743b 2870 6965 6365 2920 2a20 7374  >(piece) * st
    │ │ │ -00078e50: 6174 6963 5f63 6173 7426 6c74 3b73 7464  atic_cast<std
    │ │ │ -00078e60: 3a3a 696e 7436 345f 7426 6774 3b28 6669  ::int64_t>(fi
    │ │ │ -00078e70: 6c65 732e 7069 6563 655f 6c65 6e67 7468  les.piece_length
    │ │ │ -00078e80: 2829 290a 0909 2b20 6f66 6673 6574 202b  ())...+ offset +
    │ │ │ -00078e90: 2073 697a 6520 266c 743b 3d20 6669 6c65   size <= file
    │ │ │ -00078ea0: 732e 746f 7461 6c5f 7369 7a65 2829 293b  s.total_size());
    │ │ │ -00078eb0: 0a0a 092f 2f20 6669 6e64 2074 6865 2066  ...// find the f
    │ │ │ -00078ec0: 696c 6520 6974 6572 6174 6f72 2061 6e64  ile iterator and
    │ │ │ -00078ed0: 2066 696c 6520 6f66 6673 6574 0a09 7374   file offset..st
    │ │ │ -00078ee0: 643a 3a69 6e74 3634 5f74 2063 6f6e 7374  d::int64_t const
    │ │ │ -00078ef0: 2074 6f72 7265 6e74 5f6f 6666 7365 7420   torrent_offset 
    │ │ │ -00078f00: 3d20 7374 6174 6963 5f63 6173 7426 6c74  = static_cast<
    │ │ │ -00078f10: 3b69 6e74 2667 743b 2870 6965 6365 2920  ;int>(piece) 
    │ │ │ -00078f20: 2a20 7374 643a 3a69 6e74 3634 5f74 2866  * std::int64_t(f
    │ │ │ -00078f30: 696c 6573 2e70 6965 6365 5f6c 656e 6774  iles.piece_lengt
    │ │ │ -00078f40: 6828 2929 202b 206f 6666 7365 743b 0a09  h()) + offset;..
    │ │ │ -00078f50: 6669 6c65 5f69 6e64 6578 5f74 2066 696c  file_index_t fil
    │ │ │ -00078f60: 655f 696e 6465 7820 3d20 6669 6c65 732e  e_index = files.
    │ │ │ -00078f70: 6669 6c65 5f69 6e64 6578 5f61 745f 6f66  file_index_at_of
    │ │ │ -00078f80: 6673 6574 2874 6f72 7265 6e74 5f6f 6666  fset(torrent_off
    │ │ │ -00078f90: 7365 7429 3b0a 0954 4f52 5245 4e54 5f41  set);..TORRENT_A
    │ │ │ -00078fa0: 5353 4552 5428 746f 7272 656e 745f 6f66  SSERT(torrent_of
    │ │ │ -00078fb0: 6673 6574 2026 6774 3b3d 2066 696c 6573  fset >= files
    │ │ │ -00078fc0: 2e66 696c 655f 6f66 6673 6574 2866 696c  .file_offset(fil
    │ │ │ -00078fd0: 655f 696e 6465 7829 293b 0a09 544f 5252  e_index));..TORR
    │ │ │ -00078fe0: 454e 545f 4153 5345 5254 2874 6f72 7265  ENT_ASSERT(torre
    │ │ │ -00078ff0: 6e74 5f6f 6666 7365 7420 266c 743b 2066  nt_offset < f
    │ │ │ -00079000: 696c 6573 2e66 696c 655f 6f66 6673 6574  iles.file_offset
    │ │ │ -00079010: 2866 696c 655f 696e 6465 7829 202b 2066  (file_index) + f
    │ │ │ -00079020: 696c 6573 2e66 696c 655f 7369 7a65 2866  iles.file_size(f
    │ │ │ -00079030: 696c 655f 696e 6465 7829 293b 0a09 7374  ile_index));..st
    │ │ │ -00079040: 643a 3a69 6e74 3634 5f74 2066 696c 655f  d::int64_t file_
    │ │ │ -00079050: 6f66 6673 6574 203d 2074 6f72 7265 6e74  offset = torrent
    │ │ │ -00079060: 5f6f 6666 7365 7420 2d20 6669 6c65 732e  _offset - files.
    │ │ │ -00079070: 6669 6c65 5f6f 6666 7365 7428 6669 6c65  file_offset(file
    │ │ │ -00079080: 5f69 6e64 6578 293b 0a0a 092f 2f20 7468  _index);...// th
    │ │ │ -00079090: 6520 6e75 6d62 6572 206f 6620 6279 7465  e number of byte
    │ │ │ -000790a0: 7320 6c65 6674 2062 6566 6f72 6520 7468  s left before th
    │ │ │ -000790b0: 6973 2072 6561 6420 6f72 2077 7269 7465  is read or write
    │ │ │ -000790c0: 206f 7065 7261 7469 6f6e 2069 730a 092f   operation is../
    │ │ │ -000790d0: 2f20 636f 6d70 6c65 7465 6c79 2073 6174  / completely sat
    │ │ │ -000790e0: 6973 6669 6564 2e0a 0969 6e74 2062 7974  isfied...int byt
    │ │ │ -000790f0: 6573 5f6c 6566 7420 3d20 7369 7a65 3b0a  es_left = size;.
    │ │ │ -00079100: 0a09 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -00079110: 2862 7974 6573 5f6c 6566 7420 2667 743b  (bytes_left >
    │ │ │ -00079120: 3d20 3029 3b0a 0a09 2f2f 2063 6f70 7920  = 0);...// copy 
    │ │ │ -00079130: 7468 6520 696f 7665 6320 6172 7261 7920  the iovec array 
    │ │ │ -00079140: 736f 2077 6520 6361 6e20 7573 6520 6974  so we can use it
    │ │ │ -00079150: 2074 6f20 6b65 6570 2074 7261 636b 206f   to keep track o
    │ │ │ -00079160: 6620 6f75 7220 6375 7272 656e 740a 092f  f our current../
    │ │ │ -00079170: 2f20 6c6f 6361 7469 6f6e 2062 7920 7570  / location by up
    │ │ │ -00079180: 6461 7469 6e67 2074 6865 2068 6561 6420  dating the head 
    │ │ │ -00079190: 6261 7365 2070 6f69 6e74 6572 2061 6e64  base pointer and
    │ │ │ -000791a0: 2073 697a 652e 2028 7365 650a 092f 2f20   size. (see..// 
    │ │ │ -000791b0: 6164 7661 6e63 655f 6275 6673 2829 290a  advance_bufs()).
    │ │ │ -000791c0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -000791f0: 544f 5252 454e 545f 414c 4c4f 4341 2863 TORRENT_ALLOCA(c │ │ │ -00079200: 7572 7265 6e74 5f62 7566 2c20 7370 616e urrent_buf, span │ │ │ -00079210: 266c 743b 4368 6172 2667 743b 2c20 6275 <Char>, bu │ │ │ -00079220: 6673 2e73 697a 6528 2929 3b0a 3c2f 6469 fs.size());..copy_bufs(buf │ │ │ -00079240: 732c 2073 697a 652c 2063 7572 7265 6e74 s, size, current │ │ │ -00079250: 5f62 7566 293b 0a09 544f 5252 454e 545f _buf);..TORRENT_ │ │ │ -00079260: 4153 5345 5254 2863 6f75 6e74 5f62 7566 ASSERT(count_buf │ │ │ -00079270: 7328 6375 7272 656e 745f 6275 662c 2073 s(current_buf, s │ │ │ -00079280: 697a 6529 203d 3d20 696e 7428 6275 6673 ize) == int(bufs │ │ │ -00079290: 2e73 697a 6528 2929 293b 0a0a 0954 4f52 .size()));...TOR │ │ │ -000792a0: 5245 4e54 5f41 4c4c 4f43 4128 746d 705f RENT_ALLOCA(tmp_ │ │ │ -000792b0: 6275 662c 2073 7061 6e26 6c74 3b43 6861 buf, span<Cha │ │ │ -000792c0: 7226 6774 3b2c 2062 7566 732e 7369 7a65 r>, bufs.size │ │ │ -000792d0: 2829 293b 0a09 7768 696c 6520 2862 7974 ());..while (byt │ │ │ -000792e0: 6573 5f6c 6566 7420 2667 743b 2030 290a es_left > 0). │ │ │ -000792f0: 097b 0a09 092f 2f20 7468 6520 6e75 6d62 .{...// the numb │ │ │ -00079300: 6572 206f 6620 6279 7465 7320 6c65 6674 er of bytes left │ │ │ -00079310: 2074 6f20 7265 6164 2069 6e20 7468 6520 to read in the │ │ │ -00079320: 6375 7272 656e 7420 6669 6c65 2028 7370 current file (sp │ │ │ -00079330: 6563 6966 6965 6420 6279 0a09 092f 2f20 ecified by...// │ │ │ -00079340: 6669 6c65 5f69 6e64 6578 292e 2054 6869 file_index). Thi │ │ │ -00079350: 7320 6973 2074 6865 206d 696e 696d 756d s is the minimum │ │ │ -00079360: 206f 6620 2866 696c 655f 7369 7a65 202d of (file_size - │ │ │ -00079370: 2066 696c 655f 6f66 6673 6574 2920 616e file_offset) an │ │ │ -00079380: 640a 0909 2f2f 2062 7974 6573 5f6c 6566 d...// bytes_lef │ │ │ -00079390: 742e 0a09 0969 6e74 2066 696c 655f 6279 t....int file_by │ │ │ -000793a0: 7465 735f 6c65 6674 203d 2062 7974 6573 tes_left = bytes │ │ │ -000793b0: 5f6c 6566 743b 0a09 0969 6620 2866 696c _left;...if (fil │ │ │ -000793c0: 655f 6f66 6673 6574 202b 2066 696c 655f e_offset + file_ │ │ │ -000793d0: 6279 7465 735f 6c65 6674 2026 6774 3b20 bytes_left > │ │ │ -000793e0: 6669 6c65 732e 6669 6c65 5f73 697a 6528 files.file_size( │ │ │ -000793f0: 6669 6c65 5f69 6e64 6578 2929 0a09 0909 file_index)).... │ │ │ -00079400: 6669 6c65 5f62 7974 6573 5f6c 6566 7420 file_bytes_left │ │ │ -00079410: 3d20 7374 643a 3a6d 6178 2873 7461 7469 = std::max(stati │ │ │ -00079420: 635f 6361 7374 266c 743b 696e 7426 6774 c_cast<int> │ │ │ -00079430: 3b28 6669 6c65 732e 6669 6c65 5f73 697a ;(files.file_siz │ │ │ -00079440: 6528 6669 6c65 5f69 6e64 6578 2920 2d20 e(file_index) - │ │ │ -00079450: 6669 6c65 5f6f 6666 7365 7429 2c20 3029 file_offset), 0) │ │ │ -00079460: 3b0a 0a09 092f 2f20 7468 6572 6520 6172 ;....// there ar │ │ │ -00079470: 6520 6e6f 2062 7974 6573 206c 6566 7420 e no bytes left │ │ │ -00079480: 696e 2074 6869 7320 6669 6c65 2c20 6d6f in this file, mo │ │ │ -00079490: 7665 2074 6f20 7468 6520 6e65 7874 206f ve to the next o │ │ │ -000794a0: 6e65 0a09 092f 2f20 7468 6973 206c 6f6f ne...// this loo │ │ │ -000794b0: 7020 736b 6970 7320 6f76 6572 2065 6d70 p skips over emp │ │ │ -000794c0: 7479 2066 696c 6573 0a09 0977 6869 6c65 ty files...while │ │ │ -000794d0: 2028 6669 6c65 5f62 7974 6573 5f6c 6566 (file_bytes_lef │ │ │ -000794e0: 7420 3d3d 2030 290a 0909 7b0a 0909 092b t == 0)...{....+ │ │ │ -000794f0: 2b66 696c 655f 696e 6465 783b 0a09 0909 +file_index;.... │ │ │ -00079500: 6669 6c65 5f6f 6666 7365 7420 3d20 303b file_offset = 0; │ │ │ -00079510: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -00079520: 5254 2866 696c 655f 696e 6465 7820 266c RT(file_index &l │ │ │ -00079530: 743b 2066 696c 6573 2e65 6e64 5f66 696c t; files.end_fil │ │ │ -00079540: 6528 2929 3b0a 0a09 0909 2f2f 2074 6869 e());.....// thi │ │ │ -00079550: 7320 7368 6f75 6c64 206e 6f74 2068 6170 s should not hap │ │ │ -00079560: 7065 6e2e 2062 7974 6573 5f6c 6566 7420 pen. bytes_left │ │ │ -00079570: 7368 6f75 6c64 2062 6520 636c 616d 7065 should be clampe │ │ │ -00079580: 6420 6279 2074 6865 2074 6f74 616c 0a09 d by the total.. │ │ │ -00079590: 0909 2f2f 2073 697a 6520 6f66 2074 6865 ..// size of the │ │ │ -000795a0: 2074 6f72 7265 6e74 2c20 736f 2077 6520 torrent, so we │ │ │ -000795b0: 7368 6f75 6c64 206e 6576 6572 2072 756e should never run │ │ │ -000795c0: 206f 6666 2074 6865 2065 6e64 206f 6620 off the end of │ │ │ -000795d0: 6974 0a09 0909 6966 2028 6669 6c65 5f69 it....if (file_i │ │ │ -000795e0: 6e64 6578 2026 6774 3b3d 2066 696c 6573 ndex >= files │ │ │ -000795f0: 2e65 6e64 5f66 696c 6528 2929 2072 6574 .end_file()) ret │ │ │ -00079600: 7572 6e20 7369 7a65 3b0a 0a09 0909 6669 urn size;.....fi │ │ │ -00079610: 6c65 5f62 7974 6573 5f6c 6566 7420 3d20 le_bytes_left = │ │ │ -00079620: 6279 7465 735f 6c65 6674 3b0a 0a09 0909 bytes_left;..... │ │ │ -00079630: 6966 2028 6669 6c65 5f6f 6666 7365 7420 if (file_offset │ │ │ -00079640: 2b20 6669 6c65 5f62 7974 6573 5f6c 6566 + file_bytes_lef │ │ │ -00079650: 7420 2667 743b 2066 696c 6573 2e66 696c t > files.fil │ │ │ -00079660: 655f 7369 7a65 2866 696c 655f 696e 6465 e_size(file_inde │ │ │ -00079670: 7829 290a 0909 0909 6669 6c65 5f62 7974 x)).....file_byt │ │ │ -00079680: 6573 5f6c 6566 7420 3d20 7374 643a 3a6d es_left = std::m │ │ │ -00079690: 6178 2873 7461 7469 635f 6361 7374 266c ax(static_cast&l │ │ │ -000796a0: 743b 696e 7426 6774 3b28 6669 6c65 732e t;int>(files. │ │ │ -000796b0: 6669 6c65 5f73 697a 6528 6669 6c65 5f69 file_size(file_i │ │ │ -000796c0: 6e64 6578 2920 2d20 6669 6c65 5f6f 6666 ndex) - file_off │ │ │ -000796d0: 7365 7429 2c20 3029 3b0a 0909 7d0a 3c2f set), 0);...}.r │ │ │ -00079710: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00079720: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00079750: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00079760: 7578 5f2f 6469 736b 5f69 6f5f 7468 7265 ux_/disk_io_thre │ │ │ -00079770: 6164 5f70 6f6f 6c2e 6870 703a 3330 3c2f ad_pool.hpp:30move │ │ │ -00079790: 696e 746f 2061 7578 206e 616d 6573 7061 into aux namespa │ │ │ -000797a0: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ -000797f0: 6d6f 7665 2069 6e74 6f20 6175 7820 6e61 move into aux na │ │ │ -00079800: 6d65 7370 6163 653c 2f68 323e 3c68 343e mespace

    │ │ │ -00079810: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00079820: 7272 656e 742f 6175 785f 2f64 6973 6b5f rrent/aux_/disk_ │ │ │ -00079830: 696f 5f74 6872 6561 645f 706f 6f6c 2e68 io_thread_pool.h │ │ │ -00079840: 7070 3a33 303c 2f68 343e 3c70 7265 2073 pp:30

    */..#ifndef 
    │ │ │ -00079890: 544f 5252 454e 545f 4449 534b 5f49 4f5f  TORRENT_DISK_IO_
    │ │ │ -000798a0: 5448 5245 4144 5f50 4f4f 4c0a 2364 6566  THREAD_POOL.#def
    │ │ │ -000798b0: 696e 6520 544f 5252 454e 545f 4449 534b  ine TORRENT_DISK
    │ │ │ -000798c0: 5f49 4f5f 5448 5245 4144 5f50 4f4f 4c0a  _IO_THREAD_POOL.
    │ │ │ -000798d0: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -000798e0: 7272 656e 742f 636f 6e66 6967 2e68 7070  rrent/config.hpp
    │ │ │ -000798f0: 220a 2369 6e63 6c75 6465 2022 6c69 6274  ".#include "libt
    │ │ │ -00079900: 6f72 7265 6e74 2f61 7578 5f2f 6578 706f  orrent/aux_/expo
    │ │ │ -00079910: 7274 2e68 7070 220a 2369 6e63 6c75 6465  rt.hpp".#include
    │ │ │ -00079920: 2022 6c69 6274 6f72 7265 6e74 2f61 7578   "libtorrent/aux
    │ │ │ -00079930: 5f2f 6465 6164 6c69 6e65 5f74 696d 6572  _/deadline_timer
    │ │ │ -00079940: 2e68 7070 220a 0a23 696e 636c 7564 6520  .hpp"..#include 
    │ │ │ -00079950: 226c 6962 746f 7272 656e 742f 6175 785f  "libtorrent/aux_
    │ │ │ -00079960: 2f64 6973 6b5f 6a6f 622e 6870 7022 0a23  /disk_job.hpp".#
    │ │ │ -00079970: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00079980: 656e 742f 6175 785f 2f64 6562 7567 2e68  ent/aux_/debug.h
    │ │ │ -00079990: 7070 220a 2369 6e63 6c75 6465 2022 6c69  pp".#include "li
    │ │ │ -000799a0: 6274 6f72 7265 6e74 2f69 6f5f 636f 6e74  btorrent/io_cont
    │ │ │ -000799b0: 6578 742e 6870 7022 0a23 696e 636c 7564  ext.hpp".#includ
    │ │ │ -000799c0: 6520 226c 6962 746f 7272 656e 742f 6572  e "libtorrent/er
    │ │ │ -000799d0: 726f 725f 636f 6465 2e68 7070 220a 0a23  ror_code.hpp"..#
    │ │ │ -000799e0: 696e 636c 7564 6520 266c 743b 7468 7265  include <thre
    │ │ │ -000799f0: 6164 2667 743b 0a23 696e 636c 7564 6520  ad>.#include 
    │ │ │ -00079a00: 266c 743b 6d75 7465 7826 6774 3b0a 2369  <mutex>.#i
    │ │ │ -00079a10: 6e63 6c75 6465 2026 6c74 3b61 746f 6d69  nclude <atomi
    │ │ │ -00079a20: 6326 6774 3b0a 2369 6e63 6c75 6465 2026  c>.#include &
    │ │ │ -00079a30: 6c74 3b63 6f6e 6469 7469 6f6e 5f76 6172  lt;condition_var
    │ │ │ -00079a40: 6961 626c 6526 6774 3b0a 0a6e 616d 6573  iable>..names
    │ │ │ -00079a50: 7061 6365 206c 6962 746f 7272 656e 7420  pace libtorrent 
    │ │ │ -00079a60: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261  {.
    │ │ │ -00079a90: 0975 7369 6e67 206a 6f62 7175 6575 655f .using jobqueue_ │ │ │ -00079aa0: 7420 3d20 6175 783a 3a74 6169 6c71 7565 t = aux::tailque │ │ │ -00079ab0: 7565 266c 743b 6175 783a 3a64 6973 6b5f ue<aux::disk_ │ │ │ -00079ac0: 6a6f 6226 6774 3b3b 0a3c 2f64 6976 3e7d job>;.
    } │ │ │ -00079ad0: 0a0a 6e61 6d65 7370 6163 6520 6c69 6274 ..namespace libt │ │ │ -00079ae0: 6f72 7265 6e74 3a3a 6175 7820 7b0a 0a09 orrent::aux {... │ │ │ -00079af0: 7374 7275 6374 2064 6973 6b5f 696f 5f74 struct disk_io_t │ │ │ -00079b00: 6872 6561 645f 706f 6f6c 3b0a 0a09 7573 hread_pool;...us │ │ │ -00079b10: 696e 6720 6469 736b 5f74 6872 6561 645f ing disk_thread_ │ │ │ -00079b20: 6675 6e20 3d20 7374 643a 3a66 756e 6374 fun = std::funct │ │ │ -00079b30: 696f 6e26 6c74 3b76 6f69 6428 0a09 0961 ion<void(...a │ │ │ -00079b40: 7578 3a3a 6469 736b 5f69 6f5f 7468 7265 ux::disk_io_thre │ │ │ -00079b50: 6164 5f70 6f6f 6c26 616d 703b 2c20 6578 ad_pool&, ex │ │ │ -00079b60: 6563 7574 6f72 5f77 6f72 6b5f 6775 6172 ecutor_work_guar │ │ │ -00079b70: 6426 6c74 3b69 6f5f 636f 6e74 6578 743a d<io_context: │ │ │ -00079b80: 3a65 7865 6375 746f 725f 7479 7065 2667 :executor_type&g │ │ │ -00079b90: 743b 2077 6f72 6b29 2667 743b 3b0a 0a09 t; work)>;... │ │ │ -00079ba0: 656e 756d 2063 6c61 7373 2077 6169 745f enum class wait_ │ │ │ -00079bb0: 7265 7375 6c74 3a20 7374 643a 3a75 696e result: std::uin │ │ │ -00079bc0: 7438 5f74 0a09 7b0a 0909 6e65 775f 6a6f t8_t..{...new_jo │ │ │ -00079bd0: 622c 0a09 0965 7869 745f 7468 7265 6164 b,...exit_thread │ │ │ -00079be0: 2c0a 0909 696e 7465 7272 7570 742c 0a09 ,...interrupt,.. │ │ │ -00079bf0: 7d3b 0a0a 092f 2f20 7468 6973 2063 6c61 };...// this cla │ │ │ -00079c00: 7373 2069 6d70 6c65 6d65 6e74 7320 7468 ss implements th │ │ │ -00079c10: 6520 706f 6c69 6379 2066 6f72 2063 7265 e policy for cre │ │ │ -00079c20: 6174 696e 6720 616e 6420 6465 7374 726f ating and destro │ │ │ -00079c30: 7969 6e67 2049 2f4f 2074 6872 6561 6473 ying I/O threads │ │ │ -00079c40: 0a09 2f2f 2074 6872 6561 6473 2061 7265 ..// threads are │ │ │ -00079c50: 2063 7265 6174 6564 2077 6865 6e20 6a6f created when jo │ │ │ -00079c60: 625f 7175 6575 6564 2069 7320 6361 6c6c b_queued is call │ │ │ -00079c70: 6564 2074 6f20 7369 676e 616c 2074 6865 ed to signal the │ │ │ -00079c80: 2061 7272 6976 616c 206f 660a 092f 2f20 arrival of..// │ │ │ -00079c90: 6e65 7720 6a6f 6273 0a09 2f2f 206f 6e63 new jobs..// onc │ │ │ -00079ca0: 6520 6120 6d69 6e75 7465 2074 6872 6561 e a minute threa │ │ │ -00079cb0: 6473 2061 7265 2064 6573 7472 6f79 6564 ds are destroyed │ │ │ -00079cc0: 2069 6620 6174 206c 6561 7374 206f 6e65 if at least one │ │ │ -00079cd0: 2074 6872 6561 6420 6861 7320 6265 656e thread has been │ │ │ -00079ce0: 0a09 2f2f 2069 646c 6520 666f 7220 7468 ..// idle for th │ │ │ -00079cf0: 6520 656e 7469 7265 206d 696e 7574 650a e entire minute. │ │ │ -00079d00: 092f 2f20 7468 6520 706f 6f6c 5f74 6872 .// the pool_thr │ │ │ -00079d10: 6561 645f 696e 7465 7266 6163 6520 6973 ead_interface is │ │ │ -00079d20: 2075 7365 6420 746f 2073 7061 776e 2061 used to spawn a │ │ │ -00079d30: 6e64 206e 6f74 6966 7920 7468 6520 776f nd notify the wo │ │ │ -00079d40: 726b 6572 2074 6872 6561 6473 0a09 7374 rker threads..st │ │ │ -00079d50: 7275 6374 2054 4f52 5245 4e54 5f45 5854 ruct TORRENT_EXT │ │ │ -00079d60: 5241 5f45 5850 4f52 5420 6469 736b 5f69 RA_EXPORT disk_i │ │ │ -00079d70: 6f5f 7468 7265 6164 5f70 6f6f 6c0a 097b o_thread_pool..{ │ │ │ -00079d80: 0a09 0964 6973 6b5f 696f 5f74 6872 6561 ...disk_io_threa │ │ │ -00079d90: 645f 706f 6f6c 2864 6973 6b5f 7468 7265 d_pool(disk_thre │ │ │ -00079da0: 6164 5f66 756e 2074 6872 6561 645f 6675 ad_fun thread_fu │ │ │ -00079db0: 6e2c 2069 6f5f 636f 6e74 6578 7426 616d n, io_context&am │ │ │ -00079dc0: 703b 2069 6f73 293b 0a09 097e 6469 736b p; ios);...~disk │ │ │ -00079dd0: 5f69 6f5f 7468 7265 6164 5f70 6f6f 6c28 _io_thread_pool( │ │ │ -00079de0: 293b 0a0a 0909 2f2f 2073 6574 2074 6865 );....// set the │ │ │ -00079df0: 206d 6178 696d 756d 206e 756d 6265 7220 maximum number │ │ │ -00079e00: 6f66 2049 2f4f 2074 6872 6561 6473 2077 of I/O threads w │ │ │ -00079e10: 6869 6368 206d 6179 2062 6520 7275 6e6e hich may be runn │ │ │ -00079e20: 696e 670a 0909 2f2f 2074 6865 2061 6374 ing...// the act │ │ │ -00079e30: 7561 6c20 6e75 6d62 6572 206f 6620 7468 ual number of th │ │ │ -00079e40: 7265 6164 7320 7769 6c6c 2062 6520 266c reads will be &l │ │ │ -00079e50: 743b 3d20 7468 6973 206e 756d 6265 720a t;= this number. │ │ │ -00079e60: 0909 766f 6964 2073 6574 5f6d 6178 5f74 ..void set_max_t │ │ │ -00079e70: 6872 6561 6473 2869 6e74 2069 293b 0a3c hreads(int i);.< │ │ │ -00079e80: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00079e90: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00079ea0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00079eb0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00079ec0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../inc │ │ │ -00079ef0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00079f00: 6175 785f 2f64 6973 6b5f 696f 5f74 6872 aux_/disk_io_thr │ │ │ -00079f10: 6561 645f 706f 6f6c 2e68 7070 3a31 3036 ead_pool.hpp:106 │ │ │ -00079f20: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6865 the │ │ │ -00079f30: 206a 6f62 206d 7574 6578 206d 7573 7420 job mutex must │ │ │ -00079f40: 6265 2068 656c 6420 7768 656e 2074 6869 be held when thi │ │ │ -00079f50: 7320 6973 2063 616c 6c65 643c 2f74 643e s is called │ │ │ -00079f60: 3c2f 7472 3e3c 7472 2069 643d 2232 3737

    the job │ │ │ -00079fb0: 206d 7574 6578 206d 7573 7420 6265 2068 mutex must be h │ │ │ -00079fc0: 656c 6420 7768 656e 2074 6869 7320 6973 eld when this is │ │ │ -00079fd0: 2063 616c 6c65 643c 2f68 323e 3c68 343e called

    │ │ │ -00079fe0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00079ff0: 7272 656e 742f 6175 785f 2f64 6973 6b5f rrent/aux_/disk_ │ │ │ -0007a000: 696f 5f74 6872 6561 645f 706f 6f6c 2e68 io_thread_pool.h │ │ │ -0007a010: 7070 3a31 3036 3c2f 6834 3e3c 7072 6520 pp:106

    ..// this i
    │ │ │ -0007a060: 7320 6120 7765 616b 2063 6865 636b 2c20  s a weak check, 
    │ │ │ -0007a070: 6966 2069 7420 7265 7475 726e 7320 7472  if it returns tr
    │ │ │ -0007a080: 7565 2074 7279 5f74 6872 6561 645f 6578  ue try_thread_ex
    │ │ │ -0007a090: 6974 206d 6179 2073 7469 6c6c 0a09 092f  it may still.../
    │ │ │ -0007a0a0: 2f20 7265 7475 726e 2066 616c 7365 0a09  / return false..
    │ │ │ -0007a0b0: 0962 6f6f 6c20 7368 6f75 6c64 5f65 7869  .bool should_exi
    │ │ │ -0007a0c0: 7428 2920 7b20 7265 7475 726e 206d 5f74  t() { return m_t
    │ │ │ -0007a0d0: 6872 6561 6473 5f74 6f5f 6578 6974 2026  hreads_to_exit &
    │ │ │ -0007a0e0: 6774 3b20 303b 207d 0a09 092f 2f20 7468  gt; 0; }...// th
    │ │ │ -0007a0f0: 6973 2073 686f 756c 6420 6265 2074 6865  is should be the
    │ │ │ -0007a100: 206c 6173 7420 6675 6e63 7469 6f6e 2061   last function a
    │ │ │ -0007a110: 6e20 492f 4f20 7468 7265 6164 2063 616c  n I/O thread cal
    │ │ │ -0007a120: 6c73 2062 6566 6f72 6520 6272 6561 6b69  ls before breaki
    │ │ │ -0007a130: 6e67 0a09 092f 2f20 6f75 7420 6f66 2069  ng...// out of i
    │ │ │ -0007a140: 7473 2073 6572 7669 6365 206c 6f6f 700a  ts service loop.
    │ │ │ -0007a150: 0909 2f2f 2069 6620 6974 2072 6574 7572  ..// if it retur
    │ │ │ -0007a160: 6e73 2074 7275 6520 7468 656e 2074 6865  ns true then the
    │ │ │ -0007a170: 2074 6872 6561 6420 4d55 5354 2065 7869   thread MUST exi
    │ │ │ -0007a180: 740a 0909 2f2f 2069 6620 6974 2072 6574  t...// if it ret
    │ │ │ -0007a190: 7572 6e73 2066 616c 7365 2074 6865 2074  urns false the t
    │ │ │ -0007a1a0: 6872 6561 6420 7368 6f75 6c64 206e 6f74  hread should not
    │ │ │ -0007a1b0: 2065 7869 740a 0909 626f 6f6c 2074 7279   exit...bool try
    │ │ │ -0007a1c0: 5f74 6872 6561 645f 6578 6974 2873 7464  _thread_exit(std
    │ │ │ -0007a1d0: 3a3a 7468 7265 6164 3a3a 6964 2069 6429  ::thread::id id)
    │ │ │ -0007a1e0: 3b0a 0a09 092f 2f20 6765 7420 7468 6520  ;....// get the 
    │ │ │ -0007a1f0: 7468 7265 6164 2069 6420 6f66 2074 6865  thread id of the
    │ │ │ -0007a200: 2066 6972 7374 2074 6872 6561 6420 696e   first thread in
    │ │ │ -0007a210: 2074 6865 2069 6e74 6572 6e61 6c20 7665   the internal ve
    │ │ │ -0007a220: 6374 6f72 0a09 092f 2f20 7369 6e63 6520  ctor...// since 
    │ │ │ -0007a230: 7468 6973 2069 7320 7468 6520 6669 7273  this is the firs
    │ │ │ -0007a240: 7420 7468 7265 6164 2069 7420 7769 6c6c  t thread it will
    │ │ │ -0007a250: 2072 656d 6169 6e20 7468 6520 7361 6d65   remain the same
    │ │ │ -0007a260: 2075 6e74 696c 2074 6865 2066 6972 7374   until the first
    │ │ │ -0007a270: 0a09 092f 2f20 7468 7265 6164 2065 7869  ...// thread exi
    │ │ │ -0007a280: 7473 0a09 092f 2f20 6974 2063 616e 2062  ts...// it can b
    │ │ │ -0007a290: 6520 7573 6564 2074 6f20 7472 6967 6765  e used to trigge
    │ │ │ -0007a2a0: 7220 6d61 696e 7465 6e61 6e63 6520 6a6f  r maintenance jo
    │ │ │ -0007a2b0: 6273 2077 6869 6368 2073 686f 756c 6420  bs which should 
    │ │ │ -0007a2c0: 6f6e 6c79 2072 756e 206f 6e20 6f6e 6520  only run on one 
    │ │ │ -0007a2d0: 7468 7265 6164 0a09 0973 7464 3a3a 7468  thread...std::th
    │ │ │ -0007a2e0: 7265 6164 3a3a 6964 2066 6972 7374 5f74  read::id first_t
    │ │ │ -0007a2f0: 6872 6561 645f 6964 2829 3b0a 0909 696e  hread_id();...in
    │ │ │ -0007a300: 7420 6e75 6d5f 7468 7265 6164 7328 290a  t num_threads().
    │ │ │ -0007a310: 0909 7b0a 0909 0973 7464 3a3a 6c6f 636b  ..{....std::lock
    │ │ │ -0007a320: 5f67 7561 7264 266c 743b 7374 643a 3a6d  _guard<std::m
    │ │ │ -0007a330: 7574 6578 2667 743b 206c 286d 5f6d 7574  utex> l(m_mut
    │ │ │ -0007a340: 6578 293b 0a09 0909 7265 7475 726e 2069  ex);....return i
    │ │ │ -0007a350: 6e74 286d 5f74 6872 6561 6473 2e73 697a  nt(m_threads.siz
    │ │ │ -0007a360: 6528 2929 3b0a 0909 7d0a 0a3c 6469 7620  e());...}..
    ..void │ │ │ -0007a3a0: 6170 7065 6e64 286a 6f62 7175 6575 655f append(jobqueue_ │ │ │ -0007a3b0: 7420 6a6f 6273 290a 3c2f 6469 763e 0909 t jobs).
    .. │ │ │ -0007a3c0: 7b0a 0909 096d 5f71 7565 7565 645f 6a6f {....m_queued_jo │ │ │ -0007a3d0: 6273 2e61 7070 656e 6428 7374 643a 3a6d bs.append(std::m │ │ │ -0007a3e0: 6f76 6528 6a6f 6273 2929 3b0a 0909 7d0a ove(jobs));...}. │ │ │ -0007a3f0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0007a430: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -0007a460: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007a470: 742f 6175 785f 2f64 6973 6b5f 696f 5f74 t/aux_/disk_io_t │ │ │ -0007a480: 6872 6561 645f 706f 6f6c 2e68 7070 3a31 hread_pool.hpp:1 │ │ │ -0007a490: 3132 3c2f 613e 3c2f 7464 3e3c 7464 3e74 12t │ │ │ -0007a4a0: 6865 206a 6f62 206d 7574 6578 206d 7573 he job mutex mus │ │ │ -0007a4b0: 7420 6265 2068 656c 6420 7768 656e 2074 t be held when t │ │ │ -0007a4c0: 6869 7320 6973 2063 616c 6c65 643c 2f74 his is called

    the j │ │ │ -0007a520: 6f62 206d 7574 6578 206d 7573 7420 6265 ob mutex must be │ │ │ -0007a530: 2068 656c 6420 7768 656e 2074 6869 7320 held when this │ │ │ -0007a540: 6973 2063 616c 6c65 643c 2f68 323e 3c68 is called

    ../include/lib │ │ │ -0007a560: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ -0007a570: 6b5f 696f 5f74 6872 6561 645f 706f 6f6c k_io_thread_pool │ │ │ -0007a580: 2e68 7070 3a31 3132 3c2f 6834 3e3c 7072 .hpp:112..// if i │ │ │ -0007a5d0: 7420 7265 7475 726e 7320 7472 7565 2074 t returns true t │ │ │ -0007a5e0: 6865 6e20 7468 6520 7468 7265 6164 204d hen the thread M │ │ │ -0007a5f0: 5553 5420 6578 6974 0a09 092f 2f20 6966 UST exit...// if │ │ │ -0007a600: 2069 7420 7265 7475 726e 7320 6661 6c73 it returns fals │ │ │ -0007a610: 6520 7468 6520 7468 7265 6164 2073 686f e the thread sho │ │ │ -0007a620: 756c 6420 6e6f 7420 6578 6974 0a09 0962 uld not exit...b │ │ │ -0007a630: 6f6f 6c20 7472 795f 7468 7265 6164 5f65 ool try_thread_e │ │ │ -0007a640: 7869 7428 7374 643a 3a74 6872 6561 643a xit(std::thread: │ │ │ -0007a650: 3a69 6420 6964 293b 0a0a 0909 2f2f 2067 :id id);....// g │ │ │ -0007a660: 6574 2074 6865 2074 6872 6561 6420 6964 et the thread id │ │ │ -0007a670: 206f 6620 7468 6520 6669 7273 7420 7468 of the first th │ │ │ -0007a680: 7265 6164 2069 6e20 7468 6520 696e 7465 read in the inte │ │ │ -0007a690: 726e 616c 2076 6563 746f 720a 0909 2f2f rnal vector...// │ │ │ -0007a6a0: 2073 696e 6365 2074 6869 7320 6973 2074 since this is t │ │ │ -0007a6b0: 6865 2066 6972 7374 2074 6872 6561 6420 he first thread │ │ │ -0007a6c0: 6974 2077 696c 6c20 7265 6d61 696e 2074 it will remain t │ │ │ -0007a6d0: 6865 2073 616d 6520 756e 7469 6c20 7468 he same until th │ │ │ -0007a6e0: 6520 6669 7273 740a 0909 2f2f 2074 6872 e first...// thr │ │ │ -0007a6f0: 6561 6420 6578 6974 730a 0909 2f2f 2069 ead exits...// i │ │ │ -0007a700: 7420 6361 6e20 6265 2075 7365 6420 746f t can be used to │ │ │ -0007a710: 2074 7269 6767 6572 206d 6169 6e74 656e trigger mainten │ │ │ -0007a720: 616e 6365 206a 6f62 7320 7768 6963 6820 ance jobs which │ │ │ -0007a730: 7368 6f75 6c64 206f 6e6c 7920 7275 6e20 should only run │ │ │ -0007a740: 6f6e 206f 6e65 2074 6872 6561 640a 0909 on one thread... │ │ │ -0007a750: 7374 643a 3a74 6872 6561 643a 3a69 6420 std::thread::id │ │ │ -0007a760: 6669 7273 745f 7468 7265 6164 5f69 6428 first_thread_id( │ │ │ -0007a770: 293b 0a09 0969 6e74 206e 756d 5f74 6872 );...int num_thr │ │ │ -0007a780: 6561 6473 2829 0a09 097b 0a09 0909 7374 eads()...{....st │ │ │ -0007a790: 643a 3a6c 6f63 6b5f 6775 6172 6426 6c74 d::lock_guard< │ │ │ -0007a7a0: 3b73 7464 3a3a 6d75 7465 7826 6774 3b20 ;std::mutex> │ │ │ -0007a7b0: 6c28 6d5f 6d75 7465 7829 3b0a 0909 0972 l(m_mutex);....r │ │ │ -0007a7c0: 6574 7572 6e20 696e 7428 6d5f 7468 7265 eturn int(m_thre │ │ │ -0007a7d0: 6164 732e 7369 7a65 2829 293b 0a09 097d ads.size());...} │ │ │ -0007a7e0: 0a0a 0909 766f 6964 2061 7070 656e 6428 ....void append( │ │ │ -0007a7f0: 6a6f 6271 7565 7565 5f74 206a 6f62 7329 jobqueue_t jobs) │ │ │ -0007a800: 0a09 097b 0a09 0909 6d5f 7175 6575 6564 ...{....m_queued │ │ │ -0007a810: 5f6a 6f62 732e 6170 7065 6e64 2873 7464 _jobs.append(std │ │ │ -0007a820: 3a3a 6d6f 7665 286a 6f62 7329 293b 0a09 ::move(jobs));.. │ │ │ -0007a830: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..
    ..void push_ba │ │ │ -0007a870: 636b 2861 7578 3a3a 6469 736b 5f6a 6f62 ck(aux::disk_job │ │ │ -0007a880: 2a20 6a29 0a3c 2f64 6976 3e09 097b 0a09 * j).
    ..{.. │ │ │ -0007a890: 0909 6d5f 7175 6575 6564 5f6a 6f62 732e ..m_queued_jobs. │ │ │ -0007a8a0: 7075 7368 5f62 6163 6b28 6a29 3b0a 0909 push_back(j);... │ │ │ -0007a8b0: 7d0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f }..
    │ │ │ -0007a8e0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0007a8f0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0007a920: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007a930: 656e 742f 6175 785f 2f64 6973 6b5f 696f ent/aux_/disk_io │ │ │ -0007a940: 5f74 6872 6561 645f 706f 6f6c 2e68 7070 _thread_pool.hpp │ │ │ -0007a950: 3a31 3138 3c2f 613e 3c2f 7464 3e3c 7464 :118the job mutex m │ │ │ -0007a970: 7573 7420 6265 2068 656c 6420 7768 656e ust be held when │ │ │ -0007a980: 2074 6869 7320 6973 2063 616c 6c65 643c this is called< │ │ │ -0007a990: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    the │ │ │ -0007a9e0: 206a 6f62 206d 7574 6578 206d 7573 7420 job mutex must │ │ │ -0007a9f0: 6265 2068 656c 6420 7768 656e 2074 6869 be held when thi │ │ │ -0007aa00: 7320 6973 2063 616c 6c65 643c 2f68 323e s is called

    │ │ │ -0007aa10: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -0007aa20: 6962 746f 7272 656e 742f 6175 785f 2f64 ibtorrent/aux_/d │ │ │ -0007aa30: 6973 6b5f 696f 5f74 6872 6561 645f 706f isk_io_thread_po │ │ │ -0007aa40: 6f6c 2e68 7070 3a31 3138 3c2f 6834 3e3c ol.hpp:118

    < │ │ │ -0007aa50: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0007aa60: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0007aa70: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0007aa80: 7820 2364 6464 3b22 3e09 092f 2f20 7369 x #ddd;">..// si │ │ │ -0007aa90: 6e63 6520 7468 6973 2069 7320 7468 6520 nce this is the │ │ │ -0007aaa0: 6669 7273 7420 7468 7265 6164 2069 7420 first thread it │ │ │ -0007aab0: 7769 6c6c 2072 656d 6169 6e20 7468 6520 will remain the │ │ │ -0007aac0: 7361 6d65 2075 6e74 696c 2074 6865 2066 same until the f │ │ │ -0007aad0: 6972 7374 0a09 092f 2f20 7468 7265 6164 irst...// thread │ │ │ -0007aae0: 2065 7869 7473 0a09 092f 2f20 6974 2063 exits...// it c │ │ │ -0007aaf0: 616e 2062 6520 7573 6564 2074 6f20 7472 an be used to tr │ │ │ -0007ab00: 6967 6765 7220 6d61 696e 7465 6e61 6e63 igger maintenanc │ │ │ -0007ab10: 6520 6a6f 6273 2077 6869 6368 2073 686f e jobs which sho │ │ │ -0007ab20: 756c 6420 6f6e 6c79 2072 756e 206f 6e20 uld only run on │ │ │ -0007ab30: 6f6e 6520 7468 7265 6164 0a09 0973 7464 one thread...std │ │ │ -0007ab40: 3a3a 7468 7265 6164 3a3a 6964 2066 6972 ::thread::id fir │ │ │ -0007ab50: 7374 5f74 6872 6561 645f 6964 2829 3b0a st_thread_id();. │ │ │ -0007ab60: 0909 696e 7420 6e75 6d5f 7468 7265 6164 ..int num_thread │ │ │ -0007ab70: 7328 290a 0909 7b0a 0909 0973 7464 3a3a s()...{....std:: │ │ │ -0007ab80: 6c6f 636b 5f67 7561 7264 266c 743b 7374 lock_guard<st │ │ │ -0007ab90: 643a 3a6d 7574 6578 2667 743b 206c 286d d::mutex> l(m │ │ │ -0007aba0: 5f6d 7574 6578 293b 0a09 0909 7265 7475 _mutex);....retu │ │ │ -0007abb0: 726e 2069 6e74 286d 5f74 6872 6561 6473 rn int(m_threads │ │ │ -0007abc0: 2e73 697a 6528 2929 3b0a 0909 7d0a 0a09 .size());...}... │ │ │ -0007abd0: 0976 6f69 6420 6170 7065 6e64 286a 6f62 .void append(job │ │ │ -0007abe0: 7175 6575 655f 7420 6a6f 6273 290a 0909 queue_t jobs)... │ │ │ -0007abf0: 7b0a 0909 096d 5f71 7565 7565 645f 6a6f {....m_queued_jo │ │ │ -0007ac00: 6273 2e61 7070 656e 6428 7374 643a 3a6d bs.append(std::m │ │ │ -0007ac10: 6f76 6528 6a6f 6273 2929 3b0a 0909 7d0a ove(jobs));...}. │ │ │ -0007ac20: 0a09 0976 6f69 6420 7075 7368 5f62 6163 ...void push_bac │ │ │ -0007ac30: 6b28 6175 783a 3a64 6973 6b5f 6a6f 622a k(aux::disk_job* │ │ │ -0007ac40: 206a 290a 0909 7b0a 0909 096d 5f71 7565 j)...{....m_que │ │ │ -0007ac50: 7565 645f 6a6f 6273 2e70 7573 685f 6261 ued_jobs.push_ba │ │ │ -0007ac60: 636b 286a 293b 0a09 097d 0a0a 3c64 6976 ck(j);...}..
    ..aux: │ │ │ -0007aca0: 3a64 6973 6b5f 6a6f 622a 2070 6f70 5f66 :disk_job* pop_f │ │ │ -0007acb0: 726f 6e74 2829 0a3c 2f64 6976 3e09 097b ront().
    ..{ │ │ │ -0007acc0: 0a09 0909 7265 7475 726e 206d 5f71 7565 ....return m_que │ │ │ -0007acd0: 7565 645f 6a6f 6273 2e70 6f70 5f66 726f ued_jobs.pop_fro │ │ │ -0007ace0: 6e74 2829 3b0a 0909 7d0a 0a3c 2f70 7265 nt();...}..
    rele │ │ │ -0007ad20: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -0007ad60: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007ad70: 2f64 6973 6b5f 696f 5f74 6872 6561 645f /disk_io_thread_ │ │ │ -0007ad80: 706f 6f6c 2e68 7070 3a31 3234 3c2f 613e pool.hpp:124 │ │ │ -0007ad90: 3c2f 7464 3e3c 7464 3e74 6865 206a 6f62 the job │ │ │ -0007ada0: 206d 7574 6578 206d 7573 7420 6265 2068 mutex must be h │ │ │ -0007adb0: 656c 6420 7768 656e 2074 6869 7320 6973 eld when this is │ │ │ -0007adc0: 2063 616c 6c65 643c 2f74 643e 3c2f 7472 called

    the job mut │ │ │ -0007ae20: 6578 206d 7573 7420 6265 2068 656c 6420 ex must be held │ │ │ -0007ae30: 7768 656e 2074 6869 7320 6973 2063 616c when this is cal │ │ │ -0007ae40: 6c65 643c 2f68 323e 3c68 343e 2e2e 2f69 led

    ../i │ │ │ -0007ae50: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007ae60: 742f 6175 785f 2f64 6973 6b5f 696f 5f74 t/aux_/disk_io_t │ │ │ -0007ae70: 6872 6561 645f 706f 6f6c 2e68 7070 3a31 hread_pool.hpp:1 │ │ │ -0007ae80: 3234 3c2f 6834 3e3c 7072 6520 7374 796c 24

    ..{....std::loc
    │ │ │ -0007aed0: 6b5f 6775 6172 6426 6c74 3b73 7464 3a3a  k_guard<std::
    │ │ │ -0007aee0: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -0007aef0: 7465 7829 3b0a 0909 0972 6574 7572 6e20  tex);....return 
    │ │ │ -0007af00: 696e 7428 6d5f 7468 7265 6164 732e 7369  int(m_threads.si
    │ │ │ -0007af10: 7a65 2829 293b 0a09 097d 0a0a 0909 766f  ze());...}....vo
    │ │ │ -0007af20: 6964 2061 7070 656e 6428 6a6f 6271 7565  id append(jobque
    │ │ │ -0007af30: 7565 5f74 206a 6f62 7329 0a09 097b 0a09  ue_t jobs)...{..
    │ │ │ -0007af40: 0909 6d5f 7175 6575 6564 5f6a 6f62 732e  ..m_queued_jobs.
    │ │ │ -0007af50: 6170 7065 6e64 2873 7464 3a3a 6d6f 7665  append(std::move
    │ │ │ -0007af60: 286a 6f62 7329 293b 0a09 097d 0a0a 0909  (jobs));...}....
    │ │ │ -0007af70: 766f 6964 2070 7573 685f 6261 636b 2861  void push_back(a
    │ │ │ -0007af80: 7578 3a3a 6469 736b 5f6a 6f62 2a20 6a29  ux::disk_job* j)
    │ │ │ -0007af90: 0a09 097b 0a09 0909 6d5f 7175 6575 6564  ...{....m_queued
    │ │ │ -0007afa0: 5f6a 6f62 732e 7075 7368 5f62 6163 6b28  _jobs.push_back(
    │ │ │ -0007afb0: 6a29 3b0a 0909 7d0a 0a09 0961 7578 3a3a  j);...}....aux::
    │ │ │ -0007afc0: 6469 736b 5f6a 6f62 2a20 706f 705f 6672  disk_job* pop_fr
    │ │ │ -0007afd0: 6f6e 7428 290a 0909 7b0a 0909 0972 6574  ont()...{....ret
    │ │ │ -0007afe0: 7572 6e20 6d5f 7175 6575 6564 5f6a 6f62  urn m_queued_job
    │ │ │ -0007aff0: 732e 706f 705f 6672 6f6e 7428 293b 0a09  s.pop_front();..
    │ │ │ -0007b000: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    ..bool empty() │ │ │ -0007b040: 2063 6f6e 7374 0a3c 2f64 6976 3e09 097b const.
    ..{ │ │ │ -0007b050: 0a09 0909 7265 7475 726e 206d 5f71 7565 ....return m_que │ │ │ -0007b060: 7565 645f 6a6f 6273 2e65 6d70 7479 2829 ued_jobs.empty() │ │ │ -0007b070: 3b0a 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 ;...}..
    relevanc │ │ │ -0007b0b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -0007b0f0: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ -0007b100: 6b5f 696f 5f74 6872 6561 645f 706f 6f6c k_io_thread_pool │ │ │ -0007b110: 2e68 7070 3a31 3330 3c2f 613e 3c2f 7464 .hpp:130the job mut │ │ │ -0007b130: 6578 206d 7573 7420 6265 2068 656c 6420 ex must be held │ │ │ -0007b140: 7768 656e 2074 6869 7320 6973 2063 616c when this is cal │ │ │ -0007b150: 6c65 643c 2f74 643e 3c2f 7472 3e3c 7472 led

    the job mutex m │ │ │ -0007b1b0: 7573 7420 6265 2068 656c 6420 7768 656e ust be held when │ │ │ -0007b1c0: 2074 6869 7320 6973 2063 616c 6c65 643c this is called< │ │ │ -0007b1d0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0007b1e0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007b1f0: 785f 2f64 6973 6b5f 696f 5f74 6872 6561 x_/disk_io_threa │ │ │ -0007b200: 645f 706f 6f6c 2e68 7070 3a31 3330 3c2f d_pool.hpp:130
    ..v
    │ │ │ -0007b250: 6f69 6420 6170 7065 6e64 286a 6f62 7175  oid append(jobqu
    │ │ │ -0007b260: 6575 655f 7420 6a6f 6273 290a 0909 7b0a  eue_t jobs)...{.
    │ │ │ -0007b270: 0909 096d 5f71 7565 7565 645f 6a6f 6273  ...m_queued_jobs
    │ │ │ -0007b280: 2e61 7070 656e 6428 7374 643a 3a6d 6f76  .append(std::mov
    │ │ │ -0007b290: 6528 6a6f 6273 2929 3b0a 0909 7d0a 0a09  e(jobs));...}...
    │ │ │ -0007b2a0: 0976 6f69 6420 7075 7368 5f62 6163 6b28  .void push_back(
    │ │ │ -0007b2b0: 6175 783a 3a64 6973 6b5f 6a6f 622a 206a  aux::disk_job* j
    │ │ │ -0007b2c0: 290a 0909 7b0a 0909 096d 5f71 7565 7565  )...{....m_queue
    │ │ │ -0007b2d0: 645f 6a6f 6273 2e70 7573 685f 6261 636b  d_jobs.push_back
    │ │ │ -0007b2e0: 286a 293b 0a09 097d 0a0a 0909 6175 783a  (j);...}....aux:
    │ │ │ -0007b2f0: 3a64 6973 6b5f 6a6f 622a 2070 6f70 5f66  :disk_job* pop_f
    │ │ │ -0007b300: 726f 6e74 2829 0a09 097b 0a09 0909 7265  ront()...{....re
    │ │ │ -0007b310: 7475 726e 206d 5f71 7565 7565 645f 6a6f  turn m_queued_jo
    │ │ │ -0007b320: 6273 2e70 6f70 5f66 726f 6e74 2829 3b0a  bs.pop_front();.
    │ │ │ -0007b330: 0909 7d0a 0a09 0962 6f6f 6c20 656d 7074  ..}....bool empt
    │ │ │ -0007b340: 7928 2920 636f 6e73 740a 0909 7b0a 0909  y() const...{...
    │ │ │ -0007b350: 0972 6574 7572 6e20 6d5f 7175 6575 6564  .return m_queued
    │ │ │ -0007b360: 5f6a 6f62 732e 656d 7074 7928 293b 0a09  _jobs.empty();..
    │ │ │ -0007b370: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    ..int queue_si │ │ │ -0007b3b0: 7a65 2829 2063 6f6e 7374 0a3c 2f64 6976 ze() const.
    ..{....return m │ │ │ -0007b3d0: 5f71 7565 7565 645f 6a6f 6273 2e73 697a _queued_jobs.siz │ │ │ -0007b3e0: 6528 293b 0a09 097d 0a0a 3c2f 7072 653e e();...}..
    │ │ │ -0007b3f0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0007b420: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0007b430: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -0007b460: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007b470: 6469 736b 5f69 6f5f 7468 7265 6164 5f70 disk_io_thread_p │ │ │ -0007b480: 6f6f 6c2e 6870 703a 3133 363c 2f61 3e3c ool.hpp:136< │ │ │ -0007b490: 2f74 643e 3c74 643e 7468 6520 6a6f 6220 /td>the job │ │ │ -0007b4a0: 6d75 7465 7820 6d75 7374 2062 6520 6865 mutex must be he │ │ │ -0007b4b0: 6c64 2077 6865 6e20 7468 6973 2069 7320 ld when this is │ │ │ -0007b4c0: 6361 6c6c 6564 3c2f 7464 3e3c 2f74 723e called │ │ │ -0007b4d0: 3c74 7220 6964 3d22 3238 3222 2073 7479 │ │ │ -0007b500: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0007b510: 3c68 323e 7468 6520 6a6f 6220 6d75 7465

    the job mute │ │ │ -0007b520: 7820 6d75 7374 2062 6520 6865 6c64 2077 x must be held w │ │ │ -0007b530: 6865 6e20 7468 6973 2069 7320 6361 6c6c hen this is call │ │ │ -0007b540: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ed

    ../in │ │ │ -0007b550: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007b560: 2f61 7578 5f2f 6469 736b 5f69 6f5f 7468 /aux_/disk_io_th │ │ │ -0007b570: 7265 6164 5f70 6f6f 6c2e 6870 703a 3133 read_pool.hpp:13 │ │ │ -0007b580: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -0007b5c0: 0909 766f 6964 2070 7573 685f 6261 636b  ..void push_back
    │ │ │ -0007b5d0: 2861 7578 3a3a 6469 736b 5f6a 6f62 2a20  (aux::disk_job* 
    │ │ │ -0007b5e0: 6a29 0a09 097b 0a09 0909 6d5f 7175 6575  j)...{....m_queu
    │ │ │ -0007b5f0: 6564 5f6a 6f62 732e 7075 7368 5f62 6163  ed_jobs.push_bac
    │ │ │ -0007b600: 6b28 6a29 3b0a 0909 7d0a 0a09 0961 7578  k(j);...}....aux
    │ │ │ -0007b610: 3a3a 6469 736b 5f6a 6f62 2a20 706f 705f  ::disk_job* pop_
    │ │ │ -0007b620: 6672 6f6e 7428 290a 0909 7b0a 0909 0972  front()...{....r
    │ │ │ -0007b630: 6574 7572 6e20 6d5f 7175 6575 6564 5f6a  eturn m_queued_j
    │ │ │ -0007b640: 6f62 732e 706f 705f 6672 6f6e 7428 293b  obs.pop_front();
    │ │ │ -0007b650: 0a09 097d 0a0a 0909 626f 6f6c 2065 6d70  ...}....bool emp
    │ │ │ -0007b660: 7479 2829 2063 6f6e 7374 0a09 097b 0a09  ty() const...{..
    │ │ │ -0007b670: 0909 7265 7475 726e 206d 5f71 7565 7565  ..return m_queue
    │ │ │ -0007b680: 645f 6a6f 6273 2e65 6d70 7479 2829 3b0a  d_jobs.empty();.
    │ │ │ -0007b690: 0909 7d0a 0a09 0969 6e74 2071 7565 7565  ..}....int queue
    │ │ │ -0007b6a0: 5f73 697a 6528 2920 636f 6e73 740a 0909  _size() const...
    │ │ │ -0007b6b0: 7b0a 0909 0972 6574 7572 6e20 6d5f 7175  {....return m_qu
    │ │ │ -0007b6c0: 6575 6564 5f6a 6f62 732e 7369 7a65 2829  eued_jobs.size()
    │ │ │ -0007b6d0: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    ..void subm │ │ │ -0007b710: 6974 5f6a 6f62 7328 290a 3c2f 6469 763e it_jobs().
    │ │ │ -0007b720: 0909 7b0a 0909 0969 6620 286d 5f71 7565 ..{....if (m_que │ │ │ -0007b730: 7565 645f 6a6f 6273 2e65 6d70 7479 2829 ued_jobs.empty() │ │ │ -0007b740: 2920 7265 7475 726e 3b0a 0909 096e 6f74 ) return;....not │ │ │ -0007b750: 6966 795f 616c 6c28 293b 0a09 0909 6a6f ify_all();....jo │ │ │ -0007b760: 625f 7175 6575 6564 286d 5f71 7565 7565 b_queued(m_queue │ │ │ -0007b770: 645f 6a6f 6273 2e73 697a 6528 2929 3b0a d_jobs.size());. │ │ │ -0007b780: 0909 7d0a 0a09 0976 6f69 6420 696e 7465 ..}....void inte │ │ │ -0007b790: 7272 7570 7428 290a 0909 7b0a 0909 096d rrupt()...{....m │ │ │ -0007b7a0: 5f69 6e74 6572 7275 7074 203d 2074 7275 _interrupt = tru │ │ │ -0007b7b0: 653b 0a09 0909 6d5f 6a6f 625f 636f 6e64 e;....m_job_cond │ │ │ -0007b7c0: 2e6e 6f74 6966 795f 6f6e 6528 293b 0a09 .notify_one();.. │ │ │ -0007b7d0: 097d 0a0a 0909 7465 6d70 6c61 7465 266c .}....template&l │ │ │ -0007b7e0: 743b 7479 7065 6e61 6d65 2046 756e 2667 t;typename Fun&g │ │ │ -0007b7f0: 743b 0a09 0976 6f69 6420 7669 7369 745f t;...void visit_ │ │ │ -0007b800: 6a6f 6273 2846 756e 2066 290a 0909 7b0a jobs(Fun f)...{. │ │ │ -0007b810: 0909 0966 6f72 2028 6175 746f 2069 203d ...for (auto i = │ │ │ -0007b820: 206d 5f71 7565 7565 645f 6a6f 6273 2e69 m_queued_jobs.i │ │ │ -0007b830: 7465 7261 7465 2829 3b20 692e 6765 7428 terate(); i.get( │ │ │ -0007b840: 293b 2069 2e6e 6578 7428 2929 0a09 0909 ); i.next()).... │ │ │ -0007b850: 0966 2869 2e67 6574 2829 293b 0a09 097d .f(i.get());...} │ │ │ -0007b860: 0a0a 0970 7269 7661 7465 3a0a 0a09 092f ...private:..../ │ │ │ -0007b870: 2f20 7468 6973 2073 686f 756c 6420 6265 / this should be │ │ │ -0007b880: 2063 616c 6c65 6420 7768 656e 6576 6572 called whenever │ │ │ -0007b890: 206e 6577 206a 6f62 7320 6172 6520 7175 new jobs are qu │ │ │ -0007b8a0: 6575 6564 0a09 092f 2f20 7175 6575 655f eued...// queue_ │ │ │ -0007b8b0: 7369 7a65 2069 7320 7468 6520 6375 7272 size is the curr │ │ │ -0007b8c0: 656e 7420 7369 7a65 206f 6620 7468 6520 ent size of the │ │ │ -0007b8d0: 6a6f 6220 7175 6575 650a 0909 2f2f 206e job queue...// n │ │ │ -0007b8e0: 6f74 2074 6872 6561 6420 7361 6665 0a09 ot thread safe.. │ │ │ -0007b8f0: 0976 6f69 6420 6a6f 625f 7175 6575 6564 .void job_queued │ │ │ -0007b900: 2869 6e74 2071 7565 7565 5f73 697a 6529 (int queue_size) │ │ │ -0007b910: 3b0a 0a09 0976 6f69 6420 7265 6170 5f69 ;....void reap_i │ │ │ -0007b920: 646c 655f 7468 7265 6164 7328 6572 726f dle_threads(erro │ │ │ -0007b930: 725f 636f 6465 2063 6f6e 7374 2661 6d70 r_code const& │ │ │ -0007b940: 3b20 6563 293b 0a0a 0909 2f2f 2074 6865 ; ec);....// the │ │ │ -0007b950: 2063 616c 6c65 7220 6d75 7374 2068 6f6c caller must hol │ │ │ -0007b960: 6420 6d5f 6d75 7465 780a 0909 766f 6964 d m_mutex...void │ │ │ -0007b970: 2073 746f 705f 7468 7265 6164 7328 696e stop_threads(in │ │ │ -0007b980: 7420 6e75 6d5f 746f 5f73 746f 7029 3b0a t num_to_stop);. │ │ │ -0007b990: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0007b9a0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0007b9d0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -0007ba00: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007ba10: 2f61 7578 5f2f 7072 6f78 795f 6261 7365 /aux_/proxy_base │ │ │ -0007ba20: 2e68 7070 3a32 3034 3c2f 613e 3c2f 7464 .hpp:204it would be │ │ │ -0007ba40: 206e 6963 6520 746f 2072 656d 656d 6265 nice to remembe │ │ │ -0007ba50: 7220 7468 6520 6269 6e64 2070 6f72 7420 r the bind port │ │ │ -0007ba60: 616e 6420 6269 6e64 206f 6e63 6520 7765 and bind once we │ │ │ -0007ba70: 206b 6e6f 7720 7768 6572 6520 7468 6520 know where the │ │ │ -0007ba80: 7072 6f78 7920 6973 206d 5f73 6f63 6b2e proxy is m_sock. │ │ │ -0007ba90: 6269 6e64 2865 6e64 706f 696e 742c 2065 bind(endpoint, e │ │ │ -0007baa0: 6329 3b3c 2f74 643e 3c2f 7472 3e3c 7472 c);

    it would be nic │ │ │ -0007bb00: 6520 746f 2072 656d 656d 6265 7220 7468 e to remember th │ │ │ -0007bb10: 6520 6269 6e64 2070 6f72 7420 616e 6420 e bind port and │ │ │ -0007bb20: 6269 6e64 206f 6e63 6520 7765 206b 6e6f bind once we kno │ │ │ -0007bb30: 7720 7768 6572 6520 7468 6520 7072 6f78 w where the prox │ │ │ -0007bb40: 7920 6973 0a6d 5f73 6f63 6b2e 6269 6e64 y is.m_sock.bind │ │ │ -0007bb50: 2865 6e64 706f 696e 742c 2065 6329 3b3c (endpoint, ec);< │ │ │ -0007bb60: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0007bb70: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007bb80: 785f 2f70 726f 7879 5f62 6173 652e 6870 x_/proxy_base.hp │ │ │ -0007bb90: 703a 3230 343c 2f68 343e 3c70 7265 2073 p:204

    ..TORRENT_AS
    │ │ │ -0007bbe0: 5345 5254 286d 5f6d 6167 6963 203d 3d20  SERT(m_magic == 
    │ │ │ -0007bbf0: 3078 3133 3337 293b 0a09 096d 5f73 6f63  0x1337);...m_soc
    │ │ │ -0007bc00: 6b2e 6361 6e63 656c 2829 3b0a 097d 0a0a  k.cancel();..}..
    │ │ │ -0007bc10: 0976 6f69 6420 6361 6e63 656c 2865 7272  .void cancel(err
    │ │ │ -0007bc20: 6f72 5f63 6f64 6526 616d 703b 2065 6329  or_code& ec)
    │ │ │ -0007bc30: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ -0007bc40: 5345 5254 286d 5f6d 6167 6963 203d 3d20  SERT(m_magic == 
    │ │ │ -0007bc50: 3078 3133 3337 293b 0a09 096d 5f73 6f63  0x1337);...m_soc
    │ │ │ -0007bc60: 6b2e 6361 6e63 656c 2865 6329 3b0a 097d  k.cancel(ec);..}
    │ │ │ -0007bc70: 0a0a 0976 6f69 6420 6269 6e64 2865 6e64  ...void bind(end
    │ │ │ -0007bc80: 706f 696e 745f 7479 7065 2063 6f6e 7374  point_type const
    │ │ │ -0007bc90: 2661 6d70 3b20 2f2a 2065 6e64 706f 696e  & /* endpoin
    │ │ │ -0007bca0: 7420 2a2f 2c20 6572 726f 725f 636f 6465  t */, error_code
    │ │ │ -0007bcb0: 2661 6d70 3b20 2f2a 2065 6320 2a2f 290a  & /* ec */).
    │ │ │ -0007bcc0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ -0007bcd0: 4552 5428 6d5f 6d61 6769 6320 3d3d 2030  ERT(m_magic == 0
    │ │ │ -0007bce0: 7831 3333 3729 3b0a 0909 2f2f 2074 6865  x1337);...// the
    │ │ │ -0007bcf0: 2072 6561 736f 6e20 7768 7920 7765 2069   reason why we i
    │ │ │ -0007bd00: 676e 6f72 6520 6269 6e64 7320 6865 7265  gnore binds here
    │ │ │ -0007bd10: 2069 7320 6265 6361 7573 6520 7765 2064   is because we d
    │ │ │ -0007bd20: 6f6e 2774 0a09 092f 2f20 286e 6563 6573  on't...// (neces
    │ │ │ -0007bd30: 7361 7269 6c79 2920 7965 7420 6b6e 6f77  sarily) yet know
    │ │ │ -0007bd40: 2077 6861 7420 6164 6472 6573 7320 6661   what address fa
    │ │ │ -0007bd50: 6d69 6c79 2074 6865 2070 726f 7879 0a09  mily the proxy..
    │ │ │ -0007bd60: 092f 2f20 7769 6c6c 2072 6573 6f6c 7665  .// will resolve
    │ │ │ -0007bd70: 2074 6f2c 2061 6e64 2062 696e 6469 6e67   to, and binding
    │ │ │ -0007bd80: 2074 6f20 7468 6520 7772 6f6e 6720 6f6e   to the wrong on
    │ │ │ -0007bd90: 6520 776f 756c 640a 0909 2f2f 2062 7265  e would...// bre
    │ │ │ -0007bda0: 616b 206f 7572 2063 6f6e 6e65 6374 696f  ak our connectio
    │ │ │ -0007bdb0: 6e20 6174 7465 6d70 7420 6c61 7465 722e  n attempt later.
    │ │ │ -0007bdc0: 2054 6865 2063 616c 6c65 7220 6865 7265   The caller here
    │ │ │ -0007bdd0: 0a09 092f 2f20 646f 6573 6e27 7420 6e65  ...// doesn't ne
    │ │ │ -0007bde0: 6365 7373 6172 696c 7920 6b6e 6f77 2074  cessarily know t
    │ │ │ -0007bdf0: 6861 7420 7765 2772 6520 7072 6f78 7969  hat we're proxyi
    │ │ │ -0007be00: 6e67 2c20 736f 2074 6869 730a 0909 2f2f  ng, so this...//
    │ │ │ -0007be10: 2062 696e 6420 6164 6472 6573 7320 6973   bind address is
    │ │ │ -0007be20: 2062 6173 6564 206f 6e20 7468 6520 6669   based on the fi
    │ │ │ -0007be30: 6e61 6c20 656e 6470 6f69 6e74 2c20 6e6f  nal endpoint, no
    │ │ │ -0007be40: 7420 7468 650a 0909 2f2f 2070 726f 7879  t the...// proxy
    │ │ │ -0007be50: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0007be80: 097d 0a3c 2f64 6976 3e0a 2369 666e 6465 .}.
    .#ifnde │ │ │ -0007be90: 6620 424f 4f53 545f 4e4f 5f45 5843 4550 f BOOST_NO_EXCEP │ │ │ -0007bea0: 5449 4f4e 530a 0976 6f69 6420 6f70 656e TIONS..void open │ │ │ -0007beb0: 2870 726f 746f 636f 6c5f 7479 7065 2063 (protocol_type c │ │ │ -0007bec0: 6f6e 7374 2661 6d70 3b29 0a09 7b0a 0909 onst&)..{... │ │ │ -0007bed0: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -0007bee0: 5f6d 6167 6963 203d 3d20 3078 3133 3337 _magic == 0x1337 │ │ │ -0007bef0: 293b 0a2f 2f09 096d 5f73 6f63 6b2e 6f70 );.//..m_sock.op │ │ │ -0007bf00: 656e 2870 293b 0a09 7d0a 2365 6e64 6966 en(p);..}.#endif │ │ │ -0007bf10: 0a0a 0976 6f69 6420 6f70 656e 2870 726f ...void open(pro │ │ │ -0007bf20: 746f 636f 6c5f 7479 7065 2063 6f6e 7374 tocol_type const │ │ │ -0007bf30: 2661 6d70 3b2c 2065 7272 6f72 5f63 6f64 &, error_cod │ │ │ -0007bf40: 6526 616d 703b 290a 097b 0a09 0954 4f52 e&)..{...TOR │ │ │ -0007bf50: 5245 4e54 5f41 5353 4552 5428 6d5f 6d61 RENT_ASSERT(m_ma │ │ │ -0007bf60: 6769 6320 3d3d 2030 7831 3333 3729 3b0a gic == 0x1337);. │ │ │ -0007bf70: 0909 2f2f 2077 6520 6e65 6564 2074 6f20 ..// we need to │ │ │ -0007bf80: 6967 6e6f 7265 2074 6869 7320 666f 7220 ignore this for │ │ │ -0007bf90: 7468 6520 7361 6d65 2072 6561 736f 6e20 the same reason │ │ │ -0007bfa0: 6173 2073 7461 7465 640a 0909 2f2f 2066 as stated...// f │ │ │ -0007bfb0: 6f72 2069 676e 6f72 696e 6720 6269 6e64 or ignoring bind │ │ │ -0007bfc0: 2829 0a2f 2f09 096d 5f73 6f63 6b2e 6f70 ().//..m_sock.op │ │ │ -0007bfd0: 656e 2870 2c20 6563 293b 0a09 7d0a 0a23 en(p, ec);..}..# │ │ │ -0007bfe0: 6966 6e64 6566 2042 4f4f 5354 5f4e 4f5f ifndef BOOST_NO_ │ │ │ -0007bff0: 4558 4345 5054 494f 4e53 0a09 766f 6964 EXCEPTIONS..void │ │ │ -0007c000: 2063 6c6f 7365 2829 0a09 7b0a 0909 544f close()..{...TO │ │ │ -0007c010: 5252 454e 545f 4153 5345 5254 286d 5f6d RRENT_ASSERT(m_m │ │ │ -0007c020: 6167 6963 203d 3d20 3078 3133 3337 293b agic == 0x1337); │ │ │ -0007c030: 0a09 096d 5f72 656d 6f74 655f 656e 6470 ...m_remote_endp │ │ │ -0007c040: 6f69 6e74 203d 2065 6e64 706f 696e 745f oint = endpoint_ │ │ │ -0007c050: 7479 7065 2829 3b0a 0909 6d5f 736f 636b type();...m_sock │ │ │ -0007c060: 2e63 6c6f 7365 2829 3b0a 0909 6d5f 7265 .close();...m_re │ │ │ -0007c070: 736f 6c76 6572 2e63 616e 6365 6c28 293b solver.cancel(); │ │ │ -0007c080: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ -0007c090: 6420 636c 6f73 6528 6572 726f 725f 636f d close(error_co │ │ │ -0007c0a0: 6465 2661 6d70 3b20 6563 290a 097b 0a09 de& ec)..{.. │ │ │ -0007c0b0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0007c0c0: 6d5f 6d61 6769 6320 3d3d 2030 7831 3333 m_magic == 0x133 │ │ │ -0007c0d0: 3729 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 7);.
    < │ │ │ -0007c0e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0007c110: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0007c140: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007c150: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ -0007c160: 6e5f 696e 7465 7266 6163 652e 6870 703a n_interface.hpp: │ │ │ -0007c170: 3138 383c 2f61 3e3c 2f74 643e 3c74 643e 188 │ │ │ -0007c180: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -0007c190: 2074 6f20 6e6f 7420 6861 7665 2074 6869 to not have thi │ │ │ -0007c1a0: 7320 6265 2070 6172 7420 6f66 2073 6573 s be part of ses │ │ │ -0007c1b0: 7369 6f6e 5f69 6e74 6572 6661 6365 3c2f sion_interface

    it w │ │ │ -0007c210: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ -0007c220: 6e6f 7420 6861 7665 2074 6869 7320 6265 not have this be │ │ │ -0007c230: 2070 6172 7420 6f66 2073 6573 7369 6f6e part of session │ │ │ -0007c240: 5f69 6e74 6572 6661 6365 3c2f 6832 3e3c _interface

    < │ │ │ -0007c250: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0007c260: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ -0007c270: 7373 696f 6e5f 696e 7465 7266 6163 652e ssion_interface. │ │ │ -0007c280: 6870 703a 3138 383c 2f68 343e 3c70 7265 hpp:188
    ..virtual 
    │ │ │ -0007c2d0: 766f 6964 2064 6566 6572 7265 645f 7375  void deferred_su
    │ │ │ -0007c2e0: 626d 6974 5f6a 6f62 7328 2920 3d20 303b  bmit_jobs() = 0;
    │ │ │ -0007c2f0: 0a0a 0909 7669 7274 7561 6c20 7374 643a  ....virtual std:
    │ │ │ -0007c300: 3a75 696e 7431 365f 7420 6c69 7374 656e  :uint16_t listen
    │ │ │ -0007c310: 5f70 6f72 7428 2920 636f 6e73 7420 3d20  _port() const = 
    │ │ │ -0007c320: 303b 0a09 0976 6972 7475 616c 2073 7464  0;...virtual std
    │ │ │ -0007c330: 3a3a 7569 6e74 3136 5f74 2073 736c 5f6c  ::uint16_t ssl_l
    │ │ │ -0007c340: 6973 7465 6e5f 706f 7274 2829 2063 6f6e  isten_port() con
    │ │ │ -0007c350: 7374 203d 2030 3b0a 0a09 0976 6972 7475  st = 0;....virtu
    │ │ │ -0007c360: 616c 2069 6e74 206c 6973 7465 6e5f 706f  al int listen_po
    │ │ │ -0007c370: 7274 2861 7578 3a3a 7472 616e 7370 6f72  rt(aux::transpor
    │ │ │ -0007c380: 7420 7373 6c2c 2061 6464 7265 7373 2063  t ssl, address c
    │ │ │ -0007c390: 6f6e 7374 2661 6d70 3b20 6c6f 6361 6c5f  onst& local_
    │ │ │ -0007c3a0: 6164 6472 2920 636f 6e73 7420 3d20 303b  addr) const = 0;
    │ │ │ -0007c3b0: 0a0a 0909 7669 7274 7561 6c20 7374 643a  ....virtual std:
    │ │ │ -0007c3c0: 3a75 696e 7433 325f 7420 6c69 7374 656e  :uint32_t listen
    │ │ │ -0007c3d0: 5f73 6f63 6b65 745f 7665 7273 696f 6e28  _socket_version(
    │ │ │ -0007c3e0: 2920 636f 6e73 7420 3d20 303b 0a09 0976  ) const = 0;...v
    │ │ │ -0007c3f0: 6972 7475 616c 2076 6f69 6420 666f 725f  irtual void for_
    │ │ │ -0007c400: 6561 6368 5f6c 6973 7465 6e5f 736f 636b  each_listen_sock
    │ │ │ -0007c410: 6574 2873 7464 3a3a 6675 6e63 7469 6f6e  et(std::function
    │ │ │ -0007c420: 266c 743b 766f 6964 2861 7578 3a3a 6c69  <void(aux::li
    │ │ │ -0007c430: 7374 656e 5f73 6f63 6b65 745f 6861 6e64  sten_socket_hand
    │ │ │ -0007c440: 6c65 2063 6f6e 7374 2661 6d70 3b29 2667  le const&)&g
    │ │ │ -0007c450: 743b 2066 2920 636f 6e73 7420 3d20 303b  t; f) const = 0;
    │ │ │ -0007c460: 0a0a 0909 2f2f 2061 736b 2066 6f72 2077  ....// ask for w
    │ │ │ -0007c470: 6869 6368 2069 6e74 6572 6661 6365 2061  hich interface a
    │ │ │ -0007c480: 6e64 2070 6f72 7420 746f 2062 696e 6420  nd port to bind 
    │ │ │ -0007c490: 6f75 7467 6f69 6e67 2070 6565 7220 636f  outgoing peer co
    │ │ │ -0007c4a0: 6e6e 6563 7469 6f6e 7320 6f6e 0a09 0976  nnections on...v
    │ │ │ -0007c4b0: 6972 7475 616c 2074 6370 3a3a 656e 6470  irtual tcp::endp
    │ │ │ -0007c4c0: 6f69 6e74 2062 696e 645f 6f75 7467 6f69  oint bind_outgoi
    │ │ │ -0007c4d0: 6e67 5f73 6f63 6b65 7428 736f 636b 6574  ng_socket(socket
    │ │ │ -0007c4e0: 5f74 7970 6526 616d 703b 2073 2c20 6164  _type& s, ad
    │ │ │ -0007c4f0: 6472 6573 7320 636f 6e73 7426 616d 703b  dress const&
    │ │ │ -0007c500: 0a09 0909 7265 6d6f 7465 5f61 6464 7265  ....remote_addre
    │ │ │ -0007c510: 7373 2c20 6572 726f 725f 636f 6465 2661  ss, error_code&a
    │ │ │ -0007c520: 6d70 3b20 6563 2920 636f 6e73 7420 3d20  mp; ec) const = 
    │ │ │ -0007c530: 303b 0a09 0976 6972 7475 616c 2062 6f6f  0;...virtual boo
    │ │ │ -0007c540: 6c20 7665 7269 6679 5f62 6f75 6e64 5f61  l verify_bound_a
    │ │ │ -0007c550: 6464 7265 7373 2861 6464 7265 7373 2063  ddress(address c
    │ │ │ -0007c560: 6f6e 7374 2661 6d70 3b20 6164 6472 2c20  onst& addr, 
    │ │ │ -0007c570: 626f 6f6c 2075 7470 2920 3d20 303b 0a0a  bool utp) = 0;..
    │ │ │ -0007c580: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -0007c590: 4449 5341 424c 455f 4d55 5441 424c 455f  DISABLE_MUTABLE_
    │ │ │ -0007c5a0: 544f 5252 454e 5453 0a09 0976 6972 7475  TORRENTS...virtu
    │ │ │ -0007c5b0: 616c 2073 7464 3a3a 7665 6374 6f72 266c  al std::vector&l
    │ │ │ -0007c5c0: 743b 7374 643a 3a73 6861 7265 645f 7074  t;std::shared_pt
    │ │ │ -0007c5d0: 7226 6c74 3b74 6f72 7265 6e74 2667 743b  r<torrent>
    │ │ │ -0007c5e0: 2667 743b 2066 696e 645f 636f 6c6c 6563  > find_collec
    │ │ │ -0007c5f0: 7469 6f6e 280a 0909 0973 7464 3a3a 7374  tion(....std::st
    │ │ │ -0007c600: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20  ring const& 
    │ │ │ -0007c610: 636f 6c6c 6563 7469 6f6e 2920 636f 6e73  collection) cons
    │ │ │ -0007c620: 7420 3d20 303b 0a23 656e 6469 660a 0a3c  t = 0;.#endif..<
    │ │ │ -0007c630: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0007c640: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0007c650: 7769 6474 683d 2231 3030 2522 3e09 0976  width="100%">..v
    │ │ │ -0007c660: 6972 7475 616c 2070 726f 7879 5f73 6574  irtual proxy_set
    │ │ │ -0007c670: 7469 6e67 7320 7072 6f78 7928 2920 636f  tings proxy() co
    │ │ │ -0007c680: 6e73 7420 3d20 303b 0a3c 2f64 6976 3e0a  nst = 0;.
    . │ │ │ -0007c690: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ -0007c6a0: 4932 500a 0909 7669 7274 7561 6c20 6932 I2P...virtual i2 │ │ │ -0007c6b0: 705f 636f 6e6e 6563 7469 6f6e 2661 6d70 p_connection& │ │ │ -0007c6c0: 3b20 6932 705f 636f 6e6e 2829 203d 2030 ; i2p_conn() = 0 │ │ │ -0007c6d0: 3b0a 0909 7669 7274 7561 6c20 6368 6172 ;...virtual char │ │ │ -0007c6e0: 2063 6f6e 7374 2a20 6932 705f 7365 7373 const* i2p_sess │ │ │ -0007c6f0: 696f 6e28 2920 636f 6e73 7420 3d20 303b ion() const = 0; │ │ │ -0007c700: 0a09 0976 6972 7475 616c 2073 7464 3a3a ...virtual std:: │ │ │ -0007c710: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ -0007c720: 3b20 6c6f 6361 6c5f 6932 705f 656e 6470 ; local_i2p_endp │ │ │ -0007c730: 6f69 6e74 2829 2063 6f6e 7374 203d 2030 oint() const = 0 │ │ │ -0007c740: 3b0a 2365 6e64 6966 0a0a 0909 7669 7274 ;.#endif....virt │ │ │ -0007c750: 7561 6c20 766f 6964 2070 7269 6f72 6974 ual void priorit │ │ │ -0007c760: 697a 655f 636f 6e6e 6563 7469 6f6e 7328 ize_connections( │ │ │ -0007c770: 7374 643a 3a77 6561 6b5f 7074 7226 6c74 std::weak_ptr< │ │ │ -0007c780: 3b74 6f72 7265 6e74 2667 743b 2074 2920 ;torrent> t) │ │ │ -0007c790: 3d20 303b 0a0a 0909 7669 7274 7561 6c20 = 0;....virtual │ │ │ -0007c7a0: 766f 6964 2074 7269 6767 6572 5f61 7574 void trigger_aut │ │ │ -0007c7b0: 6f5f 6d61 6e61 6765 2829 203d 2030 3b0a o_manage() = 0;. │ │ │ -0007c7c0: 0a09 0976 6972 7475 616c 2076 6f69 6420 ...virtual void │ │ │ -0007c7d0: 6170 706c 795f 7365 7474 696e 6773 5f70 apply_settings_p │ │ │ -0007c7e0: 6163 6b28 7374 643a 3a73 6861 7265 645f ack(std::shared_ │ │ │ -0007c7f0: 7074 7226 6c74 3b73 6574 7469 6e67 735f ptr<settings_ │ │ │ -0007c800: 7061 636b 2667 743b 2070 6163 6b29 203d pack> pack) = │ │ │ -0007c810: 2030 3b0a 0909 7669 7274 7561 6c20 7365 0;...virtual se │ │ │ -0007c820: 7373 696f 6e5f 7365 7474 696e 6773 2063 ssion_settings c │ │ │ -0007c830: 6f6e 7374 2661 6d70 3b20 7365 7474 696e onst& settin │ │ │ -0007c840: 6773 2829 2063 6f6e 7374 203d 2030 3b0a gs() const = 0;. │ │ │ -0007c850: 0a09 0976 6972 7475 616c 2076 6f69 6420 ...virtual void │ │ │ -0007c860: 7175 6575 655f 7472 6163 6b65 725f 7265 queue_tracker_re │ │ │ -0007c870: 7175 6573 7428 6175 783a 3a74 7261 636b quest(aux::track │ │ │ -0007c880: 6572 5f72 6571 7565 7374 2072 6571 0a09 er_request req.. │ │ │ -0007c890: 0909 2c20 7374 643a 3a77 6561 6b5f 7074 .., std::weak_pt │ │ │ -0007c8a0: 7226 6c74 3b61 7578 3a3a 7265 7175 6573 r<aux::reques │ │ │ -0007c8b0: 745f 6361 6c6c 6261 636b 2667 743b 2063 t_callback> c │ │ │ -0007c8c0: 2920 3d20 303b 0a0a 0909 2f2f 2070 6565 ) = 0;....// pee │ │ │ -0007c8d0: 722d 636c 6173 7365 730a 0909 7669 7274 r-classes...virt │ │ │ -0007c8e0: 7561 6c20 766f 6964 2073 6574 5f70 6565 ual void set_pee │ │ │ -0007c8f0: 725f 636c 6173 7365 7328 7065 6572 5f63 r_classes(peer_c │ │ │ -0007c900: 6c61 7373 5f73 6574 2a20 732c 2061 6464 lass_set* s, add │ │ │ -0007c910: 7265 7373 2063 6f6e 7374 2661 6d70 3b20 ress const& │ │ │ -0007c920: 612c 2073 6f63 6b65 745f 7479 7065 5f74 a, socket_type_t │ │ │ -0007c930: 2073 7429 203d 2030 3b0a 0909 7669 7274 st) = 0;...virt │ │ │ -0007c940: 7561 6c20 7065 6572 5f63 6c61 7373 5f70 ual peer_class_p │ │ │ -0007c950: 6f6f 6c20 636f 6e73 7426 616d 703b 2070 ool const& p │ │ │ -0007c960: 6565 725f 636c 6173 7365 7328 2920 636f eer_classes() co │ │ │ -0007c970: 6e73 7420 3d20 303b 0a09 0976 6972 7475 nst = 0;...virtu │ │ │ -0007c980: 616c 2070 6565 725f 636c 6173 735f 706f al peer_class_po │ │ │ -0007c990: 6f6c 2661 6d70 3b20 7065 6572 5f63 6c61 ol& peer_cla │ │ │ -0007c9a0: 7373 6573 2829 203d 2030 3b0a 0909 7669 sses() = 0;...vi │ │ │ -0007c9b0: 7274 7561 6c20 626f 6f6c 2069 676e 6f72 rtual bool ignor │ │ │ -0007c9c0: 655f 756e 6368 6f6b 655f 736c 6f74 735f e_unchoke_slots_ │ │ │ -0007c9d0: 7365 7428 7065 6572 5f63 6c61 7373 5f73 set(peer_class_s │ │ │ -0007c9e0: 6574 2063 6f6e 7374 2661 6d70 3b20 7365 et const& se │ │ │ -0007c9f0: 7429 2063 6f6e 7374 203d 2030 3b0a 0909 t) const = 0;... │ │ │ -0007ca00: 7669 7274 7561 6c20 696e 7420 636f 7079 virtual int copy │ │ │ -0007ca10: 5f70 6572 7469 6e65 6e74 5f63 6861 6e6e _pertinent_chann │ │ │ -0007ca20: 656c 7328 7065 6572 5f63 6c61 7373 5f73 els(peer_class_s │ │ │ -0007ca30: 6574 2063 6f6e 7374 2661 6d70 3b20 7365 et const& se │ │ │ -0007ca40: 740a 0909 092c 2069 6e74 2063 6861 6e6e t...., int chann │ │ │ -0007ca50: 656c 2c20 6261 6e64 7769 6474 685f 6368 el, bandwidth_ch │ │ │ -0007ca60: 616e 6e65 6c2a 2a20 6473 742c 2069 6e74 annel** dst, int │ │ │ -0007ca70: 206d 2920 3d20 303b 0a09 0976 6972 7475 m) = 0;...virtu │ │ │ -0007ca80: 616c 2073 7464 3a3a 7569 6e74 385f 7420 al std::uint8_t │ │ │ -0007ca90: 7573 655f 7175 6f74 615f 6f76 6572 6865 use_quota_overhe │ │ │ -0007caa0: 6164 2870 6565 725f 636c 6173 735f 7365 ad(peer_class_se │ │ │ -0007cab0: 7426 616d 703b 2073 6574 2c20 696e 7420 t& set, int │ │ │ -0007cac0: 616d 6f75 6e74 5f64 6f77 6e2c 2069 6e74 amount_down, int │ │ │ -0007cad0: 2061 6d6f 756e 745f 7570 2920 3d20 303b amount_up) = 0; │ │ │ -0007cae0: 0a0a 0909 7669 7274 7561 6c20 6261 6e64 ....virtual band │ │ │ -0007caf0: 7769 6474 685f 6d61 6e61 6765 722a 2067 width_manager* g │ │ │ -0007cb00: 6574 5f62 616e 6477 6964 7468 5f6d 616e et_bandwidth_man │ │ │ -0007cb10: 6167 6572 2869 6e74 2063 6861 6e6e 656c ager(int channel │ │ │ -0007cb20: 2920 3d20 303b 0a0a 0909 7669 7274 7561 ) = 0;....virtua │ │ │ -0007cb30: 6c20 766f 6964 2073 656e 745f 6279 7465 l void sent_byte │ │ │ -0007cb40: 7328 696e 7420 6279 7465 735f 7061 796c s(int bytes_payl │ │ │ -0007cb50: 6f61 642c 2069 6e74 2062 7974 6573 5f70 oad, int bytes_p │ │ │ -0007cb60: 726f 746f 636f 6c29 203d 2030 3b0a 0909 rotocol) = 0;... │ │ │ -0007cb70: 7669 7274 7561 6c20 766f 6964 2072 6563 virtual void rec │ │ │ -0007cb80: 6569 7665 645f 6279 7465 7328 696e 7420 eived_bytes(int │ │ │ -0007cb90: 6279 7465 735f 7061 796c 6f61 642c 2069 bytes_payload, i │ │ │ -0007cba0: 6e74 2062 7974 6573 5f70 726f 746f 636f nt bytes_protoco │ │ │ -0007cbb0: 6c29 203d 2030 3b0a 3c2f 7072 653e 3c2f l) = 0;.
    relevan │ │ │ -0007cbf0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -0007cc30: 6274 6f72 7265 6e74 2f61 7578 5f2f 6465 btorrent/aux_/de │ │ │ -0007cc40: 7072 6563 6174 6564 2e68 7070 3a32 343c precated.hpp:24< │ │ │ -0007cc50: 2f61 3e3c 2f74 643e 3c74 643e 6669 6775 /a>figu │ │ │ -0007cc60: 7265 206f 7574 2077 6869 6368 2076 6572 re out which ver │ │ │ -0007cc70: 7369 6f6e 206f 6620 636c 616e 6720 7468 sion of clang th │ │ │ -0007cc80: 6973 2069 7320 7375 7070 6f72 7465 6420 is is supported │ │ │ -0007cc90: 696e 3c2f 7464 3e3c 2f74 723e 3c74 7220 in

    │ │ │ -0007cce0: 6669 6775 7265 206f 7574 2077 6869 6368 figure out which │ │ │ -0007ccf0: 2076 6572 7369 6f6e 206f 6620 636c 616e version of clan │ │ │ -0007cd00: 6720 7468 6973 2069 7320 7375 7070 6f72 g this is suppor │ │ │ -0007cd10: 7465 6420 696e 3c2f 6832 3e3c 6834 3e2e ted in

    . │ │ │ -0007cd20: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007cd30: 7265 6e74 2f61 7578 5f2f 6465 7072 6563 rent/aux_/deprec │ │ │ -0007cd40: 6174 6564 2e68 7070 3a32 343c 2f68 343e ated.hpp:24

    │ │ │ -0007cd50: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    All ri
    │ │ │ -0007cd90: 6768 7473 2072 6573 6572 7665 642e 0a0a  ghts reserved...
    │ │ │ -0007cda0: 596f 7520 6d61 7920 7573 652c 2064 6973  You may use, dis
    │ │ │ -0007cdb0: 7472 6962 7574 6520 616e 6420 6d6f 6469  tribute and modi
    │ │ │ -0007cdc0: 6679 2074 6869 7320 636f 6465 2075 6e64  fy this code und
    │ │ │ -0007cdd0: 6572 2074 6865 2074 6572 6d73 206f 6620  er the terms of 
    │ │ │ -0007cde0: 7468 6520 4253 4420 6c69 6365 6e73 652c  the BSD license,
    │ │ │ -0007cdf0: 0a73 6565 204c 4943 454e 5345 2066 696c  .see LICENSE fil
    │ │ │ -0007ce00: 652e 0a2a 2f0a 0a23 6966 6e64 6566 2054  e..*/..#ifndef T
    │ │ │ -0007ce10: 4f52 5245 4e54 5f44 4550 5245 4341 5445  ORRENT_DEPRECATE
    │ │ │ -0007ce20: 445f 4850 505f 494e 434c 5544 4544 0a23  D_HPP_INCLUDED.#
    │ │ │ -0007ce30: 6465 6669 6e65 2054 4f52 5245 4e54 5f44  define TORRENT_D
    │ │ │ -0007ce40: 4550 5245 4341 5445 445f 4850 505f 494e  EPRECATED_HPP_IN
    │ │ │ -0007ce50: 434c 5544 4544 0a0a 2369 6620 2164 6566  CLUDED..#if !def
    │ │ │ -0007ce60: 696e 6564 2054 4f52 5245 4e54 5f42 5549  ined TORRENT_BUI
    │ │ │ -0007ce70: 4c44 494e 475f 4c49 4252 4152 590a 2320  LDING_LIBRARY.# 
    │ │ │ -0007ce80: 6465 6669 6e65 2054 4f52 5245 4e54 5f44  define TORRENT_D
    │ │ │ -0007ce90: 4550 5245 4341 5445 4420 5b5b 6465 7072  EPRECATED [[depr
    │ │ │ -0007cea0: 6563 6174 6564 5d5d 0a23 656c 7365 0a23  ecated]].#else.#
    │ │ │ -0007ceb0: 2064 6566 696e 6520 544f 5252 454e 545f   define TORRENT_
    │ │ │ -0007cec0: 4445 5052 4543 4154 4544 0a23 656e 6469  DEPRECATED.#endi
    │ │ │ -0007ced0: 660a 0a23 6966 2064 6566 696e 6564 205f  f..#if defined _
    │ │ │ -0007cee0: 5f63 6c61 6e67 5f5f 0a0a 2f2f 203d 3d3d  _clang__..// ===
    │ │ │ -0007cef0: 3d3d 3d20 434c 414e 4720 3d3d 3d3d 3d3d  === CLANG ======
    │ │ │ -0007cf00: 3d3d 0a0a 2320 6966 2021 6465 6669 6e65  ==..# if !define
    │ │ │ -0007cf10: 6420 544f 5252 454e 545f 4255 494c 4449  d TORRENT_BUILDI
    │ │ │ -0007cf20: 4e47 5f4c 4942 5241 5259 0a3c 6469 7620  NG_LIBRARY.
    # defi │ │ │ -0007cf60: 6e65 2054 4f52 5245 4e54 5f44 4550 5245 ne TORRENT_DEPRE │ │ │ -0007cf70: 4341 5445 445f 454e 554d 205f 5f61 7474 CATED_ENUM __att │ │ │ -0007cf80: 7269 6275 7465 5f5f 2028 2864 6570 7265 ribute__ ((depre │ │ │ -0007cf90: 6361 7465 6429 290a 3c2f 6469 763e 2320 cated)).
    # │ │ │ -0007cfa0: 656e 6469 660a 0a23 656c 6966 2064 6566 endif..#elif def │ │ │ -0007cfb0: 696e 6564 205f 5f47 4e55 435f 5f0a 0a2f ined __GNUC__../ │ │ │ -0007cfc0: 2f20 3d3d 3d3d 3d3d 3d3d 2047 4343 203d / ======== GCC = │ │ │ -0007cfd0: 3d3d 3d3d 3d3d 3d0a 0a2f 2f20 6465 7072 =======..// depr │ │ │ -0007cfe0: 6563 6174 696f 6e20 6d61 726b 7570 2069 ecation markup i │ │ │ -0007cff0: 7320 6f6e 6c79 2065 6e61 626c 6564 2077 s only enabled w │ │ │ -0007d000: 6865 6e20 6c69 6274 6f72 7265 6e74 0a2f hen libtorrent./ │ │ │ -0007d010: 2f20 6865 6164 6572 7320 6172 6520 696e / headers are in │ │ │ -0007d020: 636c 7564 6564 2062 7920 636c 6965 6e74 cluded by client │ │ │ -0007d030: 732c 206e 6f74 2077 6869 6c65 2062 7569 s, not while bui │ │ │ -0007d040: 6c64 696e 670a 2f2f 206c 6962 746f 7272 lding.// libtorr │ │ │ -0007d050: 656e 7420 6974 7365 6c66 0a23 2069 6620 ent itself.# if │ │ │ -0007d060: 5f5f 474e 5543 5f5f 2026 6774 3b3d 2036 __GNUC__ >= 6 │ │ │ -0007d070: 2026 616d 703b 2661 6d70 3b20 2164 6566 && !def │ │ │ -0007d080: 696e 6564 2054 4f52 5245 4e54 5f42 5549 ined TORRENT_BUI │ │ │ -0007d090: 4c44 494e 475f 4c49 4252 4152 590a 2320 LDING_LIBRARY.# │ │ │ -0007d0a0: 2064 6566 696e 6520 544f 5252 454e 545f define TORRENT_ │ │ │ -0007d0b0: 4445 5052 4543 4154 4544 5f45 4e55 4d20 DEPRECATED_ENUM │ │ │ -0007d0c0: 5f5f 6174 7472 6962 7574 655f 5f20 2828 __attribute__ (( │ │ │ -0007d0d0: 6465 7072 6563 6174 6564 2929 0a23 2065 deprecated)).# e │ │ │ -0007d0e0: 6e64 6966 0a0a 2365 6e64 6966 0a0a 2369 ndif..#endif..#i │ │ │ -0007d0f0: 666e 6465 6620 544f 5252 454e 545f 4445 fndef TORRENT_DE │ │ │ -0007d100: 5052 4543 4154 4544 5f45 4e55 4d0a 2364 PRECATED_ENUM.#d │ │ │ -0007d110: 6566 696e 6520 544f 5252 454e 545f 4445 efine TORRENT_DE │ │ │ -0007d120: 5052 4543 4154 4544 5f45 4e55 4d0a 2365 PRECATED_ENUM.#e │ │ │ -0007d130: 6e64 6966 0a0a 2365 6e64 6966 0a3c 2f70 ndif..#endif.

    re │ │ │ -0007d170: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ -0007d1b0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007d1c0: 785f 2f74 6f72 7265 6e74 5f70 6565 722e x_/torrent_peer. │ │ │ -0007d1d0: 6870 703a 3232 383c 2f61 3e3c 2f74 643e hpp:228 │ │ │ -0007d1e0: 3c74 643e 5468 6973 2064 6573 7469 6e61 This destina │ │ │ -0007d1f0: 7469 6f6e 2073 686f 756c 6420 7072 6f62 tion should prob │ │ │ -0007d200: 6162 6c79 2062 6520 6b65 7074 2069 6e20 ably be kept in │ │ │ -0007d210: 6269 6e61 7279 2066 6f72 6d20 2872 6174 binary form (rat │ │ │ -0007d220: 6865 7220 7468 616e 2062 6173 6536 3429 her than base64) │ │ │ -0007d230: 2e20 5468 6520 7065 6572 7320 7368 6f75 . The peers shou │ │ │ -0007d240: 6c64 2070 7269 6d61 7269 6c79 2062 6520 ld primarily be │ │ │ -0007d250: 6861 6e64 6c65 6420 6279 2074 6865 6972 handled by their │ │ │ -0007d260: 2073 6861 3235 3620 6861 7368 206f 6620 sha256 hash of │ │ │ -0007d270: 7468 6520 6465 7374 696e 6174 696f 6e2c the destination, │ │ │ -0007d280: 2074 6861 7420 7368 6f75 6c64 2062 6520 that should be │ │ │ -0007d290: 6b65 7074 2069 6e20 6865 7265 2061 7320 kept in here as │ │ │ -0007d2a0: 7765 6c6c 2e3c 2f74 643e 3c2f 7472 3e3c well.< │ │ │ -0007d2b0: 7472 2069 643d 2232 3836 2220 7374 796c tr id="286" styl │ │ │ -0007d2c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0007d2d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0007d2e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0007d2f0: 6832 3e54 6869 7320 6465 7374 696e 6174 h2>This destinat │ │ │ -0007d300: 696f 6e20 7368 6f75 6c64 2070 726f 6261 ion should proba │ │ │ -0007d310: 626c 7920 6265 206b 6570 7420 696e 2062 bly be kept in b │ │ │ -0007d320: 696e 6172 7920 666f 726d 2028 7261 7468 inary form (rath │ │ │ -0007d330: 6572 2074 6861 6e0a 6261 7365 3634 292e er than.base64). │ │ │ -0007d340: 2054 6865 2070 6565 7273 2073 686f 756c The peers shoul │ │ │ -0007d350: 6420 7072 696d 6172 696c 7920 6265 2068 d primarily be h │ │ │ -0007d360: 616e 646c 6564 2062 7920 7468 6569 7220 andled by their │ │ │ -0007d370: 7368 6132 3536 2068 6173 680a 6f66 2074 sha256 hash.of t │ │ │ -0007d380: 6865 2064 6573 7469 6e61 7469 6f6e 2c20 he destination, │ │ │ -0007d390: 7468 6174 2073 686f 756c 6420 6265 206b that should be k │ │ │ -0007d3a0: 6570 7420 696e 2068 6572 6520 6173 2077 ept in here as w │ │ │ -0007d3b0: 656c 6c2e 3c2f 6832 3e3c 6834 3e2e 2e2f ell.

    ../ │ │ │ -0007d3c0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007d3d0: 6e74 2f61 7578 5f2f 746f 7272 656e 745f nt/aux_/torrent_ │ │ │ -0007d3e0: 7065 6572 2e68 7070 3a32 3238 3c2f 6834 peer.hpp:228

    .};..
    │ │ │ -0007d430: 0973 7472 7563 7420 544f 5252 454e 545f  .struct TORRENT_
    │ │ │ -0007d440: 4558 5452 415f 4558 504f 5254 2069 7076  EXTRA_EXPORT ipv
    │ │ │ -0007d450: 345f 7065 6572 203a 2074 6f72 7265 6e74  4_peer : torrent
    │ │ │ -0007d460: 5f70 6565 720a 097b 0a09 0969 7076 345f  _peer..{...ipv4_
    │ │ │ -0007d470: 7065 6572 2874 6370 3a3a 656e 6470 6f69  peer(tcp::endpoi
    │ │ │ -0007d480: 6e74 2063 6f6e 7374 2661 6d70 3b20 6570  nt const& ep
    │ │ │ -0007d490: 2c20 626f 6f6c 2063 6f6e 6e65 6374 6162  , bool connectab
    │ │ │ -0007d4a0: 6c65 2c20 7065 6572 5f73 6f75 7263 655f  le, peer_source_
    │ │ │ -0007d4b0: 666c 6167 735f 7420 7372 6329 3b0a 0909  flags_t src);...
    │ │ │ -0007d4c0: 6970 7634 5f70 6565 7228 6970 7634 5f70  ipv4_peer(ipv4_p
    │ │ │ -0007d4d0: 6565 7220 636f 6e73 7426 616d 703b 2070  eer const& p
    │ │ │ -0007d4e0: 293b 0a09 0969 7076 345f 7065 6572 2661  );...ipv4_peer&a
    │ │ │ -0007d4f0: 6d70 3b20 6f70 6572 6174 6f72 3d28 6970  mp; operator=(ip
    │ │ │ -0007d500: 7634 5f70 6565 7220 636f 6e73 7426 616d  v4_peer const&am
    │ │ │ -0007d510: 703b 2070 2920 2661 6d70 3b3b 0a0a 0909  p; p) &;....
    │ │ │ -0007d520: 6164 6472 6573 735f 7634 2061 6464 723b  address_v4 addr;
    │ │ │ -0007d530: 0a09 7d3b 0a0a 2369 6620 544f 5252 454e  ..};..#if TORREN
    │ │ │ -0007d540: 545f 5553 455f 4932 500a 0973 7472 7563  T_USE_I2P..struc
    │ │ │ -0007d550: 7420 544f 5252 454e 545f 4558 5452 415f  t TORRENT_EXTRA_
    │ │ │ -0007d560: 4558 504f 5254 2069 3270 5f70 6565 7220  EXPORT i2p_peer 
    │ │ │ -0007d570: 3a20 746f 7272 656e 745f 7065 6572 0a09  : torrent_peer..
    │ │ │ -0007d580: 7b0a 0909 6932 705f 7065 6572 2873 7472  {...i2p_peer(str
    │ │ │ -0007d590: 696e 675f 7669 6577 2064 6573 742c 2062  ing_view dest, b
    │ │ │ -0007d5a0: 6f6f 6c20 636f 6e6e 6563 7461 626c 652c  ool connectable,
    │ │ │ -0007d5b0: 2070 6565 725f 736f 7572 6365 5f66 6c61   peer_source_fla
    │ │ │ -0007d5c0: 6773 5f74 2073 7263 293b 0a09 0969 3270  gs_t src);...i2p
    │ │ │ -0007d5d0: 5f70 6565 7228 6932 705f 7065 6572 2063  _peer(i2p_peer c
    │ │ │ -0007d5e0: 6f6e 7374 2661 6d70 3b29 203d 2064 656c  onst&) = del
    │ │ │ -0007d5f0: 6574 653b 0a09 0969 3270 5f70 6565 7226  ete;...i2p_peer&
    │ │ │ -0007d600: 616d 703b 206f 7065 7261 746f 723d 2869  amp; operator=(i
    │ │ │ -0007d610: 3270 5f70 6565 7220 636f 6e73 7426 616d  2p_peer const&am
    │ │ │ -0007d620: 703b 2920 3d20 6465 6c65 7465 3b0a 0909  p;) = delete;...
    │ │ │ -0007d630: 6932 705f 7065 6572 2869 3270 5f70 6565  i2p_peer(i2p_pee
    │ │ │ -0007d640: 7226 616d 703b 2661 6d70 3b29 203d 2064  r&&) = d
    │ │ │ -0007d650: 6566 6175 6c74 3b0a 0909 6932 705f 7065  efault;...i2p_pe
    │ │ │ -0007d660: 6572 2661 6d70 3b20 6f70 6572 6174 6f72  er& operator
    │ │ │ -0007d670: 3d28 6932 705f 7065 6572 2661 6d70 3b26  =(i2p_peer&&
    │ │ │ -0007d680: 616d 703b 2920 2661 6d70 3b20 3d20 6465  amp;) & = de
    │ │ │ -0007d690: 6661 756c 743b 0a0a 3c64 6976 2073 7479  fault;..
    ..aux::str │ │ │ -0007d6d0: 696e 675f 7074 7220 6465 7374 696e 6174 ing_ptr destinat │ │ │ -0007d6e0: 696f 6e3b 0a3c 2f64 6976 3e09 7d3b 0a23 ion;.
    .};.# │ │ │ -0007d6f0: 656e 6469 660a 0a23 6966 2054 4f52 5245 endif..#if TORRE │ │ │ -0007d700: 4e54 5f55 5345 5f52 5443 0a09 7374 7275 NT_USE_RTC..stru │ │ │ -0007d710: 6374 2054 4f52 5245 4e54 5f45 5854 5241 ct TORRENT_EXTRA │ │ │ -0007d720: 5f45 5850 4f52 5420 7274 635f 7065 6572 _EXPORT rtc_peer │ │ │ -0007d730: 203a 2074 6f72 7265 6e74 5f70 6565 720a : torrent_peer. │ │ │ -0007d740: 097b 0a09 0972 7463 5f70 6565 7228 7463 .{...rtc_peer(tc │ │ │ -0007d750: 703a 3a65 6e64 706f 696e 7420 6570 2c20 p::endpoint ep, │ │ │ -0007d760: 7065 6572 5f73 6f75 7263 655f 666c 6167 peer_source_flag │ │ │ -0007d770: 735f 7420 7372 6329 3b0a 0909 7274 635f s_t src);...rtc_ │ │ │ -0007d780: 7065 6572 2872 7463 5f70 6565 7220 636f peer(rtc_peer co │ │ │ -0007d790: 6e73 7426 616d 703b 2920 3d20 6465 6c65 nst&) = dele │ │ │ -0007d7a0: 7465 3b0a 0909 7274 635f 7065 6572 2661 te;...rtc_peer&a │ │ │ -0007d7b0: 6d70 3b20 6f70 6572 6174 6f72 3d28 7274 mp; operator=(rt │ │ │ -0007d7c0: 635f 7065 6572 2063 6f6e 7374 2661 6d70 c_peer const& │ │ │ -0007d7d0: 3b29 203d 2064 656c 6574 653b 0a09 0972 ;) = delete;...r │ │ │ -0007d7e0: 7463 5f70 6565 7228 7274 635f 7065 6572 tc_peer(rtc_peer │ │ │ -0007d7f0: 2661 6d70 3b26 616d 703b 2920 3d20 6465 &&) = de │ │ │ -0007d800: 6661 756c 743b 0a09 0972 7463 5f70 6565 fault;...rtc_pee │ │ │ -0007d810: 7226 616d 703b 206f 7065 7261 746f 723d r& operator= │ │ │ -0007d820: 2872 7463 5f70 6565 7226 616d 703b 2661 (rtc_peer&&a │ │ │ -0007d830: 6d70 3b29 2026 616d 703b 203d 2064 6566 mp;) & = def │ │ │ -0007d840: 6175 6c74 3b0a 0a09 0974 6370 3a3a 656e ault;....tcp::en │ │ │ -0007d850: 6470 6f69 6e74 2065 6e64 706f 696e 743b dpoint endpoint; │ │ │ -0007d860: 0a09 7d3b 0a23 656e 6469 660a 0a09 7374 ..};.#endif...st │ │ │ -0007d870: 7275 6374 2054 4f52 5245 4e54 5f45 5854 ruct TORRENT_EXT │ │ │ -0007d880: 5241 5f45 5850 4f52 5420 6970 7636 5f70 RA_EXPORT ipv6_p │ │ │ -0007d890: 6565 7220 3a20 746f 7272 656e 745f 7065 eer : torrent_pe │ │ │ -0007d8a0: 6572 0a09 7b0a 0909 6970 7636 5f70 6565 er..{...ipv6_pee │ │ │ -0007d8b0: 7228 7463 703a 3a65 6e64 706f 696e 7420 r(tcp::endpoint │ │ │ -0007d8c0: 636f 6e73 7426 616d 703b 2065 702c 2062 const& ep, b │ │ │ -0007d8d0: 6f6f 6c20 636f 6e6e 6563 7461 626c 652c ool connectable, │ │ │ -0007d8e0: 2070 6565 725f 736f 7572 6365 5f66 6c61 peer_source_fla │ │ │ -0007d8f0: 6773 5f74 2073 7263 293b 0a09 0969 7076 gs_t src);...ipv │ │ │ -0007d900: 365f 7065 6572 2869 7076 365f 7065 6572 6_peer(ipv6_peer │ │ │ -0007d910: 2063 6f6e 7374 2661 6d70 3b20 7029 3b0a const& p);. │ │ │ -0007d920: 0a09 0963 6f6e 7374 2061 6464 7265 7373 ...const address │ │ │ -0007d930: 5f76 363a 3a62 7974 6573 5f74 7970 6520 _v6::bytes_type │ │ │ -0007d940: 6164 6472 3b0a 097d 3b0a 0a09 2f2f 2069 addr;..};...// i │ │ │ -0007d950: 6620 7765 2068 6176 6520 6932 7020 7065 f we have i2p pe │ │ │ -0007d960: 6572 2061 6464 7265 7373 6573 2c20 736f er addresses, so │ │ │ -0007d970: 7274 2074 6865 6d20 2a61 6674 6572 2a20 rt them *after* │ │ │ -0007d980: 616c 6c20 4950 2061 6464 7265 7373 6573 all IP addresses │ │ │ -0007d990: 0a09 7374 7275 6374 2070 6565 725f 6164 ..struct peer_ad │ │ │ -0007d9a0: 6472 6573 735f 636f 6d70 6172 650a 097b dress_compare..{ │ │ │ -0007d9b0: 0a09 0962 6f6f 6c20 6f70 6572 6174 6f72 ...bool operator │ │ │ -0007d9c0: 2829 2874 6f72 7265 6e74 5f70 6565 7220 ()(torrent_peer │ │ │ -0007d9d0: 636f 6e73 742a 206c 6873 2c20 6164 6472 const* lhs, addr │ │ │ -0007d9e0: 6573 7320 636f 6e73 7426 616d 703b 2072 ess const& r │ │ │ -0007d9f0: 6873 2920 636f 6e73 740a 0909 7b0a 2369 hs) const...{.#i │ │ │ -0007da00: 6620 544f 5252 454e 545f 5553 455f 4932 f TORRENT_USE_I2 │ │ │ -0007da10: 500a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 P.
    < │ │ │ -0007da40: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0007da50: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0007da80: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007da90: 6e74 2f61 7578 5f2f 6469 736b 5f63 6163 nt/aux_/disk_cac │ │ │ -0007daa0: 6865 2e68 7070 3a33 3432 3c2f 613e 3c2f he.hpp:342it would │ │ │ -0007dac0: 6265 206e 6963 6520 6966 2074 6869 7320 be nice if this │ │ │ -0007dad0: 636f 756c 6420 6265 2063 616c 6c65 6420 could be called │ │ │ -0007dae0: 7769 7468 6f75 7420 686f 6c64 696e 6720 without holding │ │ │ -0007daf0: 7468 6520 6d75 7465 782e 2049 7420 776f the mutex. It wo │ │ │ -0007db00: 756c 6420 7265 7175 6972 6520 6265 696e uld require bein │ │ │ -0007db10: 6720 6162 6c65 2074 6f20 6c6f 636b 2074 g able to lock t │ │ │ -0007db20: 6865 2070 6965 6365 3c2f 7464 3e3c 2f74 he piece

    it would b │ │ │ -0007db80: 6520 6e69 6365 2069 6620 7468 6973 2063 e nice if this c │ │ │ -0007db90: 6f75 6c64 2062 6520 6361 6c6c 6564 2077 ould be called w │ │ │ -0007dba0: 6974 686f 7574 2068 6f6c 6469 6e67 0a74 ithout holding.t │ │ │ -0007dbb0: 6865 206d 7574 6578 2e20 4974 2077 6f75 he mutex. It wou │ │ │ -0007dbc0: 6c64 2072 6571 7569 7265 2062 6569 6e67 ld require being │ │ │ -0007dbd0: 2061 626c 6520 746f 206c 6f63 6b20 7468 able to lock th │ │ │ -0007dbe0: 6520 7069 6563 653c 2f68 323e 3c68 343e e piece

    │ │ │ -0007dbf0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007dc00: 7272 656e 742f 6175 785f 2f64 6973 6b5f rrent/aux_/disk_ │ │ │ -0007dc10: 6361 6368 652e 6870 703a 3334 323c 2f68 cache.hpp:342
    ..mi
    │ │ │ -0007dc60: 3a3a 6861 7368 6564 5f75 6e69 7175 6526  ::hashed_unique&
    │ │ │ -0007dc70: 6c74 3b6d 693a 3a6d 656d 6265 7226 6c74  lt;mi::member<
    │ │ │ -0007dc80: 3b63 6163 6865 645f 7069 6563 655f 656e  ;cached_piece_en
    │ │ │ -0007dc90: 7472 792c 2070 6965 6365 5f6c 6f63 6174  try, piece_locat
    │ │ │ -0007dca0: 696f 6e2c 2026 616d 703b 6361 6368 6564  ion, &cached
    │ │ │ -0007dcb0: 5f70 6965 6365 5f65 6e74 7279 3a3a 7069  _piece_entry::pi
    │ │ │ -0007dcc0: 6563 6526 6774 3b26 6774 3b2c 0a09 092f  ece>>,.../
    │ │ │ -0007dcd0: 2f20 6f72 6465 7265 6420 6279 2077 6865  / ordered by whe
    │ │ │ -0007dce0: 7468 6572 2074 6865 2070 6965 6365 206e  ther the piece n
    │ │ │ -0007dcf0: 6565 6473 2069 7473 2068 6173 6865 7220  eeds its hasher 
    │ │ │ -0007dd00: 6b69 636b 6564 2e0a 0909 2f2f 2074 7275  kicked....// tru
    │ │ │ -0007dd10: 6520 6973 206f 7264 6572 6564 2062 6566  e is ordered bef
    │ │ │ -0007dd20: 6f72 6520 6661 6c73 652c 2073 6f20 7069  ore false, so pi
    │ │ │ -0007dd30: 6563 6573 206e 6565 6469 6e67 2061 206b  eces needing a k
    │ │ │ -0007dd40: 6963 6b20 636f 6d65 2066 6972 7374 2e0a  ick come first..
    │ │ │ -0007dd50: 0909 6d69 3a3a 6f72 6465 7265 645f 6e6f  ..mi::ordered_no
    │ │ │ -0007dd60: 6e5f 756e 6971 7565 266c 743b 6d69 3a3a  n_unique<mi::
    │ │ │ -0007dd70: 636f 6e73 745f 6d65 6d5f 6675 6e26 6c74  const_mem_fun<
    │ │ │ -0007dd80: 3b63 6163 6865 645f 7069 6563 655f 656e  ;cached_piece_en
    │ │ │ -0007dd90: 7472 792c 2062 6f6f 6c2c 2026 616d 703b  try, bool, &
    │ │ │ -0007dda0: 6361 6368 6564 5f70 6965 6365 5f65 6e74  cached_piece_ent
    │ │ │ -0007ddb0: 7279 3a3a 6e65 6564 735f 6861 7368 6572  ry::needs_hasher
    │ │ │ -0007ddc0: 5f6b 6963 6b26 6774 3b2c 2073 7464 3a3a  _kick>, std::
    │ │ │ -0007ddd0: 6772 6561 7465 7226 6c74 3b76 6f69 6426  greater<void&
    │ │ │ -0007dde0: 6774 3b26 6774 3b0a 0909 2667 743b 0a09  gt;>...>..
    │ │ │ -0007ddf0: 2667 743b 3b0a 0a09 7465 6d70 6c61 7465  >;...template
    │ │ │ -0007de00: 2026 6c74 3b74 7970 656e 616d 6520 4675   <typename Fu
    │ │ │ -0007de10: 6e26 6774 3b0a 0962 6f6f 6c20 6765 7428  n>..bool get(
    │ │ │ -0007de20: 7069 6563 655f 6c6f 6361 7469 6f6e 2063  piece_location c
    │ │ │ -0007de30: 6f6e 7374 206c 6f63 2c20 696e 7420 636f  onst loc, int co
    │ │ │ -0007de40: 6e73 7420 626c 6f63 6b5f 6964 782c 2046  nst block_idx, F
    │ │ │ -0007de50: 756e 2066 2920 636f 6e73 740a 097b 0a09  un f) const..{..
    │ │ │ -0007de60: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63  .std::unique_loc
    │ │ │ -0007de70: 6b26 6c74 3b73 7464 3a3a 6d75 7465 7826  k<std::mutex&
    │ │ │ -0007de80: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a  gt; l(m_mutex);.
    │ │ │ -0007de90: 0a09 0949 4e56 4152 4941 4e54 5f43 4845  ...INVARIANT_CHE
    │ │ │ -0007dea0: 434b 3b0a 0a09 0961 7574 6f26 616d 703b  CK;....auto&
    │ │ │ -0007deb0: 2076 6965 7720 3d20 6d5f 7069 6563 6573   view = m_pieces
    │ │ │ -0007dec0: 2e74 656d 706c 6174 6520 6765 7426 6c74  .template get<
    │ │ │ -0007ded0: 3b30 2667 743b 2829 3b0a 0909 6175 746f  ;0>();...auto
    │ │ │ -0007dee0: 2069 203d 2076 6965 772e 6669 6e64 286c   i = view.find(l
    │ │ │ -0007def0: 6f63 293b 0a09 0969 6620 2869 203d 3d20  oc);...if (i == 
    │ │ │ -0007df00: 7669 6577 2e65 6e64 2829 2920 7265 7475  view.end()) retu
    │ │ │ -0007df10: 726e 2066 616c 7365 3b0a 0a09 0969 6620  rn false;....if 
    │ │ │ -0007df20: 2869 2d26 6774 3b62 6c6f 636b 735b 626c  (i->blocks[bl
    │ │ │ -0007df30: 6f63 6b5f 6964 785d 2e64 6174 6128 2929  ock_idx].data())
    │ │ │ -0007df40: 0a09 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    ...int const │ │ │ -0007df80: 626c 6b5f 7369 7a65 203d 2073 7464 3a3a blk_size = std:: │ │ │ -0007df90: 6d69 6e28 6465 6661 756c 745f 626c 6f63 min(default_bloc │ │ │ -0007dfa0: 6b5f 7369 7a65 0a3c 2f64 6976 3e09 0909 k_size.
    ... │ │ │ -0007dfb0: 092c 2069 2d26 6774 3b70 6965 6365 5f73 ., i->piece_s │ │ │ -0007dfc0: 697a 6520 2d20 626c 6f63 6b5f 6964 7820 ize - block_idx │ │ │ -0007dfd0: 2a20 6465 6661 756c 745f 626c 6f63 6b5f * default_block_ │ │ │ -0007dfe0: 7369 7a65 293b 0a09 0909 6628 692d 2667 size);....f(i-&g │ │ │ -0007dff0: 743b 626c 6f63 6b73 5b62 6c6f 636b 5f69 t;blocks[block_i │ │ │ -0007e000: 6478 5d2e 6275 6628 626c 6b5f 7369 7a65 dx].buf(blk_size │ │ │ -0007e010: 2929 3b0a 0909 0972 6574 7572 6e20 7472 ));....return tr │ │ │ -0007e020: 7565 3b0a 0909 7d0a 0909 7265 7475 726e ue;...}...return │ │ │ -0007e030: 2066 616c 7365 3b0a 097d 0a0a 0974 656d false;..}...tem │ │ │ -0007e040: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -0007e050: 6d65 2046 756e 2667 743b 0a09 7368 6132 me Fun>..sha2 │ │ │ -0007e060: 3536 5f68 6173 6820 6861 7368 3228 7069 56_hash hash2(pi │ │ │ -0007e070: 6563 655f 6c6f 6361 7469 6f6e 2063 6f6e ece_location con │ │ │ -0007e080: 7374 206c 6f63 2c20 696e 7420 636f 6e73 st loc, int cons │ │ │ -0007e090: 7420 626c 6f63 6b5f 6964 782c 2046 756e t block_idx, Fun │ │ │ -0007e0a0: 2066 2920 636f 6e73 740a 097b 0a09 0973 f) const..{...s │ │ │ -0007e0b0: 7464 3a3a 756e 6971 7565 5f6c 6f63 6b26 td::unique_lock& │ │ │ -0007e0c0: 6c74 3b73 7464 3a3a 6d75 7465 7826 6774 lt;std::mutex> │ │ │ -0007e0d0: 3b20 6c28 6d5f 6d75 7465 7829 3b0a 0a09 ; l(m_mutex);... │ │ │ -0007e0e0: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ -0007e0f0: 3b0a 0a09 0961 7574 6f26 616d 703b 2076 ;....auto& v │ │ │ -0007e100: 6965 7720 3d20 6d5f 7069 6563 6573 2e74 iew = m_pieces.t │ │ │ -0007e110: 656d 706c 6174 6520 6765 7426 6c74 3b30 emplate get<0 │ │ │ -0007e120: 2667 743b 2829 3b0a 0909 6175 746f 2069 >();...auto i │ │ │ -0007e130: 203d 2076 6965 772e 6669 6e64 286c 6f63 = view.find(loc │ │ │ -0007e140: 293b 0a09 0969 6620 2869 203d 3d20 7669 );...if (i == vi │ │ │ -0007e150: 6577 2e65 6e64 2829 290a 0909 7b0a 0909 ew.end())...{... │ │ │ -0007e160: 096c 2e75 6e6c 6f63 6b28 293b 0a09 0909 .l.unlock();.... │ │ │ -0007e170: 7265 7475 726e 2066 2829 3b0a 0909 7d0a return f();...}. │ │ │ -0007e180: 0a09 092f 2f20 416e 6f74 6865 7220 7468 ...// Another th │ │ │ -0007e190: 7265 6164 206d 6179 2062 6520 6861 7368 read may be hash │ │ │ -0007e1a0: 696e 6720 7468 6973 2070 6965 6365 2072 ing this piece r │ │ │ -0007e1b0: 6967 6874 206e 6f77 2e20 496e 2074 6869 ight now. In thi │ │ │ -0007e1c0: 7320 6361 7365 2077 650a 0909 2f2f 206e s case we...// n │ │ │ -0007e1d0: 6565 6420 746f 2077 6169 740a 3c2f 7072 eed to wait.rel │ │ │ -0007e210: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -0007e250: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007e260: 5f2f 6469 736b 5f63 6163 6865 2e68 7070 _/disk_cache.hpp │ │ │ -0007e270: 3a33 3639 3c2f 613e 3c2f 7464 3e3c 7464 :369there may be a │ │ │ -0007e290: 6265 7474 6572 2077 6179 2074 6f20 736f better way to so │ │ │ -0007e2a0: 6c76 6520 7468 6973 2c20 6d61 7962 6520 lve this, maybe │ │ │ -0007e2b0: 6861 6e67 2074 6865 206a 6f62 206f 6e20 hang the job on │ │ │ -0007e2c0: 7468 6520 7069 6563 6520 616e 6420 7472 the piece and tr │ │ │ -0007e2d0: 7920 6c61 7465 722e 2042 7574 2069 7427 y later. But it' │ │ │ -0007e2e0: 7320 6120 6269 6720 6368 616e 6765 2074 s a big change t │ │ │ -0007e2f0: 6f20 646f 2073 6f3c 2f74 643e 3c2f 7472 o do so

    there may b │ │ │ -0007e350: 6520 6120 6265 7474 6572 2077 6179 2074 e a better way t │ │ │ -0007e360: 6f20 736f 6c76 6520 7468 6973 2c20 6d61 o solve this, ma │ │ │ -0007e370: 7962 6520 6861 6e67 2074 6865 206a 6f62 ybe hang the job │ │ │ -0007e380: 206f 6e0a 7468 6520 7069 6563 6520 616e on.the piece an │ │ │ -0007e390: 6420 7472 7920 6c61 7465 722e 2042 7574 d try later. But │ │ │ -0007e3a0: 2069 7427 7320 6120 6269 6720 6368 616e it's a big chan │ │ │ -0007e3b0: 6765 2074 6f20 646f 2073 6f3c 2f68 323e ge to do so

    │ │ │ -0007e3c0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -0007e3d0: 6962 746f 7272 656e 742f 6175 785f 2f64 ibtorrent/aux_/d │ │ │ -0007e3e0: 6973 6b5f 6361 6368 652e 6870 703a 3336 isk_cache.hpp:36 │ │ │ -0007e3f0: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ -0007e430: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -0007e440: 097d 0a0a 0974 656d 706c 6174 6520 266c  .}...template &l
    │ │ │ -0007e450: 743b 7479 7065 6e61 6d65 2046 756e 2667  t;typename Fun&g
    │ │ │ -0007e460: 743b 0a09 7368 6132 3536 5f68 6173 6820  t;..sha256_hash 
    │ │ │ -0007e470: 6861 7368 3228 7069 6563 655f 6c6f 6361  hash2(piece_loca
    │ │ │ -0007e480: 7469 6f6e 2063 6f6e 7374 206c 6f63 2c20  tion const loc, 
    │ │ │ -0007e490: 696e 7420 636f 6e73 7420 626c 6f63 6b5f  int const block_
    │ │ │ -0007e4a0: 6964 782c 2046 756e 2066 2920 636f 6e73  idx, Fun f) cons
    │ │ │ -0007e4b0: 740a 097b 0a09 0973 7464 3a3a 756e 6971  t..{...std::uniq
    │ │ │ -0007e4c0: 7565 5f6c 6f63 6b26 6c74 3b73 7464 3a3a  ue_lock<std::
    │ │ │ -0007e4d0: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -0007e4e0: 7465 7829 3b0a 0a09 0949 4e56 4152 4941  tex);....INVARIA
    │ │ │ -0007e4f0: 4e54 5f43 4845 434b 3b0a 0a09 0961 7574  NT_CHECK;....aut
    │ │ │ -0007e500: 6f26 616d 703b 2076 6965 7720 3d20 6d5f  o& view = m_
    │ │ │ -0007e510: 7069 6563 6573 2e74 656d 706c 6174 6520  pieces.template 
    │ │ │ -0007e520: 6765 7426 6c74 3b30 2667 743b 2829 3b0a  get<0>();.
    │ │ │ -0007e530: 0909 6175 746f 2069 203d 2076 6965 772e  ..auto i = view.
    │ │ │ -0007e540: 6669 6e64 286c 6f63 293b 0a09 0969 6620  find(loc);...if 
    │ │ │ -0007e550: 2869 203d 3d20 7669 6577 2e65 6e64 2829  (i == view.end()
    │ │ │ -0007e560: 290a 0909 7b0a 0909 096c 2e75 6e6c 6f63  )...{....l.unloc
    │ │ │ -0007e570: 6b28 293b 0a09 0909 7265 7475 726e 2066  k();....return f
    │ │ │ -0007e580: 2829 3b0a 0909 7d0a 0a09 092f 2f20 416e  ();...}....// An
    │ │ │ -0007e590: 6f74 6865 7220 7468 7265 6164 206d 6179  other thread may
    │ │ │ -0007e5a0: 2062 6520 6861 7368 696e 6720 7468 6973   be hashing this
    │ │ │ -0007e5b0: 2070 6965 6365 2072 6967 6874 206e 6f77   piece right now
    │ │ │ -0007e5c0: 2e20 496e 2074 6869 7320 6361 7365 2077  . In this case w
    │ │ │ -0007e5d0: 650a 0909 2f2f 206e 6565 6420 746f 2077  e...// need to w
    │ │ │ -0007e5e0: 6169 740a 3c64 6976 2073 7479 6c65 3d22  ait.
    ..while (i-> │ │ │ -0007e620: 3b66 6c61 6773 2026 616d 703b 2063 6163 ;flags & cac │ │ │ -0007e630: 6865 645f 7069 6563 655f 656e 7472 793a hed_piece_entry: │ │ │ -0007e640: 3a68 6173 6869 6e67 5f66 6c61 6729 0a3c :hashing_flag).< │ │ │ -0007e650: 2f64 6976 3e09 097b 0a09 0909 6c2e 756e /div>..{....l.un │ │ │ -0007e660: 6c6f 636b 2829 3b0a 0909 0973 7464 3a3a lock();....std:: │ │ │ -0007e670: 7468 6973 5f74 6872 6561 643a 3a79 6965 this_thread::yie │ │ │ -0007e680: 6c64 2829 3b0a 0909 096c 2e6c 6f63 6b28 ld();....l.lock( │ │ │ -0007e690: 293b 0a0a 0909 0969 203d 2076 6965 772e );.....i = view. │ │ │ -0007e6a0: 6669 6e64 286c 6f63 293b 0a09 0909 6966 find(loc);....if │ │ │ -0007e6b0: 2028 6920 3d3d 2076 6965 772e 656e 6428 (i == view.end( │ │ │ -0007e6c0: 2929 0a09 0909 7b0a 0909 0909 6c2e 756e ))....{.....l.un │ │ │ -0007e6d0: 6c6f 636b 2829 3b0a 0909 0909 7265 7475 lock();.....retu │ │ │ -0007e6e0: 726e 2066 2829 3b0a 0909 097d 0a09 097d rn f();....}...} │ │ │ -0007e6f0: 0a09 0961 7574 6f20 636f 6e73 7426 616d ...auto const&am │ │ │ -0007e700: 703b 2063 6265 203d 2069 2d26 6774 3b62 p; cbe = i->b │ │ │ -0007e710: 6c6f 636b 735b 626c 6f63 6b5f 6964 785d locks[block_idx] │ │ │ -0007e720: 3b0a 0909 2f2f 2069 6e64 6570 656e 6465 ;...// independe │ │ │ -0007e730: 6e74 206f 6620 6861 7368 6572 5f63 7572 nt of hasher_cur │ │ │ -0007e740: 736f 723a 2061 6e79 2076 3220 626c 6f63 sor: any v2 bloc │ │ │ -0007e750: 6b20 6d61 7920 6265 2068 6173 6865 6420 k may be hashed │ │ │ -0007e760: 696e 2061 6e79 0a09 092f 2f20 6f72 6465 in any...// orde │ │ │ -0007e770: 722e 2050 7265 636f 6d70 7574 6564 2076 r. Precomputed v │ │ │ -0007e780: 3220 6861 7368 6573 206c 6976 6520 6f6e 2 hashes live on │ │ │ -0007e790: 2070 7265 6164 5f73 746f 7261 6765 2061 pread_storage a │ │ │ -0007e7a0: 6e64 2061 7265 0a09 092f 2f20 636f 6e73 nd are...// cons │ │ │ -0007e7b0: 756c 7465 6420 6279 2074 6865 2063 616c ulted by the cal │ │ │ -0007e7c0: 6c65 7220 6265 666f 7265 2072 6561 6368 ler before reach │ │ │ -0007e7d0: 696e 6720 6865 7265 2e0a 0909 6966 2028 ing here....if ( │ │ │ -0007e7e0: 6362 652e 6461 7461 2829 290a 0909 7b0a cbe.data())...{. │ │ │ -0007e7f0: 0909 0969 6e74 2063 6f6e 7374 2062 6c6b ...int const blk │ │ │ -0007e800: 5f73 697a 6520 3d20 7374 643a 3a6d 696e _size = std::min │ │ │ -0007e810: 2864 6566 6175 6c74 5f62 6c6f 636b 5f73 (default_block_s │ │ │ -0007e820: 697a 650a 0909 0909 2c20 692d 2667 743b ize....., i-> │ │ │ -0007e830: 7069 6563 655f 7369 7a65 3220 2d20 626c piece_size2 - bl │ │ │ -0007e840: 6f63 6b5f 6964 7820 2a20 6465 6661 756c ock_idx * defaul │ │ │ -0007e850: 745f 626c 6f63 6b5f 7369 7a65 293b 0a09 t_block_size);.. │ │ │ -0007e860: 0909 6861 7368 6572 3235 3620 683b 0a09 ..hasher256 h;.. │ │ │ -0007e870: 0909 682e 7570 6461 7465 2863 6265 2e62 ..h.update(cbe.b │ │ │ -0007e880: 7566 2862 6c6b 5f73 697a 6529 293b 0a09 uf(blk_size));.. │ │ │ -0007e890: 0909 7265 7475 726e 2068 2e66 696e 616c ..return h.final │ │ │ -0007e8a0: 2829 3b0a 0909 7d0a 0909 6c2e 756e 6c6f ();...}...l.unlo │ │ │ -0007e8b0: 636b 2829 3b0a 0909 7265 7475 726e 2066 ck();...return f │ │ │ -0007e8c0: 2829 3b0a 097d 0a0a 0965 6e75 6d20 636c ();..}...enum cl │ │ │ -0007e8d0: 6173 7320 6861 7368 5f70 6965 6365 5f72 ass hash_piece_r │ │ │ -0007e8e0: 6573 756c 7420 7b20 6e6f 745f 696e 5f63 esult { not_in_c │ │ │ -0007e8f0: 6163 6865 2c20 636f 6d70 6c65 7465 642c ache, completed, │ │ │ -0007e900: 2064 6566 6572 7265 6420 7d3b 0a0a 3c2f deferred };..r │ │ │ -0007e940: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0007e950: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -0007e980: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -0007e990: 7578 5f2f 706f 6f6c 2e68 7070 3a32 373c ux_/pool.hpp:27< │ │ │ -0007e9a0: 2f61 3e3c 2f74 643e 3c74 643e 656e 7375 /a>ensu │ │ │ -0007e9b0: 7265 2074 6865 2061 6c69 676e 6d65 6e74 re the alignment │ │ │ -0007e9c0: 2069 7320 676f 6f64 2068 6572 653c 2f74 is good here

    ensur │ │ │ -0007ea20: 6520 7468 6520 616c 6967 6e6d 656e 7420 e the alignment │ │ │ -0007ea30: 6973 2067 6f6f 6420 6865 7265 3c2f 6832 is good here

    ../include/ │ │ │ -0007ea50: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007ea60: 706f 6f6c 2e68 7070 3a32 373c 2f68 343e pool.hpp:27

    │ │ │ -0007ea70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    see LI
    │ │ │ -0007eab0: 4345 4e53 4520 6669 6c65 2e0a 2a2f 0a0a  CENSE file..*/..
    │ │ │ -0007eac0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -0007ead0: 504f 4f4c 5f48 5050 0a23 6465 6669 6e65  POOL_HPP.#define
    │ │ │ -0007eae0: 2054 4f52 5245 4e54 5f50 4f4f 4c5f 4850   TORRENT_POOL_HP
    │ │ │ -0007eaf0: 500a 0a23 696e 636c 7564 6520 226c 6962  P..#include "lib
    │ │ │ -0007eb00: 746f 7272 656e 742f 6175 785f 2f64 6973  torrent/aux_/dis
    │ │ │ -0007eb10: 6162 6c65 5f77 6172 6e69 6e67 735f 7075  able_warnings_pu
    │ │ │ -0007eb20: 7368 2e68 7070 220a 2369 6e63 6c75 6465  sh.hpp".#include
    │ │ │ -0007eb30: 2026 6c74 3b62 6f6f 7374 2f70 6f6f 6c2f   <boost/pool/
    │ │ │ -0007eb40: 706f 6f6c 2e68 7070 2667 743b 0a23 696e  pool.hpp>.#in
    │ │ │ -0007eb50: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -0007eb60: 742f 6175 785f 2f64 6973 6162 6c65 5f77  t/aux_/disable_w
    │ │ │ -0007eb70: 6172 6e69 6e67 735f 706f 702e 6870 7022  arnings_pop.hpp"
    │ │ │ -0007eb80: 0a0a 2369 6e63 6c75 6465 2026 6c74 3b63  ..#include <c
    │ │ │ -0007eb90: 7374 6464 6566 2667 743b 0a0a 6e61 6d65  stddef>..name
    │ │ │ -0007eba0: 7370 6163 6520 6c69 6274 6f72 7265 6e74  space libtorrent
    │ │ │ -0007ebb0: 207b 0a6e 616d 6573 7061 6365 2061 7578   {.namespace aux
    │ │ │ -0007ebc0: 207b 0a0a 7374 7275 6374 2061 6c6c 6f63   {..struct alloc
    │ │ │ -0007ebd0: 6174 6f72 5f6e 6577 5f64 656c 6574 650a  ator_new_delete.
    │ │ │ -0007ebe0: 7b0a 0975 7369 6e67 2073 697a 655f 7479  {..using size_ty
    │ │ │ -0007ebf0: 7065 203d 2073 7464 3a3a 7369 7a65 5f74  pe = std::size_t
    │ │ │ -0007ec00: 3b0a 0975 7369 6e67 2064 6966 6665 7265  ;..using differe
    │ │ │ -0007ec10: 6e63 655f 7479 7065 203d 2073 7464 3a3a  nce_type = std::
    │ │ │ -0007ec20: 7074 7264 6966 665f 743b 0a0a 3c64 6976  ptrdiff_t;..
    .stati │ │ │ -0007ec60: 6320 6368 6172 2a20 6d61 6c6c 6f63 2873 c char* malloc(s │ │ │ -0007ec70: 697a 655f 7479 7065 2063 6f6e 7374 2062 ize_type const b │ │ │ -0007ec80: 7974 6573 290a 3c2f 6469 763e 097b 2072 ytes).
    .{ r │ │ │ -0007ec90: 6574 7572 6e20 6e65 7720 6368 6172 5b62 eturn new char[b │ │ │ -0007eca0: 7974 6573 5d3b 207d 0a09 7374 6174 6963 ytes]; }..static │ │ │ -0007ecb0: 2076 6f69 6420 6672 6565 2863 6861 722a void free(char* │ │ │ -0007ecc0: 2063 6f6e 7374 2062 6c6f 636b 290a 097b const block)..{ │ │ │ -0007ecd0: 2064 656c 6574 6520 5b5d 2062 6c6f 636b delete [] block │ │ │ -0007ece0: 3b20 7d0a 7d3b 0a0a 7573 696e 6720 706f ; }.};..using po │ │ │ -0007ecf0: 6f6c 203d 2062 6f6f 7374 3a3a 706f 6f6c ol = boost::pool │ │ │ -0007ed00: 266c 743b 616c 6c6f 6361 746f 725f 6e65 <allocator_ne │ │ │ -0007ed10: 775f 6465 6c65 7465 2667 743b 3b0a 7d0a w_delete>;.}. │ │ │ -0007ed20: 7d0a 0a23 656e 6469 660a 3c2f 7072 653e }..#endif.
    │ │ │ -0007ed30: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0007ed60: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0007ed70: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../include/ │ │ │ -0007eda0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007edb0: 7574 705f 7374 7265 616d 2e68 7070 3a36 utp_stream.hpp:6 │ │ │ -0007edc0: 3637 3c2f 613e 3c2f 7464 3e3c 7464 3e69 67i │ │ │ -0007edd0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -0007ede0: 746f 206d 616b 6520 7468 6973 2070 7269 to make this pri │ │ │ -0007edf0: 7661 7465 3c2f 7464 3e3c 2f74 723e 3c74 vateit would be ni │ │ │ -0007ee50: 6365 2074 6f20 6d61 6b65 2074 6869 7320 ce to make this │ │ │ -0007ee60: 7072 6976 6174 653c 2f68 323e 3c68 343e private

    │ │ │ -0007ee70: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007ee80: 7272 656e 742f 6175 785f 2f75 7470 5f73 rrent/aux_/utp_s │ │ │ -0007ee90: 7472 6561 6d2e 6870 703a 3636 373c 2f68 tream.hpp:667
    .boo
    │ │ │ -0007eee0: 6c20 636f 6e73 756d 655f 696e 636f 6d69  l consume_incomi
    │ │ │ -0007eef0: 6e67 5f64 6174 6128 0a09 0975 7470 5f68  ng_data(...utp_h
    │ │ │ -0007ef00: 6561 6465 7220 636f 6e73 742a 2070 682c  eader const* ph,
    │ │ │ -0007ef10: 2073 7464 3a3a 7569 6e74 385f 7420 636f   std::uint8_t co
    │ │ │ -0007ef20: 6e73 742a 2070 7472 2c20 696e 7420 7061  nst* ptr, int pa
    │ │ │ -0007ef30: 796c 6f61 645f 7369 7a65 2c20 7469 6d65  yload_size, time
    │ │ │ -0007ef40: 5f70 6f69 6e74 206e 6f77 293b 0a09 766f  _point now);..vo
    │ │ │ -0007ef50: 6964 2075 7064 6174 655f 6d74 755f 6c69  id update_mtu_li
    │ │ │ -0007ef60: 6d69 7473 2829 3b0a 0976 6f69 6420 6578  mits();..void ex
    │ │ │ -0007ef70: 7065 7269 656e 6365 645f 6c6f 7373 2873  perienced_loss(s
    │ │ │ -0007ef80: 7464 3a3a 7569 6e74 3332 5f74 2073 6571  td::uint32_t seq
    │ │ │ -0007ef90: 5f6e 722c 2074 696d 655f 706f 696e 7420  _nr, time_point 
    │ │ │ -0007efa0: 6e6f 7729 3b0a 0a09 766f 6964 2073 656e  now);...void sen
    │ │ │ -0007efb0: 645f 6465 6665 7272 6564 5f61 636b 2829  d_deferred_ack()
    │ │ │ -0007efc0: 3b0a 0976 6f69 6420 736f 636b 6574 5f64  ;..void socket_d
    │ │ │ -0007efd0: 7261 696e 6564 2829 3b0a 0a09 766f 6964  rained();...void
    │ │ │ -0007efe0: 2073 6574 5f75 7365 7264 6174 6128 7574   set_userdata(ut
    │ │ │ -0007eff0: 705f 7374 7265 616d 2a20 7329 207b 206d  p_stream* s) { m
    │ │ │ -0007f000: 5f75 7365 7264 6174 6120 3d20 733b 207d  _userdata = s; }
    │ │ │ -0007f010: 0a09 766f 6964 2061 626f 7274 2829 3b0a  ..void abort();.
    │ │ │ -0007f020: 0975 6470 3a3a 656e 6470 6f69 6e74 2072  .udp::endpoint r
    │ │ │ -0007f030: 656d 6f74 655f 656e 6470 6f69 6e74 2829  emote_endpoint()
    │ │ │ -0007f040: 2063 6f6e 7374 3b0a 0a09 7374 643a 3a75   const;...std::u
    │ │ │ -0007f050: 696e 7431 365f 7420 7265 6365 6976 655f  int16_t receive_
    │ │ │ -0007f060: 6964 2829 2063 6f6e 7374 207b 2072 6574  id() const { ret
    │ │ │ -0007f070: 7572 6e20 6d5f 7265 6376 5f69 643b 207d  urn m_recv_id; }
    │ │ │ -0007f080: 0a09 626f 6f6c 206d 6174 6368 2875 6470  ..bool match(udp
    │ │ │ -0007f090: 3a3a 656e 6470 6f69 6e74 2063 6f6e 7374  ::endpoint const
    │ │ │ -0007f0a0: 2661 6d70 3b20 6570 2c20 7374 643a 3a75  & ep, std::u
    │ │ │ -0007f0b0: 696e 7431 365f 7420 6964 2920 636f 6e73  int16_t id) cons
    │ │ │ -0007f0c0: 743b 0a0a 092f 2f20 6e6f 6e2d 636f 7079  t;...// non-copy
    │ │ │ -0007f0d0: 6162 6c65 0a09 7574 705f 736f 636b 6574  able..utp_socket
    │ │ │ -0007f0e0: 5f69 6d70 6c28 7574 705f 736f 636b 6574  _impl(utp_socket
    │ │ │ -0007f0f0: 5f69 6d70 6c20 636f 6e73 7426 616d 703b  _impl const&
    │ │ │ -0007f100: 2920 3d20 6465 6c65 7465 3b0a 0975 7470  ) = delete;..utp
    │ │ │ -0007f110: 5f73 6f63 6b65 745f 696d 706c 2063 6f6e  _socket_impl con
    │ │ │ -0007f120: 7374 2661 6d70 3b20 6f70 6572 6174 6f72  st& operator
    │ │ │ -0007f130: 3d28 7574 705f 736f 636b 6574 5f69 6d70  =(utp_socket_imp
    │ │ │ -0007f140: 6c20 636f 6e73 7426 616d 703b 2920 3d20  l const&) = 
    │ │ │ -0007f150: 6465 6c65 7465 3b0a 0a09 2f2f 2054 6865  delete;...// The
    │ │ │ -0007f160: 2075 6e64 6572 6c79 696e 6720 5544 5020   underlying UDP 
    │ │ │ -0007f170: 736f 636b 6574 2074 6869 7320 7554 5020  socket this uTP 
    │ │ │ -0007f180: 736f 636b 6574 2069 7320 626f 756e 6420  socket is bound 
    │ │ │ -0007f190: 746f 0a3c 6469 7620 7374 796c 653d 2262  to.
    .std::weak_ptr& │ │ │ -0007f1d0: 6c74 3b75 7470 5f73 6f63 6b65 745f 696e lt;utp_socket_in │ │ │ -0007f1e0: 7465 7266 6163 6526 6774 3b20 6d5f 736f terface> m_so │ │ │ -0007f1f0: 636b 3b0a 3c2f 6469 763e 0a09 766f 6964 ck;.
    ..void │ │ │ -0007f200: 2061 6464 5f77 7269 7465 5f62 7566 6665 add_write_buffe │ │ │ -0007f210: 7228 766f 6964 2063 6f6e 7374 2a20 6275 r(void const* bu │ │ │ -0007f220: 662c 2069 6e74 206c 656e 293b 0a09 766f f, int len);..vo │ │ │ -0007f230: 6964 2061 6464 5f72 6561 645f 6275 6666 id add_read_buff │ │ │ -0007f240: 6572 2876 6f69 642a 2062 7566 2c20 696e er(void* buf, in │ │ │ -0007f250: 7420 6c65 6e29 3b0a 0a09 696e 7420 7365 t len);...int se │ │ │ -0007f260: 6e64 5f64 656c 6179 2829 2063 6f6e 7374 nd_delay() const │ │ │ -0007f270: 207b 2072 6574 7572 6e20 6d5f 7365 6e64 { return m_send │ │ │ -0007f280: 5f64 656c 6179 3b20 7d0a 0969 6e74 2072 _delay; }..int r │ │ │ -0007f290: 6563 765f 6465 6c61 7928 2920 636f 6e73 ecv_delay() cons │ │ │ -0007f2a0: 7420 7b20 7265 7475 726e 206d 5f72 6563 t { return m_rec │ │ │ -0007f2b0: 765f 6465 6c61 793b 207d 0a0a 0976 6f69 v_delay; }...voi │ │ │ -0007f2c0: 6420 6973 7375 655f 7265 6164 2829 3b0a d issue_read();. │ │ │ -0007f2d0: 0976 6f69 6420 6973 7375 655f 7772 6974 .void issue_writ │ │ │ -0007f2e0: 6528 293b 0a09 766f 6964 2073 7562 7363 e();..void subsc │ │ │ -0007f2f0: 7269 6265 5f77 7269 7465 6162 6c65 2829 ribe_writeable() │ │ │ -0007f300: 3b0a 0a09 626f 6f6c 2063 6865 636b 5f66 ;...bool check_f │ │ │ -0007f310: 696e 5f73 656e 7428 2920 636f 6e73 743b in_sent() const; │ │ │ -0007f320: 0a0a 0976 6f69 6420 646f 5f63 6f6e 6e65 ...void do_conne │ │ │ -0007f330: 6374 2874 6370 3a3a 656e 6470 6f69 6e74 ct(tcp::endpoint │ │ │ -0007f340: 2063 6f6e 7374 2661 6d70 3b20 6570 293b const& ep); │ │ │ -0007f350: 0a0a 0973 7464 3a3a 7369 7a65 5f74 2072 ...std::size_t r │ │ │ -0007f360: 6561 645f 736f 6d65 2862 6f6f 6c20 636f ead_some(bool co │ │ │ -0007f370: 6e73 7420 636c 6561 725f 6275 6666 6572 nst clear_buffer │ │ │ -0007f380: 732c 2065 7272 6f72 5f63 6f64 6526 616d s, error_code&am │ │ │ -0007f390: 703b 2065 6329 3b0a 0973 7464 3a3a 7369 p; ec);..std::si │ │ │ -0007f3a0: 7a65 5f74 2077 7269 7465 5f73 6f6d 6528 ze_t write_some( │ │ │ -0007f3b0: 626f 6f6c 2063 6f6e 7374 2063 6c65 6172 bool const clear │ │ │ -0007f3c0: 5f62 7566 6665 7273 293b 202f 2f20 5761 _buffers); // Wa │ │ │ -0007f3d0: 726e 696e 673a 206e 6f6e 2d62 6c6f 636b rning: non-block │ │ │ -0007f3e0: 696e 670a 0969 6e74 2072 6563 6569 7665 ing..int receive │ │ │ -0007f3f0: 5f62 7566 6665 725f 7369 7a65 2829 2063 _buffer_size() c │ │ │ -0007f400: 6f6e 7374 207b 2072 6574 7572 6e20 6d5f onst { return m_ │ │ │ -0007f410: 7265 6365 6976 655f 6275 6666 6572 5f73 receive_buffer_s │ │ │ -0007f420: 697a 653b 207d 0a0a 0962 6f6f 6c20 6e75 ize; }...bool nu │ │ │ -0007f430: 6c6c 5f62 7566 6665 7273 2829 2063 6f6e ll_buffers() con │ │ │ -0007f440: 7374 207b 2072 6574 7572 6e20 6d5f 6e75 st { return m_nu │ │ │ -0007f450: 6c6c 5f62 7566 6665 7273 3b20 7d0a 0a70 ll_buffers; }..p │ │ │ -0007f460: 7269 7661 7465 3a0a 0a09 2f2f 2069 7427 rivate:...// it' │ │ │ -0007f470: 7320 696d 706f 7274 616e 7420 7468 6174 s important that │ │ │ -0007f480: 2074 6865 7365 206d 6174 6368 2074 6865 these match the │ │ │ -0007f490: 2065 6e75 6d73 2069 6e20 7065 7266 6f72 enums in perfor │ │ │ -0007f4a0: 6d61 6e63 655f 636f 756e 7465 7273 2066 mance_counters f │ │ │ -0007f4b0: 6f72 0a09 2f2f 206e 756d 5f75 7470 5f69 or..// num_utp_i │ │ │ -0007f4c0: 646c 6520 6574 632e 0a09 656e 756d 2063 dle etc...enum c │ │ │ -0007f4d0: 6c61 7373 2073 7461 7465 5f74 207b 0a09 lass state_t {.. │ │ │ -0007f4e0: 092f 2f20 6e6f 7420 7965 7420 636f 6e6e .// not yet conn │ │ │ -0007f4f0: 6563 7465 640a 0909 6e6f 6e65 2c0a 0909 ected...none,... │ │ │ -0007f500: 2f2f 2073 656e 7420 6120 7379 6e20 7061 // sent a syn pa │ │ │ -0007f510: 636b 6574 2c20 6e6f 7420 7265 6365 6976 cket, not receiv │ │ │ -0007f520: 6564 2061 6e79 2061 636b 730a 0909 7379 ed any acks...sy │ │ │ -0007f530: 6e5f 7365 6e74 2c0a 3c2f 7072 653e 3c2f n_sent,.
    relevan │ │ │ -0007f570: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -0007f5b0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7069 btorrent/aux_/pi │ │ │ -0007f5c0: 6563 655f 7069 636b 6572 2e68 7070 3a38 ece_picker.hpp:8 │ │ │ -0007f5d0: 3038 3c2f 613e 3c2f 7464 3e3c 7464 3e73 08s │ │ │ -0007f5e0: 686f 756c 6420 7468 6973 2062 6520 616c hould this be al │ │ │ -0007f5f0: 6c6f 6361 7465 6420 6c61 7a69 6c79 3f3c located lazily?< │ │ │ -0007f600: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sho │ │ │ -0007f650: 756c 6420 7468 6973 2062 6520 616c 6c6f uld this be allo │ │ │ -0007f660: 6361 7465 6420 6c61 7a69 6c79 3f3c 2f68 cated lazily?

    ../include │ │ │ -0007f680: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007f690: 2f70 6965 6365 5f70 6963 6b65 722e 6870 /piece_picker.hp │ │ │ -0007f6a0: 703a 3830 383c 2f68 343e 3c70 7265 2073 p:808

    ..// downloa
    │ │ │ -0007f6f0: 6420 6c69 7374 2069 7420 6d61 7920 6c69  d list it may li
    │ │ │ -0007f700: 7665 2069 6e20 6e6f 770a 0909 7374 643a  ve in now...std:
    │ │ │ -0007f710: 3a76 6563 746f 7226 6c74 3b64 6f77 6e6c  :vector<downl
    │ │ │ -0007f720: 6f61 6469 6e67 5f70 6965 6365 2667 743b  oading_piece>
    │ │ │ -0007f730: 3a3a 6974 6572 6174 6f72 2075 7064 6174  ::iterator updat
    │ │ │ -0007f740: 655f 7069 6563 655f 7374 6174 6528 0a09  e_piece_state(..
    │ │ │ -0007f750: 0909 7374 643a 3a76 6563 746f 7226 6c74  ..std::vector<
    │ │ │ -0007f760: 3b64 6f77 6e6c 6f61 6469 6e67 5f70 6965  ;downloading_pie
    │ │ │ -0007f770: 6365 2667 743b 3a3a 6974 6572 6174 6f72  ce>::iterator
    │ │ │ -0007f780: 2064 7029 3b0a 0a09 7072 6976 6174 653a   dp);...private:
    │ │ │ -0007f790: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ -0007f7a0: 455f 4153 5345 5254 5320 7c7c 2054 4f52  E_ASSERTS || TOR
    │ │ │ -0007f7b0: 5245 4e54 5f55 5345 5f49 4e56 4152 4941  RENT_USE_INVARIA
    │ │ │ -0007f7c0: 4e54 5f43 4845 434b 530a 0909 696e 6465  NT_CHECKS...inde
    │ │ │ -0007f7d0: 785f 7261 6e67 6526 6c74 3b64 6f77 6e6c  x_range<downl
    │ │ │ -0007f7e0: 6f61 645f 7175 6575 655f 7426 6774 3b20  oad_queue_t> 
    │ │ │ -0007f7f0: 6361 7465 676f 7269 6573 2829 2063 6f6e  categories() con
    │ │ │ -0007f800: 7374 0a09 097b 2072 6574 7572 6e20 7b7b  st...{ return {{
    │ │ │ -0007f810: 7d2c 2070 6965 6365 5f70 6963 6b65 723a  }, piece_picker:
    │ │ │ -0007f820: 3a70 6965 6365 5f70 6f73 3a3a 6e75 6d5f  :piece_pos::num_
    │ │ │ -0007f830: 646f 776e 6c6f 6164 5f63 6174 6567 6f72  download_categor
    │ │ │ -0007f840: 6965 737d 3b20 7d0a 2365 6e64 6966 0a0a  ies}; }.#endif..
    │ │ │ -0007f850: 0909 2f2f 2074 6865 2066 6f6c 6c6f 7769  ..// the followi
    │ │ │ -0007f860: 6e67 2076 6563 746f 7273 2061 7265 206d  ng vectors are m
    │ │ │ -0007f870: 7574 6162 6c65 2062 6563 6175 7365 2074  utable because t
    │ │ │ -0007f880: 6865 7920 736f 6d65 7469 6d65 7320 6d61  hey sometimes ma
    │ │ │ -0007f890: 790a 0909 2f2f 2062 6520 7570 6461 7465  y...// be update
    │ │ │ -0007f8a0: 6420 6c61 7a69 6c79 2c20 7472 6967 6765  d lazily, trigge
    │ │ │ -0007f8b0: 7265 6420 6279 2063 6f6e 7374 2066 756e  red by const fun
    │ │ │ -0007f8c0: 6374 696f 6e73 0a0a 0909 2f2f 2074 6869  ctions....// thi
    │ │ │ -0007f8d0: 7320 6d61 7073 2069 6e64 6963 6573 2074  s maps indices t
    │ │ │ -0007f8e0: 6f20 6e75 6d62 6572 206f 6620 7065 6572  o number of peer
    │ │ │ -0007f8f0: 7320 7468 6174 2068 6173 2074 6869 7320  s that has this 
    │ │ │ -0007f900: 7069 6563 6520 616e 640a 0909 2f2f 2069  piece and...// i
    │ │ │ -0007f910: 6e64 6578 2069 6e74 6f20 7468 6520 6d5f  ndex into the m_
    │ │ │ -0007f920: 7069 6563 655f 696e 666f 2076 6563 746f  piece_info vecto
    │ │ │ -0007f930: 7273 2e0a 0909 2f2f 2070 6965 6365 5f70  rs....// piece_p
    │ │ │ -0007f940: 6f73 3a3a 666c 7573 6865 645f 696e 6465  os::flushed_inde
    │ │ │ -0007f950: 7820 6d65 616e 7320 7468 6520 7069 636b  x means the pick
    │ │ │ -0007f960: 6572 2068 6173 2066 696e 616c 697a 6564  er has finalized
    │ │ │ -0007f970: 2074 6865 0a09 092f 2f20 7069 6563 652c   the...// piece,
    │ │ │ -0007f980: 2073 6f20 6974 2064 6f65 736e 2774 2065   so it doesn't e
    │ │ │ -0007f990: 7869 7374 2069 6e20 7468 6520 7069 6563  xist in the piec
    │ │ │ -0007f9a0: 655f 696e 666f 2062 7563 6b65 7473 0a09  e_info buckets..
    │ │ │ -0007f9b0: 092f 2f20 7069 6563 6573 2077 6974 6820  .// pieces with 
    │ │ │ -0007f9c0: 7468 6520 6669 6c74 6572 6564 2066 6c61  the filtered fla
    │ │ │ -0007f9d0: 6720 7365 7420 646f 6573 6e27 7420 6861  g set doesn't ha
    │ │ │ -0007f9e0: 7665 2065 6e74 7269 6573 2069 6e0a 0909  ve entries in...
    │ │ │ -0007f9f0: 2f2f 2074 6865 206d 5f70 6965 6365 5f69  // the m_piece_i
    │ │ │ -0007fa00: 6e66 6f20 6275 636b 6574 7320 6569 7468  nfo buckets eith
    │ │ │ -0007fa10: 6572 0a3c 6469 7620 7374 796c 653d 2262  er.
    ..mutable aux:: │ │ │ -0007fa50: 7665 6374 6f72 266c 743b 7069 6563 655f vector<piece_ │ │ │ -0007fa60: 706f 732c 2070 6965 6365 5f69 6e64 6578 pos, piece_index │ │ │ -0007fa70: 5f74 2667 743b 206d 5f70 6965 6365 5f6d _t> m_piece_m │ │ │ -0007fa80: 6170 3b0a 3c2f 6469 763e 0a09 092f 2f20 ap;.
    ...// │ │ │ -0007fa90: 7472 6163 6b73 2074 6865 206e 756d 6265 tracks the numbe │ │ │ -0007faa0: 7220 6f66 2062 7974 6573 2069 6e20 6120 r of bytes in a │ │ │ -0007fab0: 7370 6563 6966 6963 2070 6965 6365 2074 specific piece t │ │ │ -0007fac0: 6861 7420 6172 6520 7061 7274 206f 6620 hat are part of │ │ │ -0007fad0: 6120 7061 640a 0909 2f2f 2066 696c 652e a pad...// file. │ │ │ -0007fae0: 2054 6865 2070 6164 6469 6e67 2069 7320 The padding is │ │ │ -0007faf0: 6173 7375 6d65 6420 746f 2062 6520 6174 assumed to be at │ │ │ -0007fb00: 2074 6865 2065 6e64 206f 6620 7468 6520 the end of the │ │ │ -0007fb10: 7069 6563 652c 2061 6e64 2074 6865 0a09 piece, and the.. │ │ │ -0007fb20: 092f 2f20 626c 6f63 6b73 2063 6f76 6572 .// blocks cover │ │ │ -0007fb30: 6564 2062 7920 7468 6520 7061 6420 6279 ed by the pad by │ │ │ -0007fb40: 7465 7320 6172 6520 6e6f 7420 7069 636b tes are not pick │ │ │ -0007fb50: 6564 2062 7920 7468 6520 7069 6563 6520 ed by the piece │ │ │ -0007fb60: 7069 636b 6572 0a09 0973 7464 3a3a 756e picker...std::un │ │ │ -0007fb70: 6f72 6465 7265 645f 6d61 7026 6c74 3b70 ordered_map<p │ │ │ -0007fb80: 6965 6365 5f69 6e64 6578 5f74 2c20 696e iece_index_t, in │ │ │ -0007fb90: 7426 6774 3b20 6d5f 7061 6473 5f69 6e5f t> m_pads_in_ │ │ │ -0007fba0: 7069 6563 653b 0a0a 0909 2f2f 2077 6865 piece;....// whe │ │ │ -0007fbb0: 6e20 7468 6520 6164 6a61 6365 6e74 5f70 n the adjacent_p │ │ │ -0007fbc0: 6965 6365 2061 6666 696e 6974 7920 6973 iece affinity is │ │ │ -0007fbd0: 2065 6e61 626c 6564 2c20 7468 6973 2063 enabled, this c │ │ │ -0007fbe0: 6f6e 7461 696e 7320 7468 6520 6d6f 7374 ontains the most │ │ │ -0007fbf0: 0a09 092f 2f20 7265 6365 6e74 2022 6578 ...// recent "ex │ │ │ -0007fc00: 7465 6e74 7322 206f 6620 6164 6a61 6365 tents" of adjace │ │ │ -0007fc10: 6e74 2070 6965 6365 7320 7468 6174 2068 nt pieces that h │ │ │ -0007fc20: 6176 6520 6265 656e 2072 6571 7565 7374 ave been request │ │ │ -0007fc30: 6564 2066 726f 6d0a 0909 2f2f 2074 6869 ed from...// thi │ │ │ -0007fc40: 7320 6973 206d 7574 6162 6c65 2062 6563 s is mutable bec │ │ │ -0007fc50: 6175 7365 2069 7427 7320 7570 6461 7465 ause it's update │ │ │ -0007fc60: 6420 6279 2066 756e 6374 696f 6e73 2074 d by functions t │ │ │ -0007fc70: 6f20 7069 636b 2070 6965 6365 732c 2077 o pick pieces, w │ │ │ -0007fc80: 6869 6368 0a09 092f 2f20 6172 6520 636f hich...// are co │ │ │ -0007fc90: 6e73 742e 2054 6861 7427 7320 616e 2065 nst. That's an e │ │ │ -0007fca0: 6666 6963 6965 6e74 2070 6c61 6365 2074 fficient place t │ │ │ -0007fcb0: 6f20 7570 6461 7465 2069 742c 2073 696e o update it, sin │ │ │ -0007fcc0: 6365 2069 7427 7320 6265 696e 670a 0909 ce it's being... │ │ │ -0007fcd0: 2f2f 2074 7261 7665 7273 6564 2061 6c72 // traversed alr │ │ │ -0007fce0: 6561 6479 2e0a 0909 6d75 7461 626c 6520 eady....mutable │ │ │ -0007fcf0: 7374 643a 3a76 6563 746f 7226 6c74 3b70 std::vector<p │ │ │ -0007fd00: 6965 6365 5f65 7874 656e 745f 7426 6774 iece_extent_t> │ │ │ -0007fd10: 3b20 6d5f 7265 6365 6e74 5f65 7874 656e ; m_recent_exten │ │ │ -0007fd20: 7473 3b0a 0a09 092f 2f20 7468 6520 6e75 ts;....// the nu │ │ │ -0007fd30: 6d62 6572 206f 6620 6279 7465 7320 6f66 mber of bytes of │ │ │ -0007fd40: 2070 6164 2066 696c 6520 7365 7420 696e pad file set in │ │ │ -0007fd50: 2074 6869 7320 7069 6563 6520 7069 636b this piece pick │ │ │ -0007fd60: 6572 0a09 0973 7464 3a3a 696e 7436 345f er...std::int64_ │ │ │ -0007fd70: 7420 6d5f 6e75 6d5f 7061 645f 6279 7465 t m_num_pad_byte │ │ │ -0007fd80: 7320 3d20 303b 0a0a 0909 2f2f 2074 6865 s = 0;....// the │ │ │ -0007fd90: 206e 756d 6265 7220 6f66 2070 6164 2062 number of pad b │ │ │ -0007fda0: 6c6f 636b 7320 7468 6174 2077 6520 616c locks that we al │ │ │ -0007fdb0: 7265 6164 7920 6861 7665 0a09 0973 7464 ready have...std │ │ │ -0007fdc0: 3a3a 696e 7436 345f 7420 6d5f 6861 7665 ::int64_t m_have │ │ │ -0007fdd0: 5f70 6164 5f62 7974 6573 203d 2030 3b0a _pad_bytes = 0;. │ │ │ -0007fde0: 0a09 092f 2f20 7468 6520 6e75 6d62 6572 ...// the number │ │ │ -0007fdf0: 206f 6620 7061 6420 626c 6f63 6b73 2070 of pad blocks p │ │ │ -0007fe00: 6172 7420 6f66 2066 696c 7465 7265 6420 art of filtered │ │ │ -0007fe10: 7069 6563 6573 2077 6520 646f 6e27 7420 pieces we don't │ │ │ -0007fe20: 6861 7665 0a09 0973 7464 3a3a 696e 7436 have...std::int6 │ │ │ -0007fe30: 345f 7420 6d5f 6669 6c74 6572 6564 5f70 4_t m_filtered_p │ │ │ -0007fe40: 6164 5f62 7974 6573 203d 2030 3b0a 0a09 ad_bytes = 0;... │ │ │ -0007fe50: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -0007fe60: 6620 7061 6420 626c 6f63 6b73 2077 6520 f pad blocks we │ │ │ -0007fe70: 6861 7665 2074 6861 7420 6172 6520 616c have that are al │ │ │ -0007fe80: 736f 2066 696c 7465 7265 640a 0909 7374 so filtered...st │ │ │ -0007fe90: 643a 3a69 6e74 3634 5f74 206d 5f68 6176 d::int64_t m_hav │ │ │ -0007fea0: 655f 6669 6c74 6572 6564 5f70 6164 5f62 e_filtered_pad_b │ │ │ -0007feb0: 7974 6573 203d 2030 3b0a 0a09 092f 2f20 ytes = 0;....// │ │ │ -0007fec0: 7468 6520 6e75 6d62 6572 206f 6620 7365 the number of se │ │ │ -0007fed0: 6564 732e 2054 6865 7365 2061 7265 206e eds. These are n │ │ │ -0007fee0: 6f74 2061 6464 6564 2074 6f0a 0909 2f2f ot added to...// │ │ │ -0007fef0: 2074 6865 2061 7661 696c 6162 696c 6974 the availabilit │ │ │ -0007ff00: 7920 636f 756e 7465 7273 206f 6620 7468 y counters of th │ │ │ -0007ff10: 6520 7069 6563 6573 0a09 0969 6e74 206d e pieces...int m │ │ │ -0007ff20: 5f73 6565 6473 203d 2030 3b0a 0a09 092f _seeds = 0;..../ │ │ │ -0007ff30: 2f20 7468 6973 2076 6563 746f 7220 636f / this vector co │ │ │ -0007ff40: 6e74 6169 6e73 2061 6c6c 2070 6965 6365 ntains all piece │ │ │ -0007ff50: 2069 6e64 6963 6573 2074 6861 7420 6172 indices that ar │ │ │ -0007ff60: 6520 7069 636b 6162 6c65 0a3c 2f70 7265 e pickable.
    rele │ │ │ -0007ffa0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -0007ffe0: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007fff0: 2f70 6965 6365 5f70 6963 6b65 722e 6870 /piece_picker.hp │ │ │ -00080000: 703a 3838 303c 2f61 3e3c 2f74 643e 3c74 p:880it would be mo │ │ │ -00080020: 7265 2069 6e74 7569 7469 7665 2074 6f20 re intuitive to │ │ │ -00080030: 6163 636f 756e 7420 2277 616e 7465 6422 account "wanted" │ │ │ -00080040: 2070 6965 6365 7320 696e 7374 6561 6420 pieces instead │ │ │ -00080050: 6f66 2066 696c 7465 7265 643c 2f74 643e of filtered │ │ │ -00080060: 3c2f 7472 3e3c 7472 2069 643d 2232 3932

    it woul │ │ │ -000800b0: 6420 6265 206d 6f72 6520 696e 7475 6974 d be more intuit │ │ │ -000800c0: 6976 6520 746f 2061 6363 6f75 6e74 2022 ive to account " │ │ │ -000800d0: 7761 6e74 6564 2220 7069 6563 6573 0a69 wanted" pieces.i │ │ │ -000800e0: 6e73 7465 6164 206f 6620 6669 6c74 6572 nstead of filter │ │ │ -000800f0: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ed

    ../in │ │ │ -00080100: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00080110: 2f61 7578 5f2f 7069 6563 655f 7069 636b /aux_/piece_pick │ │ │ -00080120: 6572 2e68 7070 3a38 3830 3c2f 6834 3e3c er.hpp:880

    < │ │ │ -00080130: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00080140: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00080150: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00080160: 7820 2364 6464 3b22 3e0a 0909 2f2f 2074 x #ddd;">...// t │ │ │ -00080170: 6869 7320 686f 6c64 7320 7468 6520 696e his holds the in │ │ │ -00080180: 666f 726d 6174 696f 6e20 6f66 2074 6865 formation of the │ │ │ -00080190: 2062 6c6f 636b 7320 696e 2070 6172 7469 blocks in parti │ │ │ -000801a0: 616c 6c79 2064 6f77 6e6c 6f61 6465 640a ally downloaded. │ │ │ -000801b0: 0909 2f2f 2070 6965 6365 732e 2074 6865 ..// pieces. the │ │ │ -000801c0: 2064 6f77 6e6c 6f61 6469 6e67 5f70 6965 downloading_pie │ │ │ -000801d0: 6365 3a3a 696e 666f 2069 6e64 6578 2070 ce::info index p │ │ │ -000801e0: 6f69 6e74 2069 6e74 6f20 7468 6973 2076 oint into this v │ │ │ -000801f0: 6563 746f 7220 666f 720a 0909 2f2f 2069 ector for...// i │ │ │ -00080200: 7473 2073 746f 7261 6765 0a09 0961 7578 ts storage...aux │ │ │ -00080210: 3a3a 7665 6374 6f72 266c 743b 626c 6f63 ::vector<bloc │ │ │ -00080220: 6b5f 696e 666f 2667 743b 206d 5f62 6c6f k_info> m_blo │ │ │ -00080230: 636b 5f69 6e66 6f3b 0a0a 0909 2f2f 2074 ck_info;....// t │ │ │ -00080240: 6865 7365 2061 7265 2062 6c6f 636b 2072 hese are block r │ │ │ -00080250: 616e 6765 7320 696e 206d 5f62 6c6f 636b anges in m_block │ │ │ -00080260: 5f69 6e66 6f20 7468 6174 2061 7265 2066 _info that are f │ │ │ -00080270: 7265 652e 2054 6865 206e 756d 6265 7273 ree. The numbers │ │ │ -00080280: 0a09 092f 2f20 696e 2068 6572 652c 2077 ...// in here, w │ │ │ -00080290: 6865 6e20 6d75 6c74 6970 6c69 6564 2062 hen multiplied b │ │ │ -000802a0: 7920 626c 6f63 6b73 5f70 6572 5f70 6965 y blocks_per_pie │ │ │ -000802b0: 6365 2069 7320 7468 6520 696e 6465 7820 ce is the index │ │ │ -000802c0: 746f 2074 6865 0a09 092f 2f20 6669 7273 to the...// firs │ │ │ -000802d0: 7420 626c 6f63 6b20 696e 2074 6865 2072 t block in the r │ │ │ -000802e0: 616e 6765 2074 6861 7427 7320 6672 6565 ange that's free │ │ │ -000802f0: 2074 6f20 7573 6520 6279 2061 206e 6577 to use by a new │ │ │ -00080300: 2064 6f77 6e6c 6f61 6469 6e67 5f70 6965 downloading_pie │ │ │ -00080310: 6365 2e0a 0909 2f2f 2074 6869 7320 6973 ce....// this is │ │ │ -00080320: 2061 2066 7265 652d 6c69 7374 2e0a 0909 a free-list.... │ │ │ -00080330: 7374 643a 3a76 6563 746f 7226 6c74 3b73 std::vector<s │ │ │ -00080340: 7464 3a3a 7569 6e74 3136 5f74 2667 743b td::uint16_t> │ │ │ -00080350: 206d 5f66 7265 655f 626c 6f63 6b5f 696e m_free_block_in │ │ │ -00080360: 666f 733b 0a0a 0909 7374 643a 3a75 696e fos;....std::uin │ │ │ -00080370: 7431 365f 7420 6d5f 626c 6f63 6b73 5f69 t16_t m_blocks_i │ │ │ -00080380: 6e5f 6c61 7374 5f70 6965 6365 203d 2030 n_last_piece = 0 │ │ │ -00080390: 3b0a 0909 696e 7420 6d5f 7069 6563 655f ;...int m_piece_ │ │ │ -000803a0: 7369 7a65 203d 2030 3b0a 0909 7374 643a size = 0;...std: │ │ │ -000803b0: 3a69 6e74 3634 5f74 206d 5f74 6f74 616c :int64_t m_total │ │ │ -000803c0: 5f73 697a 6520 3d20 303b 0a0a 0909 2f2f _size = 0;....// │ │ │ -000803d0: 2074 6865 206e 756d 6265 7220 6f66 2066 the number of f │ │ │ -000803e0: 696c 7465 7265 6420 7069 6563 6573 2074 iltered pieces t │ │ │ -000803f0: 6861 7420 7765 2064 6f6e 2774 2061 6c72 hat we don't alr │ │ │ -00080400: 6561 6479 0a09 092f 2f20 6861 7665 2e20 eady...// have. │ │ │ -00080410: 746f 7461 6c5f 6e75 6d62 6572 5f6f 665f total_number_of_ │ │ │ -00080420: 7069 6563 6573 202d 206e 756d 6265 725f pieces - number_ │ │ │ -00080430: 6f66 5f70 6965 6365 735f 7765 5f68 6176 of_pieces_we_hav │ │ │ -00080440: 650a 0909 2f2f 202d 206e 756d 5f66 696c e...// - num_fil │ │ │ -00080450: 7465 7265 6420 6973 2073 7570 706f 7365 tered is suppose │ │ │ -00080460: 6420 746f 2074 6865 206e 756d 6265 7220 d to the number │ │ │ -00080470: 6f66 2070 6965 6365 730a 0909 2f2f 2077 of pieces...// w │ │ │ -00080480: 6520 7374 696c 6c20 7761 6e74 2074 6f20 e still want to │ │ │ -00080490: 646f 776e 6c6f 6164 0a3c 6469 7620 7374 download.
    ..int m_n │ │ │ -000804d0: 756d 5f66 696c 7465 7265 6420 3d20 303b um_filtered = 0; │ │ │ -000804e0: 0a3c 2f64 6976 3e0a 0909 2f2f 2074 6865 .
    ...// the │ │ │ -000804f0: 206e 756d 6265 7220 6f66 2070 6965 6365 number of piece │ │ │ -00080500: 7320 7765 2068 6176 6520 7468 6174 2061 s we have that a │ │ │ -00080510: 6c73 6f20 6172 6520 6669 6c74 6572 6564 lso are filtered │ │ │ -00080520: 0a09 0969 6e74 206d 5f6e 756d 5f68 6176 ...int m_num_hav │ │ │ -00080530: 655f 6669 6c74 6572 6564 203d 2030 3b0a e_filtered = 0;. │ │ │ -00080540: 0a09 092f 2f20 7765 2068 6176 6520 616c ...// we have al │ │ │ -00080550: 6c20 7069 6563 6573 2069 6e20 7468 6520 l pieces in the │ │ │ -00080560: 7261 6e67 6520 5b73 7461 7274 5f72 616e range [start_ran │ │ │ -00080570: 6765 2c20 6d5f 6375 7273 6f72 290a 0909 ge, m_cursor)... │ │ │ -00080580: 2f2f 206d 5f63 7572 736f 7220 6973 2074 // m_cursor is t │ │ │ -00080590: 6865 2066 6972 7374 2070 6965 6365 2077 he first piece w │ │ │ -000805a0: 6520 646f 6e27 7420 6861 7665 2e0a 0909 e don't have.... │ │ │ -000805b0: 2f2f 0a09 092f 2f20 2268 6176 6522 2068 //...// "have" h │ │ │ -000805c0: 6572 6520 6973 2074 6865 2073 7472 6963 ere is the stric │ │ │ -000805d0: 7420 6e6f 7469 6f6e 3a20 7069 6563 655f t notion: piece_ │ │ │ -000805e0: 706f 733a 3a66 6c75 7368 6564 2829 2e20 pos::flushed(). │ │ │ -000805f0: 5468 650a 0909 2f2f 2063 7572 736f 7220 The...// cursor │ │ │ -00080600: 6973 206f 6e6c 7920 6164 7661 6e63 6564 is only advanced │ │ │ -00080610: 2070 6173 7420 6120 7069 6563 6520 6279 past a piece by │ │ │ -00080620: 2070 6965 6365 5f66 6c75 7368 6564 2829 piece_flushed() │ │ │ -00080630: 2028 616e 640a 0909 2f2f 2074 6865 2063 (and...// the c │ │ │ -00080640: 7572 736f 7220 7761 6c6b 7320 696e 2073 ursor walks in s │ │ │ -00080650: 6574 5f70 6965 6365 5f70 7269 6f72 6974 et_piece_priorit │ │ │ -00080660: 7928 2920 7768 656e 2066 696c 7465 7269 y() when filteri │ │ │ -00080670: 6e67 2c20 7369 6e63 650a 0909 2f2f 2066 ng, since...// f │ │ │ -00080680: 696c 7465 7265 6420 7069 6563 6573 2061 iltered pieces a │ │ │ -00080690: 7265 2061 6c73 6f20 6f75 7420 6f66 2074 re also out of t │ │ │ -000806a0: 6865 2070 6963 6b65 7227 7320 776f 726b he picker's work │ │ │ -000806b0: 696e 6720 7365 7429 2e20 410a 0909 2f2f ing set). A...// │ │ │ -000806c0: 2070 6965 6365 2074 6861 7420 6861 7320 piece that has │ │ │ -000806d0: 6f6e 6c79 2070 6173 7365 645f 6861 7368 only passed_hash │ │ │ -000806e0: 5f63 6865 636b 2062 7574 2069 7320 6e6f _check but is no │ │ │ -000806f0: 7420 7965 7420 666c 7573 6865 640a 0909 t yet flushed... │ │ │ -00080700: 2f2f 2077 696c 6c20 6e6f 7420 6d6f 7665 // will not move │ │ │ -00080710: 2074 6865 2063 7572 736f 723b 2074 6865 the cursor; the │ │ │ -00080720: 2063 7572 736f 7220 6c61 6773 2075 6e74 cursor lags unt │ │ │ -00080730: 696c 2070 6965 6365 5f66 6c75 7368 6564 il piece_flushed │ │ │ -00080740: 2829 0a09 092f 2f20 7275 6e73 2028 7479 ()...// runs (ty │ │ │ -00080750: 7069 6361 6c6c 7920 6672 6f6d 206d 6172 pically from mar │ │ │ -00080760: 6b5f 6173 5f66 696e 6973 6865 6428 2920 k_as_finished() │ │ │ -00080770: 6f6e 6365 2074 6865 206c 6173 7420 626c once the last bl │ │ │ -00080780: 6f63 6b0a 0909 2f2f 2063 6f6d 706c 6574 ock...// complet │ │ │ -00080790: 6573 292e 2054 6869 7320 6176 6f69 6473 es). This avoids │ │ │ -000807a0: 206e 6565 6469 6e67 2074 6f20 7761 6c6b needing to walk │ │ │ -000807b0: 2074 6865 2063 7572 736f 7220 6261 636b the cursor back │ │ │ -000807c0: 7761 7264 730a 0909 2f2f 2069 6620 7772 wards...// if wr │ │ │ -000807d0: 6974 655f 6661 696c 6564 2829 206c 6174 ite_failed() lat │ │ │ -000807e0: 6572 2063 6c65 6172 7320 7061 7373 6564 er clears passed │ │ │ -000807f0: 5f68 6173 685f 6368 6563 6b2e 0a09 0970 _hash_check....p │ │ │ -00080800: 6965 6365 5f69 6e64 6578 5f74 206d 5f63 iece_index_t m_c │ │ │ -00080810: 7572 736f 727b 307d 3b0a 0a09 092f 2f20 ursor{0};....// │ │ │ -00080820: 7765 2068 6176 6520 616c 6c20 7069 6563 we have all piec │ │ │ -00080830: 6573 2069 6e20 7468 6520 7261 6e67 6520 es in the range │ │ │ -00080840: 5b6d 5f72 6576 6572 7365 5f63 7572 736f [m_reverse_curso │ │ │ -00080850: 722c 2065 6e64 5f72 616e 6765 290a 0909 r, end_range)... │ │ │ -00080860: 2f2f 206d 5f72 6576 6572 7365 5f63 7572 // m_reverse_cur │ │ │ -00080870: 736f 7220 6973 2074 6865 2066 6972 7374 sor is the first │ │ │ -00080880: 2070 6965 6365 2077 6865 7265 2077 6520 piece where we │ │ │ -00080890: 616c 736f 2068 6176 650a 0909 2f2f 2061 also have...// a │ │ │ -000808a0: 6c6c 2074 6865 2073 7562 7365 7175 656e ll the subsequen │ │ │ -000808b0: 7420 7069 6563 6573 2e0a 0909 2f2f 2053 t pieces....// S │ │ │ -000808c0: 616d 6520 7374 7269 6374 2d66 6c75 7368 ame strict-flush │ │ │ -000808d0: 6564 2073 656d 616e 7469 6373 2061 7320 ed semantics as │ │ │ -000808e0: 6d5f 6375 7273 6f72 2061 626f 7665 2e0a m_cursor above.. │ │ │ -000808f0: 0909 7069 6563 655f 696e 6465 785f 7420 ..piece_index_t │ │ │ -00080900: 6d5f 7265 7665 7273 655f 6375 7273 6f72 m_reverse_cursor │ │ │ -00080910: 7b30 7d3b 0a0a 0909 2f2f 2074 6865 206e {0};....// the n │ │ │ -00080920: 756d 6265 7220 6f66 2070 6965 6365 7320 umber of pieces │ │ │ -00080930: 7765 2068 6176 6520 2869 2e65 2e20 7061 we have (i.e. pa │ │ │ -00080940: 7373 6564 2068 6173 6820 6368 6563 6b29 ssed hash check) │ │ │ -00080950: 2e0a 0909 2f2f 2054 6869 7320 696e 636c ....// This incl │ │ │ -00080960: 7564 6573 2070 6965 6365 7320 7468 6174 udes pieces that │ │ │ -00080970: 2077 6520 6861 7665 2066 696c 7465 7265 we have filtere │ │ │ -00080980: 6420 6275 7420 7374 696c 6c20 6861 7665 d but still have │ │ │ -00080990: 0a09 0969 6e74 206d 5f6e 756d 5f68 6176 ...int m_num_hav │ │ │ -000809a0: 6520 3d20 303b 0a0a 0909 2f2f 2069 6620 e = 0;....// if │ │ │ -000809b0: 7468 6973 2069 7320 7365 7420 746f 2074 this is set to t │ │ │ -000809c0: 7275 652c 2069 7420 6d65 616e 7320 7570 rue, it means up │ │ │ -000809d0: 6461 7465 5f70 6965 6365 7328 290a 0909 date_pieces()... │ │ │ -000809e0: 2f2f 2068 6173 2074 6f20 6265 2063 616c // has to be cal │ │ │ -000809f0: 6c65 6420 6265 666f 7265 2061 6363 6573 led before acces │ │ │ -00080a00: 7369 6e67 206d 5f70 6965 6365 732e 0a3c sing m_pieces..< │ │ │ -00080a10: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00080a20: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00080a30: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00080a40: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00080a50: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../inc │ │ │ -00080a80: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00080a90: 6175 785f 2f74 6f72 7265 6e74 2e68 7070 aux_/torrent.hpp │ │ │ -00080aa0: 3a32 3835 3c2f 613e 3c2f 7464 3e3c 7464 :285make this a raw │ │ │ -00080ac0: 2070 6f69 6e74 6572 2e20 7065 7268 6170 pointer. perhap │ │ │ -00080ad0: 7320 6b65 6570 2074 6865 2073 6861 7265 s keep the share │ │ │ -00080ae0: 645f 7074 7220 6172 6f75 6e64 2066 7572 d_ptr around fur │ │ │ -00080af0: 7468 6572 2064 6f77 6e20 7468 6520 6f62 ther down the ob │ │ │ -00080b00: 6a65 6374 2074 6f20 6d61 696e 7461 696e ject to maintain │ │ │ -00080b10: 2061 6e20 6f77 6e65 723c 2f74 643e 3c2f an owner

    make this │ │ │ -00080b70: 2061 2072 6177 2070 6f69 6e74 6572 2e20 a raw pointer. │ │ │ -00080b80: 7065 7268 6170 7320 6b65 6570 2074 6865 perhaps keep the │ │ │ -00080b90: 2073 6861 7265 645f 7074 720a 6172 6f75 shared_ptr.arou │ │ │ -00080ba0: 6e64 2066 7572 7468 6572 2064 6f77 6e20 nd further down │ │ │ -00080bb0: 7468 6520 6f62 6a65 6374 2074 6f20 6d61 the object to ma │ │ │ -00080bc0: 696e 7461 696e 2061 6e20 6f77 6e65 723c intain an owner< │ │ │ -00080bd0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -00080be0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -00080bf0: 785f 2f74 6f72 7265 6e74 2e68 7070 3a32 x_/torrent.hpp:2 │ │ │ -00080c00: 3835 3c2f 6834 3e3c 7072 6520 7374 796c 85

    ..bool m_live =
    │ │ │ -00080c50: 2066 616c 7365 3b0a 097d 3b0a 0a09 7374   false;..};...st
    │ │ │ -00080c60: 7275 6374 2054 4f52 5245 4e54 5f45 5854  ruct TORRENT_EXT
    │ │ │ -00080c70: 5241 5f45 5850 4f52 5420 746f 7272 656e  RA_EXPORT torren
    │ │ │ -00080c80: 745f 686f 745f 6d65 6d62 6572 730a 097b  t_hot_members..{
    │ │ │ -00080c90: 0a09 0974 6f72 7265 6e74 5f68 6f74 5f6d  ...torrent_hot_m
    │ │ │ -00080ca0: 656d 6265 7273 2861 7578 3a3a 7365 7373  embers(aux::sess
    │ │ │ -00080cb0: 696f 6e5f 696e 7465 7266 6163 6526 616d  ion_interface&am
    │ │ │ -00080cc0: 703b 2073 6573 0a09 0909 2c20 6164 645f  p; ses...., add_
    │ │ │ -00080cd0: 746f 7272 656e 745f 7061 7261 6d73 2063  torrent_params c
    │ │ │ -00080ce0: 6f6e 7374 2661 6d70 3b20 702c 2062 6f6f  onst& p, boo
    │ │ │ -00080cf0: 6c20 7365 7373 696f 6e5f 7061 7573 6564  l session_paused
    │ │ │ -00080d00: 293b 0a0a 0970 726f 7465 6374 6564 3a0a  );...protected:.
    │ │ │ -00080d10: 0909 2f2f 2074 6865 2070 6965 6365 2070  ..// the piece p
    │ │ │ -00080d20: 6963 6b65 722e 2054 6869 7320 6973 2061  icker. This is a
    │ │ │ -00080d30: 6c6c 6f63 6174 6564 206c 617a 696c 792e  llocated lazily.
    │ │ │ -00080d40: 2057 6865 6e20 7765 2064 6f6e 2774 0a09   When we don't..
    │ │ │ -00080d50: 092f 2f20 6861 7665 2061 6e79 7468 696e  .// have anythin
    │ │ │ -00080d60: 6720 696e 2074 6865 2074 6f72 7265 6e74  g in the torrent
    │ │ │ -00080d70: 2028 666f 7220 696e 7374 616e 6365 2c20   (for instance, 
    │ │ │ -00080d80: 6966 2069 7420 6861 736e 2774 0a09 092f  if it hasn't.../
    │ │ │ -00080d90: 2f20 6265 656e 2073 7461 7274 6564 2079  / been started y
    │ │ │ -00080da0: 6574 2920 6f72 2069 6620 7765 2068 6176  et) or if we hav
    │ │ │ -00080db0: 6520 6576 6572 7974 6869 6e67 2c20 7468  e everything, th
    │ │ │ -00080dc0: 6572 6520 6973 206e 6f0a 0909 2f2f 2070  ere is no...// p
    │ │ │ -00080dd0: 6963 6b65 722e 2049 7427 7320 616c 6c6f  icker. It's allo
    │ │ │ -00080de0: 6361 7465 6420 6f6e 2d64 656d 616e 6420  cated on-demand 
    │ │ │ -00080df0: 7468 6520 6669 7273 7420 7469 6d65 2077  the first time w
    │ │ │ -00080e00: 6520 6e65 6564 0a09 092f 2f20 6974 2069  e need...// it i
    │ │ │ -00080e10: 6e20 746f 7272 656e 743a 3a6e 6565 645f  n torrent::need_
    │ │ │ -00080e20: 7069 636b 6572 2829 2e20 496e 206f 7264  picker(). In ord
    │ │ │ -00080e30: 6572 2074 6f20 7465 6c6c 2074 6865 0a09  er to tell the..
    │ │ │ -00080e40: 092f 2f20 6469 6666 6572 656e 6365 2062  .// difference b
    │ │ │ -00080e50: 6574 7765 656e 2068 6176 696e 6720 6576  etween having ev
    │ │ │ -00080e60: 6572 7974 6869 6e67 2061 6e64 206e 6f74  erything and not
    │ │ │ -00080e70: 6869 6e67 2069 6e0a 0909 2f2f 2074 6865  hing in...// the
    │ │ │ -00080e80: 2063 6173 6520 7468 6572 6520 6973 206e   case there is n
    │ │ │ -00080e90: 6f20 7069 6563 6520 7069 636b 6572 2c20  o piece picker, 
    │ │ │ -00080ea0: 7365 6520 6d5f 6861 7665 5f61 6c6c 2e0a  see m_have_all..
    │ │ │ -00080eb0: 0909 7374 643a 3a75 6e69 7175 655f 7074  ..std::unique_pt
    │ │ │ -00080ec0: 7226 6c74 3b70 6965 6365 5f70 6963 6b65  r<piece_picke
    │ │ │ -00080ed0: 7226 6774 3b20 6d5f 7069 636b 6572 3b0a  r> m_picker;.
    │ │ │ -00080ee0: 0a09 0973 7464 3a3a 756e 6971 7565 5f70  ...std::unique_p
    │ │ │ -00080ef0: 7472 266c 743b 6861 7368 5f70 6963 6b65  tr<hash_picke
    │ │ │ -00080f00: 7226 6774 3b20 6d5f 6861 7368 5f70 6963  r> m_hash_pic
    │ │ │ -00080f10: 6b65 723b 0a0a 3c64 6976 2073 7479 6c65  ker;..
    #if TORRENT_ │ │ │ -00080f50: 4142 495f 5645 5253 494f 4e20 266c 743b ABI_VERSION < │ │ │ -00080f60: 2034 0a3c 2f64 6976 3e09 0973 7464 3a3a 4.
    ..std:: │ │ │ -00080f70: 7368 6172 6564 5f70 7472 266c 743b 746f shared_ptr<to │ │ │ -00080f80: 7272 656e 745f 696e 666f 2667 743b 206d rrent_info> m │ │ │ -00080f90: 5f74 6f72 7265 6e74 5f66 696c 653b 0a23 _torrent_file;.# │ │ │ -00080fa0: 656c 7365 0a09 0973 7464 3a3a 7368 6172 else...std::shar │ │ │ -00080fb0: 6564 5f70 7472 266c 743b 746f 7272 656e ed_ptr<torren │ │ │ -00080fc0: 745f 696e 666f 2063 6f6e 7374 2667 743b t_info const> │ │ │ -00080fd0: 206d 5f74 6f72 7265 6e74 5f66 696c 653b m_torrent_file; │ │ │ -00080fe0: 0a23 656e 6469 660a 0909 7265 6e61 6d65 .#endif...rename │ │ │ -00080ff0: 645f 6669 6c65 7320 6d5f 7265 6e61 6d65 d_files m_rename │ │ │ -00081000: 645f 6669 6c65 733b 0a0a 0909 2f2f 2054 d_files;....// T │ │ │ -00081010: 6869 7320 6973 2074 6865 2073 756d 206f his is the sum o │ │ │ -00081020: 6620 616c 6c20 6e6f 6e2d 7061 6420 6669 f all non-pad fi │ │ │ -00081030: 6c65 2073 697a 6573 2e20 496e 2074 6865 le sizes. In the │ │ │ -00081040: 206e 6578 7420 6d61 6a6f 7220 7665 7273 next major vers │ │ │ -00081050: 696f 6e0a 0909 2f2f 2074 6869 7320 6973 ion...// this is │ │ │ -00081060: 2073 746f 7265 6420 696e 2066 696c 655f stored in file_ │ │ │ -00081070: 7374 6f72 6167 6520 616e 6420 6e6f 206c storage and no l │ │ │ -00081080: 6f6e 6765 7220 6e65 6564 2074 6f20 6265 onger need to be │ │ │ -00081090: 206b 6570 7420 6865 7265 2e0a 0909 7374 kept here....st │ │ │ -000810a0: 643a 3a69 6e74 3634 5f74 206d 5f73 697a d::int64_t m_siz │ │ │ -000810b0: 655f 6f6e 5f64 6973 6b20 3d20 303b 0a0a e_on_disk = 0;.. │ │ │ -000810c0: 0909 2f2f 2061 2062 6163 6b20 7265 6665 ..// a back refe │ │ │ -000810d0: 7265 6e63 6520 746f 2074 6865 2073 6573 rence to the ses │ │ │ -000810e0: 7369 6f6e 0a09 092f 2f20 7468 6973 2074 sion...// this t │ │ │ -000810f0: 6f72 7265 6e74 2062 656c 6f6e 6773 2074 orrent belongs t │ │ │ -00081100: 6f2e 0a09 0961 7578 3a3a 7365 7373 696f o....aux::sessio │ │ │ -00081110: 6e5f 696e 7465 7266 6163 6526 616d 703b n_interface& │ │ │ -00081120: 206d 5f73 6573 3b0a 0a09 092f 2f20 7468 m_ses;....// th │ │ │ -00081130: 6973 2076 6563 746f 7220 6973 2073 6f72 is vector is sor │ │ │ -00081140: 7465 6420 6174 2061 6c6c 2074 696d 6573 ted at all times │ │ │ -00081150: 2c20 6279 2074 6865 2070 6f69 6e74 6572 , by the pointer │ │ │ -00081160: 2076 616c 7565 2e0a 0909 2f2f 2075 7365 value....// use │ │ │ -00081170: 2073 6f72 7465 645f 696e 7365 7274 2829 sorted_insert() │ │ │ -00081180: 2061 6e64 2073 6f72 7465 645f 6669 6e64 and sorted_find │ │ │ -00081190: 2829 206f 6e20 6974 2e20 5468 6520 474e () on it. The GN │ │ │ -000811a0: 5520 5354 4c0a 0909 2f2f 2069 6d70 6c65 U STL...// imple │ │ │ -000811b0: 6d65 6e74 6174 696f 6e20 6f6e 2044 6172 mentation on Dar │ │ │ -000811c0: 7769 6e20 7573 6573 2073 6967 6e69 6669 win uses signifi │ │ │ -000811d0: 6361 6e74 6c79 206c 6573 7320 6d65 6d6f cantly less memo │ │ │ -000811e0: 7279 2074 6f0a 0909 2f2f 2072 6570 7265 ry to...// repre │ │ │ -000811f0: 7365 6e74 2061 2076 6563 746f 7220 7468 sent a vector th │ │ │ -00081200: 616e 2061 2073 6574 2c20 616e 6420 7468 an a set, and th │ │ │ -00081210: 6973 2073 6574 2069 7320 7479 7069 6361 is set is typica │ │ │ -00081220: 6c6c 790a 0909 2f2f 2072 656c 6174 6976 lly...// relativ │ │ │ -00081230: 656c 7920 736d 616c 6c2c 2061 6e64 2069 ely small, and i │ │ │ -00081240: 7427 7320 6368 6561 7020 746f 2063 6f70 t's cheap to cop │ │ │ -00081250: 7920 706f 696e 7465 7273 2e0a 0909 6175 y pointers....au │ │ │ -00081260: 783a 3a76 6563 746f 7226 6c74 3b70 6565 x::vector<pee │ │ │ -00081270: 725f 636f 6e6e 6563 7469 6f6e 2a26 6774 r_connection*> │ │ │ -00081280: 3b20 6d5f 636f 6e6e 6563 7469 6f6e 733b ; m_connections; │ │ │ -00081290: 0a0a 0909 2f2f 2074 6865 2073 6372 6170 ....// the scrap │ │ │ -000812a0: 6520 6461 7461 2066 726f 6d20 7468 6520 e data from the │ │ │ -000812b0: 7472 6163 6b65 7220 7265 7370 6f6e 7365 tracker response │ │ │ -000812c0: 2c20 7468 6973 0a09 092f 2f20 6973 206f , this...// is o │ │ │ -000812d0: 7074 696f 6e61 6c20 616e 6420 6d61 7920 ptional and may │ │ │ -000812e0: 6265 2030 7866 6666 6666 660a 0909 7374 be 0xffffff...st │ │ │ -000812f0: 643a 3a75 696e 7433 325f 7420 6d5f 636f d::uint32_t m_co │ │ │ -00081300: 6d70 6c65 7465 3a32 343b 0a0a 0909 2f2f mplete:24;....// │ │ │ -00081310: 2073 6574 2074 6f20 7472 7565 2077 6865 set to true whe │ │ │ -00081320: 6e20 7468 6973 2074 6f72 7265 6e74 206d n this torrent m │ │ │ -00081330: 6179 206e 6f74 2064 6f77 6e6c 6f61 6420 ay not download │ │ │ -00081340: 616e 7974 6869 6e67 0a09 0973 7464 3a3a anything...std:: │ │ │ -00081350: 7569 6e74 3332 5f74 206d 5f75 706c 6f61 uint32_t m_uploa │ │ │ -00081360: 645f 6d6f 6465 3a31 3b0a 0a09 092f 2f20 d_mode:1;....// │ │ │ -00081370: 7468 6973 2069 7320 7365 7420 746f 2066 this is set to f │ │ │ -00081380: 616c 7365 2061 7320 6c6f 6e67 2061 7320 alse as long as │ │ │ -00081390: 7468 6520 636f 6e6e 6563 7469 6f6e 730a the connections. │ │ │ -000813a0: 0909 2f2f 206f 6620 7468 6973 2074 6f72 ..// of this tor │ │ │ -000813b0: 7265 6e74 2068 6176 656e 2774 2062 6565 rent haven't bee │ │ │ -000813c0: 6e20 696e 6974 6961 6c69 7a65 642e 2049 n initialized. I │ │ │ -000813d0: 6620 7765 0a3c 2f70 7265 3e3c 2f74 643e f we.
    │ │ │ -000813e0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00081410: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00081420: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00081430: 7074 3a65 7870 616e 6428 3239 3429 223e pt:expand(294)"> │ │ │ -00081440: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00081450: 7272 656e 742f 6175 785f 2f74 6f72 7265 rrent/aux_/torre │ │ │ -00081460: 6e74 2e68 7070 3a34 3737 3c2f 613e 3c2f nt.hpp:477make grac │ │ │ -00081480: 6566 756c 2070 6175 7365 2061 6c73 6f20 eful pause also │ │ │ -00081490: 6669 6e69 7368 2061 6c6c 2073 656e 6469 finish all sendi │ │ │ -000814a0: 6e67 2062 6c6f 636b 7320 6265 666f 7265 ng blocks before │ │ │ -000814b0: 2064 6973 636f 6e6e 6563 7469 6e67 3c2f disconnecting

    make │ │ │ -00081510: 2067 7261 6365 6675 6c20 7061 7573 6520 graceful pause │ │ │ -00081520: 616c 736f 2066 696e 6973 6820 616c 6c20 also finish all │ │ │ -00081530: 7365 6e64 696e 6720 626c 6f63 6b73 0a62 sending blocks.b │ │ │ -00081540: 6566 6f72 6520 6469 7363 6f6e 6e65 6374 efore disconnect │ │ │ -00081550: 696e 673c 2f68 323e 3c68 343e 2e2e 2f69 ing

    ../i │ │ │ -00081560: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00081570: 742f 6175 785f 2f74 6f72 7265 6e74 2e68 t/aux_/torrent.h │ │ │ -00081580: 7070 3a34 3737 3c2f 6834 3e3c 7072 6520 pp:477

    ...void on_
    │ │ │ -000815d0: 7265 7375 6d65 5f64 6174 615f 6368 6563  resume_data_chec
    │ │ │ -000815e0: 6b65 6428 7374 6174 7573 5f74 2073 7461  ked(status_t sta
    │ │ │ -000815f0: 7475 732c 2073 746f 7261 6765 5f65 7272  tus, storage_err
    │ │ │ -00081600: 6f72 2063 6f6e 7374 2661 6d70 3b20 6572  or const& er
    │ │ │ -00081610: 726f 7229 3b0a 0909 766f 6964 206f 6e5f  ror);...void on_
    │ │ │ -00081620: 666f 7263 655f 7265 6368 6563 6b28 7374  force_recheck(st
    │ │ │ -00081630: 6174 7573 5f74 2073 7461 7475 732c 2073  atus_t status, s
    │ │ │ -00081640: 746f 7261 6765 5f65 7272 6f72 2063 6f6e  torage_error con
    │ │ │ -00081650: 7374 2661 6d70 3b20 6572 726f 7229 3b0a  st& error);.
    │ │ │ -00081660: 0909 766f 6964 206f 6e5f 7069 6563 655f  ..void on_piece_
    │ │ │ -00081670: 6861 7368 6564 2861 7578 3a3a 7665 6374  hashed(aux::vect
    │ │ │ -00081680: 6f72 266c 743b 7368 6132 3536 5f68 6173  or<sha256_has
    │ │ │ -00081690: 6826 6774 3b20 626c 6f63 6b5f 6861 7368  h> block_hash
    │ │ │ -000816a0: 6573 0a09 0909 2c20 7069 6563 655f 696e  es...., piece_in
    │ │ │ -000816b0: 6465 785f 7420 7069 6563 652c 2073 6861  dex_t piece, sha
    │ │ │ -000816c0: 315f 6861 7368 2063 6f6e 7374 2661 6d70  1_hash const&
    │ │ │ -000816d0: 3b20 7069 6563 655f 6861 7368 0a09 0909  ; piece_hash....
    │ │ │ -000816e0: 2c20 7374 6f72 6167 655f 6572 726f 7220  , storage_error 
    │ │ │ -000816f0: 636f 6e73 7426 616d 703b 2065 7272 6f72  const& error
    │ │ │ -00081700: 293b 0a09 0976 6f69 6420 6669 6c65 735f  );...void files_
    │ │ │ -00081710: 6368 6563 6b65 6428 293b 0a09 0976 6f69  checked();...voi
    │ │ │ -00081720: 6420 7374 6172 745f 6368 6563 6b69 6e67  d start_checking
    │ │ │ -00081730: 2829 3b0a 0a09 0976 6f69 6420 7374 6172  ();....void star
    │ │ │ -00081740: 745f 616e 6e6f 756e 6369 6e67 2829 3b0a  t_announcing();.
    │ │ │ -00081750: 0909 766f 6964 2073 746f 705f 616e 6e6f  ..void stop_anno
    │ │ │ -00081760: 756e 6369 6e67 2829 3b0a 0a09 0976 6f69  uncing();....voi
    │ │ │ -00081770: 6420 7365 6e64 5f75 706c 6f61 645f 6f6e  d send_upload_on
    │ │ │ -00081780: 6c79 2829 3b0a 0a23 6966 6e64 6566 2054  ly();..#ifndef T
    │ │ │ -00081790: 4f52 5245 4e54 5f44 4953 4142 4c45 5f53  ORRENT_DISABLE_S
    │ │ │ -000817a0: 4841 5245 5f4d 4f44 450a 0909 766f 6964  HARE_MODE...void
    │ │ │ -000817b0: 2073 656e 645f 7368 6172 655f 6d6f 6465   send_share_mode
    │ │ │ -000817c0: 2829 3b0a 0909 766f 6964 2073 6574 5f73  ();...void set_s
    │ │ │ -000817d0: 6861 7265 5f6d 6f64 6528 626f 6f6c 2073  hare_mode(bool s
    │ │ │ -000817e0: 293b 0a09 0962 6f6f 6c20 7368 6172 655f  );...bool share_
    │ │ │ -000817f0: 6d6f 6465 2829 2063 6f6e 7374 207b 2072  mode() const { r
    │ │ │ -00081800: 6574 7572 6e20 6d5f 7368 6172 655f 6d6f  eturn m_share_mo
    │ │ │ -00081810: 6465 3b20 7d0a 2365 6e64 6966 0a0a 3c64  de; }.#endif....bo
    │ │ │ -00081850: 6f6c 2067 7261 6365 6675 6c5f 7061 7573  ol graceful_paus
    │ │ │ -00081860: 6528 2920 636f 6e73 7420 7b20 7265 7475  e() const { retu
    │ │ │ -00081870: 726e 206d 5f67 7261 6365 6675 6c5f 7061  rn m_graceful_pa
    │ │ │ -00081880: 7573 655f 6d6f 6465 3b20 7d0a 3c2f 6469  use_mode; }....torrent_fla
    │ │ │ -000818a0: 6773 5f74 2066 6c61 6773 2829 2063 6f6e  gs_t flags() con
    │ │ │ -000818b0: 7374 3b0a 0909 766f 6964 2073 6574 5f66  st;...void set_f
    │ │ │ -000818c0: 6c61 6773 2874 6f72 7265 6e74 5f66 6c61  lags(torrent_fla
    │ │ │ -000818d0: 6773 5f74 2066 6c61 6773 2c20 746f 7272  gs_t flags, torr
    │ │ │ -000818e0: 656e 745f 666c 6167 735f 7420 6d61 736b  ent_flags_t mask
    │ │ │ -000818f0: 293b 0a0a 0909 766f 6964 2073 6574 5f75  );....void set_u
    │ │ │ -00081900: 706c 6f61 645f 6d6f 6465 2862 6f6f 6c20  pload_mode(bool 
    │ │ │ -00081910: 6229 3b0a 0909 626f 6f6c 2075 706c 6f61  b);...bool uploa
    │ │ │ -00081920: 645f 6d6f 6465 2829 2063 6f6e 7374 207b  d_mode() const {
    │ │ │ -00081930: 2072 6574 7572 6e20 6d5f 7570 6c6f 6164   return m_upload
    │ │ │ -00081940: 5f6d 6f64 6520 7c7c 206d 5f67 7261 6365  _mode || m_grace
    │ │ │ -00081950: 6675 6c5f 7061 7573 655f 6d6f 6465 3b20  ful_pause_mode; 
    │ │ │ -00081960: 7d0a 0909 626f 6f6c 2069 735f 7570 6c6f  }...bool is_uplo
    │ │ │ -00081970: 6164 5f6f 6e6c 7928 2920 636f 6e73 7420  ad_only() const 
    │ │ │ -00081980: 7b20 7265 7475 726e 2069 735f 6669 6e69  { return is_fini
    │ │ │ -00081990: 7368 6564 2829 207c 7c20 7570 6c6f 6164  shed() || upload
    │ │ │ -000819a0: 5f6d 6f64 6528 293b 207d 0a0a 0909 696e  _mode(); }....in
    │ │ │ -000819b0: 7420 7365 6564 5f72 616e 6b28 6175 783a  t seed_rank(aux:
    │ │ │ -000819c0: 3a73 6573 7369 6f6e 5f73 6574 7469 6e67  :session_setting
    │ │ │ -000819d0: 7320 636f 6e73 7426 616d 703b 2073 2920  s const& s) 
    │ │ │ -000819e0: 636f 6e73 743b 0a0a 0909 766f 6964 2061  const;....void a
    │ │ │ -000819f0: 6464 5f70 6965 6365 2870 6965 6365 5f69  dd_piece(piece_i
    │ │ │ -00081a00: 6e64 6578 5f74 2070 6965 6365 2c20 6368  ndex_t piece, ch
    │ │ │ -00081a10: 6172 2063 6f6e 7374 2a20 6461 7461 2c20  ar const* data, 
    │ │ │ -00081a20: 6164 645f 7069 6563 655f 666c 6167 735f  add_piece_flags_
    │ │ │ -00081a30: 7420 666c 6167 7329 3b0a 0909 766f 6964  t flags);...void
    │ │ │ -00081a40: 2061 6464 5f70 6965 6365 5f61 7379 6e63   add_piece_async
    │ │ │ -00081a50: 2870 6965 6365 5f69 6e64 6578 5f74 2070  (piece_index_t p
    │ │ │ -00081a60: 6965 6365 2c20 7374 643a 3a76 6563 746f  iece, std::vecto
    │ │ │ -00081a70: 7226 6c74 3b63 6861 7226 6774 3b20 6461  r<char> da
    │ │ │ -00081a80: 7461 2c20 6164 645f 7069 6563 655f 666c  ta, add_piece_fl
    │ │ │ -00081a90: 6167 735f 7420 666c 6167 7329 3b0a 0909  ags_t flags);...
    │ │ │ -00081aa0: 766f 6964 206f 6e5f 6469 736b 5f77 7269  void on_disk_wri
    │ │ │ -00081ab0: 7465 5f63 6f6d 706c 6574 6528 7374 6f72  te_complete(stor
    │ │ │ -00081ac0: 6167 655f 6572 726f 7220 636f 6e73 7426  age_error const&
    │ │ │ -00081ad0: 616d 703b 2065 7272 6f72 0a09 0909 2c20  amp; error...., 
    │ │ │ -00081ae0: 7065 6572 5f72 6571 7565 7374 2063 6f6e  peer_request con
    │ │ │ -00081af0: 7374 2661 6d70 3b20 7029 3b0a 0a09 0976  st& p);....v
    │ │ │ -00081b00: 6f69 6420 7365 745f 7072 6f67 7265 7373  oid set_progress
    │ │ │ -00081b10: 5f70 706d 2869 6e74 2070 2920 7b20 6d5f  _ppm(int p) { m_
    │ │ │ -00081b20: 7072 6f67 7265 7373 5f70 706d 203d 2073  progress_ppm = s
    │ │ │ -00081b30: 7464 3a3a 7569 6e74 3332 5f74 2870 293b  td::uint32_t(p);
    │ │ │ -00081b40: 207d 0a09 0973 7472 7563 7420 7265 6164   }...struct read
    │ │ │ -00081b50: 5f70 6965 6365 5f73 7472 7563 740a 0909  _piece_struct...
    │ │ │ -00081b60: 7b0a 0909 0962 6f6f 7374 3a3a 7368 6172  {....boost::shar
    │ │ │ -00081b70: 6564 5f61 7272 6179 266c 743b 6368 6172  ed_array<char
    │ │ │ -00081b80: 2667 743b 2070 6965 6365 5f64 6174 613b  > piece_data;
    │ │ │ -00081b90: 0a09 0909 696e 7420 626c 6f63 6b73 5f6c  ....int blocks_l
    │ │ │ -00081ba0: 6566 743b 0a09 0909 626f 6f6c 2066 6169  eft;....bool fai
    │ │ │ -00081bb0: 6c3b 0a09 0909 6572 726f 725f 636f 6465  l;....error_code
    │ │ │ -00081bc0: 2065 7272 6f72 3b0a 0909 7d3b 0a09 0976   error;...};...v
    │ │ │ -00081bd0: 6f69 6420 7265 6164 5f70 6965 6365 2870  oid read_piece(p
    │ │ │ -00081be0: 6965 6365 5f69 6e64 6578 5f74 293b 0a09  iece_index_t);..
    │ │ │ -00081bf0: 0976 6f69 6420 7365 745f 7365 7175 656e  .void set_sequen
    │ │ │ -00081c00: 7469 616c 5f72 616e 6765 2870 6965 6365  tial_range(piece
    │ │ │ -00081c10: 5f69 6e64 6578 5f74 2066 6972 7374 5f70  _index_t first_p
    │ │ │ -00081c20: 6965 6365 2c20 7069 6563 655f 696e 6465  iece, piece_inde
    │ │ │ -00081c30: 785f 7420 6c61 7374 5f70 6965 6365 293b  x_t last_piece);
    │ │ │ -00081c40: 0a09 0976 6f69 6420 7365 745f 7365 7175  ...void set_sequ
    │ │ │ -00081c50: 656e 7469 616c 5f72 616e 6765 2870 6965  ential_range(pie
    │ │ │ -00081c60: 6365 5f69 6e64 6578 5f74 2066 6972 7374  ce_index_t first
    │ │ │ -00081c70: 5f70 6965 6365 293b 0a09 0976 6f69 6420  _piece);...void 
    │ │ │ -00081c80: 6f6e 5f64 6973 6b5f 7265 6164 5f63 6f6d  on_disk_read_com
    │ │ │ -00081c90: 706c 6574 6528 6469 736b 5f62 7566 6665  plete(disk_buffe
    │ │ │ -00081ca0: 725f 686f 6c64 6572 2c20 7374 6f72 6167  r_holder, storag
    │ │ │ -00081cb0: 655f 6572 726f 7220 636f 6e73 7426 616d  e_error const&am
    │ │ │ -00081cc0: 703b 0a09 0909 2c20 7065 6572 5f72 6571  p;...., peer_req
    │ │ │ -00081cd0: 7565 7374 2063 6f6e 7374 2661 6d70 3b2c  uest const&,
    │ │ │ -00081ce0: 2073 7464 3a3a 7368 6172 6564 5f70 7472   std::shared_ptr
    │ │ │ -00081cf0: 266c 743b 7265 6164 5f70 6965 6365 5f73  <read_piece_s
    │ │ │ -00081d00: 7472 7563 7426 6774 3b29 3b0a 0a09 0973  truct>);....s
    │ │ │ -00081d10: 746f 7261 6765 5f6d 6f64 655f 7420 7374  torage_mode_t st
    │ │ │ -00081d20: 6f72 6167 655f 6d6f 6465 2829 2063 6f6e  orage_mode() con
    │ │ │ -00081d30: 7374 3b0a 3c2f 7072 653e 3c2f 7464 3e3c  st;.
    < │ │ │ -00081d40: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00081d70: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00081da0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00081db0: 7265 6e74 2f61 7578 5f2f 746f 7272 656e rent/aux_/torren │ │ │ -00081dc0: 742e 6870 703a 3134 3832 3c2f 613e 3c2f t.hpp:1482this wast │ │ │ -00081de0: 6573 2035 2062 6974 7320 7065 7220 6669 es 5 bits per fi │ │ │ -00081df0: 6c65 3c2f 7464 3e3c 2f74 723e 3c74 7220 le

    │ │ │ -00081e40: 7468 6973 2077 6173 7465 7320 3520 6269 this wastes 5 bi │ │ │ -00081e50: 7473 2070 6572 2066 696c 653c 2f68 323e ts per file

    │ │ │ -00081e60: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00081e70: 6962 746f 7272 656e 742f 6175 785f 2f74 ibtorrent/aux_/t │ │ │ -00081e80: 6f72 7265 6e74 2e68 7070 3a31 3438 323c orrent.hpp:1482< │ │ │ -00081e90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #i
    │ │ │ -00081ed0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ -00081ee0: 5341 424c 455f 4558 5445 4e53 494f 4e53  SABLE_EXTENSIONS
    │ │ │ -00081ef0: 0a09 0973 7464 3a3a 6c69 7374 266c 743b  ...std::list<
    │ │ │ -00081f00: 7374 643a 3a73 6861 7265 645f 7074 7226  std::shared_ptr&
    │ │ │ -00081f10: 6c74 3b74 6f72 7265 6e74 5f70 6c75 6769  lt;torrent_plugi
    │ │ │ -00081f20: 6e26 6774 3b26 6774 3b20 6d5f 6578 7465  n>> m_exte
    │ │ │ -00081f30: 6e73 696f 6e73 3b0a 2365 6e64 6966 0a0a  nsions;.#endif..
    │ │ │ -00081f40: 0909 2f2f 2075 7365 6420 666f 7220 7472  ..// used for tr
    │ │ │ -00081f50: 6163 6b65 7220 616e 6e6f 756e 6365 730a  acker announces.
    │ │ │ -00081f60: 0909 6465 6164 6c69 6e65 5f74 696d 6572  ..deadline_timer
    │ │ │ -00081f70: 206d 5f74 7261 636b 6572 5f74 696d 6572   m_tracker_timer
    │ │ │ -00081f80: 3b0a 0a09 092f 2f20 7573 6564 2074 6f20  ;....// used to 
    │ │ │ -00081f90: 6465 7465 6374 2077 6865 6e20 7765 2061  detect when we a
    │ │ │ -00081fa0: 7265 2061 6374 6976 6520 6f72 2069 6e61  re active or ina
    │ │ │ -00081fb0: 6374 6976 6520 666f 7220 6c6f 6e67 2065  ctive for long e
    │ │ │ -00081fc0: 6e6f 7567 680a 0909 2f2f 2074 6f20 7472  nough...// to tr
    │ │ │ -00081fd0: 6967 6765 7220 7468 6520 6175 746f 2d6d  igger the auto-m
    │ │ │ -00081fe0: 616e 6167 6520 6c6f 6769 630a 0909 6465  anage logic...de
    │ │ │ -00081ff0: 6164 6c69 6e65 5f74 696d 6572 206d 5f69  adline_timer m_i
    │ │ │ -00082000: 6e61 6374 6976 6974 795f 7469 6d65 723b  nactivity_timer;
    │ │ │ -00082010: 0a0a 0909 2f2f 2074 6869 7320 6973 2074  ....// this is t
    │ │ │ -00082020: 6865 2075 706c 6f61 6420 616e 6420 646f  he upload and do
    │ │ │ -00082030: 776e 6c6f 6164 2073 7461 7469 7374 6963  wnload statistic
    │ │ │ -00082040: 7320 666f 7220 7468 6520 7768 6f6c 6520  s for the whole 
    │ │ │ -00082050: 746f 7272 656e 742e 0a09 092f 2f20 6974  torrent....// it
    │ │ │ -00082060: 2773 2075 7064 6174 6564 2066 726f 6d20  's updated from 
    │ │ │ -00082070: 616c 6c20 6974 7320 7065 6572 7320 6f6e  all its peers on
    │ │ │ -00082080: 6365 2065 7665 7279 2073 6563 6f6e 642e  ce every second.
    │ │ │ -00082090: 0a09 0973 7461 7420 6d5f 7374 6174 3b0a  ...stat m_stat;.
    │ │ │ -000820a0: 0a09 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d  ...// ----------
    │ │ │ -000820b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -000820c0: 2d2d 2d0a 0a09 092f 2f20 7468 6973 2076  ---....// this v
    │ │ │ -000820d0: 6563 746f 7220 6973 2061 6c6c 6f63 6174  ector is allocat
    │ │ │ -000820e0: 6564 206c 617a 696c 792e 2049 6620 6e6f  ed lazily. If no
    │ │ │ -000820f0: 2066 696c 6520 7072 696f 7269 7469 6573   file priorities
    │ │ │ -00082100: 2061 7265 0a09 092f 2f20 6576 6572 2063   are...// ever c
    │ │ │ -00082110: 6861 6e67 6564 2c20 7468 6973 2072 656d  hanged, this rem
    │ │ │ -00082120: 6169 6e73 2065 6d70 7479 2e20 416e 7920  ains empty. Any 
    │ │ │ -00082130: 756e 616c 6c6f 6361 7465 6420 736c 6f74  unallocated slot
    │ │ │ -00082140: 0a09 092f 2f20 696d 706c 6963 6974 6c79  ...// implicitly
    │ │ │ -00082150: 206d 6561 6e73 2074 6865 2066 696c 6520   means the file 
    │ │ │ -00082160: 6861 7320 7072 696f 7269 7479 2034 2e0a  has priority 4..
    │ │ │ -00082170: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -000821a0: 6175 783a 3a76 6563 746f 7226 6c74 3b64 aux::vector<d │ │ │ -000821b0: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ -000821c0: 5f74 2c20 6669 6c65 5f69 6e64 6578 5f74 _t, file_index_t │ │ │ -000821d0: 2667 743b 206d 5f66 696c 655f 7072 696f > m_file_prio │ │ │ -000821e0: 7269 7479 3b0a 3c2f 6469 763e 0a09 092f rity;.
    .../ │ │ │ -000821f0: 2f20 616e 7920 6669 6c65 2070 7269 6f72 / any file prior │ │ │ -00082200: 6974 7920 7570 6461 7465 7320 6174 7465 ity updates atte │ │ │ -00082210: 6d70 7465 6420 7768 696c 6520 616e 6f74 mpted while anot │ │ │ -00082220: 6865 7220 6669 6c65 2070 7269 6f72 6974 her file priorit │ │ │ -00082230: 7920 7570 6461 7465 0a09 092f 2f20 6973 y update...// is │ │ │ -00082240: 2069 6e2d 7072 6f67 7265 7373 2f6f 7574 in-progress/out │ │ │ -00082250: 7374 616e 6469 6e67 2077 6974 6820 7468 standing with th │ │ │ -00082260: 6520 6469 736b 2049 2f4f 2074 6872 6561 e disk I/O threa │ │ │ -00082270: 642c 2061 7265 2071 7565 7565 6420 7570 d, are queued up │ │ │ -00082280: 2069 6e0a 0909 2f2f 2074 6869 7320 6469 in...// this di │ │ │ -00082290: 6374 696f 6e61 7279 2e20 4f6e 6365 2074 ctionary. Once t │ │ │ -000822a0: 6865 206f 7574 7374 616e 6469 6e67 2075 he outstanding u │ │ │ -000822b0: 7064 6174 6520 636f 6d65 7320 6261 636b pdate comes back │ │ │ -000822c0: 2c20 616c 6c20 6f66 2074 6865 7365 0a09 , all of these.. │ │ │ -000822d0: 092f 2f20 6172 6520 6170 706c 6965 6420 .// are applied │ │ │ -000822e0: 696e 206f 6e65 2062 6174 6368 0a09 0973 in one batch...s │ │ │ -000822f0: 7464 3a3a 6d61 7026 6c74 3b66 696c 655f td::map<file_ │ │ │ -00082300: 696e 6465 785f 742c 2064 6f77 6e6c 6f61 index_t, downloa │ │ │ -00082310: 645f 7072 696f 7269 7479 5f74 2667 743b d_priority_t> │ │ │ -00082320: 206d 5f64 6566 6572 7265 645f 6669 6c65 m_deferred_file │ │ │ -00082330: 5f70 7269 6f72 6974 6965 733b 0a0a 0909 _priorities;.... │ │ │ -00082340: 2f2f 2074 6869 7320 6f62 6a65 6374 2069 // this object i │ │ │ -00082350: 7320 7573 6564 2074 6f20 7472 6163 6b20 s used to track │ │ │ -00082360: 646f 776e 6c6f 6164 2070 726f 6772 6573 download progres │ │ │ -00082370: 7320 6f66 2069 6e64 6976 6964 7561 6c20 s of individual │ │ │ -00082380: 6669 6c65 730a 0909 6175 783a 3a66 696c files...aux::fil │ │ │ -00082390: 655f 7072 6f67 7265 7373 206d 5f66 696c e_progress m_fil │ │ │ -000823a0: 655f 7072 6f67 7265 7373 3b0a 0a09 092f e_progress;..../ │ │ │ -000823b0: 2f20 6120 7175 6575 6520 6f66 2074 6865 / a queue of the │ │ │ -000823c0: 206d 6f73 7420 7265 6365 6e74 206c 6f77 most recent low │ │ │ -000823d0: 2d61 7661 696c 6162 696c 6974 7920 7069 -availability pi │ │ │ -000823e0: 6563 6573 2077 6520 6163 6365 7373 6564 eces we accessed │ │ │ -000823f0: 206f 6e20 6469 736b 2e0a 0909 2f2f 2054 on disk....// T │ │ │ -00082400: 6865 7365 2061 7265 2067 6f6f 6420 6361 hese are good ca │ │ │ -00082410: 6e64 6964 6174 6573 2066 6f72 2073 7567 ndidates for sug │ │ │ -00082420: 6765 7374 696e 6720 6f74 6865 7220 7065 gesting other pe │ │ │ -00082430: 6572 7320 746f 2072 6571 7565 7374 2066 ers to request f │ │ │ -00082440: 726f 6d0a 0909 2f2f 2075 732e 0a09 0961 rom...// us....a │ │ │ -00082450: 7578 3a3a 7375 6767 6573 745f 7069 6563 ux::suggest_piec │ │ │ -00082460: 6520 6d5f 7375 6767 6573 745f 7069 6563 e m_suggest_piec │ │ │ -00082470: 6573 3b0a 0a09 0961 7578 3a3a 7472 6163 es;....aux::trac │ │ │ -00082480: 6b65 725f 6c69 7374 206d 5f74 7261 636b ker_list m_track │ │ │ -00082490: 6572 733b 0a0a 2369 666e 6465 6620 544f ers;..#ifndef TO │ │ │ -000824a0: 5252 454e 545f 4449 5341 424c 455f 5354 RRENT_DISABLE_ST │ │ │ -000824b0: 5245 414d 494e 470a 0909 2f2f 2074 6869 REAMING...// thi │ │ │ -000824c0: 7320 6c69 7374 2069 7320 736f 7274 6564 s list is sorted │ │ │ -000824d0: 2062 7920 7469 6d65 5f63 7269 7469 6361 by time_critica │ │ │ -000824e0: 6c5f 7069 6563 653a 3a64 6561 646c 696e l_piece::deadlin │ │ │ -000824f0: 650a 0909 7374 643a 3a76 6563 746f 7226 e...std::vector& │ │ │ -00082500: 6c74 3b74 696d 655f 6372 6974 6963 616c lt;time_critical │ │ │ -00082510: 5f70 6965 6365 2667 743b 206d 5f74 696d _piece> m_tim │ │ │ -00082520: 655f 6372 6974 6963 616c 5f70 6965 6365 e_critical_piece │ │ │ -00082530: 733b 0a23 656e 6469 660a 0a09 0973 7464 s;.#endif....std │ │ │ -00082540: 3a3a 7374 7269 6e67 206d 5f74 7261 636b ::string m_track │ │ │ -00082550: 6572 6964 3b0a 2369 6620 544f 5252 454e erid;.#if TORREN │ │ │ -00082560: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -00082570: 2031 0a09 092f 2f20 6465 7072 6563 6174 1...// deprecat │ │ │ -00082580: 6564 2069 6e20 312e 310a 0909 7374 643a ed in 1.1...std: │ │ │ -00082590: 3a73 7472 696e 6720 6d5f 7573 6572 6e61 :string m_userna │ │ │ -000825a0: 6d65 3b0a 0909 7374 643a 3a73 7472 696e me;...std::strin │ │ │ -000825b0: 6720 6d5f 7061 7373 776f 7264 3b0a 2365 g m_password;.#e │ │ │ -000825c0: 6e64 6966 0a0a 0909 7374 643a 3a73 7472 ndif....std::str │ │ │ -000825d0: 696e 6720 6d5f 7361 7665 5f70 6174 683b ing m_save_path; │ │ │ -000825e0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00082620: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -00082650: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00082660: 742f 6175 785f 2f74 6f72 7265 6e74 2e68 t/aux_/torrent.h │ │ │ -00082670: 7070 3a31 3739 343c 2f61 3e3c 2f74 643e pp:1794 │ │ │ -00082680: 3c74 643e 7468 6973 206d 656d 6265 7220 this member │ │ │ -00082690: 6361 6e20 7072 6f62 6162 6c79 2062 6520 can probably be │ │ │ -000826a0: 7265 6d6f 7665 643c 2f74 643e 3c2f 7472 removed

    this member │ │ │ -00082700: 2063 616e 2070 726f 6261 626c 7920 6265 can probably be │ │ │ -00082710: 2072 656d 6f76 6564 3c2f 6832 3e3c 6834 removed

    ../include/libt │ │ │ -00082730: 6f72 7265 6e74 2f61 7578 5f2f 746f 7272 orrent/aux_/torr │ │ │ -00082740: 656e 742e 6870 703a 3137 3934 3c2f 6834 ent.hpp:1794

    ...//
    │ │ │ -00082790: 2034 2075 6e75 7365 6420 6269 7473 0a0a   4 unused bits..
    │ │ │ -000827a0: 0909 2f2f 2077 6865 6e20 7468 6973 2069  ..// when this i
    │ │ │ -000827b0: 7320 7472 7565 2c20 7468 6973 2074 6f72  s true, this tor
    │ │ │ -000827c0: 7265 6e74 2073 7570 706f 7274 7320 7065  rent supports pe
    │ │ │ -000827d0: 6572 2065 7863 6861 6e67 650a 0909 7374  er exchange...st
    │ │ │ -000827e0: 643a 3a75 696e 7433 325f 7420 6d5f 656e  d::uint32_t m_en
    │ │ │ -000827f0: 6162 6c65 5f70 6578 3a31 3b0a 0a09 092f  able_pex:1;..../
    │ │ │ -00082800: 2f20 7365 7420 746f 2074 7275 6520 6966  / set to true if
    │ │ │ -00082810: 2074 6865 2073 6573 7369 6f6e 2049 5020   the session IP 
    │ │ │ -00082820: 6669 6c74 6572 2061 7070 6c69 6573 2074  filter applies t
    │ │ │ -00082830: 6f20 7468 6973 0a09 092f 2f20 746f 7272  o this...// torr
    │ │ │ -00082840: 656e 7420 6f72 206e 6f74 2e20 4465 6661  ent or not. Defa
    │ │ │ -00082850: 756c 7473 2074 6f20 7472 7565 2e0a 0909  ults to true....
    │ │ │ -00082860: 7374 643a 3a75 696e 7433 325f 7420 6d5f  std::uint32_t m_
    │ │ │ -00082870: 6170 706c 795f 6970 5f66 696c 7465 723a  apply_ip_filter:
    │ │ │ -00082880: 313b 0a0a 0909 2f2f 2074 6869 7320 6973  1;....// this is
    │ │ │ -00082890: 2074 7275 6520 7768 656e 206f 7572 2065   true when our e
    │ │ │ -000828a0: 6666 6563 7469 7665 2069 6e61 6374 6976  ffective inactiv
    │ │ │ -000828b0: 6520 7374 6174 6520 6973 2064 6966 6665  e state is diffe
    │ │ │ -000828c0: 7265 6e74 2066 726f 6d20 6f75 720a 0909  rent from our...
    │ │ │ -000828d0: 2f2f 2061 6374 7561 6c20 696e 6163 7469  // actual inacti
    │ │ │ -000828e0: 7665 2073 7461 7465 2e20 5768 656e 6576  ve state. Whenev
    │ │ │ -000828f0: 6572 2074 6869 7320 7374 6174 6520 6368  er this state ch
    │ │ │ -00082900: 616e 6765 732c 2074 6865 7265 2069 7320  anges, there is 
    │ │ │ -00082910: 610a 0909 2f2f 2071 7561 7261 6e74 696e  a...// quarantin
    │ │ │ -00082920: 6520 7065 7269 6f64 2075 6e74 696c 2077  e period until w
    │ │ │ -00082930: 6520 6368 616e 6765 2074 6865 2065 6666  e change the eff
    │ │ │ -00082940: 6563 7469 7665 2073 7461 7465 2e20 5468  ective state. Th
    │ │ │ -00082950: 6973 2069 7320 746f 2061 766f 6964 0a09  is is to avoid..
    │ │ │ -00082960: 092f 2f20 666c 6170 7069 6e67 2e20 4966  .// flapping. If
    │ │ │ -00082970: 2074 6865 2073 7461 7465 2063 6861 6e67   the state chang
    │ │ │ -00082980: 6573 2062 6163 6b20 6475 7269 6e67 2074  es back during t
    │ │ │ -00082990: 6869 7320 7065 7269 6f64 2c20 7765 2063  his period, we c
    │ │ │ -000829a0: 616e 6365 6c20 7468 650a 0909 2f2f 2071  ancel the...// q
    │ │ │ -000829b0: 7561 7261 6e74 696e 650a 0909 7374 643a  uarantine...std:
    │ │ │ -000829c0: 3a75 696e 7433 325f 7420 6d5f 7065 6e64  :uint32_t m_pend
    │ │ │ -000829d0: 696e 675f 6163 7469 7665 5f63 6861 6e67  ing_active_chang
    │ │ │ -000829e0: 653a 313b 0a0a 2369 6620 544f 5252 454e  e:1;..#if TORREN
    │ │ │ -000829f0: 545f 4142 495f 5645 5253 494f 4e20 266c  T_ABI_VERSION &l
    │ │ │ -00082a00: 743b 2034 0a09 092f 2f20 7468 6973 2069  t; 4...// this i
    │ │ │ -00082a10: 7320 7365 7420 746f 2074 7275 6520 6966  s set to true if
    │ │ │ -00082a20: 2061 6c6c 2070 6965 6365 206c 6179 6572   all piece layer
    │ │ │ -00082a30: 7320 7765 7265 2073 7563 6365 7373 6675  s were successfu
    │ │ │ -00082a40: 6c6c 7920 6c6f 6164 6564 2061 6e64 0a09  lly loaded and..
    │ │ │ -00082a50: 092f 2f20 7661 6c69 6461 7465 642e 204f  .// validated. O
    │ │ │ -00082a60: 6e6c 7920 666f 7220 7632 2074 6f72 7265  nly for v2 torre
    │ │ │ -00082a70: 6e74 730a 3c64 6976 2073 7479 6c65 3d22  nts.
    ..std::uint32_ │ │ │ -00082ab0: 7420 6d5f 7632 5f70 6965 6365 5f6c 6179 t m_v2_piece_lay │ │ │ -00082ac0: 6572 735f 7661 6c69 6461 7465 643a 313b ers_validated:1; │ │ │ -00082ad0: 0a3c 2f64 6976 3e23 656e 6469 660a 0a2f .
    #endif../ │ │ │ -00082ae0: 2f20 2d2d 2d2d 0a0a 0909 2f2f 2074 6869 / ----....// thi │ │ │ -00082af0: 7320 6973 2073 6574 2074 6f20 7468 6520 s is set to the │ │ │ -00082b00: 636f 6e6e 6563 7420 626f 6f73 7420 7175 connect boost qu │ │ │ -00082b10: 6f74 6120 666f 7220 7468 6973 2074 6f72 ota for this tor │ │ │ -00082b20: 7265 6e74 2e0a 0909 2f2f 2041 6674 6572 rent....// After │ │ │ -00082b30: 2068 6176 696e 6720 7265 6365 6976 6564 having received │ │ │ -00082b40: 2074 6869 7320 6d61 6e79 2070 7269 6f72 this many prior │ │ │ -00082b50: 6974 7920 7065 6572 2063 6f6e 6e65 6374 ity peer connect │ │ │ -00082b60: 696f 6e20 6174 7465 6d70 7473 2c20 6974 ion attempts, it │ │ │ -00082b70: 0a09 092f 2f20 6661 6c6c 7320 6261 636b ...// falls back │ │ │ -00082b80: 206f 6e74 6f20 7468 6520 7374 6561 6479 onto the steady │ │ │ -00082b90: 2073 7461 7465 2070 6565 7220 636f 6e6e state peer conn │ │ │ -00082ba0: 6563 7469 6f6e 206c 6f67 6963 2c20 6472 ection logic, dr │ │ │ -00082bb0: 6976 656e 2062 7920 7468 650a 0909 2f2f iven by the...// │ │ │ -00082bc0: 2073 6573 7369 6f6e 2074 6963 6b2e 2045 session tick. E │ │ │ -00082bd0: 6163 6820 7472 6163 6b65 7220 7265 7370 ach tracker resp │ │ │ -00082be0: 6f6e 7365 2c20 6173 206c 6f6e 6720 6173 onse, as long as │ │ │ -00082bf0: 2074 6869 7320 6973 206e 6f6e 2d7a 6572 this is non-zer │ │ │ -00082c00: 6f2c 2077 696c 6c0a 0909 2f2f 2061 7474 o, will...// att │ │ │ -00082c10: 656d 7074 2074 6f20 636f 6e6e 6563 7420 empt to connect │ │ │ -00082c20: 746f 2070 6565 7273 2069 6d6d 6564 6961 to peers immedia │ │ │ -00082c30: 7465 6c79 2061 6e64 2064 6563 7265 6d65 tely and decreme │ │ │ -00082c40: 6e74 2074 6865 2063 6f75 6e74 6572 2e0a nt the counter.. │ │ │ -00082c50: 0909 2f2f 2057 6520 6769 7665 2074 6f72 ..// We give tor │ │ │ -00082c60: 7265 6e74 7320 6120 636f 6e6e 6563 7420 rents a connect │ │ │ -00082c70: 626f 6f73 7420 7768 656e 2074 6865 7920 boost when they │ │ │ -00082c80: 6172 6520 6669 7273 7420 6164 6465 6420 are first added │ │ │ -00082c90: 616e 6420 7468 656e 0a09 092f 2f20 6576 and then...// ev │ │ │ -00082ca0: 6572 7920 7469 6d65 2074 6865 7920 7265 ery time they re │ │ │ -00082cb0: 7375 6d65 2066 726f 6d20 6265 696e 6720 sume from being │ │ │ -00082cc0: 7061 7573 6564 2e0a 0909 7374 643a 3a75 paused....std::u │ │ │ -00082cd0: 696e 7438 5f74 206d 5f63 6f6e 6e65 6374 int8_t m_connect │ │ │ -00082ce0: 5f62 6f6f 7374 5f63 6f75 6e74 6572 3b0a _boost_counter;. │ │ │ -00082cf0: 0a2f 2f20 2d2d 2d2d 0a0a 0909 2f2f 2074 .// ----....// t │ │ │ -00082d00: 6865 2073 6372 6170 6520 6461 7461 2066 he scrape data f │ │ │ -00082d10: 726f 6d20 7468 6520 7472 6163 6b65 7220 rom the tracker │ │ │ -00082d20: 7265 7370 6f6e 7365 2c20 7468 6973 0a09 response, this.. │ │ │ -00082d30: 092f 2f20 6973 206f 7074 696f 6e61 6c20 .// is optional │ │ │ -00082d40: 616e 6420 6d61 7920 6265 2030 7866 6666 and may be 0xfff │ │ │ -00082d50: 6666 660a 0909 7374 643a 3a75 696e 7433 fff...std::uint3 │ │ │ -00082d60: 325f 7420 6d5f 696e 636f 6d70 6c65 7465 2_t m_incomplete │ │ │ -00082d70: 3a32 343b 0a0a 0909 2f2f 2074 7275 6520 :24;....// true │ │ │ -00082d80: 7768 656e 2074 6865 2074 6f72 7265 6e74 when the torrent │ │ │ -00082d90: 2073 686f 756c 6420 616e 6e6f 756e 6365 should announce │ │ │ -00082da0: 2074 6f0a 0909 2f2f 2074 6865 2044 4854 to...// the DHT │ │ │ -00082db0: 0a09 0973 7464 3a3a 7569 6e74 3332 5f74 ...std::uint32_t │ │ │ -00082dc0: 206d 5f61 6e6e 6f75 6e63 655f 746f 5f64 m_announce_to_d │ │ │ -00082dd0: 6874 3a31 3b0a 0a09 092f 2f20 6576 656e ht:1;....// even │ │ │ -00082de0: 2069 6620 7765 2772 6520 6e6f 7420 6275 if we're not bu │ │ │ -00082df0: 696c 7420 746f 2073 7570 706f 7274 2053 ilt to support S │ │ │ -00082e00: 534c 2074 6f72 7265 6e74 732c 0a09 092f SL torrents,.../ │ │ │ -00082e10: 2f20 7265 6d65 6d62 6572 2074 6861 7420 / remember that │ │ │ -00082e20: 7468 6973 2069 7320 616e 2053 534c 2074 this is an SSL t │ │ │ -00082e30: 6f72 7265 6e74 2c20 736f 2074 6861 7420 orrent, so that │ │ │ -00082e40: 7765 2064 6f6e 2774 0a09 092f 2f20 6163 we don't...// ac │ │ │ -00082e50: 6369 6465 6e74 616c 6c79 2073 7461 7274 cidentally start │ │ │ -00082e60: 2073 6565 6469 6e67 2069 7420 7769 7468 seeding it with │ │ │ -00082e70: 6f75 7420 616e 7920 6175 7468 656e 7469 out any authenti │ │ │ -00082e80: 6361 7469 6f6e 2e0a 0909 7374 643a 3a75 cation....std::u │ │ │ -00082e90: 696e 7433 325f 7420 6d5f 7373 6c5f 746f int32_t m_ssl_to │ │ │ -00082ea0: 7272 656e 743a 313b 0a0a 0909 2f2f 2074 rrent:1;....// t │ │ │ -00082eb0: 6869 7320 6973 2073 6574 2074 6f20 7472 his is set to tr │ │ │ -00082ec0: 7565 2069 6620 7765 2772 6520 7472 7969 ue if we're tryi │ │ │ -00082ed0: 6e67 2074 6f20 6465 6c65 7465 2074 6865 ng to delete the │ │ │ -00082ee0: 0a09 092f 2f20 6669 6c65 7320 6265 6c6f ...// files belo │ │ │ -00082ef0: 6e67 696e 6720 746f 2069 742e 2057 6865 nging to it. Whe │ │ │ -00082f00: 6e20 7365 742c 2064 6f6e 2774 2077 7269 n set, don't wri │ │ │ -00082f10: 7465 2061 6e79 0a3c 2f70 7265 3e3c 2f74 te any.
    relevanc │ │ │ -00082f50: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -00082f90: 746f 7272 656e 742f 6175 785f 2f73 746f torrent/aux_/sto │ │ │ -00082fa0: 7265 5f62 7566 6665 722e 6870 703a 3834 re_buffer.hpp:84 │ │ │ -00082fb0: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 7420 it │ │ │ -00082fc0: 776f 756c 6420 6265 206e 6963 6520 6966 would be nice if │ │ │ -00082fd0: 2074 6869 7320 636f 756c 6420 6265 2063 this could be c │ │ │ -00082fe0: 616c 6c65 6420 7769 7468 6f75 7420 686f alled without ho │ │ │ -00082ff0: 6c64 696e 6720 7468 6520 6d75 7465 782e lding the mutex. │ │ │ -00083000: 2049 7420 776f 756c 6420 7265 7175 6972 It would requir │ │ │ -00083010: 6520 6120 7265 6665 7265 6e63 6520 636f e a reference co │ │ │ -00083020: 756e 7465 7220 6f6e 2074 6865 2073 746f unter on the sto │ │ │ -00083030: 7265 2062 7566 6665 7220 656e 7472 6965 re buffer entrie │ │ │ -00083040: 7320 616e 6420 7468 6174 2077 6520 706f s and that we po │ │ │ -00083050: 7465 6e74 6961 6c6c 7920 6572 6173 6573 tentially erases │ │ │ -00083060: 2069 7420 6166 7465 7220 7468 6973 2063 it after this c │ │ │ -00083070: 616c 6c2e 2069 7420 776f 756c 6420 616c all. it would al │ │ │ -00083080: 736f 2072 6571 7569 7265 2074 6865 2073 so require the s │ │ │ -00083090: 746f 7265 2062 7566 6665 7220 6265 696e tore buffer bein │ │ │ -000830a0: 6720 6162 6c65 2074 6f20 7461 6b65 206f g able to take o │ │ │ -000830b0: 7665 7220 6f77 6e65 7273 6869 7020 6f66 ver ownership of │ │ │ -000830c0: 2074 6865 2062 7566 6665 7220 7768 656e the buffer when │ │ │ -000830d0: 2074 6865 206f 776e 6572 2065 7261 7365 the owner erase │ │ │ -000830e0: 7320 6974 2e20 5065 7268 6170 7320 6572 s it. Perhaps er │ │ │ -000830f0: 6173 6528 2920 636f 756c 6420 6265 206d ase() could be m │ │ │ -00083100: 6164 6520 746f 2074 616b 6520 6120 6275 ade to take a bu │ │ │ -00083110: 6666 6572 5f68 6f6c 6465 722c 2077 6869 ffer_holder, whi │ │ │ -00083120: 6368 2069 7320 6865 6c64 206f 6e74 6f20 ch is held onto │ │ │ -00083130: 6966 2074 6865 2072 6566 636f 756e 7420 if the refcount │ │ │ -00083140: 3e20 303c 2f74 643e 3c2f 7472 3e3c 7472 > 0

    it would be nic │ │ │ -000831a0: 6520 6966 2074 6869 7320 636f 756c 6420 e if this could │ │ │ -000831b0: 6265 2063 616c 6c65 6420 7769 7468 6f75 be called withou │ │ │ -000831c0: 7420 686f 6c64 696e 670a 7468 6520 6d75 t holding.the mu │ │ │ -000831d0: 7465 782e 2049 7420 776f 756c 6420 7265 tex. It would re │ │ │ -000831e0: 7175 6972 6520 6120 7265 6665 7265 6e63 quire a referenc │ │ │ -000831f0: 6520 636f 756e 7465 7220 6f6e 2074 6865 e counter on the │ │ │ -00083200: 2073 746f 7265 0a62 7566 6665 7220 656e store.buffer en │ │ │ -00083210: 7472 6965 7320 616e 6420 7468 6174 2077 tries and that w │ │ │ -00083220: 6520 706f 7465 6e74 6961 6c6c 7920 6572 e potentially er │ │ │ -00083230: 6173 6573 2069 7420 6166 7465 7220 7468 ases it after th │ │ │ -00083240: 6973 2063 616c 6c2e 0a69 7420 776f 756c is call..it woul │ │ │ -00083250: 6420 616c 736f 2072 6571 7569 7265 2074 d also require t │ │ │ -00083260: 6865 2073 746f 7265 2062 7566 6665 7220 he store buffer │ │ │ -00083270: 6265 696e 6720 6162 6c65 2074 6f20 7461 being able to ta │ │ │ -00083280: 6b65 206f 7665 720a 6f77 6e65 7273 6869 ke over.ownershi │ │ │ -00083290: 7020 6f66 2074 6865 2062 7566 6665 7220 p of the buffer │ │ │ -000832a0: 7768 656e 2074 6865 206f 776e 6572 2065 when the owner e │ │ │ -000832b0: 7261 7365 7320 6974 2e20 5065 7268 6170 rases it. Perhap │ │ │ -000832c0: 7320 6572 6173 6528 290a 636f 756c 6420 s erase().could │ │ │ -000832d0: 6265 206d 6164 6520 746f 2074 616b 6520 be made to take │ │ │ -000832e0: 6120 6275 6666 6572 5f68 6f6c 6465 722c a buffer_holder, │ │ │ -000832f0: 2077 6869 6368 2069 7320 6865 6c64 206f which is held o │ │ │ -00083300: 6e74 6f20 6966 2074 6865 0a72 6566 636f nto if the.refco │ │ │ -00083310: 756e 7420 3e20 303c 2f68 323e 3c68 343e unt > 0

    │ │ │ -00083320: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00083330: 7272 656e 742f 6175 785f 2f73 746f 7265 rrent/aux_/store │ │ │ -00083340: 5f62 7566 6665 722e 6870 703a 3834 3c2f _buffer.hpp:84
    }..
    │ │ │ -00083390: 6e61 6d65 7370 6163 6520 6c69 6274 6f72  namespace libtor
    │ │ │ -000833a0: 7265 6e74 207b 0a6e 616d 6573 7061 6365  rent {.namespace
    │ │ │ -000833b0: 2061 7578 207b 0a0a 7374 7275 6374 2073   aux {..struct s
    │ │ │ -000833c0: 746f 7265 5f62 7566 6665 720a 7b0a 0973  tore_buffer.{..s
    │ │ │ -000833d0: 746f 7265 5f62 7566 6665 7228 696f 5f63  tore_buffer(io_c
    │ │ │ -000833e0: 6f6e 7465 7874 2661 6d70 3b20 696f 7329  ontext& ios)
    │ │ │ -000833f0: 203a 206d 5f62 6163 6b5f 7072 6573 7375   : m_back_pressu
    │ │ │ -00083400: 7265 2869 6f73 2920 7b7d 0a0a 0976 6f69  re(ios) {}...voi
    │ │ │ -00083410: 6420 7365 745f 6d61 785f 7369 7a65 2869  d set_max_size(i
    │ │ │ -00083420: 6e74 2063 6f6e 7374 206d 6178 5f73 697a  nt const max_siz
    │ │ │ -00083430: 6529 207b 0a09 096d 5f62 6163 6b5f 7072  e) {...m_back_pr
    │ │ │ -00083440: 6573 7375 7265 2e73 6574 5f6d 6178 5f73  essure.set_max_s
    │ │ │ -00083450: 697a 6528 6d61 785f 7369 7a65 293b 0a09  ize(max_size);..
    │ │ │ -00083460: 7d0a 0a09 7465 6d70 6c61 7465 2026 6c74  }...template <
    │ │ │ -00083470: 3b74 7970 656e 616d 6520 4675 6e26 6774  ;typename Fun>
    │ │ │ -00083480: 3b0a 0962 6f6f 6c20 6765 7428 746f 7272  ;..bool get(torr
    │ │ │ -00083490: 656e 745f 6c6f 6361 7469 6f6e 2063 6f6e  ent_location con
    │ │ │ -000834a0: 7374 206c 6f63 2c20 4675 6e20 6629 2063  st loc, Fun f) c
    │ │ │ -000834b0: 6f6e 7374 0a09 7b0a 0909 7374 643a 3a75  onst..{...std::u
    │ │ │ -000834c0: 6e69 7175 655f 6c6f 636b 266c 743b 7374  nique_lock<st
    │ │ │ -000834d0: 643a 3a6d 7574 6578 2667 743b 206c 286d  d::mutex> l(m
    │ │ │ -000834e0: 5f6d 7574 6578 293b 0a09 0961 7574 6f20  _mutex);...auto 
    │ │ │ -000834f0: 636f 6e73 7420 6974 203d 206d 5f73 746f  const it = m_sto
    │ │ │ -00083500: 7265 5f62 7566 6665 722e 6669 6e64 286c  re_buffer.find(l
    │ │ │ -00083510: 6f63 293b 0a09 0969 6620 2869 7420 213d  oc);...if (it !=
    │ │ │ -00083520: 206d 5f73 746f 7265 5f62 7566 6665 722e   m_store_buffer.
    │ │ │ -00083530: 656e 6428 2929 0a09 097b 0a3c 6469 7620  end())...{.
    ...f(it │ │ │ -00083570: 2d26 6774 3b73 6563 6f6e 6429 3b0a 3c2f ->second);....return tr │ │ │ -00083590: 7565 3b0a 0909 7d0a 0909 7265 7475 726e ue;...}...return │ │ │ -000835a0: 2066 616c 7365 3b0a 097d 0a0a 0974 656d false;..}...tem │ │ │ -000835b0: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -000835c0: 6d65 2046 756e 2667 743b 0a09 696e 7420 me Fun>..int │ │ │ -000835d0: 6765 7432 2874 6f72 7265 6e74 5f6c 6f63 get2(torrent_loc │ │ │ -000835e0: 6174 696f 6e20 636f 6e73 7420 6c6f 6331 ation const loc1 │ │ │ -000835f0: 2c20 746f 7272 656e 745f 6c6f 6361 7469 , torrent_locati │ │ │ -00083600: 6f6e 2063 6f6e 7374 206c 6f63 322c 2046 on const loc2, F │ │ │ -00083610: 756e 2066 2920 636f 6e73 740a 097b 0a09 un f) const..{.. │ │ │ -00083620: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63 .std::unique_loc │ │ │ -00083630: 6b26 6c74 3b73 7464 3a3a 6d75 7465 7826 k<std::mutex& │ │ │ -00083640: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a gt; l(m_mutex);. │ │ │ -00083650: 0909 6175 746f 2063 6f6e 7374 2069 7431 ..auto const it1 │ │ │ -00083660: 203d 206d 5f73 746f 7265 5f62 7566 6665 = m_store_buffe │ │ │ -00083670: 722e 6669 6e64 286c 6f63 3129 3b0a 0909 r.find(loc1);... │ │ │ -00083680: 6175 746f 2063 6f6e 7374 2069 7432 203d auto const it2 = │ │ │ -00083690: 206d 5f73 746f 7265 5f62 7566 6665 722e m_store_buffer. │ │ │ -000836a0: 6669 6e64 286c 6f63 3229 3b0a 0909 6368 find(loc2);...ch │ │ │ -000836b0: 6172 2063 6f6e 7374 2a20 6275 6631 203d ar const* buf1 = │ │ │ -000836c0: 2028 6974 3120 3d3d 206d 5f73 746f 7265 (it1 == m_store │ │ │ -000836d0: 5f62 7566 6665 722e 656e 6428 2929 203f _buffer.end()) ? │ │ │ -000836e0: 206e 756c 6c70 7472 203a 2069 7431 2d26 nullptr : it1-& │ │ │ -000836f0: 6774 3b73 6563 6f6e 643b 0a09 0963 6861 gt;second;...cha │ │ │ -00083700: 7220 636f 6e73 742a 2062 7566 3220 3d20 r const* buf2 = │ │ │ -00083710: 2869 7432 203d 3d20 6d5f 7374 6f72 655f (it2 == m_store_ │ │ │ -00083720: 6275 6666 6572 2e65 6e64 2829 2920 3f20 buffer.end()) ? │ │ │ -00083730: 6e75 6c6c 7074 7220 3a20 6974 322d 2667 nullptr : it2-&g │ │ │ -00083740: 743b 7365 636f 6e64 3b0a 0a09 0969 6620 t;second;....if │ │ │ -00083750: 2862 7566 3120 3d3d 206e 756c 6c70 7472 (buf1 == nullptr │ │ │ -00083760: 2026 616d 703b 2661 6d70 3b20 6275 6632 && buf2 │ │ │ -00083770: 203d 3d20 6e75 6c6c 7074 7229 0a09 0909 == nullptr).... │ │ │ -00083780: 7265 7475 726e 2030 3b0a 0a09 0972 6574 return 0;....ret │ │ │ -00083790: 7572 6e20 6628 6275 6631 2c20 6275 6632 urn f(buf1, buf2 │ │ │ -000837a0: 293b 0a09 7d0a 0a09 2f2f 2072 6574 7572 );..}...// retur │ │ │ -000837b0: 6e73 2074 7275 6520 6966 2074 6865 7265 ns true if there │ │ │ -000837c0: 2773 2062 6163 6b2d 7072 6573 7375 7265 's back-pressure │ │ │ -000837d0: 0a09 626f 6f6c 2069 6e73 6572 7428 746f ..bool insert(to │ │ │ -000837e0: 7272 656e 745f 6c6f 6361 7469 6f6e 2063 rrent_location c │ │ │ -000837f0: 6f6e 7374 206c 6f63 2c20 6368 6172 2063 onst loc, char c │ │ │ -00083800: 6f6e 7374 2a20 6275 662c 2073 7464 3a3a onst* buf, std:: │ │ │ -00083810: 7368 6172 6564 5f70 7472 266c 743b 6469 shared_ptr<di │ │ │ -00083820: 736b 5f6f 6273 6572 7665 7226 6774 3b20 sk_observer> │ │ │ -00083830: 6f20 3d20 6e75 6c6c 7074 7229 0a09 7b0a o = nullptr)..{. │ │ │ -00083840: 0909 7374 643a 3a6c 6f63 6b5f 6775 6172 ..std::lock_guar │ │ │ -00083850: 6426 6c74 3b73 7464 3a3a 6d75 7465 7826 d<std::mutex& │ │ │ -00083860: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a gt; l(m_mutex);. │ │ │ -00083870: 0909 6d5f 7374 6f72 655f 6275 6666 6572 ..m_store_buffer │ │ │ -00083880: 2e69 6e73 6572 7428 7b6c 6f63 2c20 6275 .insert({loc, bu │ │ │ -00083890: 667d 293b 0a09 0972 6574 7572 6e20 6d5f f});...return m_ │ │ │ -000838a0: 6261 636b 5f70 7265 7373 7572 652e 6861 back_pressure.ha │ │ │ -000838b0: 735f 6261 636b 5f70 7265 7373 7572 6528 s_back_pressure( │ │ │ -000838c0: 7374 6174 6963 5f63 6173 7426 6c74 3b69 static_cast<i │ │ │ -000838d0: 6e74 2667 743b 286d 5f73 746f 7265 5f62 nt>(m_store_b │ │ │ -000838e0: 7566 6665 722e 7369 7a65 2829 292c 206f uffer.size()), o │ │ │ -000838f0: 293b 0a09 7d0a 0a09 766f 6964 2065 7261 );..}...void era │ │ │ -00083900: 7365 2874 6f72 7265 6e74 5f6c 6f63 6174 se(torrent_locat │ │ │ -00083910: 696f 6e20 636f 6e73 7420 6c6f 6329 0a09 ion const loc).. │ │ │ -00083920: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.
    < │ │ │ -00083950: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00083960: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00083990: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000839a0: 6e74 2f61 7578 5f2f 616e 6e6f 756e 6365 nt/aux_/announce │ │ │ -000839b0: 5f65 6e74 7279 2e68 7070 3a35 363c 2f61 _entry.hpp:56includ │ │ │ -000839d0: 6520 7468 6520 6e75 6d62 6572 206f 6620 e the number of │ │ │ -000839e0: 7065 6572 7320 7265 6365 6976 6564 2066 peers received f │ │ │ -000839f0: 726f 6d20 7468 6973 2074 7261 636b 6572 rom this tracker │ │ │ -00083a00: 2c20 6174 206c 6173 7420 616e 6e6f 756e , at last announ │ │ │ -00083a10: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ -00083a60: 696e 636c 7564 6520 7468 6520 6e75 6d62 include the numb │ │ │ -00083a70: 6572 206f 6620 7065 6572 7320 7265 6365 er of peers rece │ │ │ -00083a80: 6976 6564 2066 726f 6d20 7468 6973 2074 ived from this t │ │ │ -00083a90: 7261 636b 6572 2c20 6174 206c 6173 740a racker, at last. │ │ │ -00083aa0: 616e 6e6f 756e 6365 3c2f 6832 3e3c 6834 announce

    ../include/libt │ │ │ -00083ac0: 6f72 7265 6e74 2f61 7578 5f2f 616e 6e6f orrent/aux_/anno │ │ │ -00083ad0: 756e 6365 5f65 6e74 7279 2e68 7070 3a35 unce_entry.hpp:5 │ │ │ -00083ae0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -00083b20: 0973 7472 7563 7420 746f 7272 656e 743b  .struct torrent;
    │ │ │ -00083b30: 0a0a 0973 7472 7563 7420 544f 5252 454e  ...struct TORREN
    │ │ │ -00083b40: 545f 4558 5452 415f 4558 504f 5254 2061  T_EXTRA_EXPORT a
    │ │ │ -00083b50: 6e6e 6f75 6e63 655f 696e 666f 6861 7368  nnounce_infohash
    │ │ │ -00083b60: 0a09 7b0a 0909 616e 6e6f 756e 6365 5f69  ..{...announce_i
    │ │ │ -00083b70: 6e66 6f68 6173 6828 293b 0a0a 0909 2f2f  nfohash();....//
    │ │ │ -00083b80: 2069 6620 7468 6973 2074 7261 636b 6572   if this tracker
    │ │ │ -00083b90: 2068 6173 2072 6574 7572 6e65 6420 616e   has returned an
    │ │ │ -00083ba0: 2065 7272 6f72 206f 7220 7761 726e 696e   error or warnin
    │ │ │ -00083bb0: 6720 6d65 7373 6167 650a 0909 2f2f 2074  g message...// t
    │ │ │ -00083bc0: 6861 7420 6d65 7373 6167 6520 6973 2073  hat message is s
    │ │ │ -00083bd0: 746f 7265 6420 6865 7265 0a09 0973 7464  tored here...std
    │ │ │ -00083be0: 3a3a 7374 7269 6e67 206d 6573 7361 6765  ::string message
    │ │ │ -00083bf0: 3b0a 0a09 092f 2f20 6966 2074 6869 7320  ;....// if this 
    │ │ │ -00083c00: 7472 6163 6b65 7220 6661 696c 6564 2074  tracker failed t
    │ │ │ -00083c10: 6865 206c 6173 7420 7469 6d65 2069 7420  he last time it 
    │ │ │ -00083c20: 7761 7320 636f 6e74 6163 7465 640a 0909  was contacted...
    │ │ │ -00083c30: 2f2f 2074 6869 7320 6572 726f 7220 636f  // this error co
    │ │ │ -00083c40: 6465 2073 7065 6369 6669 6573 2077 6861  de specifies wha
    │ │ │ -00083c50: 7420 6572 726f 7220 6f63 6375 7272 6564  t error occurred
    │ │ │ -00083c60: 0a09 0965 7272 6f72 5f63 6f64 6520 6c61  ...error_code la
    │ │ │ -00083c70: 7374 5f65 7272 6f72 3b0a 0a09 092f 2f20  st_error;....// 
    │ │ │ -00083c80: 7468 6520 7469 6d65 206f 6620 6e65 7874  the time of next
    │ │ │ -00083c90: 2074 7261 636b 6572 2061 6e6e 6f75 6e63   tracker announc
    │ │ │ -00083ca0: 650a 0909 7469 6d65 5f70 6f69 6e74 3332  e...time_point32
    │ │ │ -00083cb0: 206e 6578 745f 616e 6e6f 756e 6365 203d   next_announce =
    │ │ │ -00083cc0: 2028 7469 6d65 5f70 6f69 6e74 3332 3a3a   (time_point32::
    │ │ │ -00083cd0: 6d69 6e29 2829 3b0a 0a09 092f 2f20 6e6f  min)();....// no
    │ │ │ -00083ce0: 2061 6e6e 6f75 6e63 6573 2062 6566 6f72   announces befor
    │ │ │ -00083cf0: 6520 7468 6973 2074 696d 650a 0909 7469  e this time...ti
    │ │ │ -00083d00: 6d65 5f70 6f69 6e74 3332 206d 696e 5f61  me_point32 min_a
    │ │ │ -00083d10: 6e6e 6f75 6e63 6520 3d20 2874 696d 655f  nnounce = (time_
    │ │ │ -00083d20: 706f 696e 7433 323a 3a6d 696e 2928 293b  point32::min)();
    │ │ │ -00083d30: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00083d60: 0a3c 2f64 6976 3e09 092f 2f20 7468 6573 .
    ..// thes │ │ │ -00083d70: 6520 6172 6520 6569 7468 6572 202d 3120 e are either -1 │ │ │ -00083d80: 6f72 2074 6865 2073 6372 6170 6520 696e or the scrape in │ │ │ -00083d90: 666f 726d 6174 696f 6e20 7468 6973 2074 formation this t │ │ │ -00083da0: 7261 636b 6572 206c 6173 740a 0909 2f2f racker last...// │ │ │ -00083db0: 2072 6573 706f 6e64 6564 2077 6974 682e responded with. │ │ │ -00083dc0: 202a 696e 636f 6d70 6c65 7465 2a20 6973 *incomplete* is │ │ │ -00083dd0: 2074 6865 2063 7572 7265 6e74 206e 756d the current num │ │ │ -00083de0: 6265 7220 6f66 2064 6f77 6e6c 6f61 6465 ber of downloade │ │ │ -00083df0: 7273 2069 6e0a 0909 2f2f 2074 6865 2073 rs in...// the s │ │ │ -00083e00: 7761 726d 2c20 2a63 6f6d 706c 6574 652a warm, *complete* │ │ │ -00083e10: 2069 7320 7468 6520 6375 7272 656e 7420 is the current │ │ │ -00083e20: 6e75 6d62 6572 206f 6620 7365 6564 7320 number of seeds │ │ │ -00083e30: 696e 2074 6865 2073 7761 726d 2061 6e64 in the swarm and │ │ │ -00083e40: 0a09 092f 2f20 2a64 6f77 6e6c 6f61 6465 ...// *downloade │ │ │ -00083e50: 642a 2069 7320 7468 6520 6375 6d75 6c61 d* is the cumula │ │ │ -00083e60: 7469 7665 206e 756d 6265 7220 6f66 2063 tive number of c │ │ │ -00083e70: 6f6d 706c 6574 6564 2064 6f77 6e6c 6f61 ompleted downloa │ │ │ -00083e80: 6473 206f 6620 7468 6973 0a09 092f 2f20 ds of this...// │ │ │ -00083e90: 746f 7272 656e 742c 2073 696e 6365 2074 torrent, since t │ │ │ -00083ea0: 6865 2062 6567 696e 6e69 6e67 206f 6620 he beginning of │ │ │ -00083eb0: 7469 6d65 2028 6672 6f6d 2074 6869 7320 time (from this │ │ │ -00083ec0: 7472 6163 6b65 7227 7320 706f 696e 7420 tracker's point │ │ │ -00083ed0: 6f66 0a09 092f 2f20 7669 6577 292e 0a0a of...// view)... │ │ │ -00083ee0: 0909 2f2f 2069 6620 7468 6973 2074 7261 ..// if this tra │ │ │ -00083ef0: 636b 6572 2068 6173 2072 6574 7572 6e65 cker has returne │ │ │ -00083f00: 6420 7363 7261 7065 2064 6174 612c 2074 d scrape data, t │ │ │ -00083f10: 6865 7365 2066 6965 6c64 7320 6172 6520 hese fields are │ │ │ -00083f20: 6669 6c6c 6564 2069 6e0a 0909 2f2f 2077 filled in...// w │ │ │ -00083f30: 6974 6820 7661 6c69 6420 6e75 6d62 6572 ith valid number │ │ │ -00083f40: 732e 204f 7468 6572 7769 7365 2074 6865 s. Otherwise the │ │ │ -00083f50: 7920 6172 6520 7365 7420 746f 202d 312e y are set to -1. │ │ │ -00083f60: 2060 6069 6e63 6f6d 706c 6574 6560 6020 ``incomplete`` │ │ │ -00083f70: 636f 756e 7473 0a09 092f 2f20 7468 6520 counts...// the │ │ │ -00083f80: 6e75 6d62 6572 206f 6620 6375 7272 656e number of curren │ │ │ -00083f90: 7420 646f 776e 6c6f 6164 6572 732e 2060 t downloaders. ` │ │ │ -00083fa0: 6063 6f6d 706c 6574 6560 6020 636f 756e `complete`` coun │ │ │ -00083fb0: 7473 2074 6865 206e 756d 6265 7220 6f66 ts the number of │ │ │ -00083fc0: 0a09 092f 2f20 6375 7272 656e 7420 7065 ...// current pe │ │ │ -00083fd0: 6572 7320 636f 6d70 6c65 7465 6420 7468 ers completed th │ │ │ -00083fe0: 6520 646f 776e 6c6f 6164 2c20 6f72 2022 e download, or " │ │ │ -00083ff0: 7365 6564 7322 2e20 6060 646f 776e 6c6f seeds". ``downlo │ │ │ -00084000: 6164 6564 6060 2069 7320 7468 650a 0909 aded`` is the... │ │ │ -00084010: 2f2f 2063 756d 756c 6174 6976 6520 6e75 // cumulative nu │ │ │ -00084020: 6d62 6572 206f 6620 636f 6d70 6c65 7465 mber of complete │ │ │ -00084030: 6420 646f 776e 6c6f 6164 732e 0a09 0969 d downloads....i │ │ │ -00084040: 6e74 2073 6372 6170 655f 696e 636f 6d70 nt scrape_incomp │ │ │ -00084050: 6c65 7465 203d 202d 313b 0a09 0969 6e74 lete = -1;...int │ │ │ -00084060: 2073 6372 6170 655f 636f 6d70 6c65 7465 scrape_complete │ │ │ -00084070: 203d 202d 313b 0a09 0969 6e74 2073 6372 = -1;...int scr │ │ │ -00084080: 6170 655f 646f 776e 6c6f 6164 6564 203d ape_downloaded = │ │ │ -00084090: 202d 313b 0a0a 0909 2f2f 2074 6865 206e -1;....// the n │ │ │ -000840a0: 756d 6265 7220 6f66 2074 696d 6573 2069 umber of times i │ │ │ -000840b0: 6e20 6120 726f 7720 7765 2068 6176 6520 n a row we have │ │ │ -000840c0: 6661 696c 6564 2074 6f20 616e 6e6f 756e failed to announ │ │ │ -000840d0: 6365 2074 6f20 7468 6973 0a09 092f 2f20 ce to this...// │ │ │ -000840e0: 7472 6163 6b65 722e 0a09 0973 7464 3a3a tracker....std:: │ │ │ -000840f0: 7569 6e74 385f 7420 6661 696c 7320 3a20 uint8_t fails : │ │ │ -00084100: 373b 0a0a 0909 2f2f 2074 7275 6520 7768 7;....// true wh │ │ │ -00084110: 696c 6520 7765 2772 6520 7761 6974 696e ile we're waitin │ │ │ -00084120: 6720 666f 7220 6120 7265 7370 6f6e 7365 g for a response │ │ │ -00084130: 2066 726f 6d20 7468 6520 7472 6163 6b65 from the tracke │ │ │ -00084140: 722e 0a09 0962 6f6f 6c20 7570 6461 7469 r....bool updati │ │ │ -00084150: 6e67 203a 2031 3b0a 0a09 092f 2f20 7365 ng : 1;....// se │ │ │ -00084160: 7420 746f 2074 7275 6520 7768 656e 2077 t to true when w │ │ │ -00084170: 6520 6765 7420 6120 7661 6c69 6420 7265 e get a valid re │ │ │ -00084180: 7370 6f6e 7365 2066 726f 6d20 616e 2061 sponse from an a │ │ │ -00084190: 6e6e 6f75 6e63 650a 0909 2f2f 2077 6974 nnounce...// wit │ │ │ -000841a0: 6820 6576 656e 743d 7374 6172 7465 642e h event=started. │ │ │ -000841b0: 2049 6620 6974 2069 7320 7365 742c 2077 If it is set, w │ │ │ -000841c0: 6520 776f 6e27 7420 7365 6e64 2073 7461 e won't send sta │ │ │ -000841d0: 7274 2069 6e20 7468 6520 7375 6273 6571 rt in the subseq │ │ │ -000841e0: 7565 6e74 0a09 092f 2f20 616e 6e6f 756e uent...// announ │ │ │ -000841f0: 6365 732e 0a09 0962 6f6f 6c20 7374 6172 ces....bool star │ │ │ -00084200: 745f 7365 6e74 203a 2031 3b0a 0a09 092f t_sent : 1;..../ │ │ │ -00084210: 2f20 7365 7420 746f 2074 7275 6520 7768 / set to true wh │ │ │ -00084220: 656e 2077 6520 7365 6e64 2061 2065 7665 en we send a eve │ │ │ -00084230: 6e74 3d63 6f6d 706c 6574 6564 2e0a 0909 nt=completed.... │ │ │ -00084240: 626f 6f6c 2063 6f6d 706c 6574 655f 7365 bool complete_se │ │ │ -00084250: 6e74 203a 2031 3b0a 3c2f 7072 653e 3c2f nt : 1;.
    relevan │ │ │ -00084290: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -000842d0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7065 btorrent/aux_/pe │ │ │ -000842e0: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6870 er_connection.hp │ │ │ -000842f0: 703a 3139 353c 2f61 3e3c 2f74 643e 3c74 p:195make this a ra │ │ │ -00084310: 7720 706f 696e 7465 7220 2874 6f20 7361 w pointer (to sa │ │ │ -00084320: 7665 2073 697a 6520 696e 2074 6865 2066 ve size in the f │ │ │ -00084330: 6972 7374 2063 6163 6865 206c 696e 6529 irst cache line) │ │ │ -00084340: 2061 6e64 206d 616b 6520 7468 6520 636f and make the co │ │ │ -00084350: 6e73 7472 7563 746f 7220 7461 6b65 2061 nstructor take a │ │ │ -00084360: 2072 6177 2070 6f69 6e74 6572 2e20 746f raw pointer. to │ │ │ -00084370: 7272 656e 7420 6f62 6a65 6374 7320 7368 rrent objects sh │ │ │ -00084380: 6f75 6c64 2061 6c77 6179 7320 6f75 746c ould always outl │ │ │ -00084390: 6976 6520 7468 6569 7220 7065 6572 733c ive their peers< │ │ │ -000843a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    mak │ │ │ -000843f0: 6520 7468 6973 2061 2072 6177 2070 6f69 e this a raw poi │ │ │ -00084400: 6e74 6572 2028 746f 2073 6176 6520 7369 nter (to save si │ │ │ -00084410: 7a65 2069 6e0a 7468 6520 6669 7273 7420 ze in.the first │ │ │ -00084420: 6361 6368 6520 6c69 6e65 2920 616e 6420 cache line) and │ │ │ -00084430: 6d61 6b65 2074 6865 2063 6f6e 7374 7275 make the constru │ │ │ -00084440: 6374 6f72 0a74 616b 6520 6120 7261 7720 ctor.take a raw │ │ │ -00084450: 706f 696e 7465 722e 2074 6f72 7265 6e74 pointer. torrent │ │ │ -00084460: 206f 626a 6563 7473 2073 686f 756c 6420 objects should │ │ │ -00084470: 616c 7761 7973 0a6f 7574 6c69 7665 2074 always.outlive t │ │ │ -00084480: 6865 6972 2070 6565 7273 3c2f 6832 3e3c heir peers

    < │ │ │ -00084490: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -000844a0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7065 btorrent/aux_/pe │ │ │ -000844b0: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6870 er_connection.hp │ │ │ -000844c0: 703a 3139 353c 2f68 343e 3c70 7265 2073 p:195

    ..., m_snubb
    │ │ │ -00084510: 6564 2866 616c 7365 290a 0909 092c 206d  ed(false)...., m
    │ │ │ -00084520: 5f69 6e74 6572 6573 7469 6e67 2866 616c  _interesting(fal
    │ │ │ -00084530: 7365 290a 0909 092c 206d 5f63 686f 6b65  se)...., m_choke
    │ │ │ -00084540: 6428 7472 7565 290a 0909 092c 206d 5f69  d(true)...., m_i
    │ │ │ -00084550: 676e 6f72 655f 7374 6174 7328 6661 6c73  gnore_stats(fals
    │ │ │ -00084560: 6529 0a09 097b 7d0a 0a09 092f 2f20 6578  e)...{}....// ex
    │ │ │ -00084570: 706c 6963 6974 6c79 2064 6973 616c 6c6f  plicitly disallo
    │ │ │ -00084580: 7720 6173 7369 676e 6d65 6e74 2c20 746f  w assignment, to
    │ │ │ -00084590: 2073 696c 656e 6365 206d 7376 6320 7761   silence msvc wa
    │ │ │ -000845a0: 726e 696e 670a 0909 7065 6572 5f63 6f6e  rning...peer_con
    │ │ │ -000845b0: 6e65 6374 696f 6e5f 686f 745f 6d65 6d62  nection_hot_memb
    │ │ │ -000845c0: 6572 7326 616d 703b 206f 7065 7261 746f  ers& operato
    │ │ │ -000845d0: 723d 2870 6565 725f 636f 6e6e 6563 7469  r=(peer_connecti
    │ │ │ -000845e0: 6f6e 5f68 6f74 5f6d 656d 6265 7273 2063  on_hot_members c
    │ │ │ -000845f0: 6f6e 7374 2661 6d70 3b29 203d 2064 656c  onst&) = del
    │ │ │ -00084600: 6574 653b 0a0a 0970 726f 7465 6374 6564  ete;...protected
    │ │ │ -00084610: 3a0a 0a09 092f 2f20 7468 6520 7069 6563  :....// the piec
    │ │ │ -00084620: 6573 2074 6865 206f 7468 6572 2065 6e64  es the other end
    │ │ │ -00084630: 2068 6176 650a 0909 7479 7065 645f 6269   have...typed_bi
    │ │ │ -00084640: 7466 6965 6c64 266c 743b 7069 6563 655f  tfield<piece_
    │ │ │ -00084650: 696e 6465 785f 7426 6774 3b20 6d5f 6861  index_t> m_ha
    │ │ │ -00084660: 7665 5f70 6965 6365 3b0a 0a09 092f 2f20  ve_piece;....// 
    │ │ │ -00084670: 7468 6973 2069 7320 7468 6520 746f 7272  this is the torr
    │ │ │ -00084680: 656e 7420 7468 6973 2063 6f6e 6e65 6374  ent this connect
    │ │ │ -00084690: 696f 6e20 6973 0a09 092f 2f20 6173 736f  ion is...// asso
    │ │ │ -000846a0: 6369 6174 6564 2077 6974 682e 2049 6620  ciated with. If 
    │ │ │ -000846b0: 7468 6520 636f 6e6e 6563 7469 6f6e 2069  the connection i
    │ │ │ -000846c0: 7320 616e 0a09 092f 2f20 696e 636f 6d69  s an...// incomi
    │ │ │ -000846d0: 6e67 2063 6f6e 6e65 6374 696f 6e2c 2074  ng connection, t
    │ │ │ -000846e0: 6869 7320 6973 2073 6574 2074 6f20 7a65  his is set to ze
    │ │ │ -000846f0: 726f 0a09 092f 2f20 756e 7469 6c20 7468  ro...// until th
    │ │ │ -00084700: 6520 696e 666f 5f68 6173 6820 6973 2072  e info_hash is r
    │ │ │ -00084710: 6563 6569 7665 642e 2054 6865 6e20 6974  eceived. Then it
    │ │ │ -00084720: 2773 0a09 092f 2f20 7365 7420 746f 2074  's...// set to t
    │ │ │ -00084730: 6865 2074 6f72 7265 6e74 2069 7420 6265  he torrent it be
    │ │ │ -00084740: 6c6f 6e67 7320 746f 2e0a 0a3c 6469 7620  longs to...
    ..std:: │ │ │ -00084780: 7765 616b 5f70 7472 266c 743b 6175 783a weak_ptr<aux: │ │ │ -00084790: 3a74 6f72 7265 6e74 2667 743b 206d 5f74 :torrent> m_t │ │ │ -000847a0: 6f72 7265 6e74 3b0a 3c2f 6469 763e 0a09 orrent;.
    .. │ │ │ -000847b0: 7075 626c 6963 3a0a 0a09 092f 2f20 6120 public:....// a │ │ │ -000847c0: 6261 636b 2072 6566 6572 656e 6365 2074 back reference t │ │ │ -000847d0: 6f20 7468 6520 7365 7373 696f 6e0a 0909 o the session... │ │ │ -000847e0: 2f2f 2074 6865 2070 6565 7220 6265 6c6f // the peer belo │ │ │ -000847f0: 6e67 7320 746f 2e0a 0909 6175 783a 3a73 ngs to....aux::s │ │ │ -00084800: 6573 7369 6f6e 5f69 6e74 6572 6661 6365 ession_interface │ │ │ -00084810: 2661 6d70 3b20 6d5f 7365 733b 0a0a 0909 & m_ses;.... │ │ │ -00084820: 2f2f 2073 6574 7469 6e67 7320 7468 6174 // settings that │ │ │ -00084830: 2061 7070 6c79 2074 6f20 7468 6973 2070 apply to this p │ │ │ -00084840: 6565 720a 0909 6175 783a 3a73 6573 7369 eer...aux::sessi │ │ │ -00084850: 6f6e 5f73 6574 7469 6e67 7320 636f 6e73 on_settings cons │ │ │ -00084860: 7426 616d 703b 206d 5f73 6574 7469 6e67 t& m_setting │ │ │ -00084870: 733b 0a0a 0970 726f 7465 6374 6564 3a0a s;...protected:. │ │ │ -00084880: 0a09 092f 2f20 7468 6973 2069 7320 7472 ...// this is tr │ │ │ -00084890: 7565 2069 6620 7468 6973 2063 6f6e 6e65 ue if this conne │ │ │ -000848a0: 6374 696f 6e20 6861 7320 6265 656e 2061 ction has been a │ │ │ -000848b0: 6464 6564 0a09 092f 2f20 746f 2074 6865 dded...// to the │ │ │ -000848c0: 206c 6973 7420 6f66 2063 6f6e 6e65 6374 list of connect │ │ │ -000848d0: 696f 6e73 2074 6861 7420 7769 6c6c 2062 ions that will b │ │ │ -000848e0: 6520 636c 6f73 6564 2e0a 0909 626f 6f6c e closed....bool │ │ │ -000848f0: 206d 5f64 6973 636f 6e6e 6563 7469 6e67 m_disconnecting │ │ │ -00084900: 3a31 3b0a 0a09 092f 2f20 7468 6973 2069 :1;....// this i │ │ │ -00084910: 7320 7472 7565 2075 6e74 696c 2074 6869 s true until thi │ │ │ -00084920: 7320 736f 636b 6574 2068 6173 2062 6563 s socket has bec │ │ │ -00084930: 6f6d 650a 0909 2f2f 2077 7269 7461 626c ome...// writabl │ │ │ -00084940: 6520 666f 7220 7468 6520 6669 7273 7420 e for the first │ │ │ -00084950: 7469 6d65 2028 692e 652e 2074 6865 0a09 time (i.e. the.. │ │ │ -00084960: 092f 2f20 636f 6e6e 6563 7469 6f6e 2063 .// connection c │ │ │ -00084970: 6f6d 706c 6574 6564 292e 2057 6869 6c65 ompleted). While │ │ │ -00084980: 2063 6f6e 6e65 6374 696e 670a 0909 2f2f connecting...// │ │ │ -00084990: 2074 6865 2074 696d 656f 7574 2077 696c the timeout wil │ │ │ -000849a0: 6c20 6e6f 7420 6265 2074 7269 6767 6572 l not be trigger │ │ │ -000849b0: 6564 2e20 5468 6973 2069 730a 0909 2f2f ed. This is...// │ │ │ -000849c0: 2062 6563 6175 7365 2077 696e 646f 7773 because windows │ │ │ -000849d0: 2058 5020 5350 3220 6d61 7920 6465 6c61 XP SP2 may dela │ │ │ -000849e0: 7920 636f 6e6e 6563 7469 6f6e 0a09 092f y connection.../ │ │ │ -000849f0: 2f20 6174 7465 6d70 7473 2c20 7768 6963 / attempts, whic │ │ │ -00084a00: 6820 6d65 616e 7320 7468 6174 2074 6865 h means that the │ │ │ -00084a10: 2063 6f6e 6e65 6374 696f 6e0a 0909 2f2f connection...// │ │ │ -00084a20: 206d 6179 206e 6f74 2065 7665 6e20 6861 may not even ha │ │ │ -00084a30: 7665 2062 6565 6e20 6174 7465 6d70 7465 ve been attempte │ │ │ -00084a40: 6420 7768 656e 2074 6865 0a09 092f 2f20 d when the...// │ │ │ -00084a50: 7469 6d65 206f 7574 2069 7320 7265 6163 time out is reac │ │ │ -00084a60: 6865 642e 0a09 0962 6f6f 6c20 6d5f 636f hed....bool m_co │ │ │ -00084a70: 6e6e 6563 7469 6e67 3a31 3b0a 0a09 092f nnecting:1;..../ │ │ │ -00084a80: 2f20 7468 6973 2069 7320 7365 7420 746f / this is set to │ │ │ -00084a90: 2074 7275 6520 6966 2074 6865 206c 6173 true if the las │ │ │ -00084aa0: 7420 7469 6d65 2077 6520 7472 6965 6420 t time we tried │ │ │ -00084ab0: 746f 0a09 092f 2f20 7069 636b 2061 2070 to...// pick a p │ │ │ -00084ac0: 6965 6365 2074 6f20 646f 776e 6c6f 6164 iece to download │ │ │ -00084ad0: 2c20 7765 2063 6f75 6c64 206f 6e6c 7920 , we could only │ │ │ -00084ae0: 6669 6e64 0a09 092f 2f20 626c 6f63 6b73 find...// blocks │ │ │ -00084af0: 2074 6861 7420 7765 7265 2061 6c72 6561 that were alrea │ │ │ -00084b00: 6479 2072 6571 7565 7374 6564 2066 726f dy requested fro │ │ │ -00084b10: 6d20 6f74 6865 720a 0909 2f2f 2070 6565 m other...// pee │ │ │ -00084b20: 7273 2e20 496e 2074 6869 7320 6361 7365 rs. In this case │ │ │ -00084b30: 2c20 7765 2073 686f 756c 6420 6e6f 7420 , we should not │ │ │ -00084b40: 7472 7920 746f 2070 6963 6b0a 3c2f 7072 try to pick.rel │ │ │ -00084b80: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -00084bc0: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -00084bd0: 5f2f 7065 6572 5f63 6f6e 6e65 6374 696f _/peer_connectio │ │ │ -00084be0: 6e2e 6870 703a 3130 3030 3c2f 613e 3c2f n.hpp:1000factor th │ │ │ -00084c00: 6973 206f 7574 2069 6e74 6f20 6974 7320 is out into its │ │ │ -00084c10: 6f77 6e20 636c 6173 7320 7769 7468 2061 own class with a │ │ │ -00084c20: 2076 6972 7475 616c 2069 6e74 6572 6661 virtual interfa │ │ │ -00084c30: 6365 2074 6f72 7265 6e74 2061 6e64 2073 ce torrent and s │ │ │ -00084c40: 6573 7369 6f6e 2073 686f 756c 6420 696d ession should im │ │ │ -00084c50: 706c 656d 656e 7420 7468 6973 2069 6e74 plement this int │ │ │ -00084c60: 6572 6661 6365 3c2f 7464 3e3c 2f74 723e erface │ │ │ -00084c70: 3c74 7220 6964 3d22 3330 3022 2073 7479 │ │ │ -00084ca0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00084cb0: 3c68 323e 6661 6374 6f72 2074 6869 7320

    factor this │ │ │ -00084cc0: 6f75 7420 696e 746f 2069 7473 206f 776e out into its own │ │ │ -00084cd0: 2063 6c61 7373 2077 6974 6820 6120 7669 class with a vi │ │ │ -00084ce0: 7274 7561 6c20 696e 7465 7266 6163 650a rtual interface. │ │ │ -00084cf0: 746f 7272 656e 7420 616e 6420 7365 7373 torrent and sess │ │ │ -00084d00: 696f 6e20 7368 6f75 6c64 2069 6d70 6c65 ion should imple │ │ │ -00084d10: 6d65 6e74 2074 6869 7320 696e 7465 7266 ment this interf │ │ │ -00084d20: 6163 653c 2f68 323e 3c68 343e 2e2e 2f69 ace

    ../i │ │ │ -00084d30: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00084d40: 742f 6175 785f 2f70 6565 725f 636f 6e6e t/aux_/peer_conn │ │ │ -00084d50: 6563 7469 6f6e 2e68 7070 3a31 3030 303c ection.hpp:1000< │ │ │ -00084d60: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00084da0: 092f 2f20 7468 6520 6c6f 6361 6c20 656e  .// the local en
    │ │ │ -00084db0: 6470 6f69 6e74 2066 6f72 2074 6869 7320  dpoint for this 
    │ │ │ -00084dc0: 7065 6572 2c20 692e 652e 206f 7572 2061  peer, i.e. our a
    │ │ │ -00084dd0: 6464 7265 7373 0a09 092f 2f20 616e 6420  ddress...// and 
    │ │ │ -00084de0: 6f75 7220 706f 7274 2e20 4966 2074 6869  our port. If thi
    │ │ │ -00084df0: 7320 6973 2073 6574 2066 6f72 206f 7574  s is set for out
    │ │ │ -00084e00: 676f 696e 6720 636f 6e6e 6563 7469 6f6e  going connection
    │ │ │ -00084e10: 730a 0909 2f2f 2062 6566 6f72 6520 7468  s...// before th
    │ │ │ -00084e20: 6520 636f 6e6e 6563 7469 6f6e 2063 6f6d  e connection com
    │ │ │ -00084e30: 706c 6574 6573 2c20 6974 206d 6561 6e73  pletes, it means
    │ │ │ -00084e40: 2077 6520 7761 6e74 2074 6f0a 0909 2f2f   we want to...//
    │ │ │ -00084e50: 2066 6f72 6365 2074 6865 2063 6f6e 6e65   force the conne
    │ │ │ -00084e60: 6374 696f 6e20 746f 2062 6520 626f 756e  ction to be boun
    │ │ │ -00084e70: 6420 746f 2074 6865 2073 7065 6369 6669  d to the specifi
    │ │ │ -00084e80: 6564 2069 6e74 6572 6661 6365 2e0a 0909  ed interface....
    │ │ │ -00084e90: 2f2f 2069 6620 6974 2065 6e64 7320 7570  // if it ends up
    │ │ │ -00084ea0: 2062 6569 6e67 2062 6f75 6e64 2074 6f20   being bound to 
    │ │ │ -00084eb0: 6120 6469 6666 6572 656e 7420 6c6f 6361  a different loca
    │ │ │ -00084ec0: 6c20 4950 2c20 7468 6520 636f 6e6e 6563  l IP, the connec
    │ │ │ -00084ed0: 7469 6f6e 0a09 092f 2f20 6973 2063 6c6f  tion...// is clo
    │ │ │ -00084ee0: 7365 642e 0a09 0974 6370 3a3a 656e 6470  sed....tcp::endp
    │ │ │ -00084ef0: 6f69 6e74 206d 5f6c 6f63 616c 3b0a 0a09  oint m_local;...
    │ │ │ -00084f00: 092f 2f20 7265 6d6f 7465 2070 6565 7227  .// remote peer'
    │ │ │ -00084f10: 7320 6964 0a09 0970 6565 725f 6964 206d  s id...peer_id m
    │ │ │ -00084f20: 5f70 6565 725f 6964 3b0a 0a09 7072 6f74  _peer_id;...prot
    │ │ │ -00084f30: 6563 7465 643a 0a0a 0909 7465 6d70 6c61  ected:....templa
    │ │ │ -00084f40: 7465 2026 6c74 3b74 7970 656e 616d 6520  te <typename 
    │ │ │ -00084f50: 4675 6e2c 2074 7970 656e 616d 652e 2e2e  Fun, typename...
    │ │ │ -00084f60: 2041 7267 7326 6774 3b0a 0909 766f 6964   Args>...void
    │ │ │ -00084f70: 2077 7261 7028 4675 6e20 662c 2041 7267   wrap(Fun f, Arg
    │ │ │ -00084f80: 7326 616d 703b 2661 6d70 3b2e 2e2e 2061  s&&... a
    │ │ │ -00084f90: 293b 0a0a 0909 2f2f 2073 7461 7469 7374  );....// statist
    │ │ │ -00084fa0: 6963 7320 6162 6f75 7420 7570 6c6f 6164  ics about upload
    │ │ │ -00084fb0: 2061 6e64 2064 6f77 6e6c 6f61 6420 7370   and download sp
    │ │ │ -00084fc0: 6565 6473 0a09 092f 2f20 616e 6420 746f  eeds...// and to
    │ │ │ -00084fd0: 7461 6c20 616d 6f75 6e74 206f 6620 7570  tal amount of up
    │ │ │ -00084fe0: 6c6f 6164 7320 616e 6420 646f 776e 6c6f  loads and downlo
    │ │ │ -00084ff0: 6164 7320 666f 720a 0909 2f2f 2074 6869  ads for...// thi
    │ │ │ -00085000: 7320 7065 6572 0a3c 6469 7620 7374 796c  s peer.
    ..aux::stat │ │ │ -00085040: 206d 5f73 7461 7469 7374 6963 733b 0a3c m_statistics;.< │ │ │ -00085050: 2f64 6976 3e0a 0909 2f2f 2074 6865 206e /div>...// the n │ │ │ -00085060: 756d 6265 7220 6f66 206f 7574 7374 616e umber of outstan │ │ │ -00085070: 6469 6e67 2062 7974 6573 2065 7870 6563 ding bytes expec │ │ │ -00085080: 7465 640a 0909 2f2f 2074 6f20 6265 2072 ted...// to be r │ │ │ -00085090: 6563 6569 7665 6420 6279 2065 7874 656e eceived by exten │ │ │ -000850a0: 7369 6f6e 730a 0909 696e 7420 6d5f 6578 sions...int m_ex │ │ │ -000850b0: 7465 6e73 696f 6e5f 6f75 7473 7461 6e64 tension_outstand │ │ │ -000850c0: 696e 675f 6279 7465 7320 3d20 303b 0a0a ing_bytes = 0;.. │ │ │ -000850d0: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -000850e0: 6f66 2074 696d 6520 6372 6974 6963 616c of time critical │ │ │ -000850f0: 2072 6571 7565 7374 730a 0909 2f2f 2071 requests...// q │ │ │ -00085100: 7565 7565 6420 7570 2069 6e20 7468 6520 ueued up in the │ │ │ -00085110: 6d5f 7265 7175 6573 745f 7175 6575 6520 m_request_queue │ │ │ -00085120: 7468 6174 0a09 092f 2f20 736f 6f6e 2077 that...// soon w │ │ │ -00085130: 696c 6c20 6265 2063 6f6d 6d69 7474 6564 ill be committed │ │ │ -00085140: 2074 6f20 7468 6520 646f 776e 6c6f 6164 to the download │ │ │ -00085150: 0a09 092f 2f20 7175 6575 652e 2054 6869 ...// queue. Thi │ │ │ -00085160: 7320 6973 2069 6e63 6c75 6465 6420 696e s is included in │ │ │ -00085170: 2064 6f77 6e6c 6f61 645f 7175 6575 655f download_queue_ │ │ │ -00085180: 7469 6d65 2829 0a09 092f 2f20 736f 2074 time()...// so t │ │ │ -00085190: 6861 7420 6974 2063 616e 2062 6520 7573 hat it can be us │ │ │ -000851a0: 6564 2077 6869 6c65 2061 6464 696e 6720 ed while adding │ │ │ -000851b0: 6d6f 7265 0a09 092f 2f20 7265 7175 6573 more...// reques │ │ │ -000851c0: 7473 2061 6e64 2074 616b 6520 7468 6520 ts and take the │ │ │ -000851d0: 7072 6576 696f 7573 2072 6571 7565 7374 previous request │ │ │ -000851e0: 730a 0909 2f2f 2069 6e74 6f20 6163 636f s...// into acco │ │ │ -000851f0: 756e 7420 7769 7468 6f75 7420 7375 626d unt without subm │ │ │ -00085200: 6974 7469 6e67 2069 7420 616c 6c0a 0909 itting it all... │ │ │ -00085210: 2f2f 2069 6d6d 6564 6961 7465 6c79 0a09 // immediately.. │ │ │ -00085220: 0973 7464 3a3a 7569 6e74 3136 5f74 206d .std::uint16_t m │ │ │ -00085230: 5f71 7565 7565 645f 7469 6d65 5f63 7269 _queued_time_cri │ │ │ -00085240: 7469 6361 6c20 3d20 303b 0a0a 0909 2f2f tical = 0;....// │ │ │ -00085250: 2074 6865 206e 756d 6265 7220 6f66 2062 the number of b │ │ │ -00085260: 7974 6573 2077 6520 6172 6520 6375 7272 ytes we are curr │ │ │ -00085270: 656e 746c 7920 7265 6164 696e 670a 0909 ently reading... │ │ │ -00085280: 2f2f 2066 726f 6d20 6469 736b 2c20 7468 // from disk, th │ │ │ -00085290: 6174 2077 696c 6c20 6265 2061 6464 6564 at will be added │ │ │ -000852a0: 2074 6f20 7468 6520 7365 6e64 0a09 092f to the send.../ │ │ │ -000852b0: 2f20 6275 6666 6572 2061 7320 736f 6f6e / buffer as soon │ │ │ -000852c0: 2061 7320 7468 6579 2063 6f6d 706c 6574 as they complet │ │ │ -000852d0: 650a 0909 696e 7420 6d5f 7265 6164 696e e...int m_readin │ │ │ -000852e0: 675f 6279 7465 7320 3d20 303b 0a0a 0909 g_bytes = 0;.... │ │ │ -000852f0: 2f2f 206f 7074 696f 6e73 2075 7365 6420 // options used │ │ │ -00085300: 666f 7220 7468 6520 7069 6563 6520 7069 for the piece pi │ │ │ -00085310: 636b 6572 2e20 5468 6573 6520 666c 6167 cker. These flag │ │ │ -00085320: 7320 7769 6c6c 0a09 092f 2f20 6265 2061 s will...// be a │ │ │ -00085330: 7567 6d65 6e74 6564 2077 6974 6820 666c ugmented with fl │ │ │ -00085340: 6167 7320 636f 6e74 726f 6c6c 6564 2062 ags controlled b │ │ │ -00085350: 7920 6f74 6865 7220 7365 7474 696e 6773 y other settings │ │ │ -00085360: 0a09 092f 2f20 6c69 6b65 2073 6571 7565 ...// like seque │ │ │ -00085370: 6e74 6961 6c20 646f 776e 6c6f 6164 2065 ntial download e │ │ │ -00085380: 7463 2e20 5468 6573 6520 6172 6520 6865 tc. These are he │ │ │ -00085390: 7265 2074 6f0a 0909 2f2f 206c 6574 2070 re to...// let p │ │ │ -000853a0: 6c75 6769 6e73 2063 6f6e 7472 6f6c 2066 lugins control f │ │ │ -000853b0: 6c61 6773 2074 6861 7420 7368 6f75 6c64 lags that should │ │ │ -000853c0: 2061 6c77 6179 7320 6265 2073 6574 0a09 always be set.. │ │ │ -000853d0: 0970 6963 6b65 725f 6f70 7469 6f6e 735f .picker_options_ │ │ │ -000853e0: 7420 6d5f 7069 636b 6572 5f6f 7074 696f t m_picker_optio │ │ │ -000853f0: 6e73 7b7d 3b0a 0a09 092f 2f20 7468 6520 ns{};....// the │ │ │ -00085400: 6e75 6d62 6572 206f 6620 696e 7661 6c69 number of invali │ │ │ -00085410: 6420 7069 6563 652d 7265 7175 6573 7473 d piece-requests │ │ │ -00085420: 0a09 092f 2f20 7765 2068 6176 6520 676f ...// we have go │ │ │ -00085430: 7420 6672 6f6d 2074 6869 7320 7065 6572 t from this peer │ │ │ -00085440: 2e20 4966 2074 6865 2072 6571 7565 7374 . If the request │ │ │ -00085450: 0a09 092f 2f20 7175 6575 6520 6765 7473 ...// queue gets │ │ │ -00085460: 2065 6d70 7479 2c20 616e 6420 7468 6572 empty, and ther │ │ │ -00085470: 6520 6861 7665 2062 6565 6e0a 0909 2f2f e have been...// │ │ │ -00085480: 2069 6e76 616c 6964 2072 6571 7565 7374 invalid request │ │ │ -00085490: 732c 2077 6520 6361 6e20 6173 7375 6d65 s, we can assume │ │ │ -000854a0: 2074 6865 0a3c 2f70 7265 3e3c 2f74 643e the.
    │ │ │ -000854b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000854e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000854f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00085500: 7074 3a65 7870 616e 6428 3330 3129 223e pt:expand(301)"> │ │ │ -00085510: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00085520: 7272 656e 742f 6175 785f 2f74 7261 636b rrent/aux_/track │ │ │ -00085530: 6572 5f6c 6973 742e 6870 703a 3734 3c2f er_list.hpp:74make │ │ │ -00085550: 7468 6573 6520 6974 6572 6174 6f72 7320 these iterators │ │ │ -00085560: 636f 6e73 743c 2f74 643e 3c2f 7472 3e3c const< │ │ │ -00085570: 7472 2069 643d 2233 3031 2220 7374 796c tr id="301" styl │ │ │ -00085580: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00085590: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000855a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000855b0: 6832 3e6d 616b 6520 7468 6573 6520 6974 h2>make these it │ │ │ -000855c0: 6572 6174 6f72 7320 636f 6e73 743c 2f68 erators const

    ../include │ │ │ -000855e0: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -000855f0: 2f74 7261 636b 6572 5f6c 6973 742e 6870 /tracker_list.hp │ │ │ -00085600: 703a 3734 3c2f 6834 3e3c 7072 6520 7374 p:74

    .std::string 
    │ │ │ -00085650: 6c61 7374 5f77 6f72 6b69 6e67 5f75 726c  last_working_url
    │ │ │ -00085660: 2829 2063 6f6e 7374 3b0a 0961 7578 3a3a  () const;..aux::
    │ │ │ -00085670: 616e 6e6f 756e 6365 5f65 6e74 7279 2a20  announce_entry* 
    │ │ │ -00085680: 6c61 7374 5f77 6f72 6b69 6e67 2829 3b0a  last_working();.
    │ │ │ -00085690: 0961 7578 3a3a 616e 6e6f 756e 6365 5f65  .aux::announce_e
    │ │ │ -000856a0: 6e74 7279 2a20 6669 7273 7428 293b 0a0a  ntry* first();..
    │ │ │ -000856b0: 0976 6f69 6420 7265 636f 7264 5f77 6f72  .void record_wor
    │ │ │ -000856c0: 6b69 6e67 2861 7578 3a3a 616e 6e6f 756e  king(aux::announ
    │ │ │ -000856d0: 6365 5f65 6e74 7279 2063 6f6e 7374 2a20  ce_entry const* 
    │ │ │ -000856e0: 6165 293b 0a0a 0976 6f69 6420 7265 706c  ae);...void repl
    │ │ │ -000856f0: 6163 6528 7374 643a 3a76 6563 746f 7226  ace(std::vector&
    │ │ │ -00085700: 6c74 3b6c 743a 3a61 6e6e 6f75 6e63 655f  lt;lt::announce_
    │ │ │ -00085710: 656e 7472 7926 6774 3b20 636f 6e73 7426  entry> const&
    │ │ │ -00085720: 616d 703b 2061 6573 293b 0a0a 0976 6f69  amp; aes);...voi
    │ │ │ -00085730: 6420 656e 6162 6c65 5f61 6c6c 2829 3b0a  d enable_all();.
    │ │ │ -00085740: 0a09 766f 6964 2063 6f6d 706c 6574 6564  ..void completed
    │ │ │ -00085750: 2874 696d 655f 706f 696e 7433 3220 6e6f  (time_point32 no
    │ │ │ -00085760: 7729 3b0a 0a09 766f 6964 2073 6574 5f63  w);...void set_c
    │ │ │ -00085770: 6f6d 706c 6574 655f 7365 6e74 2829 3b0a  omplete_sent();.
    │ │ │ -00085780: 0a09 766f 6964 2072 6573 6574 2829 3b0a  ..void reset();.
    │ │ │ -00085790: 0a09 766f 6964 2073 746f 705f 616e 6e6f  ..void stop_anno
    │ │ │ -000857a0: 756e 6369 6e67 2874 696d 655f 706f 696e  uncing(time_poin
    │ │ │ -000857b0: 7433 3220 6e6f 7729 3b0a 0a09 626f 6f6c  t32 now);...bool
    │ │ │ -000857c0: 2061 6e79 5f76 6572 6966 6965 6428 2920   any_verified() 
    │ │ │ -000857d0: 636f 6e73 743b 0a0a 3c64 6976 2073 7479  const;..
    .iterator │ │ │ -00085810: 6265 6769 6e28 2920 7b20 7265 7475 726e begin() { return │ │ │ -00085820: 206d 5f74 7261 636b 6572 732e 6265 6769 m_trackers.begi │ │ │ -00085830: 6e28 293b 207d 0a3c 2f64 6976 3e09 6974 n(); }.
    .it │ │ │ -00085840: 6572 6174 6f72 2065 6e64 2829 207b 2072 erator end() { r │ │ │ -00085850: 6574 7572 6e20 6d5f 7472 6163 6b65 7273 eturn m_trackers │ │ │ -00085860: 2e65 6e64 2829 3b20 7d0a 0a09 636f 6e73 .end(); }...cons │ │ │ -00085870: 745f 6974 6572 6174 6f72 2062 6567 696e t_iterator begin │ │ │ -00085880: 2829 2063 6f6e 7374 207b 2072 6574 7572 () const { retur │ │ │ -00085890: 6e20 6d5f 7472 6163 6b65 7273 2e62 6567 n m_trackers.beg │ │ │ -000858a0: 696e 2829 3b20 7d0a 0963 6f6e 7374 5f69 in(); }..const_i │ │ │ -000858b0: 7465 7261 746f 7220 656e 6428 2920 636f terator end() co │ │ │ -000858c0: 6e73 7420 7b20 7265 7475 726e 206d 5f74 nst { return m_t │ │ │ -000858d0: 7261 636b 6572 732e 656e 6428 293b 207d rackers.end(); } │ │ │ -000858e0: 0a0a 0961 7578 3a3a 616e 6e6f 756e 6365 ...aux::announce │ │ │ -000858f0: 5f65 6e74 7279 2063 6f6e 7374 2a20 6669 _entry const* fi │ │ │ -00085900: 6e64 2869 6e74 2063 6f6e 7374 2069 6478 nd(int const idx │ │ │ -00085910: 2920 636f 6e73 743b 0a09 6175 783a 3a61 ) const;..aux::a │ │ │ -00085920: 6e6e 6f75 6e63 655f 656e 7472 792a 2066 nnounce_entry* f │ │ │ -00085930: 696e 6428 696e 7420 636f 6e73 7420 6964 ind(int const id │ │ │ -00085940: 7829 3b0a 0a70 7269 7661 7465 3a0a 0a23 x);..private:..# │ │ │ -00085950: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ -00085960: 4e56 4152 4941 4e54 5f43 4845 434b 530a NVARIANT_CHECKS. │ │ │ -00085970: 0966 7269 656e 6420 7374 7275 6374 206c .friend struct l │ │ │ -00085980: 6962 746f 7272 656e 743a 3a69 6e76 6172 ibtorrent::invar │ │ │ -00085990: 6961 6e74 5f61 6363 6573 733b 0a09 766f iant_access;..vo │ │ │ -000859a0: 6964 2063 6865 636b 5f69 6e76 6172 6961 id check_invaria │ │ │ -000859b0: 6e74 2829 2063 6f6e 7374 3b0a 2365 6e64 nt() const;.#end │ │ │ -000859c0: 6966 0a0a 0962 6f6f 7374 3a3a 6f62 6a65 if...boost::obje │ │ │ -000859d0: 6374 5f70 6f6f 6c26 6c74 3b61 7578 3a3a ct_pool<aux:: │ │ │ -000859e0: 616e 6e6f 756e 6365 5f65 6e74 7279 2667 announce_entry&g │ │ │ -000859f0: 743b 206d 5f73 746f 7261 6765 3b0a 0974 t; m_storage;..t │ │ │ -00085a00: 7261 636b 6572 735f 7420 6d5f 7472 6163 rackers_t m_trac │ │ │ -00085a10: 6b65 7273 3b0a 0973 7464 3a3a 756e 6f72 kers;..std::unor │ │ │ -00085a20: 6465 7265 645f 6d61 7026 6c74 3b73 7472 dered_map<str │ │ │ -00085a30: 696e 675f 7669 6577 2c20 6175 783a 3a61 ing_view, aux::a │ │ │ -00085a40: 6e6e 6f75 6e63 655f 656e 7472 792a 2667 nnounce_entry*&g │ │ │ -00085a50: 743b 206d 5f75 726c 5f69 6e64 6578 3b0a t; m_url_index;. │ │ │ -00085a60: 0a09 2f2f 2074 6865 2069 6e64 6578 2074 ..// the index t │ │ │ -00085a70: 6f20 7468 6520 6c61 7374 2074 7261 636b o the last track │ │ │ -00085a80: 6572 2074 6861 7420 776f 726b 6564 0a09 er that worked.. │ │ │ -00085a90: 6175 783a 3a61 6e6e 6f75 6e63 655f 656e aux::announce_en │ │ │ -00085aa0: 7472 792a 206d 5f6c 6173 745f 776f 726b try* m_last_work │ │ │ -00085ab0: 696e 675f 7472 6163 6b65 7220 3d20 6e75 ing_tracker = nu │ │ │ -00085ac0: 6c6c 7074 723b 0a7d 3b0a 0a7d 0a23 656e llptr;.};..}.#en │ │ │ -00085ad0: 6469 660a 0a3c 2f70 7265 3e3c 2f74 643e dif..
    │ │ │ -00085ae0: 3c2f 7472 3e3c 2f74 6162 6c65 3e3c 2f62 │ │ │ +0003bdd0: 2831 3531 2922 3e2e 2e2f 7372 632f 7365 (151)">../src/se │ │ │ +0003bde0: 7474 696e 6773 5f70 6163 6b2e 6370 703a ttings_pack.cpp: │ │ │ +0003bdf0: 3238 373c 2f61 3e3c 2f74 643e 3c74 643e 287 │ │ │ +0003be00: 6465 7072 6563 6174 6520 7468 6973 3c2f deprecate this

    depr │ │ │ +0003be60: 6563 6174 6520 7468 6973 3c2f 6832 3e3c ecate this

    < │ │ │ +0003be70: 6834 3e2e 2e2f 7372 632f 7365 7474 696e h4>../src/settin │ │ │ +0003be80: 6773 5f70 6163 6b2e 6370 703a 3238 373c gs_pack.cpp:287< │ │ │ +0003be90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0003bed0: 5345 5428 6f75 7467 6f69 6e67 5f70 6f72  SET(outgoing_por
    │ │ │ +0003bee0: 742c 2030 2c20 6e75 6c6c 7074 7229 2c0a  t, 0, nullptr),.
    │ │ │ +0003bef0: 0909 5345 5428 6e75 6d5f 6f75 7467 6f69  ..SET(num_outgoi
    │ │ │ +0003bf00: 6e67 5f70 6f72 7473 2c20 302c 206e 756c  ng_ports, 0, nul
    │ │ │ +0003bf10: 6c70 7472 292c 0a09 0953 4554 2870 6565  lptr),...SET(pee
    │ │ │ +0003bf20: 725f 6473 6370 2c20 3078 3031 2c20 2661  r_dscp, 0x01, &a
    │ │ │ +0003bf30: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a  mp;session_impl:
    │ │ │ +0003bf40: 3a75 7064 6174 655f 7065 6572 5f64 7363  :update_peer_dsc
    │ │ │ +0003bf50: 7029 2c0a 0909 5345 5428 6163 7469 7665  p),...SET(active
    │ │ │ +0003bf60: 5f64 6f77 6e6c 6f61 6473 2c20 332c 2026  _downloads, 3, &
    │ │ │ +0003bf70: 616d 703b 7365 7373 696f 6e5f 696d 706c  amp;session_impl
    │ │ │ +0003bf80: 3a3a 7472 6967 6765 725f 6175 746f 5f6d  ::trigger_auto_m
    │ │ │ +0003bf90: 616e 6167 6529 2c0a 0909 5345 5428 6163  anage),...SET(ac
    │ │ │ +0003bfa0: 7469 7665 5f73 6565 6473 2c20 352c 2026  tive_seeds, 5, &
    │ │ │ +0003bfb0: 616d 703b 7365 7373 696f 6e5f 696d 706c  amp;session_impl
    │ │ │ +0003bfc0: 3a3a 7472 6967 6765 725f 6175 746f 5f6d  ::trigger_auto_m
    │ │ │ +0003bfd0: 616e 6167 6529 2c0a 0909 5345 5428 6163  anage),...SET(ac
    │ │ │ +0003bfe0: 7469 7665 5f63 6865 636b 696e 672c 2031  tive_checking, 1
    │ │ │ +0003bff0: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69  , &session_i
    │ │ │ +0003c000: 6d70 6c3a 3a74 7269 6767 6572 5f61 7574  mpl::trigger_aut
    │ │ │ +0003c010: 6f5f 6d61 6e61 6765 292c 0a09 0953 4554  o_manage),...SET
    │ │ │ +0003c020: 2861 6374 6976 655f 6468 745f 6c69 6d69  (active_dht_limi
    │ │ │ +0003c030: 742c 2038 382c 206e 756c 6c70 7472 292c  t, 88, nullptr),
    │ │ │ +0003c040: 0a09 0953 4554 2861 6374 6976 655f 7472  ...SET(active_tr
    │ │ │ +0003c050: 6163 6b65 725f 6c69 6d69 742c 2031 3630  acker_limit, 160
    │ │ │ +0003c060: 302c 206e 756c 6c70 7472 292c 0a09 0953  0, nullptr),...S
    │ │ │ +0003c070: 4554 2861 6374 6976 655f 6c73 645f 6c69  ET(active_lsd_li
    │ │ │ +0003c080: 6d69 742c 2036 302c 206e 756c 6c70 7472  mit, 60, nullptr
    │ │ │ +0003c090: 292c 0a09 0953 4554 2861 6374 6976 655f  ),...SET(active_
    │ │ │ +0003c0a0: 6c69 6d69 742c 2035 3030 2c20 2661 6d70  limit, 500, &
    │ │ │ +0003c0b0: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a74  ;session_impl::t
    │ │ │ +0003c0c0: 7269 6767 6572 5f61 7574 6f5f 6d61 6e61  rigger_auto_mana
    │ │ │ +0003c0d0: 6765 292c 0a09 0944 4550 5245 4341 5445  ge),...DEPRECATE
    │ │ │ +0003c0e0: 445f 5345 5428 6163 7469 7665 5f6c 6f61  D_SET(active_loa
    │ │ │ +0003c0f0: 6465 645f 6c69 6d69 742c 2030 2c20 2661  ded_limit, 0, &a
    │ │ │ +0003c100: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a  mp;session_impl:
    │ │ │ +0003c110: 3a74 7269 6767 6572 5f61 7574 6f5f 6d61  :trigger_auto_ma
    │ │ │ +0003c120: 6e61 6765 292c 0a09 0953 4554 2861 7574  nage),...SET(aut
    │ │ │ +0003c130: 6f5f 6d61 6e61 6765 5f69 6e74 6572 7661  o_manage_interva
    │ │ │ +0003c140: 6c2c 2033 302c 206e 756c 6c70 7472 292c  l, 30, nullptr),
    │ │ │ +0003c150: 0a09 0953 4554 2873 6565 645f 7469 6d65  ...SET(seed_time
    │ │ │ +0003c160: 5f6c 696d 6974 2c20 3234 202a 2036 3020  _limit, 24 * 60 
    │ │ │ +0003c170: 2a20 3630 2c20 6e75 6c6c 7074 7229 2c0a  * 60, nullptr),.
    │ │ │ +0003c180: 0909 5345 5428 6175 746f 5f73 6372 6170  ..SET(auto_scrap
    │ │ │ +0003c190: 655f 696e 7465 7276 616c 2c20 3138 3030  e_interval, 1800
    │ │ │ +0003c1a0: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345  , nullptr),...SE
    │ │ │ +0003c1b0: 5428 6175 746f 5f73 6372 6170 655f 6d69  T(auto_scrape_mi
    │ │ │ +0003c1c0: 6e5f 696e 7465 7276 616c 2c20 3330 302c  n_interval, 300,
    │ │ │ +0003c1d0: 206e 756c 6c70 7472 292c 0a09 0953 4554   nullptr),...SET
    │ │ │ +0003c1e0: 286d 6178 5f70 6565 726c 6973 745f 7369  (max_peerlist_si
    │ │ │ +0003c1f0: 7a65 2c20 3330 3030 2c20 6e75 6c6c 7074  ze, 3000, nullpt
    │ │ │ +0003c200: 7229 2c0a 0909 5345 5428 6d61 785f 7061  r),...SET(max_pa
    │ │ │ +0003c210: 7573 6564 5f70 6565 726c 6973 745f 7369  used_peerlist_si
    │ │ │ +0003c220: 7a65 2c20 3130 3030 2c20 6e75 6c6c 7074  ze, 1000, nullpt
    │ │ │ +0003c230: 7229 2c0a 0909 5345 5428 6d69 6e5f 616e  r),...SET(min_an
    │ │ │ +0003c240: 6e6f 756e 6365 5f69 6e74 6572 7661 6c2c  nounce_interval,
    │ │ │ +0003c250: 2035 202a 2036 302c 206e 756c 6c70 7472   5 * 60, nullptr
    │ │ │ +0003c260: 292c 0a09 0953 4554 2861 7574 6f5f 6d61  ),...SET(auto_ma
    │ │ │ +0003c270: 6e61 6765 5f73 7461 7274 7570 2c20 3630  nage_startup, 60
    │ │ │ +0003c280: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345  , nullptr),...SE
    │ │ │ +0003c290: 5428 7365 6564 696e 675f 7069 6563 655f  T(seeding_piece_
    │ │ │ +0003c2a0: 7175 6f74 612c 2032 302c 206e 756c 6c70  quota, 20, nullp
    │ │ │ +0003c2b0: 7472 292c 0a3c 6469 7620 7374 796c 653d  tr),.
    ..SET(max_rej │ │ │ +0003c2f0: 6563 7473 2c20 3530 2c20 6e75 6c6c 7074 ects, 50, nullpt │ │ │ +0003c300: 7229 2c0a 3c2f 6469 763e 0909 5345 5428 r),.
    ..SET( │ │ │ +0003c310: 7265 6376 5f73 6f63 6b65 745f 6275 6666 recv_socket_buff │ │ │ +0003c320: 6572 5f73 697a 652c 2030 2c20 2661 6d70 er_size, 0, & │ │ │ +0003c330: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a75 ;session_impl::u │ │ │ +0003c340: 7064 6174 655f 736f 636b 6574 5f62 7566 pdate_socket_buf │ │ │ +0003c350: 6665 725f 7369 7a65 292c 0a09 0953 4554 fer_size),...SET │ │ │ +0003c360: 2873 656e 645f 736f 636b 6574 5f62 7566 (send_socket_buf │ │ │ +0003c370: 6665 725f 7369 7a65 2c20 302c 2026 616d fer_size, 0, &am │ │ │ +0003c380: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003c390: 7570 6461 7465 5f73 6f63 6b65 745f 6275 update_socket_bu │ │ │ +0003c3a0: 6666 6572 5f73 697a 6529 2c0a 0909 5345 ffer_size),...SE │ │ │ +0003c3b0: 5428 6d61 785f 7065 6572 5f72 6563 765f T(max_peer_recv_ │ │ │ +0003c3c0: 6275 6666 6572 5f73 697a 652c 2032 202a buffer_size, 2 * │ │ │ +0003c3d0: 2031 3032 3420 2a20 3130 3234 2c20 6e75 1024 * 1024, nu │ │ │ +0003c3e0: 6c6c 7074 7229 2c0a 0909 4445 5052 4543 llptr),...DEPREC │ │ │ +0003c3f0: 4154 4544 5f53 4554 2866 696c 655f 6368 ATED_SET(file_ch │ │ │ +0003c400: 6563 6b73 5f64 656c 6179 5f70 6572 5f62 ecks_delay_per_b │ │ │ +0003c410: 6c6f 636b 2c20 302c 206e 756c 6c70 7472 lock, 0, nullptr │ │ │ +0003c420: 292c 0a09 0944 4550 5245 4341 5445 4432 ),...DEPRECATED2 │ │ │ +0003c430: 5f53 4554 2872 6561 645f 6361 6368 655f _SET(read_cache_ │ │ │ +0003c440: 6c69 6e65 5f73 697a 652c 2033 322c 206e line_size, 32, n │ │ │ +0003c450: 756c 6c70 7472 292c 0a09 0944 4550 5245 ullptr),...DEPRE │ │ │ +0003c460: 4341 5445 4432 5f53 4554 2877 7269 7465 CATED2_SET(write │ │ │ +0003c470: 5f63 6163 6865 5f6c 696e 655f 7369 7a65 _cache_line_size │ │ │ +0003c480: 2c20 3136 2c20 6e75 6c6c 7074 7229 2c0a , 16, nullptr),. │ │ │ +0003c490: 0909 5345 5428 6f70 7469 6d69 7374 6963 ..SET(optimistic │ │ │ +0003c4a0: 5f64 6973 6b5f 7265 7472 792c 2031 3020 _disk_retry, 10 │ │ │ +0003c4b0: 2a20 3630 2c20 6e75 6c6c 7074 7229 2c0a * 60, nullptr),. │ │ │ +0003c4c0: 0909 5345 5428 6d61 785f 7375 6767 6573 ..SET(max_sugges │ │ │ +0003c4d0: 745f 7069 6563 6573 2c20 3136 2c20 6e75 t_pieces, 16, nu │ │ │ +0003c4e0: 6c6c 7074 7229 2c0a 0909 5345 5428 6c6f llptr),...SET(lo │ │ │ +0003c4f0: 6361 6c5f 7365 7276 6963 655f 616e 6e6f cal_service_anno │ │ │ +0003c500: 756e 6365 5f69 6e74 6572 7661 6c2c 2035 unce_interval, 5 │ │ │ +0003c510: 202a 2036 302c 206e 756c 6c70 7472 292c * 60, nullptr), │ │ │ +0003c520: 0a09 0953 4554 2864 6874 5f61 6e6e 6f75 ...SET(dht_annou │ │ │ +0003c530: 6e63 655f 696e 7465 7276 616c 2c20 3135 nce_interval, 15 │ │ │ +0003c540: 202a 2036 302c 2026 616d 703b 7365 7373 * 60, &sess │ │ │ +0003c550: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ +0003c560: 5f64 6874 5f61 6e6e 6f75 6e63 655f 696e _dht_announce_in │ │ │ +0003c570: 7465 7276 616c 292c 0a09 0953 4554 2875 terval),...SET(u │ │ │ +0003c580: 6470 5f74 7261 636b 6572 5f74 6f6b 656e dp_tracker_token │ │ │ +0003c590: 5f65 7870 6972 792c 2036 302c 206e 756c _expiry, 60, nul │ │ │ +0003c5a0: 6c70 7472 292c 0a09 0944 4550 5245 4341 lptr),...DEPRECA │ │ │ +0003c5b0: 5445 445f 5345 5428 6465 6661 756c 745f TED_SET(default_ │ │ │ +0003c5c0: 6361 6368 655f 6d69 6e5f 6167 652c 2031 cache_min_age, 1 │ │ │ +0003c5d0: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345 , nullptr),...SE │ │ │ +0003c5e0: 5428 6e75 6d5f 6f70 7469 6d69 7374 6963 T(num_optimistic │ │ │ +0003c5f0: 5f75 6e63 686f 6b65 5f73 6c6f 7473 2c20 _unchoke_slots, │ │ │ +0003c600: 302c 206e 756c 6c70 7472 292c 0a09 0944 0, nullptr),...D │ │ │ +0003c610: 4550 5245 4341 5445 445f 5345 5428 6465 EPRECATED_SET(de │ │ │ +0003c620: 6661 756c 745f 6573 745f 7265 6369 7072 fault_est_recipr │ │ │ +0003c630: 6f63 6174 696f 6e5f 7261 7465 2c20 3136 ocation_rate, 16 │ │ │ +0003c640: 3030 302c 206e 756c 6c70 7472 292c 0a09 000, nullptr),.. │ │ │ +0003c650: 0944 4550 5245 4341 5445 445f 5345 5428 .DEPRECATED_SET( │ │ │ +0003c660: 696e 6372 6561 7365 5f65 7374 5f72 6563 increase_est_rec │ │ │ +0003c670: 6970 726f 6361 7469 6f6e 5f72 6174 652c iprocation_rate, │ │ │ +0003c680: 2032 302c 206e 756c 6c70 7472 292c 0a09 20, nullptr),.. │ │ │ +0003c690: 0944 4550 5245 4341 5445 445f 5345 5428 .DEPRECATED_SET( │ │ │ +0003c6a0: 6465 6372 6561 7365 5f65 7374 5f72 6563 decrease_est_rec │ │ │ +0003c6b0: 6970 726f 6361 7469 6f6e 5f72 6174 652c iprocation_rate, │ │ │ +0003c6c0: 2033 2c20 6e75 6c6c 7074 7229 2c0a 0909 3, nullptr),... │ │ │ +0003c6d0: 5345 5428 6d61 785f 7065 785f 7065 6572 SET(max_pex_peer │ │ │ +0003c6e0: 732c 2035 302c 206e 756c 6c70 7472 292c s, 50, nullptr), │ │ │ +0003c6f0: 0a09 0953 4554 2874 6963 6b5f 696e 7465 ...SET(tick_inte │ │ │ +0003c700: 7276 616c 2c20 3530 302c 206e 756c 6c70 rval, 500, nullp │ │ │ +0003c710: 7472 292c 0a09 0953 4554 2873 6861 7265 tr),...SET(share │ │ │ +0003c720: 5f6d 6f64 655f 7461 7267 6574 2c20 332c _mode_target, 3, │ │ │ +0003c730: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ +0003c740: 2875 706c 6f61 645f 7261 7465 5f6c 696d (upload_rate_lim │ │ │ +0003c750: 6974 2c20 302c 2026 616d 703b 7365 7373 it, 0, &sess │ │ │ +0003c760: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ +0003c770: 5f75 706c 6f61 645f 7261 7465 292c 0a09 _upload_rate),.. │ │ │ +0003c780: 0953 4554 2864 6f77 6e6c 6f61 645f 7261 .SET(download_ra │ │ │ +0003c790: 7465 5f6c 696d 6974 2c20 302c 2026 616d te_limit, 0, &am │ │ │ +0003c7a0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003c7b0: 7570 6461 7465 5f64 6f77 6e6c 6f61 645f update_download_ │ │ │ +0003c7c0: 7261 7465 292c 0a09 0944 4550 5245 4341 rate),...DEPRECA │ │ │ +0003c7d0: 5445 445f 5345 5428 6c6f 6361 6c5f 7570 TED_SET(local_up │ │ │ +0003c7e0: 6c6f 6164 5f72 6174 655f 6c69 6d69 742c load_rate_limit, │ │ │ +0003c7f0: 2030 2c20 2661 6d70 3b73 6573 7369 6f6e 0, &session │ │ │ +0003c800: 5f69 6d70 6c3a 3a75 7064 6174 655f 6c6f _impl::update_lo │ │ │ +0003c810: 6361 6c5f 7570 6c6f 6164 5f72 6174 6529 cal_upload_rate) │ │ │ +0003c820: 2c0a 0909 4445 5052 4543 4154 4544 5f53 ,...DEPRECATED_S │ │ │ +0003c830: 4554 286c 6f63 616c 5f64 6f77 6e6c 6f61 ET(local_downloa │ │ │ +0003c840: 645f 7261 7465 5f6c 696d 6974 2c20 302c d_rate_limit, 0, │ │ │ +0003c850: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ +0003c860: 706c 3a3a 7570 6461 7465 5f6c 6f63 616c pl::update_local │ │ │ +0003c870: 5f64 6f77 6e6c 6f61 645f 7261 7465 292c _download_rate), │ │ │ +0003c880: 0a09 0953 4554 2864 6874 5f75 706c 6f61 ...SET(dht_uploa │ │ │ +0003c890: 645f 7261 7465 5f6c 696d 6974 2c20 3830 d_rate_limit, 80 │ │ │ +0003c8a0: 3030 2c20 2661 6d70 3b73 6573 7369 6f6e 00, &session │ │ │ +0003c8b0: 5f69 6d70 6c3a 3a75 7064 6174 655f 6468 _impl::update_dh │ │ │ +0003c8c0: 745f 7570 6c6f 6164 5f72 6174 655f 6c69 t_upload_rate_li │ │ │ +0003c8d0: 6d69 7429 2c0a 0909 5345 5428 756e 6368 mit),...SET(unch │ │ │ +0003c8e0: 6f6b 655f 736c 6f74 735f 6c69 6d69 742c oke_slots_limit, │ │ │ +0003c8f0: 2038 2c20 2661 6d70 3b73 6573 7369 6f6e 8, &session │ │ │ +0003c900: 5f69 6d70 6c3a 3a75 7064 6174 655f 756e _impl::update_un │ │ │ +0003c910: 6368 6f6b 655f 6c69 6d69 7429 2c0a 0909 choke_limit),... │ │ │ +0003c920: 4445 5052 4543 4154 4544 5f53 4554 2868 DEPRECATED_SET(h │ │ │ +0003c930: 616c 665f 6f70 656e 5f6c 696d 6974 2c20 alf_open_limit, │ │ │ +0003c940: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ +0003c950: 4554 2863 6f6e 6e65 6374 696f 6e73 5f6c ET(connections_l │ │ │ +0003c960: 696d 6974 2c20 3230 302c 2026 616d 703b imit, 200, & │ │ │ +0003c970: 7365 7373 696f 6e5f 696d 706c 3a3a 7570 session_impl::up │ │ │ +0003c980: 6461 7465 5f63 6f6e 6e65 6374 696f 6e73 date_connections │ │ │ +0003c990: 5f6c 696d 6974 292c 0a09 0953 4554 2863 _limit),...SET(c │ │ │ +0003c9a0: 6f6e 6e65 6374 696f 6e73 5f73 6c61 636b onnections_slack │ │ │ +0003c9b0: 2c20 3130 2c20 6e75 6c6c 7074 7229 2c0a , 10, nullptr),. │ │ │ +0003c9c0: 0909 5345 5428 7574 705f 7461 7267 6574 ..SET(utp_target │ │ │ +0003c9d0: 5f64 656c 6179 2c20 3130 302c 206e 756c _delay, 100, nul │ │ │ +0003c9e0: 6c70 7472 292c 0a09 0953 4554 2875 7470 lptr),...SET(utp │ │ │ +0003c9f0: 5f67 6169 6e5f 6661 6374 6f72 2c20 3330 _gain_factor, 30 │ │ │ +0003ca00: 3030 2c20 6e75 6c6c 7074 7229 2c0a 3c2f 00, nullptr),.r │ │ │ +0003ca40: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0003ca50: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0003ca80: 7365 7474 696e 6773 5f70 6163 6b2e 6370 settings_pack.cp │ │ │ +0003ca90: 703a 3537 373c 2f61 3e3c 2f74 643e 3c74 p:577it would be ni │ │ │ +0003cab0: 6365 2074 6f20 7265 7365 7276 6528 2920 ce to reserve() │ │ │ +0003cac0: 7468 6573 6520 7665 6374 6f72 7320 7570 these vectors up │ │ │ +0003cad0: 2066 726f 6e74 3c2f 7464 3e3c 2f74 723e front │ │ │ +0003cae0: 3c74 7220 6964 3d22 3135 3222 2073 7479 │ │ │ +0003cb10: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0003cb20: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +0003cb30: 6e69 6365 2074 6f20 7265 7365 7276 6528 nice to reserve( │ │ │ +0003cb40: 2920 7468 6573 6520 7665 6374 6f72 7320 ) these vectors │ │ │ +0003cb50: 7570 2066 726f 6e74 3c2f 6832 3e3c 6834 up front

    ../src/settings │ │ │ +0003cb70: 5f70 6163 6b2e 6370 703a 3537 373c 2f68 _pack.cpp:577
    ...s
    │ │ │ +0003cbc0: 2e73 6574 5f73 7472 2873 6574 7469 6e67  .set_str(setting
    │ │ │ +0003cbd0: 735f 7061 636b 3a3a 7374 7269 6e67 5f74  s_pack::string_t
    │ │ │ +0003cbe0: 7970 655f 6261 7365 207c 2069 2c20 7374  ype_base | i, st
    │ │ │ +0003cbf0: 725f 7365 7474 696e 6773 5b69 5d2e 6465  r_settings[i].de
    │ │ │ +0003cc00: 6661 756c 745f 7661 6c75 6529 3b0a 0909  fault_value);...
    │ │ │ +0003cc10: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0003cc20: 732e 6765 745f 7374 7228 7365 7474 696e  s.get_str(settin
    │ │ │ +0003cc30: 6773 5f70 6163 6b3a 3a73 7472 696e 675f  gs_pack::string_
    │ │ │ +0003cc40: 7479 7065 5f62 6173 6520 2b20 6929 203d  type_base + i) =
    │ │ │ +0003cc50: 3d20 7374 725f 7365 7474 696e 6773 5b69  = str_settings[i
    │ │ │ +0003cc60: 5d2e 6465 6661 756c 745f 7661 6c75 6529  ].default_value)
    │ │ │ +0003cc70: 3b0a 0909 7d0a 0a09 0966 6f72 2028 696e  ;...}....for (in
    │ │ │ +0003cc80: 7420 6920 3d20 303b 2069 2026 6c74 3b20  t i = 0; i < 
    │ │ │ +0003cc90: 7365 7474 696e 6773 5f70 6163 6b3a 3a6e  settings_pack::n
    │ │ │ +0003cca0: 756d 5f69 6e74 5f73 6574 7469 6e67 733b  um_int_settings;
    │ │ │ +0003ccb0: 202b 2b69 290a 0909 7b0a 0909 0973 2e73   ++i)...{....s.s
    │ │ │ +0003ccc0: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ +0003ccd0: 7061 636b 3a3a 696e 745f 7479 7065 5f62  pack::int_type_b
    │ │ │ +0003cce0: 6173 6520 7c20 692c 2069 6e74 5f73 6574  ase | i, int_set
    │ │ │ +0003ccf0: 7469 6e67 735b 695d 2e64 6566 6175 6c74  tings[i].default
    │ │ │ +0003cd00: 5f76 616c 7565 293b 0a09 0909 544f 5252  _value);....TORR
    │ │ │ +0003cd10: 454e 545f 4153 5345 5254 2873 2e67 6574  ENT_ASSERT(s.get
    │ │ │ +0003cd20: 5f69 6e74 2873 6574 7469 6e67 735f 7061  _int(settings_pa
    │ │ │ +0003cd30: 636b 3a3a 696e 745f 7479 7065 5f62 6173  ck::int_type_bas
    │ │ │ +0003cd40: 6520 2b20 6929 203d 3d20 696e 745f 7365  e + i) == int_se
    │ │ │ +0003cd50: 7474 696e 6773 5b69 5d2e 6465 6661 756c  ttings[i].defaul
    │ │ │ +0003cd60: 745f 7661 6c75 6529 3b0a 0909 7d0a 0a09  t_value);...}...
    │ │ │ +0003cd70: 0966 6f72 2028 696e 7420 6920 3d20 303b  .for (int i = 0;
    │ │ │ +0003cd80: 2069 2026 6c74 3b20 7365 7474 696e 6773   i < settings
    │ │ │ +0003cd90: 5f70 6163 6b3a 3a6e 756d 5f62 6f6f 6c5f  _pack::num_bool_
    │ │ │ +0003cda0: 7365 7474 696e 6773 3b20 2b2b 6929 0a09  settings; ++i)..
    │ │ │ +0003cdb0: 097b 0a09 0909 732e 7365 745f 626f 6f6c  .{....s.set_bool
    │ │ │ +0003cdc0: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ +0003cdd0: 626f 6f6c 5f74 7970 655f 6261 7365 207c  bool_type_base |
    │ │ │ +0003cde0: 2069 2c20 626f 6f6c 5f73 6574 7469 6e67   i, bool_setting
    │ │ │ +0003cdf0: 735b 695d 2e64 6566 6175 6c74 5f76 616c  s[i].default_val
    │ │ │ +0003ce00: 7565 293b 0a09 0909 544f 5252 454e 545f  ue);....TORRENT_
    │ │ │ +0003ce10: 4153 5345 5254 2873 2e67 6574 5f62 6f6f  ASSERT(s.get_boo
    │ │ │ +0003ce20: 6c28 7365 7474 696e 6773 5f70 6163 6b3a  l(settings_pack:
    │ │ │ +0003ce30: 3a62 6f6f 6c5f 7479 7065 5f62 6173 6520  :bool_type_base 
    │ │ │ +0003ce40: 2b20 6929 203d 3d20 626f 6f6c 5f73 6574  + i) == bool_set
    │ │ │ +0003ce50: 7469 6e67 735b 695d 2e64 6566 6175 6c74  tings[i].default
    │ │ │ +0003ce60: 5f76 616c 7565 293b 0a09 097d 0a09 7d0a  _value);...}..}.
    │ │ │ +0003ce70: 0a09 7365 7474 696e 6773 5f70 6163 6b20  ..settings_pack 
    │ │ │ +0003ce80: 6465 6661 756c 745f 7365 7474 696e 6773  default_settings
    │ │ │ +0003ce90: 2829 0a09 7b0a 0909 7365 7474 696e 6773  ()..{...settings
    │ │ │ +0003cea0: 5f70 6163 6b20 7265 743b 0a3c 6469 7620  _pack ret;.
    ..for ( │ │ │ +0003cee0: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ +0003cef0: 3b20 7365 7474 696e 6773 5f70 6163 6b3a ; settings_pack: │ │ │ +0003cf00: 3a6e 756d 5f73 7472 696e 675f 7365 7474 :num_string_sett │ │ │ +0003cf10: 696e 6773 3b20 2b2b 6929 0a3c 2f64 6976 ings; ++i).
    ..{....if (str_ │ │ │ +0003cf30: 7365 7474 696e 6773 5b69 5d2e 6465 6661 settings[i].defa │ │ │ +0003cf40: 756c 745f 7661 6c75 652e 656d 7074 7928 ult_value.empty( │ │ │ +0003cf50: 2929 2063 6f6e 7469 6e75 653b 0a09 0909 )) continue;.... │ │ │ +0003cf60: 7265 742e 7365 745f 7374 7228 7365 7474 ret.set_str(sett │ │ │ +0003cf70: 696e 6773 5f70 6163 6b3a 3a73 7472 696e ings_pack::strin │ │ │ +0003cf80: 675f 7479 7065 5f62 6173 6520 2b20 692c g_type_base + i, │ │ │ +0003cf90: 2073 7472 5f73 6574 7469 6e67 735b 695d str_settings[i] │ │ │ +0003cfa0: 2e64 6566 6175 6c74 5f76 616c 7565 293b .default_value); │ │ │ +0003cfb0: 0a09 097d 0a0a 0909 666f 7220 2869 6e74 ...}....for (int │ │ │ +0003cfc0: 2069 203d 2030 3b20 6920 266c 743b 2073 i = 0; i < s │ │ │ +0003cfd0: 6574 7469 6e67 735f 7061 636b 3a3a 6e75 ettings_pack::nu │ │ │ +0003cfe0: 6d5f 696e 745f 7365 7474 696e 6773 3b20 m_int_settings; │ │ │ +0003cff0: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ +0003d000: 7365 745f 696e 7428 7365 7474 696e 6773 set_int(settings │ │ │ +0003d010: 5f70 6163 6b3a 3a69 6e74 5f74 7970 655f _pack::int_type_ │ │ │ +0003d020: 6261 7365 202b 2069 2c20 696e 745f 7365 base + i, int_se │ │ │ +0003d030: 7474 696e 6773 5b69 5d2e 6465 6661 756c ttings[i].defaul │ │ │ +0003d040: 745f 7661 6c75 6529 3b0a 0909 7d0a 0a09 t_value);...}... │ │ │ +0003d050: 0966 6f72 2028 696e 7420 6920 3d20 303b .for (int i = 0; │ │ │ +0003d060: 2069 2026 6c74 3b20 7365 7474 696e 6773 i < settings │ │ │ +0003d070: 5f70 6163 6b3a 3a6e 756d 5f62 6f6f 6c5f _pack::num_bool_ │ │ │ +0003d080: 7365 7474 696e 6773 3b20 2b2b 6929 0a09 settings; ++i).. │ │ │ +0003d090: 097b 0a09 0909 7265 742e 7365 745f 626f .{....ret.set_bo │ │ │ +0003d0a0: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +0003d0b0: 3a3a 626f 6f6c 5f74 7970 655f 6261 7365 ::bool_type_base │ │ │ +0003d0c0: 202b 2069 2c20 626f 6f6c 5f73 6574 7469 + i, bool_setti │ │ │ +0003d0d0: 6e67 735b 695d 2e64 6566 6175 6c74 5f76 ngs[i].default_v │ │ │ +0003d0e0: 616c 7565 293b 0a09 097d 0a09 0972 6574 alue);...}...ret │ │ │ +0003d0f0: 7572 6e20 7265 743b 0a09 7d0a 0a09 766f urn ret;..}...vo │ │ │ +0003d100: 6964 2061 7070 6c79 5f70 6163 6b28 7365 id apply_pack(se │ │ │ +0003d110: 7474 696e 6773 5f70 6163 6b20 636f 6e73 ttings_pack cons │ │ │ +0003d120: 742a 2070 6163 6b2c 2061 7578 3a3a 7365 t* pack, aux::se │ │ │ +0003d130: 7373 696f 6e5f 7365 7474 696e 6773 2661 ssion_settings&a │ │ │ +0003d140: 6d70 3b20 7365 7474 0a09 092c 2061 7578 mp; sett..., aux │ │ │ +0003d150: 3a3a 7365 7373 696f 6e5f 696d 706c 2a20 ::session_impl* │ │ │ +0003d160: 7365 7329 0a09 7b0a 0909 7573 696e 6720 ses)..{...using │ │ │ +0003d170: 6675 6e5f 7420 3d20 766f 6964 2028 6175 fun_t = void (au │ │ │ +0003d180: 783a 3a73 6573 7369 6f6e 5f69 6d70 6c3a x::session_impl: │ │ │ +0003d190: 3a2a 2928 293b 0a09 0973 7464 3a3a 7665 :*)();...std::ve │ │ │ +0003d1a0: 6374 6f72 266c 743b 6675 6e5f 7426 6774 ctor<fun_t> │ │ │ +0003d1b0: 3b20 6361 6c6c 6261 636b 733b 0a0a 0909 ; callbacks;.... │ │ │ +0003d1c0: 7365 7474 2e62 756c 6b5f 7365 7428 5b26 sett.bulk_set([& │ │ │ +0003d1d0: 616d 703b 5d28 6175 783a 3a73 6573 7369 amp;](aux::sessi │ │ │ +0003d1e0: 6f6e 5f73 6574 7469 6e67 735f 7369 6e67 on_settings_sing │ │ │ +0003d1f0: 6c65 5f74 6872 6561 6426 616d 703b 2073 le_thread& s │ │ │ +0003d200: 290a 0909 7b0a 0909 0961 7070 6c79 5f70 )...{....apply_p │ │ │ +0003d210: 6163 6b5f 696d 706c 2870 6163 6b2c 2073 ack_impl(pack, s │ │ │ +0003d220: 2c20 7365 7320 3f20 2661 6d70 3b63 616c , ses ? &cal │ │ │ +0003d230: 6c62 6163 6b73 203a 206e 756c 6c70 7472 lbacks : nullptr │ │ │ +0003d240: 293b 0a09 097d 293b 0a0a 0909 2f2f 2063 );...});....// c │ │ │ +0003d250: 616c 6c20 7468 6520 6361 6c6c 6261 636b all the callback │ │ │ +0003d260: 7320 6f6e 6365 2061 6c6c 2074 6865 2073 s once all the s │ │ │ +0003d270: 6574 7469 6e67 7320 6861 7665 2062 6565 ettings have bee │ │ │ +0003d280: 6e20 6170 706c 6965 642c 2061 6e64 0a09 n applied, and.. │ │ │ +0003d290: 092f 2f20 6f6e 6c79 206f 6e63 6520 7065 .// only once pe │ │ │ +0003d2a0: 7220 6361 6c6c 6261 636b 0a3c 2f70 7265 r callback.
    rele │ │ │ +0003d2e0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ +0003d320: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3538 sion_impl.cpp:58 │ │ │ +0003d330: 373c 2f61 3e3c 2f74 643e 3c74 643e 636f 7co │ │ │ +0003d340: 6d65 2075 7020 7769 7468 2073 6f6d 6520 me up with some │ │ │ +0003d350: 6162 7374 7261 6374 696f 6e20 746f 2064 abstraction to d │ │ │ +0003d360: 6f20 7468 6973 2066 6f72 2067 6e75 746c o this for gnutl │ │ │ +0003d370: 7320 6173 2077 656c 6c20 6c6f 6164 2063 s as well load c │ │ │ +0003d380: 6572 7469 6669 6361 7465 7320 6672 6f6d ertificates from │ │ │ +0003d390: 2074 6865 2077 696e 646f 7773 2073 7973 the windows sys │ │ │ +0003d3a0: 7465 6d20 6365 7274 6966 6963 6174 6520 tem certificate │ │ │ +0003d3b0: 7374 6f72 653c 2f74 643e 3c2f 7472 3e3c store< │ │ │ +0003d3c0: 7472 2069 643d 2231 3533 2220 7374 796c tr id="153" styl │ │ │ +0003d3d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0003d3e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0003d3f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0003d400: 6832 3e63 6f6d 6520 7570 2077 6974 6820 h2>come up with │ │ │ +0003d410: 736f 6d65 2061 6273 7472 6163 7469 6f6e some abstraction │ │ │ +0003d420: 2074 6f20 646f 2074 6869 7320 666f 7220 to do this for │ │ │ +0003d430: 676e 7574 6c73 2061 7320 7765 6c6c 0a6c gnutls as well.l │ │ │ +0003d440: 6f61 6420 6365 7274 6966 6963 6174 6573 oad certificates │ │ │ +0003d450: 2066 726f 6d20 7468 6520 7769 6e64 6f77 from the window │ │ │ +0003d460: 7320 7379 7374 656d 2063 6572 7469 6669 s system certifi │ │ │ +0003d470: 6361 7465 2073 746f 7265 3c2f 6832 3e3c cate store

    < │ │ │ +0003d480: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ +0003d490: 6e5f 696d 706c 2e63 7070 3a35 3837 3c2f n_impl.cpp:587
    .vo
    │ │ │ +0003d4e0: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a  id session_impl:
    │ │ │ +0003d4f0: 3a73 7461 7274 5f73 6573 7369 6f6e 2829  :start_session()
    │ │ │ +0003d500: 0a09 7b0a 2369 666e 6465 6620 544f 5252  ..{.#ifndef TORR
    │ │ │ +0003d510: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ +0003d520: 494e 470a 0909 7365 7373 696f 6e5f 6c6f  ING...session_lo
    │ │ │ +0003d530: 6728 2273 7461 7274 2073 6573 7369 6f6e  g("start session
    │ │ │ +0003d540: 2229 3b0a 2365 6e64 6966 0a0a 2369 6620  ");.#endif..#if 
    │ │ │ +0003d550: 544f 5252 454e 545f 5553 455f 5353 4c0a  TORRENT_USE_SSL.
    │ │ │ +0003d560: 0909 6572 726f 725f 636f 6465 2065 633b  ..error_code ec;
    │ │ │ +0003d570: 0a09 096d 5f73 736c 5f63 7478 2e73 6574  ...m_ssl_ctx.set
    │ │ │ +0003d580: 5f6f 7074 696f 6e73 2873 736c 3a3a 6e6f  _options(ssl::no
    │ │ │ +0003d590: 5f6c 6567 6163 795f 746c 735f 7665 7273  _legacy_tls_vers
    │ │ │ +0003d5a0: 696f 6e73 2c20 6563 293b 0a23 6966 6e64  ions, ec);.#ifnd
    │ │ │ +0003d5b0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +0003d5c0: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620  LE_LOGGING...if 
    │ │ │ +0003d5d0: 2865 6329 0a09 0909 7365 7373 696f 6e5f  (ec)....session_
    │ │ │ +0003d5e0: 6c6f 6728 2253 534c 2073 6574 5f6f 7074  log("SSL set_opt
    │ │ │ +0003d5f0: 696f 6e73 2066 6169 6c65 643a 2025 7322  ions failed: %s"
    │ │ │ +0003d600: 2c20 6563 2e6d 6573 7361 6765 2829 2e63  , ec.message().c
    │ │ │ +0003d610: 5f73 7472 2829 293b 0a09 0965 632e 636c  _str());...ec.cl
    │ │ │ +0003d620: 6561 7228 293b 0a23 656e 6469 660a 0909  ear();.#endif...
    │ │ │ +0003d630: 6d5f 7373 6c5f 6374 782e 7365 745f 6465  m_ssl_ctx.set_de
    │ │ │ +0003d640: 6661 756c 745f 7665 7269 6679 5f70 6174  fault_verify_pat
    │ │ │ +0003d650: 6873 2865 6329 3b0a 2369 666e 6465 6620  hs(ec);.#ifndef 
    │ │ │ +0003d660: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ +0003d670: 4c4f 4747 494e 470a 0909 6966 2028 6563  LOGGING...if (ec
    │ │ │ +0003d680: 2920 7365 7373 696f 6e5f 6c6f 6728 2253  ) session_log("S
    │ │ │ +0003d690: 534c 2073 6574 5f64 6566 6175 6c74 2076  SL set_default v
    │ │ │ +0003d6a0: 6572 6966 795f 7061 7468 7320 6661 696c  erify_paths fail
    │ │ │ +0003d6b0: 6564 3a20 2573 222c 2065 632e 6d65 7373  ed: %s", ec.mess
    │ │ │ +0003d6c0: 6167 6528 292e 635f 7374 7228 2929 3b0a  age().c_str());.
    │ │ │ +0003d6d0: 0909 6563 2e63 6c65 6172 2829 3b0a 2365  ..ec.clear();.#e
    │ │ │ +0003d6e0: 6e64 6966 0a23 6966 2064 6566 696e 6564  ndif.#if defined
    │ │ │ +0003d6f0: 2054 4f52 5245 4e54 5f57 494e 444f 5753   TORRENT_WINDOWS
    │ │ │ +0003d700: 2026 616d 703b 2661 6d70 3b20 6465 6669   && defi
    │ │ │ +0003d710: 6e65 6420 544f 5252 454e 545f 5553 455f  ned TORRENT_USE_
    │ │ │ +0003d720: 4f50 454e 5353 4c20 2661 6d70 3b26 616d  OPENSSL &&am
    │ │ │ +0003d730: 703b 2021 6465 6669 6e65 6420 544f 5252  p; !defined TORR
    │ │ │ +0003d740: 454e 545f 5749 4e52 540a 3c64 6976 2073  ENT_WINRT.
    ..X509_S │ │ │ +0003d780: 544f 5245 2a20 7374 6f72 6520 3d20 5835 TORE* store = X5 │ │ │ +0003d790: 3039 5f53 544f 5245 5f6e 6577 2829 3b0a 09_STORE_new();. │ │ │ +0003d7a0: 3c2f 6469 763e 0909 6966 2028 7374 6f72
    ..if (stor │ │ │ +0003d7b0: 6529 0a09 097b 0a09 0909 4843 4552 5453 e)...{....HCERTS │ │ │ +0003d7c0: 544f 5245 2073 7973 7465 6d5f 7374 6f72 TORE system_stor │ │ │ +0003d7d0: 6520 3d20 4365 7274 4f70 656e 5379 7374 e = CertOpenSyst │ │ │ +0003d7e0: 656d 5374 6f72 6541 2830 2c20 2252 4f4f emStoreA(0, "ROO │ │ │ +0003d7f0: 5422 293b 0a09 0909 2f2f 2074 6869 7320 T");....// this │ │ │ +0003d800: 6973 2062 6573 7420 6566 666f 7274 0a09 is best effort.. │ │ │ +0003d810: 0909 6966 2028 7379 7374 656d 5f73 746f ..if (system_sto │ │ │ +0003d820: 7265 290a 0909 097b 0a09 0909 0943 4552 re)....{.....CER │ │ │ +0003d830: 545f 434f 4e54 4558 5420 636f 6e73 742a T_CONTEXT const* │ │ │ +0003d840: 2063 7478 203d 206e 756c 6c70 7472 3b0a ctx = nullptr;. │ │ │ +0003d850: 0909 0909 7768 696c 6520 2828 6374 7820 ....while ((ctx │ │ │ +0003d860: 3d20 4365 7274 456e 756d 4365 7274 6966 = CertEnumCertif │ │ │ +0003d870: 6963 6174 6573 496e 5374 6f72 6528 7379 icatesInStore(sy │ │ │ +0003d880: 7374 656d 5f73 746f 7265 2c20 6374 7829 stem_store, ctx) │ │ │ +0003d890: 2920 213d 206e 756c 6c70 7472 290a 0909 ) != nullptr)... │ │ │ +0003d8a0: 0909 7b0a 0909 0909 0975 6e73 6967 6e65 ..{......unsigne │ │ │ +0003d8b0: 6420 6368 6172 2063 6f6e 7374 2a20 6365 d char const* ce │ │ │ +0003d8c0: 7274 5f70 7472 203d 2072 6569 6e74 6572 rt_ptr = reinter │ │ │ +0003d8d0: 7072 6574 5f63 6173 7426 6c74 3b75 6e73 pret_cast<uns │ │ │ +0003d8e0: 6967 6e65 6420 6368 6172 2063 6f6e 7374 igned char const │ │ │ +0003d8f0: 2a26 6774 3b28 6374 782d 2667 743b 7062 *>(ctx->pb │ │ │ +0003d900: 4365 7274 456e 636f 6465 6429 3b0a 0909 CertEncoded);... │ │ │ +0003d910: 0909 0958 3530 392a 2078 3530 3920 3d20 ...X509* x509 = │ │ │ +0003d920: 6432 695f 5835 3039 286e 756c 6c70 7472 d2i_X509(nullptr │ │ │ +0003d930: 2c20 2661 6d70 3b63 6572 745f 7074 722c , &cert_ptr, │ │ │ +0003d940: 2063 7478 2d26 6774 3b63 6243 6572 7445 ctx->cbCertE │ │ │ +0003d950: 6e63 6f64 6564 293b 0a09 0909 0909 2f2f ncoded);......// │ │ │ +0003d960: 2074 6869 7320 6973 2062 6573 7420 6566 this is best ef │ │ │ +0003d970: 666f 7274 0a09 0909 0909 6966 2028 2178 fort......if (!x │ │ │ +0003d980: 3530 3929 2063 6f6e 7469 6e75 653b 0a09 509) continue;.. │ │ │ +0003d990: 0909 0909 5835 3039 5f53 544f 5245 5f61 ....X509_STORE_a │ │ │ +0003d9a0: 6464 5f63 6572 7428 7374 6f72 652c 2078 dd_cert(store, x │ │ │ +0003d9b0: 3530 3929 3b0a 0909 0909 0958 3530 395f 509);......X509_ │ │ │ +0003d9c0: 6672 6565 2878 3530 3929 3b0a 0909 0909 free(x509);..... │ │ │ +0003d9d0: 7d0a 0909 0909 4365 7274 4672 6565 4365 }.....CertFreeCe │ │ │ +0003d9e0: 7274 6966 6963 6174 6543 6f6e 7465 7874 rtificateContext │ │ │ +0003d9f0: 2863 7478 293b 0a09 0909 0943 6572 7443 (ctx);.....CertC │ │ │ +0003da00: 6c6f 7365 5374 6f72 6528 7379 7374 656d loseStore(system │ │ │ +0003da10: 5f73 746f 7265 2c20 3029 3b0a 0909 097d _store, 0);....} │ │ │ +0003da20: 0a09 097d 0a0a 0909 5353 4c5f 4354 582a ...}....SSL_CTX* │ │ │ +0003da30: 2073 736c 5f63 7478 203d 206d 5f73 736c ssl_ctx = m_ssl │ │ │ +0003da40: 5f63 7478 2e6e 6174 6976 655f 6861 6e64 _ctx.native_hand │ │ │ +0003da50: 6c65 2829 3b0a 0909 5353 4c5f 4354 585f le();...SSL_CTX_ │ │ │ +0003da60: 7365 745f 6365 7274 5f73 746f 7265 2873 set_cert_store(s │ │ │ +0003da70: 736c 5f63 7478 2c20 7374 6f72 6529 3b0a sl_ctx, store);. │ │ │ +0003da80: 2365 6e64 6966 0a23 6966 6465 6620 5f5f #endif.#ifdef __ │ │ │ +0003da90: 4150 504c 455f 5f0a 0909 6d5f 7373 6c5f APPLE__...m_ssl_ │ │ │ +0003daa0: 6374 782e 6c6f 6164 5f76 6572 6966 795f ctx.load_verify_ │ │ │ +0003dab0: 6669 6c65 2822 2f65 7463 2f73 736c 2f63 file("/etc/ssl/c │ │ │ +0003dac0: 6572 742e 7065 6d22 2c20 6563 293b 0a23 ert.pem", ec);.# │ │ │ +0003dad0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +0003dae0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +0003daf0: 0969 6620 2865 6329 2073 6573 7369 6f6e .if (ec) session │ │ │ +0003db00: 5f6c 6f67 2822 5353 4c20 6c6f 6164 5f76 _log("SSL load_v │ │ │ +0003db10: 6572 6966 795f 6669 6c65 2066 6169 6c65 erify_file faile │ │ │ +0003db20: 643a 2025 7322 2c20 6563 2e6d 6573 7361 d: %s", ec.messa │ │ │ +0003db30: 6765 2829 2e63 5f73 7472 2829 293b 0a23 ge().c_str());.# │ │ │ +0003db40: 656e 6469 660a 0909 6563 2e63 6c65 6172 endif...ec.clear │ │ │ +0003db50: 2829 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ();.
    < │ │ │ +0003db60: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0003db90: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0003dbc0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +0003dbd0: 706c 2e63 7070 3a31 3436 323c 2f61 3e3c pl.cpp:1462< │ │ │ +0003dbe0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ +0003dbf0: 2062 6520 6e69 6365 2074 6f20 7265 7365 be nice to rese │ │ │ +0003dc00: 7276 6528 2920 7468 6573 6520 7665 6374 rve() these vect │ │ │ +0003dc10: 6f72 7320 7570 2066 726f 6e74 3c2f 7464 ors up front

    it wou │ │ │ +0003dc70: 6c64 2062 6520 6e69 6365 2074 6f20 7265 ld be nice to re │ │ │ +0003dc80: 7365 7276 6528 2920 7468 6573 6520 7665 serve() these ve │ │ │ +0003dc90: 6374 6f72 7320 7570 2066 726f 6e74 3c2f ctors up front

    ../src/se │ │ │ +0003dcb0: 7373 696f 6e5f 696d 706c 2e63 7070 3a31 ssion_impl.cpp:1 │ │ │ +0003dcc0: 3436 323c 2f68 343e 3c70 7265 2073 7479 462

    ...bandwidth_c
    │ │ │ +0003dd10: 6861 6e6e 656c 2a20 6368 203d 2026 616d  hannel* ch = &am
    │ │ │ +0003dd20: 703b 702d 2667 743b 6368 616e 6e65 6c5b  p;p->channel[
    │ │ │ +0003dd30: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +0003dd40: 3a64 6f77 6e6c 6f61 645f 6368 616e 6e65  :download_channe
    │ │ │ +0003dd50: 6c5d 3b0a 0909 0969 6620 2875 7365 5f71  l];....if (use_q
    │ │ │ +0003dd60: 756f 7461 5f6f 7665 7268 6561 6428 6368  uota_overhead(ch
    │ │ │ +0003dd70: 2c20 616d 6f75 6e74 5f64 6f77 6e29 290a  , amount_down)).
    │ │ │ +0003dd80: 0909 0909 7265 7420 7c3d 2031 7520 266c  ....ret |= 1u &l
    │ │ │ +0003dd90: 743b 266c 743b 2070 6565 725f 636f 6e6e  t;< peer_conn
    │ │ │ +0003dda0: 6563 7469 6f6e 3a3a 646f 776e 6c6f 6164  ection::download
    │ │ │ +0003ddb0: 5f63 6861 6e6e 656c 3b0a 0909 0963 6820  _channel;....ch 
    │ │ │ +0003ddc0: 3d20 2661 6d70 3b70 2d26 6774 3b63 6861  = &p->cha
    │ │ │ +0003ddd0: 6e6e 656c 5b70 6565 725f 636f 6e6e 6563  nnel[peer_connec
    │ │ │ +0003dde0: 7469 6f6e 3a3a 7570 6c6f 6164 5f63 6861  tion::upload_cha
    │ │ │ +0003ddf0: 6e6e 656c 5d3b 0a09 0909 6966 2028 7573  nnel];....if (us
    │ │ │ +0003de00: 655f 7175 6f74 615f 6f76 6572 6865 6164  e_quota_overhead
    │ │ │ +0003de10: 2863 682c 2061 6d6f 756e 745f 7570 2929  (ch, amount_up))
    │ │ │ +0003de20: 0a09 0909 0972 6574 207c 3d20 3175 2026  .....ret |= 1u &
    │ │ │ +0003de30: 6c74 3b26 6c74 3b20 7065 6572 5f63 6f6e  lt;< peer_con
    │ │ │ +0003de40: 6e65 6374 696f 6e3a 3a75 706c 6f61 645f  nection::upload_
    │ │ │ +0003de50: 6368 616e 6e65 6c3b 0a09 097d 0a09 0972  channel;...}...r
    │ │ │ +0003de60: 6574 7572 6e20 7265 743b 0a09 7d0a 0a09  eturn ret;..}...
    │ │ │ +0003de70: 2f2f 2073 6573 7369 6f6e 5f69 6d70 6c20  // session_impl 
    │ │ │ +0003de80: 6973 2072 6573 706f 6e73 6962 6c65 2066  is responsible f
    │ │ │ +0003de90: 6f72 2064 656c 6574 696e 6720 2770 6163  or deleting 'pac
    │ │ │ +0003dea0: 6b27 0a09 766f 6964 2073 6573 7369 6f6e  k'..void session
    │ │ │ +0003deb0: 5f69 6d70 6c3a 3a61 7070 6c79 5f73 6574  _impl::apply_set
    │ │ │ +0003dec0: 7469 6e67 735f 7061 636b 2873 7464 3a3a  tings_pack(std::
    │ │ │ +0003ded0: 7368 6172 6564 5f70 7472 266c 743b 7365  shared_ptr<se
    │ │ │ +0003dee0: 7474 696e 6773 5f70 6163 6b26 6774 3b20  ttings_pack> 
    │ │ │ +0003def0: 7061 636b 290a 097b 0a09 0949 4e56 4152  pack)..{...INVAR
    │ │ │ +0003df00: 4941 4e54 5f43 4845 434b 3b0a 0909 6170  IANT_CHECK;...ap
    │ │ │ +0003df10: 706c 795f 7365 7474 696e 6773 5f70 6163  ply_settings_pac
    │ │ │ +0003df20: 6b5f 696d 706c 282a 7061 636b 293b 0a09  k_impl(*pack);..
    │ │ │ +0003df30: 7d0a 0a09 7365 7474 696e 6773 5f70 6163  }...settings_pac
    │ │ │ +0003df40: 6b20 7365 7373 696f 6e5f 696d 706c 3a3a  k session_impl::
    │ │ │ +0003df50: 6765 745f 7365 7474 696e 6773 2829 2063  get_settings() c
    │ │ │ +0003df60: 6f6e 7374 0a09 7b0a 0909 7365 7474 696e  onst..{...settin
    │ │ │ +0003df70: 6773 5f70 6163 6b20 7265 743b 0a3c 6469  gs_pack ret;...for
    │ │ │ +0003dfb0: 2028 696e 7420 6920 3d20 7365 7474 696e   (int i = settin
    │ │ │ +0003dfc0: 6773 5f70 6163 6b3a 3a73 7472 696e 675f  gs_pack::string_
    │ │ │ +0003dfd0: 7479 7065 5f62 6173 653b 0a3c 2f64 6976  type_base;....i < setti
    │ │ │ +0003dff0: 6e67 735f 7061 636b 3a3a 6d61 785f 7374  ngs_pack::max_st
    │ │ │ +0003e000: 7269 6e67 5f73 6574 7469 6e67 5f69 6e74  ring_setting_int
    │ │ │ +0003e010: 6572 6e61 6c3b 202b 2b69 290a 0909 7b0a  ernal; ++i)...{.
    │ │ │ +0003e020: 0909 0972 6574 2e73 6574 5f73 7472 2869  ...ret.set_str(i
    │ │ │ +0003e030: 2c20 6d5f 7365 7474 696e 6773 2e67 6574  , m_settings.get
    │ │ │ +0003e040: 5f73 7472 2869 2929 3b0a 0909 7d0a 0909  _str(i));...}...
    │ │ │ +0003e050: 666f 7220 2869 6e74 2069 203d 2073 6574  for (int i = set
    │ │ │ +0003e060: 7469 6e67 735f 7061 636b 3a3a 696e 745f  tings_pack::int_
    │ │ │ +0003e070: 7479 7065 5f62 6173 653b 0a09 0909 6920  type_base;....i 
    │ │ │ +0003e080: 266c 743b 2073 6574 7469 6e67 735f 7061  < settings_pa
    │ │ │ +0003e090: 636b 3a3a 6d61 785f 696e 745f 7365 7474  ck::max_int_sett
    │ │ │ +0003e0a0: 696e 675f 696e 7465 726e 616c 3b20 2b2b  ing_internal; ++
    │ │ │ +0003e0b0: 6929 0a09 097b 0a09 0909 7265 742e 7365  i)...{....ret.se
    │ │ │ +0003e0c0: 745f 696e 7428 692c 206d 5f73 6574 7469  t_int(i, m_setti
    │ │ │ +0003e0d0: 6e67 732e 6765 745f 696e 7428 6929 293b  ngs.get_int(i));
    │ │ │ +0003e0e0: 0a09 097d 0a09 0966 6f72 2028 696e 7420  ...}...for (int 
    │ │ │ +0003e0f0: 6920 3d20 7365 7474 696e 6773 5f70 6163  i = settings_pac
    │ │ │ +0003e100: 6b3a 3a62 6f6f 6c5f 7479 7065 5f62 6173  k::bool_type_bas
    │ │ │ +0003e110: 653b 0a09 0909 6920 266c 743b 2073 6574  e;....i < set
    │ │ │ +0003e120: 7469 6e67 735f 7061 636b 3a3a 6d61 785f  tings_pack::max_
    │ │ │ +0003e130: 626f 6f6c 5f73 6574 7469 6e67 5f69 6e74  bool_setting_int
    │ │ │ +0003e140: 6572 6e61 6c3b 202b 2b69 290a 0909 7b0a  ernal; ++i)...{.
    │ │ │ +0003e150: 0909 0972 6574 2e73 6574 5f62 6f6f 6c28  ...ret.set_bool(
    │ │ │ +0003e160: 692c 206d 5f73 6574 7469 6e67 732e 6765  i, m_settings.ge
    │ │ │ +0003e170: 745f 626f 6f6c 2869 2929 3b0a 0909 7d0a  t_bool(i));...}.
    │ │ │ +0003e180: 0909 7265 7475 726e 2072 6574 3b0a 097d  ..return ret;..}
    │ │ │ +0003e190: 0a0a 6e61 6d65 7370 6163 6520 7b0a 0974  ..namespace {..t
    │ │ │ +0003e1a0: 656d 706c 6174 6520 266c 743b 7479 7065  emplate <type
    │ │ │ +0003e1b0: 6e61 6d65 2050 6163 6b26 6774 3b0a 0969  name Pack>..i
    │ │ │ +0003e1c0: 6e74 2067 6574 5f73 6574 7469 6e67 5f69  nt get_setting_i
    │ │ │ +0003e1d0: 6d70 6c28 5061 636b 2063 6f6e 7374 2661  mpl(Pack const&a
    │ │ │ +0003e1e0: 6d70 3b20 702c 2069 6e74 206e 616d 652c  mp; p, int name,
    │ │ │ +0003e1f0: 2069 6e74 2a29 0a09 7b20 7265 7475 726e   int*)..{ return
    │ │ │ +0003e200: 2070 2e67 6574 5f69 6e74 286e 616d 6529   p.get_int(name)
    │ │ │ +0003e210: 3b20 7d0a 0a09 7465 6d70 6c61 7465 2026  ; }...template &
    │ │ │ +0003e220: 6c74 3b74 7970 656e 616d 6520 5061 636b  lt;typename Pack
    │ │ │ +0003e230: 2667 743b 0a09 626f 6f6c 2067 6574 5f73  >..bool get_s
    │ │ │ +0003e240: 6574 7469 6e67 5f69 6d70 6c28 5061 636b  etting_impl(Pack
    │ │ │ +0003e250: 2063 6f6e 7374 2661 6d70 3b20 702c 2069   const& p, i
    │ │ │ +0003e260: 6e74 206e 616d 652c 2062 6f6f 6c2a 290a  nt name, bool*).
    │ │ │ +0003e270: 097b 2072 6574 7572 6e20 702e 6765 745f  .{ return p.get_
    │ │ │ +0003e280: 626f 6f6c 286e 616d 6529 3b20 7d0a 0a09  bool(name); }...
    │ │ │ +0003e290: 7465 6d70 6c61 7465 2026 6c74 3b74 7970  template <typ
    │ │ │ +0003e2a0: 656e 616d 6520 5061 636b 2667 743b 0a09  ename Pack>..
    │ │ │ +0003e2b0: 7374 643a 3a73 7472 696e 6720 6765 745f  std::string get_
    │ │ │ +0003e2c0: 7365 7474 696e 675f 696d 706c 2850 6163  setting_impl(Pac
    │ │ │ +0003e2d0: 6b20 636f 6e73 7426 616d 703b 2070 2c20  k const& p, 
    │ │ │ +0003e2e0: 696e 7420 6e61 6d65 2c20 7374 643a 3a73  int name, std::s
    │ │ │ +0003e2f0: 7472 696e 672a 290a 097b 2072 6574 7572  tring*)..{ retur
    │ │ │ +0003e300: 6e20 702e 6765 745f 7374 7228 6e61 6d65  n p.get_str(name
    │ │ │ +0003e310: 293b 207d 0a0a 3c2f 7072 653e 3c2f 7464  ); }..
    relevance │ │ │ +0003e350: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0003e360: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session_ │ │ │ +0003e390: 696d 706c 2e63 7070 3a32 3032 373c 2f61 impl.cpp:2027could │ │ │ +0003e3b0: 7468 6973 2066 756e 6374 696f 6e20 6265 this function be │ │ │ +0003e3c0: 206d 6572 6765 6420 7769 7468 2065 7870 merged with exp │ │ │ +0003e3d0: 616e 645f 756e 7370 6563 6966 6965 645f and_unspecified_ │ │ │ +0003e3e0: 6164 6472 6573 7365 733f 2072 6967 6874 addresses? right │ │ │ +0003e3f0: 206e 6f77 2062 6f74 6820 6c69 7374 656e now both listen │ │ │ +0003e400: 5f65 6e64 706f 696e 745f 7420 616e 6420 _endpoint_t and │ │ │ +0003e410: 6c69 7374 656e 5f69 6e74 6572 6661 6365 listen_interface │ │ │ +0003e420: 5f74 2061 7265 2061 6c6d 6f73 7420 6964 _t are almost id │ │ │ +0003e430: 656e 7469 6361 6c2c 206d 6179 6265 2074 entical, maybe t │ │ │ +0003e440: 6865 206c 6174 7465 7220 636f 756c 6420 he latter could │ │ │ +0003e450: 6265 2072 656d 6f76 6564 2074 6f6f 3c2f be removed too

    coul │ │ │ +0003e4b0: 6420 7468 6973 2066 756e 6374 696f 6e20 d this function │ │ │ +0003e4c0: 6265 206d 6572 6765 6420 7769 7468 2065 be merged with e │ │ │ +0003e4d0: 7870 616e 645f 756e 7370 6563 6966 6965 xpand_unspecifie │ │ │ +0003e4e0: 645f 6164 6472 6573 7365 733f 0a72 6967 d_addresses?.rig │ │ │ +0003e4f0: 6874 206e 6f77 2062 6f74 6820 6c69 7374 ht now both list │ │ │ +0003e500: 656e 5f65 6e64 706f 696e 745f 7420 616e en_endpoint_t an │ │ │ +0003e510: 6420 6c69 7374 656e 5f69 6e74 6572 6661 d listen_interfa │ │ │ +0003e520: 6365 5f74 2061 7265 2061 6c6d 6f73 740a ce_t are almost. │ │ │ +0003e530: 6964 656e 7469 6361 6c2c 206d 6179 6265 identical, maybe │ │ │ +0003e540: 2074 6865 206c 6174 7465 7220 636f 756c the latter coul │ │ │ +0003e550: 6420 6265 2072 656d 6f76 6564 2074 6f6f d be removed too │ │ │ +0003e560: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0003e570: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +0003e580: 3a32 3032 373c 2f68 343e 3c70 7265 2073 :2027

    ..session_lo
    │ │ │ +0003e5d0: 6728 2246 4154 414c 2053 4553 5349 4f4e  g("FATAL SESSION
    │ │ │ +0003e5e0: 2045 5252 4f52 2028 2573 203a 2025 6429   ERROR (%s : %d)
    │ │ │ +0003e5f0: 205b 2573 5d22 0a09 0909 2c20 6563 2e63   [%s]"...., ec.c
    │ │ │ +0003e600: 6174 6567 6f72 7928 292e 6e61 6d65 2829  ategory().name()
    │ │ │ +0003e610: 2c20 6563 2e76 616c 7565 2829 2c20 6563  , ec.value(), ec
    │ │ │ +0003e620: 2e6d 6573 7361 6765 2829 2e63 5f73 7472  .message().c_str
    │ │ │ +0003e630: 2829 293b 0a23 656e 6469 660a 0909 7468  ());.#endif...th
    │ │ │ +0003e640: 6973 2d26 6774 3b61 626f 7274 2829 3b0a  is->abort();.
    │ │ │ +0003e650: 097d 0a0a 0976 6f69 6420 7365 7373 696f  .}...void sessio
    │ │ │ +0003e660: 6e5f 696d 706c 3a3a 6f6e 5f69 705f 6368  n_impl::on_ip_ch
    │ │ │ +0003e670: 616e 6765 2865 7272 6f72 5f63 6f64 6520  ange(error_code 
    │ │ │ +0003e680: 636f 6e73 7426 616d 703b 2065 6329 0a09  const& ec)..
    │ │ │ +0003e690: 7b0a 2369 666e 6465 6620 544f 5252 454e  {.#ifndef TORREN
    │ │ │ +0003e6a0: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ +0003e6b0: 470a 0909 6966 2028 2165 6329 0a09 0909  G...if (!ec)....
    │ │ │ +0003e6c0: 7365 7373 696f 6e5f 6c6f 6728 2272 6563  session_log("rec
    │ │ │ +0003e6d0: 6569 7665 6420 6970 2063 6861 6e67 6520  eived ip change 
    │ │ │ +0003e6e0: 6672 6f6d 2069 6e74 6572 6e61 6c20 6970  from internal ip
    │ │ │ +0003e6f0: 5f6e 6f74 6966 6965 7222 293b 0a09 0965  _notifier");...e
    │ │ │ +0003e700: 6c73 650a 0909 0973 6573 7369 6f6e 5f6c  lse....session_l
    │ │ │ +0003e710: 6f67 2822 7265 6365 6976 6564 2065 7272  og("received err
    │ │ │ +0003e720: 6f72 206f 6e5f 6970 5f63 6861 6e67 653a  or on_ip_change:
    │ │ │ +0003e730: 2025 642c 2025 7322 2c20 6563 2e76 616c   %d, %s", ec.val
    │ │ │ +0003e740: 7565 2829 2c20 6563 2e6d 6573 7361 6765  ue(), ec.message
    │ │ │ +0003e750: 2829 2e63 5f73 7472 2829 293b 0a23 656e  ().c_str());.#en
    │ │ │ +0003e760: 6469 660a 0909 6966 2028 6563 207c 7c20  dif...if (ec || 
    │ │ │ +0003e770: 6d5f 6162 6f72 7420 7c7c 2021 6d5f 6970  m_abort || !m_ip
    │ │ │ +0003e780: 5f6e 6f74 6966 6965 7229 2072 6574 7572  _notifier) retur
    │ │ │ +0003e790: 6e3b 0a09 096d 5f69 705f 6e6f 7469 6669  n;...m_ip_notifi
    │ │ │ +0003e7a0: 6572 2d26 6774 3b61 7379 6e63 5f77 6169  er->async_wai
    │ │ │ +0003e7b0: 7428 5b74 6869 735d 2028 6572 726f 725f  t([this] (error_
    │ │ │ +0003e7c0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20  code const& 
    │ │ │ +0003e7d0: 6529 0a09 0909 7b20 7772 6170 2826 616d  e)....{ wrap(&am
    │ │ │ +0003e7e0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a  p;session_impl::
    │ │ │ +0003e7f0: 6f6e 5f69 705f 6368 616e 6765 2c20 6529  on_ip_change, e)
    │ │ │ +0003e800: 3b20 7d29 3b0a 0909 7265 6f70 656e 5f6e  ; });...reopen_n
    │ │ │ +0003e810: 6574 776f 726b 5f73 6f63 6b65 7473 287b  etwork_sockets({
    │ │ │ +0003e820: 7d29 3b0a 097d 0a0a 3c64 6976 2073 7479  });..}..
    .void inte │ │ │ +0003e860: 7266 6163 655f 746f 5f65 6e64 706f 696e rface_to_endpoin │ │ │ +0003e870: 7473 286c 6973 7465 6e5f 696e 7465 7266 ts(listen_interf │ │ │ +0003e880: 6163 655f 7420 636f 6e73 7426 616d 703b ace_t const& │ │ │ +0003e890: 2069 6661 6365 0a3c 2f64 6976 3e09 092c iface.
    .., │ │ │ +0003e8a0: 206c 6973 7465 6e5f 736f 636b 6574 5f66 listen_socket_f │ │ │ +0003e8b0: 6c61 6773 5f74 2066 6c61 6773 0a09 092c lags_t flags..., │ │ │ +0003e8c0: 2073 7061 6e26 6c74 3b69 705f 696e 7465 span<ip_inte │ │ │ +0003e8d0: 7266 6163 6520 636f 6e73 7426 6774 3b20 rface const> │ │ │ +0003e8e0: 636f 6e73 7420 6966 730a 0909 2c20 7374 const ifs..., st │ │ │ +0003e8f0: 643a 3a76 6563 746f 7226 6c74 3b6c 6973 d::vector<lis │ │ │ +0003e900: 7465 6e5f 656e 6470 6f69 6e74 5f74 2667 ten_endpoint_t&g │ │ │ +0003e910: 743b 2661 6d70 3b20 6570 7329 0a09 7b0a t;& eps)..{. │ │ │ +0003e920: 0909 666c 6167 7320 7c3d 2069 6661 6365 ..flags |= iface │ │ │ +0003e930: 2e6c 6f63 616c 203f 206c 6973 7465 6e5f .local ? listen_ │ │ │ +0003e940: 736f 636b 6574 5f74 3a3a 6c6f 6361 6c5f socket_t::local_ │ │ │ +0003e950: 6e65 7477 6f72 6b20 3a20 6c69 7374 656e network : listen │ │ │ +0003e960: 5f73 6f63 6b65 745f 666c 6167 735f 747b _socket_flags_t{ │ │ │ +0003e970: 7d3b 0a09 0974 7261 6e73 706f 7274 2063 };...transport c │ │ │ +0003e980: 6f6e 7374 2073 736c 203d 2069 6661 6365 onst ssl = iface │ │ │ +0003e990: 2e73 736c 203f 2074 7261 6e73 706f 7274 .ssl ? transport │ │ │ +0003e9a0: 3a3a 7373 6c20 3a20 7472 616e 7370 6f72 ::ssl : transpor │ │ │ +0003e9b0: 743a 3a70 6c61 696e 7465 7874 3b0a 0a09 t::plaintext;... │ │ │ +0003e9c0: 092f 2f20 4669 7273 742c 2063 6865 636b .// First, check │ │ │ +0003e9d0: 2074 6f20 7365 6520 6966 2069 7427 7320 to see if it's │ │ │ +0003e9e0: 616e 2049 5020 6164 6472 6573 730a 0909 an IP address... │ │ │ +0003e9f0: 6572 726f 725f 636f 6465 2065 7272 3b0a error_code err;. │ │ │ +0003ea00: 0909 6164 6472 6573 7320 636f 6e73 7420 ..address const │ │ │ +0003ea10: 6164 7220 3d20 6d61 6b65 5f61 6464 7265 adr = make_addre │ │ │ +0003ea20: 7373 2869 6661 6365 2e64 6576 6963 652e ss(iface.device. │ │ │ +0003ea30: 635f 7374 7228 292c 2065 7272 293b 0a09 c_str(), err);.. │ │ │ +0003ea40: 0969 6620 2821 6572 7229 0a09 097b 0a09 .if (!err)...{.. │ │ │ +0003ea50: 0909 6570 732e 656d 706c 6163 655f 6261 ..eps.emplace_ba │ │ │ +0003ea60: 636b 2861 6472 2c20 6966 6163 652e 706f ck(adr, iface.po │ │ │ +0003ea70: 7274 2c20 7374 643a 3a73 7472 696e 677b rt, std::string{ │ │ │ +0003ea80: 7d2c 2073 736c 2c20 666c 6167 7329 3b0a }, ssl, flags);. │ │ │ +0003ea90: 0909 7d0a 0909 656c 7365 0a09 097b 0a09 ..}...else...{.. │ │ │ +0003eaa0: 0909 666c 6167 7320 7c3d 206c 6973 7465 ..flags |= liste │ │ │ +0003eab0: 6e5f 736f 636b 6574 5f74 3a3a 7761 735f n_socket_t::was_ │ │ │ +0003eac0: 6578 7061 6e64 6564 3b0a 0a09 0909 2f2f expanded;.....// │ │ │ +0003ead0: 2074 6869 7320 6973 2074 6865 2063 6173 this is the cas │ │ │ +0003eae0: 6520 7768 6572 6520 6465 7669 6365 206e e where device n │ │ │ +0003eaf0: 616d 6573 2061 206e 6574 776f 726b 2064 ames a network d │ │ │ +0003eb00: 6576 6963 652e 2057 6520 6e65 6564 2074 evice. We need t │ │ │ +0003eb10: 6f0a 0909 092f 2f20 656e 756d 6572 6174 o....// enumerat │ │ │ +0003eb20: 6520 616c 6c20 4950 7320 6173 736f 6369 e all IPs associ │ │ │ +0003eb30: 6174 6564 2077 6974 6820 7468 6973 2064 ated with this d │ │ │ +0003eb40: 6576 6963 650a 0909 0966 6f72 2028 6175 evice....for (au │ │ │ +0003eb50: 746f 2063 6f6e 7374 2661 6d70 3b20 6970 to const& ip │ │ │ +0003eb60: 6661 6365 203a 2069 6673 290a 0909 097b face : ifs)....{ │ │ │ +0003eb70: 0a09 0909 092f 2f20 7765 2772 6520 6c6f .....// we're lo │ │ │ +0003eb80: 6f6b 696e 6720 666f 7220 6120 7370 6563 oking for a spec │ │ │ +0003eb90: 6966 6963 2069 6e74 6572 6661 6365 2c20 ific interface, │ │ │ +0003eba0: 616e 6420 6974 7320 6164 6472 6573 730a and its address. │ │ │ +0003ebb0: 0909 0909 2f2f 2028 7768 6963 6820 6d75 ....// (which mu │ │ │ +0003ebc0: 7374 2062 6520 6f66 2074 6865 2073 616d st be of the sam │ │ │ +0003ebd0: 6520 6661 6d69 6c79 2061 7320 7468 6520 e family as the │ │ │ +0003ebe0: 6164 6472 6573 7320 7765 2772 650a 0909 address we're... │ │ │ +0003ebf0: 0909 2f2f 2063 6f6e 6e65 6374 696e 6720 ..// connecting │ │ │ +0003ec00: 746f 290a 0909 0909 6966 2028 6966 6163 to).....if (ifac │ │ │ +0003ec10: 652e 6465 7669 6365 2021 3d20 6970 6661 e.device != ipfa │ │ │ +0003ec20: 6365 2e6e 616d 6529 2063 6f6e 7469 6e75 ce.name) continu │ │ │ +0003ec30: 653b 0a0a 0909 0909 626f 6f6c 2063 6f6e e;......bool con │ │ │ +0003ec40: 7374 206c 6f63 616c 203d 2069 6661 6365 st local = iface │ │ │ +0003ec50: 2e6c 6f63 616c 0a09 0909 0909 7c7c 2069 .local......|| i │ │ │ +0003ec60: 7066 6163 652e 696e 7465 7266 6163 655f pface.interface_ │ │ │ +0003ec70: 6164 6472 6573 732e 6973 5f6c 6f6f 7062 address.is_loopb │ │ │ +0003ec80: 6163 6b28 290a 0909 0909 097c 7c20 6973 ack()......|| is │ │ │ +0003ec90: 5f6c 696e 6b5f 6c6f 6361 6c28 6970 6661 _link_local(ipfa │ │ │ +0003eca0: 6365 2e69 6e74 6572 6661 6365 5f61 6464 ce.interface_add │ │ │ +0003ecb0: 7265 7373 293b 0a3c 2f70 7265 3e3c 2f74 ress);.
    relevanc │ │ │ +0003ecf0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ +0003ed30: 5f69 6d70 6c2e 6370 703a 3233 3535 3c2f _impl.cpp:2355it wo │ │ │ +0003ed50: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ +0003ed60: 6265 7474 6572 2074 6f20 646f 2074 6869 better to do thi │ │ │ +0003ed70: 7320 6279 2068 6176 696e 6720 6120 6c69 s by having a li │ │ │ +0003ed80: 7374 656e 2d73 6f63 6b65 7420 2276 6572 sten-socket "ver │ │ │ +0003ed90: 7369 6f6e 2220 6e75 6d62 6572 2074 6861 sion" number tha │ │ │ +0003eda0: 7420 6765 7473 2062 756d 7065 642e 2041 t gets bumped. A │ │ │ +0003edb0: 6e64 2069 6e73 7465 6164 206f 6620 7365 nd instead of se │ │ │ +0003edc0: 7474 696e 6720 6120 626f 6f6c 2074 6f20 tting a bool to │ │ │ +0003edd0: 6469 7361 626c 6520 6120 7472 6163 6b65 disable a tracke │ │ │ +0003ede0: 722c 2077 6520 7365 7420 7468 6520 7665 r, we set the ve │ │ │ +0003edf0: 7273 696f 6e20 6e75 6d62 6572 2074 6861 rsion number tha │ │ │ +0003ee00: 7420 6974 2077 6173 2064 6973 6162 6c65 t it was disable │ │ │ +0003ee10: 6420 6174 2e20 5468 6973 2063 6861 6e67 d at. This chang │ │ │ +0003ee20: 6520 776f 756c 6420 6166 6665 6374 2074 e would affect t │ │ │ +0003ee30: 6865 2041 4249 2069 6e20 312e 322c 2073 he ABI in 1.2, s │ │ │ +0003ee40: 6f20 7368 6f75 6c64 2062 6520 646f 6e65 o should be done │ │ │ +0003ee50: 2069 6e20 322e 3020 6f72 206c 6174 6572 in 2.0 or later │ │ │ +0003ee60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ +0003eeb0: 2077 6f75 6c64 2070 726f 6261 626c 7920 would probably │ │ │ +0003eec0: 6265 2062 6574 7465 7220 746f 2064 6f20 be better to do │ │ │ +0003eed0: 7468 6973 2062 7920 6861 7669 6e67 2061 this by having a │ │ │ +0003eee0: 0a6c 6973 7465 6e2d 736f 636b 6574 2022 .listen-socket " │ │ │ +0003eef0: 7665 7273 696f 6e22 206e 756d 6265 7220 version" number │ │ │ +0003ef00: 7468 6174 2067 6574 7320 6275 6d70 6564 that gets bumped │ │ │ +0003ef10: 2e20 416e 6420 696e 7374 6561 6420 6f66 . And instead of │ │ │ +0003ef20: 0a73 6574 7469 6e67 2061 2062 6f6f 6c20 .setting a bool │ │ │ +0003ef30: 746f 2064 6973 6162 6c65 2061 2074 7261 to disable a tra │ │ │ +0003ef40: 636b 6572 2c20 7765 2073 6574 2074 6865 cker, we set the │ │ │ +0003ef50: 2076 6572 7369 6f6e 206e 756d 6265 7220 version number │ │ │ +0003ef60: 7468 6174 0a69 7420 7761 7320 6469 7361 that.it was disa │ │ │ +0003ef70: 626c 6564 2061 742e 2054 6869 7320 6368 bled at. This ch │ │ │ +0003ef80: 616e 6765 2077 6f75 6c64 2061 6666 6563 ange would affec │ │ │ +0003ef90: 7420 7468 6520 4142 4920 696e 2031 2e32 t the ABI in 1.2 │ │ │ +0003efa0: 2c20 736f 0a73 686f 756c 6420 6265 2064 , so.should be d │ │ │ +0003efb0: 6f6e 6520 696e 2032 2e30 206f 7220 6c61 one in 2.0 or la │ │ │ +0003efc0: 7465 723c 2f68 323e 3c68 343e 2e2e 2f73 ter

    ../s │ │ │ +0003efd0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +0003efe0: 6370 703a 3233 3535 3c2f 6834 3e3c 7072 cpp:2355

    ..{....fo │ │ │ +0003f030: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ +0003f040: 703b 2073 203a 206d 5f6c 6973 7465 6e5f p; s : m_listen_ │ │ │ +0003f050: 736f 636b 6574 7329 0a09 0909 0972 656d sockets).....rem │ │ │ +0003f060: 6170 5f70 6f72 7473 2872 656d 6170 5f6e ap_ports(remap_n │ │ │ +0003f070: 6174 706d 705f 616e 645f 7570 6e70 2c20 atpmp_and_upnp, │ │ │ +0003f080: 2a73 293b 0a09 097d 0a09 0965 6c73 650a *s);...}...else. │ │ │ +0003f090: 0909 7b0a 0909 092f 2f20 6e65 7720 736f ..{....// new so │ │ │ +0003f0a0: 636b 6574 7320 6e65 6564 2074 6f20 6d61 ckets need to ma │ │ │ +0003f0b0: 7020 706f 7274 7320 6576 656e 2069 6620 p ports even if │ │ │ +0003f0c0: 7468 6520 6361 6c6c 6572 2064 6964 206e the caller did n │ │ │ +0003f0d0: 6f74 2072 6571 7565 7374 0a09 0909 2f2f ot request....// │ │ │ +0003f0e0: 2072 652d 6d61 7070 696e 670a 0909 0966 re-mapping....f │ │ │ +0003f0f0: 6f72 2028 6175 746f 2063 6f6e 7374 2661 or (auto const&a │ │ │ +0003f100: 6d70 3b20 7320 3a20 6e65 775f 736f 636b mp; s : new_sock │ │ │ +0003f110: 6574 7329 0a09 0909 0972 656d 6170 5f70 ets).....remap_p │ │ │ +0003f120: 6f72 7473 2872 656d 6170 5f6e 6174 706d orts(remap_natpm │ │ │ +0003f130: 705f 616e 645f 7570 6e70 2c20 2a73 293b p_and_upnp, *s); │ │ │ +0003f140: 0a09 097d 0a0a 0909 7570 6461 7465 5f6c ...}....update_l │ │ │ +0003f150: 7364 2829 3b0a 0a23 6966 2054 4f52 5245 sd();..#if TORRE │ │ │ +0003f160: 4e54 5f55 5345 5f49 3250 0a09 096f 7065 NT_USE_I2P...ope │ │ │ +0003f170: 6e5f 6e65 775f 696e 636f 6d69 6e67 5f69 n_new_incoming_i │ │ │ +0003f180: 3270 5f63 6f6e 6e65 6374 696f 6e28 293b 2p_connection(); │ │ │ +0003f190: 0a23 656e 6469 660a 0a09 092f 2f20 7472 .#endif....// tr │ │ │ +0003f1a0: 6163 6b65 7273 2074 6861 7420 7765 7265 ackers that were │ │ │ +0003f1b0: 206e 6f74 2072 6561 6368 6162 6c65 2c20 not reachable, │ │ │ +0003f1c0: 6d61 7920 6861 7665 2062 6563 6f6d 6520 may have become │ │ │ +0003f1d0: 7265 6163 6861 626c 6520 6e6f 772e 0a09 reachable now... │ │ │ +0003f1e0: 092f 2f20 736f 2063 6c65 6172 2074 6865 .// so clear the │ │ │ +0003f1f0: 2022 6469 7361 626c 6564 2220 666c 6167 "disabled" flag │ │ │ +0003f200: 7320 746f 206c 6574 2074 6865 6d20 6265 s to let them be │ │ │ +0003f210: 2074 7269 6564 206f 6e65 206d 6f72 6520 tried one more │ │ │ +0003f220: 7469 6d65 0a3c 6469 7620 7374 796c 653d time.
    ..for (auto&a │ │ │ +0003f260: 6d70 3b20 7420 3a20 6d5f 746f 7272 656e mp; t : m_torren │ │ │ +0003f270: 7473 290a 3c2f 6469 763e 0909 0974 2d26 ts).
    ...t-& │ │ │ +0003f280: 6774 3b65 6e61 626c 655f 616c 6c5f 7472 gt;enable_all_tr │ │ │ +0003f290: 6163 6b65 7273 2829 3b0a 097d 0a0a 0976 ackers();..}...v │ │ │ +0003f2a0: 6f69 6420 7365 7373 696f 6e5f 696d 706c oid session_impl │ │ │ +0003f2b0: 3a3a 7265 6f70 656e 5f6e 6574 776f 726b ::reopen_network │ │ │ +0003f2c0: 5f73 6f63 6b65 7473 2872 656f 7065 6e5f _sockets(reopen_ │ │ │ +0003f2d0: 6e65 7477 6f72 6b5f 666c 6167 735f 7420 network_flags_t │ │ │ +0003f2e0: 636f 6e73 7420 6f70 7469 6f6e 7329 0a09 const options).. │ │ │ +0003f2f0: 7b0a 0909 7265 6f70 656e 5f6c 6973 7465 {...reopen_liste │ │ │ +0003f300: 6e5f 736f 636b 6574 7328 626f 6f6c 286f n_sockets(bool(o │ │ │ +0003f310: 7074 696f 6e73 2026 616d 703b 2073 6573 ptions & ses │ │ │ +0003f320: 7369 6f6e 5f68 616e 646c 653a 3a72 656f sion_handle::reo │ │ │ +0003f330: 7065 6e5f 6d61 705f 706f 7274 7329 293b pen_map_ports)); │ │ │ +0003f340: 0a09 7d0a 0a09 6e61 6d65 7370 6163 6520 ..}...namespace │ │ │ +0003f350: 7b0a 0909 7465 6d70 6c61 7465 2026 6c74 {...template < │ │ │ +0003f360: 3b74 7970 656e 616d 6520 4d61 7050 726f ;typename MapPro │ │ │ +0003f370: 746f 636f 6c2c 2074 7970 656e 616d 6520 tocol, typename │ │ │ +0003f380: 5072 6f74 6f54 7970 652c 2074 7970 656e ProtoType, typen │ │ │ +0003f390: 616d 6520 456e 6470 6f69 6e74 5479 7065 ame EndpointType │ │ │ +0003f3a0: 2667 743b 0a09 0976 6f69 6420 6d61 705f >...void map_ │ │ │ +0003f3b0: 706f 7274 284d 6170 5072 6f74 6f63 6f6c port(MapProtocol │ │ │ +0003f3c0: 2661 6d70 3b20 6d2c 2050 726f 746f 5479 & m, ProtoTy │ │ │ +0003f3d0: 7065 2070 726f 746f 636f 6c2c 2045 6e64 pe protocol, End │ │ │ +0003f3e0: 706f 696e 7454 7970 6520 636f 6e73 7426 pointType const& │ │ │ +0003f3f0: 616d 703b 2065 700a 0909 092c 2070 6f72 amp; ep...., por │ │ │ +0003f400: 745f 6d61 7070 696e 675f 7426 616d 703b t_mapping_t& │ │ │ +0003f410: 206d 6170 5f68 616e 646c 652c 2073 7464 map_handle, std │ │ │ +0003f420: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ +0003f430: 6d70 3b20 6465 7669 6365 290a 0909 7b0a mp; device)...{. │ │ │ +0003f440: 0909 0969 6620 286d 6170 5f68 616e 646c ...if (map_handl │ │ │ +0003f450: 6520 213d 2070 6f72 745f 6d61 7070 696e e != port_mappin │ │ │ +0003f460: 675f 747b 2d31 7d29 206d 2e64 656c 6574 g_t{-1}) m.delet │ │ │ +0003f470: 655f 6d61 7070 696e 6728 6d61 705f 6861 e_mapping(map_ha │ │ │ +0003f480: 6e64 6c65 293b 0a09 0909 6d61 705f 6861 ndle);....map_ha │ │ │ +0003f490: 6e64 6c65 203d 2070 6f72 745f 6d61 7070 ndle = port_mapp │ │ │ +0003f4a0: 696e 675f 747b 2d31 7d3b 0a0a 0909 0961 ing_t{-1};.....a │ │ │ +0003f4b0: 6464 7265 7373 2063 6f6e 7374 2061 6464 ddress const add │ │ │ +0003f4c0: 7220 3d20 6570 2e61 6464 7265 7373 2829 r = ep.address() │ │ │ +0003f4d0: 3b0a 0909 092f 2f20 7769 7468 2049 5076 ;....// with IPv │ │ │ +0003f4e0: 3420 7468 6520 696e 7465 7266 6163 6520 4 the interface │ │ │ +0003f4f0: 6d69 6768 7420 6265 2062 6568 696e 6420 might be behind │ │ │ +0003f500: 4e41 5420 736f 2077 6520 6361 6e27 7420 NAT so we can't │ │ │ +0003f510: 736b 6970 2074 6865 6d0a 0909 092f 2f20 skip them....// │ │ │ +0003f520: 6261 7365 6420 6f6e 2074 6865 2073 636f based on the sco │ │ │ +0003f530: 7065 206f 6620 7468 6520 6c6f 6361 6c20 pe of the local │ │ │ +0003f540: 6164 6472 6573 730a 0909 0969 6620 2861 address....if (a │ │ │ +0003f550: 6464 722e 6973 5f76 3628 2920 2661 6d70 ddr.is_v6() & │ │ │ +0003f560: 3b26 616d 703b 2069 735f 6c6f 6361 6c28 ;& is_local( │ │ │ +0003f570: 6164 6472 2929 0a09 0909 0972 6574 7572 addr)).....retur │ │ │ +0003f580: 6e3b 0a0a 0909 092f 2f20 6f6e 6c79 2075 n;.....// only u │ │ │ +0003f590: 7064 6174 6520 7468 6973 206d 6170 7069 pdate this mappi │ │ │ +0003f5a0: 6e67 2069 6620 7765 2061 6374 7561 6c6c ng if we actuall │ │ │ +0003f5b0: 7920 6861 7665 2061 2073 6f63 6b65 7420 y have a socket │ │ │ +0003f5c0: 6c69 7374 656e 696e 670a 0909 0969 6620 listening....if │ │ │ +0003f5d0: 2865 7020 213d 2045 6e64 706f 696e 7454 (ep != EndpointT │ │ │ +0003f5e0: 7970 6528 2929 0a09 0909 096d 6170 5f68 ype()).....map_h │ │ │ +0003f5f0: 616e 646c 6520 3d20 6d2e 6164 645f 6d61 andle = m.add_ma │ │ │ +0003f600: 7070 696e 6728 7072 6f74 6f63 6f6c 2c20 pping(protocol, │ │ │ +0003f610: 6570 2e70 6f72 7428 292c 2065 702c 2064 ep.port(), ep, d │ │ │ +0003f620: 6576 6963 6529 3b0a 0909 7d0a 097d 0a0a evice);...}..}.. │ │ │ +0003f630: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ +0003f640: 706c 3a3a 7265 6d61 705f 706f 7274 7328 pl::remap_ports( │ │ │ +0003f650: 7265 6d61 705f 706f 7274 5f6d 6173 6b5f remap_port_mask_ │ │ │ +0003f660: 7420 636f 6e73 7420 6d61 736b 0a09 092c t const mask..., │ │ │ +0003f670: 206c 6973 7465 6e5f 736f 636b 6574 5f74 listen_socket_t │ │ │ +0003f680: 2661 6d70 3b20 7329 0a3c 2f70 7265 3e3c & s).
    < │ │ │ +0003f690: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0003f6c0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0003f6d0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ +0003f700: 6f6e 5f69 6d70 6c2e 6370 703a 3239 3934 on_impl.cpp:2994 │ │ │ +0003f710: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ +0003f720: 7320 7369 7a65 206e 6565 6420 746f 2062 s size need to b │ │ │ +0003f730: 6520 6361 7070 6564 3c2f 7464 3e3c 2f74 e capped

    this size │ │ │ +0003f790: 6e65 6564 2074 6f20 6265 2063 6170 7065 need to be cappe │ │ │ +0003f7a0: 643c 2f68 323e 3c68 343e 2e2e 2f73 7263 d

    ../src │ │ │ +0003f7b0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +0003f7c0: 703a 3239 3934 3c2f 6834 3e3c 7072 6520 p:2994

    ....// hand
    │ │ │ +0003f810: 7368 616b 696e 670a 0909 0909 7265 7475  shaking.....retu
    │ │ │ +0003f820: 726e 2073 6f63 6b65 745f 7479 7065 2873  rn socket_type(s
    │ │ │ +0003f830: 736c 5f73 7472 6561 6d26 6c74 3b74 6370  sl_stream<tcp
    │ │ │ +0003f840: 3a3a 736f 636b 6574 2667 743b 2874 6370  ::socket>(tcp
    │ │ │ +0003f850: 3a3a 736f 636b 6574 2873 7464 3a3a 6d6f  ::socket(std::mo
    │ │ │ +0003f860: 7665 2873 2929 2c20 6d5f 7065 6572 5f73  ve(s)), m_peer_s
    │ │ │ +0003f870: 736c 5f63 7478 2929 3b0a 0909 097d 0a09  sl_ctx));....}..
    │ │ │ +0003f880: 0909 656c 7365 0a23 656e 6469 660a 0909  ..else.#endif...
    │ │ │ +0003f890: 097b 0a09 0909 0972 6574 7572 6e20 736f  .{.....return so
    │ │ │ +0003f8a0: 636b 6574 5f74 7970 6528 7463 703a 3a73  cket_type(tcp::s
    │ │ │ +0003f8b0: 6f63 6b65 7428 7374 643a 3a6d 6f76 6528  ocket(std::move(
    │ │ │ +0003f8c0: 7329 2929 3b0a 0909 097d 0a09 097d 2829  s)));....}...}()
    │ │ │ +0003f8d0: 3b0a 0a23 6966 6465 6620 544f 5252 454e  ;..#ifdef TORREN
    │ │ │ +0003f8e0: 545f 5353 4c5f 5045 4552 530a 0909 544f  T_SSL_PEERS...TO
    │ │ │ +0003f8f0: 5252 454e 545f 4153 5345 5254 2828 7373  RRENT_ASSERT((ss
    │ │ │ +0003f900: 6c20 3d3d 2074 7261 6e73 706f 7274 3a3a  l == transport::
    │ │ │ +0003f910: 7373 6c29 203d 3d20 6973 5f73 736c 2863  ssl) == is_ssl(c
    │ │ │ +0003f920: 2929 3b0a 2365 6e64 6966 0a0a 2369 6664  ));.#endif..#ifd
    │ │ │ +0003f930: 6566 2054 4f52 5245 4e54 5f53 534c 5f50  ef TORRENT_SSL_P
    │ │ │ +0003f940: 4545 5253 0a09 0969 6620 2873 736c 203d  EERS...if (ssl =
    │ │ │ +0003f950: 3d20 7472 616e 7370 6f72 743a 3a73 736c  = transport::ssl
    │ │ │ +0003f960: 290a 0909 7b0a 0909 0954 4f52 5245 4e54  )...{....TORRENT
    │ │ │ +0003f970: 5f41 5353 4552 5428 6973 5f73 736c 2863  _ASSERT(is_ssl(c
    │ │ │ +0003f980: 2929 3b0a 0a09 0909 2f2f 2073 6176 6520  ));.....// save 
    │ │ │ +0003f990: 7468 6520 736f 636b 6574 2073 6f20 7765  the socket so we
    │ │ │ +0003f9a0: 2063 616e 2063 616e 6365 6c20 7468 6520   can cancel the 
    │ │ │ +0003f9b0: 6861 6e64 7368 616b 650a 3c64 6976 2073  handshake.
    ...auto │ │ │ +0003f9f0: 6974 6572 203d 206d 5f69 6e63 6f6d 696e iter = m_incomin │ │ │ +0003fa00: 675f 736f 636b 6574 732e 656d 706c 6163 g_sockets.emplac │ │ │ +0003fa10: 6528 7374 643a 3a6d 616b 655f 756e 6971 e(std::make_uniq │ │ │ +0003fa20: 7565 266c 743b 736f 636b 6574 5f74 7970 ue<socket_typ │ │ │ +0003fa30: 6526 6774 3b28 7374 643a 3a6d 6f76 6528 e>(std::move( │ │ │ +0003fa40: 6329 2929 2e66 6972 7374 3b0a 3c2f 6469 c))).first;.....auto sock │ │ │ +0003fa60: 3d20 6974 6572 2d26 6774 3b67 6574 2829 = iter->get() │ │ │ +0003fa70: 3b0a 0909 092f 2f20 666f 7220 5353 4c20 ;....// for SSL │ │ │ +0003fa80: 636f 6e6e 6563 7469 6f6e 732c 2069 6e63 connections, inc │ │ │ +0003fa90: 6f6d 696e 675f 636f 6e6e 6563 7469 6f6e oming_connection │ │ │ +0003faa0: 2829 2069 7320 6361 6c6c 6564 0a09 0909 () is called.... │ │ │ +0003fab0: 2f2f 2061 6674 6572 2074 6865 2068 616e // after the han │ │ │ +0003fac0: 6473 6861 6b65 2069 7320 646f 6e65 0a09 dshake is done.. │ │ │ +0003fad0: 0909 4144 445f 4f55 5453 5441 4e44 494e ..ADD_OUTSTANDIN │ │ │ +0003fae0: 475f 4153 594e 4328 2273 6573 7369 6f6e G_ASYNC("session │ │ │ +0003faf0: 5f69 6d70 6c3a 3a73 736c 5f68 616e 6473 _impl::ssl_hands │ │ │ +0003fb00: 6861 6b65 2229 3b0a 0909 0973 7464 3a3a hake");....std:: │ │ │ +0003fb10: 6765 7426 6c74 3b73 736c 5f73 7472 6561 get<ssl_strea │ │ │ +0003fb20: 6d26 6c74 3b74 6370 3a3a 736f 636b 6574 m<tcp::socket │ │ │ +0003fb30: 2667 743b 2667 743b 282a 2a69 7465 7229 >>(**iter) │ │ │ +0003fb40: 2e61 7379 6e63 5f61 6363 6570 745f 6861 .async_accept_ha │ │ │ +0003fb50: 6e64 7368 616b 6528 0a09 0909 095b 7468 ndshake(.....[th │ │ │ +0003fb60: 6973 2c20 736f 636b 5d20 2865 7272 6f72 is, sock] (error │ │ │ +0003fb70: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ +0003fb80: 2065 7272 2920 7b20 7373 6c5f 6861 6e64 err) { ssl_hand │ │ │ +0003fb90: 7368 616b 6528 6572 722c 2073 6f63 6b29 shake(err, sock) │ │ │ +0003fba0: 3b20 7d29 3b0a 0909 7d0a 0909 656c 7365 ; });...}...else │ │ │ +0003fbb0: 0a23 656e 6469 660a 0909 7b0a 0909 0969 .#endif...{....i │ │ │ +0003fbc0: 6e63 6f6d 696e 675f 636f 6e6e 6563 7469 ncoming_connecti │ │ │ +0003fbd0: 6f6e 2873 7464 3a3a 6d6f 7665 2863 2929 on(std::move(c)) │ │ │ +0003fbe0: 3b0a 0909 7d0a 097d 0a0a 2369 6664 6566 ;...}..}..#ifdef │ │ │ +0003fbf0: 2054 4f52 5245 4e54 5f53 534c 5f50 4545 TORRENT_SSL_PEE │ │ │ +0003fc00: 5253 0a0a 0976 6f69 6420 7365 7373 696f RS...void sessio │ │ │ +0003fc10: 6e5f 696d 706c 3a3a 6f6e 5f69 6e63 6f6d n_impl::on_incom │ │ │ +0003fc20: 696e 675f 7574 705f 7373 6c28 736f 636b ing_utp_ssl(sock │ │ │ +0003fc30: 6574 5f74 7970 6520 7329 0a09 7b0a 0909 et_type s)..{... │ │ │ +0003fc40: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +0003fc50: 735f 7373 6c28 7329 293b 0a0a 0909 2f2f s_ssl(s));....// │ │ │ +0003fc60: 2073 6176 6520 7468 6520 736f 636b 6574 save the socket │ │ │ +0003fc70: 2073 6f20 7765 2063 616e 2063 616e 6365 so we can cance │ │ │ +0003fc80: 6c20 7468 6520 6861 6e64 7368 616b 650a l the handshake. │ │ │ +0003fc90: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0003fcd0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0003fd00: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +0003fd10: 6370 703a 3330 3139 3c2f 613e 3c2f 7464 cpp:3019this size n │ │ │ +0003fd30: 6565 6420 746f 2062 6520 6361 7070 6564 eed to be capped │ │ │ +0003fd40: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ +0003fd90: 6973 2073 697a 6520 6e65 6564 2074 6f20 is size need to │ │ │ +0003fda0: 6265 2063 6170 7065 643c 2f68 323e 3c68 be capped

    ../src/session │ │ │ +0003fdc0: 5f69 6d70 6c2e 6370 703a 3330 3139 3c2f _impl.cpp:3019
    ...
    │ │ │ +0003fe10: 2f2f 2061 6674 6572 2074 6865 2068 616e  // after the han
    │ │ │ +0003fe20: 6473 6861 6b65 2069 7320 646f 6e65 0a09  dshake is done..
    │ │ │ +0003fe30: 0909 4144 445f 4f55 5453 5441 4e44 494e  ..ADD_OUTSTANDIN
    │ │ │ +0003fe40: 475f 4153 594e 4328 2273 6573 7369 6f6e  G_ASYNC("session
    │ │ │ +0003fe50: 5f69 6d70 6c3a 3a73 736c 5f68 616e 6473  _impl::ssl_hands
    │ │ │ +0003fe60: 6861 6b65 2229 3b0a 0909 0973 7464 3a3a  hake");....std::
    │ │ │ +0003fe70: 6765 7426 6c74 3b73 736c 5f73 7472 6561  get<ssl_strea
    │ │ │ +0003fe80: 6d26 6c74 3b74 6370 3a3a 736f 636b 6574  m<tcp::socket
    │ │ │ +0003fe90: 2667 743b 2667 743b 282a 2a69 7465 7229  >>(**iter)
    │ │ │ +0003fea0: 2e61 7379 6e63 5f61 6363 6570 745f 6861  .async_accept_ha
    │ │ │ +0003feb0: 6e64 7368 616b 6528 0a09 0909 095b 7468  ndshake(.....[th
    │ │ │ +0003fec0: 6973 2c20 736f 636b 5d20 2865 7272 6f72  is, sock] (error
    │ │ │ +0003fed0: 5f63 6f64 6520 636f 6e73 7426 616d 703b  _code const&
    │ │ │ +0003fee0: 2065 7272 2920 7b20 7373 6c5f 6861 6e64   err) { ssl_hand
    │ │ │ +0003fef0: 7368 616b 6528 6572 722c 2073 6f63 6b29  shake(err, sock)
    │ │ │ +0003ff00: 3b20 7d29 3b0a 0909 7d0a 0909 656c 7365  ; });...}...else
    │ │ │ +0003ff10: 0a23 656e 6469 660a 0909 7b0a 0909 0969  .#endif...{....i
    │ │ │ +0003ff20: 6e63 6f6d 696e 675f 636f 6e6e 6563 7469  ncoming_connecti
    │ │ │ +0003ff30: 6f6e 2873 7464 3a3a 6d6f 7665 2863 2929  on(std::move(c))
    │ │ │ +0003ff40: 3b0a 0909 7d0a 097d 0a0a 2369 6664 6566  ;...}..}..#ifdef
    │ │ │ +0003ff50: 2054 4f52 5245 4e54 5f53 534c 5f50 4545   TORRENT_SSL_PEE
    │ │ │ +0003ff60: 5253 0a0a 0976 6f69 6420 7365 7373 696f  RS...void sessio
    │ │ │ +0003ff70: 6e5f 696d 706c 3a3a 6f6e 5f69 6e63 6f6d  n_impl::on_incom
    │ │ │ +0003ff80: 696e 675f 7574 705f 7373 6c28 736f 636b  ing_utp_ssl(sock
    │ │ │ +0003ff90: 6574 5f74 7970 6520 7329 0a09 7b0a 0909  et_type s)..{...
    │ │ │ +0003ffa0: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ +0003ffb0: 735f 7373 6c28 7329 293b 0a0a 0909 2f2f  s_ssl(s));....//
    │ │ │ +0003ffc0: 2073 6176 6520 7468 6520 736f 636b 6574   save the socket
    │ │ │ +0003ffd0: 2073 6f20 7765 2063 616e 2063 616e 6365   so we can cance
    │ │ │ +0003ffe0: 6c20 7468 6520 6861 6e64 7368 616b 650a  l the handshake.
    │ │ │ +0003fff0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00040020: 0961 7574 6f20 6974 6572 203d 206d 5f69 .auto iter = m_i │ │ │ +00040030: 6e63 6f6d 696e 675f 736f 636b 6574 732e ncoming_sockets. │ │ │ +00040040: 656d 706c 6163 6528 7374 643a 3a6d 616b emplace(std::mak │ │ │ +00040050: 655f 756e 6971 7565 266c 743b 736f 636b e_unique<sock │ │ │ +00040060: 6574 5f74 7970 6526 6774 3b28 7374 643a et_type>(std: │ │ │ +00040070: 3a6d 6f76 6528 7329 2929 2e66 6972 7374 :move(s))).first │ │ │ +00040080: 3b0a 3c2f 6469 763e 0909 6175 746f 2073 ;.
    ..auto s │ │ │ +00040090: 6f63 6b20 3d20 6974 6572 2d26 6774 3b67 ock = iter->g │ │ │ +000400a0: 6574 2829 3b0a 0a09 092f 2f20 666f 7220 et();....// for │ │ │ +000400b0: 5353 4c20 636f 6e6e 6563 7469 6f6e 732c SSL connections, │ │ │ +000400c0: 2069 6e63 6f6d 696e 675f 636f 6e6e 6563 incoming_connec │ │ │ +000400d0: 7469 6f6e 2829 2069 7320 6361 6c6c 6564 tion() is called │ │ │ +000400e0: 0a09 092f 2f20 6166 7465 7220 7468 6520 ...// after the │ │ │ +000400f0: 6861 6e64 7368 616b 6520 6973 2064 6f6e handshake is don │ │ │ +00040100: 650a 0909 4144 445f 4f55 5453 5441 4e44 e...ADD_OUTSTAND │ │ │ +00040110: 494e 475f 4153 594e 4328 2273 6573 7369 ING_ASYNC("sessi │ │ │ +00040120: 6f6e 5f69 6d70 6c3a 3a73 736c 5f68 616e on_impl::ssl_han │ │ │ +00040130: 6473 6861 6b65 2229 3b0a 0909 7374 643a dshake");...std: │ │ │ +00040140: 3a67 6574 266c 743b 7373 6c5f 7374 7265 :get<ssl_stre │ │ │ +00040150: 616d 266c 743b 7574 705f 7374 7265 616d am<utp_stream │ │ │ +00040160: 2667 743b 2667 743b 282a 2a69 7465 7229 >>(**iter) │ │ │ +00040170: 2e61 7379 6e63 5f61 6363 6570 745f 6861 .async_accept_ha │ │ │ +00040180: 6e64 7368 616b 6528 0a09 0909 5b74 6869 ndshake(....[thi │ │ │ +00040190: 732c 2073 6f63 6b5d 2028 6572 726f 725f s, sock] (error_ │ │ │ +000401a0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20 code const& │ │ │ +000401b0: 6572 7229 207b 2073 736c 5f68 616e 6473 err) { ssl_hands │ │ │ +000401c0: 6861 6b65 2865 7272 2c20 736f 636b 293b hake(err, sock); │ │ │ +000401d0: 207d 293b 0a09 7d0a 0a09 2f2f 2074 6f20 });..}...// to │ │ │ +000401e0: 7465 7374 2053 534c 2063 6f6e 6e65 6374 test SSL connect │ │ │ +000401f0: 696f 6e73 2c20 6f6e 6520 6361 6e20 7573 ions, one can us │ │ │ +00040200: 6520 7468 6973 206f 7065 6e73 736c 2063 e this openssl c │ │ │ +00040210: 6f6d 6d61 6e64 2074 656d 706c 6174 653a ommand template: │ │ │ +00040220: 0a09 2f2f 0a09 2f2f 206f 7065 6e73 736c ..//..// openssl │ │ │ +00040230: 2073 5f63 6c69 656e 7420 2d63 6572 7420 s_client -cert │ │ │ +00040240: 266c 743b 636c 6965 6e74 2d63 6572 7426 <client-cert& │ │ │ +00040250: 6774 3b2e 7065 6d20 2d6b 6579 2026 6c74 gt;.pem -key < │ │ │ +00040260: 3b63 6c69 656e 742d 7072 6976 6174 652d ;client-private- │ │ │ +00040270: 6b65 7926 6774 3b2e 7065 6d0a 092f 2f20 key>.pem..// │ │ │ +00040280: 2020 2d43 4166 696c 6520 266c 743b 746f -CAfile <to │ │ │ +00040290: 7272 656e 742d 6365 7274 2667 743b 2e70 rrent-cert>.p │ │ │ +000402a0: 656d 2020 2d64 6562 7567 202d 636f 6e6e em -debug -conn │ │ │ +000402b0: 6563 7420 3132 372e 302e 302e 313a 3434 ect 127.0.0.1:44 │ │ │ +000402c0: 3333 202d 746c 7331 0a09 2f2f 2020 202d 33 -tls1..// - │ │ │ +000402d0: 7365 7276 6572 6e61 6d65 2026 6c74 3b68 servername <h │ │ │ +000402e0: 6578 2d65 6e63 6f64 6564 2d69 6e66 6f2d ex-encoded-info- │ │ │ +000402f0: 6861 7368 2667 743b 0a0a 0976 6f69 6420 hash>...void │ │ │ +00040300: 7365 7373 696f 6e5f 696d 706c 3a3a 7373 session_impl::ss │ │ │ +00040310: 6c5f 6861 6e64 7368 616b 6528 6572 726f l_handshake(erro │ │ │ +00040320: 725f 636f 6465 2063 6f6e 7374 2661 6d70 r_code const& │ │ │ +00040330: 3b20 6563 2c20 736f 636b 6574 5f74 7970 ; ec, socket_typ │ │ │ +00040340: 652a 2073 6f63 6b29 0a09 7b0a 0909 434f e* sock)..{...CO │ │ │ +00040350: 4d50 4c45 5445 5f41 5359 4e43 2822 7365 MPLETE_ASYNC("se │ │ │ +00040360: 7373 696f 6e5f 696d 706c 3a3a 7373 6c5f ssion_impl::ssl_ │ │ │ +00040370: 6861 6e64 7368 616b 6522 293b 0a0a 0909 handshake");.... │ │ │ +00040380: 6175 746f 2069 7465 7220 3d20 6d5f 696e auto iter = m_in │ │ │ +00040390: 636f 6d69 6e67 5f73 6f63 6b65 7473 2e66 coming_sockets.f │ │ │ +000403a0: 696e 6428 736f 636b 293b 0a0a 0909 2f2f ind(sock);....// │ │ │ +000403b0: 2074 6869 7320 6861 7070 656e 7320 6966 this happens if │ │ │ +000403c0: 2074 6865 2053 534c 2063 6f6e 6e65 6374 the SSL connect │ │ │ +000403d0: 696f 6e20 6973 2061 626f 7274 6564 2062 ion is aborted b │ │ │ +000403e0: 6563 6175 7365 2077 6527 7265 2073 6875 ecause we're shu │ │ │ +000403f0: 7474 696e 670a 0909 2f2f 2064 6f77 6e0a tting...// down. │ │ │ +00040400: 0909 6966 2028 6974 6572 203d 3d20 6d5f ..if (iter == m_ │ │ │ +00040410: 696e 636f 6d69 6e67 5f73 6f63 6b65 7473 incoming_sockets │ │ │ +00040420: 2e65 6e64 2829 2920 7265 7475 726e 3b0a .end()) return;. │ │ │ +00040430: 0a09 0973 6f63 6b65 745f 7479 7065 2073 ...socket_type s │ │ │ +00040440: 2873 7464 3a3a 6d6f 7665 282a 2a69 7465 (std::move(**ite │ │ │ +00040450: 7229 293b 0a09 0954 4f52 5245 4e54 5f41 r));...TORRENT_A │ │ │ +00040460: 5353 4552 5428 6973 5f73 736c 2873 2929 SSERT(is_ssl(s)) │ │ │ +00040470: 3b0a 0909 6d5f 696e 636f 6d69 6e67 5f73 ;...m_incoming_s │ │ │ +00040480: 6f63 6b65 7473 2e65 7261 7365 2869 7465 ockets.erase(ite │ │ │ +00040490: 7229 3b0a 0a09 0965 7272 6f72 5f63 6f64 r);....error_cod │ │ │ +000404a0: 6520 653b 0a3c 2f70 7265 3e3c 2f74 643e e e;.
    │ │ │ +000404b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +000404e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +000404f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00040500: 7074 3a65 7870 616e 6428 3135 3929 223e pt:expand(159)"> │ │ │ +00040510: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +00040520: 6d70 6c2e 6370 703a 3337 3331 3c2f 613e mpl.cpp:3731 │ │ │ +00040530: 3c2f 7464 3e3c 7464 3e68 6176 6520 6120 have a │ │ │ +00040540: 7365 7061 7261 7465 206c 6973 7420 666f separate list fo │ │ │ +00040550: 7220 7468 6573 6520 636f 6e6e 6563 7469 r these connecti │ │ │ +00040560: 6f6e 732c 2069 6e73 7465 6164 206f 6620 ons, instead of │ │ │ +00040570: 6861 7669 6e67 2074 6f20 6c6f 6f70 2074 having to loop t │ │ │ +00040580: 6872 6f75 6768 2061 6c6c 206f 6620 7468 hrough all of th │ │ │ +00040590: 656d 3c2f 7464 3e3c 2f74 723e 3c74 7220 em

    │ │ │ +000405e0: 6861 7665 2061 2073 6570 6172 6174 6520 have a separate │ │ │ +000405f0: 6c69 7374 2066 6f72 2074 6865 7365 2063 list for these c │ │ │ +00040600: 6f6e 6e65 6374 696f 6e73 2c20 696e 7374 onnections, inst │ │ │ +00040610: 6561 6420 6f66 2068 6176 696e 6720 746f ead of having to │ │ │ +00040620: 206c 6f6f 7020 7468 726f 7567 6820 616c loop through al │ │ │ +00040630: 6c20 6f66 2074 6865 6d3c 2f68 323e 3c68 l of them

    ../src/session │ │ │ +00040650: 5f69 6d70 6c2e 6370 703a 3337 3331 3c2f _impl.cpp:3731
    ../
    │ │ │ +000406a0: 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  / --------------
    │ │ │ +000406b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000406c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000406d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000406e0: 0a09 0969 6620 2821 6d5f 7061 7573 6564  ...if (!m_paused
    │ │ │ +000406f0: 2920 6d5f 6175 746f 5f6d 616e 6167 655f  ) m_auto_manage_
    │ │ │ +00040700: 7469 6d65 5f73 6361 6c65 722d 2d3b 0a09  time_scaler--;..
    │ │ │ +00040710: 0969 6620 286d 5f61 7574 6f5f 6d61 6e61  .if (m_auto_mana
    │ │ │ +00040720: 6765 5f74 696d 655f 7363 616c 6572 2026  ge_time_scaler &
    │ │ │ +00040730: 6c74 3b20 3029 0a09 097b 0a09 0909 6d5f  lt; 0)...{....m_
    │ │ │ +00040740: 6175 746f 5f6d 616e 6167 655f 7469 6d65  auto_manage_time
    │ │ │ +00040750: 5f73 6361 6c65 7220 3d20 7365 7474 696e  _scaler = settin
    │ │ │ +00040760: 6773 2829 2e67 6574 5f69 6e74 2873 6574  gs().get_int(set
    │ │ │ +00040770: 7469 6e67 735f 7061 636b 3a3a 6175 746f  tings_pack::auto
    │ │ │ +00040780: 5f6d 616e 6167 655f 696e 7465 7276 616c  _manage_interval
    │ │ │ +00040790: 293b 0a09 0909 7265 6361 6c63 756c 6174  );....recalculat
    │ │ │ +000407a0: 655f 6175 746f 5f6d 616e 6167 6564 5f74  e_auto_managed_t
    │ │ │ +000407b0: 6f72 7265 6e74 7328 293b 0a09 097d 0a0a  orrents();...}..
    │ │ │ +000407c0: 0909 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d  ..// -----------
    │ │ │ +000407d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040800: 2d2d 2d0a 0909 2f2f 2063 6865 636b 2066  ---...// check f
    │ │ │ +00040810: 6f72 2069 6e63 6f6d 696e 6720 636f 6e6e  or incoming conn
    │ │ │ +00040820: 6563 7469 6f6e 7320 7468 6174 206d 6967  ections that mig
    │ │ │ +00040830: 6874 2068 6176 6520 7469 6d65 6420 6f75  ht have timed ou
    │ │ │ +00040840: 740a 0909 2f2f 202d 2d2d 2d2d 2d2d 2d2d  t...// ---------
    │ │ │ +00040850: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040860: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040870: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040880: 2d2d 2d2d 2d0a 0a09 0966 6f72 2028 6175  -----....for (au
    │ │ │ +00040890: 746f 2069 203d 206d 5f63 6f6e 6e65 6374  to i = m_connect
    │ │ │ +000408a0: 696f 6e73 2e62 6567 696e 2829 3b20 6920  ions.begin(); i 
    │ │ │ +000408b0: 213d 206d 5f63 6f6e 6e65 6374 696f 6e73  != m_connections
    │ │ │ +000408c0: 2e65 6e64 2829 3b29 0a09 097b 0a09 0909  .end();)...{....
    │ │ │ +000408d0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2a  peer_connection*
    │ │ │ +000408e0: 2070 203d 2028 2a69 292e 6765 7428 293b   p = (*i).get();
    │ │ │ +000408f0: 0a09 0909 2b2b 693b 0a09 0909 2f2f 2069  ....++i;....// i
    │ │ │ +00040900: 676e 6f72 6520 636f 6e6e 6563 7469 6f6e  gnore connection
    │ │ │ +00040910: 7320 7468 6174 2061 6c72 6561 6479 2068  s that already h
    │ │ │ +00040920: 6176 6520 6120 746f 7272 656e 742c 2073  ave a torrent, s
    │ │ │ +00040930: 696e 6365 2074 6865 790a 0909 092f 2f20  ince they....// 
    │ │ │ +00040940: 6172 6520 7469 636b 6564 2074 6872 6f75  are ticked throu
    │ │ │ +00040950: 6768 2074 6865 2074 6f72 7265 6e74 7327  gh the torrents'
    │ │ │ +00040960: 2073 6563 6f6e 645f 7469 636b 0a09 0909   second_tick....
    │ │ │ +00040970: 6966 2028 2170 2d26 6774 3b61 7373 6f63  if (!p->assoc
    │ │ │ +00040980: 6961 7465 645f 746f 7272 656e 7428 292e  iated_torrent().
    │ │ │ +00040990: 6578 7069 7265 6428 2929 2063 6f6e 7469  expired()) conti
    │ │ │ +000409a0: 6e75 653b 0a0a 3c64 6976 2073 7479 6c65  nue;..
    ...int timeo │ │ │ +000409e0: 7574 203d 206d 5f73 6574 7469 6e67 732e ut = m_settings. │ │ │ +000409f0: 6765 745f 696e 7428 7365 7474 696e 6773 get_int(settings │ │ │ +00040a00: 5f70 6163 6b3a 3a68 616e 6473 6861 6b65 _pack::handshake │ │ │ +00040a10: 5f74 696d 656f 7574 293b 0a3c 2f64 6976 _timeout);.
    #if TORRENT_USE │ │ │ +00040a30: 5f49 3250 0a09 0909 7469 6d65 6f75 7420 _I2P....timeout │ │ │ +00040a40: 2a3d 2069 735f 6932 7028 702d 2667 743b *= is_i2p(p-> │ │ │ +00040a50: 6765 745f 736f 636b 6574 2829 2920 3f20 get_socket()) ? │ │ │ +00040a60: 3420 3a20 313b 0a23 656e 6469 660a 0909 4 : 1;.#endif... │ │ │ +00040a70: 0969 6620 286d 5f6c 6173 745f 7469 636b .if (m_last_tick │ │ │ +00040a80: 202d 2070 2d26 6774 3b63 6f6e 6e65 6374 - p->connect │ │ │ +00040a90: 6564 5f74 696d 6520 2829 2026 6774 3b20 ed_time () > │ │ │ +00040aa0: 7365 636f 6e64 7328 7469 6d65 6f75 7429 seconds(timeout) │ │ │ +00040ab0: 290a 0909 0909 702d 2667 743b 6469 7363 ).....p->disc │ │ │ +00040ac0: 6f6e 6e65 6374 2865 7272 6f72 733a 3a74 onnect(errors::t │ │ │ +00040ad0: 696d 6564 5f6f 7574 2c20 6f70 6572 6174 imed_out, operat │ │ │ +00040ae0: 696f 6e5f 743a 3a62 6974 746f 7272 656e ion_t::bittorren │ │ │ +00040af0: 7429 3b0a 0909 7d0a 0a09 092f 2f20 2d2d t);...}....// -- │ │ │ +00040b00: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040b10: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040b20: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040b30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 092f ------------.../ │ │ │ +00040b40: 2f20 7365 636f 6e64 5f74 6963 6b20 6576 / second_tick ev │ │ │ +00040b50: 6572 7920 746f 7272 656e 7420 2874 6861 ery torrent (tha │ │ │ +00040b60: 7420 7761 6e74 7320 6974 290a 0909 2f2f t wants it)...// │ │ │ +00040b70: 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d --------------- │ │ │ +00040b80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040b90: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040ba0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a ---------------. │ │ │ +00040bb0: 0a23 6966 2054 4f52 5245 4e54 5f44 4542 .#if TORRENT_DEB │ │ │ +00040bc0: 5547 5f53 5452 4541 4d49 4e47 2026 6774 UG_STREAMING > │ │ │ +00040bd0: 3b20 300a 0909 7374 643a 3a70 7269 6e74 ; 0...std::print │ │ │ +00040be0: 6628 225c 3033 335b 324a 5c30 3333 5b30 f("\033[2J\033[0 │ │ │ +00040bf0: 3b30 4822 293b 0a23 656e 6469 660a 0a09 ;0H");.#endif... │ │ │ +00040c00: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ +00040c10: 746f 7272 656e 742a 2667 743b 2661 6d70 torrent*>& │ │ │ +00040c20: 3b20 7761 6e74 5f74 6963 6b20 3d20 6d5f ; want_tick = m_ │ │ │ +00040c30: 746f 7272 656e 745f 6c69 7374 735b 746f torrent_lists[to │ │ │ +00040c40: 7272 656e 745f 7761 6e74 5f74 6963 6b5d rrent_want_tick] │ │ │ +00040c50: 3b0a 0909 666f 7220 2869 6e74 2069 203d ;...for (int i = │ │ │ +00040c60: 2030 3b20 6920 266c 743b 2069 6e74 2877 0; i < int(w │ │ │ +00040c70: 616e 745f 7469 636b 2e73 697a 6528 2929 ant_tick.size()) │ │ │ +00040c80: 3b20 2b2b 6929 0a09 097b 0a09 0909 746f ; ++i)...{....to │ │ │ +00040c90: 7272 656e 7426 616d 703b 2074 203d 202a rrent& t = * │ │ │ +00040ca0: 7761 6e74 5f74 6963 6b5b 695d 3b0a 0909 want_tick[i];... │ │ │ +00040cb0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00040cc0: 742e 7761 6e74 5f74 6963 6b28 2929 3b0a t.want_tick());. │ │ │ +00040cd0: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00040ce0: 5428 2174 2e69 735f 6162 6f72 7465 6428 T(!t.is_aborted( │ │ │ +00040cf0: 2929 3b0a 0a09 0909 742e 7365 636f 6e64 ));.....t.second │ │ │ +00040d00: 5f74 6963 6b28 7469 636b 5f69 6e74 6572 _tick(tick_inter │ │ │ +00040d10: 7661 6c5f 6d73 293b 0a0a 0909 092f 2f20 val_ms);.....// │ │ │ +00040d20: 6966 2074 6865 2063 616c 6c20 746f 2073 if the call to s │ │ │ +00040d30: 6563 6f6e 645f 7469 636b 2063 6175 7365 econd_tick cause │ │ │ +00040d40: 6420 7468 6520 746f 7272 656e 740a 0909 d the torrent... │ │ │ +00040d50: 092f 2f20 746f 206e 6f20 6c6f 6e67 6572 .// to no longer │ │ │ +00040d60: 2077 616e 7420 746f 2062 6520 7469 636b want to be tick │ │ │ +00040d70: 6564 2028 692e 652e 2069 7420 7761 730a ed (i.e. it was. │ │ │ +00040d80: 0909 092f 2f20 7265 6d6f 7665 6420 6672 ...// removed fr │ │ │ +00040d90: 6f6d 2074 6865 206c 6973 7429 2077 6520 om the list) we │ │ │ +00040da0: 6e65 6564 2074 6f20 6261 636b 2075 7020 need to back up │ │ │ +00040db0: 7468 6520 636f 756e 7465 720a 0909 092f the counter..../ │ │ │ +00040dc0: 2f20 746f 206e 6f74 206d 6973 7320 7468 / to not miss th │ │ │ +00040dd0: 6520 746f 7272 656e 7420 6166 7465 7220 e torrent after │ │ │ +00040de0: 6974 0a09 0909 6966 2028 2174 2e77 616e it....if (!t.wan │ │ │ +00040df0: 745f 7469 636b 2829 2920 2d2d 693b 0a09 t_tick()) --i;.. │ │ │ +00040e00: 097d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .}.
    │ │ │ +00040e30: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00040e40: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00040e70: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +00040e80: 6c2e 6370 703a 3337 3634 3c2f 613e 3c2f l.cpp:3764this shou │ │ │ +00040ea0: 6c64 2061 7070 6c79 2074 6f20 616c 6c20 ld apply to all │ │ │ +00040eb0: 6261 6e64 7769 6474 6820 6368 616e 6e65 bandwidth channe │ │ │ +00040ec0: 6c73 3c2f 7464 3e3c 2f74 723e 3c74 7220 ls

    │ │ │ +00040f10: 7468 6973 2073 686f 756c 6420 6170 706c this should appl │ │ │ +00040f20: 7920 746f 2061 6c6c 2062 616e 6477 6964 y to all bandwid │ │ │ +00040f30: 7468 2063 6861 6e6e 656c 733c 2f68 323e th channels

    │ │ │ +00040f40: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ +00040f50: 6f6e 5f69 6d70 6c2e 6370 703a 3337 3634 on_impl.cpp:3764 │ │ │ +00040f60: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +00040fa0: 6966 2054 4f52 5245 4e54 5f44 4542 5547  if TORRENT_DEBUG
    │ │ │ +00040fb0: 5f53 5452 4541 4d49 4e47 2026 6774 3b20  _STREAMING > 
    │ │ │ +00040fc0: 300a 0909 7374 643a 3a70 7269 6e74 6628  0...std::printf(
    │ │ │ +00040fd0: 225c 3033 335b 324a 5c30 3333 5b30 3b30  "\033[2J\033[0;0
    │ │ │ +00040fe0: 4822 293b 0a23 656e 6469 660a 0a09 0961  H");.#endif....a
    │ │ │ +00040ff0: 7578 3a3a 7665 6374 6f72 266c 743b 746f  ux::vector<to
    │ │ │ +00041000: 7272 656e 742a 2667 743b 2661 6d70 3b20  rrent*>& 
    │ │ │ +00041010: 7761 6e74 5f74 6963 6b20 3d20 6d5f 746f  want_tick = m_to
    │ │ │ +00041020: 7272 656e 745f 6c69 7374 735b 746f 7272  rrent_lists[torr
    │ │ │ +00041030: 656e 745f 7761 6e74 5f74 6963 6b5d 3b0a  ent_want_tick];.
    │ │ │ +00041040: 0909 666f 7220 2869 6e74 2069 203d 2030  ..for (int i = 0
    │ │ │ +00041050: 3b20 6920 266c 743b 2069 6e74 2877 616e  ; i < int(wan
    │ │ │ +00041060: 745f 7469 636b 2e73 697a 6528 2929 3b20  t_tick.size()); 
    │ │ │ +00041070: 2b2b 6929 0a09 097b 0a09 0909 746f 7272  ++i)...{....torr
    │ │ │ +00041080: 656e 7426 616d 703b 2074 203d 202a 7761  ent& t = *wa
    │ │ │ +00041090: 6e74 5f74 6963 6b5b 695d 3b0a 0909 0954  nt_tick[i];....T
    │ │ │ +000410a0: 4f52 5245 4e54 5f41 5353 4552 5428 742e  ORRENT_ASSERT(t.
    │ │ │ +000410b0: 7761 6e74 5f74 6963 6b28 2929 3b0a 0909  want_tick());...
    │ │ │ +000410c0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +000410d0: 2174 2e69 735f 6162 6f72 7465 6428 2929  !t.is_aborted())
    │ │ │ +000410e0: 3b0a 0a09 0909 742e 7365 636f 6e64 5f74  ;.....t.second_t
    │ │ │ +000410f0: 6963 6b28 7469 636b 5f69 6e74 6572 7661  ick(tick_interva
    │ │ │ +00041100: 6c5f 6d73 293b 0a0a 0909 092f 2f20 6966  l_ms);.....// if
    │ │ │ +00041110: 2074 6865 2063 616c 6c20 746f 2073 6563   the call to sec
    │ │ │ +00041120: 6f6e 645f 7469 636b 2063 6175 7365 6420  ond_tick caused 
    │ │ │ +00041130: 7468 6520 746f 7272 656e 740a 0909 092f  the torrent..../
    │ │ │ +00041140: 2f20 746f 206e 6f20 6c6f 6e67 6572 2077  / to no longer w
    │ │ │ +00041150: 616e 7420 746f 2062 6520 7469 636b 6564  ant to be ticked
    │ │ │ +00041160: 2028 692e 652e 2069 7420 7761 730a 0909   (i.e. it was...
    │ │ │ +00041170: 092f 2f20 7265 6d6f 7665 6420 6672 6f6d  .// removed from
    │ │ │ +00041180: 2074 6865 206c 6973 7429 2077 6520 6e65   the list) we ne
    │ │ │ +00041190: 6564 2074 6f20 6261 636b 2075 7020 7468  ed to back up th
    │ │ │ +000411a0: 6520 636f 756e 7465 720a 0909 092f 2f20  e counter....// 
    │ │ │ +000411b0: 746f 206e 6f74 206d 6973 7320 7468 6520  to not miss the 
    │ │ │ +000411c0: 746f 7272 656e 7420 6166 7465 7220 6974  torrent after it
    │ │ │ +000411d0: 0a09 0909 6966 2028 2174 2e77 616e 745f  ....if (!t.want_
    │ │ │ +000411e0: 7469 636b 2829 2920 2d2d 693b 0a09 097d  tick()) --i;...}
    │ │ │ +000411f0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00041220: 0909 6966 2028 6d5f 7365 7474 696e 6773 ..if (m_settings │ │ │ +00041230: 2e67 6574 5f62 6f6f 6c28 7365 7474 696e .get_bool(settin │ │ │ +00041240: 6773 5f70 6163 6b3a 3a72 6174 655f 6c69 gs_pack::rate_li │ │ │ +00041250: 6d69 745f 6970 5f6f 7665 7268 6561 6429 mit_ip_overhead) │ │ │ +00041260: 290a 3c2f 6469 763e 0909 7b0a 0909 0969 ).
    ..{....i │ │ │ +00041270: 6e74 2063 6f6e 7374 2075 705f 6c69 6d69 nt const up_limi │ │ │ +00041280: 7420 3d20 7570 6c6f 6164 5f72 6174 655f t = upload_rate_ │ │ │ +00041290: 6c69 6d69 7428 6d5f 676c 6f62 616c 5f63 limit(m_global_c │ │ │ +000412a0: 6c61 7373 293b 0a09 0909 696e 7420 636f lass);....int co │ │ │ +000412b0: 6e73 7420 646f 776e 5f6c 696d 6974 203d nst down_limit = │ │ │ +000412c0: 2064 6f77 6e6c 6f61 645f 7261 7465 5f6c download_rate_l │ │ │ +000412d0: 696d 6974 286d 5f67 6c6f 6261 6c5f 636c imit(m_global_cl │ │ │ +000412e0: 6173 7329 3b0a 0a09 0909 6966 2028 646f ass);.....if (do │ │ │ +000412f0: 776e 5f6c 696d 6974 2026 6774 3b20 300a wn_limit > 0. │ │ │ +00041300: 0909 0909 2661 6d70 3b26 616d 703b 206d ....&& m │ │ │ +00041310: 5f73 7461 742e 646f 776e 6c6f 6164 5f69 _stat.download_i │ │ │ +00041320: 705f 6f76 6572 6865 6164 2829 2026 6774 p_overhead() > │ │ │ +00041330: 3b3d 2064 6f77 6e5f 6c69 6d69 740a 0909 ;= down_limit... │ │ │ +00041340: 0909 2661 6d70 3b26 616d 703b 206d 5f61 ..&& m_a │ │ │ +00041350: 6c65 7274 732e 7368 6f75 6c64 5f70 6f73 lerts.should_pos │ │ │ +00041360: 7426 6c74 3b70 6572 666f 726d 616e 6365 t<performance │ │ │ +00041370: 5f61 6c65 7274 2667 743b 2829 290a 0909 _alert>())... │ │ │ +00041380: 097b 0a09 0909 096d 5f61 6c65 7274 732e .{.....m_alerts. │ │ │ +00041390: 656d 706c 6163 655f 616c 6572 7426 6c74 emplace_alert< │ │ │ +000413a0: 3b70 6572 666f 726d 616e 6365 5f61 6c65 ;performance_ale │ │ │ +000413b0: 7274 2667 743b 2874 6f72 7265 6e74 5f68 rt>(torrent_h │ │ │ +000413c0: 616e 646c 6528 290a 0909 0909 092c 2070 andle()......, p │ │ │ +000413d0: 6572 666f 726d 616e 6365 5f61 6c65 7274 erformance_alert │ │ │ +000413e0: 3a3a 646f 776e 6c6f 6164 5f6c 696d 6974 ::download_limit │ │ │ +000413f0: 5f74 6f6f 5f6c 6f77 293b 0a09 0909 7d0a _too_low);....}. │ │ │ +00041400: 0a09 0909 6966 2028 7570 5f6c 696d 6974 ....if (up_limit │ │ │ +00041410: 2026 6774 3b20 300a 0909 0909 2661 6d70 > 0.....& │ │ │ +00041420: 3b26 616d 703b 206d 5f73 7461 742e 7570 ;& m_stat.up │ │ │ +00041430: 6c6f 6164 5f69 705f 6f76 6572 6865 6164 load_ip_overhead │ │ │ +00041440: 2829 2026 6774 3b3d 2075 705f 6c69 6d69 () >= up_limi │ │ │ +00041450: 740a 0909 0909 2661 6d70 3b26 616d 703b t.....&& │ │ │ +00041460: 206d 5f61 6c65 7274 732e 7368 6f75 6c64 m_alerts.should │ │ │ +00041470: 5f70 6f73 7426 6c74 3b70 6572 666f 726d _post<perform │ │ │ +00041480: 616e 6365 5f61 6c65 7274 2667 743b 2829 ance_alert>() │ │ │ +00041490: 290a 0909 097b 0a09 0909 096d 5f61 6c65 )....{.....m_ale │ │ │ +000414a0: 7274 732e 656d 706c 6163 655f 616c 6572 rts.emplace_aler │ │ │ +000414b0: 7426 6c74 3b70 6572 666f 726d 616e 6365 t<performance │ │ │ +000414c0: 5f61 6c65 7274 2667 743b 2874 6f72 7265 _alert>(torre │ │ │ +000414d0: 6e74 5f68 616e 646c 6528 290a 0909 0909 nt_handle()..... │ │ │ +000414e0: 092c 2070 6572 666f 726d 616e 6365 5f61 ., performance_a │ │ │ +000414f0: 6c65 7274 3a3a 7570 6c6f 6164 5f6c 696d lert::upload_lim │ │ │ +00041500: 6974 5f74 6f6f 5f6c 6f77 293b 0a09 0909 it_too_low);.... │ │ │ +00041510: 7d0a 0909 7d0a 0a23 6966 2054 4f52 5245 }...}..#if TORRE │ │ │ +00041520: 4e54 5f41 4249 5f56 4552 5349 4f4e 203d NT_ABI_VERSION = │ │ │ +00041530: 3d20 310a 0909 6d5f 7065 616b 5f75 705f = 1...m_peak_up_ │ │ │ +00041540: 7261 7465 203d 2073 7464 3a3a 6d61 7828 rate = std::max( │ │ │ +00041550: 6d5f 7374 6174 2e75 706c 6f61 645f 7261 m_stat.upload_ra │ │ │ +00041560: 7465 2829 2c20 6d5f 7065 616b 5f75 705f te(), m_peak_up_ │ │ │ +00041570: 7261 7465 293b 0a23 656e 6469 660a 0a09 rate);.#endif... │ │ │ +00041580: 096d 5f73 7461 742e 7365 636f 6e64 5f74 .m_stat.second_t │ │ │ +00041590: 6963 6b28 7469 636b 5f69 6e74 6572 7661 ick(tick_interva │ │ │ +000415a0: 6c5f 6d73 293b 0a0a 0909 2f2f 202d 2d2d l_ms);....// --- │ │ │ +000415b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000415c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000415d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000415e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0909 2f2f -----------...// │ │ │ +000415f0: 2073 6372 6170 6520 7061 7573 6564 2074 scrape paused t │ │ │ +00041600: 6f72 7265 6e74 7320 7468 6174 2061 7265 orrents that are │ │ │ +00041610: 2061 7574 6f20 6d61 6e61 6765 640a 0909 auto managed... │ │ │ +00041620: 2f2f 2028 756e 6c65 7373 2074 6865 2073 // (unless the s │ │ │ +00041630: 6573 7369 6f6e 2069 7320 7061 7573 6564 ession is paused │ │ │ +00041640: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ +00041670: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00041680: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000416b0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +000416c0: 2e63 7070 3a34 3531 393c 2f61 3e3c 2f74 .cpp:4519use a lowe │ │ │ +000416e0: 7220 6c69 6d69 7420 7468 616e 206d 5f73 r limit than m_s │ │ │ +000416f0: 6574 7469 6e67 732e 636f 6e6e 6563 7469 ettings.connecti │ │ │ +00041700: 6f6e 735f 6c69 6d69 7420 746f 2061 6c6c ons_limit to all │ │ │ +00041710: 6f63 6174 6520 7468 6520 746f 2031 3025 ocate the to 10% │ │ │ +00041720: 206f 7220 736f 206f 6620 636f 6e6e 6563 or so of connec │ │ │ +00041730: 7469 6f6e 2073 6c6f 7473 2066 6f72 2069 tion slots for i │ │ │ +00041740: 6e63 6f6d 696e 6720 636f 6e6e 6563 7469 ncoming connecti │ │ │ +00041750: 6f6e 7320 6361 7020 7468 6973 2061 7420 ons cap this at │ │ │ +00041760: 6d61 7820 2d20 312c 2073 696e 6365 2077 max - 1, since w │ │ │ +00041770: 6520 6d61 7920 6164 6420 6f6e 6520 6265 e may add one be │ │ │ +00041780: 6c6f 773c 2f74 643e 3c2f 7472 3e3c 7472 low

    use a lower lim │ │ │ +000417e0: 6974 2074 6861 6e20 6d5f 7365 7474 696e it than m_settin │ │ │ +000417f0: 6773 2e63 6f6e 6e65 6374 696f 6e73 5f6c gs.connections_l │ │ │ +00041800: 696d 6974 0a74 6f20 616c 6c6f 6361 7465 imit.to allocate │ │ │ +00041810: 2074 6865 2074 6f20 3130 2520 6f72 2073 the to 10% or s │ │ │ +00041820: 6f20 6f66 2063 6f6e 6e65 6374 696f 6e20 o of connection │ │ │ +00041830: 736c 6f74 7320 666f 7220 696e 636f 6d69 slots for incomi │ │ │ +00041840: 6e67 0a63 6f6e 6e65 6374 696f 6e73 0a63 ng.connections.c │ │ │ +00041850: 6170 2074 6869 7320 6174 206d 6178 202d ap this at max - │ │ │ +00041860: 2031 2c20 7369 6e63 6520 7765 206d 6179 1, since we may │ │ │ +00041870: 2061 6464 206f 6e65 2062 656c 6f77 3c2f add one below

    ../src/se │ │ │ +00041890: 7373 696f 6e5f 696d 706c 2e63 7070 3a34 ssion_impl.cpp:4 │ │ │ +000418a0: 3531 393c 2f68 343e 3c70 7265 2073 7479 519

    ..// boost, wh
    │ │ │ +000418f0: 6963 6820 6172 6520 646f 6e65 2069 6d6d  ich are done imm
    │ │ │ +00041900: 6564 6961 7465 6c79 206f 6e20 6120 7472  ediately on a tr
    │ │ │ +00041910: 6163 6b65 7220 7265 7370 6f6e 7365 2e20  acker response. 
    │ │ │ +00041920: 5468 6573 650a 0909 2f2f 2063 6f6e 6e65  These...// conne
    │ │ │ +00041930: 6374 696f 6e73 206e 6565 6473 2074 6f20  ctions needs to 
    │ │ │ +00041940: 6265 2064 6564 7563 7465 6420 6672 6f6d  be deducted from
    │ │ │ +00041950: 2074 6865 2072 6567 756c 6172 2063 6f6e   the regular con
    │ │ │ +00041960: 6e65 6374 696f 6e20 6174 7465 6d70 740a  nection attempt.
    │ │ │ +00041970: 0909 2f2f 2071 756f 7461 2066 6f72 2074  ..// quota for t
    │ │ │ +00041980: 6869 7320 7469 636b 0a09 0969 6620 286d  his tick...if (m
    │ │ │ +00041990: 5f62 6f6f 7374 5f63 6f6e 6e65 6374 696f  _boost_connectio
    │ │ │ +000419a0: 6e73 2026 6774 3b20 3029 0a09 097b 0a09  ns > 0)...{..
    │ │ │ +000419b0: 0909 6966 2028 6d5f 626f 6f73 745f 636f  ..if (m_boost_co
    │ │ │ +000419c0: 6e6e 6563 7469 6f6e 7320 2667 743b 206d  nnections > m
    │ │ │ +000419d0: 6178 5f63 6f6e 6e65 6374 696f 6e73 290a  ax_connections).
    │ │ │ +000419e0: 0909 097b 0a09 0909 096d 5f62 6f6f 7374  ...{.....m_boost
    │ │ │ +000419f0: 5f63 6f6e 6e65 6374 696f 6e73 202d 3d20  _connections -= 
    │ │ │ +00041a00: 6d61 785f 636f 6e6e 6563 7469 6f6e 733b  max_connections;
    │ │ │ +00041a10: 0a09 0909 096d 6178 5f63 6f6e 6e65 6374  .....max_connect
    │ │ │ +00041a20: 696f 6e73 203d 2030 3b0a 0909 097d 0a09  ions = 0;....}..
    │ │ │ +00041a30: 0909 656c 7365 0a09 0909 7b0a 0909 0909  ..else....{.....
    │ │ │ +00041a40: 6d61 785f 636f 6e6e 6563 7469 6f6e 7320  max_connections 
    │ │ │ +00041a50: 2d3d 206d 5f62 6f6f 7374 5f63 6f6e 6e65  -= m_boost_conne
    │ │ │ +00041a60: 6374 696f 6e73 3b0a 0909 0909 6d5f 626f  ctions;.....m_bo
    │ │ │ +00041a70: 6f73 745f 636f 6e6e 6563 7469 6f6e 7320  ost_connections 
    │ │ │ +00041a80: 3d20 303b 0a09 0909 7d0a 0909 7d0a 0a09  = 0;....}...}...
    │ │ │ +00041a90: 092f 2f20 7a65 726f 2063 6f6e 6e65 6374  .// zero connect
    │ │ │ +00041aa0: 696f 6e73 2073 7065 6564 7320 6172 6520  ions speeds are 
    │ │ │ +00041ab0: 616c 6c6f 7765 642c 2077 6520 6a75 7374  allowed, we just
    │ │ │ +00041ac0: 2077 6f6e 2774 206d 616b 6520 616e 7920   won't make any 
    │ │ │ +00041ad0: 636f 6e6e 6563 7469 6f6e 730a 0909 6966  connections...if
    │ │ │ +00041ae0: 2028 6d61 785f 636f 6e6e 6563 7469 6f6e   (max_connection
    │ │ │ +00041af0: 7320 266c 743b 3d20 3029 2072 6574 7572  s <= 0) retur
    │ │ │ +00041b00: 6e3b 0a0a 3c64 6976 2073 7479 6c65 3d22  n;..
    ..int const li │ │ │ +00041b40: 6d69 7420 3d20 7374 643a 3a6d 696e 286d mit = std::min(m │ │ │ +00041b50: 5f73 6574 7469 6e67 732e 6765 745f 696e _settings.get_in │ │ │ +00041b60: 7428 7365 7474 696e 6773 5f70 6163 6b3a t(settings_pack: │ │ │ +00041b70: 3a63 6f6e 6e65 6374 696f 6e73 5f6c 696d :connections_lim │ │ │ +00041b80: 6974 290a 3c2f 6469 763e 0909 092d 206e it).
    ...- n │ │ │ +00041b90: 756d 5f63 6f6e 6e65 6374 696f 6e73 2829 um_connections() │ │ │ +00041ba0: 2c20 7374 643a 3a6e 756d 6572 6963 5f6c , std::numeric_l │ │ │ +00041bb0: 696d 6974 7326 6c74 3b69 6e74 2667 743b imits<int> │ │ │ +00041bc0: 3a3a 6d61 7828 2920 2d20 3129 3b0a 0a09 ::max() - 1);... │ │ │ +00041bd0: 092f 2f20 7468 6973 206c 6f67 6963 2069 .// this logic i │ │ │ +00041be0: 7320 6865 7265 2074 6f20 736d 6f6f 7468 s here to smooth │ │ │ +00041bf0: 206f 7574 2074 6865 206e 756d 6265 7220 out the number │ │ │ +00041c00: 6f66 206e 6577 2063 6f6e 6e65 6374 696f of new connectio │ │ │ +00041c10: 6e0a 0909 2f2f 2061 7474 656d 7074 7320 n...// attempts │ │ │ +00041c20: 6f76 6572 2074 696d 652c 2074 6f20 7072 over time, to pr │ │ │ +00041c30: 6576 656e 7420 636f 6e6e 6563 7469 6e67 event connecting │ │ │ +00041c40: 2061 206c 6172 6765 206e 756d 6265 7220 a large number │ │ │ +00041c50: 6f66 0a09 092f 2f20 736f 636b 6574 732c of...// sockets, │ │ │ +00041c60: 2077 6169 7420 3130 2073 6563 6f6e 6473 wait 10 seconds │ │ │ +00041c70: 2c20 616e 6420 7468 656e 2074 7279 2061 , and then try a │ │ │ +00041c80: 6761 696e 0a09 0969 6620 286d 5f73 6574 gain...if (m_set │ │ │ +00041c90: 7469 6e67 732e 6765 745f 626f 6f6c 2873 tings.get_bool(s │ │ │ +00041ca0: 6574 7469 6e67 735f 7061 636b 3a3a 736d ettings_pack::sm │ │ │ +00041cb0: 6f6f 7468 5f63 6f6e 6e65 6374 7329 2026 ooth_connects) & │ │ │ +00041cc0: 616d 703b 2661 6d70 3b20 6d61 785f 636f amp;& max_co │ │ │ +00041cd0: 6e6e 6563 7469 6f6e 7320 2667 743b 2028 nnections > ( │ │ │ +00041ce0: 6c69 6d69 742b 3129 202f 2032 290a 0909 limit+1) / 2)... │ │ │ +00041cf0: 096d 6178 5f63 6f6e 6e65 6374 696f 6e73 .max_connections │ │ │ +00041d00: 203d 2028 6c69 6d69 7420 2b20 3129 202f = (limit + 1) / │ │ │ +00041d10: 2032 3b0a 0a09 0961 7578 3a3a 7665 6374 2;....aux::vect │ │ │ +00041d20: 6f72 266c 743b 746f 7272 656e 742a 2667 or<torrent*&g │ │ │ +00041d30: 743b 2661 6d70 3b20 7761 6e74 5f70 6565 t;& want_pee │ │ │ +00041d40: 7273 5f64 6f77 6e6c 6f61 6420 3d20 6d5f rs_download = m_ │ │ │ +00041d50: 746f 7272 656e 745f 6c69 7374 735b 746f torrent_lists[to │ │ │ +00041d60: 7272 656e 745f 7761 6e74 5f70 6565 7273 rrent_want_peers │ │ │ +00041d70: 5f64 6f77 6e6c 6f61 645d 3b0a 0909 6175 _download];...au │ │ │ +00041d80: 783a 3a76 6563 746f 7226 6c74 3b74 6f72 x::vector<tor │ │ │ +00041d90: 7265 6e74 2a26 6774 3b26 616d 703b 2077 rent*>& w │ │ │ +00041da0: 616e 745f 7065 6572 735f 6669 6e69 7368 ant_peers_finish │ │ │ +00041db0: 6564 203d 206d 5f74 6f72 7265 6e74 5f6c ed = m_torrent_l │ │ │ +00041dc0: 6973 7473 5b74 6f72 7265 6e74 5f77 616e ists[torrent_wan │ │ │ +00041dd0: 745f 7065 6572 735f 6669 6e69 7368 6564 t_peers_finished │ │ │ +00041de0: 5d3b 0a0a 0909 2f2f 2069 6620 6e6f 2074 ];....// if no t │ │ │ +00041df0: 6f72 7265 6e74 2077 616e 7420 616e 7920 orrent want any │ │ │ +00041e00: 7065 6572 732c 206a 7573 7420 7265 7475 peers, just retu │ │ │ +00041e10: 726e 0a09 0969 6620 2877 616e 745f 7065 rn...if (want_pe │ │ │ +00041e20: 6572 735f 646f 776e 6c6f 6164 2e65 6d70 ers_download.emp │ │ │ +00041e30: 7479 2829 2026 616d 703b 2661 6d70 3b20 ty() && │ │ │ +00041e40: 7761 6e74 5f70 6565 7273 5f66 696e 6973 want_peers_finis │ │ │ +00041e50: 6865 642e 656d 7074 7928 2929 2072 6574 hed.empty()) ret │ │ │ +00041e60: 7572 6e3b 0a0a 0909 2f2f 2069 6620 7765 urn;....// if we │ │ │ +00041e70: 2064 6f6e 2774 2068 6176 6520 616e 7920 don't have any │ │ │ +00041e80: 636f 6e6e 6563 7469 6f6e 2061 7474 656d connection attem │ │ │ +00041e90: 7074 2071 756f 7461 2c20 7265 7475 726e pt quota, return │ │ │ +00041ea0: 0a09 0969 6620 286d 6178 5f63 6f6e 6e65 ...if (max_conne │ │ │ +00041eb0: 6374 696f 6e73 2026 6c74 3b3d 2030 2920 ctions <= 0) │ │ │ +00041ec0: 7265 7475 726e 3b0a 0a09 0969 6e74 2073 return;....int s │ │ │ +00041ed0: 7465 7073 5f73 696e 6365 5f6c 6173 745f teps_since_last_ │ │ │ +00041ee0: 636f 6e6e 6563 7420 3d20 303b 0a09 0969 connect = 0;...i │ │ │ +00041ef0: 6e74 2063 6f6e 7374 206e 756d 5f74 6f72 nt const num_tor │ │ │ +00041f00: 7265 6e74 7320 3d20 696e 7428 7761 6e74 rents = int(want │ │ │ +00041f10: 5f70 6565 7273 5f66 696e 6973 6865 642e _peers_finished. │ │ │ +00041f20: 7369 7a65 2829 202b 2077 616e 745f 7065 size() + want_pe │ │ │ +00041f30: 6572 735f 646f 776e 6c6f 6164 2e73 697a ers_download.siz │ │ │ +00041f40: 6528 2929 3b0a 0909 666f 7220 283b 3b29 e());...for (;;) │ │ │ +00041f50: 0a09 097b 0a09 0909 6966 2028 6d5f 6e65 ...{....if (m_ne │ │ │ +00041f60: 7874 5f64 6f77 6e6c 6f61 6469 6e67 5f63 xt_downloading_c │ │ │ +00041f70: 6f6e 6e65 6374 5f74 6f72 7265 6e74 2026 onnect_torrent & │ │ │ +00041f80: 6774 3b3d 2069 6e74 2877 616e 745f 7065 gt;= int(want_pe │ │ │ +00041f90: 6572 735f 646f 776e 6c6f 6164 2e73 697a ers_download.siz │ │ │ +00041fa0: 6528 2929 290a 0909 0909 6d5f 6e65 7874 e())).....m_next │ │ │ +00041fb0: 5f64 6f77 6e6c 6f61 6469 6e67 5f63 6f6e _downloading_con │ │ │ +00041fc0: 6e65 6374 5f74 6f72 7265 6e74 203d 2030 nect_torrent = 0 │ │ │ +00041fd0: 3b0a 0a09 0909 6966 2028 6d5f 6e65 7874 ;.....if (m_next │ │ │ +00041fe0: 5f66 696e 6973 6865 645f 636f 6e6e 6563 _finished_connec │ │ │ +00041ff0: 745f 746f 7272 656e 7420 2667 743b 3d20 t_torrent >= │ │ │ +00042000: 696e 7428 7761 6e74 5f70 6565 7273 5f66 int(want_peers_f │ │ │ +00042010: 696e 6973 6865 642e 7369 7a65 2829 2929 inished.size())) │ │ │ +00042020: 0a09 0909 096d 5f6e 6578 745f 6669 6e69 .....m_next_fini │ │ │ +00042030: 7368 6564 5f63 6f6e 6e65 6374 5f74 6f72 shed_connect_tor │ │ │ +00042040: 7265 6e74 203d 2030 3b0a 0a09 0909 746f rent = 0;.....to │ │ │ +00042050: 7272 656e 742a 2074 203d 206e 756c 6c70 rrent* t = nullp │ │ │ +00042060: 7472 3b0a 0909 092f 2f20 7468 6572 6520 tr;....// there │ │ │ +00042070: 6172 6520 7072 696f 7269 7469 7a65 6420 are prioritized │ │ │ +00042080: 746f 7272 656e 7473 2e20 5069 636b 206f torrents. Pick o │ │ │ +00042090: 6e65 206f 6620 7468 6f73 650a 0909 0977 ne of those....w │ │ │ +000420a0: 6869 6c65 2028 216d 5f70 7269 6f5f 746f hile (!m_prio_to │ │ │ +000420b0: 7272 656e 7473 2e65 6d70 7479 2829 290a rrents.empty()). │ │ │ +000420c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000420d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00042100: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00042130: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00042140: 7070 3a34 3636 343c 2f61 3e3c 2f74 643e pp:4664 │ │ │ +00042150: 3c74 643e 706f 7374 2061 206d 6573 7361 post a messa │ │ │ +00042160: 6765 2074 6f20 6861 7665 2074 6869 7320 ge to have this │ │ │ +00042170: 6861 7070 656e 2069 6d6d 6564 6961 7465 happen immediate │ │ │ +00042180: 6c79 2069 6e73 7465 6164 206f 6620 7761 ly instead of wa │ │ │ +00042190: 6974 696e 6720 666f 7220 7468 6520 6e65 iting for the ne │ │ │ +000421a0: 7874 2074 6963 6b3c 2f74 643e 3c2f 7472 xt tick

    post a mess │ │ │ +00042200: 6167 6520 746f 2068 6176 6520 7468 6973 age to have this │ │ │ +00042210: 2068 6170 7065 6e0a 696d 6d65 6469 6174 happen.immediat │ │ │ +00042220: 656c 7920 696e 7374 6561 6420 6f66 2077 ely instead of w │ │ │ +00042230: 6169 7469 6e67 2066 6f72 2074 6865 206e aiting for the n │ │ │ +00042240: 6578 7420 7469 636b 3c2f 6832 3e3c 6834 ext tick

    ../src/session_ │ │ │ +00042260: 696d 706c 2e63 7070 3a34 3636 343c 2f68 impl.cpp:4664
    ....
    │ │ │ +000422b0: 636f 6e74 696e 7565 3b0a 0909 097d 0a0a  continue;....}..
    │ │ │ +000422c0: 0909 0969 6620 2821 702d 2667 743b 6973  ...if (!p->is
    │ │ │ +000422d0: 5f70 6565 725f 696e 7465 7265 7374 6564  _peer_interested
    │ │ │ +000422e0: 2829 0a09 0909 097c 7c20 702d 2667 743b  ().....|| p->
    │ │ │ +000422f0: 6973 5f64 6973 636f 6e6e 6563 7469 6e67  is_disconnecting
    │ │ │ +00042300: 2829 0a09 0909 097c 7c20 702d 2667 743b  ().....|| p->
    │ │ │ +00042310: 6973 5f63 6f6e 6e65 6374 696e 6728 2929  is_connecting())
    │ │ │ +00042320: 0a09 0909 7b0a 0909 0909 2f2f 2074 6869  ....{.....// thi
    │ │ │ +00042330: 7320 7065 6572 2069 7320 6e6f 7420 756e  s peer is not un
    │ │ │ +00042340: 6368 6f6b 6162 6c65 2e20 536f 2c20 6966  chokable. So, if
    │ │ │ +00042350: 2069 7427 7320 756e 6368 6f6b 6564 0a09   it's unchoked..
    │ │ │ +00042360: 0909 092f 2f20 616c 7265 6164 792c 206d  ...// already, m
    │ │ │ +00042370: 616b 6520 7375 7265 2074 6f20 6368 6f6b  ake sure to chok
    │ │ │ +00042380: 6520 6974 2e0a 0909 0909 6966 2028 702d  e it......if (p-
    │ │ │ +00042390: 2667 743b 6973 5f63 686f 6b65 6428 2929  >is_choked())
    │ │ │ +000423a0: 0a09 0909 097b 0a09 0909 0909 702d 2667  .....{......p-&g
    │ │ │ +000423b0: 743b 7265 7365 745f 6368 6f6b 655f 636f  t;reset_choke_co
    │ │ │ +000423c0: 756e 7465 7273 2829 3b0a 0909 0909 0963  unters();......c
    │ │ │ +000423d0: 6f6e 7469 6e75 653b 0a09 0909 097d 0a09  ontinue;.....}..
    │ │ │ +000423e0: 0909 0969 6620 2870 6920 2661 6d70 3b26  ...if (pi &&
    │ │ │ +000423f0: 616d 703b 2070 692d 2667 743b 6f70 7469  amp; pi->opti
    │ │ │ +00042400: 6d69 7374 6963 616c 6c79 5f75 6e63 686f  mistically_uncho
    │ │ │ +00042410: 6b65 6429 0a09 0909 097b 0a09 0909 0909  ked).....{......
    │ │ │ +00042420: 6d5f 7374 6174 735f 636f 756e 7465 7273  m_stats_counters
    │ │ │ +00042430: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ +00042440: 6572 2863 6f75 6e74 6572 733a 3a6e 756d  er(counters::num
    │ │ │ +00042450: 5f70 6565 7273 5f75 705f 756e 6368 6f6b  _peers_up_unchok
    │ │ │ +00042460: 6564 5f6f 7074 696d 6973 7469 632c 202d  ed_optimistic, -
    │ │ │ +00042470: 3129 3b0a 0909 0909 0970 692d 2667 743b  1);......pi->
    │ │ │ +00042480: 6f70 7469 6d69 7374 6963 616c 6c79 5f75  optimistically_u
    │ │ │ +00042490: 6e63 686f 6b65 6420 3d20 6661 6c73 653b  nchoked = false;
    │ │ │ +000424a0: 0a09 0909 0909 2f2f 2066 6f72 6365 2061  ......// force a
    │ │ │ +000424b0: 206e 6577 206f 7074 696d 6973 7469 6320   new optimistic 
    │ │ │ +000424c0: 756e 6368 6f6b 650a 0909 0909 096d 5f6f  unchoke......m_o
    │ │ │ +000424d0: 7074 696d 6973 7469 635f 756e 6368 6f6b  ptimistic_unchok
    │ │ │ +000424e0: 655f 7469 6d65 5f73 6361 6c65 7220 3d20  e_time_scaler = 
    │ │ │ +000424f0: 303b 0a3c 6469 7620 7374 796c 653d 2262  0;.
    ....}.
    ... │ │ │ +00042530: 0974 2d26 6774 3b63 686f 6b65 5f70 6565 .t->choke_pee │ │ │ +00042540: 7228 2a70 293b 0a09 0909 0970 2d26 6774 r(*p);.....p-> │ │ │ +00042550: 3b72 6573 6574 5f63 686f 6b65 5f63 6f75 ;reset_choke_cou │ │ │ +00042560: 6e74 6572 7328 293b 0a09 0909 0963 6f6e nters();.....con │ │ │ +00042570: 7469 6e75 653b 0a09 0909 7d0a 0a09 0909 tinue;....}..... │ │ │ +00042580: 7065 6572 732e 7075 7368 5f62 6163 6b28 peers.push_back( │ │ │ +00042590: 702e 6765 7428 2929 3b0a 0909 7d0a 0a09 p.get());...}... │ │ │ +000425a0: 0969 6e74 2063 6f6e 7374 2061 6c6c 6f77 .int const allow │ │ │ +000425b0: 6564 5f75 706c 6f61 645f 736c 6f74 7320 ed_upload_slots │ │ │ +000425c0: 3d20 756e 6368 6f6b 655f 736f 7274 2870 = unchoke_sort(p │ │ │ +000425d0: 6565 7273 0a09 0909 2c20 756e 6368 6f6b eers...., unchok │ │ │ +000425e0: 655f 696e 7465 7276 616c 2c20 6d5f 7365 e_interval, m_se │ │ │ +000425f0: 7474 696e 6773 293b 0a0a 0909 6966 2028 ttings);....if ( │ │ │ +00042600: 6d5f 7365 7474 696e 6773 2e67 6574 5f69 m_settings.get_i │ │ │ +00042610: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +00042620: 3a3a 6368 6f6b 696e 675f 616c 676f 7269 ::choking_algori │ │ │ +00042630: 7468 6d29 203d 3d20 7365 7474 696e 6773 thm) == settings │ │ │ +00042640: 5f70 6163 6b3a 3a66 6978 6564 5f73 6c6f _pack::fixed_slo │ │ │ +00042650: 7473 5f63 686f 6b65 7229 0a09 097b 0a09 ts_choker)...{.. │ │ │ +00042660: 0909 696e 7420 636f 6e73 7420 7570 6c6f ..int const uplo │ │ │ +00042670: 6164 5f73 6c6f 7473 203d 2067 6574 5f69 ad_slots = get_i │ │ │ +00042680: 6e74 5f73 6574 7469 6e67 2873 6574 7469 nt_setting(setti │ │ │ +00042690: 6e67 735f 7061 636b 3a3a 756e 6368 6f6b ngs_pack::unchok │ │ │ +000426a0: 655f 736c 6f74 735f 6c69 6d69 7429 3b0a e_slots_limit);. │ │ │ +000426b0: 0909 096d 5f73 7461 7473 5f63 6f75 6e74 ...m_stats_count │ │ │ +000426c0: 6572 732e 7365 745f 7661 6c75 6528 636f ers.set_value(co │ │ │ +000426d0: 756e 7465 7273 3a3a 6e75 6d5f 756e 6368 unters::num_unch │ │ │ +000426e0: 6f6b 655f 736c 6f74 732c 2075 706c 6f61 oke_slots, uploa │ │ │ +000426f0: 645f 736c 6f74 7329 3b0a 0909 7d0a 0909 d_slots);...}... │ │ │ +00042700: 656c 7365 0a09 097b 0a09 0909 6d5f 7374 else...{....m_st │ │ │ +00042710: 6174 735f 636f 756e 7465 7273 2e73 6574 ats_counters.set │ │ │ +00042720: 5f76 616c 7565 2863 6f75 6e74 6572 733a _value(counters: │ │ │ +00042730: 3a6e 756d 5f75 6e63 686f 6b65 5f73 6c6f :num_unchoke_slo │ │ │ +00042740: 7473 0a09 0909 092c 2061 6c6c 6f77 6564 ts....., allowed │ │ │ +00042750: 5f75 706c 6f61 645f 736c 6f74 7329 3b0a _upload_slots);. │ │ │ +00042760: 0909 7d0a 0a23 6966 6e64 6566 2054 4f52 ..}..#ifndef TOR │ │ │ +00042770: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47 RENT_DISABLE_LOG │ │ │ +00042780: 4749 4e47 0a09 0969 6620 2873 686f 756c GING...if (shoul │ │ │ +00042790: 645f 6c6f 6728 2929 0a09 097b 0a09 0909 d_log())...{.... │ │ │ +000427a0: 7365 7373 696f 6e5f 6c6f 6728 2252 4543 session_log("REC │ │ │ +000427b0: 414c 4355 4c41 5445 2055 4e43 484f 4b45 ALCULATE UNCHOKE │ │ │ +000427c0: 2053 4c4f 5453 3a20 5b20 7065 6572 733a SLOTS: [ peers: │ │ │ +000427d0: 2025 6420 220a 0909 0909 2265 6c69 6769 %d "....."eligi │ │ │ +000427e0: 626c 652d 7065 6572 733a 2025 6422 0a09 ble-peers: %d".. │ │ │ +000427f0: 0909 0922 2061 6c6c 6f77 6564 2d73 6c6f ..." allowed-slo │ │ │ +00042800: 7473 3a20 2564 205d 220a 0909 0909 2c20 ts: %d ]"....., │ │ │ +00042810: 696e 7428 6d5f 636f 6e6e 6563 7469 6f6e int(m_connection │ │ │ +00042820: 732e 7369 7a65 2829 290a 0909 0909 2c20 s.size())....., │ │ │ +00042830: 696e 7428 7065 6572 732e 7369 7a65 2829 int(peers.size() │ │ │ +00042840: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ +00042870: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00042880: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000428b0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +000428c0: 2e63 7070 3a34 3939 313c 2f61 3e3c 2f74 .cpp:4991it might b │ │ │ +000428e0: 6520 6120 6e69 6365 2066 6561 7475 7265 e a nice feature │ │ │ +000428f0: 2068 6572 6520 746f 206c 696d 6974 2074 here to limit t │ │ │ +00042900: 6865 206e 756d 6265 7220 6f66 2074 6f72 he number of tor │ │ │ +00042910: 7265 6e74 7320 746f 2073 656e 6420 696e rents to send in │ │ │ +00042920: 2061 2073 696e 676c 6520 7570 6461 7465 a single update │ │ │ +00042930: 2e20 4279 206a 7573 7420 706f 7374 696e . By just postin │ │ │ +00042940: 6720 7468 6520 6669 7273 7420 6e20 746f g the first n to │ │ │ +00042950: 7272 656e 7473 2c20 7468 6579 2077 6f75 rrents, they wou │ │ │ +00042960: 6c64 206e 6963 656c 7920 6265 2072 6f75 ld nicely be rou │ │ │ +00042970: 6e64 2d72 6f62 696e 6564 2062 6563 6175 nd-robined becau │ │ │ +00042980: 7365 2074 6865 2074 6f72 7265 6e74 206c se the torrent l │ │ │ +00042990: 6973 7473 2061 7265 2061 6c77 6179 7320 ists are always │ │ │ +000429a0: 7075 7368 6564 2062 6163 6b2e 2050 6572 pushed back. Per │ │ │ +000429b0: 6861 7073 2074 6865 2073 7461 7475 735f haps the status_ │ │ │ +000429c0: 7570 6461 7465 5f61 6c65 7274 2063 6f75 update_alert cou │ │ │ +000429d0: 6c64 2065 7665 6e20 6861 7665 2061 2066 ld even have a f │ │ │ +000429e0: 6978 6564 2061 7272 6179 206f 6620 6e20 ixed array of n │ │ │ +000429f0: 656e 7472 6965 7320 7261 7468 6572 2074 entries rather t │ │ │ +00042a00: 6861 6e20 6120 7665 6374 6f72 2c20 746f han a vector, to │ │ │ +00042a10: 2066 7572 7468 6572 2069 6d70 726f 7665 further improve │ │ │ +00042a20: 206d 656d 6f72 7920 6c6f 6361 6c69 7479 memory locality │ │ │ +00042a30: 2e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 .

    i │ │ │ +00042a80: 7420 6d69 6768 7420 6265 2061 206e 6963 t might be a nic │ │ │ +00042a90: 6520 6665 6174 7572 6520 6865 7265 2074 e feature here t │ │ │ +00042aa0: 6f20 6c69 6d69 7420 7468 6520 6e75 6d62 o limit the numb │ │ │ +00042ab0: 6572 206f 6620 746f 7272 656e 7473 0a74 er of torrents.t │ │ │ +00042ac0: 6f20 7365 6e64 2069 6e20 6120 7369 6e67 o send in a sing │ │ │ +00042ad0: 6c65 2075 7064 6174 652e 2042 7920 6a75 le update. By ju │ │ │ +00042ae0: 7374 2070 6f73 7469 6e67 2074 6865 2066 st posting the f │ │ │ +00042af0: 6972 7374 206e 2074 6f72 7265 6e74 732c irst n torrents, │ │ │ +00042b00: 2074 6865 790a 776f 756c 6420 6e69 6365 they.would nice │ │ │ +00042b10: 6c79 2062 6520 726f 756e 642d 726f 6269 ly be round-robi │ │ │ +00042b20: 6e65 6420 6265 6361 7573 6520 7468 6520 ned because the │ │ │ +00042b30: 746f 7272 656e 7420 6c69 7374 7320 6172 torrent lists ar │ │ │ +00042b40: 6520 616c 7761 7973 0a70 7573 6865 6420 e always.pushed │ │ │ +00042b50: 6261 636b 2e20 5065 7268 6170 7320 7468 back. Perhaps th │ │ │ +00042b60: 6520 7374 6174 7573 5f75 7064 6174 655f e status_update_ │ │ │ +00042b70: 616c 6572 7420 636f 756c 6420 6576 656e alert could even │ │ │ +00042b80: 2068 6176 6520 6120 6669 7865 640a 6172 have a fixed.ar │ │ │ +00042b90: 7261 7920 6f66 206e 2065 6e74 7269 6573 ray of n entries │ │ │ +00042ba0: 2072 6174 6865 7220 7468 616e 2061 2076 rather than a v │ │ │ +00042bb0: 6563 746f 722c 2074 6f20 6675 7274 6865 ector, to furthe │ │ │ +00042bc0: 7220 696d 7072 6f76 6520 6d65 6d6f 7279 r improve memory │ │ │ +00042bd0: 0a6c 6f63 616c 6974 792e 3c2f 6832 3e3c .locality.

    < │ │ │ +00042be0: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ +00042bf0: 6e5f 696d 706c 2e63 7070 3a34 3939 313c n_impl.cpp:4991< │ │ │ +00042c00: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00042c40: 0974 2d26 6774 3b73 7461 7475 7328 2661  .t->status(&a
    │ │ │ +00042c50: 6d70 3b73 742c 2066 6c61 6773 293b 0a09  mp;st, flags);..
    │ │ │ +00042c60: 097d 0a09 7d0a 0a09 766f 6964 2073 6573  .}..}...void ses
    │ │ │ +00042c70: 7369 6f6e 5f69 6d70 6c3a 3a70 6f73 745f  sion_impl::post_
    │ │ │ +00042c80: 746f 7272 656e 745f 7570 6461 7465 7328  torrent_updates(
    │ │ │ +00042c90: 7374 6174 7573 5f66 6c61 6773 5f74 2063  status_flags_t c
    │ │ │ +00042ca0: 6f6e 7374 2066 6c61 6773 290a 097b 0a09  onst flags)..{..
    │ │ │ +00042cb0: 0949 4e56 4152 4941 4e54 5f43 4845 434b  .INVARIANT_CHECK
    │ │ │ +00042cc0: 3b0a 0a09 0954 4f52 5245 4e54 5f41 5353  ;....TORRENT_ASS
    │ │ │ +00042cd0: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ +00042ce0: 7265 6164 2829 293b 0a0a 0909 7374 643a  read());....std:
    │ │ │ +00042cf0: 3a76 6563 746f 7226 6c74 3b74 6f72 7265  :vector<torre
    │ │ │ +00042d00: 6e74 2a26 6774 3b26 616d 703b 2073 7461  nt*>& sta
    │ │ │ +00042d10: 7465 5f75 7064 6174 6573 0a09 0909 3d20  te_updates....= 
    │ │ │ +00042d20: 6d5f 746f 7272 656e 745f 6c69 7374 735b  m_torrent_lists[
    │ │ │ +00042d30: 6175 783a 3a73 6573 7369 6f6e 5f69 6d70  aux::session_imp
    │ │ │ +00042d40: 6c3a 3a74 6f72 7265 6e74 5f73 7461 7465  l::torrent_state
    │ │ │ +00042d50: 5f75 7064 6174 6573 5d3b 0a0a 2369 6620  _updates];..#if 
    │ │ │ +00042d60: 544f 5252 454e 545f 5553 455f 4153 5345  TORRENT_USE_ASSE
    │ │ │ +00042d70: 5254 530a 0909 6d5f 706f 7374 696e 675f  RTS...m_posting_
    │ │ │ +00042d80: 746f 7272 656e 745f 7570 6461 7465 7320  torrent_updates 
    │ │ │ +00042d90: 3d20 7472 7565 3b0a 2365 6e64 6966 0a0a  = true;.#endif..
    │ │ │ +00042da0: 0909 7374 643a 3a76 6563 746f 7226 6c74  ..std::vector<
    │ │ │ +00042db0: 3b74 6f72 7265 6e74 5f73 7461 7475 7326  ;torrent_status&
    │ │ │ +00042dc0: 6774 3b20 7374 6174 7573 3b0a 0909 7374  gt; status;...st
    │ │ │ +00042dd0: 6174 7573 2e72 6573 6572 7665 2873 7461  atus.reserve(sta
    │ │ │ +00042de0: 7465 5f75 7064 6174 6573 2e73 697a 6528  te_updates.size(
    │ │ │ +00042df0: 2929 3b0a 0a3c 6469 7620 7374 796c 653d  ));..
    ..for (auto&a │ │ │ +00042e30: 6d70 3b20 7420 3a20 7374 6174 655f 7570 mp; t : state_up │ │ │ +00042e40: 6461 7465 7329 0a3c 2f64 6976 3e09 097b dates).
    ..{ │ │ │ +00042e50: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00042e60: 5254 2874 2d26 6774 3b6d 5f6c 696e 6b73 RT(t->m_links │ │ │ +00042e70: 5b61 7578 3a3a 7365 7373 696f 6e5f 696d [aux::session_im │ │ │ +00042e80: 706c 3a3a 746f 7272 656e 745f 7374 6174 pl::torrent_stat │ │ │ +00042e90: 655f 7570 6461 7465 735d 2e69 6e5f 6c69 e_updates].in_li │ │ │ +00042ea0: 7374 2829 293b 0a09 0909 7374 6174 7573 st());....status │ │ │ +00042eb0: 2e65 6d70 6c61 6365 5f62 6163 6b28 293b .emplace_back(); │ │ │ +00042ec0: 0a09 0909 2f2f 2071 7565 7279 696e 6720 ....// querying │ │ │ +00042ed0: 6163 6375 7261 7465 2064 6f77 6e6c 6f61 accurate downloa │ │ │ +00042ee0: 6420 636f 756e 7465 7273 206d 6179 2072 d counters may r │ │ │ +00042ef0: 6571 7569 7265 0a09 0909 2f2f 2074 6865 equire....// the │ │ │ +00042f00: 2074 6f72 7265 6e74 2074 6f20 6265 206c torrent to be l │ │ │ +00042f10: 6f61 6465 642e 204c 6f61 6469 6e67 2061 oaded. Loading a │ │ │ +00042f20: 2074 6f72 7265 6e74 2c20 616e 6420 6576 torrent, and ev │ │ │ +00042f30: 6963 7469 6e67 2061 6e6f 7468 6572 0a09 icting another.. │ │ │ +00042f40: 0909 2f2f 206f 6e65 2077 696c 6c20 6c65 ..// one will le │ │ │ +00042f50: 6164 2074 6f20 6361 6c6c 696e 6720 7374 ad to calling st │ │ │ +00042f60: 6174 655f 7570 6461 7465 6428 292c 2077 ate_updated(), w │ │ │ +00042f70: 6869 6368 2073 6372 6577 7320 7769 7468 hich screws with │ │ │ +00042f80: 0a09 0909 2f2f 2074 6869 7320 6c69 7374 ....// this list │ │ │ +00042f90: 2077 6869 6c65 2077 6527 7265 2077 6f72 while we're wor │ │ │ +00042fa0: 6b69 6e67 206f 6e20 6974 2c20 616e 6420 king on it, and │ │ │ +00042fb0: 6272 6561 6b20 7468 696e 6773 0a09 0909 break things.... │ │ │ +00042fc0: 742d 2667 743b 7374 6174 7573 2826 616d t->status(&am │ │ │ +00042fd0: 703b 7374 6174 7573 2e62 6163 6b28 292c p;status.back(), │ │ │ +00042fe0: 2066 6c61 6773 293b 0a09 0909 742d 2667 flags);....t-&g │ │ │ +00042ff0: 743b 636c 6561 725f 696e 5f73 7461 7465 t;clear_in_state │ │ │ +00043000: 5f75 7064 6174 6528 293b 0a09 097d 0a09 _update();...}.. │ │ │ +00043010: 0973 7461 7465 5f75 7064 6174 6573 2e63 .state_updates.c │ │ │ +00043020: 6c65 6172 2829 3b0a 0a23 6966 2054 4f52 lear();..#if TOR │ │ │ +00043030: 5245 4e54 5f55 5345 5f41 5353 4552 5453 RENT_USE_ASSERTS │ │ │ +00043040: 0a09 096d 5f70 6f73 7469 6e67 5f74 6f72 ...m_posting_tor │ │ │ +00043050: 7265 6e74 5f75 7064 6174 6573 203d 2066 rent_updates = f │ │ │ +00043060: 616c 7365 3b0a 2365 6e64 6966 0a0a 0909 alse;.#endif.... │ │ │ +00043070: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ +00043080: 5f61 6c65 7274 266c 743b 7374 6174 655f _alert<state_ │ │ │ +00043090: 7570 6461 7465 5f61 6c65 7274 2667 743b update_alert> │ │ │ +000430a0: 2873 7464 3a3a 6d6f 7665 2873 7461 7475 (std::move(statu │ │ │ +000430b0: 7329 293b 0a09 7d0a 0a09 766f 6964 2073 s));..}...void s │ │ │ +000430c0: 6573 7369 6f6e 5f69 6d70 6c3a 3a70 6f73 ession_impl::pos │ │ │ +000430d0: 745f 7365 7373 696f 6e5f 7374 6174 7328 t_session_stats( │ │ │ +000430e0: 290a 097b 0a09 0969 6620 2821 6d5f 706f )..{...if (!m_po │ │ │ +000430f0: 7374 6564 5f73 7461 7473 5f68 6561 6465 sted_stats_heade │ │ │ +00043100: 7229 0a09 097b 0a09 0909 6d5f 706f 7374 r)...{....m_post │ │ │ +00043110: 6564 5f73 7461 7473 5f68 6561 6465 7220 ed_stats_header │ │ │ +00043120: 3d20 7472 7565 3b0a 0909 096d 5f61 6c65 = true;....m_ale │ │ │ +00043130: 7274 732e 656d 706c 6163 655f 616c 6572 rts.emplace_aler │ │ │ +00043140: 7426 6c74 3b73 6573 7369 6f6e 5f73 7461 t<session_sta │ │ │ +00043150: 7473 5f68 6561 6465 725f 616c 6572 7426 ts_header_alert& │ │ │ +00043160: 6774 3b28 293b 0a09 097d 0a09 096d 5f64 gt;();...}...m_d │ │ │ +00043170: 6973 6b5f 7468 7265 6164 2d26 6774 3b75 isk_thread->u │ │ │ +00043180: 7064 6174 655f 7374 6174 735f 636f 756e pdate_stats_coun │ │ │ +00043190: 7465 7273 286d 5f73 7461 7473 5f63 6f75 ters(m_stats_cou │ │ │ +000431a0: 6e74 6572 7329 3b0a 0a23 6966 6e64 6566 nters);..#ifndef │ │ │ +000431b0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +000431c0: 5f44 4854 0a09 0969 6620 286d 5f64 6874 _DHT...if (m_dht │ │ │ +000431d0: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ +00043200: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00043210: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00043240: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ +00043250: 2e63 7070 3a35 3338 353c 2f61 3e3c 2f74 .cpp:5385factor out │ │ │ +00043270: 2074 6869 7320 6c6f 6769 6320 696e 746f this logic into │ │ │ +00043280: 2061 2073 6570 6172 6174 6520 6675 6e63 a separate func │ │ │ +00043290: 7469 6f6e 2066 6f72 2075 6e69 7420 7465 tion for unit te │ │ │ +000432a0: 7374 696e 673c 2f74 643e 3c2f 7472 3e3c sting< │ │ │ +000432b0: 7472 2069 643d 2231 3634 2220 7374 796c tr id="164" styl │ │ │ +000432c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +000432d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +000432e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000432f0: 6832 3e66 6163 746f 7220 6f75 7420 7468 h2>factor out th │ │ │ +00043300: 6973 206c 6f67 6963 2069 6e74 6f20 6120 is logic into a │ │ │ +00043310: 7365 7061 7261 7465 2066 756e 6374 696f separate functio │ │ │ +00043320: 6e20 666f 7220 756e 6974 0a74 6573 7469 n for unit.testi │ │ │ +00043330: 6e67 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ng

    ../sr │ │ │ +00043340: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00043350: 7070 3a35 3338 353c 2f68 343e 3c70 7265 pp:5385

    ..if (m_se
    │ │ │ +000433a0: 7474 696e 6773 2e67 6574 5f69 6e74 2873  ttings.get_int(s
    │ │ │ +000433b0: 6574 7469 6e67 735f 7061 636b 3a3a 6f75  ettings_pack::ou
    │ │ │ +000433c0: 7467 6f69 6e67 5f70 6f72 7429 2026 6774  tgoing_port) >
    │ │ │ +000433d0: 3b20 3029 0a09 097b 0a23 6966 6465 6620  ; 0)...{.#ifdef 
    │ │ │ +000433e0: 544f 5252 454e 545f 5749 4e44 4f57 530a  TORRENT_WINDOWS.
    │ │ │ +000433f0: 0909 0973 2e73 6574 5f6f 7074 696f 6e28  ...s.set_option(
    │ │ │ +00043400: 6578 636c 7573 6976 655f 6164 6472 6573  exclusive_addres
    │ │ │ +00043410: 735f 7573 6528 7472 7565 292c 2065 6329  s_use(true), ec)
    │ │ │ +00043420: 3b0a 2365 6c73 650a 0909 0973 2e73 6574  ;.#else....s.set
    │ │ │ +00043430: 5f6f 7074 696f 6e28 7463 703a 3a61 6363  _option(tcp::acc
    │ │ │ +00043440: 6570 746f 723a 3a72 6575 7365 5f61 6464  eptor::reuse_add
    │ │ │ +00043450: 7265 7373 2874 7275 6529 2c20 6563 293b  ress(true), ec);
    │ │ │ +00043460: 0a23 656e 6469 660a 0909 092f 2f20 6967  .#endif....// ig
    │ │ │ +00043470: 6e6f 7265 2065 7272 6f72 7320 6265 6361  nore errors beca
    │ │ │ +00043480: 7573 6520 7468 6520 756e 6465 726c 7969  use the underlyi
    │ │ │ +00043490: 6e67 2073 6f63 6b65 7420 6d61 7920 6e6f  ng socket may no
    │ │ │ +000434a0: 740a 0909 092f 2f20 6265 206f 7065 6e65  t....// be opene
    │ │ │ +000434b0: 6420 7965 742e 2054 6869 7320 6861 7070  d yet. This happ
    │ │ │ +000434c0: 656e 7320 7768 656e 2077 6527 7265 2072  ens when we're r
    │ │ │ +000434d0: 6f75 7469 6e67 2074 6872 6f75 6768 0a09  outing through..
    │ │ │ +000434e0: 0909 2f2f 2061 2070 726f 7879 2e20 496e  ..// a proxy. In
    │ │ │ +000434f0: 2074 6861 7420 6361 7365 2c20 7765 2064   that case, we d
    │ │ │ +00043500: 6f6e 2774 2079 6574 206b 6e6f 7720 7468  on't yet know th
    │ │ │ +00043510: 6520 6164 6472 6573 7320 6f66 0a09 0909  e address of....
    │ │ │ +00043520: 2f2f 2074 6865 2070 726f 7879 2073 6572  // the proxy ser
    │ │ │ +00043530: 7665 722c 2061 6e64 206d 6f72 6520 696d  ver, and more im
    │ │ │ +00043540: 706f 7274 616e 746c 792c 2077 6520 646f  portantly, we do
    │ │ │ +00043550: 6e27 7420 6b6e 6f77 0a09 0909 2f2f 2074  n't know....// t
    │ │ │ +00043560: 6865 2061 6464 7265 7373 2066 616d 696c  he address famil
    │ │ │ +00043570: 7920 6f66 2069 7473 2061 6464 7265 7373  y of its address
    │ │ │ +00043580: 2e20 5468 6973 206d 6561 6e73 2077 6520  . This means we 
    │ │ │ +00043590: 6361 6e27 740a 0909 092f 2f20 6f70 656e  can't....// open
    │ │ │ +000435a0: 2074 6865 2073 6f63 6b65 7420 7965 742e   the socket yet.
    │ │ │ +000435b0: 2054 6865 2073 6f63 6b73 2061 6273 7472   The socks abstr
    │ │ │ +000435c0: 6163 7469 6f6e 206c 6179 6572 2064 6566  action layer def
    │ │ │ +000435d0: 6572 730a 0909 092f 2f20 6f70 656e 696e  ers....// openin
    │ │ │ +000435e0: 6720 6974 2e0a 0909 0965 632e 636c 6561  g it.....ec.clea
    │ │ │ +000435f0: 7228 293b 0a09 0909 6269 6e64 5f65 702e  r();....bind_ep.
    │ │ │ +00043600: 706f 7274 2873 7464 3a3a 7569 6e74 3136  port(std::uint16
    │ │ │ +00043610: 5f74 286e 6578 745f 706f 7274 2829 2929  _t(next_port()))
    │ │ │ +00043620: 3b0a 0909 7d0a 0a09 0969 6620 2869 735f  ;...}....if (is_
    │ │ │ +00043630: 7574 7028 7329 290a 0909 7b0a 3c64 6976  utp(s))...{.
    .
    ...utp_socket_i │ │ │ +00043680: 6d70 6c2a 2069 6d70 6c20 3d20 6e75 6c6c mpl* impl = null │ │ │ +00043690: 7074 723b 0a09 0909 7472 616e 7370 6f72 ptr;....transpor │ │ │ +000436a0: 7420 7373 6c20 3d20 7472 616e 7370 6f72 t ssl = transpor │ │ │ +000436b0: 743a 3a70 6c61 696e 7465 7874 3b0a 2369 t::plaintext;.#i │ │ │ +000436c0: 6620 544f 5252 454e 545f 5553 455f 5353 f TORRENT_USE_SS │ │ │ +000436d0: 4c0a 0909 0969 6620 2873 7464 3a3a 6765 L....if (std::ge │ │ │ +000436e0: 745f 6966 266c 743b 7373 6c5f 7374 7265 t_if<ssl_stre │ │ │ +000436f0: 616d 266c 743b 7574 705f 7374 7265 616d am<utp_stream │ │ │ +00043700: 2667 743b 2667 743b 2826 616d 703b 732e >>(&s. │ │ │ +00043710: 7661 7228 2929 2021 3d20 6e75 6c6c 7074 var()) != nullpt │ │ │ +00043720: 7229 0a09 0909 7b0a 0909 0909 696d 706c r)....{.....impl │ │ │ +00043730: 203d 2073 7464 3a3a 6765 7426 6c74 3b73 = std::get<s │ │ │ +00043740: 736c 5f73 7472 6561 6d26 6c74 3b75 7470 sl_stream<utp │ │ │ +00043750: 5f73 7472 6561 6d26 6774 3b26 6774 3b28 _stream>>( │ │ │ +00043760: 7329 2e6e 6578 745f 6c61 7965 7228 292e s).next_layer(). │ │ │ +00043770: 6765 745f 696d 706c 2829 3b0a 0909 0909 get_impl();..... │ │ │ +00043780: 7373 6c20 3d20 7472 616e 7370 6f72 743a ssl = transport: │ │ │ +00043790: 3a73 736c 3b0a 0909 097d 0a09 0909 656c :ssl;....}....el │ │ │ +000437a0: 7365 0a23 656e 6469 660a 0909 0909 696d se.#endif.....im │ │ │ +000437b0: 706c 203d 2073 7464 3a3a 6765 7426 6c74 pl = std::get< │ │ │ +000437c0: 3b75 7470 5f73 7472 6561 6d26 6774 3b28 ;utp_stream>( │ │ │ +000437d0: 7329 2e67 6574 5f69 6d70 6c28 293b 0a0a s).get_impl();.. │ │ │ +000437e0: 0909 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ +000437f0: 743b 7374 643a 3a73 6861 7265 645f 7074 t;std::shared_pt │ │ │ +00043800: 7226 6c74 3b6c 6973 7465 6e5f 736f 636b r<listen_sock │ │ │ +00043810: 6574 5f74 2667 743b 2667 743b 2077 6974 et_t>> wit │ │ │ +00043820: 685f 6761 7465 7761 7973 3b0a 0909 0973 h_gateways;....s │ │ │ +00043830: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ +00043840: 743b 6c69 7374 656e 5f73 6f63 6b65 745f t;listen_socket_ │ │ │ +00043850: 7426 6774 3b20 6d61 7463 683b 0a09 0909 t> match;.... │ │ │ +00043860: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +00043870: 616d 703b 206c 7320 3a20 6d5f 6c69 7374 amp; ls : m_list │ │ │ +00043880: 656e 5f73 6f63 6b65 7473 290a 0909 097b en_sockets)....{ │ │ │ +00043890: 0a09 0909 092f 2f20 7468 6973 2069 7320 .....// this is │ │ │ +000438a0: 616c 6d6f 7374 2c20 6275 7420 6e6f 7420 almost, but not │ │ │ +000438b0: 7175 6974 652c 206c 696b 6520 6361 6e5f quite, like can_ │ │ │ +000438c0: 726f 7574 6528 290a 0909 0909 6966 2028 route().....if ( │ │ │ +000438d0: 2128 6c73 2d26 6774 3b66 6c61 6773 2026 !(ls->flags & │ │ │ +000438e0: 616d 703b 206c 6973 7465 6e5f 736f 636b amp; listen_sock │ │ │ +000438f0: 6574 5f74 3a3a 7072 6f78 7929 0a09 0909 et_t::proxy).... │ │ │ +00043900: 0909 2661 6d70 3b26 616d 703b 2069 735f ..&& is_ │ │ │ +00043910: 7634 286c 732d 2667 743b 6c6f 6361 6c5f v4(ls->local_ │ │ │ +00043920: 656e 6470 6f69 6e74 2920 213d 2072 656d endpoint) != rem │ │ │ +00043930: 6f74 655f 6164 6472 6573 732e 6973 5f76 ote_address.is_v │ │ │ +00043940: 3428 2929 0a09 0909 0909 636f 6e74 696e 4())......contin │ │ │ +00043950: 7565 3b0a 0909 0909 6966 2028 6c73 2d26 ue;.....if (ls-& │ │ │ +00043960: 6774 3b73 736c 2021 3d20 7373 6c29 2063 gt;ssl != ssl) c │ │ │ +00043970: 6f6e 7469 6e75 653b 0a09 0909 0969 6620 ontinue;.....if │ │ │ +00043980: 2821 286c 732d 2667 743b 666c 6167 7320 (!(ls->flags │ │ │ +00043990: 2661 6d70 3b20 6c69 7374 656e 5f73 6f63 & listen_soc │ │ │ +000439a0: 6b65 745f 743a 3a6c 6f63 616c 5f6e 6574 ket_t::local_net │ │ │ +000439b0: 776f 726b 2929 0a09 0909 0909 7769 7468 work))......with │ │ │ +000439c0: 5f67 6174 6577 6179 732e 7075 7368 5f62 _gateways.push_b │ │ │ +000439d0: 6163 6b28 6c73 293b 0a0a 0909 0909 6966 ack(ls);......if │ │ │ +000439e0: 2028 6c73 2d26 6774 3b66 6c61 6773 2026 (ls->flags & │ │ │ +000439f0: 616d 703b 206c 6973 7465 6e5f 736f 636b amp; listen_sock │ │ │ +00043a00: 6574 5f74 3a3a 7072 6f78 790a 0909 0909 et_t::proxy..... │ │ │ +00043a10: 097c 7c20 6d61 7463 685f 6164 6472 5f6d .|| match_addr_m │ │ │ +00043a20: 6173 6b28 6c73 2d26 6774 3b6c 6f63 616c ask(ls->local │ │ │ +00043a30: 5f65 6e64 706f 696e 742e 6164 6472 6573 _endpoint.addres │ │ │ +00043a40: 7328 292c 2072 656d 6f74 655f 6164 6472 s(), remote_addr │ │ │ +00043a50: 6573 732c 206c 732d 2667 743b 6e65 746d ess, ls->netm │ │ │ +00043a60: 6173 6b29 290a 0909 0909 7b0a 0909 0909 ask)).....{..... │ │ │ +00043a70: 092f 2f20 6973 2074 6869 7320 6265 7474 .// is this bett │ │ │ +00043a80: 6572 2074 6861 6e20 7468 6520 7072 6576 er than the prev │ │ │ +00043a90: 696f 7573 206d 6174 6368 3f0a 0909 0909 ious match?..... │ │ │ +00043aa0: 096d 6174 6368 203d 206c 733b 0a09 0909 .match = ls;.... │ │ │ +00043ab0: 097d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .}.
    │ │ │ +00043ae0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00043af0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00043b20: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +00043b30: 6c2e 6370 703a 3631 3137 3c2f 613e 3c2f l.cpp:6117refactor, │ │ │ +00043b50: 206d 6f76 6520 7468 6520 7374 6f72 6167 move the storag │ │ │ +00043b60: 6520 746f 2064 6874 5f74 7261 636b 6572 e to dht_tracker │ │ │ +00043b70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ +00043bc0: 6661 6374 6f72 2c20 6d6f 7665 2074 6865 factor, move the │ │ │ +00043bd0: 2073 746f 7261 6765 2074 6f20 6468 745f storage to dht_ │ │ │ +00043be0: 7472 6163 6b65 723c 2f68 323e 3c68 343e tracker

    │ │ │ +00043bf0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +00043c00: 6d70 6c2e 6370 703a 3631 3137 3c2f 6834 mpl.cpp:6117

    #ifnd
    │ │ │ +00043c50: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +00043c60: 4c45 5f4c 4f47 4749 4e47 0a09 0909 7365  LE_LOGGING....se
    │ │ │ +00043c70: 7373 696f 6e5f 6c6f 6728 226e 6f74 2073  ssion_log("not s
    │ │ │ +00043c80: 7461 7274 696e 6720 4448 542c 206f 7574  tarting DHT, out
    │ │ │ +00043c90: 7374 616e 6469 6e67 2072 6f75 7465 7220  standing router 
    │ │ │ +00043ca0: 6c6f 6f6b 7570 733a 2025 6422 0a09 0909  lookups: %d"....
    │ │ │ +00043cb0: 092c 206d 5f6f 7574 7374 616e 6469 6e67  ., m_outstanding
    │ │ │ +00043cc0: 5f72 6f75 7465 725f 6c6f 6f6b 7570 7329  _router_lookups)
    │ │ │ +00043cd0: 3b0a 2365 6e64 6966 0a09 0909 7265 7475  ;.#endif....retu
    │ │ │ +00043ce0: 726e 3b0a 0909 7d0a 0a09 0969 6620 286d  rn;...}....if (m
    │ │ │ +00043cf0: 5f61 626f 7274 290a 0909 7b0a 2369 666e  _abort)...{.#ifn
    │ │ │ +00043d00: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +00043d10: 424c 455f 4c4f 4747 494e 470a 0909 0973  BLE_LOGGING....s
    │ │ │ +00043d20: 6573 7369 6f6e 5f6c 6f67 2822 6e6f 7420  ession_log("not 
    │ │ │ +00043d30: 7374 6172 7469 6e67 2044 4854 2c20 6162  starting DHT, ab
    │ │ │ +00043d40: 6f72 7469 6e67 2229 3b0a 2365 6e64 6966  orting");.#endif
    │ │ │ +00043d50: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a  ....return;...}.
    │ │ │ +00043d60: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +00043d70: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ +00043d80: 0a09 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ +00043d90: 7374 6172 7469 6e67 2044 4854 2c20 7275  starting DHT, ru
    │ │ │ +00043da0: 6e6e 696e 673a 2025 732c 2072 6f75 7465  nning: %s, route
    │ │ │ +00043db0: 7220 6c6f 6f6b 7570 733a 2025 6422 0a09  r lookups: %d"..
    │ │ │ +00043dc0: 0909 2c20 6d5f 6468 7420 3f20 2274 7275  .., m_dht ? "tru
    │ │ │ +00043dd0: 6522 203a 2022 6661 6c73 6522 2c20 6d5f  e" : "false", m_
    │ │ │ +00043de0: 6f75 7473 7461 6e64 696e 675f 726f 7574  outstanding_rout
    │ │ │ +00043df0: 6572 5f6c 6f6f 6b75 7073 293b 0a23 656e  er_lookups);.#en
    │ │ │ +00043e00: 6469 660a 0a3c 6469 7620 7374 796c 653d  dif..
    ..m_dht_stora │ │ │ +00043e40: 6765 203d 206d 5f64 6874 5f73 746f 7261 ge = m_dht_stora │ │ │ +00043e50: 6765 5f63 6f6e 7374 7275 6374 6f72 286d ge_constructor(m │ │ │ +00043e60: 5f73 6574 7469 6e67 7329 3b0a 3c2f 6469 _settings);...m_dht = std: │ │ │ +00043e80: 3a6d 616b 655f 7368 6172 6564 266c 743b :make_shared< │ │ │ +00043e90: 6468 743a 3a64 6874 5f74 7261 636b 6572 dht::dht_tracker │ │ │ +00043ea0: 2667 743b 280a 0909 0973 7461 7469 635f >(....static_ │ │ │ +00043eb0: 6361 7374 266c 743b 6468 743a 3a64 6874 cast<dht::dht │ │ │ +00043ec0: 5f6f 6273 6572 7665 722a 2667 743b 2874 _observer*>(t │ │ │ +00043ed0: 6869 7329 0a09 0909 2c20 6d5f 696f 5f63 his)...., m_io_c │ │ │ +00043ee0: 6f6e 7465 7874 0a09 0909 2c20 5b74 6869 ontext...., [thi │ │ │ +00043ef0: 735d 2861 7578 3a3a 6c69 7374 656e 5f73 s](aux::listen_s │ │ │ +00043f00: 6f63 6b65 745f 6861 6e64 6c65 2063 6f6e ocket_handle con │ │ │ +00043f10: 7374 2661 6d70 3b20 736f 636b 0a09 0909 st& sock.... │ │ │ +00043f20: 092c 2075 6470 3a3a 656e 6470 6f69 6e74 ., udp::endpoint │ │ │ +00043f30: 2063 6f6e 7374 2661 6d70 3b20 6570 0a09 const& ep.. │ │ │ +00043f40: 0909 092c 2073 7061 6e26 6c74 3b63 6861 ..., span<cha │ │ │ +00043f50: 7220 636f 6e73 7426 6774 3b20 700a 0909 r const> p... │ │ │ +00043f60: 0909 2c20 6572 726f 725f 636f 6465 2661 .., error_code&a │ │ │ +00043f70: 6d70 3b20 6563 0a09 0909 092c 2075 6470 mp; ec....., udp │ │ │ +00043f80: 5f73 656e 645f 666c 6167 735f 7420 636f _send_flags_t co │ │ │ +00043f90: 6e73 7420 666c 6167 7329 0a09 0909 097b nst flags).....{ │ │ │ +00043fa0: 2073 656e 645f 7564 705f 7061 636b 6574 send_udp_packet │ │ │ +00043fb0: 5f6c 6973 7465 6e28 736f 636b 2c20 6570 _listen(sock, ep │ │ │ +00043fc0: 2c20 702c 2065 632c 2066 6c61 6773 293b , p, ec, flags); │ │ │ +00043fd0: 207d 0a09 0909 2c20 6d5f 7365 7474 696e }...., m_settin │ │ │ +00043fe0: 6773 0a09 0909 2c20 6d5f 7374 6174 735f gs...., m_stats_ │ │ │ +00043ff0: 636f 756e 7465 7273 0a09 0909 2c20 2a6d counters...., *m │ │ │ +00044000: 5f64 6874 5f73 746f 7261 6765 0a09 0909 _dht_storage.... │ │ │ +00044010: 2c20 7374 643a 3a6d 6f76 6528 6d5f 6468 , std::move(m_dh │ │ │ +00044020: 745f 7374 6174 6529 293b 0a0a 0909 666f t_state));....fo │ │ │ +00044030: 7220 2861 7574 6f26 616d 703b 2073 203a r (auto& s : │ │ │ +00044040: 206d 5f6c 6973 7465 6e5f 736f 636b 6574 m_listen_socket │ │ │ +00044050: 7329 0a09 097b 0a09 0909 6966 2028 732d s)...{....if (s- │ │ │ +00044060: 2667 743b 7373 6c20 213d 2074 7261 6e73 >ssl != trans │ │ │ +00044070: 706f 7274 3a3a 7373 6c0a 0909 0909 2661 port::ssl.....&a │ │ │ +00044080: 6d70 3b26 616d 703b 2021 2873 2d26 6774 mp;& !(s-> │ │ │ +00044090: 3b66 6c61 6773 2026 616d 703b 206c 6973 ;flags & lis │ │ │ +000440a0: 7465 6e5f 736f 636b 6574 5f74 3a3a 6c6f ten_socket_t::lo │ │ │ +000440b0: 6361 6c5f 6e65 7477 6f72 6b29 290a 0909 cal_network))... │ │ │ +000440c0: 097b 0a09 0909 096d 5f64 6874 2d26 6774 .{.....m_dht-> │ │ │ +000440d0: 3b6e 6577 5f73 6f63 6b65 7428 7329 3b0a ;new_socket(s);. │ │ │ +000440e0: 0909 097d 0a09 097d 0a0a 0909 666f 7220 ...}...}....for │ │ │ +000440f0: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ +00044100: 206e 203a 206d 5f64 6874 5f72 6f75 7465 n : m_dht_route │ │ │ +00044110: 725f 6e6f 6465 7329 0a09 097b 0a09 0909 r_nodes)...{.... │ │ │ +00044120: 6d5f 6468 742d 2667 743b 6164 645f 726f m_dht->add_ro │ │ │ +00044130: 7574 6572 5f6e 6f64 6528 6e29 3b0a 0909 uter_node(n);... │ │ │ +00044140: 7d0a 0a09 0966 6f72 2028 6175 746f 2063 }....for (auto c │ │ │ +00044150: 6f6e 7374 2661 6d70 3b20 6e20 3a20 6d5f onst& n : m_ │ │ │ +00044160: 6468 745f 6e6f 6465 7329 0a09 097b 0a3c dht_nodes)...{.< │ │ │ +00044170: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00044180: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00044190: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000441a0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000441b0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +000441e0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +000441f0: 703a 3635 3030 3c2f 613e 3c2f 7464 3e3c p:6500< │ │ │ +00044200: 7464 3e61 7373 6572 7473 2074 6861 7420 td>asserts that │ │ │ +00044210: 6e6f 206f 7574 7374 616e 6469 6e67 2061 no outstanding a │ │ │ +00044220: 7379 6e63 206f 7065 7261 7469 6f6e 7320 sync operations │ │ │ +00044230: 6172 6520 7374 696c 6c20 696e 2066 6c69 are still in fli │ │ │ +00044240: 6768 743c 2f74 643e 3c2f 7472 3e3c 7472 ght

    asserts that no │ │ │ +000442a0: 206f 7574 7374 616e 6469 6e67 2061 7379 outstanding asy │ │ │ +000442b0: 6e63 206f 7065 7261 7469 6f6e 7320 6172 nc operations ar │ │ │ +000442c0: 6520 7374 696c 6c20 696e 2066 6c69 6768 e still in fligh │ │ │ +000442d0: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ +000442e0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +000442f0: 703a 3635 3030 3c2f 6834 3e3c 7072 6520 p:6500

    ..if (!m_dh
    │ │ │ +00044340: 7429 2072 6574 7572 6e3b 0a09 096d 5f64  t) return;...m_d
    │ │ │ +00044350: 6874 2d26 6774 3b64 6972 6563 745f 7265  ht->direct_re
    │ │ │ +00044360: 7175 6573 7428 6570 2c20 652c 2073 7464  quest(ep, e, std
    │ │ │ +00044370: 3a3a 6269 6e64 2826 616d 703b 6f6e 5f64  ::bind(&on_d
    │ │ │ +00044380: 6972 6563 745f 7265 7370 6f6e 7365 2c20  irect_response, 
    │ │ │ +00044390: 7374 643a 3a72 6566 286d 5f61 6c65 7274  std::ref(m_alert
    │ │ │ +000443a0: 7329 2c20 7573 6572 6461 7461 2c20 5f31  s), userdata, _1
    │ │ │ +000443b0: 2929 3b0a 097d 0a0a 2365 6e64 6966 0a0a  ));..}..#endif..
    │ │ │ +000443c0: 0962 6f6f 6c20 7365 7373 696f 6e5f 696d  .bool session_im
    │ │ │ +000443d0: 706c 3a3a 6973 5f6c 6973 7465 6e69 6e67  pl::is_listening
    │ │ │ +000443e0: 2829 2063 6f6e 7374 0a09 7b0a 0909 7265  () const..{...re
    │ │ │ +000443f0: 7475 726e 2021 6d5f 6c69 7374 656e 5f73  turn !m_listen_s
    │ │ │ +00044400: 6f63 6b65 7473 2e65 6d70 7479 2829 3b0a  ockets.empty();.
    │ │ │ +00044410: 097d 0a0a 0973 6573 7369 6f6e 5f69 6d70  .}...session_imp
    │ │ │ +00044420: 6c3a 3a7e 7365 7373 696f 6e5f 696d 706c  l::~session_impl
    │ │ │ +00044430: 2829 0a09 7b0a 0909 2f2f 2073 696e 6365  ()..{...// since
    │ │ │ +00044440: 2077 6527 7265 2064 6573 7472 7563 7469   we're destructi
    │ │ │ +00044450: 6e67 2074 6865 2073 6573 7369 6f6e 2c20  ng the session, 
    │ │ │ +00044460: 6e6f 206d 6f72 6520 616c 6572 7473 2077  no more alerts w
    │ │ │ +00044470: 696c 6c20 6d61 6b65 2069 7420 6f75 7420  ill make it out 
    │ │ │ +00044480: 746f 0a09 092f 2f20 7468 6520 7573 6572  to...// the user
    │ │ │ +00044490: 2e20 536f 2073 746f 7020 706f 7374 696e  . So stop postin
    │ │ │ +000444a0: 6720 7468 656d 206e 6f77 0a09 096d 5f61  g them now...m_a
    │ │ │ +000444b0: 6c65 7274 732e 7365 745f 616c 6572 745f  lerts.set_alert_
    │ │ │ +000444c0: 6d61 736b 287b 7d29 3b0a 0909 6d5f 616c  mask({});...m_al
    │ │ │ +000444d0: 6572 7473 2e73 6574 5f6e 6f74 6966 795f  erts.set_notify_
    │ │ │ +000444e0: 6675 6e63 7469 6f6e 287b 7d29 3b0a 0a09  function({});...
    │ │ │ +000444f0: 092f 2f20 7468 6973 2069 7320 6e6f 7420  .// this is not 
    │ │ │ +00044500: 616c 6c6f 7765 6420 746f 2062 6520 7468  allowed to be th
    │ │ │ +00044510: 6520 6e65 7477 6f72 6b20 7468 7265 6164  e network thread
    │ │ │ +00044520: 210a 2f2f 0909 544f 5252 454e 545f 4153  !.//..TORRENT_AS
    │ │ │ +00044530: 5345 5254 2869 735f 6e6f 745f 7468 7265  SERT(is_not_thre
    │ │ │ +00044540: 6164 2829 293b 0a3c 6469 7620 7374 796c  ad());.
    .
    ..// │ │ │ +00044580: 2074 6869 7320 6361 6e20 6861 7070 656e this can happen │ │ │ +00044590: 2069 6620 7765 2065 6e64 2074 6865 2069 if we end the i │ │ │ +000445a0: 6f5f 636f 6e74 6578 7420 7275 6e20 6c6f o_context run lo │ │ │ +000445b0: 6f70 2077 6974 6820 616e 2065 7863 6570 op with an excep │ │ │ +000445c0: 7469 6f6e 0a09 096d 5f63 6f6e 6e65 6374 tion...m_connect │ │ │ +000445d0: 696f 6e73 2e63 6c65 6172 2829 3b0a 0909 ions.clear();... │ │ │ +000445e0: 666f 7220 2861 7574 6f26 616d 703b 2074 for (auto& t │ │ │ +000445f0: 203a 206d 5f74 6f72 7265 6e74 7329 0a09 : m_torrents).. │ │ │ +00044600: 097b 0a09 0909 742d 2667 743b 7061 6e69 .{....t->pani │ │ │ +00044610: 6328 293b 0a09 0909 742d 2667 743b 6162 c();....t->ab │ │ │ +00044620: 6f72 7428 293b 0a09 097d 0a09 096d 5f74 ort();...}...m_t │ │ │ +00044630: 6f72 7265 6e74 732e 636c 6561 7228 293b orrents.clear(); │ │ │ +00044640: 0a0a 0909 2f2f 2074 6869 7320 6861 7320 ....// this has │ │ │ +00044650: 7072 6f62 6162 6c79 2062 6565 6e20 6361 probably been ca │ │ │ +00044660: 6c6c 6564 2061 6c72 6561 6479 2c20 6275 lled already, bu │ │ │ +00044670: 7420 696e 2063 6173 6520 6f66 2073 7564 t in case of sud │ │ │ +00044680: 6465 6e0a 0909 2f2f 2074 6572 6d69 6e61 den...// termina │ │ │ +00044690: 7469 6f6e 2074 6872 6f75 6768 2061 6e20 tion through an │ │ │ +000446a0: 6578 6365 7074 696f 6e2c 2069 7420 6d61 exception, it ma │ │ │ +000446b0: 7920 6e6f 7420 6861 7665 2062 6565 6e20 y not have been │ │ │ +000446c0: 646f 6e65 0a09 0961 626f 7274 5f73 7461 done...abort_sta │ │ │ +000446d0: 6765 3228 293b 0a0a 2369 6620 6465 6669 ge2();..#if defi │ │ │ +000446e0: 6e65 6420 544f 5252 454e 545f 4153 494f ned TORRENT_ASIO │ │ │ +000446f0: 5f44 4542 5547 4749 4e47 0a09 0946 494c _DEBUGGING...FIL │ │ │ +00044700: 452a 2066 203d 2066 6f70 656e 2822 7761 E* f = fopen("wa │ │ │ +00044710: 6b65 7570 732e 6c6f 6722 2c20 2277 2b22 keups.log", "w+" │ │ │ +00044720: 293b 0a09 0969 6620 2866 2021 3d20 6e75 );...if (f != nu │ │ │ +00044730: 6c6c 7074 7229 0a09 097b 0a09 0909 7469 llptr)...{....ti │ │ │ +00044740: 6d65 5f70 6f69 6e74 206d 203d 206d 696e me_point m = min │ │ │ +00044750: 5f74 696d 6528 293b 0a09 0909 6966 2028 _time();....if ( │ │ │ +00044760: 215f 7761 6b65 7570 732e 656d 7074 7928 !_wakeups.empty( │ │ │ +00044770: 2929 206d 203d 205f 7761 6b65 7570 735b )) m = _wakeups[ │ │ │ +00044780: 305d 2e74 696d 6573 7461 6d70 3b0a 0909 0].timestamp;... │ │ │ +00044790: 0974 696d 655f 706f 696e 7420 7072 6576 .time_point prev │ │ │ +000447a0: 203d 206d 3b0a 0909 0973 7464 3a3a 7569 = m;....std::ui │ │ │ +000447b0: 6e74 3634 5f74 2070 7265 765f 6373 7720 nt64_t prev_csw │ │ │ +000447c0: 3d20 303b 0a09 0909 6966 2028 215f 7761 = 0;....if (!_wa │ │ │ +000447d0: 6b65 7570 732e 656d 7074 7928 2929 2070 keups.empty()) p │ │ │ +000447e0: 7265 765f 6373 7720 3d20 5f77 616b 6575 rev_csw = _wakeu │ │ │ +000447f0: 7073 5b30 5d2e 636f 6e74 6578 745f 7377 ps[0].context_sw │ │ │ +00044800: 6974 6368 6573 3b0a 0909 0973 7464 3a3a itches;....std:: │ │ │ +00044810: 6670 7269 6e74 6628 662c 2022 6162 732e fprintf(f, "abs. │ │ │ +00044820: 2074 696d 655c 7472 656c 2e20 7469 6d65 time\trel. time │ │ │ +00044830: 5c74 6374 7820 7377 6974 6368 5c74 6964 \tctx switch\tid │ │ │ +00044840: 6c65 2d77 616b 6575 705c 746f 7065 7261 le-wakeup\topera │ │ │ +00044850: 7469 6f6e 5c6e 2229 3b0a 0909 0966 6f72 tion\n");....for │ │ │ +00044860: 2028 7761 6b65 7570 5f74 2063 6f6e 7374 (wakeup_t const │ │ │ +00044870: 2661 6d70 3b20 7720 3a20 5f77 616b 6575 & w : _wakeu │ │ │ +00044880: 7073 290a 0909 097b 0a09 0909 0962 6f6f ps)....{.....boo │ │ │ +00044890: 6c20 636f 6e73 7420 6964 6c65 5f77 616b l const idle_wak │ │ │ +000448a0: 6575 7020 3d20 772e 636f 6e74 6578 745f eup = w.context_ │ │ │ +000448b0: 7377 6974 6368 6573 2026 6774 3b20 7072 switches > pr │ │ │ +000448c0: 6576 5f63 7377 3b0a 0909 0909 7374 643a ev_csw;.....std: │ │ │ +000448d0: 3a66 7072 696e 7466 2866 2c20 2225 2220 :fprintf(f, "%" │ │ │ +000448e0: 5052 4964 3634 2022 5c74 2522 2050 5249 PRId64 "\t%" PRI │ │ │ +000448f0: 6436 3420 225c 7425 2220 5052 4964 3634 d64 "\t%" PRId64 │ │ │ +00044900: 2022 5c74 2563 5c74 2573 5c6e 220a 0909 "\t%c\t%s\n"... │ │ │ +00044910: 0909 092c 2074 6f74 616c 5f6d 6963 726f ..., total_micro │ │ │ +00044920: 7365 636f 6e64 7328 772e 7469 6d65 7374 seconds(w.timest │ │ │ +00044930: 616d 7020 2d20 6d29 0a09 0909 0909 2c20 amp - m)......, │ │ │ +00044940: 746f 7461 6c5f 6d69 6372 6f73 6563 6f6e total_microsecon │ │ │ +00044950: 6473 2877 2e74 696d 6573 7461 6d70 202d ds(w.timestamp - │ │ │ +00044960: 2070 7265 7629 0a09 0909 0909 2c20 772e prev)......, w. │ │ │ +00044970: 636f 6e74 6578 745f 7377 6974 6368 6573 context_switches │ │ │ +00044980: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000449c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +000449f0: 7263 2f75 6470 5f73 6f63 6b65 742e 6370 rc/udp_socket.cp │ │ │ +00044a00: 703a 3634 333c 2f61 3e3c 2f74 643e 3c74 p:643perhaps an att │ │ │ +00044a20: 656d 7074 2073 686f 756c 6420 6265 206d empt should be m │ │ │ +00044a30: 6164 6520 746f 2062 696e 6420 6d5f 736f ade to bind m_so │ │ │ +00044a40: 636b 7335 5f73 6f63 6b20 746f 2074 6865 cks5_sock to the │ │ │ +00044a50: 2064 6576 6963 6520 6f66 206d 5f6c 6973 device of m_lis │ │ │ +00044a60: 7465 6e5f 736f 636b 6574 3c2f 7464 3e3c ten_socket< │ │ │ +00044a70: 2f74 723e 3c74 7220 6964 3d22 3136 3722 /tr>

    perhaps │ │ │ +00044ac0: 616e 2061 7474 656d 7074 2073 686f 756c an attempt shoul │ │ │ +00044ad0: 6420 6265 206d 6164 6520 746f 2062 696e d be made to bin │ │ │ +00044ae0: 6420 6d5f 736f 636b 7335 5f73 6f63 6b20 d m_socks5_sock │ │ │ +00044af0: 746f 2074 6865 0a64 6576 6963 6520 6f66 to the.device of │ │ │ +00044b00: 206d 5f6c 6973 7465 6e5f 736f 636b 6574 m_listen_socket │ │ │ +00044b10: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00044b20: 7564 705f 736f 636b 6574 2e63 7070 3a36 udp_socket.cpp:6 │ │ │ +00044b30: 3433 3c2f 6834 3e3c 7072 6520 7374 796c 43

    .if (ec)..{...i
    │ │ │ +00044b80: 6620 286d 5f61 6c65 7274 732e 7368 6f75  f (m_alerts.shou
    │ │ │ +00044b90: 6c64 5f70 6f73 7426 6c74 3b73 6f63 6b73  ld_post<socks
    │ │ │ +00044ba0: 355f 616c 6572 7426 6774 3b28 2929 0a09  5_alert>())..
    │ │ │ +00044bb0: 0909 6d5f 616c 6572 7473 2e65 6d70 6c61  ..m_alerts.empla
    │ │ │ +00044bc0: 6365 5f61 6c65 7274 266c 743b 736f 636b  ce_alert<sock
    │ │ │ +00044bd0: 7335 5f61 6c65 7274 2667 743b 286d 5f70  s5_alert>(m_p
    │ │ │ +00044be0: 726f 7879 5f61 6464 722c 206f 7065 7261  roxy_addr, opera
    │ │ │ +00044bf0: 7469 6f6e 5f74 3a3a 736f 636b 5f6f 7074  tion_t::sock_opt
    │ │ │ +00044c00: 696f 6e2c 2065 6329 3b0a 0909 6563 2e63  ion, ec);...ec.c
    │ │ │ +00044c10: 6c65 6172 2829 3b0a 097d 0a23 656e 6469  lear();..}.#endi
    │ │ │ +00044c20: 660a 2365 6e64 6966 0a0a 0974 6370 3a3a  f.#endif...tcp::
    │ │ │ +00044c30: 656e 6470 6f69 6e74 2063 6f6e 7374 2062  endpoint const b
    │ │ │ +00044c40: 696e 645f 6570 286d 5f6c 6973 7465 6e5f  ind_ep(m_listen_
    │ │ │ +00044c50: 736f 636b 6574 2e67 6574 5f6c 6f63 616c  socket.get_local
    │ │ │ +00044c60: 5f65 6e64 706f 696e 7428 292e 6164 6472  _endpoint().addr
    │ │ │ +00044c70: 6573 7328 292c 2030 293b 0a09 6d5f 736f  ess(), 0);..m_so
    │ │ │ +00044c80: 636b 7335 5f73 6f63 6b2e 6269 6e64 2862  cks5_sock.bind(b
    │ │ │ +00044c90: 696e 645f 6570 2c20 6563 293b 0a09 6966  ind_ep, ec);..if
    │ │ │ +00044ca0: 2028 6563 290a 097b 0a09 0969 6620 286d   (ec)..{...if (m
    │ │ │ +00044cb0: 5f61 6c65 7274 732e 7368 6f75 6c64 5f70  _alerts.should_p
    │ │ │ +00044cc0: 6f73 7426 6c74 3b73 6f63 6b73 355f 616c  ost<socks5_al
    │ │ │ +00044cd0: 6572 7426 6774 3b28 2929 0a09 0909 6d5f  ert>())....m_
    │ │ │ +00044ce0: 616c 6572 7473 2e65 6d70 6c61 6365 5f61  alerts.emplace_a
    │ │ │ +00044cf0: 6c65 7274 266c 743b 736f 636b 7335 5f61  lert<socks5_a
    │ │ │ +00044d00: 6c65 7274 2667 743b 286d 5f70 726f 7879  lert>(m_proxy
    │ │ │ +00044d10: 5f61 6464 722c 206f 7065 7261 7469 6f6e  _addr, operation
    │ │ │ +00044d20: 5f74 3a3a 736f 636b 5f62 696e 642c 2065  _t::sock_bind, e
    │ │ │ +00044d30: 6329 3b0a 0909 2b2b 6d5f 6661 696c 7572  c);...++m_failur
    │ │ │ +00044d40: 6573 3b0a 0909 7265 7472 795f 636f 6e6e  es;...retry_conn
    │ │ │ +00044d50: 6563 7469 6f6e 2829 3b0a 0909 7265 7475  ection();...retu
    │ │ │ +00044d60: 726e 3b0a 097d 0a0a 3c64 6976 2073 7479  rn;..}..
    .
    .AD │ │ │ +00044da0: 445f 4f55 5453 5441 4e44 494e 475f 4153 D_OUTSTANDING_AS │ │ │ +00044db0: 594e 4328 2273 6f63 6b73 353a 3a6f 6e5f YNC("socks5::on_ │ │ │ +00044dc0: 636f 6e6e 6563 7465 6422 293b 0a09 6d5f connected");..m_ │ │ │ +00044dd0: 736f 636b 7335 5f73 6f63 6b2e 6173 796e socks5_sock.asyn │ │ │ +00044de0: 635f 636f 6e6e 6563 7428 6d5f 7072 6f78 c_connect(m_prox │ │ │ +00044df0: 795f 6164 6472 0a09 092c 2073 7464 3a3a y_addr..., std:: │ │ │ +00044e00: 6269 6e64 2826 616d 703b 736f 636b 7335 bind(&socks5 │ │ │ +00044e10: 3a3a 6f6e 5f63 6f6e 6e65 6374 6564 2c20 ::on_connected, │ │ │ +00044e20: 7365 6c66 2829 2c20 5f31 2929 3b0a 0a09 self(), _1));... │ │ │ +00044e30: 4144 445f 4f55 5453 5441 4e44 494e 475f ADD_OUTSTANDING_ │ │ │ +00044e40: 4153 594e 4328 2273 6f63 6b73 353a 3a6f ASYNC("socks5::o │ │ │ +00044e50: 6e5f 636f 6e6e 6563 745f 7469 6d65 6f75 n_connect_timeou │ │ │ +00044e60: 7422 293b 0a09 6d5f 7469 6d65 722e 6578 t");..m_timer.ex │ │ │ +00044e70: 7069 7265 735f 6166 7465 7228 7365 636f pires_after(seco │ │ │ +00044e80: 6e64 7328 3130 2929 3b0a 096d 5f74 696d nds(10));..m_tim │ │ │ +00044e90: 6572 2e61 7379 6e63 5f77 6169 7428 7374 er.async_wait(st │ │ │ +00044ea0: 643a 3a62 696e 6428 2661 6d70 3b73 6f63 d::bind(&soc │ │ │ +00044eb0: 6b73 353a 3a6f 6e5f 636f 6e6e 6563 745f ks5::on_connect_ │ │ │ +00044ec0: 7469 6d65 6f75 740a 0909 2c20 7365 6c66 timeout..., self │ │ │ +00044ed0: 2829 2c20 5f31 2929 3b0a 7d0a 0a76 6f69 (), _1));.}..voi │ │ │ +00044ee0: 6420 736f 636b 7335 3a3a 6f6e 5f63 6f6e d socks5::on_con │ │ │ +00044ef0: 6e65 6374 5f74 696d 656f 7574 2865 7272 nect_timeout(err │ │ │ +00044f00: 6f72 5f63 6f64 6520 636f 6e73 7426 616d or_code const&am │ │ │ +00044f10: 703b 2065 290a 7b0a 0943 4f4d 504c 4554 p; e).{..COMPLET │ │ │ +00044f20: 455f 4153 594e 4328 2273 6f63 6b73 353a E_ASYNC("socks5: │ │ │ +00044f30: 3a6f 6e5f 636f 6e6e 6563 745f 7469 6d65 :on_connect_time │ │ │ +00044f40: 6f75 7422 293b 0a0a 0969 6620 2865 203d out");...if (e = │ │ │ +00044f50: 3d20 626f 6f73 743a 3a61 7369 6f3a 3a65 = boost::asio::e │ │ │ +00044f60: 7272 6f72 3a3a 6f70 6572 6174 696f 6e5f rror::operation_ │ │ │ +00044f70: 6162 6f72 7465 6429 2072 6574 7572 6e3b aborted) return; │ │ │ +00044f80: 0a0a 0969 6620 286d 5f61 626f 7274 2920 ...if (m_abort) │ │ │ +00044f90: 7265 7475 726e 3b0a 0a09 6966 2028 6d5f return;...if (m_ │ │ │ +00044fa0: 616c 6572 7473 2e73 686f 756c 645f 706f alerts.should_po │ │ │ +00044fb0: 7374 266c 743b 736f 636b 7335 5f61 6c65 st<socks5_ale │ │ │ +00044fc0: 7274 2667 743b 2829 290a 0909 6d5f 616c rt>())...m_al │ │ │ +00044fd0: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65 erts.emplace_ale │ │ │ +00044fe0: 7274 266c 743b 736f 636b 7335 5f61 6c65 rt<socks5_ale │ │ │ +00044ff0: 7274 2667 743b 286d 5f70 726f 7879 5f61 rt>(m_proxy_a │ │ │ +00045000: 6464 722c 206f 7065 7261 7469 6f6e 5f74 ddr, operation_t │ │ │ +00045010: 3a3a 636f 6e6e 6563 742c 2065 7272 6f72 ::connect, error │ │ │ +00045020: 733a 3a74 696d 6564 5f6f 7574 293b 0a0a s::timed_out);.. │ │ │ +00045030: 0965 7272 6f72 5f63 6f64 6520 6967 6e6f .error_code igno │ │ │ +00045040: 7265 3b0a 096d 5f73 6f63 6b73 355f 736f re;..m_socks5_so │ │ │ +00045050: 636b 2e63 6c6f 7365 2869 676e 6f72 6529 ck.close(ignore) │ │ │ +00045060: 3b0a 0a09 2b2b 6d5f 6661 696c 7572 6573 ;...++m_failures │ │ │ +00045070: 3b0a 0972 6574 7279 5f63 6f6e 6e65 6374 ;..retry_connect │ │ │ +00045080: 696f 6e28 293b 0a7d 0a0a 766f 6964 2073 ion();.}..void s │ │ │ +00045090: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563 ocks5::on_connec │ │ │ +000450a0: 7465 6428 6572 726f 725f 636f 6465 2063 ted(error_code c │ │ │ +000450b0: 6f6e 7374 2661 6d70 3b20 6529 0a7b 0a3c onst& e).{.< │ │ │ +000450c0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +000450d0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000450e0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000450f0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00045100: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00045130: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ +00045140: 2e63 7070 3a31 3038 373c 2f61 3e3c 2f74 .cpp:1087this shoul │ │ │ +00045160: 6420 6265 2074 6865 2067 6c6f 6261 6c20 d be the global │ │ │ +00045170: 646f 776e 6c6f 6164 2072 6174 653c 2f74 download rate

    this │ │ │ +000451d0: 7368 6f75 6c64 2062 6520 7468 6520 676c should be the gl │ │ │ +000451e0: 6f62 616c 2064 6f77 6e6c 6f61 6420 7261 obal download ra │ │ │ +000451f0: 7465 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 te

    ../sr │ │ │ +00045200: 632f 7065 6572 5f63 6f6e 6e65 6374 696f c/peer_connectio │ │ │ +00045210: 6e2e 6370 703a 3130 3837 3c2f 6834 3e3c n.cpp:1087

    < │ │ │ +00045220: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00045230: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00045240: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00045250: 7820 2364 6464 3b22 3e0a 0909 696e 7420 x #ddd;">...int │ │ │ +00045260: 7261 7465 203d 2030 3b0a 0a09 092f 2f20 rate = 0;....// │ │ │ +00045270: 6966 2077 6520 6861 7665 6e27 7420 7265 if we haven't re │ │ │ +00045280: 6365 6976 6564 2061 6e79 2064 6174 6120 ceived any data │ │ │ +00045290: 7265 6365 6e74 6c79 2c20 7468 6520 6375 recently, the cu │ │ │ +000452a0: 7272 656e 7420 646f 776e 6c6f 6164 2072 rrent download r │ │ │ +000452b0: 6174 650a 0909 2f2f 2069 7320 6e6f 7420 ate...// is not │ │ │ +000452c0: 7265 7072 6573 656e 7461 7469 7665 0a09 representative.. │ │ │ +000452d0: 0969 6620 2861 7578 3a3a 7469 6d65 5f6e .if (aux::time_n │ │ │ +000452e0: 6f77 2829 202d 206d 5f6c 6173 745f 7069 ow() - m_last_pi │ │ │ +000452f0: 6563 652e 6765 7428 6d5f 636f 6e6e 6563 ece.get(m_connec │ │ │ +00045300: 7429 2026 6774 3b20 7365 636f 6e64 7328 t) > seconds( │ │ │ +00045310: 3330 2920 2661 6d70 3b26 616d 703b 206d 30) && m │ │ │ +00045320: 5f64 6f77 6e6c 6f61 645f 7261 7465 5f70 _download_rate_p │ │ │ +00045330: 6561 6b20 2667 743b 2030 290a 0909 7b0a eak > 0)...{. │ │ │ +00045340: 0909 0972 6174 6520 3d20 6d5f 646f 776e ...rate = m_down │ │ │ +00045350: 6c6f 6164 5f72 6174 655f 7065 616b 3b0a load_rate_peak;. │ │ │ +00045360: 0909 7d0a 0909 656c 7365 2069 6620 2861 ..}...else if (a │ │ │ +00045370: 7578 3a3a 7469 6d65 5f6e 6f77 2829 202d ux::time_now() - │ │ │ +00045380: 206d 5f6c 6173 745f 756e 6368 6f6b 6564 m_last_unchoked │ │ │ +00045390: 2e67 6574 286d 5f63 6f6e 6e65 6374 2920 .get(m_connect) │ │ │ +000453a0: 266c 743b 2073 6563 6f6e 6473 2835 290a < seconds(5). │ │ │ +000453b0: 0909 0926 616d 703b 2661 6d70 3b20 6d5f ...&& m_ │ │ │ +000453c0: 7374 6174 6973 7469 6373 2e74 6f74 616c statistics.total │ │ │ +000453d0: 5f70 6179 6c6f 6164 5f75 706c 6f61 6428 _payload_upload( │ │ │ +000453e0: 2920 266c 743b 2032 202a 2030 7834 3030 ) < 2 * 0x400 │ │ │ +000453f0: 3029 0a09 097b 0a09 0909 2f2f 2069 6620 0)...{....// if │ │ │ +00045400: 7765 2772 6520 6861 7665 206f 6e6c 7920 we're have only │ │ │ +00045410: 6265 656e 2075 6e63 686f 6b65 6420 666f been unchoked fo │ │ │ +00045420: 7220 6120 7368 6f72 7420 7065 7269 6f64 r a short period │ │ │ +00045430: 206f 6620 7469 6d65 2c0a 0909 092f 2f20 of time,....// │ │ │ +00045440: 7765 2064 6f6e 2774 206b 6e6f 7720 7768 we don't know wh │ │ │ +00045450: 6174 2072 6174 6520 7765 2063 616e 2067 at rate we can g │ │ │ +00045460: 6574 2066 726f 6d20 7468 6973 2070 6565 et from this pee │ │ │ +00045470: 722e 2049 6e73 7465 6164 206f 6620 6173 r. Instead of as │ │ │ +00045480: 7375 6d69 6e67 0a09 0909 2f2f 2074 6865 suming....// the │ │ │ +00045490: 206c 6f77 6573 7420 706f 7373 6962 6c65 lowest possible │ │ │ +000454a0: 2072 6174 652c 2061 7373 756d 6520 7468 rate, assume th │ │ │ +000454b0: 6520 6176 6572 6167 652e 0a0a 0909 0969 e average......i │ │ │ +000454c0: 6e74 2070 6565 7273 5f77 6974 685f 7265 nt peers_with_re │ │ │ +000454d0: 7175 6573 7473 203d 2069 6e74 2873 7461 quests = int(sta │ │ │ +000454e0: 7473 5f63 6f75 6e74 6572 7328 295b 636f ts_counters()[co │ │ │ +000454f0: 756e 7465 7273 3a3a 6e75 6d5f 7065 6572 unters::num_peer │ │ │ +00045500: 735f 646f 776e 5f72 6571 7565 7374 735d s_down_requests] │ │ │ +00045510: 293b 0a09 0909 2f2f 2061 766f 6964 2064 );....// avoid d │ │ │ +00045520: 6976 6973 696f 6e20 6279 2030 0a09 0909 ivision by 0.... │ │ │ +00045530: 6966 2028 7065 6572 735f 7769 7468 5f72 if (peers_with_r │ │ │ +00045540: 6571 7565 7374 7320 3d3d 2030 2920 7065 equests == 0) pe │ │ │ +00045550: 6572 735f 7769 7468 5f72 6571 7565 7374 ers_with_request │ │ │ +00045560: 7320 3d20 313b 0a0a 3c64 6976 2073 7479 s = 1;..
    ...rate = │ │ │ +000455a0: 742d 2667 743b 7374 6174 6973 7469 6373 t->statistics │ │ │ +000455b0: 2829 2e74 7261 6e73 6665 725f 7261 7465 ().transfer_rate │ │ │ +000455c0: 2861 7578 3a3a 7374 6174 3a3a 646f 776e (aux::stat::down │ │ │ +000455d0: 6c6f 6164 5f70 6179 6c6f 6164 2920 2f20 load_payload) / │ │ │ +000455e0: 7065 6572 735f 7769 7468 5f72 6571 7565 peers_with_reque │ │ │ +000455f0: 7374 733b 0a3c 2f64 6976 3e09 097d 0a09 sts;.
    ..}.. │ │ │ +00045600: 0965 6c73 650a 0909 7b0a 0909 092f 2f20 .else...{....// │ │ │ +00045610: 6375 7272 656e 7420 646f 776e 6c6f 6164 current download │ │ │ +00045620: 2072 6174 6520 696e 2062 7974 6573 2070 rate in bytes p │ │ │ +00045630: 6572 2073 6563 6f6e 6473 0a09 0909 7261 er seconds....ra │ │ │ +00045640: 7465 203d 206d 5f73 7461 7469 7374 6963 te = m_statistic │ │ │ +00045650: 732e 7472 616e 7366 6572 5f72 6174 6528 s.transfer_rate( │ │ │ +00045660: 6175 783a 3a73 7461 743a 3a64 6f77 6e6c aux::stat::downl │ │ │ +00045670: 6f61 645f 7061 796c 6f61 6429 3b0a 0909 oad_payload);... │ │ │ +00045680: 7d0a 0a09 092f 2f20 6176 6f69 6420 6469 }....// avoid di │ │ │ +00045690: 7669 7369 6f6e 2062 7920 7a65 726f 0a09 vision by zero.. │ │ │ +000456a0: 0969 6620 2872 6174 6520 266c 743b 2035 .if (rate < 5 │ │ │ +000456b0: 3029 2072 6174 6520 3d20 3530 3b0a 0a09 0) rate = 50;... │ │ │ +000456c0: 092f 2f20 6176 6572 6167 6520 6f66 2063 .// average of c │ │ │ +000456d0: 7572 7265 6e74 2072 6174 6520 616e 6420 urrent rate and │ │ │ +000456e0: 7065 616b 0a2f 2f09 0972 6174 6520 3d20 peak.//..rate = │ │ │ +000456f0: 2872 6174 6520 2b20 6d5f 646f 776e 6c6f (rate + m_downlo │ │ │ +00045700: 6164 5f72 6174 655f 7065 616b 2920 2f20 ad_rate_peak) / │ │ │ +00045710: 323b 0a0a 0909 7265 7475 726e 206d 696c 2;....return mil │ │ │ +00045720: 6c69 7365 636f 6e64 7328 2873 7464 3a3a liseconds((std:: │ │ │ +00045730: 696e 7436 345f 7428 6d5f 6f75 7473 7461 int64_t(m_outsta │ │ │ +00045740: 6e64 696e 675f 6279 7465 7329 202b 2065 nding_bytes) + e │ │ │ +00045750: 7874 7261 5f62 7974 6573 0a09 0909 0909 xtra_bytes...... │ │ │ +00045760: 0909 092b 2073 7464 3a3a 696e 7436 345f ...+ std::int64_ │ │ │ +00045770: 7428 6d5f 7175 6575 6564 5f74 696d 655f t(m_queued_time_ │ │ │ +00045780: 6372 6974 6963 616c 2920 2a20 742d 2667 critical) * t-&g │ │ │ +00045790: 743b 626c 6f63 6b5f 7369 7a65 2829 202a t;block_size() * │ │ │ +000457a0: 2031 3030 3029 0a09 0909 2f20 7261 7465 1000)..../ rate │ │ │ +000457b0: 293b 0a09 7d0a 0a09 766f 6964 2070 6565 );..}...void pee │ │ │ +000457c0: 725f 636f 6e6e 6563 7469 6f6e 3a3a 6164 r_connection::ad │ │ │ +000457d0: 645f 7374 6174 2873 7464 3a3a 696e 7436 d_stat(std::int6 │ │ │ +000457e0: 345f 7420 636f 6e73 7420 646f 776e 6c6f 4_t const downlo │ │ │ +000457f0: 6164 6564 2c20 7374 643a 3a69 6e74 3634 aded, std::int64 │ │ │ +00045800: 5f74 2063 6f6e 7374 2075 706c 6f61 6465 _t const uploade │ │ │ +00045810: 6429 0a09 7b0a 0909 544f 5252 454e 545f d)..{...TORRENT_ │ │ │ +00045820: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ +00045830: 5f74 6872 6561 6428 2929 3b0a 0909 6d5f _thread());...m_ │ │ │ +00045840: 7374 6174 6973 7469 6373 2e61 6464 5f73 statistics.add_s │ │ │ +00045850: 7461 7428 646f 776e 6c6f 6164 6564 2c20 tat(downloaded, │ │ │ +00045860: 7570 6c6f 6164 6564 293b 0a09 7d0a 0a09 uploaded);..}... │ │ │ +00045870: 7368 6131 5f68 6173 6820 7065 6572 5f63 sha1_hash peer_c │ │ │ +00045880: 6f6e 6e65 6374 696f 6e3a 3a61 7373 6f63 onnection::assoc │ │ │ +00045890: 6961 7465 645f 696e 666f 5f68 6173 6828 iated_info_hash( │ │ │ +000458a0: 2920 636f 6e73 740a 097b 0a09 0961 7574 ) const..{...aut │ │ │ +000458b0: 6f20 7420 3d20 6173 736f 6369 6174 6564 o t = associated │ │ │ +000458c0: 5f74 6f72 7265 6e74 2829 2e6c 6f63 6b28 _torrent().lock( │ │ │ +000458d0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +000458e0: 4552 5428 7429 3b0a 0909 6175 746f 2063 ERT(t);...auto c │ │ │ +000458f0: 6f6e 7374 2661 6d70 3b20 6968 203d 2074 onst& ih = t │ │ │ +00045900: 2d26 6774 3b69 6e66 6f5f 6861 7368 2829 ->info_hash() │ │ │ +00045910: 3b0a 0909 2f2f 2061 2070 6565 7227 7320 ;...// a peer's │ │ │ +00045920: 7072 6f74 6f63 6f6c 5f76 3220 666c 6167 protocol_v2 flag │ │ │ +00045930: 206d 6179 2062 6520 7365 7420 7370 6563 may be set spec │ │ │ +00045940: 756c 6174 6976 656c 7920 7768 696c 6520 ulatively while │ │ │ +00045950: 6d65 7461 6461 7461 0a3c 2f70 7265 3e3c metadata.
    < │ │ │ +00045960: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00045990: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +000459a0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/peer_ │ │ │ +000459d0: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a31 connection.cpp:1 │ │ │ +000459e0: 3139 323c 2f61 3e3c 2f74 643e 3c74 643e 192 │ │ │ +000459f0: 7374 6f72 6520 7468 6520 7361 6832 3536 store the sah256 │ │ │ +00045a00: 2068 6173 6820 6f66 2074 6865 2064 6573 hash of the des │ │ │ +00045a10: 7469 6e61 7469 6f6e 2069 6e20 7468 6520 tination in the │ │ │ +00045a20: 6932 705f 7065 6572 2073 7472 7563 742c i2p_peer struct, │ │ │ +00045a30: 2073 6f20 7765 2064 6f6e 2774 2068 6176 so we don't hav │ │ │ +00045a40: 6520 746f 2072 6563 6f6d 7075 7465 2069 e to recompute i │ │ │ +00045a50: 7420 6576 6572 7920 7469 6d65 3c2f 7464 t every time

    store │ │ │ +00045ab0: 7468 6520 7361 6832 3536 2068 6173 6820 the sah256 hash │ │ │ +00045ac0: 6f66 2074 6865 2064 6573 7469 6e61 7469 of the destinati │ │ │ +00045ad0: 6f6e 2069 6e20 7468 650a 6932 705f 7065 on in the.i2p_pe │ │ │ +00045ae0: 6572 2073 7472 7563 742c 2073 6f20 7765 er struct, so we │ │ │ +00045af0: 2064 6f6e 2774 2068 6176 6520 746f 2072 don't have to r │ │ │ +00045b00: 6563 6f6d 7075 7465 2069 7420 6576 6572 ecompute it ever │ │ │ +00045b10: 7920 7469 6d65 3c2f 6832 3e3c 6834 3e2e y time

    . │ │ │ +00045b20: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +00045b30: 6374 696f 6e2e 6370 703a 3131 3932 3c2f ction.cpp:1192
    ..a
    │ │ │ +00045b80: 7574 6f20 7420 3d20 6d5f 746f 7272 656e  uto t = m_torren
    │ │ │ +00045b90: 742e 6c6f 636b 2829 3b0a 0909 6966 2028  t.lock();...if (
    │ │ │ +00045ba0: 2174 2920 7265 7475 726e 3b0a 0909 742d  !t) return;...t-
    │ │ │ +00045bb0: 2667 743b 7365 6e74 5f73 796e 2869 7076  >sent_syn(ipv
    │ │ │ +00045bc0: 3629 3b0a 097d 0a0a 0976 6f69 6420 7065  6);..}...void pe
    │ │ │ +00045bd0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a72  er_connection::r
    │ │ │ +00045be0: 6563 6569 7665 645f 7379 6e61 636b 2862  eceived_synack(b
    │ │ │ +00045bf0: 6f6f 6c20 636f 6e73 7420 6970 7636 290a  ool const ipv6).
    │ │ │ +00045c00: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +00045c10: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ +00045c20: 7265 6164 2829 293b 0a09 096d 5f73 7461  read());...m_sta
    │ │ │ +00045c30: 7469 7374 6963 732e 7265 6365 6976 6564  tistics.received
    │ │ │ +00045c40: 5f73 796e 6163 6b28 6970 7636 293b 0a09  _synack(ipv6);..
    │ │ │ +00045c50: 0969 6620 286d 5f69 676e 6f72 655f 7374  .if (m_ignore_st
    │ │ │ +00045c60: 6174 7329 2072 6574 7572 6e3b 0a09 0961  ats) return;...a
    │ │ │ +00045c70: 7574 6f20 7420 3d20 6d5f 746f 7272 656e  uto t = m_torren
    │ │ │ +00045c80: 742e 6c6f 636b 2829 3b0a 0909 6966 2028  t.lock();...if (
    │ │ │ +00045c90: 2174 2920 7265 7475 726e 3b0a 0909 742d  !t) return;...t-
    │ │ │ +00045ca0: 2667 743b 7265 6365 6976 6564 5f73 796e  >received_syn
    │ │ │ +00045cb0: 6163 6b28 6970 7636 293b 0a09 7d0a 0a09  ack(ipv6);..}...
    │ │ │ +00045cc0: 7065 6572 5f65 6e64 706f 696e 745f 7420  peer_endpoint_t 
    │ │ │ +00045cd0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +00045ce0: 3a72 656d 6f74 655f 656e 6470 6f69 6e74  :remote_endpoint
    │ │ │ +00045cf0: 2829 2063 6f6e 7374 0a09 7b0a 2369 6620  () const..{.#if 
    │ │ │ +00045d00: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ +00045d10: 0909 6966 2028 6175 746f 2073 203d 2073  ..if (auto s = s
    │ │ │ +00045d20: 7464 3a3a 6765 745f 6966 266c 743b 6932  td::get_if<i2
    │ │ │ +00045d30: 705f 7374 7265 616d 2667 743b 2826 616d  p_stream>(&am
    │ │ │ +00045d40: 703b 6d5f 736f 636b 6574 2929 0a09 097b  p;m_socket))...{
    │ │ │ +00045d50: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00045d80: 0909 7265 7475 726e 2068 6173 6865 7232 ..return hasher2 │ │ │ +00045d90: 3536 2862 6173 6536 3464 6563 6f64 655f 56(base64decode_ │ │ │ +00045da0: 6932 7028 732d 2667 743b 6465 7374 696e i2p(s->destin │ │ │ +00045db0: 6174 696f 6e28 2929 292e 6669 6e61 6c28 ation())).final( │ │ │ +00045dc0: 293b 0a3c 2f64 6976 3e09 097d 0a23 656e );.
    ..}.#en │ │ │ +00045dd0: 6469 660a 0909 7265 7475 726e 206d 5f72 dif...return m_r │ │ │ +00045de0: 656d 6f74 653b 0a09 7d0a 0a23 6966 2054 emote;..}..#if T │ │ │ +00045df0: 4f52 5245 4e54 5f55 5345 5f49 3250 0a09 ORRENT_USE_I2P.. │ │ │ +00045e00: 7374 643a 3a73 7472 696e 6720 636f 6e73 std::string cons │ │ │ +00045e10: 7426 616d 703b 2070 6565 725f 636f 6e6e t& peer_conn │ │ │ +00045e20: 6563 7469 6f6e 3a3a 6465 7374 696e 6174 ection::destinat │ │ │ +00045e30: 696f 6e28 2920 636f 6e73 740a 097b 0a09 ion() const..{.. │ │ │ +00045e40: 0973 7461 7469 6320 7374 643a 3a73 7472 .static std::str │ │ │ +00045e50: 696e 6720 636f 6e73 7420 656d 7074 793b ing const empty; │ │ │ +00045e60: 0a09 0961 7574 6f20 7320 3d20 7374 643a ...auto s = std: │ │ │ +00045e70: 3a67 6574 5f69 6626 6c74 3b69 3270 5f73 :get_if<i2p_s │ │ │ +00045e80: 7472 6561 6d26 6774 3b28 2661 6d70 3b6d tream>(&m │ │ │ +00045e90: 5f73 6f63 6b65 7429 3b0a 0909 7265 7475 _socket);...retu │ │ │ +00045ea0: 726e 2073 203f 2073 2d26 6774 3b64 6573 rn s ? s->des │ │ │ +00045eb0: 7469 6e61 7469 6f6e 2829 203a 2065 6d70 tination() : emp │ │ │ +00045ec0: 7479 3b0a 097d 0a0a 0973 7464 3a3a 7374 ty;..}...std::st │ │ │ +00045ed0: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20 ring const& │ │ │ +00045ee0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ +00045ef0: 3a6c 6f63 616c 5f69 3270 5f65 6e64 706f :local_i2p_endpo │ │ │ +00045f00: 696e 7428 2920 636f 6e73 740a 097b 0a09 int() const..{.. │ │ │ +00045f10: 0973 7461 7469 6320 7374 643a 3a73 7472 .static std::str │ │ │ +00045f20: 696e 6720 636f 6e73 7420 656d 7074 793b ing const empty; │ │ │ +00045f30: 0a09 0961 7574 6f20 7320 3d20 7374 643a ...auto s = std: │ │ │ +00045f40: 3a67 6574 5f69 6626 6c74 3b69 3270 5f73 :get_if<i2p_s │ │ │ +00045f50: 7472 6561 6d26 6774 3b28 2661 6d70 3b6d tream>(&m │ │ │ +00045f60: 5f73 6f63 6b65 7429 3b0a 0909 7265 7475 _socket);...retu │ │ │ +00045f70: 726e 2073 203f 2073 2d26 6774 3b6c 6f63 rn s ? s->loc │ │ │ +00045f80: 616c 5f69 3270 5f65 6e64 706f 696e 7428 al_i2p_endpoint( │ │ │ +00045f90: 2920 3a20 656d 7074 793b 0a09 7d0a 2365 ) : empty;..}.#e │ │ │ +00045fa0: 6e64 6966 0a0a 0974 7970 6564 5f62 6974 ndif...typed_bit │ │ │ +00045fb0: 6669 656c 6426 6c74 3b70 6965 6365 5f69 field<piece_i │ │ │ +00045fc0: 6e64 6578 5f74 2667 743b 2063 6f6e 7374 ndex_t> const │ │ │ +00045fd0: 2661 6d70 3b20 7065 6572 5f63 6f6e 6e65 & peer_conne │ │ │ +00045fe0: 6374 696f 6e3a 3a67 6574 5f62 6974 6669 ction::get_bitfi │ │ │ +00045ff0: 656c 6428 2920 636f 6e73 740a 097b 0a09 eld() const..{.. │ │ │ +00046000: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00046010: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ +00046020: 2829 293b 0a09 0972 6574 7572 6e20 6d5f ());...return m_ │ │ │ +00046030: 6861 7665 5f70 6965 6365 3b0a 097d 0a0a have_piece;..}.. │ │ │ +00046040: 0976 6f69 6420 7065 6572 5f63 6f6e 6e65 .void peer_conne │ │ │ +00046050: 6374 696f 6e3a 3a72 6563 6569 7665 645f ction::received_ │ │ │ +00046060: 7661 6c69 645f 6461 7461 2870 6965 6365 valid_data(piece │ │ │ +00046070: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069 _index_t const i │ │ │ +00046080: 6e64 6578 290a 097b 0a09 0954 4f52 5245 ndex)..{...TORRE │ │ │ +00046090: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ +000460a0: 676c 655f 7468 7265 6164 2829 293b 0a3c gle_thread());.< │ │ │ +000460b0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +000460c0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000460d0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000460e0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000460f0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00046120: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e /peer_connection │ │ │ +00046130: 2e63 7070 3a33 3535 333c 2f61 3e3c 2f74 .cpp:3553sort the a │ │ │ +00046150: 6c6c 6f77 6564 2066 6173 7420 7365 7420 llowed fast set │ │ │ +00046160: 696e 2070 7269 6f72 6974 7920 6f72 6465 in priority orde │ │ │ +00046170: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    s │ │ │ +000461c0: 6f72 7420 7468 6520 616c 6c6f 7765 6420 ort the allowed │ │ │ +000461d0: 6661 7374 2073 6574 2069 6e20 7072 696f fast set in prio │ │ │ +000461e0: 7269 7479 206f 7264 6572 3c2f 6832 3e3c rity order

    < │ │ │ +000461f0: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ +00046200: 6f6e 6e65 6374 696f 6e2e 6370 703a 3335 onnection.cpp:35 │ │ │ +00046210: 3533 3c2f 6834 3e3c 7072 6520 7374 796c 53

    ...// if the pe
    │ │ │ +00046260: 6572 2068 6173 2074 6865 2070 6965 6365  er has the piece
    │ │ │ +00046270: 2061 6e64 2077 6520 7761 6e74 0a09 092f   and we want.../
    │ │ │ +00046280: 2f20 746f 2064 6f77 6e6c 6f61 6420 6974  / to download it
    │ │ │ +00046290: 2c20 7265 7175 6573 7420 6974 0a09 0969  , request it...i
    │ │ │ +000462a0: 6620 2869 6e64 6578 2026 6c74 3b20 6d5f  f (index < m_
    │ │ │ +000462b0: 6861 7665 5f70 6965 6365 2e65 6e64 5f69  have_piece.end_i
    │ │ │ +000462c0: 6e64 6578 2829 0a09 0909 2661 6d70 3b26  ndex()....&&
    │ │ │ +000462d0: 616d 703b 206d 5f68 6176 655f 7069 6563  amp; m_have_piec
    │ │ │ +000462e0: 655b 696e 6465 785d 0a09 0909 2661 6d70  e[index]....&
    │ │ │ +000462f0: 3b26 616d 703b 2021 742d 2667 743b 6861  ;& !t->ha
    │ │ │ +00046300: 7665 5f70 6965 6365 2869 6e64 6578 290a  ve_piece(index).
    │ │ │ +00046310: 0909 0926 616d 703b 2661 6d70 3b20 742d  ...&& t-
    │ │ │ +00046320: 2667 743b 7661 6c69 645f 6d65 7461 6461  >valid_metada
    │ │ │ +00046330: 7461 2829 0a09 0909 2661 6d70 3b26 616d  ta()....&&am
    │ │ │ +00046340: 703b 2074 2d26 6774 3b68 6173 5f70 6963  p; t->has_pic
    │ │ │ +00046350: 6b65 7228 290a 0909 0926 616d 703b 2661  ker()....&&a
    │ │ │ +00046360: 6d70 3b20 742d 2667 743b 7069 636b 6572  mp; t->picker
    │ │ │ +00046370: 2829 2e70 6965 6365 5f70 7269 6f72 6974  ().piece_priorit
    │ │ │ +00046380: 7928 696e 6465 7829 2026 6774 3b20 646f  y(index) > do
    │ │ │ +00046390: 6e74 5f64 6f77 6e6c 6f61 6429 0a09 097b  nt_download)...{
    │ │ │ +000463a0: 0a09 0909 742d 2667 743b 7065 6572 5f69  ....t->peer_i
    │ │ │ +000463b0: 735f 696e 7465 7265 7374 696e 6728 2a74  s_interesting(*t
    │ │ │ +000463c0: 6869 7329 3b0a 0909 7d0a 097d 0a0a 0973  his);...}..}...s
    │ │ │ +000463d0: 7464 3a3a 7665 6374 6f72 266c 743b 7069  td::vector<pi
    │ │ │ +000463e0: 6563 655f 696e 6465 785f 7426 6774 3b20  ece_index_t> 
    │ │ │ +000463f0: 636f 6e73 7426 616d 703b 2070 6565 725f  const& peer_
    │ │ │ +00046400: 636f 6e6e 6563 7469 6f6e 3a3a 616c 6c6f  connection::allo
    │ │ │ +00046410: 7765 645f 6661 7374 2829 0a09 7b0a 0909  wed_fast()..{...
    │ │ │ +00046420: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ +00046430: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ +00046440: 2929 3b0a 0909 6175 746f 2074 203d 206d  ));...auto t = m
    │ │ │ +00046450: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b  _torrent.lock();
    │ │ │ +00046460: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +00046470: 5428 7429 3b0a 0a3c 6469 7620 7374 796c  T(t);..
    ..return m_ │ │ │ +000464b0: 616c 6c6f 7765 645f 6661 7374 3b0a 3c2f allowed_fast;..}...bool pe │ │ │ +000464d0: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a63 er_connection::c │ │ │ +000464e0: 616e 5f72 6571 7565 7374 5f74 696d 655f an_request_time_ │ │ │ +000464f0: 6372 6974 6963 616c 2829 2063 6f6e 7374 critical() const │ │ │ +00046500: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +00046510: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ +00046520: 6872 6561 6428 2929 3b0a 0909 6966 2028 hread());...if ( │ │ │ +00046530: 6861 735f 7065 6572 5f63 686f 6b65 6428 has_peer_choked( │ │ │ +00046540: 2920 7c7c 2021 6973 5f69 6e74 6572 6573 ) || !is_interes │ │ │ +00046550: 7469 6e67 2829 2920 7265 7475 726e 2066 ting()) return f │ │ │ +00046560: 616c 7365 3b0a 0909 6966 2028 696e 7428 alse;...if (int( │ │ │ +00046570: 6d5f 646f 776e 6c6f 6164 5f71 7565 7565 m_download_queue │ │ │ +00046580: 2e73 697a 6528 2929 202b 2069 6e74 286d .size()) + int(m │ │ │ +00046590: 5f72 6571 7565 7374 5f71 7565 7565 2e73 _request_queue.s │ │ │ +000465a0: 697a 6528 2929 0a09 0909 2667 743b 206d ize())....> m │ │ │ +000465b0: 5f64 6573 6972 6564 5f71 7565 7565 5f73 _desired_queue_s │ │ │ +000465c0: 697a 6520 2a20 3229 2072 6574 7572 6e20 ize * 2) return │ │ │ +000465d0: 6661 6c73 653b 0a09 0969 6620 286f 6e5f false;...if (on_ │ │ │ +000465e0: 7061 726f 6c65 2829 2920 7265 7475 726e parole()) return │ │ │ +000465f0: 2066 616c 7365 3b0a 0909 6966 2028 6d5f false;...if (m_ │ │ │ +00046600: 6469 7363 6f6e 6e65 6374 696e 6729 2072 disconnecting) r │ │ │ +00046610: 6574 7572 6e20 6661 6c73 653b 0a09 0961 eturn false;...a │ │ │ +00046620: 7574 6f20 7420 3d20 6d5f 746f 7272 656e uto t = m_torren │ │ │ +00046630: 742e 6c6f 636b 2829 3b0a 0909 544f 5252 t.lock();...TORR │ │ │ +00046640: 454e 545f 4153 5345 5254 2874 293b 0a09 ENT_ASSERT(t);.. │ │ │ +00046650: 0969 6620 2874 2d26 6774 3b75 706c 6f61 .if (t->uploa │ │ │ +00046660: 645f 6d6f 6465 2829 2920 7265 7475 726e d_mode()) return │ │ │ +00046670: 2066 616c 7365 3b0a 0a09 092f 2f20 6967 false;....// ig │ │ │ +00046680: 6e6f 7265 2073 6e75 6262 6564 2070 6565 nore snubbed pee │ │ │ +00046690: 7273 2c20 7369 6e63 6520 7468 6579 2772 rs, since they'r │ │ │ +000466a0: 6520 6e6f 7420 6c69 6b65 6c79 2074 6f20 e not likely to │ │ │ +000466b0: 7265 7475 726e 2070 6965 6365 7320 696e return pieces in │ │ │ +000466c0: 2061 0a09 092f 2f20 7469 6d65 6c79 206d a...// timely m │ │ │ +000466d0: 616e 6e65 7220 616e 7977 6179 0a09 0969 anner anyway...i │ │ │ +000466e0: 6620 286d 5f73 6e75 6262 6564 2920 7265 f (m_snubbed) re │ │ │ +000466f0: 7475 726e 2066 616c 7365 3b0a 0909 7265 turn false;...re │ │ │ +00046700: 7475 726e 2074 7275 653b 0a09 7d0a 0a09 turn true;..}... │ │ │ +00046710: 626f 6f6c 2070 6565 725f 636f 6e6e 6563 bool peer_connec │ │ │ +00046720: 7469 6f6e 3a3a 6d61 6b65 5f74 696d 655f tion::make_time_ │ │ │ +00046730: 6372 6974 6963 616c 2870 6965 6365 5f62 critical(piece_b │ │ │ +00046740: 6c6f 636b 2063 6f6e 7374 2661 6d70 3b20 lock const& │ │ │ +00046750: 626c 6f63 6b29 0a09 7b0a 0909 544f 5252 block)..{...TORR │ │ │ +00046760: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ +00046770: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ +00046780: 0909 6175 746f 2063 6f6e 7374 2072 6974 ..auto const rit │ │ │ +00046790: 203d 2073 7464 3a3a 6669 6e64 5f69 6628 = std::find_if( │ │ │ +000467a0: 6d5f 7265 7175 6573 745f 7175 6575 652e m_request_queue. │ │ │ +000467b0: 6265 6769 6e28 290a 0909 092c 206d 5f72 begin()...., m_r │ │ │ +000467c0: 6571 7565 7374 5f71 7565 7565 2e65 6e64 equest_queue.end │ │ │ +000467d0: 2829 2c20 6175 783a 3a68 6173 5f62 6c6f (), aux::has_blo │ │ │ +000467e0: 636b 2862 6c6f 636b 2929 3b0a 0909 6966 ck(block));...if │ │ │ +000467f0: 2028 7269 7420 3d3d 206d 5f72 6571 7565 (rit == m_reque │ │ │ +00046800: 7374 5f71 7565 7565 2e65 6e64 2829 2920 st_queue.end()) │ │ │ +00046810: 7265 7475 726e 2066 616c 7365 3b0a 2369 return false;.#i │ │ │ +00046820: 6620 544f 5252 454e 545f 5553 455f 4153 f TORRENT_USE_AS │ │ │ +00046830: 5345 5254 530a 0909 6175 746f 2074 203d SERTS...auto t = │ │ │ +00046840: 206d 5f74 6f72 7265 6e74 2e6c 6f63 6b28 m_torrent.lock( │ │ │ +00046850: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +00046860: 4552 5428 7429 3b0a 0909 544f 5252 454e ERT(t);...TORREN │ │ │ +00046870: 545f 4153 5345 5254 2874 2d26 6774 3b68 T_ASSERT(t->h │ │ │ +00046880: 6173 5f70 6963 6b65 7228 2929 3b0a 3c2f as_picker());.r │ │ │ +000468c0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +000468d0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00046900: 746f 7272 656e 742e 6370 703a 3231 3032 torrent.cpp:2102 │ │ │ +00046910: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ +00046920: 7320 636f 756c 6420 6265 206f 7074 696d s could be optim │ │ │ +00046930: 697a 6564 2062 7920 6c6f 6f6b 696e 6720 ized by looking │ │ │ +00046940: 7570 2077 6869 6368 2066 696c 6573 2061 up which files a │ │ │ +00046950: 7265 2063 6f6d 706c 6574 6520 616e 6420 re complete and │ │ │ +00046960: 6a75 7374 206c 6f6f 6b20 6174 2074 686f just look at tho │ │ │ +00046970: 7365 3c2f 7464 3e3c 2f74 723e 3c74 7220 se

    │ │ │ +000469c0: 7468 6973 2063 6f75 6c64 2062 6520 6f70 this could be op │ │ │ +000469d0: 7469 6d69 7a65 6420 6279 206c 6f6f 6b69 timized by looki │ │ │ +000469e0: 6e67 2075 7020 7768 6963 6820 6669 6c65 ng up which file │ │ │ +000469f0: 7320 6172 650a 636f 6d70 6c65 7465 2061 s are.complete a │ │ │ +00046a00: 6e64 206a 7573 7420 6c6f 6f6b 2061 7420 nd just look at │ │ │ +00046a10: 7468 6f73 653c 2f68 323e 3c68 343e 2e2e those

    .. │ │ │ +00046a20: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +00046a30: 3a32 3130 323c 2f68 343e 3c70 7265 2073 :2102

    //....TORREN
    │ │ │ +00046a80: 545f 4153 5345 5254 2870 6963 6b65 7228  T_ASSERT(picker(
    │ │ │ +00046a90: 292e 6861 7665 5f70 6965 6365 2869 2929  ).have_piece(i))
    │ │ │ +00046aa0: 3b0a 0909 0909 7765 5f68 6176 6528 6929  ;.....we_have(i)
    │ │ │ +00046ab0: 3b0a 0909 097d 0a09 097d 0a0a 0909 7365  ;....}...}....se
    │ │ │ +00046ac0: 745f 7374 6174 6528 746f 7272 656e 745f  t_state(torrent_
    │ │ │ +00046ad0: 7374 6174 7573 3a3a 6368 6563 6b69 6e67  status::checking
    │ │ │ +00046ae0: 5f72 6573 756d 655f 6461 7461 293b 0a0a  _resume_data);..
    │ │ │ +00046af0: 0909 6175 783a 3a76 6563 746f 7226 6c74  ..aux::vector<
    │ │ │ +00046b00: 3b73 7464 3a3a 7374 7269 6e67 2c20 6669  ;std::string, fi
    │ │ │ +00046b10: 6c65 5f69 6e64 6578 5f74 2667 743b 206c  le_index_t> l
    │ │ │ +00046b20: 696e 6b73 3b0a 2369 666e 6465 6620 544f  inks;.#ifndef TO
    │ │ │ +00046b30: 5252 454e 545f 4449 5341 424c 455f 4d55  RRENT_DISABLE_MU
    │ │ │ +00046b40: 5441 424c 455f 544f 5252 454e 5453 0a09  TABLE_TORRENTS..
    │ │ │ +00046b50: 0969 6620 2821 6d5f 746f 7272 656e 745f  .if (!m_torrent_
    │ │ │ +00046b60: 6669 6c65 2d26 6774 3b73 696d 696c 6172  file->similar
    │ │ │ +00046b70: 5f74 6f72 7265 6e74 7328 292e 656d 7074  _torrents().empt
    │ │ │ +00046b80: 7928 290a 0909 097c 7c20 216d 5f74 6f72  y()....|| !m_tor
    │ │ │ +00046b90: 7265 6e74 5f66 696c 652d 2667 743b 636f  rent_file->co
    │ │ │ +00046ba0: 6c6c 6563 7469 6f6e 7328 292e 656d 7074  llections().empt
    │ │ │ +00046bb0: 7928 2929 0a09 097b 0a09 0909 7265 736f  y())...{....reso
    │ │ │ +00046bc0: 6c76 655f 6c69 6e6b 7320 7265 7328 6d5f  lve_links res(m_
    │ │ │ +00046bd0: 746f 7272 656e 745f 6669 6c65 293b 0a0a  torrent_file);..
    │ │ │ +00046be0: 0909 0966 6f72 2028 6175 746f 2063 6f6e  ...for (auto con
    │ │ │ +00046bf0: 7374 2661 6d70 3b20 6968 203a 206d 5f74  st& ih : m_t
    │ │ │ +00046c00: 6f72 7265 6e74 5f66 696c 652d 2667 743b  orrent_file->
    │ │ │ +00046c10: 7369 6d69 6c61 725f 746f 7272 656e 7473  similar_torrents
    │ │ │ +00046c20: 2829 290a 0909 097b 0a09 0909 0973 7464  ())....{.....std
    │ │ │ +00046c30: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ +00046c40: 746f 7272 656e 7426 6774 3b20 7420 3d20  torrent> t = 
    │ │ │ +00046c50: 6d5f 7365 732e 6669 6e64 5f74 6f72 7265  m_ses.find_torre
    │ │ │ +00046c60: 6e74 2869 6e66 6f5f 6861 7368 5f74 2869  nt(info_hash_t(i
    │ │ │ +00046c70: 6829 292e 6c6f 636b 2829 3b0a 0909 0909  h)).lock();.....
    │ │ │ +00046c80: 6966 2028 2174 2920 636f 6e74 696e 7565  if (!t) continue
    │ │ │ +00046c90: 3b0a 0a09 0909 092f 2f20 4f6e 6c79 2061  ;......// Only a
    │ │ │ +00046ca0: 7474 656d 7074 2074 6f20 7265 7573 6520  ttempt to reuse 
    │ │ │ +00046cb0: 6669 6c65 7320 6672 6f6d 2074 6f72 7265  files from torre
    │ │ │ +00046cc0: 6e74 7320 7468 6174 2061 7265 2073 6565  nts that are see
    │ │ │ +00046cd0: 6469 6e67 2e0a 3c64 6976 2073 7479 6c65  ding..
    ....if (!t-& │ │ │ +00046d10: 6774 3b69 735f 7365 6564 2829 2920 636f gt;is_seed()) co │ │ │ +00046d20: 6e74 696e 7565 3b0a 3c2f 6469 763e 0a09 ntinue;.
    .. │ │ │ +00046d30: 0909 0961 7574 6f20 7469 203d 2074 2d26 ...auto ti = t-& │ │ │ +00046d40: 6774 3b67 6574 5f74 6f72 7265 6e74 5f66 gt;get_torrent_f │ │ │ +00046d50: 696c 6528 293b 0a09 0909 0972 6573 2e6d ile();.....res.m │ │ │ +00046d60: 6174 6368 282a 7469 2c20 6669 6c65 6e61 atch(*ti, filena │ │ │ +00046d70: 6d65 7328 7469 2d26 6774 3b6c 6179 6f75 mes(ti->layou │ │ │ +00046d80: 7428 292c 2074 2d26 6774 3b6d 5f72 656e t(), t->m_ren │ │ │ +00046d90: 616d 6564 5f66 696c 6573 292c 2074 2d26 amed_files), t-& │ │ │ +00046da0: 6774 3b73 6176 655f 7061 7468 2829 293b gt;save_path()); │ │ │ +00046db0: 0a09 0909 7d0a 0909 0966 6f72 2028 6175 ....}....for (au │ │ │ +00046dc0: 746f 2063 6f6e 7374 2661 6d70 3b20 6320 to const& c │ │ │ +00046dd0: 3a20 6d5f 746f 7272 656e 745f 6669 6c65 : m_torrent_file │ │ │ +00046de0: 2d26 6774 3b63 6f6c 6c65 6374 696f 6e73 ->collections │ │ │ +00046df0: 2829 290a 0909 097b 0a09 0909 0973 7464 ())....{.....std │ │ │ +00046e00: 3a3a 7665 6374 6f72 266c 743b 7374 643a ::vector<std: │ │ │ +00046e10: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ +00046e20: 6f72 7265 6e74 2667 743b 2667 743b 2074 orrent>> t │ │ │ +00046e30: 7320 3d20 6d5f 7365 732e 6669 6e64 5f63 s = m_ses.find_c │ │ │ +00046e40: 6f6c 6c65 6374 696f 6e28 6329 3b0a 0a09 ollection(c);... │ │ │ +00046e50: 0909 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ +00046e60: 7374 2661 6d70 3b20 7420 3a20 7473 290a st& t : ts). │ │ │ +00046e70: 0909 0909 7b0a 0909 0909 092f 2f20 4f6e ....{......// On │ │ │ +00046e80: 6c79 2061 7474 656d 7074 2074 6f20 7265 ly attempt to re │ │ │ +00046e90: 7573 6520 6669 6c65 7320 6672 6f6d 2074 use files from t │ │ │ +00046ea0: 6f72 7265 6e74 7320 7468 6174 2061 7265 orrents that are │ │ │ +00046eb0: 2073 6565 6469 6e67 2e0a 3c2f 7072 653e seeding..
    │ │ │ +00046ec0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00046ef0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00046f00: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +00046f30: 656e 742e 6370 703a 3231 3136 3c2f 613e ent.cpp:2116 │ │ │ +00046f40: 3c2f 7464 3e3c 7464 3e74 6869 7320 636f this co │ │ │ +00046f50: 756c 6420 6265 206f 7074 696d 697a 6564 uld be optimized │ │ │ +00046f60: 2062 7920 6c6f 6f6b 696e 6720 7570 2077 by looking up w │ │ │ +00046f70: 6869 6368 2066 696c 6573 2061 7265 2063 hich files are c │ │ │ +00046f80: 6f6d 706c 6574 6520 616e 6420 6a75 7374 omplete and just │ │ │ +00046f90: 206c 6f6f 6b20 6174 2074 686f 7365 3c2f look at those

    this │ │ │ +00046ff0: 2063 6f75 6c64 2062 6520 6f70 7469 6d69 could be optimi │ │ │ +00047000: 7a65 6420 6279 206c 6f6f 6b69 6e67 2075 zed by looking u │ │ │ +00047010: 7020 7768 6963 6820 6669 6c65 7320 6172 p which files ar │ │ │ +00047020: 650a 636f 6d70 6c65 7465 2061 6e64 206a e.complete and j │ │ │ +00047030: 7573 7420 6c6f 6f6b 2061 7420 7468 6f73 ust look at thos │ │ │ +00047040: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ +00047050: 2f74 6f72 7265 6e74 2e63 7070 3a32 3131 /torrent.cpp:211 │ │ │ +00047060: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ +000470a0: 0909 0972 6573 6f6c 7665 5f6c 696e 6b73  ...resolve_links
    │ │ │ +000470b0: 2072 6573 286d 5f74 6f72 7265 6e74 5f66   res(m_torrent_f
    │ │ │ +000470c0: 696c 6529 3b0a 0a09 0909 666f 7220 2861  ile);.....for (a
    │ │ │ +000470d0: 7574 6f20 636f 6e73 7426 616d 703b 2069  uto const& i
    │ │ │ +000470e0: 6820 3a20 6d5f 746f 7272 656e 745f 6669  h : m_torrent_fi
    │ │ │ +000470f0: 6c65 2d26 6774 3b73 696d 696c 6172 5f74  le->similar_t
    │ │ │ +00047100: 6f72 7265 6e74 7328 2929 0a09 0909 7b0a  orrents())....{.
    │ │ │ +00047110: 0909 0909 7374 643a 3a73 6861 7265 645f  ....std::shared_
    │ │ │ +00047120: 7074 7226 6c74 3b74 6f72 7265 6e74 2667  ptr<torrent&g
    │ │ │ +00047130: 743b 2074 203d 206d 5f73 6573 2e66 696e  t; t = m_ses.fin
    │ │ │ +00047140: 645f 746f 7272 656e 7428 696e 666f 5f68  d_torrent(info_h
    │ │ │ +00047150: 6173 685f 7428 6968 2929 2e6c 6f63 6b28  ash_t(ih)).lock(
    │ │ │ +00047160: 293b 0a09 0909 0969 6620 2821 7429 2063  );.....if (!t) c
    │ │ │ +00047170: 6f6e 7469 6e75 653b 0a0a 0909 0909 2f2f  ontinue;......//
    │ │ │ +00047180: 204f 6e6c 7920 6174 7465 6d70 7420 746f   Only attempt to
    │ │ │ +00047190: 2072 6575 7365 2066 696c 6573 2066 726f   reuse files fro
    │ │ │ +000471a0: 6d20 746f 7272 656e 7473 2074 6861 7420  m torrents that 
    │ │ │ +000471b0: 6172 6520 7365 6564 696e 672e 0a09 0909  are seeding.....
    │ │ │ +000471c0: 0969 6620 2821 742d 2667 743b 6973 5f73  .if (!t->is_s
    │ │ │ +000471d0: 6565 6428 2929 2063 6f6e 7469 6e75 653b  eed()) continue;
    │ │ │ +000471e0: 0a0a 0909 0909 6175 746f 2074 6920 3d20  ......auto ti = 
    │ │ │ +000471f0: 742d 2667 743b 6765 745f 746f 7272 656e  t->get_torren
    │ │ │ +00047200: 745f 6669 6c65 2829 3b0a 0909 0909 7265  t_file();.....re
    │ │ │ +00047210: 732e 6d61 7463 6828 2a74 692c 2066 696c  s.match(*ti, fil
    │ │ │ +00047220: 656e 616d 6573 2874 692d 2667 743b 6c61  enames(ti->la
    │ │ │ +00047230: 796f 7574 2829 2c20 742d 2667 743b 6d5f  yout(), t->m_
    │ │ │ +00047240: 7265 6e61 6d65 645f 6669 6c65 7329 2c20  renamed_files), 
    │ │ │ +00047250: 742d 2667 743b 7361 7665 5f70 6174 6828  t->save_path(
    │ │ │ +00047260: 2929 3b0a 0909 097d 0a09 0909 666f 7220  ));....}....for 
    │ │ │ +00047270: 2861 7574 6f20 636f 6e73 7426 616d 703b  (auto const&
    │ │ │ +00047280: 2063 203a 206d 5f74 6f72 7265 6e74 5f66   c : m_torrent_f
    │ │ │ +00047290: 696c 652d 2667 743b 636f 6c6c 6563 7469  ile->collecti
    │ │ │ +000472a0: 6f6e 7328 2929 0a09 0909 7b0a 0909 0909  ons())....{.....
    │ │ │ +000472b0: 7374 643a 3a76 6563 746f 7226 6c74 3b73  std::vector<s
    │ │ │ +000472c0: 7464 3a3a 7368 6172 6564 5f70 7472 266c  td::shared_ptr&l
    │ │ │ +000472d0: 743b 746f 7272 656e 7426 6774 3b26 6774  t;torrent>>
    │ │ │ +000472e0: 3b20 7473 203d 206d 5f73 6573 2e66 696e  ; ts = m_ses.fin
    │ │ │ +000472f0: 645f 636f 6c6c 6563 7469 6f6e 2863 293b  d_collection(c);
    │ │ │ +00047300: 0a0a 0909 0909 666f 7220 2861 7574 6f20  ......for (auto 
    │ │ │ +00047310: 636f 6e73 7426 616d 703b 2074 203a 2074  const& t : t
    │ │ │ +00047320: 7329 0a09 0909 097b 0a09 0909 0909 2f2f  s).....{......//
    │ │ │ +00047330: 204f 6e6c 7920 6174 7465 6d70 7420 746f   Only attempt to
    │ │ │ +00047340: 2072 6575 7365 2066 696c 6573 2066 726f   reuse files fro
    │ │ │ +00047350: 6d20 746f 7272 656e 7473 2074 6861 7420  m torrents that 
    │ │ │ +00047360: 6172 6520 7365 6564 696e 672e 0a3c 6469  are seeding.......
    │ │ │ +000473a0: 6966 2028 2174 2d26 6774 3b69 735f 7365  if (!t->is_se
    │ │ │ +000473b0: 6564 2829 2920 636f 6e74 696e 7565 3b0a  ed()) continue;.
    │ │ │ +000473c0: 3c2f 6469 763e 0a09 0909 0909 6175 746f  
    ......auto │ │ │ +000473d0: 2074 6920 3d20 742d 2667 743b 6765 745f ti = t->get_ │ │ │ +000473e0: 746f 7272 656e 745f 6669 6c65 2829 3b0a torrent_file();. │ │ │ +000473f0: 0909 0909 0972 6573 2e6d 6174 6368 282a .....res.match(* │ │ │ +00047400: 7469 2c20 6669 6c65 6e61 6d65 7328 7469 ti, filenames(ti │ │ │ +00047410: 2d26 6774 3b6c 6179 6f75 7428 292c 2074 ->layout(), t │ │ │ +00047420: 2d26 6774 3b6d 5f72 656e 616d 6564 5f66 ->m_renamed_f │ │ │ +00047430: 696c 6573 292c 2074 2d26 6774 3b73 6176 iles), t->sav │ │ │ +00047440: 655f 7061 7468 2829 293b 0a09 0909 097d e_path());.....} │ │ │ +00047450: 0a09 0909 7d0a 0a09 0909 6c69 6e6b 7320 ....}.....links │ │ │ +00047460: 3d20 7374 643a 3a6d 6f76 6528 7265 7329 = std::move(res) │ │ │ +00047470: 2e67 6574 5f6c 696e 6b73 2829 3b0a 0909 .get_links();... │ │ │ +00047480: 7d0a 2365 6e64 6966 202f 2f20 544f 5252 }.#endif // TORR │ │ │ +00047490: 454e 545f 4449 5341 424c 455f 4d55 5441 ENT_DISABLE_MUTA │ │ │ +000474a0: 424c 455f 544f 5252 454e 5453 0a0a 2369 BLE_TORRENTS..#i │ │ │ +000474b0: 6620 544f 5252 454e 545f 5553 455f 4153 f TORRENT_USE_AS │ │ │ +000474c0: 5345 5254 530a 0909 544f 5252 454e 545f SERTS...TORRENT_ │ │ │ +000474d0: 4153 5345 5254 286d 5f6f 7574 7374 616e ASSERT(m_outstan │ │ │ +000474e0: 6469 6e67 5f63 6865 636b 5f66 696c 6573 ding_check_files │ │ │ +000474f0: 203d 3d20 6661 6c73 6529 3b0a 0909 6d5f == false);...m_ │ │ │ +00047500: 6f75 7473 7461 6e64 696e 675f 6368 6563 outstanding_chec │ │ │ +00047510: 6b5f 6669 6c65 7320 3d20 7472 7565 3b0a k_files = true;. │ │ │ +00047520: 2365 6e64 6966 0a0a 0909 6966 2028 216d #endif....if (!m │ │ │ +00047530: 5f61 6464 5f74 6f72 7265 6e74 5f70 6172 _add_torrent_par │ │ │ +00047540: 616d 7320 7c7c 2021 286d 5f61 6464 5f74 ams || !(m_add_t │ │ │ +00047550: 6f72 7265 6e74 5f70 6172 616d 732d 2667 orrent_params-&g │ │ │ +00047560: 743b 666c 6167 7320 2661 6d70 3b20 746f t;flags & to │ │ │ +00047570: 7272 656e 745f 666c 6167 733a 3a6e 6f5f rrent_flags::no_ │ │ │ +00047580: 7665 7269 6679 5f66 696c 6573 2929 0a09 verify_files)).. │ │ │ +00047590: 097b 0a09 0909 6d5f 7365 732e 6469 736b .{....m_ses.disk │ │ │ +000475a0: 5f74 6872 6561 6428 292e 6173 796e 635f _thread().async_ │ │ │ +000475b0: 6368 6563 6b5f 6669 6c65 7328 0a09 0909 check_files(.... │ │ │ +000475c0: 096d 5f73 746f 7261 6765 2c20 6d5f 6164 .m_storage, m_ad │ │ │ +000475d0: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +000475e0: 203f 206d 5f61 6464 5f74 6f72 7265 6e74 ? m_add_torrent │ │ │ +000475f0: 5f70 6172 616d 732e 6765 7428 2920 3a20 _params.get() : │ │ │ +00047600: 6e75 6c6c 7074 720a 0909 0909 2c20 7374 nullptr....., st │ │ │ +00047610: 643a 3a6d 6f76 6528 6c69 6e6b 7329 2c20 d::move(links), │ │ │ +00047620: 5b73 656c 6620 3d20 7368 6172 6564 5f66 [self = shared_f │ │ │ +00047630: 726f 6d5f 7468 6973 2829 5d28 7374 6174 rom_this()](stat │ │ │ +00047640: 7573 5f74 2073 742c 2073 746f 7261 6765 us_t st, storage │ │ │ +00047650: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70 _error const& │ │ │ +00047660: 3b20 6572 726f 7229 0a09 0909 097b 2073 ; error).....{ s │ │ │ +00047670: 656c 662d 2667 743b 6f6e 5f72 6573 756d elf->on_resum │ │ │ +00047680: 655f 6461 7461 5f63 6865 636b 6564 2873 e_data_checked(s │ │ │ +00047690: 742c 2065 7272 6f72 293b 207d 293b 0a23 t, error); });.# │ │ │ +000476a0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +000476b0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +000476c0: 0909 6465 6275 675f 6c6f 6728 2269 6e69 ..debug_log("ini │ │ │ +000476d0: 742c 2061 7379 6e63 5f63 6865 636b 5f66 t, async_check_f │ │ │ +000476e0: 696c 6573 2229 3b0a 2365 6e64 6966 0a09 iles");.#endif.. │ │ │ +000476f0: 0909 6d5f 7365 732e 6465 6665 7272 6564 ..m_ses.deferred │ │ │ +00047700: 5f73 7562 6d69 745f 6a6f 6273 2829 3b0a _submit_jobs();. │ │ │ +00047710: 0909 7d0a 0909 656c 7365 0a09 097b 0a09 ..}...else...{.. │ │ │ +00047720: 0909 6f6e 5f72 6573 756d 655f 6461 7461 ..on_resume_data │ │ │ +00047730: 5f63 6865 636b 6564 287b 7d2c 2073 746f _checked({}, sto │ │ │ +00047740: 7261 6765 5f65 7272 6f72 7b7d 293b 0a09 rage_error{});.. │ │ │ +00047750: 097d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .}.
    │ │ │ +00047780: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00047790: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +000477c0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +000477d0: 3a32 3839 313c 2f61 3e3c 2f74 643e 3c74 :2891this pattern i │ │ │ +000477f0: 7320 7265 7065 6174 6564 2069 6e20 6120 s repeated in a │ │ │ +00047800: 6665 7720 706c 6163 6573 2e20 4661 6374 few places. Fact │ │ │ +00047810: 6f72 2074 6869 7320 696e 746f 2061 2066 or this into a f │ │ │ +00047820: 756e 6374 696f 6e20 616e 6420 6765 6e65 unction and gene │ │ │ +00047830: 7261 6c69 7a65 2074 6865 2063 6f6e 6365 ralize the conce │ │ │ +00047840: 7074 206f 6620 6120 746f 7272 656e 7420 pt of a torrent │ │ │ +00047850: 6861 7669 6e67 2061 2064 6564 6963 6174 having a dedicat │ │ │ +00047860: 6564 206c 6973 7465 6e20 706f 7274 3c2f ed listen port

    this │ │ │ +000478c0: 2070 6174 7465 726e 2069 7320 7265 7065 pattern is repe │ │ │ +000478d0: 6174 6564 2069 6e20 6120 6665 7720 706c ated in a few pl │ │ │ +000478e0: 6163 6573 2e20 4661 6374 6f72 2074 6869 aces. Factor thi │ │ │ +000478f0: 7320 696e 746f 0a61 2066 756e 6374 696f s into.a functio │ │ │ +00047900: 6e20 616e 6420 6765 6e65 7261 6c69 7a65 n and generalize │ │ │ +00047910: 2074 6865 2063 6f6e 6365 7074 206f 6620 the concept of │ │ │ +00047920: 6120 746f 7272 656e 7420 6861 7669 6e67 a torrent having │ │ │ +00047930: 2061 0a64 6564 6963 6174 6564 206c 6973 a.dedicated lis │ │ │ +00047940: 7465 6e20 706f 7274 3c2f 6832 3e3c 6834 ten port

    ../src/torrent. │ │ │ +00047960: 6370 703a 3238 3931 3c2f 6834 3e3c 7072 cpp:2891

    ..// not │ │ │ +000479b0: 7265 6164 7920 666f 7220 7065 6572 732e ready for peers. │ │ │ +000479c0: 2045 7863 6570 742c 2069 6620 7765 2064 Except, if we d │ │ │ +000479d0: 6f6e 2774 2068 6176 6520 6d65 7461 6461 on't have metada │ │ │ +000479e0: 7461 2c0a 0909 2f2f 2077 6520 6e65 6564 ta,...// we need │ │ │ +000479f0: 2070 6565 7273 2074 6f20 646f 776e 6c6f peers to downlo │ │ │ +00047a00: 6164 2066 726f 6d0a 0909 6966 2028 216d ad from...if (!m │ │ │ +00047a10: 5f66 696c 6573 5f63 6865 636b 6564 2026 _files_checked & │ │ │ +00047a20: 616d 703b 2661 6d70 3b20 7661 6c69 645f amp;& valid_ │ │ │ +00047a30: 6d65 7461 6461 7461 2829 2920 7265 7475 metadata()) retu │ │ │ +00047a40: 726e 3b0a 0a09 0969 6620 2821 6d5f 616e rn;....if (!m_an │ │ │ +00047a50: 6e6f 756e 6365 5f74 6f5f 6c73 6429 2072 nounce_to_lsd) r │ │ │ +00047a60: 6574 7572 6e3b 0a0a 0909 2f2f 2070 7269 eturn;....// pri │ │ │ +00047a70: 7661 7465 2074 6f72 7265 6e74 7320 6172 vate torrents ar │ │ │ +00047a80: 6520 6e65 7665 7220 616e 6e6f 756e 6365 e never announce │ │ │ +00047a90: 6420 6f6e 204c 5344 0a09 0969 6620 286d d on LSD...if (m │ │ │ +00047aa0: 5f74 6f72 7265 6e74 5f66 696c 652d 2667 _torrent_file-&g │ │ │ +00047ab0: 743b 6973 5f76 616c 6964 2829 2026 616d t;is_valid() &am │ │ │ +00047ac0: 703b 2661 6d70 3b20 6d5f 746f 7272 656e p;& m_torren │ │ │ +00047ad0: 745f 6669 6c65 2d26 6774 3b70 7269 7628 t_file->priv( │ │ │ +00047ae0: 2929 2072 6574 7572 6e3b 0a0a 2369 6620 )) return;..#if │ │ │ +00047af0: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ +00047b00: 0909 2f2f 2069 3270 2074 6f72 7265 6e74 ..// i2p torrent │ │ │ +00047b10: 7320 6172 6520 616c 736f 206e 6576 6572 s are also never │ │ │ +00047b20: 2061 6e6e 6f75 6e63 6564 206f 6e20 4c53 announced on LS │ │ │ +00047b30: 440a 0909 2f2f 2075 6e6c 6573 7320 7765 D...// unless we │ │ │ +00047b40: 2061 6c6c 6f77 206d 6978 6564 2073 7761 allow mixed swa │ │ │ +00047b50: 726d 730a 0909 6966 2028 6973 5f69 3270 rms...if (is_i2p │ │ │ +00047b60: 2829 2026 616d 703b 2661 6d70 3b20 2173 () && !s │ │ │ +00047b70: 6574 7469 6e67 7328 292e 6765 745f 626f ettings().get_bo │ │ │ +00047b80: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +00047b90: 3a3a 616c 6c6f 775f 6932 705f 6d69 7865 ::allow_i2p_mixe │ │ │ +00047ba0: 6429 290a 0909 0972 6574 7572 6e3b 0a23 d))....return;.# │ │ │ +00047bb0: 656e 6469 660a 0a09 0969 6620 2869 735f endif....if (is_ │ │ │ +00047bc0: 7061 7573 6564 2829 2920 7265 7475 726e paused()) return │ │ │ +00047bd0: 3b0a 0a09 0969 6620 2821 6d5f 7365 732e ;....if (!m_ses. │ │ │ +00047be0: 6861 735f 6c73 6428 2929 2072 6574 7572 has_lsd()) retur │ │ │ +00047bf0: 6e3b 0a0a 3c64 6976 2073 7479 6c65 3d22 n;..
    #ifdef TORRENT │ │ │ +00047c30: 5f53 534c 5f50 4545 5253 0a3c 2f64 6976 _SSL_PEERS.
    ..int port = is │ │ │ +00047c50: 5f73 736c 5f74 6f72 7265 6e74 2829 203f _ssl_torrent() ? │ │ │ +00047c60: 206d 5f73 6573 2e73 736c 5f6c 6973 7465 m_ses.ssl_liste │ │ │ +00047c70: 6e5f 706f 7274 2829 203a 206d 5f73 6573 n_port() : m_ses │ │ │ +00047c80: 2e6c 6973 7465 6e5f 706f 7274 2829 3b0a .listen_port();. │ │ │ +00047c90: 2365 6c73 650a 0909 696e 7420 706f 7274 #else...int port │ │ │ +00047ca0: 203d 206d 5f73 6573 2e6c 6973 7465 6e5f = m_ses.listen_ │ │ │ +00047cb0: 706f 7274 2829 3b0a 2365 6e64 6966 0a0a port();.#endif.. │ │ │ +00047cc0: 0909 2f2f 2061 6e6e 6f75 6e63 6520 7769 ..// announce wi │ │ │ +00047cd0: 7468 2074 6865 206c 6f63 616c 2064 6973 th the local dis │ │ │ +00047ce0: 636f 7665 7279 2073 6572 7669 6365 0a09 covery service.. │ │ │ +00047cf0: 096d 5f74 6f72 7265 6e74 5f66 696c 652d .m_torrent_file- │ │ │ +00047d00: 2667 743b 696e 666f 5f68 6173 6865 7328 >info_hashes( │ │ │ +00047d10: 292e 666f 725f 6561 6368 285b 2661 6d70 ).for_each([& │ │ │ +00047d20: 3b5d 2873 6861 315f 6861 7368 2063 6f6e ;](sha1_hash con │ │ │ +00047d30: 7374 2661 6d70 3b20 6968 2c20 7072 6f74 st& ih, prot │ │ │ +00047d40: 6f63 6f6c 5f76 6572 7369 6f6e 290a 0909 ocol_version)... │ │ │ +00047d50: 7b0a 0909 096d 5f73 6573 2e61 6e6e 6f75 {....m_ses.annou │ │ │ +00047d60: 6e63 655f 6c73 6428 6968 2c20 706f 7274 nce_lsd(ih, port │ │ │ +00047d70: 293b 0a09 097d 293b 0a09 7d0a 0a23 6966 );...});..}..#if │ │ │ +00047d80: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +00047d90: 4142 4c45 5f44 4854 0a0a 0976 6f69 6420 ABLE_DHT...void │ │ │ +00047da0: 746f 7272 656e 743a 3a64 6874 5f61 6e6e torrent::dht_ann │ │ │ +00047db0: 6f75 6e63 6528 290a 097b 0a09 0954 4f52 ounce()..{...TOR │ │ │ +00047dc0: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ +00047dd0: 696e 676c 655f 7468 7265 6164 2829 293b ingle_thread()); │ │ │ +00047de0: 0a09 0969 6620 2821 6d5f 7365 732e 6468 ...if (!m_ses.dh │ │ │ +00047df0: 7428 2929 0a09 097b 0a23 6966 6e64 6566 t())...{.#ifndef │ │ │ +00047e00: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +00047e10: 5f4c 4f47 4749 4e47 0a09 0909 6465 6275 _LOGGING....debu │ │ │ +00047e20: 675f 6c6f 6728 2244 4854 3a20 6e6f 2064 g_log("DHT: no d │ │ │ +00047e30: 6874 2069 6e69 7469 616c 697a 6564 2229 ht initialized") │ │ │ +00047e40: 3b0a 2365 6e64 6966 0a09 0909 7265 7475 ;.#endif....retu │ │ │ +00047e50: 726e 3b0a 0909 7d0a 0909 6966 2028 2173 rn;...}...if (!s │ │ │ +00047e60: 686f 756c 645f 616e 6e6f 756e 6365 5f64 hould_announce_d │ │ │ +00047e70: 6874 2829 290a 0909 7b0a 2369 666e 6465 ht())...{.#ifnde │ │ │ +00047e80: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +00047e90: 455f 4c4f 4747 494e 470a 0909 0969 6620 E_LOGGING....if │ │ │ +00047ea0: 2873 686f 756c 645f 6c6f 6728 2929 0a09 (should_log()).. │ │ │ +00047eb0: 0909 7b0a 2369 6620 544f 5252 454e 545f ..{.#if TORRENT_ │ │ │ +00047ec0: 5553 455f 4932 500a 3c2f 7072 653e 3c2f USE_I2P.
    relevan │ │ │ +00047f00: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +00047f40: 742e 6370 703a 3332 3336 3c2f 613e 3c2f t.cpp:3236it would │ │ │ +00047f60: 6265 206e 6963 6520 746f 2072 6169 7365 be nice to raise │ │ │ +00047f70: 2074 6865 2061 6273 7472 6163 7469 6f6e the abstraction │ │ │ +00047f80: 206c 6576 656c 206f 6620 7468 6520 7472 level of the tr │ │ │ +00047f90: 6163 6b65 725f 6c69 7374 206f 7220 7472 acker_list or tr │ │ │ +00047fa0: 6163 6b65 7273 2061 2062 6974 2068 6572 ackers a bit her │ │ │ +00047fb0: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    i │ │ │ +00048000: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ +00048010: 746f 2072 6169 7365 2074 6865 2061 6273 to raise the abs │ │ │ +00048020: 7472 6163 7469 6f6e 206c 6576 656c 206f traction level o │ │ │ +00048030: 6620 7468 650a 7472 6163 6b65 725f 6c69 f the.tracker_li │ │ │ +00048040: 7374 206f 7220 7472 6163 6b65 7273 2061 st or trackers a │ │ │ +00048050: 2062 6974 2068 6572 653c 2f68 323e 3c68 bit here

    ../src/torrent │ │ │ +00048070: 2e63 7070 3a33 3233 363c 2f68 343e 3c70 .cpp:3236

    ..time_p │ │ │ +000480c0: 6f69 6e74 3332 2063 6f6e 7374 206e 6f77 oint32 const now │ │ │ +000480d0: 203d 2061 7578 3a3a 7469 6d65 5f6e 6f77 = aux::time_now │ │ │ +000480e0: 3332 2829 3b0a 0a09 092f 2f20 6561 6368 32();....// each │ │ │ +000480f0: 206c 6973 7465 6e20 736f 636b 6574 2067 listen socket g │ │ │ +00048100: 6574 7320 6974 7320 6f77 6e20 616e 6e6f ets its own anno │ │ │ +00048110: 756e 6365 2073 7461 7465 0a09 092f 2f20 unce state...// │ │ │ +00048120: 736f 2074 6861 7420 6561 6368 206f 6e65 so that each one │ │ │ +00048130: 2073 686f 756c 6420 6765 7420 6174 206c should get at l │ │ │ +00048140: 6561 7374 206f 6e65 2061 6e6e 6f75 6e63 east one announc │ │ │ +00048150: 650a 0909 7374 643a 3a76 6563 746f 7226 e...std::vector& │ │ │ +00048160: 6c74 3b61 6e6e 6f75 6e63 655f 7374 6174 lt;announce_stat │ │ │ +00048170: 6526 6774 3b20 6c69 7374 656e 5f73 6f63 e> listen_soc │ │ │ +00048180: 6b65 745f 7374 6174 6573 3b0a 0a09 0962 ket_states;....b │ │ │ +00048190: 6f6f 6c20 636f 6e73 7420 616e 6e6f 756e ool const announ │ │ │ +000481a0: 6365 5f74 6f5f 616c 6c5f 7469 6572 7320 ce_to_all_tiers │ │ │ +000481b0: 3d20 7365 7474 696e 6773 2829 2e67 6574 = settings().get │ │ │ +000481c0: 5f62 6f6f 6c28 7365 7474 696e 6773 5f70 _bool(settings_p │ │ │ +000481d0: 6163 6b3a 3a61 6e6e 6f75 6e63 655f 746f ack::announce_to │ │ │ +000481e0: 5f61 6c6c 5f74 6965 7273 293b 0a09 0962 _all_tiers);...b │ │ │ +000481f0: 6f6f 6c20 636f 6e73 7420 616e 6e6f 756e ool const announ │ │ │ +00048200: 6365 5f74 6f5f 616c 6c5f 7472 6163 6b65 ce_to_all_tracke │ │ │ +00048210: 7273 203d 2073 6574 7469 6e67 7328 292e rs = settings(). │ │ │ +00048220: 6765 745f 626f 6f6c 2873 6574 7469 6e67 get_bool(setting │ │ │ +00048230: 735f 7061 636b 3a3a 616e 6e6f 756e 6365 s_pack::announce │ │ │ +00048240: 5f74 6f5f 616c 6c5f 7472 6163 6b65 7273 _to_all_trackers │ │ │ +00048250: 293b 0a23 6966 6e64 6566 2054 4f52 5245 );.#ifndef TORRE │ │ │ +00048260: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +00048270: 4e47 0a09 0969 6e74 2069 6478 203d 202d NG...int idx = - │ │ │ +00048280: 313b 0a09 0969 6620 2873 686f 756c 645f 1;...if (should_ │ │ │ +00048290: 6c6f 6728 2929 0a09 097b 0a09 0909 6465 log())...{....de │ │ │ +000482a0: 6275 675f 6c6f 6728 222a 2a2a 2061 6e6e bug_log("*** ann │ │ │ +000482b0: 6f75 6e63 653a 2022 0a09 0909 0922 5b20 ounce: "....."[ │ │ │ +000482c0: 616e 6e6f 756e 6365 5f74 6f5f 616c 6c5f announce_to_all_ │ │ │ +000482d0: 7469 6572 733a 2025 6420 616e 6e6f 756e tiers: %d announ │ │ │ +000482e0: 6365 5f74 6f5f 616c 6c5f 7472 6163 6b65 ce_to_all_tracke │ │ │ +000482f0: 7273 3a20 2564 206e 756d 5f74 7261 636b rs: %d num_track │ │ │ +00048300: 6572 733a 2025 6420 5d22 0a09 0909 092c ers: %d ]"....., │ │ │ +00048310: 2061 6e6e 6f75 6e63 655f 746f 5f61 6c6c announce_to_all │ │ │ +00048320: 5f74 6965 7273 0a09 0909 092c 2061 6e6e _tiers....., ann │ │ │ +00048330: 6f75 6e63 655f 746f 5f61 6c6c 5f74 7261 ounce_to_all_tra │ │ │ +00048340: 636b 6572 730a 0909 0909 2c20 696e 7428 ckers....., int( │ │ │ +00048350: 6d5f 7472 6163 6b65 7273 2e73 697a 6528 m_trackers.size( │ │ │ +00048360: 2929 293b 0a09 097d 0a23 656e 6469 660a )));...}.#endif. │ │ │ +00048370: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ +000483a0: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ +000483b0: 6165 203a 206d 5f74 7261 636b 6572 7329 ae : m_trackers) │ │ │ +000483c0: 0a3c 2f64 6976 3e09 097b 0a23 6966 6e64 .
    ..{.#ifnd │ │ │ +000483d0: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ +000483e0: 4c45 5f4c 4f47 4749 4e47 0a09 0909 2b2b LE_LOGGING....++ │ │ │ +000483f0: 6964 783b 0a23 656e 6469 660a 0909 0972 idx;.#endif....r │ │ │ +00048400: 6566 7265 7368 5f65 6e64 706f 696e 745f efresh_endpoint_ │ │ │ +00048410: 6c69 7374 286d 5f73 6573 2c20 6973 5f73 list(m_ses, is_s │ │ │ +00048420: 736c 5f74 6f72 7265 6e74 2829 2c20 626f sl_torrent(), bo │ │ │ +00048430: 6f6c 286d 5f63 6f6d 706c 6574 655f 7365 ol(m_complete_se │ │ │ +00048440: 6e74 292c 2061 6529 3b0a 0a09 0909 2f2f nt), ae);.....// │ │ │ +00048450: 2069 6620 7472 6163 6b65 7269 6420 6973 if trackerid is │ │ │ +00048460: 206e 6f74 2073 7065 6369 6669 6564 2066 not specified f │ │ │ +00048470: 6f72 2074 7261 636b 6572 2075 7365 2064 or tracker use d │ │ │ +00048480: 6566 6175 6c74 206f 6e65 2c20 7072 6f62 efault one, prob │ │ │ +00048490: 6162 6c79 2073 6574 2065 7870 6c69 6369 ably set explici │ │ │ +000484a0: 746c 790a 0909 0972 6571 2e74 7261 636b tly....req.track │ │ │ +000484b0: 6572 6964 203d 2061 652e 7472 6163 6b65 erid = ae.tracke │ │ │ +000484c0: 7269 642e 656d 7074 7928 2920 3f20 6d5f rid.empty() ? m_ │ │ │ +000484d0: 7472 6163 6b65 7269 6420 3a20 6165 2e74 trackerid : ae.t │ │ │ +000484e0: 7261 636b 6572 6964 3b0a 0909 0972 6571 rackerid;....req │ │ │ +000484f0: 2e75 726c 203d 2061 652e 7572 6c3b 0a0a .url = ae.url;.. │ │ │ +00048500: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ +00048510: 4932 500a 0909 092f 2f20 6966 2077 6520 I2P....// if we │ │ │ +00048520: 646f 6e27 7420 616c 6c6f 7720 6d69 7869 don't allow mixi │ │ │ +00048530: 6e67 206e 6f72 6d61 6c20 7065 6572 7320 ng normal peers │ │ │ +00048540: 696e 746f 2074 6869 7320 6932 7020 746f into this i2p to │ │ │ +00048550: 7272 656e 742c 0a09 0909 2f2f 2073 6b69 rrent,....// ski │ │ │ +00048560: 7020 6e6f 6e2d 6932 7020 7472 6163 6b65 p non-i2p tracke │ │ │ +00048570: 7273 2e20 7570 6461 7465 5f74 7261 636b rs. update_track │ │ │ +00048580: 6572 5f74 696d 6572 2829 2061 7070 6c69 er_timer() appli │ │ │ +00048590: 6573 2074 6865 0a09 0909 2f2f 2073 616d es the....// sam │ │ │ +000485a0: 6520 736b 6970 2073 6f20 7468 6520 7469 e skip so the ti │ │ │ +000485b0: 6d65 7220 646f 6573 6e27 7420 6b65 6570 mer doesn't keep │ │ │ +000485c0: 2066 6972 696e 6720 666f 7220 7472 6163 firing for trac │ │ │ +000485d0: 6b65 7273 2077 6527 6c6c 0a09 0909 2f2f kers we'll....// │ │ │ +000485e0: 206e 6576 6572 2063 6f6e 7461 6374 2e0a never contact.. │ │ │ +000485f0: 0909 0969 6620 2821 6932 705f 636f 6d70 ...if (!i2p_comp │ │ │ +00048600: 6174 6962 6c65 5f74 7261 636b 6572 2861 atible_tracker(a │ │ │ +00048610: 6529 2920 636f 6e74 696e 7565 3b0a 0909 e)) continue;... │ │ │ +00048620: 092f 2f20 7265 7120 6973 2072 6575 7365 .// req is reuse │ │ │ +00048630: 6420 6163 726f 7373 2069 7465 7261 7469 d across iterati │ │ │ +00048640: 6f6e 732c 2073 6f20 7365 7420 7468 6520 ons, so set the │ │ │ +00048650: 6932 7020 6269 7420 746f 206d 6174 6368 i2p bit to match │ │ │ +00048660: 0a09 0909 2f2f 2074 6869 7320 7472 6163 ....// this trac │ │ │ +00048670: 6b65 7220 7261 7468 6572 2074 6861 6e20 ker rather than │ │ │ +00048680: 6f6e 6c79 2065 7665 7220 4f52 2d69 6e67 only ever OR-ing │ │ │ +00048690: 2069 7420 696e 2e0a 0909 0969 6620 2861 it in.....if (a │ │ │ +000486a0: 652e 6932 7029 0a09 0909 0972 6571 2e6b e.i2p).....req.k │ │ │ +000486b0: 696e 6420 7c3d 2074 7261 636b 6572 5f72 ind |= tracker_r │ │ │ +000486c0: 6571 7565 7374 3a3a 6932 703b 0a09 0909 equest::i2p;.... │ │ │ +000486d0: 656c 7365 0a09 0909 0972 6571 2e6b 696e else.....req.kin │ │ │ +000486e0: 6420 2661 6d70 3b3d 207e 7472 6163 6b65 d &= ~tracke │ │ │ +000486f0: 725f 7265 7175 6573 743a 3a69 3270 3b0a r_request::i2p;. │ │ │ +00048700: 2365 6e64 6966 0a0a 0909 0966 6f72 2028 #endif.....for ( │ │ │ +00048710: 6175 746f 2661 6d70 3b20 6165 7020 3a20 auto& aep : │ │ │ +00048720: 6165 2e65 6e64 706f 696e 7473 290a 0909 ae.endpoints)... │ │ │ +00048730: 097b 0a09 0909 092f 2f20 646f 206e 6f74 .{.....// do not │ │ │ +00048740: 2061 6464 2063 6f64 6520 7768 6963 6820 add code which │ │ │ +00048750: 636f 6e74 696e 7565 7320 746f 2074 6865 continues to the │ │ │ +00048760: 206e 6578 7420 656e 6470 6f69 6e74 2068 next endpoint h │ │ │ +00048770: 6572 6521 0a09 0909 092f 2f20 6c69 7374 ere!.....// list │ │ │ +00048780: 656e 5f73 6f63 6b65 745f 7374 6174 6573 en_socket_states │ │ │ +00048790: 206e 6565 6473 2074 6f20 6265 2070 6f70 needs to be pop │ │ │ +000487a0: 756c 6174 6564 2065 7665 6e20 6966 206e ulated even if n │ │ │ +000487b0: 6f6e 6520 6f66 2074 6865 2065 6e64 706f one of the endpo │ │ │ +000487c0: 696e 7473 0a09 0909 092f 2f20 7769 6c6c ints.....// will │ │ │ +000487d0: 2062 6520 616e 6e6f 756e 6369 6e67 2066 be announcing f │ │ │ +000487e0: 6f72 2074 6869 7320 7472 6163 6b65 720a or this tracker. │ │ │ +000487f0: 0909 0909 2f2f 206f 7468 6572 7769 7365 ....// otherwise │ │ │ +00048800: 2074 6865 2065 6172 6c79 2062 6169 6c20 the early bail │ │ │ +00048810: 6f75 7420 7768 656e 206e 6569 7468 6572 out when neither │ │ │ +00048820: 2061 6e6e 6f75 6e63 655f 746f 5f61 6c6c announce_to_all │ │ │ +00048830: 5f74 7261 636b 6572 730a 3c2f 7072 653e _trackers.
    │ │ │ +00048840: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00048870: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00048880: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +000488b0: 656e 742e 6370 703a 3337 3730 3c2f 613e ent.cpp:3770 │ │ │ +000488c0: 3c2f 7464 3e3c 7464 3e6d 6f76 6520 7468 move th │ │ │ +000488d0: 6973 2069 6e74 6f20 6120 6675 6e63 7469 is into a functi │ │ │ +000488e0: 6f6e 206f 6e20 7472 6163 6b65 725f 6c69 on on tracker_li │ │ │ +000488f0: 7374 3c2f 7464 3e3c 2f74 723e 3c74 7220 st

    │ │ │ +00048940: 6d6f 7665 2074 6869 7320 696e 746f 2061 move this into a │ │ │ +00048950: 2066 756e 6374 696f 6e20 6f6e 2074 7261 function on tra │ │ │ +00048960: 636b 6572 5f6c 6973 743c 2f68 323e 3c68 cker_list

    ../src/torrent │ │ │ +00048980: 2e63 7070 3a33 3737 303c 2f68 343e 3c70 .cpp:3770

    .., stru │ │ │ +000489d0: 6374 2074 7261 636b 6572 5f72 6573 706f ct tracker_respo │ │ │ +000489e0: 6e73 6520 636f 6e73 7426 616d 703b 2072 nse const& r │ │ │ +000489f0: 6573 7029 0a09 7b0a 0909 544f 5252 454e esp)..{...TORREN │ │ │ +00048a00: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ +00048a10: 6c65 5f74 6872 6561 6428 2929 3b0a 0a09 le_thread());... │ │ │ +00048a20: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ +00048a30: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ +00048a40: 5254 2821 2872 2e6b 696e 6420 2661 6d70 RT(!(r.kind & │ │ │ +00048a50: 3b20 7472 6163 6b65 725f 7265 7175 6573 ; tracker_reques │ │ │ +00048a60: 743a 3a73 6372 6170 655f 7265 7175 6573 t::scrape_reques │ │ │ +00048a70: 7429 293b 0a0a 0909 2f2f 2069 6620 7468 t));....// if th │ │ │ +00048a80: 6520 7472 6163 6b65 7220 746f 6c64 2075 e tracker told u │ │ │ +00048a90: 7320 7768 6174 206f 7572 2065 7874 6572 s what our exter │ │ │ +00048aa0: 6e61 6c20 4950 2061 6464 7265 7373 2069 nal IP address i │ │ │ +00048ab0: 732c 2072 6563 6f72 6420 6974 2077 6974 s, record it wit │ │ │ +00048ac0: 680a 0909 2f2f 206f 7574 2065 7874 6572 h...// out exter │ │ │ +00048ad0: 6e61 6c20 4950 2063 6f75 6e74 6572 2028 nal IP counter ( │ │ │ +00048ae0: 616e 6420 7061 7373 2061 6c6f 6e67 2074 and pass along t │ │ │ +00048af0: 6865 2049 5020 6f66 2074 6865 2074 7261 he IP of the tra │ │ │ +00048b00: 636b 6572 2074 6f20 6b6e 6f77 0a09 092f cker to know.../ │ │ │ +00048b10: 2f20 7768 6f20 746f 2061 7474 7269 6275 / who to attribu │ │ │ +00048b20: 7465 2074 6869 7320 766f 7465 2074 6f29 te this vote to) │ │ │ +00048b30: 0a09 0969 6620 2872 6573 702e 6578 7465 ...if (resp.exte │ │ │ +00048b40: 726e 616c 5f69 7020 213d 2061 6464 7265 rnal_ip != addre │ │ │ +00048b50: 7373 2829 2026 616d 703b 2661 6d70 3b20 ss() && │ │ │ +00048b60: 2174 7261 636b 6572 5f69 702e 6973 5f75 !tracker_ip.is_u │ │ │ +00048b70: 6e73 7065 6369 6669 6564 2829 2026 616d nspecified() &am │ │ │ +00048b80: 703b 2661 6d70 3b20 722e 6f75 7467 6f69 p;& r.outgoi │ │ │ +00048b90: 6e67 5f73 6f63 6b65 7429 0a09 0909 6d5f ng_socket)....m_ │ │ │ +00048ba0: 7365 732e 7365 745f 6578 7465 726e 616c ses.set_external │ │ │ +00048bb0: 5f61 6464 7265 7373 2872 2e6f 7574 676f _address(r.outgo │ │ │ +00048bc0: 696e 675f 736f 636b 6574 2e67 6574 5f6c ing_socket.get_l │ │ │ +00048bd0: 6f63 616c 5f65 6e64 706f 696e 7428 290a ocal_endpoint(). │ │ │ +00048be0: 0909 0909 2c20 7265 7370 2e65 7874 6572 ...., resp.exter │ │ │ +00048bf0: 6e61 6c5f 6970 0a09 0909 092c 2061 7578 nal_ip....., aux │ │ │ +00048c00: 3a3a 7365 7373 696f 6e5f 696e 7465 7266 ::session_interf │ │ │ +00048c10: 6163 653a 3a73 6f75 7263 655f 7472 6163 ace::source_trac │ │ │ +00048c20: 6b65 722c 2074 7261 636b 6572 5f69 7029 ker, tracker_ip) │ │ │ +00048c30: 3b0a 0a09 0974 696d 655f 706f 696e 7433 ;....time_point3 │ │ │ +00048c40: 3220 636f 6e73 7420 6e6f 7720 3d20 6175 2 const now = au │ │ │ +00048c50: 783a 3a74 696d 655f 6e6f 7733 3228 293b x::time_now32(); │ │ │ +00048c60: 0a0a 0909 7072 6f74 6f63 6f6c 5f76 6572 ....protocol_ver │ │ │ +00048c70: 7369 6f6e 2063 6f6e 7374 2076 203d 2072 sion const v = r │ │ │ +00048c80: 2e69 6e66 6f5f 6861 7368 203d 3d20 746f .info_hash == to │ │ │ +00048c90: 7272 656e 745f 6669 6c65 2829 2e69 6e66 rrent_file().inf │ │ │ +00048ca0: 6f5f 6861 7368 6573 2829 2e76 310a 0909 o_hashes().v1... │ │ │ +00048cb0: 093f 2070 726f 746f 636f 6c5f 7665 7273 .? protocol_vers │ │ │ +00048cc0: 696f 6e3a 3a56 3120 3a20 7072 6f74 6f63 ion::V1 : protoc │ │ │ +00048cd0: 6f6c 5f76 6572 7369 6f6e 3a3a 5632 3b0a ol_version::V2;. │ │ │ +00048ce0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    . │ │ │ +00048d10: 0961 7578 3a3a 616e 6e6f 756e 6365 5f65 .aux::announce_e │ │ │ +00048d20: 6e74 7279 2a20 6165 203d 206d 5f74 7261 ntry* ae = m_tra │ │ │ +00048d30: 636b 6572 732e 6669 6e64 5f74 7261 636b ckers.find_track │ │ │ +00048d40: 6572 2872 2e75 726c 293b 0a3c 2f64 6976 er(r.url);.
    ...tcp::endpoin │ │ │ +00048d60: 7420 6c6f 6361 6c5f 656e 6470 6f69 6e74 t local_endpoint │ │ │ +00048d70: 3b0a 0909 6966 2028 6165 290a 0909 7b0a ;...if (ae)...{. │ │ │ +00048d80: 0909 0961 7574 6f2a 2061 6570 203d 2061 ...auto* aep = a │ │ │ +00048d90: 652d 2667 743b 6669 6e64 5f65 6e64 706f e->find_endpo │ │ │ +00048da0: 696e 7428 722e 6f75 7467 6f69 6e67 5f73 int(r.outgoing_s │ │ │ +00048db0: 6f63 6b65 7429 3b0a 0909 0969 6620 2861 ocket);....if (a │ │ │ +00048dc0: 6570 290a 0909 097b 0a09 0909 0961 7574 ep)....{.....aut │ │ │ +00048dd0: 6f26 616d 703b 2061 203d 2061 6570 2d26 o& a = aep-& │ │ │ +00048de0: 6774 3b69 6e66 6f5f 6861 7368 6573 5b76 gt;info_hashes[v │ │ │ +00048df0: 5d3b 0a0a 0909 0909 6c6f 6361 6c5f 656e ];......local_en │ │ │ +00048e00: 6470 6f69 6e74 203d 2061 6570 2d26 6774 dpoint = aep-> │ │ │ +00048e10: 3b6c 6f63 616c 5f65 6e64 706f 696e 743b ;local_endpoint; │ │ │ +00048e20: 0a09 0909 0969 6620 2872 6573 702e 696e .....if (resp.in │ │ │ +00048e30: 636f 6d70 6c65 7465 2026 6774 3b3d 2030 complete >= 0 │ │ │ +00048e40: 2920 612e 7363 7261 7065 5f69 6e63 6f6d ) a.scrape_incom │ │ │ +00048e50: 706c 6574 6520 3d20 7265 7370 2e69 6e63 plete = resp.inc │ │ │ +00048e60: 6f6d 706c 6574 653b 0a09 0909 0969 6620 omplete;.....if │ │ │ +00048e70: 2872 6573 702e 636f 6d70 6c65 7465 2026 (resp.complete & │ │ │ +00048e80: 6774 3b3d 2030 2920 612e 7363 7261 7065 gt;= 0) a.scrape │ │ │ +00048e90: 5f63 6f6d 706c 6574 6520 3d20 7265 7370 _complete = resp │ │ │ +00048ea0: 2e63 6f6d 706c 6574 653b 0a09 0909 0969 .complete;.....i │ │ │ +00048eb0: 6620 2872 6573 702e 646f 776e 6c6f 6164 f (resp.download │ │ │ +00048ec0: 6564 2026 6774 3b3d 2030 2920 612e 7363 ed >= 0) a.sc │ │ │ +00048ed0: 7261 7065 5f64 6f77 6e6c 6f61 6465 6420 rape_downloaded │ │ │ +00048ee0: 3d20 7265 7370 2e64 6f77 6e6c 6f61 6465 = resp.downloade │ │ │ +00048ef0: 643b 0a09 0909 0969 6620 2821 612e 7374 d;.....if (!a.st │ │ │ +00048f00: 6172 745f 7365 6e74 2026 616d 703b 2661 art_sent &&a │ │ │ +00048f10: 6d70 3b20 722e 6576 656e 7420 3d3d 2065 mp; r.event == e │ │ │ +00048f20: 7665 6e74 5f74 3a3a 7374 6172 7465 6429 vent_t::started) │ │ │ +00048f30: 0a09 0909 0909 612e 7374 6172 745f 7365 ......a.start_se │ │ │ +00048f40: 6e74 203d 2074 7275 653b 0a09 0909 0969 nt = true;.....i │ │ │ +00048f50: 6620 2821 612e 636f 6d70 6c65 7465 5f73 f (!a.complete_s │ │ │ +00048f60: 656e 7420 2661 6d70 3b26 616d 703b 2072 ent && r │ │ │ +00048f70: 2e65 7665 6e74 203d 3d20 6576 656e 745f .event == event_ │ │ │ +00048f80: 743a 3a63 6f6d 706c 6574 6564 290a 0909 t::completed)... │ │ │ +00048f90: 0909 7b0a 0909 0909 0961 2e63 6f6d 706c ..{......a.compl │ │ │ +00048fa0: 6574 655f 7365 6e74 203d 2074 7275 653b ete_sent = true; │ │ │ +00048fb0: 0a09 0909 0909 2f2f 2077 6520 7375 6363 ......// we succ │ │ │ +00048fc0: 6573 7366 756c 6c79 2072 6570 6f72 7465 essfully reporte │ │ │ +00048fd0: 6420 6576 656e 743d 636f 6d70 6c65 7465 d event=complete │ │ │ +00048fe0: 6420 746f 206f 6e65 2074 7261 636b 6572 d to one tracker │ │ │ +00048ff0: 2e20 446f 6e27 740a 0909 0909 092f 2f20 . Don't......// │ │ │ +00049000: 7365 6e64 2069 7420 746f 2061 6e79 206f send it to any o │ │ │ +00049010: 7468 6572 206f 6e65 7320 6672 6f6d 206e ther ones from n │ │ │ +00049020: 6f77 206f 6e20 2874 6865 7265 206d 6179 ow on (there may │ │ │ +00049030: 2062 6520 6f74 6865 720a 0909 0909 092f be other....../ │ │ │ +00049040: 2f20 616e 6e6f 756e 6365 7320 6f75 7473 / announces outs │ │ │ +00049050: 7461 6e64 696e 6720 7269 6768 7420 6e6f tanding right no │ │ │ +00049060: 7720 7468 6f75 6768 290a 0909 0909 096d w though)......m │ │ │ +00049070: 5f63 6f6d 706c 6574 655f 7365 6e74 203d _complete_sent = │ │ │ +00049080: 2074 7275 653b 0a09 0909 097d 0a09 0909 true;.....}.... │ │ │ +00049090: 0961 652d 2667 743b 7665 7269 6669 6564 .ae->verified │ │ │ +000490a0: 203d 2074 7275 653b 0a09 0909 0961 2e6e = true;.....a.n │ │ │ +000490b0: 6578 745f 616e 6e6f 756e 6365 203d 206e ext_announce = n │ │ │ +000490c0: 6f77 202b 2072 6573 702e 696e 7465 7276 ow + resp.interv │ │ │ +000490d0: 616c 3b0a 0909 0909 612e 6d69 6e5f 616e al;.....a.min_an │ │ │ +000490e0: 6e6f 756e 6365 203d 206e 6f77 202b 2072 nounce = now + r │ │ │ +000490f0: 6573 702e 6d69 6e5f 696e 7465 7276 616c esp.min_interval │ │ │ +00049100: 3b0a 0909 0909 612e 7570 6461 7469 6e67 ;.....a.updating │ │ │ +00049110: 203d 2066 616c 7365 3b0a 0909 0909 612e = false;.....a. │ │ │ +00049120: 6661 696c 7320 3d20 303b 0a09 0909 0961 fails = 0;.....a │ │ │ +00049130: 2e6c 6173 745f 6572 726f 722e 636c 6561 .last_error.clea │ │ │ +00049140: 7228 293b 0a09 0909 0961 2e6d 6573 7361 r();.....a.messa │ │ │ +00049150: 6765 203d 2021 7265 7370 2e77 6172 6e69 ge = !resp.warni │ │ │ +00049160: 6e67 5f6d 6573 7361 6765 2e65 6d70 7479 ng_message.empty │ │ │ +00049170: 2829 203f 2072 6573 702e 7761 726e 696e () ? resp.warnin │ │ │ +00049180: 675f 6d65 7373 6167 6520 3a20 7374 643a g_message : std: │ │ │ +00049190: 3a73 7472 696e 6728 293b 0a3c 2f70 7265 :string();.
    rele │ │ │ +000491d0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ +00049210: 7265 6e74 2e63 7070 3a33 3836 343c 2f61 rent.cpp:3864the de │ │ │ +00049230: 7374 696e 6174 696f 6e20 7374 7269 6e67 stination string │ │ │ +00049240: 2073 686f 756c 6420 6265 2062 6173 6536 should be base6 │ │ │ +00049250: 3420 6465 636f 6465 6420 616e 6420 7368 4 decoded and sh │ │ │ +00049260: 6132 3536 2068 6173 6865 6420 746f 2066 a256 hashed to f │ │ │ +00049270: 6f72 6d20 7468 6520 6465 7374 696e 6174 orm the destinat │ │ │ +00049280: 696f 6e20 6164 6472 6573 7320 616e 6420 ion address and │ │ │ +00049290: 7374 6f72 6520 7468 6174 2069 6e20 7468 store that in th │ │ │ +000492a0: 6520 6932 705f 7065 6572 206f 626a 6563 e i2p_peer objec │ │ │ +000492b0: 7420 6469 7265 6374 6c79 3c2f 7464 3e3c t directly< │ │ │ +000492c0: 2f74 723e 3c74 7220 6964 3d22 3137 3622 /tr>

    the dest │ │ │ +00049310: 696e 6174 696f 6e20 7374 7269 6e67 2073 ination string s │ │ │ +00049320: 686f 756c 6420 6265 2062 6173 6536 3420 hould be base64 │ │ │ +00049330: 6465 636f 6465 6420 616e 640a 7368 6132 decoded and.sha2 │ │ │ +00049340: 3536 2068 6173 6865 6420 746f 2066 6f72 56 hashed to for │ │ │ +00049350: 6d20 7468 6520 6465 7374 696e 6174 696f m the destinatio │ │ │ +00049360: 6e20 6164 6472 6573 7320 616e 6420 7374 n address and st │ │ │ +00049370: 6f72 650a 7468 6174 2069 6e20 7468 6520 ore.that in the │ │ │ +00049380: 6932 705f 7065 6572 206f 626a 6563 7420 i2p_peer object │ │ │ +00049390: 6469 7265 6374 6c79 3c2f 6832 3e3c 6834 directly

    ../src/torrent. │ │ │ +000493b0: 6370 703a 3338 3634 3c2f 6834 3e3c 7072 cpp:3864

    ..for (au │ │ │ +00049400: 746f 2063 6f6e 7374 2661 6d70 3b20 6920 to const& i │ │ │ +00049410: 3a20 7265 7370 2e70 6565 7273 290a 0909 : resp.peers)... │ │ │ +00049420: 7b0a 0909 092f 2f20 646f 6e27 7420 6d61 {....// don't ma │ │ │ +00049430: 6b65 2063 6f6e 6e65 6374 696f 6e73 2074 ke connections t │ │ │ +00049440: 6f20 6f75 7273 656c 660a 0909 0969 6620 o ourself....if │ │ │ +00049450: 2869 2e70 6964 203d 3d20 6d5f 7065 6572 (i.pid == m_peer │ │ │ +00049460: 5f69 6429 0a09 0909 0963 6f6e 7469 6e75 _id).....continu │ │ │ +00049470: 653b 0a0a 2369 6620 544f 5252 454e 545f e;..#if TORRENT_ │ │ │ +00049480: 5553 455f 4932 500a 0909 0969 6620 2872 USE_I2P....if (r │ │ │ +00049490: 2e69 3270 636f 6e6e 290a 0909 097b 0a09 .i2pconn)....{.. │ │ │ +000494a0: 0909 092f 2f20 7468 6973 2069 7320 616e ...// this is an │ │ │ +000494b0: 2069 3270 206e 616d 652c 2077 6520 6e65 i2p name, we ne │ │ │ +000494c0: 6564 2074 6f20 7573 6520 7468 6520 5341 ed to use the SA │ │ │ +000494d0: 4d20 636f 6e6e 6563 7469 6f6e 0a09 0909 M connection.... │ │ │ +000494e0: 092f 2f20 746f 2064 6f20 7468 6520 6e61 .// to do the na │ │ │ +000494f0: 6d65 206c 6f6f 6b75 700a 0909 0909 6966 me lookup.....if │ │ │ +00049500: 2028 7374 7269 6e67 5f65 6e64 735f 7769 (string_ends_wi │ │ │ +00049510: 7468 2869 2e68 6f73 746e 616d 652c 2022 th(i.hostname, " │ │ │ +00049520: 2e69 3270 2229 290a 0909 0909 7b0a 0909 .i2p")).....{... │ │ │ +00049530: 0909 0941 4444 5f4f 5554 5354 414e 4449 ...ADD_OUTSTANDI │ │ │ +00049540: 4e47 5f41 5359 4e43 2822 746f 7272 656e NG_ASYNC("torren │ │ │ +00049550: 743a 3a6f 6e5f 6932 705f 7265 736f 6c76 t::on_i2p_resolv │ │ │ +00049560: 6522 293b 0a09 0909 0909 722e 6932 7063 e");......r.i2pc │ │ │ +00049570: 6f6e 6e2d 2667 743b 6173 796e 635f 6e61 onn->async_na │ │ │ +00049580: 6d65 5f6c 6f6f 6b75 7028 692e 686f 7374 me_lookup(i.host │ │ │ +00049590: 6e61 6d65 2e63 5f73 7472 2829 0a09 0909 name.c_str().... │ │ │ +000495a0: 0909 092c 205b 7365 6c66 203d 2073 6861 ..., [self = sha │ │ │ +000495b0: 7265 645f 6672 6f6d 5f74 6869 7328 295d red_from_this()] │ │ │ +000495c0: 2028 6572 726f 725f 636f 6465 2063 6f6e (error_code con │ │ │ +000495d0: 7374 2661 6d70 3b20 6563 2c20 6368 6172 st& ec, char │ │ │ +000495e0: 2063 6f6e 7374 2a20 6465 7374 290a 0909 const* dest)... │ │ │ +000495f0: 0909 0909 7b20 7365 6c66 2d26 6774 3b74 ....{ self->t │ │ │ +00049600: 6f72 7265 6e74 3a3a 6f6e 5f69 3270 5f72 orrent::on_i2p_r │ │ │ +00049610: 6573 6f6c 7665 2865 632c 2064 6573 742c esolve(ec, dest, │ │ │ +00049620: 2070 6565 725f 696e 666f 3a3a 7472 6163 peer_info::trac │ │ │ +00049630: 6b65 7229 3b20 7d29 3b0a 0909 0909 7d0a ker); });.....}. │ │ │ +00049640: 0909 0909 656c 7365 0a09 0909 097b 0a3c ....else.....{.< │ │ │ +00049650: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +00049660: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +00049670: 7769 6474 683d 2231 3030 2522 3e09 0909 width="100%">... │ │ │ +00049680: 0909 746f 7272 656e 745f 7374 6174 6520 ..torrent_state │ │ │ +00049690: 7374 203d 2067 6574 5f70 6565 725f 6c69 st = get_peer_li │ │ │ +000496a0: 7374 5f73 7461 7465 2829 3b0a 3c2f 6469 st_state();......need_peer │ │ │ +000496c0: 5f6c 6973 7428 293b 0a09 0909 0909 6966 _list();......if │ │ │ +000496d0: 2028 6d5f 7065 6572 5f6c 6973 742d 2667 (m_peer_list-&g │ │ │ +000496e0: 743b 6164 645f 6932 705f 7065 6572 2869 t;add_i2p_peer(i │ │ │ +000496f0: 2e68 6f73 746e 616d 652c 2070 6565 725f .hostname, peer_ │ │ │ +00049700: 696e 666f 3a3a 7472 6163 6b65 722c 207b info::tracker, { │ │ │ +00049710: 7d2c 2026 616d 703b 7374 2929 0a09 0909 }, &st)).... │ │ │ +00049720: 0909 0973 7461 7465 5f75 7064 6174 6564 ...state_updated │ │ │ +00049730: 2829 3b0a 0909 0909 0970 6565 7273 5f65 ();......peers_e │ │ │ +00049740: 7261 7365 6428 7374 2e65 7261 7365 6429 rased(st.erased) │ │ │ +00049750: 3b0a 0909 0909 7d0a 0909 097d 0a09 0909 ;.....}....}.... │ │ │ +00049760: 656c 7365 0a23 656e 6469 660a 0909 097b else.#endif....{ │ │ │ +00049770: 0a09 0909 0941 4444 5f4f 5554 5354 414e .....ADD_OUTSTAN │ │ │ +00049780: 4449 4e47 5f41 5359 4e43 2822 746f 7272 DING_ASYNC("torr │ │ │ +00049790: 656e 743a 3a6f 6e5f 7065 6572 5f6e 616d ent::on_peer_nam │ │ │ +000497a0: 655f 6c6f 6f6b 7570 2229 3b0a 0909 0909 e_lookup");..... │ │ │ +000497b0: 6d5f 7365 732e 6765 745f 7265 736f 6c76 m_ses.get_resolv │ │ │ +000497c0: 6572 2829 2e61 7379 6e63 5f72 6573 6f6c er().async_resol │ │ │ +000497d0: 7665 2869 2e68 6f73 746e 616d 652c 2061 ve(i.hostname, a │ │ │ +000497e0: 7578 3a3a 7265 736f 6c76 6572 5f69 6e74 ux::resolver_int │ │ │ +000497f0: 6572 6661 6365 3a3a 6162 6f72 745f 6f6e erface::abort_on │ │ │ +00049800: 5f73 6875 7464 6f77 6e0a 0909 0909 092c _shutdown......, │ │ │ +00049810: 2073 7464 3a3a 6269 6e64 2826 616d 703b std::bind(& │ │ │ +00049820: 746f 7272 656e 743a 3a6f 6e5f 7065 6572 torrent::on_peer │ │ │ +00049830: 5f6e 616d 655f 6c6f 6f6b 7570 2c20 7368 _name_lookup, sh │ │ │ +00049840: 6172 6564 5f66 726f 6d5f 7468 6973 2829 ared_from_this() │ │ │ +00049850: 2c20 5f31 2c20 5f32 2c20 692e 706f 7274 , _1, _2, i.port │ │ │ +00049860: 2c20 7629 293b 0a09 0909 7d0a 0909 7d0a , v));....}...}. │ │ │ +00049870: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ +00049880: 5f49 3250 0a09 0969 6620 2872 2e69 3270 _I2P...if (r.i2p │ │ │ +00049890: 636f 6e6e 290a 0909 7b0a 0909 0966 6f72 conn)...{....for │ │ │ +000498a0: 2028 6175 746f 2063 6f6e 7374 2661 6d70 (auto const& │ │ │ +000498b0: 3b20 6920 3a20 7265 7370 2e69 3270 5f70 ; i : resp.i2p_p │ │ │ +000498c0: 6565 7273 290a 0909 097b 0a09 0909 0961 eers)....{.....a │ │ │ +000498d0: 6464 5f69 3270 5f70 6565 7228 692e 6465 dd_i2p_peer(i.de │ │ │ +000498e0: 7374 696e 6174 696f 6e2c 2070 6565 725f stination, peer_ │ │ │ +000498f0: 696e 666f 3a3a 7472 6163 6b65 7229 3b0a info::tracker);. │ │ │ +00049900: 0909 097d 0a09 097d 0a23 656e 6469 660a ...}...}.#endif. │ │ │ +00049910: 0a09 092f 2f20 7468 6572 6520 6172 6520 ...// there are │ │ │ +00049920: 3220 7265 6173 6f6e 7320 746f 2061 6c6c 2 reasons to all │ │ │ +00049930: 6f77 206c 6f63 616c 2049 5073 2074 6f20 ow local IPs to │ │ │ +00049940: 6265 2072 6574 7572 6e65 6420 6672 6f6d be returned from │ │ │ +00049950: 2061 0a09 092f 2f20 6e6f 6e2d 6c6f 6361 a...// non-loca │ │ │ +00049960: 6c20 7472 6163 6b65 720a 0909 2f2f 2031 l tracker...// 1 │ │ │ +00049970: 2e20 7265 7472 6163 6b65 7273 2061 7265 . retrackers are │ │ │ +00049980: 2070 6f70 756c 6172 2069 6e20 7275 7373 popular in russ │ │ │ +00049990: 6961 2c20 7768 6572 6520 616e 2049 5350 ia, where an ISP │ │ │ +000499a0: 2072 756e 7320 6120 7472 6163 6b65 7220 runs a tracker │ │ │ +000499b0: 7769 7468 696e 0a09 092f 2f20 2020 2074 within...// t │ │ │ +000499c0: 6865 2041 5320 2862 7574 206e 6f74 206f he AS (but not o │ │ │ +000499d0: 6e20 7468 6520 6c6f 6361 6c20 6e65 7477 n the local netw │ │ │ +000499e0: 6f72 6b29 2067 6976 696e 6720 6f75 7420 ork) giving out │ │ │ +000499f0: 7065 6572 7320 6f6e 6c79 2066 726f 6d20 peers only from │ │ │ +00049a00: 7468 650a 0909 2f2f 2020 2020 6c6f 6361 the...// loca │ │ │ +00049a10: 6c20 6e65 7477 6f72 6b0a 3c2f 7072 653e l network. │ │ │ +00049a20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00049a50: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00049a60: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +00049a90: 656e 742e 6370 703a 3431 3838 3c2f 613e ent.cpp:4188 │ │ │ +00049aa0: 3c2f 7464 3e3c 7464 3e73 746f 7265 2069 store i │ │ │ +00049ab0: 3270 2061 6464 7265 7373 6573 2061 7320 2p addresses as │ │ │ +00049ac0: 6120 3332 2062 7974 6520 7368 6132 3536 a 32 byte sha256 │ │ │ +00049ad0: 2068 6173 6820 696e 2074 6865 2069 3270 hash in the i2p │ │ │ +00049ae0: 5f70 6565 7220 6f62 6a65 6374 2c20 7261 _peer object, ra │ │ │ +00049af0: 7468 6572 2074 6861 6e20 7265 736f 6c76 ther than resolv │ │ │ +00049b00: 696e 6720 6974 2069 6e74 6f20 7468 6520 ing it into the │ │ │ +00049b10: 6675 6c6c 2076 6173 6536 3420 6465 7374 full vase64 dest │ │ │ +00049b20: 696e 6174 696f 6e2e 2057 6520 7368 6f75 ination. We shou │ │ │ +00049b30: 6c64 206b 6565 7020 7468 6520 6675 6c6c ld keep the full │ │ │ +00049b40: 2064 6573 7469 6e61 7469 6f6e 2061 7320 destination as │ │ │ +00049b50: 6120 6361 6368 6520 696e 2074 6865 2069 a cache in the i │ │ │ +00049b60: 3270 5f70 6565 7220 6f62 6a65 6374 2073 2p_peer object s │ │ │ +00049b70: 7469 6c6c 2e3c 2f74 643e 3c2f 7472 3e3c till.< │ │ │ +00049b80: 7472 2069 643d 2231 3737 2220 7374 796c tr id="177" styl │ │ │ +00049b90: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00049ba0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00049bb0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00049bc0: 6832 3e73 746f 7265 2069 3270 2061 6464 h2>store i2p add │ │ │ +00049bd0: 7265 7373 6573 2061 7320 6120 3332 2062 resses as a 32 b │ │ │ +00049be0: 7974 6520 7368 6132 3536 2068 6173 6820 yte sha256 hash │ │ │ +00049bf0: 696e 2074 6865 0a69 3270 5f70 6565 7220 in the.i2p_peer │ │ │ +00049c00: 6f62 6a65 6374 2c20 7261 7468 6572 2074 object, rather t │ │ │ +00049c10: 6861 6e20 7265 736f 6c76 696e 6720 6974 han resolving it │ │ │ +00049c20: 2069 6e74 6f20 7468 6520 6675 6c6c 2076 into the full v │ │ │ +00049c30: 6173 6536 340a 6465 7374 696e 6174 696f ase64.destinatio │ │ │ +00049c40: 6e2e 2057 6520 7368 6f75 6c64 206b 6565 n. We should kee │ │ │ +00049c50: 7020 7468 6520 6675 6c6c 2064 6573 7469 p the full desti │ │ │ +00049c60: 6e61 7469 6f6e 2061 7320 6120 6361 6368 nation as a cach │ │ │ +00049c70: 6520 696e 2074 6865 0a69 3270 5f70 6565 e in the.i2p_pee │ │ │ +00049c80: 7220 6f62 6a65 6374 2073 7469 6c6c 2e3c r object still.< │ │ │ +00049c90: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +00049ca0: 6f72 7265 6e74 2e63 7070 3a34 3138 383c orrent.cpp:4188< │ │ │ +00049cb0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #i
    │ │ │ +00049cf0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +00049d00: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ +00049d10: 656c 7365 0a09 097b 0a09 0909 6465 6275  else...{....debu
    │ │ │ +00049d20: 675f 6c6f 6728 222a 2a2a 2066 6f75 6e64  g_log("*** found
    │ │ │ +00049d30: 206e 6f20 7472 6163 6b65 7220 656e 6470   no tracker endp
    │ │ │ +00049d40: 6f69 6e74 7320 746f 2061 6e6e 6f75 6e63  oints to announc
    │ │ │ +00049d50: 6522 293b 0a09 097d 0a23 656e 6469 660a  e");...}.#endif.
    │ │ │ +00049d60: 097d 0a0a 2369 6620 544f 5252 454e 545f  .}..#if TORRENT_
    │ │ │ +00049d70: 4142 495f 5645 5253 494f 4e20 3d3d 2031  ABI_VERSION == 1
    │ │ │ +00049d80: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ +00049d90: 7365 745f 7472 6163 6b65 725f 6c6f 6769  set_tracker_logi
    │ │ │ +00049da0: 6e28 7374 643a 3a73 7472 696e 6720 636f  n(std::string co
    │ │ │ +00049db0: 6e73 7426 616d 703b 206e 616d 650a 0909  nst& name...
    │ │ │ +00049dc0: 2c20 7374 643a 3a73 7472 696e 6720 636f  , std::string co
    │ │ │ +00049dd0: 6e73 7426 616d 703b 2070 7729 0a09 7b0a  nst& pw)..{.
    │ │ │ +00049de0: 0909 6d5f 7573 6572 6e61 6d65 203d 206e  ..m_username = n
    │ │ │ +00049df0: 616d 653b 0a09 096d 5f70 6173 7377 6f72  ame;...m_passwor
    │ │ │ +00049e00: 6420 3d20 7077 3b0a 097d 0a23 656e 6469  d = pw;..}.#endi
    │ │ │ +00049e10: 660a 0a23 6966 2054 4f52 5245 4e54 5f55  f..#if TORRENT_U
    │ │ │ +00049e20: 5345 5f49 3250 0a09 766f 6964 2074 6f72  SE_I2P..void tor
    │ │ │ +00049e30: 7265 6e74 3a3a 6164 645f 6932 705f 7065  rent::add_i2p_pe
    │ │ │ +00049e40: 6572 2873 6861 3235 365f 6861 7368 2063  er(sha256_hash c
    │ │ │ +00049e50: 6f6e 7374 2661 6d70 3b20 6465 7374 2c20  onst& dest, 
    │ │ │ +00049e60: 7065 6572 5f73 6f75 7263 655f 666c 6167  peer_source_flag
    │ │ │ +00049e70: 735f 7420 636f 6e73 7420 736f 7572 6365  s_t const source
    │ │ │ +00049e80: 290a 097b 0a3c 6469 7620 7374 796c 653d  )..{.
    ..i2p_connect │ │ │ +00049ec0: 696f 6e26 616d 703b 2069 3270 636f 6e6e ion& i2pconn │ │ │ +00049ed0: 203d 2073 6573 7369 6f6e 2829 2e69 3270 = session().i2p │ │ │ +00049ee0: 5f63 6f6e 6e28 293b 0a3c 2f64 6976 3e09 _conn();.
    . │ │ │ +00049ef0: 0969 6620 2821 6932 7063 6f6e 6e2e 6973 .if (!i2pconn.is │ │ │ +00049f00: 5f6f 7065 6e28 2929 2072 6574 7572 6e3b _open()) return; │ │ │ +00049f10: 0a0a 0909 7374 643a 3a73 7472 696e 6720 ....std::string │ │ │ +00049f20: 6465 7374 696e 6174 696f 6e20 3d20 6261 destination = ba │ │ │ +00049f30: 7365 3332 656e 636f 6465 5f69 3270 2864 se32encode_i2p(d │ │ │ +00049f40: 6573 7429 3b0a 0909 6465 7374 696e 6174 est);...destinat │ │ │ +00049f50: 696f 6e20 2b3d 2022 2e62 3332 2e69 3270 ion += ".b32.i2p │ │ │ +00049f60: 223b 0a0a 0909 4144 445f 4f55 5453 5441 ";....ADD_OUTSTA │ │ │ +00049f70: 4e44 494e 475f 4153 594e 4328 2274 6f72 NDING_ASYNC("tor │ │ │ +00049f80: 7265 6e74 3a3a 6f6e 5f69 3270 5f72 6573 rent::on_i2p_res │ │ │ +00049f90: 6f6c 7665 2229 3b0a 0909 6932 7063 6f6e olve");...i2pcon │ │ │ +00049fa0: 6e2e 6173 796e 635f 6e61 6d65 5f6c 6f6f n.async_name_loo │ │ │ +00049fb0: 6b75 7028 6465 7374 696e 6174 696f 6e2e kup(destination. │ │ │ +00049fc0: 635f 7374 7228 290a 0909 092c 205b 7365 c_str()...., [se │ │ │ +00049fd0: 6c66 203d 2073 6861 7265 645f 6672 6f6d lf = shared_from │ │ │ +00049fe0: 5f74 6869 7328 292c 2073 6f75 7263 655d _this(), source] │ │ │ +00049ff0: 2028 6572 726f 725f 636f 6465 2063 6f6e (error_code con │ │ │ +0004a000: 7374 2661 6d70 3b20 6563 2c20 6368 6172 st& ec, char │ │ │ +0004a010: 2063 6f6e 7374 2a20 6429 0a09 0909 7b20 const* d)....{ │ │ │ +0004a020: 7365 6c66 2d26 6774 3b74 6f72 7265 6e74 self->torrent │ │ │ +0004a030: 3a3a 6f6e 5f69 3270 5f72 6573 6f6c 7665 ::on_i2p_resolve │ │ │ +0004a040: 2865 632c 2064 2c20 736f 7572 6365 293b (ec, d, source); │ │ │ +0004a050: 207d 293b 0a09 7d0a 0a09 766f 6964 2074 });..}...void t │ │ │ +0004a060: 6f72 7265 6e74 3a3a 6f6e 5f69 3270 5f72 orrent::on_i2p_r │ │ │ +0004a070: 6573 6f6c 7665 2865 7272 6f72 5f63 6f64 esolve(error_cod │ │ │ +0004a080: 6520 636f 6e73 7426 616d 703b 2065 632c e const& ec, │ │ │ +0004a090: 2063 6861 7220 636f 6e73 742a 2064 6573 char const* des │ │ │ +0004a0a0: 742c 2070 6565 725f 736f 7572 6365 5f66 t, peer_source_f │ │ │ +0004a0b0: 6c61 6773 5f74 2063 6f6e 7374 2073 6f75 lags_t const sou │ │ │ +0004a0c0: 7263 6529 2074 7279 0a09 7b0a 0909 544f rce) try..{...TO │ │ │ +0004a0d0: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ +0004a0e0: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ +0004a0f0: 3b0a 0a09 0949 4e56 4152 4941 4e54 5f43 ;....INVARIANT_C │ │ │ +0004a100: 4845 434b 3b0a 0a09 0943 4f4d 504c 4554 HECK;....COMPLET │ │ │ +0004a110: 455f 4153 594e 4328 2274 6f72 7265 6e74 E_ASYNC("torrent │ │ │ +0004a120: 3a3a 6f6e 5f69 3270 5f72 6573 6f6c 7665 ::on_i2p_resolve │ │ │ +0004a130: 2229 3b0a 2369 666e 6465 6620 544f 5252 ");.#ifndef TORR │ │ │ +0004a140: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ +0004a150: 494e 470a 0909 6966 2028 6563 2026 616d ING...if (ec &am │ │ │ +0004a160: 703b 2661 6d70 3b20 7368 6f75 6c64 5f6c p;& should_l │ │ │ +0004a170: 6f67 2829 290a 0909 0964 6562 7567 5f6c og())....debug_l │ │ │ +0004a180: 6f67 2822 6932 705f 7265 736f 6c76 6520 og("i2p_resolve │ │ │ +0004a190: 6572 726f 723a 2025 7322 2c20 6563 2e6d error: %s", ec.m │ │ │ +0004a1a0: 6573 7361 6765 2829 2e63 5f73 7472 2829 essage().c_str() │ │ │ +0004a1b0: 293b 0a23 656e 6469 660a 0909 6966 2028 );.#endif...if ( │ │ │ +0004a1c0: 6563 207c 7c20 6d5f 6162 6f72 7420 7c7c ec || m_abort || │ │ │ +0004a1d0: 206d 5f73 6573 2e69 735f 6162 6f72 7465 m_ses.is_aborte │ │ │ +0004a1e0: 6428 2929 2072 6574 7572 6e3b 0a0a 0909 d()) return;.... │ │ │ +0004a1f0: 6e65 6564 5f70 6565 725f 6c69 7374 2829 need_peer_list() │ │ │ +0004a200: 3b0a 0909 746f 7272 656e 745f 7374 6174 ;...torrent_stat │ │ │ +0004a210: 6520 7374 203d 2067 6574 5f70 6565 725f e st = get_peer_ │ │ │ +0004a220: 6c69 7374 5f73 7461 7465 2829 3b0a 0909 list_state();... │ │ │ +0004a230: 6966 2028 6d5f 7065 6572 5f6c 6973 742d if (m_peer_list- │ │ │ +0004a240: 2667 743b 6164 645f 6932 705f 7065 6572 >add_i2p_peer │ │ │ +0004a250: 2864 6573 742c 2073 6f75 7263 652c 207b (dest, source, { │ │ │ +0004a260: 7d2c 2026 616d 703b 7374 2929 0a09 0909 }, &st)).... │ │ │ +0004a270: 7374 6174 655f 7570 6461 7465 6428 293b state_updated(); │ │ │ +0004a280: 0a09 0970 6565 7273 5f65 7261 7365 6428 ...peers_erased( │ │ │ +0004a290: 7374 2e65 7261 7365 6429 3b0a 0a3c 2f70 st.erased);..

    re │ │ │ +0004a2d0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/t │ │ │ +0004a310: 6f72 7265 6e74 2e63 7070 3a34 3234 353c orrent.cpp:4245< │ │ │ +0004a320: 2f61 3e3c 2f74 643e 3c74 643e 6164 6420 /a>add │ │ │ +0004a330: 6f6e 6520 7065 6572 2070 6572 2049 5020 one peer per IP │ │ │ +0004a340: 7468 6520 686f 7374 6e61 6d65 2072 6573 the hostname res │ │ │ +0004a350: 6f6c 7665 7320 746f 3c2f 7464 3e3c 2f74 olves to

    add one pe │ │ │ +0004a3b0: 6572 2070 6572 2049 5020 7468 6520 686f er per IP the ho │ │ │ +0004a3c0: 7374 6e61 6d65 2072 6573 6f6c 7665 7320 stname resolves │ │ │ +0004a3d0: 746f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 to

    ../sr │ │ │ +0004a3e0: 632f 746f 7272 656e 742e 6370 703a 3432 c/torrent.cpp:42 │ │ │ +0004a3f0: 3435 3c2f 6834 3e3c 7072 6520 7374 796c 45

    .catch (...) { 
    │ │ │ +0004a440: 6861 6e64 6c65 5f65 7863 6570 7469 6f6e  handle_exception
    │ │ │ +0004a450: 2829 3b20 7d0a 2365 6e64 6966 0a0a 0976  (); }.#endif...v
    │ │ │ +0004a460: 6f69 6420 746f 7272 656e 743a 3a6f 6e5f  oid torrent::on_
    │ │ │ +0004a470: 7065 6572 5f6e 616d 655f 6c6f 6f6b 7570  peer_name_lookup
    │ │ │ +0004a480: 2865 7272 6f72 5f63 6f64 6520 636f 6e73  (error_code cons
    │ │ │ +0004a490: 7426 616d 703b 2065 0a09 092c 2073 7464  t& e..., std
    │ │ │ +0004a4a0: 3a3a 7665 6374 6f72 266c 743b 6164 6472  ::vector<addr
    │ │ │ +0004a4b0: 6573 7326 6774 3b20 636f 6e73 7426 616d  ess> const&am
    │ │ │ +0004a4c0: 703b 2068 6f73 745f 6c69 7374 2c20 696e  p; host_list, in
    │ │ │ +0004a4d0: 7420 636f 6e73 7420 706f 7274 0a09 092c  t const port...,
    │ │ │ +0004a4e0: 2070 726f 746f 636f 6c5f 7665 7273 696f   protocol_versio
    │ │ │ +0004a4f0: 6e20 636f 6e73 7420 7629 2074 7279 0a09  n const v) try..
    │ │ │ +0004a500: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +0004a510: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ +0004a520: 6561 6428 2929 3b0a 0a09 0949 4e56 4152  ead());....INVAR
    │ │ │ +0004a530: 4941 4e54 5f43 4845 434b 3b0a 0a09 0943  IANT_CHECK;....C
    │ │ │ +0004a540: 4f4d 504c 4554 455f 4153 594e 4328 2274  OMPLETE_ASYNC("t
    │ │ │ +0004a550: 6f72 7265 6e74 3a3a 6f6e 5f70 6565 725f  orrent::on_peer_
    │ │ │ +0004a560: 6e61 6d65 5f6c 6f6f 6b75 7022 293b 0a0a  name_lookup");..
    │ │ │ +0004a570: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +0004a580: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +0004a590: 0909 6966 2028 6520 2661 6d70 3b26 616d  ..if (e &&am
    │ │ │ +0004a5a0: 703b 2073 686f 756c 645f 6c6f 6728 2929  p; should_log())
    │ │ │ +0004a5b0: 0a09 0909 6465 6275 675f 6c6f 6728 2270  ....debug_log("p
    │ │ │ +0004a5c0: 6565 7220 6e61 6d65 206c 6f6f 6b75 7020  eer name lookup 
    │ │ │ +0004a5d0: 6572 726f 723a 2025 7322 2c20 652e 6d65  error: %s", e.me
    │ │ │ +0004a5e0: 7373 6167 6528 292e 635f 7374 7228 2929  ssage().c_str())
    │ │ │ +0004a5f0: 3b0a 2365 6e64 6966 0a0a 0909 6966 2028  ;.#endif....if (
    │ │ │ +0004a600: 6520 7c7c 206d 5f61 626f 7274 207c 7c20  e || m_abort || 
    │ │ │ +0004a610: 686f 7374 5f6c 6973 742e 656d 7074 7928  host_list.empty(
    │ │ │ +0004a620: 2920 7c7c 206d 5f73 6573 2e69 735f 6162  ) || m_ses.is_ab
    │ │ │ +0004a630: 6f72 7465 6428 2929 2072 6574 7572 6e3b  orted()) return;
    │ │ │ +0004a640: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0004a670: 0909 7463 703a 3a65 6e64 706f 696e 7420 ..tcp::endpoint │ │ │ +0004a680: 686f 7374 2868 6f73 745f 6c69 7374 2e66 host(host_list.f │ │ │ +0004a690: 726f 6e74 2829 2c20 7374 643a 3a75 696e ront(), std::uin │ │ │ +0004a6a0: 7431 365f 7428 706f 7274 2929 3b0a 3c2f t16_t(port));....if (m_ip_ │ │ │ +0004a6c0: 6669 6c74 6572 2026 616d 703b 2661 6d70 filter && │ │ │ +0004a6d0: 3b20 6d5f 6970 5f66 696c 7465 722d 2667 ; m_ip_filter-&g │ │ │ +0004a6e0: 743b 6163 6365 7373 2868 6f73 742e 6164 t;access(host.ad │ │ │ +0004a6f0: 6472 6573 7328 2929 2026 616d 703b 2069 dress()) & i │ │ │ +0004a700: 705f 6669 6c74 6572 3a3a 626c 6f63 6b65 p_filter::blocke │ │ │ +0004a710: 6429 0a09 097b 0a23 6966 6e64 6566 2054 d)...{.#ifndef T │ │ │ +0004a720: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +0004a730: 4f47 4749 4e47 0a09 0909 6966 2028 7368 OGGING....if (sh │ │ │ +0004a740: 6f75 6c64 5f6c 6f67 2829 290a 0909 097b ould_log())....{ │ │ │ +0004a750: 0a09 0909 0964 6562 7567 5f6c 6f67 2822 .....debug_log(" │ │ │ +0004a760: 626c 6f63 6b65 6420 6970 2066 726f 6d20 blocked ip from │ │ │ +0004a770: 7472 6163 6b65 723a 2025 7322 2c20 686f tracker: %s", ho │ │ │ +0004a780: 7374 2e61 6464 7265 7373 2829 2e74 6f5f st.address().to_ │ │ │ +0004a790: 7374 7269 6e67 2829 2e63 5f73 7472 2829 string().c_str() │ │ │ +0004a7a0: 293b 0a09 0909 7d0a 2365 6e64 6966 0a09 );....}.#endif.. │ │ │ +0004a7b0: 0909 6966 2028 6d5f 7365 732e 616c 6572 ..if (m_ses.aler │ │ │ +0004a7c0: 7473 2829 2e73 686f 756c 645f 706f 7374 ts().should_post │ │ │ +0004a7d0: 266c 743b 7065 6572 5f62 6c6f 636b 6564 <peer_blocked │ │ │ +0004a7e0: 5f61 6c65 7274 2667 743b 2829 290a 0909 _alert>())... │ │ │ +0004a7f0: 0909 6d5f 7365 732e 616c 6572 7473 2829 ..m_ses.alerts() │ │ │ +0004a800: 2e65 6d70 6c61 6365 5f61 6c65 7274 266c .emplace_alert&l │ │ │ +0004a810: 743b 7065 6572 5f62 6c6f 636b 6564 5f61 t;peer_blocked_a │ │ │ +0004a820: 6c65 7274 2667 743b 2867 6574 5f68 616e lert>(get_han │ │ │ +0004a830: 646c 6528 290a 0909 0909 092c 2068 6f73 dle()......, hos │ │ │ +0004a840: 742c 2070 6565 725f 626c 6f63 6b65 645f t, peer_blocked_ │ │ │ +0004a850: 616c 6572 743a 3a69 705f 6669 6c74 6572 alert::ip_filter │ │ │ +0004a860: 293b 0a09 0909 7265 7475 726e 3b0a 0909 );....return;... │ │ │ +0004a870: 7d0a 0a09 0969 6620 2861 6464 5f70 6565 }....if (add_pee │ │ │ +0004a880: 7228 686f 7374 2c20 7065 6572 5f69 6e66 r(host, peer_inf │ │ │ +0004a890: 6f3a 3a74 7261 636b 6572 2c20 7620 3d3d o::tracker, v == │ │ │ +0004a8a0: 2070 726f 746f 636f 6c5f 7665 7273 696f protocol_versio │ │ │ +0004a8b0: 6e3a 3a56 3220 3f20 7065 785f 6c74 5f76 n::V2 ? pex_lt_v │ │ │ +0004a8c0: 3220 3a20 7065 785f 666c 6167 735f 7428 2 : pex_flags_t( │ │ │ +0004a8d0: 3029 2929 0a09 097b 0a09 0909 7374 6174 0)))...{....stat │ │ │ +0004a8e0: 655f 7570 6461 7465 6428 293b 0a0a 2369 e_updated();..#i │ │ │ +0004a8f0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0004a900: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ +0004a910: 0969 6620 2873 686f 756c 645f 6c6f 6728 .if (should_log( │ │ │ +0004a920: 2929 0a09 0909 7b0a 0909 0909 6465 6275 ))....{.....debu │ │ │ +0004a930: 675f 6c6f 6728 226e 616d 652d 6c6f 6f6b g_log("name-look │ │ │ +0004a940: 7570 2061 6464 5f70 6565 7228 2920 5b20 up add_peer() [ │ │ │ +0004a950: 2573 205d 2063 6f6e 6e65 6374 2d63 616e %s ] connect-can │ │ │ +0004a960: 6469 6461 7465 733a 2025 6422 0a09 0909 didates: %d".... │ │ │ +0004a970: 0909 2c20 686f 7374 2e61 6464 7265 7373 .., host.address │ │ │ +0004a980: 2829 2e74 6f5f 7374 7269 6e67 2829 2e63 ().to_string().c │ │ │ +0004a990: 5f73 7472 2829 0a09 0909 0909 2c20 6d5f _str()......, m_ │ │ │ +0004a9a0: 7065 6572 5f6c 6973 7420 3f20 6d5f 7065 peer_list ? m_pe │ │ │ +0004a9b0: 6572 5f6c 6973 742d 2667 743b 6e75 6d5f er_list->num_ │ │ │ +0004a9c0: 636f 6e6e 6563 745f 6361 6e64 6964 6174 connect_candidat │ │ │ +0004a9d0: 6573 2829 203a 202d 3129 3b0a 0909 097d es() : -1);....} │ │ │ +0004a9e0: 0a23 656e 6469 660a 0909 7d0a 0909 7570 .#endif...}...up │ │ │ +0004a9f0: 6461 7465 5f77 616e 745f 7065 6572 7328 date_want_peers( │ │ │ +0004aa00: 293b 0a09 7d0a 3c2f 7072 653e 3c2f 7464 );..}.
    relevance │ │ │ +0004aa40: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0004aa50: 3c61 2068 7265 663d 226a 6176 6173 6372
    ../src/torrent. │ │ │ +0004aa80: 6370 703a 3439 3633 3c2f 613e 3c2f 7464 cpp:4963only do thi │ │ │ +0004aaa0: 7320 6966 2074 6865 2070 6965 6365 2073 s if the piece s │ │ │ +0004aab0: 697a 6520 3e20 3120 626c 6f63 6b73 2054 ize > 1 blocks T │ │ │ +0004aac0: 6869 7320 6973 2061 2076 3220 746f 7272 his is a v2 torr │ │ │ +0004aad0: 656e 7420 736f 2077 6520 6361 6e20 7265 ent so we can re │ │ │ +0004aae0: 7175 6573 7420 6765 7420 626c 6f63 6b20 quest get block │ │ │ +0004aaf0: 6c65 7665 6c20 6861 7368 6573 2e3c 2f74 level hashes.

    only │ │ │ +0004ab50: 646f 2074 6869 7320 6966 2074 6865 2070 do this if the p │ │ │ +0004ab60: 6965 6365 2073 697a 6520 3e20 3120 626c iece size > 1 bl │ │ │ +0004ab70: 6f63 6b73 0a54 6869 7320 6973 2061 2076 ocks.This is a v │ │ │ +0004ab80: 3220 746f 7272 656e 7420 736f 2077 6520 2 torrent so we │ │ │ +0004ab90: 6361 6e20 7265 7175 6573 7420 6765 7420 can request get │ │ │ +0004aba0: 626c 6f63 6b0a 6c65 7665 6c20 6861 7368 block.level hash │ │ │ +0004abb0: 6573 2e3c 2f68 323e 3c68 343e 2e2e 2f73 es.

    ../s │ │ │ +0004abc0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a34 rc/torrent.cpp:4 │ │ │ +0004abd0: 3936 333c 2f68 343e 3c70 7265 2073 7479 963

    ..{....std::se
    │ │ │ +0004ac20: 7426 6c74 3b74 6f72 7265 6e74 5f70 6565  t<torrent_pee
    │ │ │ +0004ac30: 722a 2667 743b 2072 6574 3b0a 0909 0969  r*> ret;....i
    │ │ │ +0004ac40: 6620 2821 626c 6f63 6b73 2e65 6d70 7479  f (!blocks.empty
    │ │ │ +0004ac50: 2829 2026 616d 703b 2661 6d70 3b20 2164  () && !d
    │ │ │ +0004ac60: 6f77 6e6c 6f61 6465 7273 2e65 6d70 7479  ownloaders.empty
    │ │ │ +0004ac70: 2829 290a 0909 097b 0a09 0909 0966 6f72  ())....{.....for
    │ │ │ +0004ac80: 2028 6175 746f 2063 6f6e 7374 2062 203a   (auto const b :
    │ │ │ +0004ac90: 2062 6c6f 636b 7329 2072 6574 2e69 6e73   blocks) ret.ins
    │ │ │ +0004aca0: 6572 7428 646f 776e 6c6f 6164 6572 735b  ert(downloaders[
    │ │ │ +0004acb0: 7374 643a 3a73 697a 655f 7428 6229 5d29  std::size_t(b)])
    │ │ │ +0004acc0: 3b0a 0909 097d 0a09 0909 656c 7365 0a09  ;....}....else..
    │ │ │ +0004acd0: 0909 7b0a 0909 0909 7374 643a 3a63 6f70  ..{.....std::cop
    │ │ │ +0004ace0: 7928 646f 776e 6c6f 6164 6572 732e 6265  y(downloaders.be
    │ │ │ +0004acf0: 6769 6e28 292c 2064 6f77 6e6c 6f61 6465  gin(), downloade
    │ │ │ +0004ad00: 7273 2e65 6e64 2829 2c20 7374 643a 3a69  rs.end(), std::i
    │ │ │ +0004ad10: 6e73 6572 7465 7228 7265 742c 2072 6574  nserter(ret, ret
    │ │ │ +0004ad20: 2e62 6567 696e 2829 2929 3b0a 0909 097d  .begin()));....}
    │ │ │ +0004ad30: 0a09 0909 7265 7475 726e 2072 6574 3b0a  ....return ret;.
    │ │ │ +0004ad40: 0909 7d28 293b 0a0a 0909 2f2f 2069 6620  ..}();....// if 
    │ │ │ +0004ad50: 7468 6973 2070 6965 6365 2077 6173 6e27  this piece wasn'
    │ │ │ +0004ad60: 7420 646f 776e 6c6f 6164 6564 2066 726f  t downloaded fro
    │ │ │ +0004ad70: 6d20 7065 6572 732c 2077 6520 6a75 7374  m peers, we just
    │ │ │ +0004ad80: 2066 6f75 6e64 2069 7420 6f6e 2064 6973   found it on dis
    │ │ │ +0004ad90: 6b2e 0a09 092f 2f20 496e 2074 6861 7420  k....// In that 
    │ │ │ +0004ada0: 6361 7365 2c20 7765 2073 686f 756c 6420  case, we should 
    │ │ │ +0004adb0: 6a75 7374 2063 6f6e 7369 6465 7220 6974  just consider it
    │ │ │ +0004adc0: 2061 7320 226e 6f74 2d68 6176 6522 2061   as "not-have" a
    │ │ │ +0004add0: 6e64 2074 6865 7265 2773 206e 6f0a 0909  nd there's no...
    │ │ │ +0004ade0: 2f2f 206e 6565 6420 746f 2074 7279 2074  // need to try t
    │ │ │ +0004adf0: 6f20 6765 7420 6869 6768 6572 2066 6964  o get higher fid
    │ │ │ +0004ae00: 656c 6974 7920 6861 7368 6573 2028 7965  elity hashes (ye
    │ │ │ +0004ae10: 7429 0a09 0962 6f6f 6c20 636f 6e73 7420  t)...bool const 
    │ │ │ +0004ae20: 666f 756e 645f 6f6e 5f64 6973 6b20 3d20  found_on_disk = 
    │ │ │ +0004ae30: 7065 6572 732e 7369 7a65 2829 203d 3d20  peers.size() == 
    │ │ │ +0004ae40: 3120 2661 6d70 3b26 616d 703b 2070 6565  1 && pee
    │ │ │ +0004ae50: 7273 2e63 6f75 6e74 286e 756c 6c70 7472  rs.count(nullptr
    │ │ │ +0004ae60: 293b 0a0a 0909 6966 2028 746f 7272 656e  );....if (torren
    │ │ │ +0004ae70: 745f 6669 6c65 2829 2e69 6e66 6f5f 6861  t_file().info_ha
    │ │ │ +0004ae80: 7368 6573 2829 2e68 6173 5f76 3228 2920  shes().has_v2() 
    │ │ │ +0004ae90: 2661 6d70 3b26 616d 703b 2062 6c6f 636b  && block
    │ │ │ +0004aea0: 732e 656d 7074 7928 2920 2661 6d70 3b26  s.empty() &&
    │ │ │ +0004aeb0: 616d 703b 2021 666f 756e 645f 6f6e 5f64  amp; !found_on_d
    │ │ │ +0004aec0: 6973 6b29 0a09 097b 0a3c 6469 7620 7374  isk)...{.
    ...verify │ │ │ +0004af00: 5f62 6c6f 636b 5f68 6173 6865 7328 696e _block_hashes(in │ │ │ +0004af10: 6465 7829 3b0a 3c2f 6469 763e 0909 7d0a dex);.
    ..}. │ │ │ +0004af20: 0a09 092f 2f20 7468 6520 6265 6c6f 7720 ...// the below │ │ │ +0004af30: 636f 6465 2069 7320 7065 6e61 6c69 7a69 code is penalizi │ │ │ +0004af40: 6e67 2070 6565 7273 2074 6861 7420 7365 ng peers that se │ │ │ +0004af50: 6e74 2075 7365 2062 6164 2064 6174 612e nt use bad data. │ │ │ +0004af60: 0a09 092f 2f20 696e 6372 6561 7365 2074 ...// increase t │ │ │ +0004af70: 6865 2074 6f74 616c 2061 6d6f 756e 7420 he total amount │ │ │ +0004af80: 6f66 2066 6169 6c65 6420 6279 7465 730a of failed bytes. │ │ │ +0004af90: 0909 6966 2028 2166 6f75 6e64 5f6f 6e5f ..if (!found_on_ │ │ │ +0004afa0: 6469 736b 290a 0909 7b0a 0909 0969 6620 disk)...{....if │ │ │ +0004afb0: 2862 6c6f 636b 732e 656d 7074 7928 2929 (blocks.empty()) │ │ │ +0004afc0: 0a09 0909 0961 6464 5f66 6169 6c65 645f .....add_failed_ │ │ │ +0004afd0: 6279 7465 7328 6d5f 746f 7272 656e 745f bytes(m_torrent_ │ │ │ +0004afe0: 6669 6c65 2d26 6774 3b70 6965 6365 5f73 file->piece_s │ │ │ +0004aff0: 697a 6528 696e 6465 7829 293b 0a09 0909 ize(index));.... │ │ │ +0004b000: 656c 7365 0a09 0909 0961 6464 5f66 6169 else.....add_fai │ │ │ +0004b010: 6c65 645f 6279 7465 7328 7374 6174 6963 led_bytes(static │ │ │ +0004b020: 5f63 6173 7426 6c74 3b69 6e74 2667 743b _cast<int> │ │ │ +0004b030: 2862 6c6f 636b 732e 7369 7a65 2829 2920 (blocks.size()) │ │ │ +0004b040: 2a20 6465 6661 756c 745f 626c 6f63 6b5f * default_block_ │ │ │ +0004b050: 7369 7a65 293b 0a0a 2369 666e 6465 6620 size);..#ifndef │ │ │ +0004b060: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0004b070: 4558 5445 4e53 494f 4e53 0a09 0909 666f EXTENSIONS....fo │ │ │ +0004b080: 7220 2861 7574 6f26 616d 703b 2065 7874 r (auto& ext │ │ │ +0004b090: 203a 206d 5f65 7874 656e 7369 6f6e 7329 : m_extensions) │ │ │ +0004b0a0: 0a09 0909 7b0a 0909 0909 6578 742d 2667 ....{.....ext-&g │ │ │ +0004b0b0: 743b 6f6e 5f70 6965 6365 5f66 6169 6c65 t;on_piece_faile │ │ │ +0004b0c0: 6428 696e 6465 7829 3b0a 0909 097d 0a23 d(index);....}.# │ │ │ +0004b0d0: 656e 6469 660a 0a09 0909 2f2f 2064 6964 endif.....// did │ │ │ +0004b0e0: 2077 6520 7265 6365 6976 6520 7468 6973 we receive this │ │ │ +0004b0f0: 2070 6965 6365 2066 726f 6d20 6120 7369 piece from a si │ │ │ +0004b100: 6e67 6c65 2070 6565 723f 0a09 0909 2f2f ngle peer?....// │ │ │ +0004b110: 2069 6620 7765 206b 6e6f 7720 6578 6163 if we know exac │ │ │ +0004b120: 746c 7920 7768 6963 6820 626c 6f63 6b73 tly which blocks │ │ │ +0004b130: 2066 6169 6c65 6420 7468 6520 6861 7368 failed the hash │ │ │ +0004b140: 2c20 7765 2063 616e 2061 6c73 6f20 6265 , we can also be │ │ │ +0004b150: 2063 6572 7461 696e 0a09 0909 2f2f 2074 certain....// t │ │ │ +0004b160: 6861 7420 616c 6c20 7065 6572 7320 696e hat all peers in │ │ │ +0004b170: 2074 6865 206c 6973 7420 7365 6e74 2075 the list sent u │ │ │ +0004b180: 7320 6261 6420 6461 7461 0a09 0909 626f s bad data....bo │ │ │ +0004b190: 6f6c 2063 6f6e 7374 206b 6e6f 776e 5f62 ol const known_b │ │ │ +0004b1a0: 6164 5f70 6565 7220 3d20 7065 6572 732e ad_peer = peers. │ │ │ +0004b1b0: 7369 7a65 2829 203d 3d20 3120 7c7c 2021 size() == 1 || ! │ │ │ +0004b1c0: 626c 6f63 6b73 2e65 6d70 7479 2829 3b0a blocks.empty();. │ │ │ +0004b1d0: 0a09 0909 7065 6e61 6c69 7a65 5f70 6565 ....penalize_pee │ │ │ +0004b1e0: 7273 2870 6565 7273 2c20 696e 6465 782c rs(peers, index, │ │ │ +0004b1f0: 206b 6e6f 776e 5f62 6164 5f70 6565 7229 known_bad_peer) │ │ │ +0004b200: 3b0a 0909 7d0a 0a09 092f 2f20 4966 206d ;...}....// If m │ │ │ +0004b210: 5f73 746f 7261 6765 2069 736e 2774 2073 _storage isn't s │ │ │ +0004b220: 6574 2068 6572 652c 2069 7420 6d65 616e et here, it mean │ │ │ +0004b230: 7320 7765 2772 6520 7368 7574 7469 6e67 s we're shutting │ │ │ +0004b240: 2064 6f77 6e0a 0909 6966 2028 6d5f 7374 down...if (m_st │ │ │ +0004b250: 6f72 6167 6529 0a09 097b 0a09 0909 2f2f orage)...{....// │ │ │ +0004b260: 2069 7420 646f 6573 6e27 7420 6d61 6b65 it doesn't make │ │ │ +0004b270: 206d 7563 6820 7365 6e73 6520 746f 2066 much sense to f │ │ │ +0004b280: 6169 6c20 746f 2068 6173 6820 6120 7069 ail to hash a pi │ │ │ +0004b290: 6563 650a 3c2f 7072 653e 3c2f 7464 3e3c ece.
    < │ │ │ +0004b2a0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0004b2d0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0004b300: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0004b310: 703a 3739 3335 3c2f 613e 3c2f 7464 3e3c p:7935< │ │ │ +0004b320: 7464 3e63 6f6d 6520 7570 2077 6974 6820 td>come up with │ │ │ +0004b330: 6120 6265 7474 6572 2077 6179 206f 6620 a better way of │ │ │ +0004b340: 646f 696e 6720 7468 6973 2c20 696e 7374 doing this, inst │ │ │ +0004b350: 6561 6420 6f66 2061 6e20 696d 6d65 6469 ead of an immedi │ │ │ +0004b360: 6174 656c 7920 696e 766f 6b65 6420 6c61 ately invoked la │ │ │ +0004b370: 6d62 6461 2065 7870 7265 7373 696f 6e2e mbda expression. │ │ │ +0004b380: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    co │ │ │ +0004b3d0: 6d65 2075 7020 7769 7468 2061 2062 6574 me up with a bet │ │ │ +0004b3e0: 7465 7220 7761 7920 6f66 2064 6f69 6e67 ter way of doing │ │ │ +0004b3f0: 2074 6869 732c 2069 6e73 7465 6164 206f this, instead o │ │ │ +0004b400: 6620 616e 0a69 6d6d 6564 6961 7465 6c79 f an.immediately │ │ │ +0004b410: 2069 6e76 6f6b 6564 206c 616d 6264 6120 invoked lambda │ │ │ +0004b420: 6578 7072 6573 7369 6f6e 2e3c 2f68 323e expression.

    │ │ │ +0004b430: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ +0004b440: 6e74 2e63 7070 3a37 3933 353c 2f68 343e nt.cpp:7935

    │ │ │ +0004b450: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .....|
    │ │ │ +0004b490: 7c20 7065 6572 696e 666f 2d26 6774 3b63  | peerinfo->c
    │ │ │ +0004b4a0: 6f6e 6669 726d 6564 5f73 7570 706f 7274  onfirmed_support
    │ │ │ +0004b4b0: 735f 7574 7029 290a 0909 097b 0a09 0909  s_utp))....{....
    │ │ │ +0004b4c0: 0973 6d20 3d20 6d5f 7365 732e 7574 705f  .sm = m_ses.utp_
    │ │ │ +0004b4d0: 736f 636b 6574 5f6d 616e 6167 6572 2829  socket_manager()
    │ │ │ +0004b4e0: 3b0a 0909 097d 0a0a 0909 092f 2f20 646f  ;....}.....// do
    │ │ │ +0004b4f0: 6e27 7420 6d61 6b65 2061 2054 4350 2063  n't make a TCP c
    │ │ │ +0004b500: 6f6e 6e65 6374 696f 6e20 6966 2069 7427  onnection if it'
    │ │ │ +0004b510: 7320 6469 7361 626c 6564 0a09 0909 6966  s disabled....if
    │ │ │ +0004b520: 2028 736d 203d 3d20 6e75 6c6c 7074 7220   (sm == nullptr 
    │ │ │ +0004b530: 2661 6d70 3b26 616d 703b 2021 7365 7474  && !sett
    │ │ │ +0004b540: 696e 6773 2829 2e67 6574 5f62 6f6f 6c28  ings().get_bool(
    │ │ │ +0004b550: 7365 7474 696e 6773 5f70 6163 6b3a 3a65  settings_pack::e
    │ │ │ +0004b560: 6e61 626c 655f 6f75 7467 6f69 6e67 5f74  nable_outgoing_t
    │ │ │ +0004b570: 6370 2929 0a09 0909 7b0a 2369 666e 6465  cp))....{.#ifnde
    │ │ │ +0004b580: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ +0004b590: 455f 4c4f 4747 494e 470a 0909 0909 6966  E_LOGGING.....if
    │ │ │ +0004b5a0: 2028 7368 6f75 6c64 5f6c 6f67 2829 290a   (should_log()).
    │ │ │ +0004b5b0: 0909 0909 7b0a 0909 0909 0964 6562 7567  ....{......debug
    │ │ │ +0004b5c0: 5f6c 6f67 2822 6469 7363 6172 6469 6e67  _log("discarding
    │ │ │ +0004b5d0: 2070 6565 7220 5c22 2573 5c22 3a20 5443   peer \"%s\": TC
    │ │ │ +0004b5e0: 5020 636f 6e6e 6563 7469 6f6e 7320 6469  P connections di
    │ │ │ +0004b5f0: 7361 626c 6564 2022 0a09 0909 0909 0922  sabled "......."
    │ │ │ +0004b600: 5b20 7375 7070 6f72 7473 2d75 7470 3a20  [ supports-utp: 
    │ │ │ +0004b610: 2564 205d 222c 2070 6565 7269 6e66 6f2d  %d ]", peerinfo-
    │ │ │ +0004b620: 2667 743b 746f 5f73 7472 696e 6728 292e  >to_string().
    │ │ │ +0004b630: 635f 7374 7228 290a 0909 0909 0909 2c20  c_str()......., 
    │ │ │ +0004b640: 7065 6572 696e 666f 2d26 6774 3b73 7570  peerinfo->sup
    │ │ │ +0004b650: 706f 7274 735f 7574 7029 3b0a 0909 0909  ports_utp);.....
    │ │ │ +0004b660: 7d0a 2365 6e64 6966 0a09 0909 0972 6574  }.#endif.....ret
    │ │ │ +0004b670: 7572 6e20 6661 6c73 653b 0a09 0909 7d0a  urn false;....}.
    │ │ │ +0004b680: 0909 7d0a 0a3c 6469 7620 7374 796c 653d  ..}..
    ..aux::socket │ │ │ +0004b6c0: 5f74 7970 6520 7320 3d20 5b26 616d 703b _type s = [& │ │ │ +0004b6d0: 5d20 7b0a 3c2f 6469 763e 0a23 6966 2054 ] {.
    .#if T │ │ │ +0004b6e0: 4f52 5245 4e54 5f55 5345 5f49 3250 0a09 ORRENT_USE_I2P.. │ │ │ +0004b6f0: 0969 6620 2870 6565 7269 6e66 6f2d 2667 .if (peerinfo-&g │ │ │ +0004b700: 743b 6973 5f69 3270 5f61 6464 7229 0a09 t;is_i2p_addr).. │ │ │ +0004b710: 097b 0a09 0909 2f2f 2049 7427 7320 6e6f .{....// It's no │ │ │ +0004b720: 7420 656e 7469 7265 6c79 206f 6276 696f t entirely obvio │ │ │ +0004b730: 7573 2077 6879 2074 6869 7320 7065 6572 us why this peer │ │ │ +0004b740: 2063 6f6e 6e65 6374 696f 6e20 6973 206e connection is n │ │ │ +0004b750: 6f74 206d 6172 6b65 6420 6173 0a09 0909 ot marked as.... │ │ │ +0004b760: 2f2f 206f 6e65 2e20 5468 6520 6d61 696e // one. The main │ │ │ +0004b770: 2066 6561 7475 7265 206f 6620 6120 7065 feature of a pe │ │ │ +0004b780: 6572 2063 6f6e 6e65 6374 696f 6e20 6973 er connection is │ │ │ +0004b790: 2074 6861 7420 7768 6574 6865 7220 6f72 that whether or │ │ │ +0004b7a0: 206e 6f74 2077 650a 0909 092f 2f20 7072 not we....// pr │ │ │ +0004b7b0: 6f78 7920 6974 2069 7320 636f 6e66 6967 oxy it is config │ │ │ +0004b7c0: 7572 6162 6c65 2e20 5768 656e 2077 6520 urable. When we │ │ │ +0004b7d0: 7573 6520 6932 702c 2077 6520 7761 6e74 use i2p, we want │ │ │ +0004b7e0: 2074 6f20 616c 7761 7973 2070 726f 780a to always prox. │ │ │ +0004b7f0: 0909 092f 2f20 6576 6572 7974 6869 6e67 ...// everything │ │ │ +0004b800: 2076 6961 2069 3270 2e0a 0a09 0909 6175 via i2p......au │ │ │ +0004b810: 783a 3a70 726f 7879 5f73 6574 7469 6e67 x::proxy_setting │ │ │ +0004b820: 7320 7072 6f78 793b 0a09 0909 7072 6f78 s proxy;....prox │ │ │ +0004b830: 792e 686f 7374 6e61 6d65 203d 2073 6574 y.hostname = set │ │ │ +0004b840: 7469 6e67 7328 292e 6765 745f 7374 7228 tings().get_str( │ │ │ +0004b850: 7365 7474 696e 6773 5f70 6163 6b3a 3a69 settings_pack::i │ │ │ +0004b860: 3270 5f68 6f73 746e 616d 6529 3b0a 0909 2p_hostname);... │ │ │ +0004b870: 0970 726f 7879 2e70 6f72 7420 3d20 7374 .proxy.port = st │ │ │ +0004b880: 643a 3a75 696e 7431 365f 7428 7365 7474 d::uint16_t(sett │ │ │ +0004b890: 696e 6773 2829 2e67 6574 5f69 6e74 2873 ings().get_int(s │ │ │ +0004b8a0: 6574 7469 6e67 735f 7061 636b 3a3a 6932 ettings_pack::i2 │ │ │ +0004b8b0: 705f 706f 7274 2929 3b0a 0909 0970 726f p_port));....pro │ │ │ +0004b8c0: 7879 2e74 7970 6520 3d20 7365 7474 696e xy.type = settin │ │ │ +0004b8d0: 6773 5f70 6163 6b3a 3a69 3270 5f70 726f gs_pack::i2p_pro │ │ │ +0004b8e0: 7879 3b0a 0a09 0909 6175 783a 3a73 6f63 xy;.....aux::soc │ │ │ +0004b8f0: 6b65 745f 7479 7065 2072 6574 203d 2069 ket_type ret = i │ │ │ +0004b900: 6e73 7461 6e74 6961 7465 5f63 6f6e 6e65 nstantiate_conne │ │ │ +0004b910: 6374 696f 6e28 6d5f 7365 732e 6765 745f ction(m_ses.get_ │ │ │ +0004b920: 636f 6e74 6578 7428 290a 0909 0909 2c20 context()....., │ │ │ +0004b930: 7072 6f78 792c 206e 756c 6c70 7472 2c20 proxy, nullptr, │ │ │ +0004b940: 6e75 6c6c 7074 722c 2066 616c 7365 2c20 nullptr, false, │ │ │ +0004b950: 6661 6c73 6529 3b0a 0909 0961 7574 6f26 false);....auto& │ │ │ +0004b960: 616d 703b 2073 7472 203d 2073 7464 3a3a amp; str = std:: │ │ │ +0004b970: 6765 7426 6c74 3b69 3270 5f73 7472 6561 get<i2p_strea │ │ │ +0004b980: 6d26 6774 3b28 7265 7429 3b0a 0909 0973 m>(ret);....s │ │ │ +0004b990: 7472 2e73 6574 5f6c 6f63 616c 5f69 3270 tr.set_local_i2p │ │ │ +0004b9a0: 5f65 6e64 706f 696e 7428 6d5f 7365 732e _endpoint(m_ses. │ │ │ +0004b9b0: 6c6f 6361 6c5f 6932 705f 656e 6470 6f69 local_i2p_endpoi │ │ │ +0004b9c0: 6e74 2829 293b 0a09 0909 7374 722e 7365 nt());....str.se │ │ │ +0004b9d0: 745f 6465 7374 696e 6174 696f 6e28 7374 t_destination(st │ │ │ +0004b9e0: 6174 6963 5f63 6173 7426 6c74 3b69 3270 atic_cast<i2p │ │ │ +0004b9f0: 5f70 6565 722a 2667 743b 2870 6565 7269 _peer*>(peeri │ │ │ +0004ba00: 6e66 6f29 2d26 6774 3b64 6573 7428 2929 nfo)->dest()) │ │ │ +0004ba10: 3b0a 0909 0973 7472 2e73 6574 5f63 6f6d ;....str.set_com │ │ │ +0004ba20: 6d61 6e64 2869 3270 5f73 7472 6561 6d3a mand(i2p_stream: │ │ │ +0004ba30: 3a63 6d64 5f63 6f6e 6e65 6374 293b 0a09 :cmd_connect);.. │ │ │ +0004ba40: 0909 7374 722e 7365 745f 7365 7373 696f ..str.set_sessio │ │ │ +0004ba50: 6e5f 6964 286d 5f73 6573 2e69 3270 5f73 n_id(m_ses.i2p_s │ │ │ +0004ba60: 6573 7369 6f6e 2829 293b 0a09 0909 7265 ession());....re │ │ │ +0004ba70: 7475 726e 2072 6574 3b0a 0909 7d0a 0909 turn ret;...}... │ │ │ +0004ba80: 656c 7365 0a23 656e 6469 660a 0909 7b0a else.#endif...{. │ │ │ +0004ba90: 0909 0976 6f69 642a 2075 7365 7264 6174 ...void* userdat │ │ │ +0004baa0: 6120 3d20 6e75 6c6c 7074 723b 0a23 6966 a = nullptr;.#if │ │ │ +0004bab0: 6465 6620 544f 5252 454e 545f 5353 4c5f def TORRENT_SSL_ │ │ │ +0004bac0: 5045 4552 530a 0909 0969 6620 2869 735f PEERS....if (is_ │ │ │ +0004bad0: 7373 6c5f 746f 7272 656e 7428 2929 0a09 ssl_torrent()).. │ │ │ +0004bae0: 0909 7b0a 3c2f 7072 653e 3c2f 7464 3e3c ..{.
    < │ │ │ +0004baf0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0004bb20: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0004bb50: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0004bb60: 703a 3936 3232 3c2f 613e 3c2f 7464 3e3c p:9622< │ │ │ +0004bb70: 7464 3e70 6572 6861 7073 2030 2073 686f td>perhaps 0 sho │ │ │ +0004bb80: 756c 6420 6163 7475 616c 6c79 206d 6561 uld actually mea │ │ │ +0004bb90: 6e20 303c 2f74 643e 3c2f 7472 3e3c 7472 n 0

    perhaps 0 shoul │ │ │ +0004bbf0: 6420 6163 7475 616c 6c79 206d 6561 6e20 d actually mean │ │ │ +0004bc00: 303c 2f68 323e 3c68 343e 2e2e 2f73 7263 0

    ../src │ │ │ +0004bc10: 2f74 6f72 7265 6e74 2e63 7070 3a39 3632 /torrent.cpp:962 │ │ │ +0004bc20: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ +0004bc60: 0909 2f2f 2066 696e 6973 6865 6420 746f  ..// finished to
    │ │ │ +0004bc70: 7272 656e 7473 206d 6179 206e 6f74 2063  rrents may not c
    │ │ │ +0004bc80: 6861 6e67 6520 7468 6569 7220 7175 6575  hange their queu
    │ │ │ +0004bc90: 6520 706f 7369 7469 6f6e 732c 2061 7320  e positions, as 
    │ │ │ +0004bca0: 6974 2773 2073 6574 2074 6f0a 0909 2f2f  it's set to...//
    │ │ │ +0004bcb0: 202d 310a 0909 6966 2028 286d 5f61 626f   -1...if ((m_abo
    │ │ │ +0004bcc0: 7274 207c 7c20 6973 5f66 696e 6973 6865  rt || is_finishe
    │ │ │ +0004bcd0: 6428 2929 2026 616d 703b 2661 6d70 3b20  d()) && 
    │ │ │ +0004bce0: 7020 213d 206e 6f5f 706f 7329 2072 6574  p != no_pos) ret
    │ │ │ +0004bcf0: 7572 6e3b 0a0a 0909 544f 5252 454e 545f  urn;....TORRENT_
    │ │ │ +0004bd00: 4153 5345 5254 2828 7020 3d3d 206e 6f5f  ASSERT((p == no_
    │ │ │ +0004bd10: 706f 7329 203d 3d20 6973 5f66 696e 6973  pos) == is_finis
    │ │ │ +0004bd20: 6865 6428 290a 0909 097c 7c20 2821 6d5f  hed()....|| (!m_
    │ │ │ +0004bd30: 6175 746f 5f6d 616e 6167 6564 2026 616d  auto_managed &am
    │ │ │ +0004bd40: 703b 2661 6d70 3b20 7020 3d3d 206e 6f5f  p;& p == no_
    │ │ │ +0004bd50: 706f 7329 0a09 0909 7c7c 2028 6d5f 6162  pos)....|| (m_ab
    │ │ │ +0004bd60: 6f72 7420 2661 6d70 3b26 616d 703b 2070  ort && p
    │ │ │ +0004bd70: 203d 3d20 6e6f 5f70 6f73 290a 0909 097c   == no_pos)....|
    │ │ │ +0004bd80: 7c20 2821 6d5f 6164 6465 6420 2661 6d70  | (!m_added &
    │ │ │ +0004bd90: 3b26 616d 703b 2070 203d 3d20 6e6f 5f70  ;& p == no_p
    │ │ │ +0004bda0: 6f73 2929 3b0a 0909 6966 2028 7020 3d3d  os));...if (p ==
    │ │ │ +0004bdb0: 206d 5f73 6571 7565 6e63 655f 6e75 6d62   m_sequence_numb
    │ │ │ +0004bdc0: 6572 2920 7265 7475 726e 3b0a 0a09 0954  er) return;....T
    │ │ │ +0004bdd0: 4f52 5245 4e54 5f41 5353 4552 5428 7020  ORRENT_ASSERT(p 
    │ │ │ +0004bde0: 2667 743b 3d20 6e6f 5f70 6f73 293b 0a0a  >= no_pos);..
    │ │ │ +0004bdf0: 0909 7374 6174 655f 7570 6461 7465 6428  ..state_updated(
    │ │ │ +0004be00: 293b 0a0a 0909 6d5f 7365 732e 7365 745f  );....m_ses.set_
    │ │ │ +0004be10: 7175 6575 655f 706f 7369 7469 6f6e 2874  queue_position(t
    │ │ │ +0004be20: 6869 732c 2070 293b 0a09 7d0a 0a09 766f  his, p);..}...vo
    │ │ │ +0004be30: 6964 2074 6f72 7265 6e74 3a3a 7365 745f  id torrent::set_
    │ │ │ +0004be40: 6d61 785f 7570 6c6f 6164 7328 696e 7420  max_uploads(int 
    │ │ │ +0004be50: 6c69 6d69 742c 2062 6f6f 6c20 636f 6e73  limit, bool cons
    │ │ │ +0004be60: 7420 7374 6174 655f 7570 6461 7465 290a  t state_update).
    │ │ │ +0004be70: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +0004be80: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ +0004be90: 7265 6164 2829 293b 0a3c 6469 7620 7374  read());.
    ..if (lim │ │ │ +0004bed0: 6974 2026 6c74 3b3d 2030 2920 6c69 6d69 it <= 0) limi │ │ │ +0004bee0: 7420 3d20 2831 2026 6c74 3b26 6c74 3b20 t = (1 << │ │ │ +0004bef0: 3234 2920 2d20 313b 0a3c 2f64 6976 3e09 24) - 1;.
    . │ │ │ +0004bf00: 0969 6620 2869 6e74 286d 5f6d 6178 5f75 .if (int(m_max_u │ │ │ +0004bf10: 706c 6f61 6473 2920 3d3d 206c 696d 6974 ploads) == limit │ │ │ +0004bf20: 2920 7265 7475 726e 3b0a 0909 6966 2028 ) return;...if ( │ │ │ +0004bf30: 7374 6174 655f 7570 6461 7465 2920 7374 state_update) st │ │ │ +0004bf40: 6174 655f 7570 6461 7465 6428 293b 0a09 ate_updated();.. │ │ │ +0004bf50: 096d 5f6d 6178 5f75 706c 6f61 6473 203d .m_max_uploads = │ │ │ +0004bf60: 2061 7578 3a3a 6e75 6d65 7269 635f 6361 aux::numeric_ca │ │ │ +0004bf70: 7374 266c 743b 7374 643a 3a75 696e 7433 st<std::uint3 │ │ │ +0004bf80: 325f 7426 6774 3b28 6c69 6d69 7429 3b0a 2_t>(limit);. │ │ │ +0004bf90: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0004bfa0: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +0004bfb0: 0909 6966 2028 7368 6f75 6c64 5f6c 6f67 ..if (should_log │ │ │ +0004bfc0: 2829 2026 616d 703b 2661 6d70 3b20 7374 () && st │ │ │ +0004bfd0: 6174 655f 7570 6461 7465 290a 0909 0964 ate_update)....d │ │ │ +0004bfe0: 6562 7567 5f6c 6f67 2822 2a2a 2a20 7365 ebug_log("*** se │ │ │ +0004bff0: 742d 6d61 782d 7570 6c6f 6164 733a 2025 t-max-uploads: % │ │ │ +0004c000: 6422 2c20 6d5f 6d61 785f 7570 6c6f 6164 d", m_max_upload │ │ │ +0004c010: 7329 3b0a 2365 6e64 6966 0a0a 0909 6966 s);.#endif....if │ │ │ +0004c020: 2028 7374 6174 655f 7570 6461 7465 290a (state_update). │ │ │ +0004c030: 0909 0973 6574 5f6e 6565 645f 7361 7665 ...set_need_save │ │ │ +0004c040: 5f72 6573 756d 6528 746f 7272 656e 745f _resume(torrent_ │ │ │ +0004c050: 6861 6e64 6c65 3a3a 6966 5f63 6f6e 6669 handle::if_confi │ │ │ +0004c060: 675f 6368 616e 6765 6429 3b0a 097d 0a0a g_changed);..}.. │ │ │ +0004c070: 0976 6f69 6420 746f 7272 656e 743a 3a73 .void torrent::s │ │ │ +0004c080: 6574 5f6d 6178 5f63 6f6e 6e65 6374 696f et_max_connectio │ │ │ +0004c090: 6e73 2869 6e74 206c 696d 6974 2c20 626f ns(int limit, bo │ │ │ +0004c0a0: 6f6c 2063 6f6e 7374 2073 7461 7465 5f75 ol const state_u │ │ │ +0004c0b0: 7064 6174 6529 0a09 7b0a 0909 544f 5252 pdate)..{...TORR │ │ │ +0004c0c0: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ +0004c0d0: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ +0004c0e0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0004c0f0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0004c120: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0004c150: 632f 746f 7272 656e 742e 6370 703a 3936 c/torrent.cpp:96 │ │ │ +0004c160: 3339 3c2f 613e 3c2f 7464 3e3c 7464 3e70 39p │ │ │ +0004c170: 6572 6861 7073 2030 2073 686f 756c 6420 erhaps 0 should │ │ │ +0004c180: 6163 7475 616c 6c79 206d 6561 6e20 303c actually mean 0< │ │ │ +0004c190: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    per │ │ │ +0004c1e0: 6861 7073 2030 2073 686f 756c 6420 6163 haps 0 should ac │ │ │ +0004c1f0: 7475 616c 6c79 206d 6561 6e20 303c 2f68 tually mean 0

    ../src/tor │ │ │ +0004c210: 7265 6e74 2e63 7070 3a39 3633 393c 2f68 rent.cpp:9639
    ..vo
    │ │ │ +0004c260: 6964 2074 6f72 7265 6e74 3a3a 7365 745f  id torrent::set_
    │ │ │ +0004c270: 6d61 785f 7570 6c6f 6164 7328 696e 7420  max_uploads(int 
    │ │ │ +0004c280: 6c69 6d69 742c 2062 6f6f 6c20 636f 6e73  limit, bool cons
    │ │ │ +0004c290: 7420 7374 6174 655f 7570 6461 7465 290a  t state_update).
    │ │ │ +0004c2a0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +0004c2b0: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ +0004c2c0: 7265 6164 2829 293b 0a09 0969 6620 286c  read());...if (l
    │ │ │ +0004c2d0: 696d 6974 2026 6c74 3b3d 2030 2920 6c69  imit <= 0) li
    │ │ │ +0004c2e0: 6d69 7420 3d20 2831 2026 6c74 3b26 6c74  mit = (1 <<
    │ │ │ +0004c2f0: 3b20 3234 2920 2d20 313b 0a09 0969 6620  ; 24) - 1;...if 
    │ │ │ +0004c300: 2869 6e74 286d 5f6d 6178 5f75 706c 6f61  (int(m_max_uploa
    │ │ │ +0004c310: 6473 2920 3d3d 206c 696d 6974 2920 7265  ds) == limit) re
    │ │ │ +0004c320: 7475 726e 3b0a 0909 6966 2028 7374 6174  turn;...if (stat
    │ │ │ +0004c330: 655f 7570 6461 7465 2920 7374 6174 655f  e_update) state_
    │ │ │ +0004c340: 7570 6461 7465 6428 293b 0a09 096d 5f6d  updated();...m_m
    │ │ │ +0004c350: 6178 5f75 706c 6f61 6473 203d 2061 7578  ax_uploads = aux
    │ │ │ +0004c360: 3a3a 6e75 6d65 7269 635f 6361 7374 266c  ::numeric_cast&l
    │ │ │ +0004c370: 743b 7374 643a 3a75 696e 7433 325f 7426  t;std::uint32_t&
    │ │ │ +0004c380: 6774 3b28 6c69 6d69 7429 3b0a 2369 666e  gt;(limit);.#ifn
    │ │ │ +0004c390: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0004c3a0: 424c 455f 4c4f 4747 494e 470a 0909 6966  BLE_LOGGING...if
    │ │ │ +0004c3b0: 2028 7368 6f75 6c64 5f6c 6f67 2829 2026   (should_log() &
    │ │ │ +0004c3c0: 616d 703b 2661 6d70 3b20 7374 6174 655f  amp;& state_
    │ │ │ +0004c3d0: 7570 6461 7465 290a 0909 0964 6562 7567  update)....debug
    │ │ │ +0004c3e0: 5f6c 6f67 2822 2a2a 2a20 7365 742d 6d61  _log("*** set-ma
    │ │ │ +0004c3f0: 782d 7570 6c6f 6164 733a 2025 6422 2c20  x-uploads: %d", 
    │ │ │ +0004c400: 6d5f 6d61 785f 7570 6c6f 6164 7329 3b0a  m_max_uploads);.
    │ │ │ +0004c410: 2365 6e64 6966 0a0a 0909 6966 2028 7374  #endif....if (st
    │ │ │ +0004c420: 6174 655f 7570 6461 7465 290a 0909 0973  ate_update)....s
    │ │ │ +0004c430: 6574 5f6e 6565 645f 7361 7665 5f72 6573  et_need_save_res
    │ │ │ +0004c440: 756d 6528 746f 7272 656e 745f 6861 6e64  ume(torrent_hand
    │ │ │ +0004c450: 6c65 3a3a 6966 5f63 6f6e 6669 675f 6368  le::if_config_ch
    │ │ │ +0004c460: 616e 6765 6429 3b0a 097d 0a0a 0976 6f69  anged);..}...voi
    │ │ │ +0004c470: 6420 746f 7272 656e 743a 3a73 6574 5f6d  d torrent::set_m
    │ │ │ +0004c480: 6178 5f63 6f6e 6e65 6374 696f 6e73 2869  ax_connections(i
    │ │ │ +0004c490: 6e74 206c 696d 6974 2c20 626f 6f6c 2063  nt limit, bool c
    │ │ │ +0004c4a0: 6f6e 7374 2073 7461 7465 5f75 7064 6174  onst state_updat
    │ │ │ +0004c4b0: 6529 0a09 7b0a 0909 544f 5252 454e 545f  e)..{...TORRENT_
    │ │ │ +0004c4c0: 4153 5345 5254 2869 735f 7369 6e67 6c65  ASSERT(is_single
    │ │ │ +0004c4d0: 5f74 6872 6561 6428 2929 3b0a 3c64 6976  _thread());.
    ..if ( │ │ │ +0004c510: 6c69 6d69 7420 266c 743b 3d20 3029 206c limit <= 0) l │ │ │ +0004c520: 696d 6974 203d 2028 3120 266c 743b 266c imit = (1 <&l │ │ │ +0004c530: 743b 2032 3429 202d 2031 3b0a 3c2f 6469 t; 24) - 1;...if (int(m_ma │ │ │ +0004c550: 785f 636f 6e6e 6563 7469 6f6e 7329 203d x_connections) = │ │ │ +0004c560: 3d20 6c69 6d69 7429 2072 6574 7572 6e3b = limit) return; │ │ │ +0004c570: 0a09 0969 6620 2873 7461 7465 5f75 7064 ...if (state_upd │ │ │ +0004c580: 6174 6529 2073 7461 7465 5f75 7064 6174 ate) state_updat │ │ │ +0004c590: 6564 2829 3b0a 0909 6d5f 6d61 785f 636f ed();...m_max_co │ │ │ +0004c5a0: 6e6e 6563 7469 6f6e 7320 3d20 6175 783a nnections = aux: │ │ │ +0004c5b0: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ +0004c5c0: 3b73 7464 3a3a 7569 6e74 3332 5f74 2667 ;std::uint32_t&g │ │ │ +0004c5d0: 743b 286c 696d 6974 293b 0a09 0975 7064 t;(limit);...upd │ │ │ +0004c5e0: 6174 655f 7761 6e74 5f70 6565 7273 2829 ate_want_peers() │ │ │ +0004c5f0: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245 ;..#ifndef TORRE │ │ │ +0004c600: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +0004c610: 4e47 0a09 0969 6620 2873 686f 756c 645f NG...if (should_ │ │ │ +0004c620: 6c6f 6728 2920 2661 6d70 3b26 616d 703b log() && │ │ │ +0004c630: 2073 7461 7465 5f75 7064 6174 6529 0a09 state_update).. │ │ │ +0004c640: 0909 6465 6275 675f 6c6f 6728 222a 2a2a ..debug_log("*** │ │ │ +0004c650: 2073 6574 2d6d 6178 2d63 6f6e 6e65 6374 set-max-connect │ │ │ +0004c660: 696f 6e73 3a20 2564 222c 206d 5f6d 6178 ions: %d", m_max │ │ │ +0004c670: 5f63 6f6e 6e65 6374 696f 6e73 293b 0a23 _connections);.# │ │ │ +0004c680: 656e 6469 660a 0a09 0969 6620 286e 756d endif....if (num │ │ │ +0004c690: 5f70 6565 7273 2829 2026 6774 3b20 696e _peers() > in │ │ │ +0004c6a0: 7428 6d5f 6d61 785f 636f 6e6e 6563 7469 t(m_max_connecti │ │ │ +0004c6b0: 6f6e 7329 290a 0909 7b0a 0909 0964 6973 ons))...{....dis │ │ │ +0004c6c0: 636f 6e6e 6563 745f 7065 6572 7328 6e75 connect_peers(nu │ │ │ +0004c6d0: 6d5f 7065 6572 7328 2920 2d20 6d5f 6d61 m_peers() - m_ma │ │ │ +0004c6e0: 785f 636f 6e6e 6563 7469 6f6e 730a 0909 x_connections... │ │ │ +0004c6f0: 0909 2c20 6572 726f 7273 3a3a 746f 6f5f .., errors::too_ │ │ │ +0004c700: 6d61 6e79 5f63 6f6e 6e65 6374 696f 6e73 many_connections │ │ │ +0004c710: 293b 0a09 097d 0a0a 0909 6966 2028 7374 );...}....if (st │ │ │ +0004c720: 6174 655f 7570 6461 7465 290a 0909 0973 ate_update)....s │ │ │ +0004c730: 6574 5f6e 6565 645f 7361 7665 5f72 6573 et_need_save_res │ │ │ +0004c740: 756d 6528 746f 7272 656e 745f 6861 6e64 ume(torrent_hand │ │ │ +0004c750: 6c65 3a3a 6966 5f63 6f6e 6669 675f 6368 le::if_config_ch │ │ │ +0004c760: 616e 6765 6429 3b0a 097d 0a0a 0976 6f69 anged);..}...voi │ │ │ +0004c770: 6420 746f 7272 656e 743a 3a73 6574 5f75 d torrent::set_u │ │ │ +0004c780: 706c 6f61 645f 6c69 6d69 7428 696e 7420 pload_limit(int │ │ │ +0004c790: 636f 6e73 7420 6c69 6d69 7429 0a09 7b0a const limit)..{. │ │ │ +0004c7a0: 0909 7365 745f 6c69 6d69 745f 696d 706c ..set_limit_impl │ │ │ +0004c7b0: 286c 696d 6974 2c20 7065 6572 5f63 6f6e (limit, peer_con │ │ │ +0004c7c0: 6e65 6374 696f 6e3a 3a75 706c 6f61 645f nection::upload_ │ │ │ +0004c7d0: 6368 616e 6e65 6c29 3b0a 2369 666e 6465 channel);.#ifnde │ │ │ +0004c7e0: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0004c7f0: 455f 4c4f 4747 494e 470a 0909 6465 6275 E_LOGGING...debu │ │ │ +0004c800: 675f 6c6f 6728 222a 2a2a 2073 6574 2d75 g_log("*** set-u │ │ │ +0004c810: 706c 6f61 642d 6c69 6d69 743a 2025 6422 pload-limit: %d" │ │ │ +0004c820: 2c20 6c69 6d69 7429 3b0a 2365 6e64 6966 , limit);.#endif │ │ │ +0004c830: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265 ..}...void torre │ │ │ +0004c840: 6e74 3a3a 7365 745f 646f 776e 6c6f 6164 nt::set_download │ │ │ +0004c850: 5f6c 696d 6974 2869 6e74 2063 6f6e 7374 _limit(int const │ │ │ +0004c860: 206c 696d 6974 290a 097b 0a3c 2f70 7265 limit)..{.
    rele │ │ │ +0004c8a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ +0004c8e0: 7265 6e74 2e63 7070 3a31 3135 3532 3c2f rent.cpp:11552inste │ │ │ +0004c900: 6164 206f 6620 7265 736f 7274 696e 6720 ad of resorting │ │ │ +0004c910: 7468 6520 7768 6f6c 6520 6c69 7374 2c20 the whole list, │ │ │ +0004c920: 696e 7365 7274 2074 6865 2070 6565 7273 insert the peers │ │ │ +0004c930: 2064 6972 6563 746c 7920 696e 746f 2074 directly into t │ │ │ +0004c940: 6865 2072 6967 6874 2070 6c61 6365 3c2f he right place

    inst │ │ │ +0004c9a0: 6561 6420 6f66 2072 6573 6f72 7469 6e67 ead of resorting │ │ │ +0004c9b0: 2074 6865 2077 686f 6c65 206c 6973 742c the whole list, │ │ │ +0004c9c0: 2069 6e73 6572 7420 7468 6520 7065 6572 insert the peer │ │ │ +0004c9d0: 730a 6469 7265 6374 6c79 2069 6e74 6f20 s.directly into │ │ │ +0004c9e0: 7468 6520 7269 6768 7420 706c 6163 653c the right place< │ │ │ +0004c9f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0004ca00: 6f72 7265 6e74 2e63 7070 3a31 3135 3532 orrent.cpp:11552 │ │ │ +0004ca10: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0004ca50: 0909 0973 7464 3a3a 7072 696e 7466 2822  ...std::printf("
    │ │ │ +0004ca60: 7469 6d65 6420 6f75 7420 5b61 7665 7261  timed out [avera
    │ │ │ +0004ca70: 6765 2d70 6965 6365 2d74 696d 653a 2025  ge-piece-time: %
    │ │ │ +0004ca80: 6420 6d73 205d 5c6e 220a 0909 0909 092c  d ms ]\n"......,
    │ │ │ +0004ca90: 206d 5f61 7665 7261 6765 5f70 6965 6365   m_average_piece
    │ │ │ +0004caa0: 5f74 696d 6529 3b0a 2365 6e64 6966 0a09  _time);.#endif..
    │ │ │ +0004cab0: 0909 7d0a 0a09 0909 2f2f 2070 6963 6b20  ..}.....// pick 
    │ │ │ +0004cac0: 616c 6c20 626c 6f63 6b73 2066 6f72 2074  all blocks for t
    │ │ │ +0004cad0: 6869 7320 7069 6563 652e 2074 6865 2070  his piece. the p
    │ │ │ +0004cae0: 6565 7273 206c 6973 7420 6973 206b 6570  eers list is kep
    │ │ │ +0004caf0: 7420 7570 2074 6f20 6461 7465 0a09 0909  t up to date....
    │ │ │ +0004cb00: 2f2f 2061 6e64 2073 6f72 7465 642e 2077  // and sorted. w
    │ │ │ +0004cb10: 6865 6e20 7765 2069 7373 7565 2061 2072  hen we issue a r
    │ │ │ +0004cb20: 6571 7565 7374 2074 6f20 6120 7065 6572  equest to a peer
    │ │ │ +0004cb30: 2c20 6974 7320 646f 776e 6c6f 6164 2071  , its download q
    │ │ │ +0004cb40: 7565 7565 0a09 0909 2f2f 2074 696d 6520  ueue....// time 
    │ │ │ +0004cb50: 7769 6c6c 2069 6e63 7265 6173 6520 616e  will increase an
    │ │ │ +0004cb60: 6420 6974 206d 6179 206e 6565 6420 746f  d it may need to
    │ │ │ +0004cb70: 2062 6520 6275 6d70 6564 2069 6e20 7468   be bumped in th
    │ │ │ +0004cb80: 6520 7065 6572 7320 6c69 7374 2c0a 0909  e peers list,...
    │ │ │ +0004cb90: 092f 2f20 7369 6e63 6520 6974 2773 206f  .// since it's o
    │ │ │ +0004cba0: 7264 6572 6564 2062 7920 646f 776e 6c6f  rdered by downlo
    │ │ │ +0004cbb0: 6164 2071 7565 7565 2074 696d 650a 0909  ad queue time...
    │ │ │ +0004cbc0: 0970 6963 6b5f 7469 6d65 5f63 7269 7469  .pick_time_criti
    │ │ │ +0004cbd0: 6361 6c5f 626c 6f63 6b28 7065 6572 732c  cal_block(peers,
    │ │ │ +0004cbe0: 2069 676e 6f72 655f 7065 6572 730a 0909   ignore_peers...
    │ │ │ +0004cbf0: 0909 2c20 7065 6572 735f 7769 7468 5f72  .., peers_with_r
    │ │ │ +0004cc00: 6571 7565 7374 730a 0909 0909 2c20 7069  equests....., pi
    │ │ │ +0004cc10: 2c20 2661 6d70 3b69 2c20 6d5f 7069 636b  , &i, m_pick
    │ │ │ +0004cc20: 6572 2e67 6574 2829 0a09 0909 092c 2062  er.get()....., b
    │ │ │ +0004cc30: 6c6f 636b 735f 696e 5f70 6965 6365 2c20  locks_in_piece, 
    │ │ │ +0004cc40: 7469 6d65 645f 6f75 7429 3b0a 0a09 0909  timed_out);.....
    │ │ │ +0004cc50: 2f2f 2070 7574 2062 6163 6b20 7468 6520  // put back the 
    │ │ │ +0004cc60: 7065 6572 7320 7765 2069 676e 6f72 6564  peers we ignored
    │ │ │ +0004cc70: 2069 6e74 6f20 7468 6520 7065 6572 206c   into the peer l
    │ │ │ +0004cc80: 6973 7420 666f 7220 7468 6520 6e65 7874  ist for the next
    │ │ │ +0004cc90: 2070 6965 6365 0a09 0909 6966 2028 2169   piece....if (!i
    │ │ │ +0004cca0: 676e 6f72 655f 7065 6572 732e 656d 7074  gnore_peers.empt
    │ │ │ +0004ccb0: 7928 2929 0a09 0909 7b0a 0909 0909 7065  y())....{.....pe
    │ │ │ +0004ccc0: 6572 732e 696e 7365 7274 2870 6565 7273  ers.insert(peers
    │ │ │ +0004ccd0: 2e62 6567 696e 2829 2c20 6967 6e6f 7265  .begin(), ignore
    │ │ │ +0004cce0: 5f70 6565 7273 2e62 6567 696e 2829 2c20  _peers.begin(), 
    │ │ │ +0004ccf0: 6967 6e6f 7265 5f70 6565 7273 2e65 6e64  ignore_peers.end
    │ │ │ +0004cd00: 2829 293b 0a09 0909 0969 676e 6f72 655f  ());.....ignore_
    │ │ │ +0004cd10: 7065 6572 732e 636c 6561 7228 293b 0a0a  peers.clear();..
    │ │ │ +0004cd20: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0004cd50: 0909 7374 643a 3a73 6f72 7428 7065 6572 ..std::sort(peer │ │ │ +0004cd60: 732e 6265 6769 6e28 292c 2070 6565 7273 s.begin(), peers │ │ │ +0004cd70: 2e65 6e64 2829 0a3c 2f64 6976 3e09 0909 .end().
    ... │ │ │ +0004cd80: 0909 2c20 5b5d 2028 7065 6572 5f63 6f6e .., [] (peer_con │ │ │ +0004cd90: 6e65 6374 696f 6e20 636f 6e73 742a 206c nection const* l │ │ │ +0004cda0: 6873 2c20 7065 6572 5f63 6f6e 6e65 6374 hs, peer_connect │ │ │ +0004cdb0: 696f 6e20 636f 6e73 742a 2072 6873 290a ion const* rhs). │ │ │ +0004cdc0: 0909 0909 097b 2072 6574 7572 6e20 6c68 .....{ return lh │ │ │ +0004cdd0: 732d 2667 743b 646f 776e 6c6f 6164 5f71 s->download_q │ │ │ +0004cde0: 7565 7565 5f74 696d 6528 3136 2a31 3032 ueue_time(16*102 │ │ │ +0004cdf0: 3429 2026 6c74 3b20 7268 732d 2667 743b 4) < rhs-> │ │ │ +0004ce00: 646f 776e 6c6f 6164 5f71 7565 7565 5f74 download_queue_t │ │ │ +0004ce10: 696d 6528 3136 2a31 3032 3429 3b20 7d29 ime(16*1024); }) │ │ │ +0004ce20: 3b0a 0909 097d 0a0a 0909 092f 2f20 6966 ;....}.....// if │ │ │ +0004ce30: 2074 6869 7320 7065 6572 2773 2064 6f77 this peer's dow │ │ │ +0004ce40: 6e6c 6f61 6420 7469 6d65 2065 7863 6565 nload time excee │ │ │ +0004ce50: 6473 2032 2073 6563 6f6e 6473 2c20 7765 ds 2 seconds, we │ │ │ +0004ce60: 2772 6520 646f 6e65 2e0a 0909 092f 2f20 're done.....// │ │ │ +0004ce70: 5765 2064 6f6e 2774 2077 616e 7420 746f We don't want to │ │ │ +0004ce80: 2062 7569 6c64 2075 6e72 6561 736f 6e61 build unreasona │ │ │ +0004ce90: 626c 7920 6c6f 6e67 2072 6571 7565 7374 bly long request │ │ │ +0004cea0: 2071 7565 7565 730a 0909 0969 6620 2821 queues....if (! │ │ │ +0004ceb0: 7065 6572 732e 656d 7074 7928 2920 2661 peers.empty() &a │ │ │ +0004cec0: 6d70 3b26 616d 703b 2070 6565 7273 5b30 mp;& peers[0 │ │ │ +0004ced0: 5d2d 2667 743b 646f 776e 6c6f 6164 5f71 ]->download_q │ │ │ +0004cee0: 7565 7565 5f74 696d 6528 2920 2667 743b ueue_time() > │ │ │ +0004cef0: 206d 696c 6c69 7365 636f 6e64 7328 3230 milliseconds(20 │ │ │ +0004cf00: 3030 2929 0a09 0909 0962 7265 616b 3b0a 00)).....break;. │ │ │ +0004cf10: 0909 7d0a 0a09 092f 2f20 636f 6d6d 6974 ..}....// commit │ │ │ +0004cf20: 2061 6c6c 2074 6865 2074 696d 6520 6372 all the time cr │ │ │ +0004cf30: 6974 6963 616c 2072 6571 7565 7374 730a itical requests. │ │ │ +0004cf40: 0909 666f 7220 2861 7574 6f2a 2070 203a ..for (auto* p : │ │ │ +0004cf50: 2070 6565 7273 5f77 6974 685f 7265 7175 peers_with_requ │ │ │ +0004cf60: 6573 7473 290a 0909 7b0a 0909 0970 2d26 ests)...{....p-& │ │ │ +0004cf70: 6774 3b73 656e 645f 626c 6f63 6b5f 7265 gt;send_block_re │ │ │ +0004cf80: 7175 6573 7473 2829 3b0a 0909 7d0a 097d quests();...}..} │ │ │ +0004cf90: 0a23 656e 6469 6620 2f2f 2054 4f52 5245 .#endif // TORRE │ │ │ +0004cfa0: 4e54 5f44 4953 4142 4c45 5f53 5452 4541 NT_DISABLE_STREA │ │ │ +0004cfb0: 4d49 4e47 0a0a 0973 7464 3a3a 7365 7426 MING...std::set& │ │ │ +0004cfc0: 6c74 3b73 7464 3a3a 7374 7269 6e67 2667 lt;std::string&g │ │ │ +0004cfd0: 743b 2074 6f72 7265 6e74 3a3a 7765 625f t; torrent::web_ │ │ │ +0004cfe0: 7365 6564 7328 2920 636f 6e73 740a 097b seeds() const..{ │ │ │ +0004cff0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0004d000: 5428 6973 5f73 696e 676c 655f 7468 7265 T(is_single_thre │ │ │ +0004d010: 6164 2829 293b 0a09 0973 7464 3a3a 7365 ad());...std::se │ │ │ +0004d020: 7426 6c74 3b73 7464 3a3a 7374 7269 6e67 t<std::string │ │ │ +0004d030: 2667 743b 2072 6574 3b0a 0909 666f 7220 > ret;...for │ │ │ +0004d040: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ +0004d050: 2073 203a 206d 5f77 6562 5f73 6565 6473 s : m_web_seeds │ │ │ +0004d060: 290a 0909 7b0a 0909 0969 6620 2873 2e70 )...{....if (s.p │ │ │ +0004d070: 6565 725f 696e 666f 2e62 616e 6e65 6429 eer_info.banned) │ │ │ +0004d080: 2063 6f6e 7469 6e75 653b 0a09 0909 6966 continue;....if │ │ │ +0004d090: 2028 732e 7265 6d6f 7665 6429 2063 6f6e (s.removed) con │ │ │ +0004d0a0: 7469 6e75 653b 0a09 0909 7265 742e 696e tinue;....ret.in │ │ │ +0004d0b0: 7365 7274 2873 2e75 726c 293b 0a09 097d sert(s.url);...} │ │ │ +0004d0c0: 0a09 0972 6574 7572 6e20 7265 743b 0a09 ...return ret;.. │ │ │ +0004d0d0: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ +0004d100: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0004d110: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0
    ../ │ │ │ +0004d140: 7372 632f 7765 625f 636f 6e6e 6563 7469 src/web_connecti │ │ │ +0004d150: 6f6e 5f62 6173 652e 6370 703a 3530 3c2f on_base.cpp:50intro │ │ │ +0004d170: 6475 6365 2061 2077 6562 2d73 6565 6420 duce a web-seed │ │ │ +0004d180: 6465 6661 756c 7420 636c 6173 7320 7768 default class wh │ │ │ +0004d190: 6963 6820 6861 7320 6120 6c6f 7720 646f ich has a low do │ │ │ +0004d1a0: 776e 6c6f 6164 2070 7269 6f72 6974 793c wnload priority< │ │ │ +0004d1b0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    int │ │ │ +0004d200: 726f 6475 6365 2061 2077 6562 2d73 6565 roduce a web-see │ │ │ +0004d210: 6420 6465 6661 756c 7420 636c 6173 7320 d default class │ │ │ +0004d220: 7768 6963 6820 6861 7320 6120 6c6f 7720 which has a low │ │ │ +0004d230: 646f 776e 6c6f 6164 2070 7269 6f72 6974 download priorit │ │ │ +0004d240: 793c 2f68 323e 3c68 343e 2e2e 2f73 7263 y

    ../src │ │ │ +0004d250: 2f77 6562 5f63 6f6e 6e65 6374 696f 6e5f /web_connection_ │ │ │ +0004d260: 6261 7365 2e63 7070 3a35 303c 2f68 343e base.cpp:50

    │ │ │ +0004d270: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..: pe
    │ │ │ +0004d2b0: 6572 5f63 6f6e 6e65 6374 696f 6e28 7061  er_connection(pa
    │ │ │ +0004d2c0: 636b 290a 0909 2c20 6d5f 6669 7273 745f  ck)..., m_first_
    │ │ │ +0004d2d0: 7265 7175 6573 7428 7472 7565 290a 0909  request(true)...
    │ │ │ +0004d2e0: 2c20 6d5f 7373 6c28 6661 6c73 6529 0a09  , m_ssl(false)..
    │ │ │ +0004d2f0: 092c 206d 5f65 7874 6572 6e61 6c5f 6175  ., m_external_au
    │ │ │ +0004d300: 7468 2877 6562 2e61 7574 6829 0a09 092c  th(web.auth)...,
    │ │ │ +0004d310: 206d 5f65 7874 7261 5f68 6561 6465 7273   m_extra_headers
    │ │ │ +0004d320: 2877 6562 2e65 7874 7261 5f68 6561 6465  (web.extra_heade
    │ │ │ +0004d330: 7273 290a 0909 2c20 6d5f 7061 7273 6572  rs)..., m_parser
    │ │ │ +0004d340: 2861 7578 3a3a 6874 7470 5f70 6172 7365  (aux::http_parse
    │ │ │ +0004d350: 723a 3a64 6f6e 745f 7061 7273 655f 6368  r::dont_parse_ch
    │ │ │ +0004d360: 756e 6b73 290a 0909 2c20 6d5f 626f 6479  unks)..., m_body
    │ │ │ +0004d370: 5f73 7461 7274 2830 290a 097b 0a09 0954  _start(0)..{...T
    │ │ │ +0004d380: 4f52 5245 4e54 5f41 5353 4552 5428 2661  ORRENT_ASSERT(&a
    │ │ │ +0004d390: 6d70 3b77 6562 2e70 6565 725f 696e 666f  mp;web.peer_info
    │ │ │ +0004d3a0: 203d 3d20 7061 636b 2e70 6565 7269 6e66   == pack.peerinf
    │ │ │ +0004d3b0: 6f29 3b0a 0909 2f2f 2077 6865 6e20 676f  o);...// when go
    │ │ │ +0004d3c0: 696e 6720 7468 726f 7567 6820 6120 7072  ing through a pr
    │ │ │ +0004d3d0: 6f78 792c 2077 6520 646f 6e27 7420 6e65  oxy, we don't ne
    │ │ │ +0004d3e0: 6365 7373 6172 696c 7920 6861 7665 2061  cessarily have a
    │ │ │ +0004d3f0: 6e20 656e 6470 6f69 6e74 2068 6572 652c  n endpoint here,
    │ │ │ +0004d400: 0a09 092f 2f20 7369 6e63 6520 7468 6520  ...// since the 
    │ │ │ +0004d410: 7072 6f78 7920 6d69 6768 7420 6265 2072  proxy might be r
    │ │ │ +0004d420: 6573 6f6c 7669 6e67 2074 6865 2068 6f73  esolving the hos
    │ │ │ +0004d430: 746e 616d 652c 206e 6f74 2075 730a 0909  tname, not us...
    │ │ │ +0004d440: 544f 5252 454e 545f 4153 5345 5254 2877  TORRENT_ASSERT(w
    │ │ │ +0004d450: 6562 2e65 6e64 706f 696e 7473 2e65 6d70  eb.endpoints.emp
    │ │ │ +0004d460: 7479 2829 207c 7c20 7765 622e 656e 6470  ty() || web.endp
    │ │ │ +0004d470: 6f69 6e74 732e 6672 6f6e 7428 2920 3d3d  oints.front() ==
    │ │ │ +0004d480: 2070 6163 6b2e 656e 6470 293b 0a0a 0909   pack.endp);....
    │ │ │ +0004d490: 494e 5641 5249 414e 545f 4348 4543 4b3b  INVARIANT_CHECK;
    │ │ │ +0004d4a0: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +0004d4b0: 5254 2869 735f 6f75 7467 6f69 6e67 2829  RT(is_outgoing()
    │ │ │ +0004d4c0: 293b 0a0a 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ +0004d4d0: 5345 5254 2821 6d5f 746f 7272 656e 742e  SERT(!m_torrent.
    │ │ │ +0004d4e0: 6c6f 636b 2829 2d26 6774 3b69 735f 7570  lock()->is_up
    │ │ │ +0004d4f0: 6c6f 6164 5f6f 6e6c 7928 2929 3b0a 0a09  load_only());...
    │ │ │ +0004d500: 092f 2f20 7765 206f 6e6c 7920 7761 6e74  .// we only want
    │ │ │ +0004d510: 206c 6566 742d 6f76 6572 2062 616e 6477   left-over bandw
    │ │ │ +0004d520: 6964 7468 0a3c 6469 7620 7374 796c 653d  idth.
    .
    ..std: │ │ │ +0004d560: 3a73 7472 696e 6720 7072 6f74 6f63 6f6c :string protocol │ │ │ +0004d570: 3b0a 0909 6572 726f 725f 636f 6465 2065 ;...error_code e │ │ │ +0004d580: 633b 0a09 0973 7464 3a3a 7469 6528 7072 c;...std::tie(pr │ │ │ +0004d590: 6f74 6f63 6f6c 2c20 6d5f 6261 7369 635f otocol, m_basic_ │ │ │ +0004d5a0: 6175 7468 2c20 6d5f 686f 7374 2c20 6d5f auth, m_host, m_ │ │ │ +0004d5b0: 706f 7274 2c20 6d5f 7061 7468 290a 0909 port, m_path)... │ │ │ +0004d5c0: 093d 2070 6172 7365 5f75 726c 5f63 6f6d .= parse_url_com │ │ │ +0004d5d0: 706f 6e65 6e74 7328 7765 622e 7572 6c2c ponents(web.url, │ │ │ +0004d5e0: 2065 6329 3b0a 0909 544f 5252 454e 545f ec);...TORRENT_ │ │ │ +0004d5f0: 4153 5345 5254 2821 6563 293b 0a0a 0909 ASSERT(!ec);.... │ │ │ +0004d600: 6966 2028 6d5f 706f 7274 203d 3d20 2d31 if (m_port == -1 │ │ │ +0004d610: 2026 616d 703b 2661 6d70 3b20 7072 6f74 && prot │ │ │ +0004d620: 6f63 6f6c 203d 3d20 2268 7474 7022 290a ocol == "http"). │ │ │ +0004d630: 0909 096d 5f70 6f72 7420 3d20 3830 3b0a ...m_port = 80;. │ │ │ +0004d640: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ +0004d650: 5f53 534c 0a09 0969 6620 2870 726f 746f _SSL...if (proto │ │ │ +0004d660: 636f 6c20 3d3d 2022 6874 7470 7322 290a col == "https"). │ │ │ +0004d670: 0909 7b0a 0909 096d 5f73 736c 203d 2074 ..{....m_ssl = t │ │ │ +0004d680: 7275 653b 0a09 0909 6966 2028 6d5f 706f rue;....if (m_po │ │ │ +0004d690: 7274 203d 3d20 2d31 2920 6d5f 706f 7274 rt == -1) m_port │ │ │ +0004d6a0: 203d 2034 3433 3b0a 0909 7d0a 2365 6e64 = 443;...}.#end │ │ │ +0004d6b0: 6966 0a0a 0909 6966 2028 216d 5f62 6173 if....if (!m_bas │ │ │ +0004d6c0: 6963 5f61 7574 682e 656d 7074 7928 2929 ic_auth.empty()) │ │ │ +0004d6d0: 0a09 0909 6d5f 6261 7369 635f 6175 7468 ....m_basic_auth │ │ │ +0004d6e0: 203d 2062 6173 6536 3465 6e63 6f64 6528 = base64encode( │ │ │ +0004d6f0: 6d5f 6261 7369 635f 6175 7468 293b 0a0a m_basic_auth);.. │ │ │ +0004d700: 0909 6d5f 7365 7276 6572 5f73 7472 696e ..m_server_strin │ │ │ +0004d710: 6720 3d20 6d5f 686f 7374 3b0a 0909 6175 g = m_host;...au │ │ │ +0004d720: 783a 3a76 6572 6966 795f 656e 636f 6469 x::verify_encodi │ │ │ +0004d730: 6e67 286d 5f73 6572 7665 725f 7374 7269 ng(m_server_stri │ │ │ +0004d740: 6e67 293b 0a09 7d0a 0a09 696e 7420 7765 ng);..}...int we │ │ │ +0004d750: 625f 636f 6e6e 6563 7469 6f6e 5f62 6173 b_connection_bas │ │ │ +0004d760: 653a 3a74 696d 656f 7574 2829 2063 6f6e e::timeout() con │ │ │ +0004d770: 7374 0a09 7b0a 0909 2f2f 2073 696e 6365 st..{...// since │ │ │ +0004d780: 2074 6869 7320 6973 2061 2077 6562 2073 this is a web s │ │ │ +0004d790: 6565 642c 2063 6861 6e67 6520 7468 6520 eed, change the │ │ │ +0004d7a0: 7469 6d65 6f75 740a 0909 2f2f 2061 6363 timeout...// acc │ │ │ +0004d7b0: 6f72 6469 6e67 2074 6f20 7468 6520 7365 ording to the se │ │ │ +0004d7c0: 7474 696e 6773 2e0a 0909 7265 7475 726e ttings....return │ │ │ +0004d7d0: 206d 5f73 6574 7469 6e67 732e 6765 745f m_settings.get_ │ │ │ +0004d7e0: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ +0004d7f0: 6b3a 3a75 726c 7365 6564 5f74 696d 656f k::urlseed_timeo │ │ │ +0004d800: 7574 293b 0a09 7d0a 3c2f 7072 653e 3c2f ut);..}.
    relevan │ │ │ +0004d840: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/storag │ │ │ +0004d880: 655f 7574 696c 732e 6370 703a 3132 333c e_utils.cpp:123< │ │ │ +0004d890: 2f61 3e3c 2f74 643e 3c74 643e 6964 6561 /a>idea │ │ │ +0004d8a0: 6c6c 792c 2069 6620 7765 2065 6e64 2075 lly, if we end u │ │ │ +0004d8b0: 7020 636f 7079 696e 6720 6669 6c65 7320 p copying files │ │ │ +0004d8c0: 6265 6361 7573 6520 6f66 2061 206d 6f76 because of a mov │ │ │ +0004d8d0: 6520 6163 726f 7373 2076 6f6c 756d 6573 e across volumes │ │ │ +0004d8e0: 2c20 7468 6520 736f 7572 6365 2073 686f , the source sho │ │ │ +0004d8f0: 756c 6420 6e6f 7420 6265 2064 656c 6574 uld not be delet │ │ │ +0004d900: 6564 2075 6e74 696c 2074 6865 7927 7665 ed until they've │ │ │ +0004d910: 2061 6c6c 2062 6565 6e20 636f 7069 6564 all been copied │ │ │ +0004d920: 2e20 5468 6174 2077 6f75 6c64 206c 6574 . That would let │ │ │ +0004d930: 2075 7320 726f 6c6c 6261 636b 2077 6974 us rollback wit │ │ │ +0004d940: 6820 6869 6768 6572 2063 6f6e 6669 6465 h higher confide │ │ │ +0004d950: 6e63 652e 3c2f 7464 3e3c 2f74 723e 3c74 nce.ideally, if we │ │ │ +0004d9b0: 2065 6e64 2075 7020 636f 7079 696e 6720 end up copying │ │ │ +0004d9c0: 6669 6c65 7320 6265 6361 7573 6520 6f66 files because of │ │ │ +0004d9d0: 2061 206d 6f76 6520 6163 726f 7373 0a76 a move across.v │ │ │ +0004d9e0: 6f6c 756d 6573 2c20 7468 6520 736f 7572 olumes, the sour │ │ │ +0004d9f0: 6365 2073 686f 756c 6420 6e6f 7420 6265 ce should not be │ │ │ +0004da00: 2064 656c 6574 6564 2075 6e74 696c 2074 deleted until t │ │ │ +0004da10: 6865 7927 7665 2061 6c6c 2062 6565 6e0a hey've all been. │ │ │ +0004da20: 636f 7069 6564 2e20 5468 6174 2077 6f75 copied. That wou │ │ │ +0004da30: 6c64 206c 6574 2075 7320 726f 6c6c 6261 ld let us rollba │ │ │ +0004da40: 636b 2077 6974 6820 6869 6768 6572 2063 ck with higher c │ │ │ +0004da50: 6f6e 6669 6465 6e63 652e 3c2f 6832 3e3c onfidence.

    < │ │ │ +0004da60: 6834 3e2e 2e2f 7372 632f 7374 6f72 6167 h4>../src/storag │ │ │ +0004da70: 655f 7574 696c 732e 6370 703a 3132 333c e_utils.cpp:123< │ │ │ +0004da80: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0004dac0: 2f2f 206c 6174 6572 0a09 0961 7578 3a3a  // later...aux::
    │ │ │ +0004dad0: 7665 6374 6f72 266c 743b 626f 6f6c 2c20  vector<bool, 
    │ │ │ +0004dae0: 6669 6c65 5f69 6e64 6578 5f74 2667 743b  file_index_t>
    │ │ │ +0004daf0: 2063 6f70 6965 645f 6669 6c65 7328 7374   copied_files(st
    │ │ │ +0004db00: 643a 3a73 697a 655f 7428 662e 6e75 6d5f  d::size_t(f.num_
    │ │ │ +0004db10: 6669 6c65 7328 2929 2c20 6661 6c73 6529  files()), false)
    │ │ │ +0004db20: 3b0a 0a09 092f 2f20 7472 6163 6b20 686f  ;....// track ho
    │ │ │ +0004db30: 7720 6661 7220 7765 2067 6f74 2069 6e20  w far we got in 
    │ │ │ +0004db40: 6361 7365 206f 6620 616e 2065 7272 6f72  case of an error
    │ │ │ +0004db50: 0a09 0966 696c 655f 696e 6465 785f 7420  ...file_index_t 
    │ │ │ +0004db60: 6669 6c65 5f69 6e64 6578 7b7d 3b0a 0909  file_index{};...
    │ │ │ +0004db70: 666f 7220 2861 7574 6f20 636f 6e73 7420  for (auto const 
    │ │ │ +0004db80: 6920 3a20 662e 6669 6c65 5f72 616e 6765  i : f.file_range
    │ │ │ +0004db90: 2829 290a 0909 7b0a 0909 092f 2f20 6669  ())...{....// fi
    │ │ │ +0004dba0: 6c65 7320 6d6f 7665 6420 6f75 7420 746f  les moved out to
    │ │ │ +0004dbb0: 2061 6273 6f6c 7574 6520 7061 7468 7320   absolute paths 
    │ │ │ +0004dbc0: 6172 6520 6e6f 7420 6d6f 7665 640a 0909  are not moved...
    │ │ │ +0004dbd0: 0969 6620 2866 2e66 696c 655f 6162 736f  .if (f.file_abso
    │ │ │ +0004dbe0: 6c75 7465 5f70 6174 6828 6929 2920 636f  lute_path(i)) co
    │ │ │ +0004dbf0: 6e74 696e 7565 3b0a 0a09 0909 7374 643a  ntinue;.....std:
    │ │ │ +0004dc00: 3a73 7472 696e 6720 636f 6e73 7420 6f6c  :string const ol
    │ │ │ +0004dc10: 645f 7061 7468 203d 2063 6f6d 6269 6e65  d_path = combine
    │ │ │ +0004dc20: 5f70 6174 6828 7361 7665 5f70 6174 682c  _path(save_path,
    │ │ │ +0004dc30: 2066 2e66 696c 655f 7061 7468 2869 2929   f.file_path(i))
    │ │ │ +0004dc40: 3b0a 0909 0973 7464 3a3a 7374 7269 6e67  ;....std::string
    │ │ │ +0004dc50: 2063 6f6e 7374 206e 6577 5f70 6174 6820   const new_path 
    │ │ │ +0004dc60: 3d20 636f 6d62 696e 655f 7061 7468 286e  = combine_path(n
    │ │ │ +0004dc70: 6577 5f73 6176 655f 7061 7468 2c20 662e  ew_save_path, f.
    │ │ │ +0004dc80: 6669 6c65 5f70 6174 6828 6929 293b 0a0a  file_path(i));..
    │ │ │ +0004dc90: 0909 0965 7272 6f72 5f63 6f64 6520 6967  ...error_code ig
    │ │ │ +0004dca0: 6e6f 7265 3b0a 0909 0969 6620 2866 6c61  nore;....if (fla
    │ │ │ +0004dcb0: 6773 203d 3d20 6d6f 7665 5f66 6c61 6773  gs == move_flags
    │ │ │ +0004dcc0: 5f74 3a3a 646f 6e74 5f72 6570 6c61 6365  _t::dont_replace
    │ │ │ +0004dcd0: 2026 616d 703b 2661 6d70 3b20 6578 6973   && exis
    │ │ │ +0004dce0: 7473 286e 6577 5f70 6174 682c 2069 676e  ts(new_path, ign
    │ │ │ +0004dcf0: 6f72 6529 290a 0909 097b 0a09 0909 0972  ore))....{.....r
    │ │ │ +0004dd00: 6574 207c 3d20 6469 736b 5f73 7461 7475  et |= disk_statu
    │ │ │ +0004dd10: 733a 3a6e 6565 645f 6675 6c6c 5f63 6865  s::need_full_che
    │ │ │ +0004dd20: 636b 3b0a 0909 0909 636f 6e74 696e 7565  ck;.....continue
    │ │ │ +0004dd30: 3b0a 0909 097d 0a0a 3c64 6976 2073 7479  ;....}..
    ...move_fi │ │ │ +0004dd70: 6c65 286f 6c64 5f70 6174 682c 206e 6577 le(old_path, new │ │ │ +0004dd80: 5f70 6174 682c 2065 6329 3b0a 3c2f 6469 _path, ec);.....// if the │ │ │ +0004dda0: 736f 7572 6365 2066 696c 6520 646f 6573 source file does │ │ │ +0004ddb0: 6e27 7420 6578 6973 742e 2054 6861 7427 n't exist. That' │ │ │ +0004ddc0: 7320 6e6f 7420 6120 7072 6f62 6c65 6d0a s not a problem. │ │ │ +0004ddd0: 0909 092f 2f20 7765 206a 7573 7420 6967 ...// we just ig │ │ │ +0004dde0: 6e6f 7265 2074 6861 7420 6669 6c65 0a09 nore that file.. │ │ │ +0004ddf0: 0909 6966 2028 6563 2e65 6320 3d3d 2062 ..if (ec.ec == b │ │ │ +0004de00: 6f6f 7374 3a3a 7379 7374 656d 3a3a 6572 oost::system::er │ │ │ +0004de10: 7263 3a3a 6e6f 5f73 7563 685f 6669 6c65 rc::no_such_file │ │ │ +0004de20: 5f6f 725f 6469 7265 6374 6f72 7929 0a09 _or_directory).. │ │ │ +0004de30: 0909 0965 632e 6563 2e63 6c65 6172 2829 ...ec.ec.clear() │ │ │ +0004de40: 3b0a 0909 0965 6c73 6520 6966 2028 6563 ;....else if (ec │ │ │ +0004de50: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ +0004de60: 6563 2e65 6320 213d 2062 6f6f 7374 3a3a ec.ec != boost:: │ │ │ +0004de70: 7379 7374 656d 3a3a 6572 7263 3a3a 696e system::errc::in │ │ │ +0004de80: 7661 6c69 645f 6172 6775 6d65 6e74 0a09 valid_argument.. │ │ │ +0004de90: 0909 0926 616d 703b 2661 6d70 3b20 6563 ...&& ec │ │ │ +0004dea0: 2e65 6320 213d 2062 6f6f 7374 3a3a 7379 .ec != boost::sy │ │ │ +0004deb0: 7374 656d 3a3a 6572 7263 3a3a 7065 726d stem::errc::perm │ │ │ +0004dec0: 6973 7369 6f6e 5f64 656e 6965 6429 0a09 ission_denied).. │ │ │ +0004ded0: 0909 7b0a 0909 0909 2f2f 206d 6f76 696e ..{.....// movin │ │ │ +0004dee0: 6720 7468 6520 6669 6c65 2066 6169 6c65 g the file faile │ │ │ +0004def0: 640a 0909 0909 2f2f 206f 6e20 4f53 582c d.....// on OSX, │ │ │ +0004df00: 2074 6865 2065 7272 6f72 2077 6865 6e20 the error when │ │ │ +0004df10: 7472 7969 6e67 2074 6f20 7265 6e61 6d65 trying to rename │ │ │ +0004df20: 2061 2066 696c 6520 6163 726f 7373 2064 a file across d │ │ │ +0004df30: 6966 6665 7265 6e74 0a09 0909 092f 2f20 ifferent.....// │ │ │ +0004df40: 766f 6c75 6d65 7320 6973 2045 5844 4556 volumes is EXDEV │ │ │ +0004df50: 2c20 7768 6963 6820 7769 6c6c 206d 616b , which will mak │ │ │ +0004df60: 6520 6974 2066 616c 6c20 6261 636b 2074 e it fall back t │ │ │ +0004df70: 6f20 636f 7079 696e 672e 0a09 0909 0965 o copying......e │ │ │ +0004df80: 632e 6563 2e63 6c65 6172 2829 3b0a 0909 c.ec.clear();... │ │ │ +0004df90: 0909 636f 7079 5f66 696c 6528 6f6c 645f ..copy_file(old_ │ │ │ +0004dfa0: 7061 7468 2c20 6e65 775f 7061 7468 2c20 path, new_path, │ │ │ +0004dfb0: 6563 293b 0a09 0909 0969 6620 2821 6563 ec);.....if (!ec │ │ │ +0004dfc0: 2920 636f 7069 6564 5f66 696c 6573 5b69 ) copied_files[i │ │ │ +0004dfd0: 5d20 3d20 7472 7565 3b0a 0909 097d 0a0a ] = true;....}.. │ │ │ +0004dfe0: 0909 0969 6620 2865 6329 0a09 0909 7b0a ...if (ec)....{. │ │ │ +0004dff0: 0909 0909 6563 2e66 696c 6528 6929 3b0a ....ec.file(i);. │ │ │ +0004e000: 0909 0909 6669 6c65 5f69 6e64 6578 203d ....file_index = │ │ │ +0004e010: 2069 3b0a 0909 0909 6272 6561 6b3b 0a09 i;.....break;.. │ │ │ +0004e020: 0909 7d0a 0909 7d0a 0a09 0969 6620 2821 ..}...}....if (! │ │ │ +0004e030: 6563 2026 616d 703b 2661 6d70 3b20 6d6f ec && mo │ │ │ +0004e040: 7665 5f70 6172 7466 696c 6529 0a09 097b ve_partfile)...{ │ │ │ +0004e050: 0a09 0909 6572 726f 725f 636f 6465 2065 ....error_code e │ │ │ +0004e060: 3b0a 0909 096d 6f76 655f 7061 7274 6669 ;....move_partfi │ │ │ +0004e070: 6c65 286e 6577 5f73 6176 655f 7061 7468 le(new_save_path │ │ │ +0004e080: 2c20 6529 3b0a 0909 0969 6620 2865 290a , e);....if (e). │ │ │ +0004e090: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0004e0a0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0004e0d0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../sr │ │ │ +0004e100: 632f 7374 6f72 6167 655f 7574 696c 732e c/storage_utils. │ │ │ +0004e110: 6370 703a 3433 313c 2f61 3e3c 2f74 643e cpp:431 │ │ │ +0004e120: 3c74 643e 6974 2077 6f75 6c64 2073 6565 it would see │ │ │ +0004e130: 6d20 7265 6173 6f6e 6162 6c65 2074 6f2c m reasonable to, │ │ │ +0004e140: 2069 6e73 7465 6164 2c20 7365 7420 7468 instead, set th │ │ │ +0004e150: 6520 6861 7665 5f70 6965 6365 7320 6269 e have_pieces bi │ │ │ +0004e160: 7473 2066 6f72 2074 6865 2070 6965 6365 ts for the piece │ │ │ +0004e170: 7320 7265 7072 6573 656e 7469 6e67 2074 s representing t │ │ │ +0004e180: 6865 7365 2066 696c 6573 2c20 616e 6420 hese files, and │ │ │ +0004e190: 7265 7375 6d65 2077 6974 6820 7468 6520 resume with the │ │ │ +0004e1a0: 6e6f 726d 616c 206c 6f67 6963 3c2f 7464 normal logic

    it wou │ │ │ +0004e200: 6c64 2073 6565 6d20 7265 6173 6f6e 6162 ld seem reasonab │ │ │ +0004e210: 6c65 2074 6f2c 2069 6e73 7465 6164 2c20 le to, instead, │ │ │ +0004e220: 7365 7420 7468 6520 6861 7665 5f70 6965 set the have_pie │ │ │ +0004e230: 6365 7320 6269 7473 0a66 6f72 2074 6865 ces bits.for the │ │ │ +0004e240: 2070 6965 6365 7320 7265 7072 6573 656e pieces represen │ │ │ +0004e250: 7469 6e67 2074 6865 7365 2066 696c 6573 ting these files │ │ │ +0004e260: 2c20 616e 6420 7265 7375 6d65 2077 6974 , and resume wit │ │ │ +0004e270: 6820 7468 6520 6e6f 726d 616c 0a6c 6f67 h the normal.log │ │ │ +0004e280: 6963 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ic

    ../sr │ │ │ +0004e290: 632f 7374 6f72 6167 655f 7574 696c 732e c/storage_utils. │ │ │ +0004e2a0: 6370 703a 3433 313c 2f68 343e 3c70 7265 cpp:431

    .....conti
    │ │ │ +0004e2f0: 6e75 653b 0a0a 0909 0909 7374 643a 3a69  nue;......std::i
    │ │ │ +0004e300: 6e74 3634 5f74 2063 6f6e 7374 2073 697a  nt64_t const siz
    │ │ │ +0004e310: 6520 3d20 6765 745f 6669 6c65 7369 7a65  e = get_filesize
    │ │ │ +0004e320: 2873 7461 742c 2066 696c 655f 696e 6465  (stat, file_inde
    │ │ │ +0004e330: 782c 2066 730a 0909 0909 092c 2073 6176  x, fs......, sav
    │ │ │ +0004e340: 655f 7061 7468 2c20 6563 293b 0a09 0909  e_path, ec);....
    │ │ │ +0004e350: 0969 6620 2873 697a 6520 266c 743b 2030  .if (size < 0
    │ │ │ +0004e360: 2920 7265 7475 726e 2066 616c 7365 3b0a  ) return false;.
    │ │ │ +0004e370: 0a09 0909 0969 6620 2873 697a 6520 266c  .....if (size &l
    │ │ │ +0004e380: 743b 2066 732e 6669 6c65 5f73 697a 6528  t; fs.file_size(
    │ │ │ +0004e390: 6669 6c65 5f69 6e64 6578 2929 0a09 0909  file_index))....
    │ │ │ +0004e3a0: 097b 0a09 0909 0909 6563 2e65 6320 3d20  .{......ec.ec = 
    │ │ │ +0004e3b0: 6572 726f 7273 3a3a 6d69 736d 6174 6368  errors::mismatch
    │ │ │ +0004e3c0: 696e 675f 6669 6c65 5f73 697a 653b 0a09  ing_file_size;..
    │ │ │ +0004e3d0: 0909 0909 6563 2e66 696c 6528 6669 6c65  ....ec.file(file
    │ │ │ +0004e3e0: 5f69 6e64 6578 293b 0a09 0909 0909 6563  _index);......ec
    │ │ │ +0004e3f0: 2e6f 7065 7261 7469 6f6e 203d 206f 7065  .operation = ope
    │ │ │ +0004e400: 7261 7469 6f6e 5f74 3a3a 6368 6563 6b5f  ration_t::check_
    │ │ │ +0004e410: 7265 7375 6d65 3b0a 0909 0909 0972 6574  resume;......ret
    │ │ │ +0004e420: 7572 6e20 6661 6c73 653b 0a09 0909 097d  urn false;.....}
    │ │ │ +0004e430: 0a09 0909 7d0a 0909 0972 6574 7572 6e20  ....}....return 
    │ │ │ +0004e440: 7472 7565 3b0a 0909 7d0a 0a23 6966 6e64  true;...}..#ifnd
    │ │ │ +0004e450: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +0004e460: 4c45 5f4d 5554 4142 4c45 5f54 4f52 5245  LE_MUTABLE_TORRE
    │ │ │ +0004e470: 4e54 530a 0909 2f2f 2061 6c77 6179 7320  NTS...// always 
    │ │ │ +0004e480: 7472 6967 6765 7220 6120 6675 6c6c 2072  trigger a full r
    │ │ │ +0004e490: 6563 6865 636b 2077 6865 6e20 7765 2070  echeck when we p
    │ │ │ +0004e4a0: 756c 6c20 696e 2066 696c 6573 2066 726f  ull in files fro
    │ │ │ +0004e4b0: 6d20 6f74 6865 720a 0909 2f2f 2074 6f72  m other...// tor
    │ │ │ +0004e4c0: 7265 6e74 732c 2076 6961 2068 6172 6420  rents, via hard 
    │ │ │ +0004e4d0: 6c69 6e6b 730a 3c64 6976 2073 7479 6c65  links.
    ..if (added_ │ │ │ +0004e510: 6669 6c65 7329 2072 6574 7572 6e20 6661 files) return fa │ │ │ +0004e520: 6c73 653b 0a3c 2f64 6976 3e23 656e 6469 lse;.
    #endi │ │ │ +0004e530: 660a 0a09 092f 2f20 7061 7273 6520 6861 f....// parse ha │ │ │ +0004e540: 7665 2062 6974 6d61 736b 2e20 5665 7269 ve bitmask. Veri │ │ │ +0004e550: 6679 2074 6861 7420 6669 6c65 7320 746f fy that files to │ │ │ +0004e560: 7563 6865 6420 6279 2063 6f6d 706c 6574 uched by complet │ │ │ +0004e570: 6564 2070 6965 6365 730a 0909 2f2f 2061 ed pieces...// a │ │ │ +0004e580: 6374 7561 6c6c 7920 6578 6973 742e 2041 ctually exist. A │ │ │ +0004e590: 2063 6f6d 706c 6574 6564 2070 6965 6365 completed piece │ │ │ +0004e5a0: 206d 6179 2073 7061 6e20 6d75 6c74 6970 may span multip │ │ │ +0004e5b0: 6c65 2066 696c 6573 2e0a 0909 666f 7220 le files....for │ │ │ +0004e5c0: 2866 696c 655f 696e 6465 785f 7420 636f (file_index_t co │ │ │ +0004e5d0: 6e73 7420 6669 6c65 5f69 6e64 6578 203a nst file_index : │ │ │ +0004e5e0: 2066 732e 6669 6c65 5f72 616e 6765 2829 fs.file_range() │ │ │ +0004e5f0: 290a 0909 7b0a 0909 092f 2f20 6669 6c65 )...{....// file │ │ │ +0004e600: 7320 7769 7468 2070 7269 6f72 6974 7920 s with priority │ │ │ +0004e610: 7a65 726f 206d 6179 206e 6f74 2068 6176 zero may not hav │ │ │ +0004e620: 6520 6265 656e 2073 6176 6564 2074 6f20 e been saved to │ │ │ +0004e630: 6469 736b 2061 7420 7468 6569 720a 0909 disk at their... │ │ │ +0004e640: 092f 2f20 6578 7065 6374 6564 206c 6f63 .// expected loc │ │ │ +0004e650: 6174 696f 6e2c 2062 7574 2069 7320 6c69 ation, but is li │ │ │ +0004e660: 6b65 6c79 2074 6f20 6265 2069 6e20 6120 kely to be in a │ │ │ +0004e670: 7061 7274 6669 6c65 2e20 4a75 7374 2065 partfile. Just e │ │ │ +0004e680: 7865 6d70 7420 6974 0a09 0909 2f2f 2066 xempt it....// f │ │ │ +0004e690: 726f 6d20 6368 6563 6b69 6e67 0a09 0909 rom checking.... │ │ │ +0004e6a0: 6966 2028 6669 6c65 5f69 6e64 6578 2026 if (file_index & │ │ │ +0004e6b0: 6c74 3b20 6669 6c65 5f70 7269 6f72 6974 lt; file_priorit │ │ │ +0004e6c0: 792e 656e 645f 696e 6465 7828 290a 0909 y.end_index()... │ │ │ +0004e6d0: 0909 2661 6d70 3b26 616d 703b 2066 696c ..&& fil │ │ │ +0004e6e0: 655f 7072 696f 7269 7479 5b66 696c 655f e_priority[file_ │ │ │ +0004e6f0: 696e 6465 785d 203d 3d20 646f 6e74 5f64 index] == dont_d │ │ │ +0004e700: 6f77 6e6c 6f61 6429 0a09 0909 0963 6f6e ownload).....con │ │ │ +0004e710: 7469 6e75 653b 0a0a 0909 0969 6620 2866 tinue;.....if (f │ │ │ +0004e720: 732e 7061 645f 6669 6c65 5f61 7428 6669 s.pad_file_at(fi │ │ │ +0004e730: 6c65 5f69 6e64 6578 2929 2063 6f6e 7469 le_index)) conti │ │ │ +0004e740: 6e75 653b 0a09 0909 6966 2028 6673 2e66 nue;....if (fs.f │ │ │ +0004e750: 696c 655f 7369 7a65 2866 696c 655f 696e ile_size(file_in │ │ │ +0004e760: 6465 7829 203d 3d20 3029 2063 6f6e 7469 dex) == 0) conti │ │ │ +0004e770: 6e75 653b 0a0a 0909 0961 7574 6f20 636f nue;.....auto co │ │ │ +0004e780: 6e73 7420 7069 6563 655f 7261 6e67 6520 nst piece_range │ │ │ +0004e790: 3d20 6175 783a 3a66 696c 655f 7069 6563 = aux::file_piec │ │ │ +0004e7a0: 655f 7261 6e67 655f 696e 636c 7573 6976 e_range_inclusiv │ │ │ +0004e7b0: 6528 6673 2c20 6669 6c65 5f69 6e64 6578 e(fs, file_index │ │ │ +0004e7c0: 293b 0a09 0909 7069 6563 655f 696e 6465 );....piece_inde │ │ │ +0004e7d0: 785f 7420 636f 6e73 7420 7374 6172 745f x_t const start_ │ │ │ +0004e7e0: 7069 6563 6520 3d20 7069 6563 655f 7261 piece = piece_ra │ │ │ +0004e7f0: 6e67 652e 5f62 6567 696e 3b0a 0a09 0909 nge._begin;..... │ │ │ +0004e800: 7069 6563 655f 696e 6465 785f 7420 636f piece_index_t co │ │ │ +0004e810: 6e73 7420 656e 645f 7069 6563 6520 3d20 nst end_piece = │ │ │ +0004e820: 7374 643a 3a6d 696e 2870 6965 6365 5f72 std::min(piece_r │ │ │ +0004e830: 616e 6765 2e5f 656e 642c 2072 642e 6861 ange._end, rd.ha │ │ │ +0004e840: 7665 5f70 6965 6365 732e 656e 645f 696e ve_pieces.end_in │ │ │ +0004e850: 6465 7828 2929 3b0a 0a09 0909 626f 6f6c dex());.....bool │ │ │ +0004e860: 2068 6173 5f63 6f6d 706c 6574 6564 5f72 has_completed_r │ │ │ +0004e870: 6573 756d 655f 7069 6563 6520 3d20 6661 esume_piece = fa │ │ │ +0004e880: 6c73 653b 0a09 0909 666f 7220 2870 6965 lse;....for (pie │ │ │ +0004e890: 6365 5f69 6e64 6578 5f74 2070 6965 6365 ce_index_t piece │ │ │ +0004e8a0: 203d 2073 7461 7274 5f70 6965 6365 3b20 = start_piece; │ │ │ +0004e8b0: 7069 6563 6520 266c 743b 2065 6e64 5f70 piece < end_p │ │ │ +0004e8c0: 6965 6365 3b20 2b2b 7069 6563 6529 0a09 iece; ++piece).. │ │ │ +0004e8d0: 0909 7b0a 0909 0909 6966 2028 2172 642e ..{.....if (!rd. │ │ │ +0004e8e0: 6861 7665 5f70 6965 6365 732e 6765 745f have_pieces.get_ │ │ │ +0004e8f0: 6269 7428 7069 6563 6529 2920 636f 6e74 bit(piece)) cont │ │ │ +0004e900: 696e 7565 3b0a 0909 0909 6861 735f 636f inue;.....has_co │ │ │ +0004e910: 6d70 6c65 7465 645f 7265 7375 6d65 5f70 mpleted_resume_p │ │ │ +0004e920: 6965 6365 203d 2074 7275 653b 0a09 0909 iece = true;.... │ │ │ +0004e930: 0962 7265 616b 3b0a 0909 097d 0a0a 0909 .break;....}.... │ │ │ +0004e940: 0969 6620 2821 6861 735f 636f 6d70 6c65 .if (!has_comple │ │ │ +0004e950: 7465 645f 7265 7375 6d65 5f70 6965 6365 ted_resume_piece │ │ │ +0004e960: 2920 636f 6e74 696e 7565 3b0a 3c2f 7072 ) continue;.rel │ │ │ +0004e9a0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/en │ │ │ +0004e9e0: 756d 5f6e 6574 2e63 7070 3a32 3436 3c2f um_net.cpp:246if we │ │ │ +0004ea00: 2067 6574 2068 6572 652c 2074 6865 2063 get here, the c │ │ │ +0004ea10: 616c 6c65 7220 7374 696c 6c20 6173 7375 aller still assu │ │ │ +0004ea20: 6d65 7320 7468 6520 6572 726f 7220 636f mes the error co │ │ │ +0004ea30: 6465 2069 7320 7265 706f 7274 6564 2076 de is reported v │ │ │ +0004ea40: 6961 2065 7272 6e6f 3c2f 7464 3e3c 2f74 ia errno

    if we get │ │ │ +0004eaa0: 6865 7265 2c20 7468 6520 6361 6c6c 6572 here, the caller │ │ │ +0004eab0: 2073 7469 6c6c 2061 7373 756d 6573 2074 still assumes t │ │ │ +0004eac0: 6865 2065 7272 6f72 2063 6f64 650a 6973 he error code.is │ │ │ +0004ead0: 2072 6570 6f72 7465 6420 7669 6120 6572 reported via er │ │ │ +0004eae0: 726e 6f3c 2f68 323e 3c68 343e 2e2e 2f73 rno

    ../s │ │ │ +0004eaf0: 7263 2f65 6e75 6d5f 6e65 742e 6370 703a rc/enum_net.cpp: │ │ │ +0004eb00: 3234 363c 2f68 343e 3c70 7265 2073 7479 246

    ..;..}.#endif.
    │ │ │ +0004eb50: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +0004eb60: 5f4e 4554 4c49 4e4b 0a0a 0969 6e74 2072  _NETLINK...int r
    │ │ │ +0004eb70: 6561 645f 6e6c 5f73 6f63 6b28 696e 7420  ead_nl_sock(int 
    │ │ │ +0004eb80: 736f 636b 2c20 7374 643a 3a75 696e 7433  sock, std::uint3
    │ │ │ +0004eb90: 325f 7420 636f 6e73 7420 7365 712c 2073  2_t const seq, s
    │ │ │ +0004eba0: 7464 3a3a 7569 6e74 3332 5f74 2063 6f6e  td::uint32_t con
    │ │ │ +0004ebb0: 7374 2070 6964 0a09 092c 2073 7464 3a3a  st pid..., std::
    │ │ │ +0004ebc0: 6675 6e63 7469 6f6e 266c 743b 766f 6964  function<void
    │ │ │ +0004ebd0: 286e 6c6d 7367 6864 7220 636f 6e73 742a  (nlmsghdr const*
    │ │ │ +0004ebe0: 2926 6774 3b20 6f6e 5f6d 7367 290a 097b  )> on_msg)..{
    │ │ │ +0004ebf0: 0a09 0973 7464 3a3a 6172 7261 7926 6c74  ...std::array<
    │ │ │ +0004ec00: 3b63 6861 722c 2034 3039 3626 6774 3b20  ;char, 4096> 
    │ │ │ +0004ec10: 6275 663b 0a09 0966 6f72 2028 3b3b 290a  buf;...for (;;).
    │ │ │ +0004ec20: 0909 7b0a 0909 0969 6e74 2063 6f6e 7374  ..{....int const
    │ │ │ +0004ec30: 2072 6561 645f 6c65 6e20 3d20 696e 7428   read_len = int(
    │ │ │ +0004ec40: 7265 6376 2873 6f63 6b2c 2062 7566 2e64  recv(sock, buf.d
    │ │ │ +0004ec50: 6174 6128 292c 2062 7566 2e73 697a 6528  ata(), buf.size(
    │ │ │ +0004ec60: 292c 2030 2929 3b0a 0909 0969 6620 2872  ), 0));....if (r
    │ │ │ +0004ec70: 6561 645f 6c65 6e20 266c 743b 2030 2920  ead_len < 0) 
    │ │ │ +0004ec80: 7265 7475 726e 202d 313b 0a0a 0909 0961  return -1;.....a
    │ │ │ +0004ec90: 7574 6f20 636f 6e73 742a 206e 6c5f 6864  uto const* nl_hd
    │ │ │ +0004eca0: 7220 3d20 7265 696e 7465 7270 7265 745f  r = reinterpret_
    │ │ │ +0004ecb0: 6361 7374 266c 743b 6e6c 6d73 6768 6472  cast<nlmsghdr
    │ │ │ +0004ecc0: 2063 6f6e 7374 2a26 6774 3b28 6275 662e   const*>(buf.
    │ │ │ +0004ecd0: 6461 7461 2829 293b 0a09 0909 696e 7420  data());....int 
    │ │ │ +0004ece0: 6c65 6e20 3d20 7265 6164 5f6c 656e 3b0a  len = read_len;.
    │ │ │ +0004ecf0: 0a09 0909 666f 7220 283b 206c 656e 2026  ....for (; len &
    │ │ │ +0004ed00: 6774 3b20 3020 2661 6d70 3b26 616d 703b  gt; 0 &&
    │ │ │ +0004ed10: 2061 7578 3a3a 6e6c 6d73 675f 6f6b 286e   aux::nlmsg_ok(n
    │ │ │ +0004ed20: 6c5f 6864 722c 206c 656e 293b 206e 6c5f  l_hdr, len); nl_
    │ │ │ +0004ed30: 6864 7220 3d20 6175 783a 3a6e 6c6d 7367  hdr = aux::nlmsg
    │ │ │ +0004ed40: 5f6e 6578 7428 6e6c 5f68 6472 2c20 6c65  _next(nl_hdr, le
    │ │ │ +0004ed50: 6e29 290a 0909 097b 0a3c 6469 7620 7374  n))....{.
    ....if (( │ │ │ +0004ed90: 6175 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c aux::nlmsg_ok(nl │ │ │ +0004eda0: 5f68 6472 2c20 7265 6164 5f6c 656e 2920 _hdr, read_len) │ │ │ +0004edb0: 3d3d 2030 2920 7c7c 2028 6e6c 5f68 6472 == 0) || (nl_hdr │ │ │ +0004edc0: 2d26 6774 3b6e 6c6d 7367 5f74 7970 6520 ->nlmsg_type │ │ │ +0004edd0: 3d3d 204e 4c4d 5347 5f45 5252 4f52 2929 == NLMSG_ERROR)) │ │ │ +0004ede0: 0a3c 2f64 6976 3e09 0909 0909 7265 7475 .
    .....retu │ │ │ +0004edf0: 726e 202d 313b 0a09 0909 092f 2f20 7468 rn -1;.....// th │ │ │ +0004ee00: 6973 2066 756e 6374 696f 6e20 646f 6573 is function does │ │ │ +0004ee10: 6e27 7420 6861 6e64 6c65 206d 756c 7469 n't handle multi │ │ │ +0004ee20: 706c 6520 7265 7175 6573 7473 2061 7420 ple requests at │ │ │ +0004ee30: 7468 6520 7361 6d65 2074 696d 650a 0909 the same time... │ │ │ +0004ee40: 0909 2f2f 2073 6f20 7265 706f 7274 2061 ..// so report a │ │ │ +0004ee50: 6e20 6572 726f 7220 6966 2074 6865 206d n error if the m │ │ │ +0004ee60: 6573 7361 6765 2064 6f65 7320 6e6f 7420 essage does not │ │ │ +0004ee70: 6861 7665 2074 6865 2065 7870 6563 7465 have the expecte │ │ │ +0004ee80: 6420 7365 7120 616e 6420 7069 640a 3c2f d seq and pid.r │ │ │ +0004eec0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0004eed0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../src/ │ │ │ +0004ef00: 656e 756d 5f6e 6574 2e63 7070 3a32 3532 enum_net.cpp:252 │ │ │ +0004ef10: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6620 if │ │ │ +0004ef20: 7765 2067 6574 2068 6572 652c 2074 6865 we get here, the │ │ │ +0004ef30: 2063 616c 6c65 7220 7374 696c 6c20 6173 caller still as │ │ │ +0004ef40: 7375 6d65 7320 7468 6520 6572 726f 7220 sumes the error │ │ │ +0004ef50: 636f 6465 2069 7320 7265 706f 7274 6564 code is reported │ │ │ +0004ef60: 2076 6961 2065 7272 6e6f 3c2f 7464 3e3c via errno< │ │ │ +0004ef70: 2f74 723e 3c74 7220 6964 3d22 3138 3822 /tr>

    if we ge │ │ │ +0004efc0: 7420 6865 7265 2c20 7468 6520 6361 6c6c t here, the call │ │ │ +0004efd0: 6572 2073 7469 6c6c 2061 7373 756d 6573 er still assumes │ │ │ +0004efe0: 2074 6865 2065 7272 6f72 2063 6f64 650a the error code. │ │ │ +0004eff0: 6973 2072 6570 6f72 7465 6420 7669 6120 is reported via │ │ │ +0004f000: 6572 726e 6f3c 2f68 323e 3c68 343e 2e2e errno

    .. │ │ │ +0004f010: 2f73 7263 2f65 6e75 6d5f 6e65 742e 6370 /src/enum_net.cp │ │ │ +0004f020: 703a 3235 323c 2f68 343e 3c70 7265 2073 p:252

    #if TORRENT_
    │ │ │ +0004f070: 5553 455f 4e45 544c 494e 4b0a 0a09 696e  USE_NETLINK...in
    │ │ │ +0004f080: 7420 7265 6164 5f6e 6c5f 736f 636b 2869  t read_nl_sock(i
    │ │ │ +0004f090: 6e74 2073 6f63 6b2c 2073 7464 3a3a 7569  nt sock, std::ui
    │ │ │ +0004f0a0: 6e74 3332 5f74 2063 6f6e 7374 2073 6571  nt32_t const seq
    │ │ │ +0004f0b0: 2c20 7374 643a 3a75 696e 7433 325f 7420  , std::uint32_t 
    │ │ │ +0004f0c0: 636f 6e73 7420 7069 640a 0909 2c20 7374  const pid..., st
    │ │ │ +0004f0d0: 643a 3a66 756e 6374 696f 6e26 6c74 3b76  d::function<v
    │ │ │ +0004f0e0: 6f69 6428 6e6c 6d73 6768 6472 2063 6f6e  oid(nlmsghdr con
    │ │ │ +0004f0f0: 7374 2a29 2667 743b 206f 6e5f 6d73 6729  st*)> on_msg)
    │ │ │ +0004f100: 0a09 7b0a 0909 7374 643a 3a61 7272 6179  ..{...std::array
    │ │ │ +0004f110: 266c 743b 6368 6172 2c20 3430 3936 2667  <char, 4096&g
    │ │ │ +0004f120: 743b 2062 7566 3b0a 0909 666f 7220 283b  t; buf;...for (;
    │ │ │ +0004f130: 3b29 0a09 097b 0a09 0909 696e 7420 636f  ;)...{....int co
    │ │ │ +0004f140: 6e73 7420 7265 6164 5f6c 656e 203d 2069  nst read_len = i
    │ │ │ +0004f150: 6e74 2872 6563 7628 736f 636b 2c20 6275  nt(recv(sock, bu
    │ │ │ +0004f160: 662e 6461 7461 2829 2c20 6275 662e 7369  f.data(), buf.si
    │ │ │ +0004f170: 7a65 2829 2c20 3029 293b 0a09 0909 6966  ze(), 0));....if
    │ │ │ +0004f180: 2028 7265 6164 5f6c 656e 2026 6c74 3b20   (read_len < 
    │ │ │ +0004f190: 3029 2072 6574 7572 6e20 2d31 3b0a 0a09  0) return -1;...
    │ │ │ +0004f1a0: 0909 6175 746f 2063 6f6e 7374 2a20 6e6c  ..auto const* nl
    │ │ │ +0004f1b0: 5f68 6472 203d 2072 6569 6e74 6572 7072  _hdr = reinterpr
    │ │ │ +0004f1c0: 6574 5f63 6173 7426 6c74 3b6e 6c6d 7367  et_cast<nlmsg
    │ │ │ +0004f1d0: 6864 7220 636f 6e73 742a 2667 743b 2862  hdr const*>(b
    │ │ │ +0004f1e0: 7566 2e64 6174 6128 2929 3b0a 0909 0969  uf.data());....i
    │ │ │ +0004f1f0: 6e74 206c 656e 203d 2072 6561 645f 6c65  nt len = read_le
    │ │ │ +0004f200: 6e3b 0a0a 0909 0966 6f72 2028 3b20 6c65  n;.....for (; le
    │ │ │ +0004f210: 6e20 2667 743b 2030 2026 616d 703b 2661  n > 0 &&a
    │ │ │ +0004f220: 6d70 3b20 6175 783a 3a6e 6c6d 7367 5f6f  mp; aux::nlmsg_o
    │ │ │ +0004f230: 6b28 6e6c 5f68 6472 2c20 6c65 6e29 3b20  k(nl_hdr, len); 
    │ │ │ +0004f240: 6e6c 5f68 6472 203d 2061 7578 3a3a 6e6c  nl_hdr = aux::nl
    │ │ │ +0004f250: 6d73 675f 6e65 7874 286e 6c5f 6864 722c  msg_next(nl_hdr,
    │ │ │ +0004f260: 206c 656e 2929 0a09 0909 7b0a 0909 0909   len))....{.....
    │ │ │ +0004f270: 6966 2028 2861 7578 3a3a 6e6c 6d73 675f  if ((aux::nlmsg_
    │ │ │ +0004f280: 6f6b 286e 6c5f 6864 722c 2072 6561 645f  ok(nl_hdr, read_
    │ │ │ +0004f290: 6c65 6e29 203d 3d20 3029 207c 7c20 286e  len) == 0) || (n
    │ │ │ +0004f2a0: 6c5f 6864 722d 2667 743b 6e6c 6d73 675f  l_hdr->nlmsg_
    │ │ │ +0004f2b0: 7479 7065 203d 3d20 4e4c 4d53 475f 4552  type == NLMSG_ER
    │ │ │ +0004f2c0: 524f 5229 290a 0909 0909 0972 6574 7572  ROR))......retur
    │ │ │ +0004f2d0: 6e20 2d31 3b0a 0909 0909 2f2f 2074 6869  n -1;.....// thi
    │ │ │ +0004f2e0: 7320 6675 6e63 7469 6f6e 2064 6f65 736e  s function doesn
    │ │ │ +0004f2f0: 2774 2068 616e 646c 6520 6d75 6c74 6970  't handle multip
    │ │ │ +0004f300: 6c65 2072 6571 7565 7374 7320 6174 2074  le requests at t
    │ │ │ +0004f310: 6865 2073 616d 6520 7469 6d65 0a09 0909  he same time....
    │ │ │ +0004f320: 092f 2f20 736f 2072 6570 6f72 7420 616e  .// so report an
    │ │ │ +0004f330: 2065 7272 6f72 2069 6620 7468 6520 6d65   error if the me
    │ │ │ +0004f340: 7373 6167 6520 646f 6573 206e 6f74 2068  ssage does not h
    │ │ │ +0004f350: 6176 6520 7468 6520 6578 7065 6374 6564  ave the expected
    │ │ │ +0004f360: 2073 6571 2061 6e64 2070 6964 0a3c 6469   seq and pid.....i
    │ │ │ +0004f3a0: 6620 286e 6c5f 6864 722d 2667 743b 6e6c  f (nl_hdr->nl
    │ │ │ +0004f3b0: 6d73 675f 7365 7120 213d 2073 6571 207c  msg_seq != seq |
    │ │ │ +0004f3c0: 7c20 6e6c 5f68 6472 2d26 6774 3b6e 6c6d  | nl_hdr->nlm
    │ │ │ +0004f3d0: 7367 5f70 6964 2021 3d20 7069 6429 0a3c  sg_pid != pid).<
    │ │ │ +0004f3e0: 2f64 6976 3e09 0909 0909 7265 7475 726e  /div>.....return
    │ │ │ +0004f3f0: 202d 313b 0a0a 0909 0909 6966 2028 6e6c   -1;......if (nl
    │ │ │ +0004f400: 5f68 6472 2d26 6774 3b6e 6c6d 7367 5f74  _hdr->nlmsg_t
    │ │ │ +0004f410: 7970 6520 3d3d 204e 4c4d 5347 5f44 4f4e  ype == NLMSG_DON
    │ │ │ +0004f420: 4529 2072 6574 7572 6e20 303b 0a0a 0909  E) return 0;....
    │ │ │ +0004f430: 0909 6f6e 5f6d 7367 286e 6c5f 6864 7229  ..on_msg(nl_hdr)
    │ │ │ +0004f440: 3b0a 0a09 0909 0969 6620 2828 6e6c 5f68  ;......if ((nl_h
    │ │ │ +0004f450: 6472 2d26 6774 3b6e 6c6d 7367 5f66 6c61  dr->nlmsg_fla
    │ │ │ +0004f460: 6773 2026 616d 703b 204e 4c4d 5f46 5f4d  gs & NLM_F_M
    │ │ │ +0004f470: 554c 5449 2920 3d3d 2030 2920 7265 7475  ULTI) == 0) retu
    │ │ │ +0004f480: 726e 2030 3b0a 0909 097d 0a09 097d 0a2f  rn 0;....}...}./
    │ │ │ +0004f490: 2f09 0972 6574 7572 6e20 303b 0a09 7d0a  /..return 0;..}.
    │ │ │ +0004f4a0: 0a09 696e 7420 6e6c 5f64 756d 705f 7265  ..int nl_dump_re
    │ │ │ +0004f4b0: 7175 6573 7428 696e 7420 636f 6e73 7420  quest(int const 
    │ │ │ +0004f4c0: 736f 636b 2c20 7374 643a 3a75 696e 7433  sock, std::uint3
    │ │ │ +0004f4d0: 325f 7420 636f 6e73 7420 7365 710a 0909  2_t const seq...
    │ │ │ +0004f4e0: 2c20 6e6c 6d73 6768 6472 2a20 636f 6e73  , nlmsghdr* cons
    │ │ │ +0004f4f0: 7420 7265 7175 6573 745f 6d73 672c 2073  t request_msg, s
    │ │ │ +0004f500: 7464 3a3a 6675 6e63 7469 6f6e 266c 743b  td::function<
    │ │ │ +0004f510: 766f 6964 286e 6c6d 7367 6864 7220 636f  void(nlmsghdr co
    │ │ │ +0004f520: 6e73 742a 2926 6774 3b20 6f6e 5f6d 7367  nst*)> on_msg
    │ │ │ +0004f530: 290a 097b 0a09 0972 6571 7565 7374 5f6d  )..{...request_m
    │ │ │ +0004f540: 7367 2d26 6774 3b6e 6c6d 7367 5f66 6c61  sg->nlmsg_fla
    │ │ │ +0004f550: 6773 203d 204e 4c4d 5f46 5f44 554d 5020  gs = NLM_F_DUMP 
    │ │ │ +0004f560: 7c20 4e4c 4d5f 465f 5245 5155 4553 543b  | NLM_F_REQUEST;
    │ │ │ +0004f570: 0a09 0972 6571 7565 7374 5f6d 7367 2d26  ...request_msg-&
    │ │ │ +0004f580: 6774 3b6e 6c6d 7367 5f73 6571 203d 2073  gt;nlmsg_seq = s
    │ │ │ +0004f590: 6571 3b0a 0909 2f2f 2069 6e20 7468 656f  eq;...// in theo
    │ │ │ +0004f5a0: 7279 206e 6c6d 7367 5f70 6964 2073 686f  ry nlmsg_pid sho
    │ │ │ +0004f5b0: 756c 6420 6265 2073 6574 2074 6f20 7468  uld be set to th
    │ │ │ +0004f5c0: 6520 6e65 746c 696e 6b20 706f 7274 2049  e netlink port I
    │ │ │ +0004f5d0: 4420 284e 4f54 2074 6865 2070 726f 6365  D (NOT the proce
    │ │ │ +0004f5e0: 7373 2049 4429 0a09 092f 2f20 6f66 2074  ss ID)...// of t
    │ │ │ +0004f5f0: 6865 2073 656e 6465 722c 2062 7574 2074  he sender, but t
    │ │ │ +0004f600: 6865 206b 6572 6e65 6c20 6967 6e6f 7265  he kernel ignore
    │ │ │ +0004f610: 7320 7468 6973 2066 6965 6c64 2073 6f20  s this field so 
    │ │ │ +0004f620: 6974 2069 7320 7479 7069 6361 6c6c 7920  it is typically 
    │ │ │ +0004f630: 7365 7420 746f 0a09 092f 2f20 7a65 726f  set to...// zero
    │ │ │ +0004f640: 0a09 0972 6571 7565 7374 5f6d 7367 2d26  ...request_msg-&
    │ │ │ +0004f650: 6774 3b6e 6c6d 7367 5f70 6964 203d 2030  gt;nlmsg_pid = 0
    │ │ │ +0004f660: 3b0a 0a09 0969 6620 283a 3a73 656e 6428  ;....if (::send(
    │ │ │ +0004f670: 736f 636b 2c20 7265 7175 6573 745f 6d73  sock, request_ms
    │ │ │ +0004f680: 672c 2072 6571 7565 7374 5f6d 7367 2d26  g, request_msg-&
    │ │ │ +0004f690: 6774 3b6e 6c6d 7367 5f6c 656e 2c20 3029  gt;nlmsg_len, 0)
    │ │ │ +0004f6a0: 2026 6c74 3b20 3029 0a09 0909 7265 7475   < 0)....retu
    │ │ │ +0004f6b0: 726e 202d 313b 0a0a 0909 2f2f 2067 6574  rn -1;....// get
    │ │ │ +0004f6c0: 2074 6865 2073 6f63 6b65 7427 7320 706f   the socket's po
    │ │ │ +0004f6d0: 7274 2049 4420 736f 2074 6861 7420 7765  rt ID so that we
    │ │ │ +0004f6e0: 2063 616e 2076 6572 6966 7920 6974 2069   can verify it i
    │ │ │ +0004f6f0: 6e20 7468 6520 7265 7370 6f6e 7365 0a09  n the response..
    │ │ │ +0004f700: 0973 6f63 6b61 6464 725f 6e6c 2073 6f63  .sockaddr_nl soc
    │ │ │ +0004f710: 6b5f 6164 6472 3b0a 0909 736f 636b 6c65  k_addr;...sockle
    │ │ │ +0004f720: 6e5f 7420 736f 636b 5f61 6464 725f 6c65  n_t sock_addr_le
    │ │ │ +0004f730: 6e20 3d20 7369 7a65 6f66 2873 6f63 6b5f  n = sizeof(sock_
    │ │ │ +0004f740: 6164 6472 293b 0a09 0969 6620 283a 3a67  addr);...if (::g
    │ │ │ +0004f750: 6574 736f 636b 6e61 6d65 2873 6f63 6b2c  etsockname(sock,
    │ │ │ +0004f760: 2072 6569 6e74 6572 7072 6574 5f63 6173   reinterpret_cas
    │ │ │ +0004f770: 7426 6c74 3b73 6f63 6b61 6464 722a 2667  t<sockaddr*&g
    │ │ │ +0004f780: 743b 2826 616d 703b 736f 636b 5f61 6464  t;(&sock_add
    │ │ │ +0004f790: 7229 2c20 2661 6d70 3b73 6f63 6b5f 6164  r), &sock_ad
    │ │ │ +0004f7a0: 6472 5f6c 656e 2920 266c 743b 2030 290a  dr_len) < 0).
    │ │ │ +0004f7b0: 0909 0972 6574 7572 6e20 2d31 3b0a 3c2f  ...return -1;.r
    │ │ │ +0004f7f0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +0004f800: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ +0004f830: 7072 6561 645f 6469 736b 5f69 6f2e 6370  pread_disk_io.cp
    │ │ │ +0004f840: 703a 3735 323c 2f61 3e3c 2f74 643e 3c74  p:752back-pressure 
    │ │ │ +0004f860: 2874 6865 2064 6973 6b5f 6f62 7365 7276  (the disk_observ
    │ │ │ +0004f870: 6572 206f 2920 6973 2064 726f 7070 6564  er o) is dropped
    │ │ │ +0004f880: 206f 6e20 7468 6520 626c 6f63 6b65 6420   on the blocked 
    │ │ │ +0004f890: 7061 7468 2e20 6173 796e 635f 7772 6974  path. async_writ
    │ │ │ +0004f8a0: 6520 7265 7475 726e 7320 6661 6c73 6520  e returns false 
    │ │ │ +0004f8b0: 286b 6565 7020 7772 6974 696e 6729 2062  (keep writing) b
    │ │ │ +0004f8c0: 7574 2074 6865 2063 6163 6865 2773 2062  ut the cache's b
    │ │ │ +0004f8d0: 6163 6b2d 7072 6573 7375 7265 2028 6472  ack-pressure (dr
    │ │ │ +0004f8e0: 6976 656e 206f 6666 206d 5f62 6c6f 636b  iven off m_block
    │ │ │ +0004f8f0: 7329 2063 616e 2774 2073 6565 2074 6865  s) can't see the
    │ │ │ +0004f900: 2070 6172 6b65 6420 7772 6974 6573 2c20   parked writes, 
    │ │ │ +0004f910: 736f 2061 206c 6f6e 672d 6c69 7665 6420  so a long-lived 
    │ │ │ +0004f920: 6665 6e63 6520 2865 2e67 2e20 6d6f 7665  fence (e.g. move
    │ │ │ +0004f930: 5f73 746f 7261 6765 2920 6f6e 2061 2062  _storage) on a b
    │ │ │ +0004f940: 7573 7920 746f 7272 656e 7420 6361 6e20  usy torrent can 
    │ │ │ +0004f950: 6772 6f77 206d 5f62 6c6f 636b 6564 5f6a  grow m_blocked_j
    │ │ │ +0004f960: 6f62 7320 756e 626f 756e 6465 642e 2043  obs unbounded. C
    │ │ │ +0004f970: 6172 7279 2074 6865 206f 6273 6572 7665  arry the observe
    │ │ │ +0004f980: 7220 7468 726f 7567 6820 746f 2074 6872  r through to thr
    │ │ │ +0004f990: 6f74 746c 6520 7468 6520 7065 6572 2077  ottle the peer w
    │ │ │ +0004f9a0: 6869 6c65 2069 7473 2077 7269 7465 7320  hile its writes 
    │ │ │ +0004f9b0: 6172 6520 7061 726b 6564 2e3c 2f74 643e  are parked.
    │ │ │ +0004f9c0: 3c2f 7472 3e3c 7472 2069 643d 2231 3839  

    back-pr │ │ │ +0004fa10: 6573 7375 7265 2028 7468 6520 6469 736b essure (the disk │ │ │ +0004fa20: 5f6f 6273 6572 7665 7220 6f29 2069 7320 _observer o) is │ │ │ +0004fa30: 6472 6f70 7065 6420 6f6e 2074 6865 2062 dropped on the b │ │ │ +0004fa40: 6c6f 636b 6564 2070 6174 682e 0a61 7379 locked path..asy │ │ │ +0004fa50: 6e63 5f77 7269 7465 2072 6574 7572 6e73 nc_write returns │ │ │ +0004fa60: 2066 616c 7365 2028 6b65 6570 2077 7269 false (keep wri │ │ │ +0004fa70: 7469 6e67 2920 6275 7420 7468 6520 6361 ting) but the ca │ │ │ +0004fa80: 6368 6527 7320 6261 636b 2d70 7265 7373 che's back-press │ │ │ +0004fa90: 7572 650a 2864 7269 7665 6e20 6f66 6620 ure.(driven off │ │ │ +0004faa0: 6d5f 626c 6f63 6b73 2920 6361 6e27 7420 m_blocks) can't │ │ │ +0004fab0: 7365 6520 7468 6520 7061 726b 6564 2077 see the parked w │ │ │ +0004fac0: 7269 7465 732c 2073 6f20 6120 6c6f 6e67 rites, so a long │ │ │ +0004fad0: 2d6c 6976 6564 2066 656e 6365 0a28 652e -lived fence.(e. │ │ │ +0004fae0: 672e 206d 6f76 655f 7374 6f72 6167 6529 g. move_storage) │ │ │ +0004faf0: 206f 6e20 6120 6275 7379 2074 6f72 7265 on a busy torre │ │ │ +0004fb00: 6e74 2063 616e 2067 726f 7720 6d5f 626c nt can grow m_bl │ │ │ +0004fb10: 6f63 6b65 645f 6a6f 6273 2075 6e62 6f75 ocked_jobs unbou │ │ │ +0004fb20: 6e64 6564 2e0a 4361 7272 7920 7468 6520 nded..Carry the │ │ │ +0004fb30: 6f62 7365 7276 6572 2074 6872 6f75 6768 observer through │ │ │ +0004fb40: 2074 6f20 7468 726f 7474 6c65 2074 6865 to throttle the │ │ │ +0004fb50: 2070 6565 7220 7768 696c 6520 6974 7320 peer while its │ │ │ +0004fb60: 7772 6974 6573 2061 7265 2070 6172 6b65 writes are parke │ │ │ +0004fb70: 642e 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 d.

    ../sr │ │ │ +0004fb80: 632f 7072 6561 645f 6469 736b 5f69 6f2e c/pread_disk_io. │ │ │ +0004fb90: 6370 703a 3735 323c 2f68 343e 3c70 7265 cpp:752

    .// storag
    │ │ │ +0004fbe0: 6527 7320 6f75 7473 7461 6e64 696e 672d  e's outstanding-
    │ │ │ +0004fbf0: 6a6f 6220 636f 756e 742e 2069 735f 626c  job count. is_bl
    │ │ │ +0004fc00: 6f63 6b65 6428 2920 6861 7320 6e6f 7420  ocked() has not 
    │ │ │ +0004fc10: 7275 6e2c 2073 6f20 6a20 6973 206e 6f74  run, so j is not
    │ │ │ +0004fc20: 0a09 2f2f 2069 6e5f 7072 6f67 7265 7373  ..// in_progress
    │ │ │ +0004fc30: 2061 6e64 206d 7573 7420 6e6f 7420 6265   and must not be
    │ │ │ +0004fc40: 206a 6f62 5f63 6f6d 706c 6574 6528 2964   job_complete()d
    │ │ │ +0004fc50: 202d 2d20 6162 6f72 7420 6974 2064 6972   -- abort it dir
    │ │ │ +0004fc60: 6563 746c 792e 0a09 6966 2028 6d5f 6162  ectly...if (m_ab
    │ │ │ +0004fc70: 6f72 7429 0a09 7b0a 0909 6d5f 636f 6d70  ort)..{...m_comp
    │ │ │ +0004fc80: 6c65 7465 645f 6a6f 6273 2e61 626f 7274  leted_jobs.abort
    │ │ │ +0004fc90: 5f6a 6f62 286d 5f69 6f73 2c20 6a29 3b0a  _job(m_ios, j);.
    │ │ │ +0004fca0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ +0004fcb0: 097d 0a0a 092f 2f20 6120 7772 6974 6520  .}...// a write 
    │ │ │ +0004fcc0: 636f 756e 7473 2061 7320 616e 206f 7574  counts as an out
    │ │ │ +0004fcd0: 7374 616e 6469 6e67 206a 6f62 206f 6e20  standing job on 
    │ │ │ +0004fce0: 7468 6520 7374 6f72 6167 6520 286c 696b  the storage (lik
    │ │ │ +0004fcf0: 6520 6120 7265 6164 206f 7220 6861 7368  e a read or hash
    │ │ │ +0004fd00: 292c 0a09 2f2f 2073 6f20 6120 6665 6e63  ),..// so a fenc
    │ │ │ +0004fd10: 6520 7761 6974 7320 666f 7220 6275 6666  e waits for buff
    │ │ │ +0004fd20: 6572 6564 2077 7269 7465 7320 616e 6420  ered writes and 
    │ │ │ +0004fd30: 7468 6569 7220 696e 2d66 6c69 6768 7420  their in-flight 
    │ │ │ +0004fd40: 666c 7573 6820 6265 666f 7265 2069 740a  flush before it.
    │ │ │ +0004fd50: 092f 2f20 7275 6e73 2c20 7261 7468 6572  .// runs, rather
    │ │ │ +0004fd60: 2074 6861 6e20 7465 6172 696e 6720 7468   than tearing th
    │ │ │ +0004fd70: 6520 7374 6f72 6167 6520 646f 776e 2075  e storage down u
    │ │ │ +0004fd80: 6e64 6572 2061 2066 6c75 7368 2e20 5468  nder a flush. Th
    │ │ │ +0004fd90: 6973 2064 6f65 7320 6e6f 740a 092f 2f20  is does not..// 
    │ │ │ +0004fda0: 6465 6164 6c6f 636b 2074 6865 2066 656e  deadlock the fen
    │ │ │ +0004fdb0: 6365 3a20 6164 645f 6665 6e63 655f 6a6f  ce: add_fence_jo
    │ │ │ +0004fdc0: 6228 2920 6861 6e64 7320 6120 7374 6f72  b() hands a stor
    │ │ │ +0004fdd0: 6167 6520 7769 7468 206f 7574 7374 616e  age with outstan
    │ │ │ +0004fde0: 6469 6e67 2077 7269 7465 730a 092f 2f20  ding writes..// 
    │ │ │ +0004fdf0: 746f 2061 2067 656e 6572 6963 2074 6872  to a generic thr
    │ │ │ +0004fe00: 6561 6420 746f 2066 6c75 7368 2c20 6472  ead to flush, dr
    │ │ │ +0004fe10: 6169 6e69 6e67 2074 6865 2077 7269 7465  aining the write
    │ │ │ +0004fe20: 7320 7468 6520 6665 6e63 6520 7761 6974  s the fence wait
    │ │ │ +0004fe30: 7320 6f6e 2e0a 092f 2f0a 092f 2f20 7768  s on...//..// wh
    │ │ │ +0004fe40: 656e 2061 2066 656e 6365 2069 7320 7570  en a fence is up
    │ │ │ +0004fe50: 2c20 6973 5f62 6c6f 636b 6564 2829 2070  , is_blocked() p
    │ │ │ +0004fe60: 6172 6b73 2074 6865 206a 6f62 2069 6e20  arks the job in 
    │ │ │ +0004fe70: 7468 6520 6665 6e63 6527 7320 626c 6f63  the fence's bloc
    │ │ │ +0004fe80: 6b65 6420 7175 6575 650a 092f 2f20 746f  ked queue..// to
    │ │ │ +0004fe90: 2062 6520 7265 706f 7374 6564 2069 6e74   be reposted int
    │ │ │ +0004fea0: 6f20 7468 6520 6361 6368 6520 6f6e 6365  o the cache once
    │ │ │ +0004feb0: 2074 6865 2066 656e 6365 206c 6f77 6572   the fence lower
    │ │ │ +0004fec0: 7320 2861 6464 5f63 6f6d 706c 6574 6564  s (add_completed
    │ │ │ +0004fed0: 5f6a 6f62 735f 696d 706c 292e 0a09 2f2f  _jobs_impl)...//
    │ │ │ +0004fee0: 2049 6e73 6572 7469 6e67 206e 6f77 2077   Inserting now w
    │ │ │ +0004fef0: 6f75 6c64 2072 6163 6520 7465 6172 646f  ould race teardo
    │ │ │ +0004ff00: 776e 3a20 666f 7220 636c 6561 725f 7069  wn: for clear_pi
    │ │ │ +0004ff10: 6563 6520 7468 6520 6370 6520 6973 2061  ece the cpe is a
    │ │ │ +0004ff20: 626f 7574 2074 6f20 6265 0a09 2f2f 2072  bout to be..// r
    │ │ │ +0004ff30: 6573 6574 2c20 666f 7220 7374 6f72 6167  eset, for storag
    │ │ │ +0004ff40: 652d 7769 6465 2066 656e 6365 7320 7468  e-wide fences th
    │ │ │ +0004ff50: 6520 7374 6f72 6167 6520 6973 2061 626f  e storage is abo
    │ │ │ +0004ff60: 7574 2074 6f20 676f 2061 7761 792e 2050  ut to go away. P
    │ │ │ +0004ff70: 6172 6b69 6e67 0a09 2f2f 206b 6565 7073  arking..// keeps
    │ │ │ +0004ff80: 2074 6865 2062 6c6f 636b 2022 7772 6974   the block "writ
    │ │ │ +0004ff90: 696e 6722 2069 6e20 7468 6520 7069 636b  ing" in the pick
    │ │ │ +0004ffa0: 6572 2773 2076 6965 772c 2073 6f20 7468  er's view, so th
    │ │ │ +0004ffb0: 6520 7069 6563 6520 6973 6e27 7420 7265  e piece isn't re
    │ │ │ +0004ffc0: 706f 7274 6564 0a09 2f2f 2066 696e 6973  ported..// finis
    │ │ │ +0004ffd0: 6865 6420 616e 6420 6974 7320 6861 7368  hed and its hash
    │ │ │ +0004ffe0: 2069 736e 2774 2072 6571 7565 7374 6564   isn't requested
    │ │ │ +0004fff0: 2062 6566 6f72 6520 7468 6520 626c 6f63   before the bloc
    │ │ │ +00050000: 6b20 6861 7320 6265 656e 2069 6e73 6572  k has been inser
    │ │ │ +00050010: 7465 642e 0a3c 6469 7620 7374 796c 653d  ted..
    .if (j->st │ │ │ +00050050: 6f72 6167 652d 2667 743b 6973 5f62 6c6f orage->is_blo │ │ │ +00050060: 636b 6564 286a 2c20 6d5f 7374 6174 735f cked(j, m_stats_ │ │ │ +00050070: 636f 756e 7465 7273 2929 0a3c 2f64 6976 counters)).
    .{...return fal │ │ │ +00050090: 7365 3b0a 097d 0a0a 092f 2f20 6973 5f62 se;..}...// is_b │ │ │ +000500a0: 6c6f 636b 6564 2829 206d 6172 6b65 6420 locked() marked │ │ │ +000500b0: 6a20 696e 5f70 726f 6772 6573 7320 616e j in_progress an │ │ │ +000500c0: 6420 636f 756e 7465 6420 6974 2061 7320 d counted it as │ │ │ +000500d0: 6f75 7473 7461 6e64 696e 672e 0a09 626f outstanding...bo │ │ │ +000500e0: 6f6c 2063 6f6e 7374 2065 7863 6565 6465 ol const exceede │ │ │ +000500f0: 6420 3d20 6164 645f 7772 6974 655f 746f d = add_write_to │ │ │ +00050100: 5f63 6163 6865 286a 2c20 7374 643a 3a6d _cache(j, std::m │ │ │ +00050110: 6f76 6528 6f29 293b 0a09 7363 6865 6475 ove(o));..schedu │ │ │ +00050120: 6c65 5f66 6c75 7368 2829 3b0a 0972 6574 le_flush();..ret │ │ │ +00050130: 7572 6e20 6578 6365 6564 6564 3b0a 7d0a urn exceeded;.}. │ │ │ +00050140: 0a61 7578 3a3a 696e 7365 7274 5f72 6573 .aux::insert_res │ │ │ +00050150: 756c 745f 666c 6167 7320 7072 6561 645f ult_flags pread_ │ │ │ +00050160: 6469 736b 5f69 6f3a 3a69 6e73 6572 745f disk_io::insert_ │ │ │ +00050170: 7772 6974 6528 0a09 6175 783a 3a70 7265 write(..aux::pre │ │ │ +00050180: 6164 5f64 6973 6b5f 6a6f 622a 206a 2c20 ad_disk_job* j, │ │ │ +00050190: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +000501a0: 6c74 3b64 6973 6b5f 6f62 7365 7276 6572 lt;disk_observer │ │ │ +000501b0: 2667 743b 206f 290a 7b0a 0961 7574 6f20 > o).{..auto │ │ │ +000501c0: 636f 6e73 7426 616d 703b 2061 203d 2073 const& a = s │ │ │ +000501d0: 7464 3a3a 6765 7426 6c74 3b61 7578 3a3a td::get<aux:: │ │ │ +000501e0: 6a6f 623a 3a77 7269 7465 2667 743b 286a job::write>(j │ │ │ +000501f0: 2d26 6774 3b61 6374 696f 6e29 3b0a 0970 ->action);..p │ │ │ +00050200: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e iece_index_t con │ │ │ +00050210: 7374 2070 6965 6365 203d 2061 2e70 6965 st piece = a.pie │ │ │ +00050220: 6365 3b0a 0969 6e74 2063 6f6e 7374 206f ce;..int const o │ │ │ +00050230: 6666 7365 7420 3d20 612e 6f66 6673 6574 ffset = a.offset │ │ │ +00050240: 3b0a 0a09 444c 4f47 2822 6173 796e 635f ;...DLOG("async_ │ │ │ +00050250: 7772 6974 653a 2070 6965 6365 3a20 2564 write: piece: %d │ │ │ +00050260: 206f 6666 7365 743a 2025 6420 666c 6167 offset: %d flag │ │ │ +00050270: 733a 2025 785c 6e22 2c0a 0909 696e 7428 s: %x\n",...int( │ │ │ +00050280: 7069 6563 6529 2c0a 0909 696e 7428 6f66 piece),...int(of │ │ │ +00050290: 6673 6574 292c 0a09 0973 7461 7469 635f fset),...static_ │ │ │ +000502a0: 6361 7374 266c 743b 7374 643a 3a75 696e cast<std::uin │ │ │ +000502b0: 7438 5f74 2667 743b 286a 2d26 6774 3b66 t8_t>(j->f │ │ │ +000502c0: 6c61 6773 2929 3b0a 0962 6f6f 6c20 636f lags));..bool co │ │ │ +000502d0: 6e73 7420 666f 7263 655f 666c 7573 6820 nst force_flush │ │ │ +000502e0: 3d20 626f 6f6c 286a 2d26 6774 3b66 6c61 = bool(j->fla │ │ │ +000502f0: 6773 2026 616d 703b 2066 6c75 7368 5f70 gs & flush_p │ │ │ +00050300: 6965 6365 293b 0a09 6669 6c65 5f73 746f iece);..file_sto │ │ │ +00050310: 7261 6765 2063 6f6e 7374 2661 6d70 3b20 rage const& │ │ │ +00050320: 6673 203d 206a 2d26 6774 3b73 746f 7261 fs = j->stora │ │ │ +00050330: 6765 2d26 6774 3b66 696c 6573 2829 3b0a ge->files();. │ │ │ +00050340: 092f 2f20 696e 206f 7264 6572 2074 6f20 .// in order to │ │ │ +00050350: 636f 6d70 7574 6520 7631 2068 6173 6865 compute v1 hashe │ │ │ +00050360: 732c 2077 6520 6e65 6564 2074 6865 2066 s, we need the f │ │ │ +00050370: 756c 6c20 7069 6563 652c 2069 6e63 6c75 ull piece, inclu │ │ │ +00050380: 6469 6e67 2070 6164 0a09 2f2f 2066 696c ding pad..// fil │ │ │ +00050390: 6573 2e20 4576 656e 2074 686f 7567 6820 es. Even though │ │ │ +000503a0: 7632 2074 6f72 7265 6e74 7320 6775 6172 v2 torrents guar │ │ │ +000503b0: 616e 7465 6520 7468 6174 2074 6865 7920 antee that they │ │ │ +000503c0: 6172 6520 7a65 726f 2e0a 0969 6e74 2063 are zero...int c │ │ │ +000503d0: 6f6e 7374 2070 6965 6365 5f73 697a 6520 onst piece_size │ │ │ +000503e0: 3d20 6a2d 2667 743b 7374 6f72 6167 652d = j->storage- │ │ │ +000503f0: 2667 743b 7631 2829 203f 2066 732e 7069 >v1() ? fs.pi │ │ │ +00050400: 6563 655f 7369 7a65 2870 6965 6365 2920 ece_size(piece) │ │ │ +00050410: 3a20 6673 2e70 6965 6365 5f73 697a 6532 : fs.piece_size2 │ │ │ +00050420: 2870 6965 6365 293b 0a09 544f 5252 454e (piece);..TORREN │ │ │ +00050430: 545f 4153 5345 5254 2861 2e62 7566 6665 T_ASSERT(a.buffe │ │ │ +00050440: 725f 7369 7a65 203d 3d20 7374 643a 3a6d r_size == std::m │ │ │ +00050450: 696e 2870 6965 6365 5f73 697a 6520 2d20 in(piece_size - │ │ │ +00050460: 6f66 6673 6574 2c20 6465 6661 756c 745f offset, default_ │ │ │ +00050470: 626c 6f63 6b5f 7369 7a65 2929 3b0a 0961 block_size));..a │ │ │ +00050480: 7578 3a3a 6469 736b 5f63 6163 6865 3a3a ux::disk_cache:: │ │ │ +00050490: 7069 6563 655f 656e 7472 795f 7061 7261 piece_entry_para │ │ │ +000504a0: 6d73 2063 6f6e 7374 2070 6965 6365 5f70 ms const piece_p │ │ │ +000504b0: 6172 616d 737b 0a09 0966 732e 7069 6563 arams{...fs.piec │ │ │ +000504c0: 655f 7369 7a65 3228 7069 6563 6529 2c20 e_size2(piece), │ │ │ +000504d0: 7069 6563 655f 7369 7a65 2c20 6a2d 2667 piece_size, j-&g │ │ │ +000504e0: 743b 7374 6f72 6167 652d 2667 743b 7631 t;storage->v1 │ │ │ +000504f0: 2829 2c20 6a2d 2667 743b 7374 6f72 6167 (), j->storag │ │ │ +00050500: 652d 2667 743b 7632 2829 2c20 6a2d 2667 e->v2(), j-&g │ │ │ +00050510: 743b 7374 6f72 6167 657d 3b0a 0972 6574 t;storage};..ret │ │ │ +00050520: 7572 6e20 6d5f 6361 6368 652e 696e 7365 urn m_cache.inse │ │ │ +00050530: 7274 287b 6a2d 2667 743b 7374 6f72 6167 rt({j->storag │ │ │ +00050540: 652d 2667 743b 7374 6f72 6167 655f 696e e->storage_in │ │ │ +00050550: 6465 7828 292c 2070 6965 6365 7d2c 0a3c dex(), piece},.< │ │ │ +00050560: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00050570: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00050580: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00050590: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000505a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +000505d0: 2f70 7265 6164 5f64 6973 6b5f 696f 2e63 /pread_disk_io.c │ │ │ +000505e0: 7070 3a39 3336 3c2f 613e 3c2f 7464 3e3c pp:936< │ │ │ +000505f0: 7464 3e77 6520 6d61 7920 6e6f 7420 6e65 td>we may not ne │ │ │ +00050600: 6564 2074 6f20 646f 2074 6869 732c 2074 ed to do this, t │ │ │ +00050610: 6865 2063 6163 6865 2063 6f75 6c64 2074 he cache could t │ │ │ +00050620: 656c 6c20 7573 2074 6869 7320 7069 6563 ell us this piec │ │ │ +00050630: 6520 7368 6f75 6c64 2062 6520 666c 7573 e should be flus │ │ │ +00050640: 6865 6420 746f 2064 6973 6b20 6e6f 772e hed to disk now. │ │ │ +00050650: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    we │ │ │ +000506a0: 206d 6179 206e 6f74 206e 6565 6420 746f may not need to │ │ │ +000506b0: 2064 6f20 7468 6973 2c20 7468 6520 6361 do this, the ca │ │ │ +000506c0: 6368 6520 636f 756c 6420 7465 6c6c 2075 che could tell u │ │ │ +000506d0: 730a 7468 6973 2070 6965 6365 2073 686f s.this piece sho │ │ │ +000506e0: 756c 6420 6265 2066 6c75 7368 6564 2074 uld be flushed t │ │ │ +000506f0: 6f20 6469 736b 206e 6f77 2e3c 2f68 323e o disk now.

    │ │ │ +00050700: 3c68 343e 2e2e 2f73 7263 2f70 7265 6164

    ../src/pread │ │ │ +00050710: 5f64 6973 6b5f 696f 2e63 7070 3a39 3336 _disk_io.cpp:936 │ │ │ +00050720: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00050760: 0909 6669 6c6c 5f70 7265 636f 6d70 7574  ..fill_precomput
    │ │ │ +00050770: 6564 5f76 3228 0a09 0909 0961 2e62 6c6f  ed_v2(.....a.blo
    │ │ │ +00050780: 636b 5f68 6173 6865 732c 206a 2d26 6774  ck_hashes, j->
    │ │ │ +00050790: 3b73 746f 7261 6765 2d26 6774 3b74 616b  ;storage->tak
    │ │ │ +000507a0: 655f 7072 6563 6f6d 7075 7465 645f 7632  e_precomputed_v2
    │ │ │ +000507b0: 2870 6965 6365 292c 2062 6c6f 636b 735f  (piece), blocks_
    │ │ │ +000507c0: 696e 5f70 6965 6365 3229 3b0a 0a09 0909  in_piece2);.....
    │ │ │ +000507d0: 666f 7220 2869 6e74 2069 203d 2030 3b20  for (int i = 0; 
    │ │ │ +000507e0: 6920 266c 743b 2062 6c6f 636b 735f 696e  i < blocks_in
    │ │ │ +000507f0: 5f70 6965 6365 323b 202b 2b69 290a 0909  _piece2; ++i)...
    │ │ │ +00050800: 097b 0a09 0909 0969 6620 2869 2026 6774  .{.....if (i >
    │ │ │ +00050810: 3b3d 2069 6e74 2861 2e62 6c6f 636b 5f68  ;= int(a.block_h
    │ │ │ +00050820: 6173 6865 732e 7369 7a65 2829 2920 7c7c  ashes.size()) ||
    │ │ │ +00050830: 2061 2e62 6c6f 636b 5f68 6173 6865 735b   a.block_hashes[
    │ │ │ +00050840: 695d 2e69 735f 616c 6c5f 7a65 726f 7328  i].is_all_zeros(
    │ │ │ +00050850: 2929 0a09 0909 097b 0a09 0909 0909 6e65  )).....{......ne
    │ │ │ +00050860: 6564 5f64 6973 6b5f 6661 6c6c 6261 636b  ed_disk_fallback
    │ │ │ +00050870: 203d 2074 7275 653b 0a09 0909 0909 6272   = true;......br
    │ │ │ +00050880: 6561 6b3b 0a09 0909 097d 0a09 0909 7d0a  eak;.....}....}.
    │ │ │ +00050890: 0909 7d0a 0a09 0969 6620 286e 6565 645f  ..}....if (need_
    │ │ │ +000508a0: 6469 736b 5f66 616c 6c62 6163 6b29 0a09  disk_fallback)..
    │ │ │ +000508b0: 097b 0a09 0909 444c 4f47 2822 6173 796e  .{....DLOG("asyn
    │ │ │ +000508c0: 635f 6861 7368 3a20 7632 2068 6173 6865  c_hash: v2 hashe
    │ │ │ +000508d0: 7320 696e 636f 6d70 6c65 7465 2c20 6661  s incomplete, fa
    │ │ │ +000508e0: 6c6c 696e 6720 6261 636b 2074 6f20 646f  lling back to do
    │ │ │ +000508f0: 5f6a 6f62 2868 6173 6829 5c6e 2229 3b0a  _job(hash)\n");.
    │ │ │ +00050900: 0909 0961 6464 5f6a 6f62 286a 293b 0a09  ...add_job(j);..
    │ │ │ +00050910: 0909 7265 7475 726e 3b0a 0909 7d0a 0a3c  ..return;...}..<
    │ │ │ +00050920: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +00050930: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00050940: 7769 6474 683d 2231 3030 2522 3e09 096d  width="100%">..m
    │ │ │ +00050950: 5f67 656e 6572 6963 5f74 6872 6561 6473  _generic_threads
    │ │ │ +00050960: 2e69 6e74 6572 7275 7074 2829 3b0a 3c2f  .interrupt();....jobqueue_
    │ │ │ +00050980: 7420 6a6f 6273 3b0a 0909 6a6f 6273 2e70  t jobs;...jobs.p
    │ │ │ +00050990: 7573 685f 6261 636b 286a 293b 0a09 0961  ush_back(j);...a
    │ │ │ +000509a0: 6464 5f63 6f6d 706c 6574 6564 5f6a 6f62  dd_completed_job
    │ │ │ +000509b0: 7328 7374 643a 3a6d 6f76 6528 6a6f 6273  s(std::move(jobs
    │ │ │ +000509c0: 2929 3b0a 0909 7265 7475 726e 3b0a 097d  ));...return;..}
    │ │ │ +000509d0: 0a0a 092f 2f20 496e 2074 6869 7320 6361  ...// In this ca
    │ │ │ +000509e0: 7365 2074 6865 206a 6f62 2068 6173 2062  se the job has b
    │ │ │ +000509f0: 6565 6e20 7175 6575 6564 206f 6e20 7468  een queued on th
    │ │ │ +00050a00: 6520 7069 6563 652c 2061 6e64 2077 696c  e piece, and wil
    │ │ │ +00050a10: 6c20 6265 2070 6f73 7465 640a 092f 2f20  l be posted..// 
    │ │ │ +00050a20: 6f6e 6365 2074 6865 2068 6173 6869 6e67  once the hashing
    │ │ │ +00050a30: 2063 6f6d 706c 6574 6573 0a09 6966 2028   completes..if (
    │ │ │ +00050a40: 7265 7420 3d3d 2061 7578 3a3a 6469 736b  ret == aux::disk
    │ │ │ +00050a50: 5f63 6163 6865 3a3a 6a6f 625f 7175 6575  _cache::job_queu
    │ │ │ +00050a60: 6564 290a 0909 7265 7475 726e 3b0a 0a09  ed)...return;...
    │ │ │ +00050a70: 6164 645f 6a6f 6228 6a29 3b0a 7d0a 0a76  add_job(j);.}..v
    │ │ │ +00050a80: 6f69 6420 7072 6561 645f 6469 736b 5f69  oid pread_disk_i
    │ │ │ +00050a90: 6f3a 3a61 7379 6e63 5f68 6173 6832 2873  o::async_hash2(s
    │ │ │ +00050aa0: 746f 7261 6765 5f69 6e64 6578 5f74 2063  torage_index_t c
    │ │ │ +00050ab0: 6f6e 7374 2073 746f 7261 6765 0a09 2c20  onst storage.., 
    │ │ │ +00050ac0: 7069 6563 655f 696e 6465 785f 7420 636f  piece_index_t co
    │ │ │ +00050ad0: 6e73 7420 7069 6563 652c 2069 6e74 2063  nst piece, int c
    │ │ │ +00050ae0: 6f6e 7374 206f 6666 7365 742c 2064 6973  onst offset, dis
    │ │ │ +00050af0: 6b5f 6a6f 625f 666c 6167 735f 7420 636f  k_job_flags_t co
    │ │ │ +00050b00: 6e73 7420 666c 6167 730a 092c 2073 7464  nst flags.., std
    │ │ │ +00050b10: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f  ::function<vo
    │ │ │ +00050b20: 6964 2870 6965 6365 5f69 6e64 6578 5f74  id(piece_index_t
    │ │ │ +00050b30: 2c20 7368 6132 3536 5f68 6173 6820 636f  , sha256_hash co
    │ │ │ +00050b40: 6e73 7426 616d 703b 2c20 7374 6f72 6167  nst&, storag
    │ │ │ +00050b50: 655f 6572 726f 7220 636f 6e73 7426 616d  e_error const&am
    │ │ │ +00050b60: 703b 2926 6774 3b20 6861 6e64 6c65 7229  p;)> handler)
    │ │ │ +00050b70: 0a7b 0a09 544f 5252 454e 545f 4153 5345  .{..TORRENT_ASSE
    │ │ │ +00050b80: 5254 2876 616c 6964 5f66 6c61 6773 2866  RT(valid_flags(f
    │ │ │ +00050b90: 6c61 6773 2929 3b0a 0961 7578 3a3a 7072  lags));..aux::pr
    │ │ │ +00050ba0: 6561 645f 6469 736b 5f6a 6f62 2a20 6a20  ead_disk_job* j 
    │ │ │ +00050bb0: 3d20 6d5f 6a6f 625f 706f 6f6c 2e61 6c6c  = m_job_pool.all
    │ │ │ +00050bc0: 6f63 6174 655f 6a6f 6226 6c74 3b61 7578  ocate_job<aux
    │ │ │ +00050bd0: 3a3a 6a6f 623a 3a68 6173 6832 2667 743b  ::job::hash2>
    │ │ │ +00050be0: 280a 0909 666c 6167 732c 0a09 096d 5f74  (...flags,...m_t
    │ │ │ +00050bf0: 6f72 7265 6e74 735b 7374 6f72 6167 655d  orrents[storage]
    │ │ │ +00050c00: 2d26 6774 3b73 6861 7265 645f 6672 6f6d  ->shared_from
    │ │ │ +00050c10: 5f74 6869 7328 292c 0a09 0973 7464 3a3a  _this(),...std::
    │ │ │ +00050c20: 6d6f 7665 2868 616e 646c 6572 292c 0a09  move(handler),..
    │ │ │ +00050c30: 0970 6965 6365 2c0a 0909 6f66 6673 6574  .piece,...offset
    │ │ │ +00050c40: 2c0a 0909 7368 6132 3536 5f68 6173 687b  ,...sha256_hash{
    │ │ │ +00050c50: 7d0a 0929 3b0a 0a09 2f2f 2049 6e20 7468  }..);...// In th
    │ │ │ +00050c60: 656f 7279 2c20 7765 2063 6f75 6c64 2063  eory, we could c
    │ │ │ +00050c70: 6865 636b 2074 6865 2063 6163 6865 2066  heck the cache f
    │ │ │ +00050c80: 6f72 2074 6869 7320 626c 6f63 6b20 6861  or this block ha
    │ │ │ +00050c90: 7368 2c20 6275 7420 7765 0a3c 2f70 7265  sh, but we.
    rele │ │ │ +00050cd0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pre │ │ │ +00050d10: 6164 5f64 6973 6b5f 696f 2e63 7070 3a31 ad_disk_io.cpp:1 │ │ │ +00050d20: 3432 303c 2f61 3e3c 2f74 643e 3c74 643e 420 │ │ │ +00050d30: 6d61 7962 6520 7765 2064 6f6e 2774 206e maybe we don't n │ │ │ +00050d40: 6565 6420 746f 2077 7269 7465 2074 6f20 eed to write to │ │ │ +00050d50: 6669 6c65 7320 7765 2772 6520 6162 6f75 files we're abou │ │ │ +00050d60: 7420 746f 2064 656c 6574 653c 2f74 643e t to delete │ │ │ +00050d70: 3c2f 7472 3e3c 7472 2069 643d 2231 3931

    maybe w │ │ │ +00050dc0: 6520 646f 6e27 7420 6e65 6564 2074 6f20 e don't need to │ │ │ +00050dd0: 7772 6974 6520 746f 2066 696c 6573 2077 write to files w │ │ │ +00050de0: 6527 7265 2061 626f 7574 2074 6f20 6465 e're about to de │ │ │ +00050df0: 6c65 7465 3c2f 6832 3e3c 6834 3e2e 2e2f lete

    ../ │ │ │ +00050e00: 7372 632f 7072 6561 645f 6469 736b 5f69 src/pread_disk_i │ │ │ +00050e10: 6f2e 6370 703a 3134 3230 3c2f 6834 3e3c o.cpp:1420

    < │ │ │ +00050e20: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00050e30: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00050e40: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00050e50: 7820 2364 6464 3b22 3e09 612e 7061 7468 x #ddd;">.a.path │ │ │ +00050e60: 203d 2073 7464 3a3a 6d6f 7665 2870 293b = std::move(p); │ │ │ +00050e70: 0a09 7265 7475 726e 2072 6574 3b0a 7d0a ..return ret;.}. │ │ │ +00050e80: 0a73 7461 7475 735f 7420 7072 6561 645f .status_t pread_ │ │ │ +00050e90: 6469 736b 5f69 6f3a 3a64 6f5f 6a6f 6228 disk_io::do_job( │ │ │ +00050ea0: 6175 783a 3a6a 6f62 3a3a 7265 6c65 6173 aux::job::releas │ │ │ +00050eb0: 655f 6669 6c65 7326 616d 703b 2c20 6175 e_files&, au │ │ │ +00050ec0: 783a 3a70 7265 6164 5f64 6973 6b5f 6a6f x::pread_disk_jo │ │ │ +00050ed0: 622a 206a 290a 7b0a 092f 2f20 6966 2074 b* j).{..// if t │ │ │ +00050ee0: 6869 7320 6173 7365 7274 2066 6169 6c73 his assert fails │ │ │ +00050ef0: 2c20 736f 6d65 7468 696e 6727 7320 7772 , something's wr │ │ │ +00050f00: 6f6e 6720 7769 7468 2074 6865 2066 656e ong with the fen │ │ │ +00050f10: 6365 206c 6f67 6963 0a09 544f 5252 454e ce logic..TORREN │ │ │ +00050f20: 545f 4153 5345 5254 286a 2d26 6774 3b73 T_ASSERT(j->s │ │ │ +00050f30: 746f 7261 6765 2d26 6774 3b6e 756d 5f6f torage->num_o │ │ │ +00050f40: 7574 7374 616e 6469 6e67 5f6a 6f62 7328 utstanding_jobs( │ │ │ +00050f50: 2920 3d3d 2031 293b 0a09 666c 7573 685f ) == 1);..flush_ │ │ │ +00050f60: 7374 6f72 6167 6528 6a2d 2667 743b 7374 storage(j->st │ │ │ +00050f70: 6f72 6167 6529 3b0a 096a 2d26 6774 3b73 orage);..j->s │ │ │ +00050f80: 746f 7261 6765 2d26 6774 3b72 656c 6561 torage->relea │ │ │ +00050f90: 7365 5f66 696c 6573 286a 2d26 6774 3b65 se_files(j->e │ │ │ +00050fa0: 7272 6f72 293b 0a09 7265 7475 726e 206a rror);..return j │ │ │ +00050fb0: 2d26 6774 3b65 7272 6f72 203f 2064 6973 ->error ? dis │ │ │ +00050fc0: 6b5f 7374 6174 7573 3a3a 6661 7461 6c5f k_status::fatal_ │ │ │ +00050fd0: 6469 736b 5f65 7272 6f72 203a 2073 7461 disk_error : sta │ │ │ +00050fe0: 7475 735f 747b 7d3b 0a7d 0a0a 7374 6174 tus_t{};.}..stat │ │ │ +00050ff0: 7573 5f74 2070 7265 6164 5f64 6973 6b5f us_t pread_disk_ │ │ │ +00051000: 696f 3a3a 646f 5f6a 6f62 2861 7578 3a3a io::do_job(aux:: │ │ │ +00051010: 6a6f 623a 3a64 656c 6574 655f 6669 6c65 job::delete_file │ │ │ +00051020: 7326 616d 703b 2061 2c20 6175 783a 3a70 s& a, aux::p │ │ │ +00051030: 7265 6164 5f64 6973 6b5f 6a6f 622a 206a read_disk_job* j │ │ │ +00051040: 290a 7b0a 0954 4f52 5245 4e54 5f41 5353 ).{..TORRENT_ASS │ │ │ +00051050: 4552 5428 612e 666c 6167 7329 3b0a 0a09 ERT(a.flags);... │ │ │ +00051060: 2f2f 2069 6620 7468 6973 2061 7373 6572 // if this asser │ │ │ +00051070: 7420 6661 696c 732c 2073 6f6d 6574 6869 t fails, somethi │ │ │ +00051080: 6e67 2773 2077 726f 6e67 2077 6974 6820 ng's wrong with │ │ │ +00051090: 7468 6520 6665 6e63 6520 6c6f 6769 630a the fence logic. │ │ │ +000510a0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +000510b0: 6a2d 2667 743b 7374 6f72 6167 652d 2667 j->storage-&g │ │ │ +000510c0: 743b 6e75 6d5f 6f75 7473 7461 6e64 696e t;num_outstandin │ │ │ +000510d0: 675f 6a6f 6273 2829 203d 3d20 3129 3b0a g_jobs() == 1);. │ │ │ +000510e0: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ +00051110: 666c 7573 685f 7374 6f72 6167 6528 6a2d flush_storage(j- │ │ │ +00051120: 2667 743b 7374 6f72 6167 6529 3b0a 3c2f >storage);...j->stor │ │ │ +00051140: 6167 652d 2667 743b 6465 6c65 7465 5f66 age->delete_f │ │ │ +00051150: 696c 6573 2861 2e66 6c61 6773 2c20 6a2d iles(a.flags, j- │ │ │ +00051160: 2667 743b 6572 726f 7229 3b0a 0972 6574 >error);..ret │ │ │ +00051170: 7572 6e20 6a2d 2667 743b 6572 726f 7220 urn j->error │ │ │ +00051180: 3f20 6469 736b 5f73 7461 7475 733a 3a66 ? disk_status::f │ │ │ +00051190: 6174 616c 5f64 6973 6b5f 6572 726f 7220 atal_disk_error │ │ │ +000511a0: 3a20 7374 6174 7573 5f74 7b7d 3b0a 7d0a : status_t{};.}. │ │ │ +000511b0: 0a73 7461 7475 735f 7420 7072 6561 645f .status_t pread_ │ │ │ +000511c0: 6469 736b 5f69 6f3a 3a64 6f5f 6a6f 6228 disk_io::do_job( │ │ │ +000511d0: 6175 783a 3a6a 6f62 3a3a 6368 6563 6b5f aux::job::check_ │ │ │ +000511e0: 6661 7374 7265 7375 6d65 2661 6d70 3b20 fastresume& │ │ │ +000511f0: 612c 2061 7578 3a3a 7072 6561 645f 6469 a, aux::pread_di │ │ │ +00051200: 736b 5f6a 6f62 2a20 6a29 0a7b 0a09 2f2f sk_job* j).{..// │ │ │ +00051210: 2069 6620 7468 6973 2061 7373 6572 7420 if this assert │ │ │ +00051220: 6661 696c 732c 2073 6f6d 6574 6869 6e67 fails, something │ │ │ +00051230: 2773 2077 726f 6e67 2077 6974 6820 7468 's wrong with th │ │ │ +00051240: 6520 6665 6e63 6520 6c6f 6769 630a 0954 e fence logic..T │ │ │ +00051250: 4f52 5245 4e54 5f41 5353 4552 5428 6a2d ORRENT_ASSERT(j- │ │ │ +00051260: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ +00051270: 6e75 6d5f 6f75 7473 7461 6e64 696e 675f num_outstanding_ │ │ │ +00051280: 6a6f 6273 2829 203d 3d20 3129 3b0a 0966 jobs() == 1);..f │ │ │ +00051290: 6c75 7368 5f73 746f 7261 6765 286a 2d26 lush_storage(j-& │ │ │ +000512a0: 6774 3b73 746f 7261 6765 293b 0a09 6164 gt;storage);..ad │ │ │ +000512b0: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +000512c0: 2063 6f6e 7374 2a20 7264 203d 2061 2e72 const* rd = a.r │ │ │ +000512d0: 6573 756d 655f 6461 7461 3b0a 0961 6464 esume_data;..add │ │ │ +000512e0: 5f74 6f72 7265 6e74 5f70 6172 616d 7320 _torrent_params │ │ │ +000512f0: 746d 703b 0a09 6966 2028 7264 203d 3d20 tmp;..if (rd == │ │ │ +00051300: 6e75 6c6c 7074 7229 2072 6420 3d20 2661 nullptr) rd = &a │ │ │ +00051310: 6d70 3b74 6d70 3b0a 0a09 7374 643a 3a75 mp;tmp;...std::u │ │ │ +00051320: 6e69 7175 655f 7074 7226 6c74 3b61 7578 nique_ptr<aux │ │ │ +00051330: 3a3a 7665 6374 6f72 266c 743b 7374 643a ::vector<std: │ │ │ +00051340: 3a73 7472 696e 672c 2066 696c 655f 696e :string, file_in │ │ │ +00051350: 6465 785f 7426 6774 3b26 6774 3b20 6c69 dex_t>> li │ │ │ +00051360: 6e6b 7328 612e 6c69 6e6b 7329 3b0a 092f nks(a.links);../ │ │ │ +00051370: 2f20 6368 6563 6b20 6966 2074 6865 2066 / check if the f │ │ │ +00051380: 6173 7472 6573 756d 6520 6461 7461 2069 astresume data i │ │ │ +00051390: 7320 7570 2074 6f20 6461 7465 0a09 2f2f s up to date..// │ │ │ +000513a0: 2069 6620 6974 2069 732c 2075 7365 2069 if it is, use i │ │ │ +000513b0: 7420 616e 6420 7265 7475 726e 2074 7275 t and return tru │ │ │ +000513c0: 652e 2049 6620 6974 0a09 2f2f 2069 736e e. If it..// isn │ │ │ +000513d0: 2774 2072 6574 7572 6e20 6661 6c73 6520 't return false │ │ │ +000513e0: 616e 6420 7468 6520 6675 6c6c 2063 6865 and the full che │ │ │ +000513f0: 636b 0a09 2f2f 2077 696c 6c20 6265 2072 ck..// will be r │ │ │ +00051400: 756e 2e20 4966 2074 6865 206c 696e 6b73 un. If the links │ │ │ +00051410: 2070 6f69 6e74 6572 2069 7320 6e6f 6e2d pointer is non- │ │ │ +00051420: 656d 7074 792c 2069 7420 6861 7320 7468 empty, it has th │ │ │ +00051430: 6520 7361 6d65 206e 756d 6265 720a 092f e same number../ │ │ │ +00051440: 2f20 6f66 2065 6c65 6d65 6e74 7320 6173 / of elements as │ │ │ +00051450: 2074 6865 7265 2061 7265 2066 696c 6573 there are files │ │ │ +00051460: 2e20 4561 6368 2065 6c65 6d65 6e74 2069 . Each element i │ │ │ +00051470: 7320 6569 7468 6572 2065 6d70 7479 206f s either empty o │ │ │ +00051480: 7220 636f 6e74 6169 6e73 0a09 2f2f 2074 r contains..// t │ │ │ +00051490: 6865 2061 6273 6f6c 7574 6520 7061 7468 he absolute path │ │ │ +000514a0: 2074 6f20 6120 6669 6c65 2069 6465 6e74 to a file ident │ │ │ +000514b0: 6963 616c 2074 6f20 7468 6520 636f 7272 ical to the corr │ │ │ +000514c0: 6573 706f 6e64 696e 6720 6669 6c65 2069 esponding file i │ │ │ +000514d0: 6e20 7468 6973 0a09 2f2f 2074 6f72 7265 n this..// torre │ │ │ +000514e0: 6e74 2e20 5468 6520 7374 6f72 6167 6520 nt. The storage │ │ │ +000514f0: 6d75 7374 2063 7265 6174 6520 6861 7264 must create hard │ │ │ +00051500: 206c 696e 6b73 2028 6f72 2063 6f70 7929 links (or copy) │ │ │ +00051510: 2074 686f 7365 2066 696c 6573 2e20 4966 those files. If │ │ │ +00051520: 0a09 2f2f 2061 6e79 2066 696c 6520 646f ..// any file do │ │ │ +00051530: 6573 206e 6f74 2065 7869 7374 206f 7220 es not exist or │ │ │ +00051540: 6973 2069 6e61 6363 6573 7369 626c 652c is inaccessible, │ │ │ +00051550: 2074 6865 2064 6973 6b20 6a6f 6220 6d75 the disk job mu │ │ │ +00051560: 7374 2066 6169 6c2e 0a0a 0954 4f52 5245 st fail....TORRE │ │ │ +00051570: 4e54 5f41 5353 4552 5428 6a2d 2667 743b NT_ASSERT(j-> │ │ │ +00051580: 7374 6f72 6167 652d 2667 743b 6669 6c65 storage->file │ │ │ +00051590: 7328 292e 7069 6563 655f 6c65 6e67 7468 s().piece_length │ │ │ +000515a0: 2829 2026 6774 3b20 3029 3b0a 0a09 2f2f () > 0);...// │ │ │ +000515b0: 2061 6c77 6179 7320 696e 6974 6961 6c69 always initiali │ │ │ +000515c0: 7a65 2074 6865 2073 746f 7261 6765 0a09 ze the storage.. │ │ │ +000515d0: 6175 746f 2063 6f6e 7374 2072 6574 5f66 auto const ret_f │ │ │ +000515e0: 6c61 6720 3d20 6a2d 2667 743b 7374 6f72 lag = j->stor │ │ │ +000515f0: 6167 652d 2667 743b 696e 6974 6961 6c69 age->initiali │ │ │ +00051600: 7a65 286d 5f73 6574 7469 6e67 732c 206a ze(m_settings, j │ │ │ +00051610: 2d26 6774 3b65 7272 6f72 293b 0a09 6966 ->error);..if │ │ │ +00051620: 2028 6a2d 2667 743b 6572 726f 7229 2072 (j->error) r │ │ │ +00051630: 6574 7572 6e20 6469 736b 5f73 7461 7475 eturn disk_statu │ │ │ +00051640: 733a 3a66 6174 616c 5f64 6973 6b5f 6572 s::fatal_disk_er │ │ │ +00051650: 726f 7220 7c20 7265 745f 666c 6167 3b0a ror | ret_flag;. │ │ │ +00051660: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000516a0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +000516d0: 7263 2f70 6f73 6978 5f70 6172 745f 6669 rc/posix_part_fi │ │ │ +000516e0: 6c65 2e63 7070 3a33 3136 3c2f 613e 3c2f le.cpp:316what do w │ │ │ +00051700: 6520 646f 2069 6620 736f 6d65 6f6e 6520 e do if someone │ │ │ +00051710: 6973 2063 7572 7265 6e74 6c79 2072 6561 is currently rea │ │ │ +00051720: 6469 6e67 2066 726f 6d20 7468 6520 6469 ding from the di │ │ │ +00051730: 736b 2066 726f 6d20 7468 6973 2070 6965 sk from this pie │ │ │ +00051740: 6365 3f20 646f 6573 2069 7420 6d61 7474 ce? does it matt │ │ │ +00051750: 6572 3f20 5369 6e63 6520 7765 2077 6f6e er? Since we won │ │ │ +00051760: 2774 2061 6374 6976 656c 7920 6572 6173 't actively eras │ │ │ +00051770: 6520 7468 6520 6461 7461 2066 726f 6d20 e the data from │ │ │ +00051780: 6469 736b 2c20 6275 7420 6974 206d 6179 disk, but it may │ │ │ +00051790: 2062 6520 6f76 6572 7772 6974 7465 6e20 be overwritten │ │ │ +000517a0: 736f 6f6e 2c20 6974 2773 2070 726f 6261 soon, it's proba │ │ │ +000517b0: 626c 7920 6e6f 7420 7468 6174 2062 6967 bly not that big │ │ │ +000517c0: 206f 6620 6120 6465 616c 3c2f 7464 3e3c of a deal< │ │ │ +000517d0: 2f74 723e 3c74 7220 6964 3d22 3139 3222 /tr>

    what do │ │ │ +00051820: 7765 2064 6f20 6966 2073 6f6d 656f 6e65 we do if someone │ │ │ +00051830: 2069 7320 6375 7272 656e 746c 7920 7265 is currently re │ │ │ +00051840: 6164 696e 6720 6672 6f6d 2074 6865 2064 ading from the d │ │ │ +00051850: 6973 6b0a 6672 6f6d 2074 6869 7320 7069 isk.from this pi │ │ │ +00051860: 6563 653f 2064 6f65 7320 6974 206d 6174 ece? does it mat │ │ │ +00051870: 7465 723f 2053 696e 6365 2077 6520 776f ter? Since we wo │ │ │ +00051880: 6e27 7420 6163 7469 7665 6c79 2065 7261 n't actively era │ │ │ +00051890: 7365 2074 6865 0a64 6174 6120 6672 6f6d se the.data from │ │ │ +000518a0: 2064 6973 6b2c 2062 7574 2069 7420 6d61 disk, but it ma │ │ │ +000518b0: 7920 6265 206f 7665 7277 7269 7474 656e y be overwritten │ │ │ +000518c0: 2073 6f6f 6e2c 2069 7427 7320 7072 6f62 soon, it's prob │ │ │ +000518d0: 6162 6c79 206e 6f74 2074 6861 740a 6269 ably not that.bi │ │ │ +000518e0: 6720 6f66 2061 2064 6561 6c3c 2f68 323e g of a deal

    │ │ │ +000518f0: 3c68 343e 2e2e 2f73 7263 2f70 6f73 6978

    ../src/posix │ │ │ +00051900: 5f70 6172 745f 6669 6c65 2e63 7070 3a33 _part_file.cpp:3 │ │ │ +00051910: 3136 3c2f 6834 3e3c 7072 6520 7374 796c 16

    ....if (ec) ret
    │ │ │ +00051960: 7572 6e20 7b7d 3b0a 0a23 6966 6465 6620  urn {};..#ifdef 
    │ │ │ +00051970: 544f 5252 454e 545f 5749 4e44 4f57 530a  TORRENT_WINDOWS.
    │ │ │ +00051980: 0909 0972 6574 203d 2066 696c 655f 706f  ...ret = file_po
    │ │ │ +00051990: 696e 7465 7228 3a3a 5f77 666f 7065 6e28  inter(::_wfopen(
    │ │ │ +000519a0: 636f 6e76 6572 745f 746f 5f6e 6174 6976  convert_to_nativ
    │ │ │ +000519b0: 655f 7061 7468 5f73 7472 696e 6728 666e  e_path_string(fn
    │ │ │ +000519c0: 292e 635f 7374 7228 292c 204c 2277 622b  ).c_str(), L"wb+
    │ │ │ +000519d0: 2229 293b 0a23 656c 7365 0a09 0909 7265  "));.#else....re
    │ │ │ +000519e0: 7420 3d20 6669 6c65 5f70 6f69 6e74 6572  t = file_pointer
    │ │ │ +000519f0: 283a 3a66 6f70 656e 2866 6e2e 635f 7374  (::fopen(fn.c_st
    │ │ │ +00051a00: 7228 292c 2022 7762 2b22 2929 3b0a 2365  r(), "wb+"));.#e
    │ │ │ +00051a10: 6e64 6966 0a09 0909 6966 2028 7265 742e  ndif....if (ret.
    │ │ │ +00051a20: 6669 6c65 2829 203d 3d20 6e75 6c6c 7074  file() == nullpt
    │ │ │ +00051a30: 7229 0a09 0909 0965 632e 6173 7369 676e  r).....ec.assign
    │ │ │ +00051a40: 2865 7272 6e6f 2c20 6765 6e65 7269 635f  (errno, generic_
    │ │ │ +00051a50: 6361 7465 676f 7279 2829 293b 0a09 097d  category());...}
    │ │ │ +00051a60: 0a09 0969 6620 2865 6329 2072 6574 7572  ...if (ec) retur
    │ │ │ +00051a70: 6e20 7b7d 3b0a 0909 7265 7475 726e 2072  n {};...return r
    │ │ │ +00051a80: 6574 3b0a 097d 0a0a 0976 6f69 6420 706f  et;..}...void po
    │ │ │ +00051a90: 7369 785f 7061 7274 5f66 696c 653a 3a66  six_part_file::f
    │ │ │ +00051aa0: 7265 655f 7069 6563 6528 7069 6563 655f  ree_piece(piece_
    │ │ │ +00051ab0: 696e 6465 785f 7420 636f 6e73 7420 7069  index_t const pi
    │ │ │ +00051ac0: 6563 6529 0a09 7b0a 0909 6175 746f 2063  ece)..{...auto c
    │ │ │ +00051ad0: 6f6e 7374 2069 203d 206d 5f70 6965 6365  onst i = m_piece
    │ │ │ +00051ae0: 5f6d 6170 2e66 696e 6428 7069 6563 6529  _map.find(piece)
    │ │ │ +00051af0: 3b0a 0909 6966 2028 6920 3d3d 206d 5f70  ;...if (i == m_p
    │ │ │ +00051b00: 6965 6365 5f6d 6170 2e65 6e64 2829 2920  iece_map.end()) 
    │ │ │ +00051b10: 7265 7475 726e 3b0a 0a3c 6469 7620 7374  return;..
    .
    .. │ │ │ +00051b50: 6d5f 6672 6565 5f73 6c6f 7473 2e70 7573 m_free_slots.pus │ │ │ +00051b60: 685f 6261 636b 2869 2d26 6774 3b73 6563 h_back(i->sec │ │ │ +00051b70: 6f6e 6429 3b0a 0909 6d5f 7069 6563 655f ond);...m_piece_ │ │ │ +00051b80: 6d61 702e 6572 6173 6528 6929 3b0a 0909 map.erase(i);... │ │ │ +00051b90: 6d5f 6469 7274 795f 6d65 7461 6461 7461 m_dirty_metadata │ │ │ +00051ba0: 203d 2074 7275 653b 0a09 7d0a 0a09 766f = true;..}...vo │ │ │ +00051bb0: 6964 2070 6f73 6978 5f70 6172 745f 6669 id posix_part_fi │ │ │ +00051bc0: 6c65 3a3a 6d6f 7665 5f70 6172 7466 696c le::move_partfil │ │ │ +00051bd0: 6528 7374 643a 3a73 7472 696e 6720 636f e(std::string co │ │ │ +00051be0: 6e73 7426 616d 703b 2070 6174 682c 2065 nst& path, e │ │ │ +00051bf0: 7272 6f72 5f63 6f64 6526 616d 703b 2065 rror_code& e │ │ │ +00051c00: 6329 0a09 7b0a 0909 666c 7573 685f 6d65 c)..{...flush_me │ │ │ +00051c10: 7461 6461 7461 5f69 6d70 6c28 6563 293b tadata_impl(ec); │ │ │ +00051c20: 0a09 0969 6620 2865 6329 2072 6574 7572 ...if (ec) retur │ │ │ +00051c30: 6e3b 0a0a 0909 6966 2028 216d 5f70 6965 n;....if (!m_pie │ │ │ +00051c40: 6365 5f6d 6170 2e65 6d70 7479 2829 290a ce_map.empty()). │ │ │ +00051c50: 0909 7b0a 0909 0973 7464 3a3a 7374 7269 ..{....std::stri │ │ │ +00051c60: 6e67 206f 6c64 5f70 6174 6820 3d20 636f ng old_path = co │ │ │ +00051c70: 6d62 696e 655f 7061 7468 286d 5f70 6174 mbine_path(m_pat │ │ │ +00051c80: 682c 206d 5f6e 616d 6529 3b0a 0909 0973 h, m_name);....s │ │ │ +00051c90: 7464 3a3a 7374 7269 6e67 206e 6577 5f70 td::string new_p │ │ │ +00051ca0: 6174 6820 3d20 636f 6d62 696e 655f 7061 ath = combine_pa │ │ │ +00051cb0: 7468 2870 6174 682c 206d 5f6e 616d 6529 th(path, m_name) │ │ │ +00051cc0: 3b0a 0a09 0909 7265 6e61 6d65 286f 6c64 ;.....rename(old │ │ │ +00051cd0: 5f70 6174 682c 206e 6577 5f70 6174 682c _path, new_path, │ │ │ +00051ce0: 2065 6329 3b0a 0909 0969 6620 2865 6320 ec);....if (ec │ │ │ +00051cf0: 3d3d 2062 6f6f 7374 3a3a 7379 7374 656d == boost::system │ │ │ +00051d00: 3a3a 6572 7263 3a3a 6e6f 5f73 7563 685f ::errc::no_such_ │ │ │ +00051d10: 6669 6c65 5f6f 725f 6469 7265 6374 6f72 file_or_director │ │ │ +00051d20: 7929 0a09 0909 0965 632e 636c 6561 7228 y).....ec.clear( │ │ │ +00051d30: 293b 0a0a 0909 0969 6620 2865 6329 0a09 );.....if (ec).. │ │ │ +00051d40: 0909 7b0a 0909 0909 7374 6f72 6167 655f ..{.....storage_ │ │ │ +00051d50: 6572 726f 7220 7365 3b0a 0909 0909 6175 error se;.....au │ │ │ +00051d60: 783a 3a63 6f70 795f 6669 6c65 286f 6c64 x::copy_file(old │ │ │ +00051d70: 5f70 6174 682c 206e 6577 5f70 6174 682c _path, new_path, │ │ │ +00051d80: 2073 6529 3b0a 0909 0909 6563 203d 2073 se);.....ec = s │ │ │ +00051d90: 652e 6563 3b0a 0909 0909 6966 2028 6563 e.ec;.....if (ec │ │ │ +00051da0: 2920 7265 7475 726e 3b0a 0909 0909 7265 ) return;.....re │ │ │ +00051db0: 6d6f 7665 286f 6c64 5f70 6174 682c 2065 move(old_path, e │ │ │ +00051dc0: 6329 3b0a 0909 097d 0a09 097d 0a09 096d c);....}...}...m │ │ │ +00051dd0: 5f70 6174 6820 3d20 7061 7468 3b0a 097d _path = path;..} │ │ │ +00051de0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00051e20: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00051e50: 7263 2f70 6f73 6978 5f70 6172 745f 6669 rc/posix_part_fi │ │ │ +00051e60: 6c65 2e63 7070 3a34 3038 3c2f 613e 3c2f le.cpp:408instead o │ │ │ +00051e80: 6620 7265 6275 696c 6469 6e67 2074 6865 f rebuilding the │ │ │ +00051e90: 2077 686f 6c65 2066 696c 6520 6865 6164 whole file head │ │ │ +00051ea0: 6572 2061 6e64 2066 6c75 7368 696e 6720 er and flushing │ │ │ +00051eb0: 6974 2c20 7570 6461 7465 2074 6865 2073 it, update the s │ │ │ +00051ec0: 6c6f 7420 656e 7472 6965 7320 6173 2077 lot entries as w │ │ │ +00051ed0: 6520 676f 3c2f 7464 3e3c 2f74 723e 3c74 e goinstead of reb │ │ │ +00051f30: 7569 6c64 696e 6720 7468 6520 7768 6f6c uilding the whol │ │ │ +00051f40: 6520 6669 6c65 2068 6561 6465 720a 616e e file header.an │ │ │ +00051f50: 6420 666c 7573 6869 6e67 2069 742c 2075 d flushing it, u │ │ │ +00051f60: 7064 6174 6520 7468 6520 736c 6f74 2065 pdate the slot e │ │ │ +00051f70: 6e74 7269 6573 2061 7320 7765 2067 6f3c ntries as we go< │ │ │ +00051f80: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00051f90: 6f73 6978 5f70 6172 745f 6669 6c65 2e63 osix_part_file.c │ │ │ +00051fa0: 7070 3a34 3038 3c2f 6834 3e3c 7072 6520 pp:408

    ......ec.as
    │ │ │ +00051ff0: 7369 676e 2865 7272 6e6f 2c20 6765 6e65  sign(errno, gene
    │ │ │ +00052000: 7269 635f 6361 7465 676f 7279 2829 293b  ric_category());
    │ │ │ +00052010: 0a09 0909 0909 656c 7365 0a09 0909 0909  ......else......
    │ │ │ +00052020: 0965 632e 6173 7369 676e 2865 7272 6f72  .ec.assign(error
    │ │ │ +00052030: 733a 3a66 696c 655f 746f 6f5f 7368 6f72  s::file_too_shor
    │ │ │ +00052040: 742c 206c 6962 746f 7272 656e 745f 6361  t, libtorrent_ca
    │ │ │ +00052050: 7465 676f 7279 2829 293b 0a09 0909 097d  tegory());.....}
    │ │ │ +00052060: 0a0a 0909 0909 6966 2028 6563 2920 7265  ......if (ec) re
    │ │ │ +00052070: 7475 726e 3b0a 0a09 0909 0966 2866 696c  turn;......f(fil
    │ │ │ +00052080: 655f 6f66 6673 6574 2c20 7b62 7566 2e67  e_offset, {buf.g
    │ │ │ +00052090: 6574 2829 2c20 626c 6f63 6b5f 746f 5f63  et(), block_to_c
    │ │ │ +000520a0: 6f70 797d 293b 0a09 0909 7d0a 0909 0966  opy});....}....f
    │ │ │ +000520b0: 696c 655f 6f66 6673 6574 202b 3d20 626c  ile_offset += bl
    │ │ │ +000520c0: 6f63 6b5f 746f 5f63 6f70 793b 0a09 0909  ock_to_copy;....
    │ │ │ +000520d0: 7069 6563 655f 6f66 6673 6574 203d 2030  piece_offset = 0
    │ │ │ +000520e0: 3b0a 0909 0973 697a 6520 2d3d 2062 6c6f  ;....size -= blo
    │ │ │ +000520f0: 636b 5f74 6f5f 636f 7079 3b0a 0909 7d0a  ck_to_copy;...}.
    │ │ │ +00052100: 097d 0a0a 0976 6f69 6420 706f 7369 785f  .}...void posix_
    │ │ │ +00052110: 7061 7274 5f66 696c 653a 3a66 6c75 7368  part_file::flush
    │ │ │ +00052120: 5f6d 6574 6164 6174 6128 6572 726f 725f  _metadata(error_
    │ │ │ +00052130: 636f 6465 2661 6d70 3b20 6563 290a 097b  code& ec)..{
    │ │ │ +00052140: 0a09 0966 6c75 7368 5f6d 6574 6164 6174  ...flush_metadat
    │ │ │ +00052150: 615f 696d 706c 2865 6329 3b0a 097d 0a0a  a_impl(ec);..}..
    │ │ │ +00052160: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .v │ │ │ +00052190: 6f69 6420 706f 7369 785f 7061 7274 5f66 oid posix_part_f │ │ │ +000521a0: 696c 653a 3a66 6c75 7368 5f6d 6574 6164 ile::flush_metad │ │ │ +000521b0: 6174 615f 696d 706c 2865 7272 6f72 5f63 ata_impl(error_c │ │ │ +000521c0: 6f64 6526 616d 703b 2065 6329 0a3c 2f64 ode& ec)..{...// do we │ │ │ +000521e0: 206e 6565 6420 746f 2066 6c75 7368 2074 need to flush t │ │ │ +000521f0: 6865 206d 6574 6164 6174 613f 0a09 0969 he metadata?...i │ │ │ +00052200: 6620 286d 5f64 6972 7479 5f6d 6574 6164 f (m_dirty_metad │ │ │ +00052210: 6174 6120 3d3d 2066 616c 7365 2920 7265 ata == false) re │ │ │ +00052220: 7475 726e 3b0a 0a09 0969 6620 286d 5f70 turn;....if (m_p │ │ │ +00052230: 6965 6365 5f6d 6170 2e65 6d70 7479 2829 iece_map.empty() │ │ │ +00052240: 290a 0909 7b0a 0909 092f 2f20 6966 2077 )...{....// if w │ │ │ +00052250: 6520 646f 6e27 7420 6861 7665 2061 6e79 e don't have any │ │ │ +00052260: 2070 6965 6365 7320 6c65 6674 2069 6e20 pieces left in │ │ │ +00052270: 7468 650a 0909 092f 2f20 7061 7274 2066 the....// part f │ │ │ +00052280: 696c 652c 2072 656d 6f76 6520 6974 0a09 ile, remove it.. │ │ │ +00052290: 0909 7374 643a 3a73 7472 696e 6720 636f ..std::string co │ │ │ +000522a0: 6e73 7420 7020 3d20 636f 6d62 696e 655f nst p = combine_ │ │ │ +000522b0: 7061 7468 286d 5f70 6174 682c 206d 5f6e path(m_path, m_n │ │ │ +000522c0: 616d 6529 3b0a 0909 0972 656d 6f76 6528 ame);....remove( │ │ │ +000522d0: 702c 2065 6329 3b0a 0a09 0909 6966 2028 p, ec);.....if ( │ │ │ +000522e0: 6563 203d 3d20 626f 6f73 743a 3a73 7973 ec == boost::sys │ │ │ +000522f0: 7465 6d3a 3a65 7272 633a 3a6e 6f5f 7375 tem::errc::no_su │ │ │ +00052300: 6368 5f66 696c 655f 6f72 5f64 6972 6563 ch_file_or_direc │ │ │ +00052310: 746f 7279 290a 0909 0909 6563 2e63 6c65 tory).....ec.cle │ │ │ +00052320: 6172 2829 3b0a 0909 0972 6574 7572 6e3b ar();....return; │ │ │ +00052330: 0a09 097d 0a0a 0909 6175 746f 2066 203d ...}....auto f = │ │ │ +00052340: 206f 7065 6e5f 6669 6c65 286f 7065 6e5f open_file(open_ │ │ │ +00052350: 6d6f 6465 3a3a 7265 6164 5f77 7269 7465 mode::read_write │ │ │ +00052360: 2c20 6563 293b 0a09 0969 6620 2865 6329 , ec);...if (ec) │ │ │ +00052370: 2072 6574 7572 6e3b 0a0a 0909 7374 643a return;....std: │ │ │ +00052380: 3a76 6563 746f 7226 6c74 3b63 6861 7226 :vector<char& │ │ │ +00052390: 6774 3b20 6865 6164 6572 2873 7461 7469 gt; header(stati │ │ │ +000523a0: 635f 6361 7374 266c 743b 7374 643a 3a73 c_cast<std::s │ │ │ +000523b0: 697a 655f 7426 6774 3b28 6d5f 6865 6164 ize_t>(m_head │ │ │ +000523c0: 6572 5f73 697a 6529 293b 0a0a 0909 7573 er_size));....us │ │ │ +000523d0: 696e 6720 6e61 6d65 7370 6163 6520 6c69 ing namespace li │ │ │ +000523e0: 6274 6f72 7265 6e74 3a3a 6175 783b 0a0a btorrent::aux;.. │ │ │ +000523f0: 0909 6368 6172 2a20 7074 7220 3d20 6865 ..char* ptr = he │ │ │ +00052400: 6164 6572 2e64 6174 6128 293b 0a09 0977 ader.data();...w │ │ │ +00052410: 7269 7465 5f75 696e 7433 3228 6d5f 6d61 rite_uint32(m_ma │ │ │ +00052420: 785f 7069 6563 6573 2c20 7074 7229 3b0a x_pieces, ptr);. │ │ │ +00052430: 0909 7772 6974 655f 7569 6e74 3332 286d ..write_uint32(m │ │ │ +00052440: 5f70 6965 6365 5f73 697a 652c 2070 7472 _piece_size, ptr │ │ │ +00052450: 293b 0a0a 0909 666f 7220 2870 6965 6365 );....for (piece │ │ │ +00052460: 5f69 6e64 6578 5f74 2070 6965 6365 2830 _index_t piece(0 │ │ │ +00052470: 293b 2070 6965 6365 2026 6c74 3b20 7069 ); piece < pi │ │ │ +00052480: 6563 655f 696e 6465 785f 7428 6d5f 6d61 ece_index_t(m_ma │ │ │ +00052490: 785f 7069 6563 6573 293b 202b 2b70 6965 x_pieces); ++pie │ │ │ +000524a0: 6365 290a 0909 7b0a 0909 0961 7574 6f20 ce)...{....auto │ │ │ +000524b0: 636f 6e73 7420 6920 3d20 6d5f 7069 6563 const i = m_piec │ │ │ +000524c0: 655f 6d61 702e 6669 6e64 2870 6965 6365 e_map.find(piece │ │ │ +000524d0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +00052500: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00052510: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00052540: 2f73 7263 2f74 6f72 7265 6e74 5f70 6565 /src/torrent_pee │ │ │ +00052550: 722e 6370 703a 3136 373c 2f61 3e3c 2f74 r.cpp:167
    how do we │ │ │ +00052570: 6465 616c 2077 6974 6820 6f75 7220 6578 deal with our ex │ │ │ +00052580: 7465 726e 616c 2061 6464 7265 7373 2063 ternal address c │ │ │ +00052590: 6861 6e67 696e 673f 3c2f 7464 3e3c 2f74 hanging?

    how do we │ │ │ +000525f0: 6465 616c 2077 6974 6820 6f75 7220 6578 deal with our ex │ │ │ +00052600: 7465 726e 616c 2061 6464 7265 7373 2063 ternal address c │ │ │ +00052610: 6861 6e67 696e 673f 3c2f 6832 3e3c 6834 hanging?

    ../src/torrent_ │ │ │ +00052630: 7065 6572 2e63 7070 3a31 3637 3c2f 6834 peer.cpp:167

    #endi
    │ │ │ +00052680: 660a 0909 2c20 6973 5f76 365f 6164 6472  f..., is_v6_addr
    │ │ │ +00052690: 2866 616c 7365 290a 2369 6620 544f 5252  (false).#if TORR
    │ │ │ +000526a0: 454e 545f 5553 455f 4932 500a 0909 2c20  ENT_USE_I2P..., 
    │ │ │ +000526b0: 6973 5f69 3270 5f61 6464 7228 6661 6c73  is_i2p_addr(fals
    │ │ │ +000526c0: 6529 0a23 656e 6469 660a 2369 6620 544f  e).#endif.#if TO
    │ │ │ +000526d0: 5252 454e 545f 5553 455f 5254 430a 0909  RRENT_USE_RTC...
    │ │ │ +000526e0: 2c20 6973 5f72 7463 5f61 6464 7228 6661  , is_rtc_addr(fa
    │ │ │ +000526f0: 6c73 6529 0a23 656e 6469 660a 0909 2c20  lse).#endif..., 
    │ │ │ +00052700: 6f6e 5f70 6172 6f6c 6528 6661 6c73 6529  on_parole(false)
    │ │ │ +00052710: 0a09 092c 2062 616e 6e65 6428 6661 6c73  ..., banned(fals
    │ │ │ +00052720: 6529 0a09 092c 2073 7570 706f 7274 735f  e)..., supports_
    │ │ │ +00052730: 7574 7028 7472 7565 2920 2f2f 2061 7373  utp(true) // ass
    │ │ │ +00052740: 756d 6520 7065 6572 7320 7375 7070 6f72  ume peers suppor
    │ │ │ +00052750: 7420 7574 700a 0909 2c20 636f 6e66 6972  t utp..., confir
    │ │ │ +00052760: 6d65 645f 7375 7070 6f72 7473 5f75 7470  med_supports_utp
    │ │ │ +00052770: 2866 616c 7365 290a 0909 2c20 7375 7070  (false)..., supp
    │ │ │ +00052780: 6f72 7473 5f68 6f6c 6570 756e 6368 2866  orts_holepunch(f
    │ │ │ +00052790: 616c 7365 290a 0909 2c20 7765 625f 7365  alse)..., web_se
    │ │ │ +000527a0: 6564 2866 616c 7365 290a 0909 2c20 7072  ed(false)..., pr
    │ │ │ +000527b0: 6f74 6f63 6f6c 5f76 3228 6661 6c73 6529  otocol_v2(false)
    │ │ │ +000527c0: 0a09 7b7d 0a0a 0973 7464 3a3a 7569 6e74  ..{}...std::uint
    │ │ │ +000527d0: 3332 5f74 2074 6f72 7265 6e74 5f70 6565  32_t torrent_pee
    │ │ │ +000527e0: 723a 3a72 616e 6b28 6175 783a 3a65 7874  r::rank(aux::ext
    │ │ │ +000527f0: 6572 6e61 6c5f 6970 2063 6f6e 7374 2661  ernal_ip const&a
    │ │ │ +00052800: 6d70 3b20 6578 7465 726e 616c 2c20 696e  mp; external, in
    │ │ │ +00052810: 7420 6578 7465 726e 616c 5f70 6f72 7429  t external_port)
    │ │ │ +00052820: 2063 6f6e 7374 0a09 7b0a 0909 544f 5252   const..{...TORR
    │ │ │ +00052830: 454e 545f 4153 5345 5254 2869 6e5f 7573  ENT_ASSERT(in_us
    │ │ │ +00052840: 6529 3b0a 3c64 6976 2073 7479 6c65 3d22  e);.
    ..if (peer_ran │ │ │ +00052880: 6b20 3d3d 2030 290a 3c2f 6469 763e 0909 k == 0).
    .. │ │ │ +00052890: 0970 6565 725f 7261 6e6b 203d 2070 6565 .peer_rank = pee │ │ │ +000528a0: 725f 7072 696f 7269 7479 280a 0909 0909 r_priority(..... │ │ │ +000528b0: 7463 703a 3a65 6e64 706f 696e 7428 6578 tcp::endpoint(ex │ │ │ +000528c0: 7465 726e 616c 2e65 7874 6572 6e61 6c5f ternal.external_ │ │ │ +000528d0: 6164 6472 6573 7328 7468 6973 2d26 6774 address(this-> │ │ │ +000528e0: 3b61 6464 7265 7373 2829 292c 2073 7464 ;address()), std │ │ │ +000528f0: 3a3a 7569 6e74 3136 5f74 2865 7874 6572 ::uint16_t(exter │ │ │ +00052900: 6e61 6c5f 706f 7274 2929 0a09 0909 092c nal_port))....., │ │ │ +00052910: 2074 6370 3a3a 656e 6470 6f69 6e74 2874 tcp::endpoint(t │ │ │ +00052920: 6869 732d 2667 743b 6164 6472 6573 7328 his->address( │ │ │ +00052930: 292c 2074 6869 732d 2667 743b 706f 7274 ), this->port │ │ │ +00052940: 2929 3b0a 0909 7265 7475 726e 2070 6565 ));...return pee │ │ │ +00052950: 725f 7261 6e6b 3b0a 097d 0a0a 2369 666e r_rank;..}..#ifn │ │ │ +00052960: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +00052970: 424c 455f 4c4f 4747 494e 470a 0973 7464 BLE_LOGGING..std │ │ │ +00052980: 3a3a 7374 7269 6e67 2074 6f72 7265 6e74 ::string torrent │ │ │ +00052990: 5f70 6565 723a 3a74 6f5f 7374 7269 6e67 _peer::to_string │ │ │ +000529a0: 2829 2063 6f6e 7374 0a09 7b0a 0909 544f () const..{...TO │ │ │ +000529b0: 5252 454e 545f 4153 5345 5254 2869 6e5f RRENT_ASSERT(in_ │ │ │ +000529c0: 7573 6529 3b0a 2369 6620 544f 5252 454e use);.#if TORREN │ │ │ +000529d0: 545f 5553 455f 4932 500a 0909 6966 2028 T_USE_I2P...if ( │ │ │ +000529e0: 6973 5f69 3270 5f61 6464 7229 2072 6574 is_i2p_addr) ret │ │ │ +000529f0: 7572 6e20 7374 643a 3a73 7472 696e 6728 urn std::string( │ │ │ +00052a00: 6465 7374 2829 293b 0a23 656e 6469 660a dest());.#endif. │ │ │ +00052a10: 0909 7265 7475 726e 2061 6464 7265 7373 ..return address │ │ │ +00052a20: 2829 2e74 6f5f 7374 7269 6e67 2829 3b0a ().to_string();. │ │ │ +00052a30: 097d 0a23 656e 6469 660a 0a09 7374 643a .}.#endif...std: │ │ │ +00052a40: 3a69 6e74 3634 5f74 2074 6f72 7265 6e74 :int64_t torrent │ │ │ +00052a50: 5f70 6565 723a 3a74 6f74 616c 5f64 6f77 _peer::total_dow │ │ │ +00052a60: 6e6c 6f61 6428 2920 636f 6e73 740a 097b nload() const..{ │ │ │ +00052a70: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00052a80: 5428 696e 5f75 7365 293b 0a09 0969 6620 T(in_use);...if │ │ │ +00052a90: 2863 6f6e 6e65 6374 696f 6e20 213d 206e (connection != n │ │ │ +00052aa0: 756c 6c70 7472 290a 0909 7b0a 0909 0954 ullptr)...{....T │ │ │ +00052ab0: 4f52 5245 4e54 5f41 5353 4552 5428 7072 ORRENT_ASSERT(pr │ │ │ +00052ac0: 6576 5f61 6d6f 756e 745f 646f 776e 6c6f ev_amount_downlo │ │ │ +00052ad0: 6164 203d 3d20 3029 3b0a 0909 0972 6574 ad == 0);....ret │ │ │ +00052ae0: 7572 6e20 636f 6e6e 6563 7469 6f6e 2d26 urn connection-& │ │ │ +00052af0: 6774 3b73 7461 7469 7374 6963 7328 292e gt;statistics(). │ │ │ +00052b00: 746f 7461 6c5f 7061 796c 6f61 645f 646f total_payload_do │ │ │ +00052b10: 776e 6c6f 6164 2829 3b0a 0909 7d0a 0909 wnload();...}... │ │ │ +00052b20: 656c 7365 0a09 097b 0a09 0909 7265 7475 else...{....retu │ │ │ +00052b30: 726e 2073 7464 3a3a 696e 7436 345f 7428 rn std::int64_t( │ │ │ +00052b40: 7072 6576 5f61 6d6f 756e 745f 646f 776e prev_amount_down │ │ │ +00052b50: 6c6f 6164 2920 2a20 3130 3234 3b0a 0909 load) * 1024;... │ │ │ +00052b60: 7d0a 097d 0a3c 2f70 7265 3e3c 2f74 643e }..}.
    │ │ │ +00052b70: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00052ba0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00052bb0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00052bc0: 7074 3a65 7870 616e 6428 3139 3529 223e pt:expand(195)"> │ │ │ +00052bd0: 2e2e 2f73 7263 2f6d 6167 6e65 745f 7572 ../src/magnet_ur │ │ │ +00052be0: 692e 6370 703a 3432 353c 2f61 3e3c 2f74 i.cpp:425
    what's the │ │ │ +00052c00: 2072 6967 6874 206e 756d 6265 7220 6865 right number he │ │ │ +00052c10: 7265 3f3c 2f74 643e 3c2f 7472 3e3c 7472 re?

    what's the righ │ │ │ +00052c70: 7420 6e75 6d62 6572 2068 6572 653f 3c2f t number here?

    ../src/ma │ │ │ +00052c90: 676e 6574 5f75 7269 2e63 7070 3a34 3235 gnet_uri.cpp:425 │ │ │ +00052ca0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00052ce0: 0909 7d0a 0909 0965 6c73 6520 6966 2028  ..}....else if (
    │ │ │ +00052cf0: 6175 783a 3a73 7472 696e 675f 6571 7561  aux::string_equa
    │ │ │ +00052d00: 6c5f 6e6f 5f63 6173 6528 6e61 6d65 2c20  l_no_case(name, 
    │ │ │ +00052d10: 2273 6f22 5f73 7629 2920 2f2f 2073 656c  "so"_sv)) // sel
    │ │ │ +00052d20: 6563 742d 6f6e 6c79 2028 6669 6c65 7329  ect-only (files)
    │ │ │ +00052d30: 0a09 0909 7b0a 0909 0909 2f2f 2061 6363  ....{.....// acc
    │ │ │ +00052d40: 6570 7420 6f6e 6c79 2064 6967 6974 732c  ept only digits,
    │ │ │ +00052d50: 2027 2d27 2061 6e64 2027 2c27 0a09 0909   '-' and ','....
    │ │ │ +00052d60: 0969 6620 2873 7464 3a3a 616e 795f 6f66  .if (std::any_of
    │ │ │ +00052d70: 2876 616c 7565 2e62 6567 696e 2829 2c20  (value.begin(), 
    │ │ │ +00052d80: 7661 6c75 652e 656e 6428 292c 205b 5d28  value.end(), [](
    │ │ │ +00052d90: 6368 6172 2063 290a 0909 0909 097b 2072  char c)......{ r
    │ │ │ +00052da0: 6574 7572 6e20 2161 7578 3a3a 6973 5f64  eturn !aux::is_d
    │ │ │ +00052db0: 6967 6974 2863 2920 2661 6d70 3b26 616d  igit(c) &&am
    │ │ │ +00052dc0: 703b 2063 2021 3d20 272d 2720 2661 6d70  p; c != '-' &
    │ │ │ +00052dd0: 3b26 616d 703b 2063 2021 3d20 272c 273b  ;& c != ',';
    │ │ │ +00052de0: 207d 2929 0a09 0909 0909 636f 6e74 696e   }))......contin
    │ │ │ +00052df0: 7565 3b0a 0a09 0909 092f 2f20 6d61 6b65  ue;......// make
    │ │ │ +00052e00: 2073 7572 6520 616c 6c20 6669 6c65 2070   sure all file p
    │ │ │ +00052e10: 7269 6f72 6974 6965 7320 6172 6520 7365  riorities are se
    │ │ │ +00052e20: 7420 746f 2030 2c20 6578 6365 7074 2074  t to 0, except t
    │ │ │ +00052e30: 6865 206f 6e65 730a 0909 0909 2f2f 2077  he ones.....// w
    │ │ │ +00052e40: 6520 7370 6563 6966 7920 696e 2074 6865  e specify in the
    │ │ │ +00052e50: 2066 696c 655f 7072 696f 7269 7469 6573   file_priorities
    │ │ │ +00052e60: 0a09 0909 0970 2e66 6c61 6773 207c 3d20  .....p.flags |= 
    │ │ │ +00052e70: 746f 7272 656e 745f 666c 6167 733a 3a64  torrent_flags::d
    │ │ │ +00052e80: 6566 6175 6c74 5f64 6f6e 745f 646f 776e  efault_dont_down
    │ │ │ +00052e90: 6c6f 6164 3b0a 0a09 0909 0964 6f0a 0909  load;......do...
    │ │ │ +00052ea0: 0909 7b0a 0909 0909 0973 7472 696e 675f  ..{......string_
    │ │ │ +00052eb0: 7669 6577 2074 6f6b 656e 3b0a 0909 0909  view token;.....
    │ │ │ +00052ec0: 0973 7464 3a3a 7469 6528 746f 6b65 6e2c  .std::tie(token,
    │ │ │ +00052ed0: 2076 616c 7565 2920 3d20 6175 783a 3a73   value) = aux::s
    │ │ │ +00052ee0: 706c 6974 5f73 7472 696e 6728 7661 6c75  plit_string(valu
    │ │ │ +00052ef0: 652c 2027 2c27 293b 0a0a 0909 0909 0969  e, ',');.......i
    │ │ │ +00052f00: 6620 2874 6f6b 656e 2e65 6d70 7479 2829  f (token.empty()
    │ │ │ +00052f10: 2920 636f 6e74 696e 7565 3b0a 0a09 0909  ) continue;.....
    │ │ │ +00052f20: 0909 696e 7420 6964 7831 2c20 6964 7832  ..int idx1, idx2
    │ │ │ +00052f30: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261  ;.
    │ │ │ +00052f60: 0909 0909 0963 6f6e 7374 6578 7072 2069 .....constexpr i │ │ │ +00052f70: 6e74 206d 6178 5f69 6e64 6578 203d 2031 nt max_index = 1 │ │ │ +00052f80: 3030 3030 3b20 2f2f 2063 616e 2774 2072 0000; // can't r │ │ │ +00052f90: 6973 6b20 6f75 7420 6f66 206d 656d 6f72 isk out of memor │ │ │ +00052fa0: 790a 3c2f 6469 763e 0a09 0909 0909 6175 y.
    ......au │ │ │ +00052fb0: 746f 2063 6f6e 7374 2064 6976 6964 6572 to const divider │ │ │ +00052fc0: 203d 2074 6f6b 656e 2e66 696e 645f 6669 = token.find_fi │ │ │ +00052fd0: 7273 745f 6f66 2827 2d27 293b 0a09 0909 rst_of('-');.... │ │ │ +00052fe0: 0909 6966 2028 6469 7669 6465 7220 213d ..if (divider != │ │ │ +00052ff0: 2073 7464 3a3a 7374 7269 6e67 3a3a 6e70 std::string::np │ │ │ +00053000: 6f73 2920 2f2f 2069 7427 7320 6120 7261 os) // it's a ra │ │ │ +00053010: 6e67 650a 0909 0909 097b 0a09 0909 0909 nge......{...... │ │ │ +00053020: 0969 6620 2864 6976 6964 6572 203d 3d20 .if (divider == │ │ │ +00053030: 3029 202f 2f20 6e6f 2073 7461 7274 2069 0) // no start i │ │ │ +00053040: 6e64 6578 0a09 0909 0909 0909 636f 6e74 ndex........cont │ │ │ +00053050: 696e 7565 3b0a 0909 0909 0909 6966 2028 inue;.......if ( │ │ │ +00053060: 6469 7669 6465 7220 3d3d 2074 6f6b 656e divider == token │ │ │ +00053070: 2e73 697a 6528 2920 2d20 3129 202f 2f20 .size() - 1) // │ │ │ +00053080: 6e6f 2065 6e64 2069 6e64 6578 0a09 0909 no end index.... │ │ │ +00053090: 0909 0909 636f 6e74 696e 7565 3b0a 0a09 ....continue;... │ │ │ +000530a0: 0909 0909 0961 7574 6f20 636f 6e73 7420 .....auto const │ │ │ +000530b0: 6669 7273 7420 3d20 6175 783a 3a70 6172 first = aux::par │ │ │ +000530c0: 7365 5f64 6563 696d 616c 2874 6f6b 656e se_decimal(token │ │ │ +000530d0: 2e73 7562 7374 7228 302c 2064 6976 6964 .substr(0, divid │ │ │ +000530e0: 6572 2929 3b0a 0909 0909 0909 6966 2028 er));.......if ( │ │ │ +000530f0: 2166 6972 7374 207c 7c20 2a66 6972 7374 !first || *first │ │ │ +00053100: 2026 6c74 3b20 3020 7c7c 202a 6669 7273 < 0 || *firs │ │ │ +00053110: 7420 2667 743b 206d 6178 5f69 6e64 6578 t > max_index │ │ │ +00053120: 2920 2f2f 2069 6e76 616c 6964 2069 6e64 ) // invalid ind │ │ │ +00053130: 6578 0a09 0909 0909 0909 636f 6e74 696e ex........contin │ │ │ +00053140: 7565 3b0a 0909 0909 0909 6175 746f 2063 ue;.......auto c │ │ │ +00053150: 6f6e 7374 206c 6173 7420 3d20 6175 783a onst last = aux: │ │ │ +00053160: 3a70 6172 7365 5f64 6563 696d 616c 2874 :parse_decimal(t │ │ │ +00053170: 6f6b 656e 2e73 7562 7374 7228 6469 7669 oken.substr(divi │ │ │ +00053180: 6465 7220 2b20 3129 293b 0a09 0909 0909 der + 1));...... │ │ │ +00053190: 0969 6620 2821 6c61 7374 207c 7c20 2a6c .if (!last || *l │ │ │ +000531a0: 6173 7420 266c 743b 2030 207c 7c20 2a6c ast < 0 || *l │ │ │ +000531b0: 6173 7420 2667 743b 206d 6178 5f69 6e64 ast > max_ind │ │ │ +000531c0: 6578 2920 2f2f 2069 6e76 616c 6964 2069 ex) // invalid i │ │ │ +000531d0: 6e64 6578 0a09 0909 0909 0909 636f 6e74 ndex........cont │ │ │ +000531e0: 696e 7565 3b0a 0909 0909 0909 6964 7831 inue;.......idx1 │ │ │ +000531f0: 203d 202a 6669 7273 743b 0a09 0909 0909 = *first;...... │ │ │ +00053200: 0969 6478 3220 3d20 2a6c 6173 743b 0a0a .idx2 = *last;.. │ │ │ +00053210: 0909 0909 0909 6966 2028 6964 7831 2026 ......if (idx1 & │ │ │ +00053220: 6774 3b20 6964 7832 2920 2f2f 2077 726f gt; idx2) // wro │ │ │ +00053230: 6e67 2072 616e 6765 206c 696d 6974 730a ng range limits. │ │ │ +00053240: 0909 0909 0909 0963 6f6e 7469 6e75 653b .......continue; │ │ │ +00053250: 0a09 0909 0909 7d0a 0909 0909 0965 6c73 ......}......els │ │ │ +00053260: 6520 2f2f 2069 7427 7320 616e 2069 6e64 e // it's an ind │ │ │ +00053270: 6578 0a09 0909 0909 7b0a 0909 0909 0909 ex......{....... │ │ │ +00053280: 6175 746f 2063 6f6e 7374 2069 6478 203d auto const idx = │ │ │ +00053290: 2061 7578 3a3a 7061 7273 655f 6465 6369 aux::parse_deci │ │ │ +000532a0: 6d61 6c28 746f 6b65 6e29 3b0a 0909 0909 mal(token);..... │ │ │ +000532b0: 0909 6966 2028 2169 6478 207c 7c20 2a69 ..if (!idx || *i │ │ │ +000532c0: 6478 2026 6c74 3b20 3020 7c7c 202a 6964 dx < 0 || *id │ │ │ +000532d0: 7820 2667 743b 206d 6178 5f69 6e64 6578 x > max_index │ │ │ +000532e0: 2920 2f2f 2069 6e76 616c 6964 2069 6e64 ) // invalid ind │ │ │ +000532f0: 6578 0a09 0909 0909 0909 636f 6e74 696e ex........contin │ │ │ +00053300: 7565 3b0a 0909 0909 0909 6964 7831 203d ue;.......idx1 = │ │ │ +00053310: 202a 6964 783b 0a09 0909 0909 0969 6478 *idx;.......idx │ │ │ +00053320: 3220 3d20 6964 7831 3b0a 0909 0909 097d 2 = idx1;......} │ │ │ +00053330: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ +00053360: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00053370: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000533a0: 7372 632f 7265 736f 6c76 655f 6475 706c src/resolve_dupl │ │ │ +000533b0: 6963 6174 655f 6669 6c65 6e61 6d65 732e icate_filenames. │ │ │ +000533c0: 6370 703a 3135 383c 2f61 3e3c 2f74 643e cpp:158 │ │ │ +000533d0: 3c74 643e 7468 6973 2063 616e 2062 6520 this can be │ │ │ +000533e0: 6d6f 7265 2065 6666 6963 6965 6e74 2066 more efficient f │ │ │ +000533f0: 6f72 2076 3220 746f 7272 656e 7473 3c2f or v2 torrents

    this │ │ │ +00053450: 2063 616e 2062 6520 6d6f 7265 2065 6666 can be more eff │ │ │ +00053460: 6963 6965 6e74 2066 6f72 2076 3220 746f icient for v2 to │ │ │ +00053470: 7272 656e 7473 3c2f 6832 3e3c 6834 3e2e rrents

    . │ │ │ +00053480: 2e2f 7372 632f 7265 736f 6c76 655f 6475 ./src/resolve_du │ │ │ +00053490: 706c 6963 6174 655f 6669 6c65 6e61 6d65 plicate_filename │ │ │ +000534a0: 732e 6370 703a 3135 383c 2f68 343e 3c70 s.cpp:158

    ....}... │ │ │ +000534f0: 0909 2b2b 6e75 6d5f 636f 6c6c 6973 696f ..++num_collisio │ │ │ +00053500: 6e73 3b0a 0909 0909 6966 2028 6e75 6d5f ns;.....if (num_ │ │ │ +00053510: 636f 6c6c 6973 696f 6e73 2026 6774 3b20 collisions > │ │ │ +00053520: 6d61 785f 6475 706c 6963 6174 655f 6669 max_duplicate_fi │ │ │ +00053530: 6c65 6e61 6d65 7329 0a09 0909 097b 0a09 lenames).....{.. │ │ │ +00053540: 0909 0909 6563 203d 2065 7272 6f72 733a ....ec = errors: │ │ │ +00053550: 3a74 6f6f 5f6d 616e 795f 6475 706c 6963 :too_many_duplic │ │ │ +00053560: 6174 655f 6669 6c65 6e61 6d65 733b 0a09 ate_filenames;.. │ │ │ +00053570: 0909 0909 7265 7475 726e 207b 7d3b 0a09 ....return {};.. │ │ │ +00053580: 0909 097d 0a09 0909 7d0a 0909 0972 6574 ...}....}....ret │ │ │ +00053590: 2e69 6e73 6572 7428 7b69 2c20 6669 6c65 .insert({i, file │ │ │ +000535a0: 6e61 6d65 7d29 3b0a 0909 7d0a 0909 7265 name});...}...re │ │ │ +000535b0: 7475 726e 2072 6574 3b0a 097d 0a0a 7d0a turn ret;..}..}. │ │ │ +000535c0: 0a09 7374 643a 3a6d 6170 266c 743b 6669 ..std::map<fi │ │ │ +000535d0: 6c65 5f69 6e64 6578 5f74 2c20 7374 643a le_index_t, std: │ │ │ +000535e0: 3a73 7472 696e 6726 6774 3b20 7265 736f :string> reso │ │ │ +000535f0: 6c76 655f 6475 706c 6963 6174 655f 6669 lve_duplicate_fi │ │ │ +00053600: 6c65 6e61 6d65 7328 0a09 0966 696c 655f lenames(...file_ │ │ │ +00053610: 7374 6f72 6167 6520 636f 6e73 7426 616d storage const&am │ │ │ +00053620: 703b 2066 730a 0909 2c20 696e 7420 636f p; fs..., int co │ │ │ +00053630: 6e73 7420 6d61 785f 6475 706c 6963 6174 nst max_duplicat │ │ │ +00053640: 655f 6669 6c65 6e61 6d65 730a 0909 2c20 e_filenames..., │ │ │ +00053650: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ +00053660: 6563 290a 097b 0a3c 6469 7620 7374 796c ec)..{.

    ..std::unor │ │ │ +000536a0: 6465 7265 645f 7365 7426 6c74 3b73 7464 dered_set<std │ │ │ +000536b0: 3a3a 7569 6e74 3332 5f74 2667 743b 2066 ::uint32_t> f │ │ │ +000536c0: 696c 6573 3b0a 3c2f 6469 763e 0a09 0973 iles;.
    ...s │ │ │ +000536d0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ +000536e0: 2065 6d70 7479 5f73 7472 3b0a 0a09 092f empty_str;..../ │ │ │ +000536f0: 2f20 696e 7365 7274 2061 6c6c 2064 6972 / insert all dir │ │ │ +00053700: 6563 746f 7269 6573 2066 6972 7374 2c20 ectories first, │ │ │ +00053710: 746f 206d 616b 6520 7375 7265 206e 6f20 to make sure no │ │ │ +00053720: 6669 6c65 730a 0909 2f2f 2061 7265 2061 files...// are a │ │ │ +00053730: 6c6c 6f77 6564 2074 6f20 636f 6c6c 6965 llowed to collie │ │ │ +00053740: 6420 7769 7468 2074 6865 6d0a 0909 6673 d with them...fs │ │ │ +00053750: 2e61 6c6c 5f70 6174 685f 6861 7368 6573 .all_path_hashes │ │ │ +00053760: 2866 696c 6573 293b 0a09 0966 6f72 2028 (files);...for ( │ │ │ +00053770: 6175 746f 2063 6f6e 7374 2069 203a 2066 auto const i : f │ │ │ +00053780: 732e 6669 6c65 5f72 616e 6765 2829 290a s.file_range()). │ │ │ +00053790: 0909 7b0a 0909 092f 2f20 6173 206c 6f6e ..{....// as lon │ │ │ +000537a0: 6720 6173 2074 6869 7320 6669 6c65 2061 g as this file a │ │ │ +000537b0: 6c72 6561 6479 2065 7869 7374 730a 0909 lready exists... │ │ │ +000537c0: 092f 2f20 696e 6372 6561 7365 2074 6865 .// increase the │ │ │ +000537d0: 2063 6f75 6e74 6572 0a09 0909 7374 643a counter....std: │ │ │ +000537e0: 3a75 696e 7433 325f 7420 636f 6e73 7420 :uint32_t const │ │ │ +000537f0: 6820 3d20 6673 2e66 696c 655f 7061 7468 h = fs.file_path │ │ │ +00053800: 5f68 6173 6828 692c 2065 6d70 7479 5f73 _hash(i, empty_s │ │ │ +00053810: 7472 293b 0a09 0909 6966 2028 2166 696c tr);....if (!fil │ │ │ +00053820: 6573 2e69 6e73 6572 7428 6829 2e73 6563 es.insert(h).sec │ │ │ +00053830: 6f6e 6429 0a09 0909 7b0a 0909 0909 2f2f ond)....{.....// │ │ │ +00053840: 2054 6869 7320 6669 6c65 6e61 6d65 2061 This filename a │ │ │ +00053850: 7070 6561 7273 2074 6f20 616c 7265 6164 ppears to alread │ │ │ +00053860: 7920 6578 6973 7421 0a09 0909 092f 2f20 y exist!.....// │ │ │ +00053870: 4966 2074 6869 7320 6861 7070 656e 732c If this happens, │ │ │ +00053880: 206a 7573 7420 7374 6172 7420 6f76 6572 just start over │ │ │ +00053890: 2061 6e64 2064 6f20 6974 2074 6865 2073 and do it the s │ │ │ +000538a0: 6c6f 7720 7761 792c 0a09 0909 092f 2f20 low way,.....// │ │ │ +000538b0: 636f 6d70 6172 696e 6720 6675 6c6c 2066 comparing full f │ │ │ +000538c0: 696c 6520 6e61 6d65 7320 616e 6420 636f ile names and co │ │ │ +000538d0: 6d65 2075 7020 7769 7468 206e 6577 206e me up with new n │ │ │ +000538e0: 616d 6573 0a09 0909 0972 6574 7572 6e20 ames.....return │ │ │ +000538f0: 7265 736f 6c76 655f 6475 706c 6963 6174 resolve_duplicat │ │ │ +00053900: 655f 6669 6c65 6e61 6d65 735f 736c 6f77 e_filenames_slow │ │ │ +00053910: 2866 732c 206d 6178 5f64 7570 6c69 6361 (fs, max_duplica │ │ │ +00053920: 7465 5f66 696c 656e 616d 6573 2c20 6563 te_filenames, ec │ │ │ +00053930: 293b 0a09 0909 7d0a 0909 7d0a 0909 7265 );....}...}...re │ │ │ +00053940: 7475 726e 207b 7d3b 0a09 7d0a 0a7d 0a3c turn {};..}..}.< │ │ │ +00053950: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00053960: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00053970: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00053980: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00053990: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +000539c0: 2f66 696e 6765 7270 7269 6e74 2e63 7070 /fingerprint.cpp │ │ │ +000539d0: 3a35 353c 2f61 3e3c 2f74 643e 3c74 643e :55 │ │ │ +000539e0: 7468 6520 6669 6e67 6572 7072 696e 7420 the fingerprint │ │ │ +000539f0: 636f 6e73 7472 7563 746f 7220 7368 6f75 constructor shou │ │ │ +00053a00: 6c64 2074 616b 6520 6120 7374 7269 6e67 ld take a string │ │ │ +00053a10: 5f76 6965 773c 2f74 643e 3c2f 7472 3e3c _view< │ │ │ +00053a20: 7472 2069 643d 2231 3937 2220 7374 796c tr id="197" styl │ │ │ +00053a30: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00053a40: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00053a50: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00053a60: 6832 3e74 6865 2066 696e 6765 7270 7269 h2>the fingerpri │ │ │ +00053a70: 6e74 2063 6f6e 7374 7275 6374 6f72 2073 nt constructor s │ │ │ +00053a80: 686f 756c 6420 7461 6b65 2061 2073 7472 hould take a str │ │ │ +00053a90: 696e 675f 7669 6577 3c2f 6832 3e3c 6834 ing_view

    ../src/fingerpr │ │ │ +00053ab0: 696e 742e 6370 703a 3535 3c2f 6834 3e3c int.cpp:55

    < │ │ │ +00053ac0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00053ad0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00053ae0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00053af0: 7820 2364 6464 3b22 3e09 0954 4f52 5245 x #ddd;">..TORRE │ │ │ +00053b00: 4e54 5f41 5353 4552 545f 5052 4543 4f4e NT_ASSERT_PRECON │ │ │ +00053b10: 4428 6d69 6e6f 7220 2667 743b 3d20 3029 D(minor >= 0) │ │ │ +00053b20: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ +00053b30: 5254 5f50 5245 434f 4e44 2872 6576 6973 RT_PRECOND(revis │ │ │ +00053b40: 696f 6e20 2667 743b 3d20 3029 3b0a 0909 ion >= 0);... │ │ │ +00053b50: 544f 5252 454e 545f 4153 5345 5254 5f50 TORRENT_ASSERT_P │ │ │ +00053b60: 5245 434f 4e44 2874 6167 2026 6774 3b3d RECOND(tag >= │ │ │ +00053b70: 2030 293b 0a09 0954 4f52 5245 4e54 5f41 0);...TORRENT_A │ │ │ +00053b80: 5353 4552 545f 5052 4543 4f4e 4428 6e61 SSERT_PRECOND(na │ │ │ +00053b90: 6d65 2e73 697a 6528 2920 3d3d 2032 293b me.size() == 2); │ │ │ +00053ba0: 0a09 0969 6620 286e 616d 652e 7369 7a65 ...if (name.size │ │ │ +00053bb0: 2829 2026 6c74 3b20 3229 206e 616d 6520 () < 2) name │ │ │ +00053bc0: 3d20 222d 2d22 3b0a 0a09 0973 7464 3a3a = "--";....std:: │ │ │ +00053bd0: 7374 7269 6e67 2072 6574 3b0a 0909 7265 string ret;...re │ │ │ +00053be0: 742e 7265 7369 7a65 2838 293b 0a09 0972 t.resize(8);...r │ │ │ +00053bf0: 6574 5b30 5d20 3d20 272d 273b 0a09 0972 et[0] = '-';...r │ │ │ +00053c00: 6574 5b31 5d20 3d20 6e61 6d65 5b30 5d3b et[1] = name[0]; │ │ │ +00053c10: 0a09 0972 6574 5b32 5d20 3d20 6e61 6d65 ...ret[2] = name │ │ │ +00053c20: 5b31 5d3b 0a09 0972 6574 5b33 5d20 3d20 [1];...ret[3] = │ │ │ +00053c30: 7665 7273 696f 6e5f 746f 5f63 6861 7228 version_to_char( │ │ │ +00053c40: 6d61 6a6f 7229 3b0a 0909 7265 745b 345d major);...ret[4] │ │ │ +00053c50: 203d 2076 6572 7369 6f6e 5f74 6f5f 6368 = version_to_ch │ │ │ +00053c60: 6172 286d 696e 6f72 293b 0a09 0972 6574 ar(minor);...ret │ │ │ +00053c70: 5b35 5d20 3d20 7665 7273 696f 6e5f 746f [5] = version_to │ │ │ +00053c80: 5f63 6861 7228 7265 7669 7369 6f6e 293b _char(revision); │ │ │ +00053c90: 0a09 0972 6574 5b36 5d20 3d20 7665 7273 ...ret[6] = vers │ │ │ +00053ca0: 696f 6e5f 746f 5f63 6861 7228 7461 6729 ion_to_char(tag) │ │ │ +00053cb0: 3b0a 0909 7265 745b 375d 203d 2027 2d27 ;...ret[7] = '-' │ │ │ +00053cc0: 3b0a 0909 7265 7475 726e 2072 6574 3b0a ;...return ret;. │ │ │ +00053cd0: 097d 0a0a 2369 6664 6566 205f 5f63 6c61 .}..#ifdef __cla │ │ │ +00053ce0: 6e67 5f5f 0a3c 6469 7620 7374 796c 653d ng__.
    #pragma clang │ │ │ +00053d20: 2064 6961 676e 6f73 7469 6320 7075 7368 diagnostic push │ │ │ +00053d30: 0a3c 2f64 6976 3e23 7072 6167 6d61 2063 .
    #pragma c │ │ │ +00053d40: 6c61 6e67 2064 6961 676e 6f73 7469 6320 lang diagnostic │ │ │ +00053d50: 6967 6e6f 7265 6420 222d 5775 6e6b 6e6f ignored "-Wunkno │ │ │ +00053d60: 776e 2d77 6172 6e69 6e67 2d6f 7074 696f wn-warning-optio │ │ │ +00053d70: 6e22 0a23 7072 6167 6d61 2063 6c61 6e67 n".#pragma clang │ │ │ +00053d80: 2064 6961 676e 6f73 7469 6320 6967 6e6f diagnostic igno │ │ │ +00053d90: 7265 6420 222d 5775 6e73 6166 652d 6275 red "-Wunsafe-bu │ │ │ +00053da0: 6666 6572 2d75 7361 6765 220a 2365 6e64 ffer-usage".#end │ │ │ +00053db0: 6966 0a0a 0966 696e 6765 7270 7269 6e74 if...fingerprint │ │ │ +00053dc0: 3a3a 6669 6e67 6572 7072 696e 7428 636f ::fingerprint(co │ │ │ +00053dd0: 6e73 7420 6368 6172 2a20 6964 5f73 7472 nst char* id_str │ │ │ +00053de0: 696e 672c 2069 6e74 206d 616a 6f72 2c20 ing, int major, │ │ │ +00053df0: 696e 7420 6d69 6e6f 720a 0909 2c20 696e int minor..., in │ │ │ +00053e00: 7420 7265 7669 7369 6f6e 2c20 696e 7420 t revision, int │ │ │ +00053e10: 7461 6729 0a09 093a 206d 616a 6f72 5f76 tag)...: major_v │ │ │ +00053e20: 6572 7369 6f6e 286d 616a 6f72 290a 0909 ersion(major)... │ │ │ +00053e30: 2c20 6d69 6e6f 725f 7665 7273 696f 6e28 , minor_version( │ │ │ +00053e40: 6d69 6e6f 7229 0a09 092c 2072 6576 6973 minor)..., revis │ │ │ +00053e50: 696f 6e5f 7665 7273 696f 6e28 7265 7669 ion_version(revi │ │ │ +00053e60: 7369 6f6e 290a 0909 2c20 7461 675f 7665 sion)..., tag_ve │ │ │ +00053e70: 7273 696f 6e28 7461 6729 0a09 7b0a 0909 rsion(tag)..{... │ │ │ +00053e80: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +00053e90: 645f 7374 7269 6e67 293b 0a09 0954 4f52 d_string);...TOR │ │ │ +00053ea0: 5245 4e54 5f41 5353 4552 5428 6d61 6a6f RENT_ASSERT(majo │ │ │ +00053eb0: 7220 2667 743b 3d20 3029 3b0a 0909 544f r >= 0);...TO │ │ │ +00053ec0: 5252 454e 545f 4153 5345 5254 286d 696e RRENT_ASSERT(min │ │ │ +00053ed0: 6f72 2026 6774 3b3d 2030 293b 0a09 0954 or >= 0);...T │ │ │ +00053ee0: 4f52 5245 4e54 5f41 5353 4552 5428 7265 ORRENT_ASSERT(re │ │ │ +00053ef0: 7669 7369 6f6e 2026 6774 3b3d 2030 293b vision >= 0); │ │ │ +00053f00: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00053f10: 5428 7461 6720 2667 743b 3d20 3029 3b0a T(tag >= 0);. │ │ │ +00053f20: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00053f30: 2873 7464 3a3a 7374 726c 656e 2869 645f (std::strlen(id_ │ │ │ +00053f40: 7374 7269 6e67 2920 3d3d 2032 293b 0a09 string) == 2);.. │ │ │ +00053f50: 096e 616d 655b 305d 203d 2069 645f 7374 .name[0] = id_st │ │ │ +00053f60: 7269 6e67 5b30 5d3b 0a09 096e 616d 655b ring[0];...name[ │ │ │ +00053f70: 315d 203d 2069 645f 7374 7269 6e67 5b31 1] = id_string[1 │ │ │ +00053f80: 5d3b 0a09 7d0a 0a23 6966 6465 6620 5f5f ];..}..#ifdef __ │ │ │ +00053f90: 636c 616e 675f 5f0a 2370 7261 676d 6120 clang__.#pragma │ │ │ +00053fa0: 636c 616e 6720 6469 6167 6e6f 7374 6963 clang diagnostic │ │ │ +00053fb0: 2070 6f70 0a23 656e 6469 660a 0a23 6966 pop.#endif..#if │ │ │ +00053fc0: 2054 4f52 5245 4e54 5f41 4249 5f56 4552 TORRENT_ABI_VER │ │ │ +00053fd0: 5349 4f4e 203d 3d20 310a 0973 7464 3a3a SION == 1..std:: │ │ │ +00053fe0: 7374 7269 6e67 2066 696e 6765 7270 7269 string fingerpri │ │ │ +00053ff0: 6e74 3a3a 746f 5f73 7472 696e 6728 2920 nt::to_string() │ │ │ +00054000: 636f 6e73 740a 097b 0a09 0972 6574 7572 const..{...retur │ │ │ +00054010: 6e20 6765 6e65 7261 7465 5f66 696e 6765 n generate_finge │ │ │ +00054020: 7270 7269 6e74 2873 7464 3a3a 7374 7269 rprint(std::stri │ │ │ +00054030: 6e67 286e 616d 652c 2032 292c 206d 616a ng(name, 2), maj │ │ │ +00054040: 6f72 5f76 6572 7369 6f6e 2c20 6d69 6e6f or_version, mino │ │ │ +00054050: 725f 7665 7273 696f 6e0a 0909 092c 2072 r_version...., r │ │ │ +00054060: 6576 6973 696f 6e5f 7665 7273 696f 6e2c evision_version, │ │ │ +00054070: 2074 6167 5f76 6572 7369 6f6e 293b 0a3c tag_version);.< │ │ │ +00054080: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00054090: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +000540a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +000540b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000540c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +000540f0: 2f72 616e 646f 6d2e 6370 703a 3131 373c /random.cpp:117< │ │ │ +00054100: 2f61 3e3c 2f74 643e 3c74 643e 696d 7072 /a>impr │ │ │ +00054110: 6f76 6520 6361 6c6c 696e 6720 5241 4e44 ove calling RAND │ │ │ +00054120: 5f62 7974 6573 206d 756c 7469 706c 6520 _bytes multiple │ │ │ +00054130: 7469 6d65 732c 2075 7369 6e67 2066 616c times, using fal │ │ │ +00054140: 6c62 6163 6b20 666f 7220 6e6f 773c 2f74 lback for now

    impro │ │ │ +000541a0: 7665 2063 616c 6c69 6e67 2052 414e 445f ve calling RAND_ │ │ │ +000541b0: 6279 7465 7320 6d75 6c74 6970 6c65 2074 bytes multiple t │ │ │ +000541c0: 696d 6573 2c20 7573 696e 6720 6661 6c6c imes, using fall │ │ │ +000541d0: 6261 636b 2066 6f72 206e 6f77 3c2f 6832 back for now

    ../src/rand │ │ │ +000541f0: 6f6d 2e63 7070 3a31 3137 3c2f 6834 3e3c om.cpp:117

    < │ │ │ +00054200: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00054210: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00054220: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00054230: 7820 2364 6464 3b22 3e23 656c 7365 0a09 x #ddd;">#else.. │ │ │ +00054240: 0909 7374 643a 3a67 656e 6572 6174 6528 ..std::generate( │ │ │ +00054250: 6275 6666 6572 2e62 6567 696e 2829 2c20 buffer.begin(), │ │ │ +00054260: 6275 6666 6572 2e65 6e64 2829 2c20 5b5d buffer.end(), [] │ │ │ +00054270: 207b 2072 6574 7572 6e20 6368 6172 2872 { return char(r │ │ │ +00054280: 616e 646f 6d28 3078 6666 2929 3b20 7d29 andom(0xff)); }) │ │ │ +00054290: 3b0a 2365 6e64 6966 0a09 097d 0a0a 0909 ;.#endif...}.... │ │ │ +000542a0: 766f 6964 2063 7279 7074 6f5f 7261 6e64 void crypto_rand │ │ │ +000542b0: 6f6d 5f62 7974 6573 2873 7061 6e26 6c74 om_bytes(span< │ │ │ +000542c0: 3b63 6861 7226 6774 3b20 6275 6666 6572 ;char> buffer │ │ │ +000542d0: 290a 0909 7b0a 2369 6664 6566 2054 4f52 )...{.#ifdef TOR │ │ │ +000542e0: 5245 4e54 5f42 5549 4c44 5f53 494d 554c RENT_BUILD_SIMUL │ │ │ +000542f0: 4154 4f52 0a09 0909 2f2f 2049 6e20 7468 ATOR....// In th │ │ │ +00054300: 6520 7369 6d75 6c61 746f 7220 7765 2077 e simulator we w │ │ │ +00054310: 616e 7420 6465 7465 726d 696e 6973 7469 ant deterministi │ │ │ +00054320: 6320 7261 6e64 6f6d 206e 756d 6265 7273 c random numbers │ │ │ +00054330: 0a09 0909 7374 643a 3a67 656e 6572 6174 ....std::generat │ │ │ +00054340: 6528 6275 6666 6572 2e62 6567 696e 2829 e(buffer.begin() │ │ │ +00054350: 2c20 6275 6666 6572 2e65 6e64 2829 2c20 , buffer.end(), │ │ │ +00054360: 5b5d 207b 2072 6574 7572 6e20 6368 6172 [] { return char │ │ │ +00054370: 2872 616e 646f 6d28 3078 6666 2929 3b20 (random(0xff)); │ │ │ +00054380: 7d29 3b0a 2365 6c69 6620 544f 5252 454e });.#elif TORREN │ │ │ +00054390: 545f 5553 455f 434e 470a 0909 0961 7578 T_USE_CNG....aux │ │ │ +000543a0: 3a3a 636e 675f 6765 6e5f 7261 6e64 6f6d ::cng_gen_random │ │ │ +000543b0: 2862 7566 6665 7229 3b0a 2365 6c69 6620 (buffer);.#elif │ │ │ +000543c0: 544f 5252 454e 545f 5553 455f 4352 5950 TORRENT_USE_CRYP │ │ │ +000543d0: 544f 4150 490a 0909 092f 2f20 7769 6e64 TOAPI....// wind │ │ │ +000543e0: 6f77 730a 0909 0961 7578 3a3a 6372 7970 ows....aux::cryp │ │ │ +000543f0: 745f 6765 6e5f 7261 6e64 6f6d 2862 7566 t_gen_random(buf │ │ │ +00054400: 6665 7229 3b0a 2365 6c69 6620 6465 6669 fer);.#elif defi │ │ │ +00054410: 6e65 6420 544f 5252 454e 545f 5553 455f ned TORRENT_USE_ │ │ │ +00054420: 4c49 4243 5259 5054 4f20 2661 6d70 3b26 LIBCRYPTO && │ │ │ +00054430: 616d 703b 2021 6465 6669 6e65 6420 544f amp; !defined TO │ │ │ +00054440: 5252 454e 545f 5553 455f 574f 4c46 5353 RRENT_USE_WOLFSS │ │ │ +00054450: 4c0a 2f2f 2077 6f6c 6653 534c 2075 7365 L.// wolfSSL use │ │ │ +00054460: 7320 7763 5f52 4e47 5f47 656e 6572 6174 s wc_RNG_Generat │ │ │ +00054470: 6542 6c6f 636b 2061 7320 7468 6520 696e eBlock as the in │ │ │ +00054480: 7465 726e 616c 2066 756e 6374 696f 6e20 ternal function │ │ │ +00054490: 666f 7220 7468 650a 2f2f 206f 7065 6e73 for the.// opens │ │ │ +000544a0: 736c 2063 6f6d 7061 7469 6269 6c69 7479 sl compatibility │ │ │ +000544b0: 206c 6179 6572 2e20 5468 6973 2066 756e layer. This fun │ │ │ +000544c0: 6374 696f 6e20 4150 4920 646f 6573 206e ction API does n │ │ │ +000544d0: 6f74 2073 7570 706f 7274 0a2f 2f20 616e ot support.// an │ │ │ +000544e0: 2061 7262 6974 7261 7279 2062 7566 6665 arbitrary buffe │ │ │ +000544f0: 7220 7369 7a65 2028 6f70 656e 7373 6c20 r size (openssl │ │ │ +00054500: 646f 6573 292c 2069 7420 6973 206c 696d does), it is lim │ │ │ +00054510: 6974 6564 2062 7920 7468 650a 2f2f 2063 ited by the.// c │ │ │ +00054520: 6f6e 7374 616e 7420 524e 475f 4d41 585f onstant RNG_MAX_ │ │ │ +00054530: 424c 4f43 4b5f 4c45 4e2e 0a3c 6469 7620 BLOCK_LEN..
    .
    │ │ │ +00054570: 0909 092f 2f20 6f70 656e 7373 6c0a 0909 ...// openssl... │ │ │ +00054580: 0969 6e74 2072 203d 2052 414e 445f 6279 .int r = RAND_by │ │ │ +00054590: 7465 7328 7265 696e 7465 7270 7265 745f tes(reinterpret_ │ │ │ +000545a0: 6361 7374 266c 743b 756e 7369 676e 6564 cast<unsigned │ │ │ +000545b0: 2063 6861 722a 2667 743b 2862 7566 6665 char*>(buffe │ │ │ +000545c0: 722e 6461 7461 2829 290a 0909 0909 2c20 r.data())....., │ │ │ +000545d0: 696e 7428 6275 6666 6572 2e73 697a 6528 int(buffer.size( │ │ │ +000545e0: 2929 293b 0a09 0909 6966 2028 7220 213d )));....if (r != │ │ │ +000545f0: 2031 2920 6175 783a 3a74 6872 6f77 5f65 1) aux::throw_e │ │ │ +00054600: 7826 6c74 3b73 7973 7465 6d5f 6572 726f x<system_erro │ │ │ +00054610: 7226 6774 3b28 6572 726f 7273 3a3a 6e6f r>(errors::no │ │ │ +00054620: 5f65 6e74 726f 7079 293b 0a23 656c 6966 _entropy);.#elif │ │ │ +00054630: 2054 4f52 5245 4e54 5f55 5345 5f47 4554 TORRENT_USE_GET │ │ │ +00054640: 5241 4e44 4f4d 0a09 0909 7373 697a 655f RANDOM....ssize_ │ │ │ +00054650: 7420 636f 6e73 7420 7220 3d20 3a3a 6765 t const r = ::ge │ │ │ +00054660: 7472 616e 646f 6d28 6275 6666 6572 2e64 trandom(buffer.d │ │ │ +00054670: 6174 6128 292c 2073 7461 7469 635f 6361 ata(), static_ca │ │ │ +00054680: 7374 266c 743b 7374 643a 3a73 697a 655f st<std::size_ │ │ │ +00054690: 7426 6774 3b28 6275 6666 6572 2e73 697a t>(buffer.siz │ │ │ +000546a0: 6528 2929 2c20 3029 3b0a 0909 0969 6620 e()), 0);....if │ │ │ +000546b0: 2872 203d 3d20 7373 697a 655f 7428 6275 (r == ssize_t(bu │ │ │ +000546c0: 6666 6572 2e73 697a 6528 2929 2920 7265 ffer.size())) re │ │ │ +000546d0: 7475 726e 3b0a 0909 0969 6620 2872 203d turn;....if (r = │ │ │ +000546e0: 3d20 2d31 2026 616d 703b 2661 6d70 3b20 = -1 && │ │ │ +000546f0: 6572 726e 6f20 213d 2045 4e4f 5359 5329 errno != ENOSYS) │ │ │ +00054700: 2061 7578 3a3a 7468 726f 775f 6578 266c aux::throw_ex&l │ │ │ +00054710: 743b 7379 7374 656d 5f65 7272 6f72 2667 t;system_error&g │ │ │ +00054720: 743b 2865 7272 6f72 5f63 6f64 6528 6572 t;(error_code(er │ │ │ +00054730: 726e 6f2c 2067 656e 6572 6963 5f63 6174 rno, generic_cat │ │ │ +00054740: 6567 6f72 7928 2929 293b 0a09 0909 7374 egory()));....st │ │ │ +00054750: 6174 6963 2064 6576 5f72 616e 646f 6d20 atic dev_random │ │ │ +00054760: 6465 763b 0a09 0909 6465 762e 7265 6164 dev;....dev.read │ │ │ +00054770: 2862 7566 6665 7229 3b0a 2365 6c69 6620 (buffer);.#elif │ │ │ +00054780: 544f 5252 454e 545f 5553 455f 4445 565f TORRENT_USE_DEV_ │ │ │ +00054790: 5241 4e44 4f4d 0a09 0909 7374 6174 6963 RANDOM....static │ │ │ +000547a0: 2064 6576 5f72 616e 646f 6d20 6465 763b dev_random dev; │ │ │ +000547b0: 0a09 0909 6465 762e 7265 6164 2862 7566 ....dev.read(buf │ │ │ +000547c0: 6665 7229 3b0a 2365 6c73 650a 0a23 6966 fer);.#else..#if │ │ │ +000547d0: 2054 4f52 5245 4e54 5f42 524f 4b45 4e5f TORRENT_BROKEN_ │ │ │ +000547e0: 5241 4e44 4f4d 5f44 4556 4943 450a 0909 RANDOM_DEVICE... │ │ │ +000547f0: 092f 2f20 6576 656e 2070 7365 7564 6f20 .// even pseudo │ │ │ +00054800: 7261 6e64 6f6d 206e 756d 6265 7273 2072 random numbers r │ │ │ +00054810: 656c 7920 6f6e 2062 6569 6e67 2061 626c ely on being abl │ │ │ +00054820: 6520 746f 2073 6565 6420 7468 6520 7261 e to seed the ra │ │ │ +00054830: 6e64 6f6d 0a09 0909 2f2f 2067 656e 6572 ndom....// gener │ │ │ +00054840: 6174 6f72 0a23 6572 726f 7220 226e 6f20 ator.#error "no │ │ │ +00054850: 656e 7472 6f70 7920 736f 7572 6365 2061 entropy source a │ │ │ +00054860: 7661 696c 6162 6c65 220a 2365 6c73 650a vailable".#else. │ │ │ +00054870: 2369 6664 6566 2054 4f52 5245 4e54 5f49 #ifdef TORRENT_I │ │ │ +00054880: 5f57 414e 545f 494e 5345 4355 5245 5f52 _WANT_INSECURE_R │ │ │ +00054890: 414e 444f 4d5f 4e55 4d42 4552 530a 0909 ANDOM_NUMBERS... │ │ │ +000548a0: 0973 7464 3a3a 6765 6e65 7261 7465 2862 .std::generate(b │ │ │ +000548b0: 7566 6665 722e 6265 6769 6e28 292c 2062 uffer.begin(), b │ │ │ +000548c0: 7566 6665 722e 656e 6428 292c 205b 5d20 uffer.end(), [] │ │ │ +000548d0: 7b20 7265 7475 726e 2063 6861 7228 7261 { return char(ra │ │ │ +000548e0: 6e64 6f6d 2830 7866 6629 293b 207d 293b ndom(0xff)); }); │ │ │ +000548f0: 0a23 656c 7365 0a23 6572 726f 7220 226e .#else.#error "n │ │ │ +00054900: 6f20 7365 6375 7265 2065 6e74 726f 7079 o secure entropy │ │ │ +00054910: 2073 6f75 7263 6520 6176 6169 6c61 626c source availabl │ │ │ +00054920: 652e 2049 6620 796f 7520 7265 616c 6c79 e. If you really │ │ │ +00054930: 2077 616e 7420 696e 7365 6375 7265 2072 want insecure r │ │ │ +00054940: 616e 646f 6d20 6e75 6d62 6572 732c 2064 andom numbers, d │ │ │ +00054950: 6566 696e 6520 544f 5252 454e 545f 495f efine TORRENT_I_ │ │ │ +00054960: 5741 4e54 5f49 4e53 4543 5552 455f 5241 WANT_INSECURE_RA │ │ │ +00054970: 4e44 4f4d 5f4e 554d 4245 5253 220a 2365 NDOM_NUMBERS".#e │ │ │ +00054980: 6e64 6966 0a23 656e 6469 660a 0a23 656e ndif.#endif..#en │ │ │ +00054990: 6469 660a 0909 7d0a 0a3c 2f70 7265 3e3c dif...}..< │ │ │ +000549a0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +000549d0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +000549e0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../src/torre │ │ │ +00054a10: 6e74 5f68 616e 646c 652e 6370 703a 3535 nt_handle.cpp:55 │ │ │ +00054a20: 343c 2f61 3e3c 2f74 643e 3c74 643e 7375 4su │ │ │ +00054a30: 7070 6f72 7420 6d6f 7669 6e67 2066 696c pport moving fil │ │ │ +00054a40: 6573 2069 6e74 6f20 7468 6973 2063 616c es into this cal │ │ │ +00054a50: 6c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 l

    s │ │ │ +00054aa0: 7570 706f 7274 206d 6f76 696e 6720 6669 upport moving fi │ │ │ +00054ab0: 6c65 7320 696e 746f 2074 6869 7320 6361 les into this ca │ │ │ +00054ac0: 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ll

    ../sr │ │ │ +00054ad0: 632f 746f 7272 656e 745f 6861 6e64 6c65 c/torrent_handle │ │ │ +00054ae0: 2e63 7070 3a35 3534 3c2f 6834 3e3c 7072 .cpp:554

    ..auto* c │ │ │ +00054b30: 6f6e 7374 2072 6574 7020 3d20 2661 6d70 onst retp = & │ │ │ +00054b40: 3b70 7269 6f3b 0a09 0973 796e 635f 6361 ;prio;...sync_ca │ │ │ +00054b50: 6c6c 2826 616d 703b 6175 783a 3a74 6f72 ll(&aux::tor │ │ │ +00054b60: 7265 6e74 3a3a 7069 6563 655f 7072 696f rent::piece_prio │ │ │ +00054b70: 7269 7469 6573 2c20 7265 7470 293b 0a09 rities, retp);.. │ │ │ +00054b80: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ +00054b90: 696e 7426 6774 3b20 7265 743b 0a09 0972 int> ret;...r │ │ │ +00054ba0: 6574 2e72 6573 6572 7665 2870 7269 6f2e et.reserve(prio. │ │ │ +00054bb0: 7369 7a65 2829 293b 0a09 0966 6f72 2028 size());...for ( │ │ │ +00054bc0: 6175 746f 2070 203a 2070 7269 6f29 0a09 auto p : prio).. │ │ │ +00054bd0: 0909 7265 742e 7075 7368 5f62 6163 6b28 ..ret.push_back( │ │ │ +00054be0: 696e 7428 7374 6174 6963 5f63 6173 7426 int(static_cast& │ │ │ +00054bf0: 6c74 3b73 7464 3a3a 7569 6e74 385f 7426 lt;std::uint8_t& │ │ │ +00054c00: 6774 3b28 7029 2929 3b0a 0909 7265 7475 gt;(p)));...retu │ │ │ +00054c10: 726e 2072 6574 3b0a 097d 0a23 656e 6469 rn ret;..}.#endi │ │ │ +00054c20: 660a 0a09 766f 6964 2074 6f72 7265 6e74 f...void torrent │ │ │ +00054c30: 5f68 616e 646c 653a 3a66 696c 655f 7072 _handle::file_pr │ │ │ +00054c40: 696f 7269 7479 2866 696c 655f 696e 6465 iority(file_inde │ │ │ +00054c50: 785f 7420 696e 6465 782c 2064 6f77 6e6c x_t index, downl │ │ │ +00054c60: 6f61 645f 7072 696f 7269 7479 5f74 2070 oad_priority_t p │ │ │ +00054c70: 7269 6f72 6974 7929 2063 6f6e 7374 0a09 riority) const.. │ │ │ +00054c80: 7b0a 0909 6173 796e 635f 6361 6c6c 2826 {...async_call(& │ │ │ +00054c90: 616d 703b 6175 783a 3a74 6f72 7265 6e74 amp;aux::torrent │ │ │ +00054ca0: 3a3a 7365 745f 6669 6c65 5f70 7269 6f72 ::set_file_prior │ │ │ +00054cb0: 6974 792c 2069 6e64 6578 2c20 7072 696f ity, index, prio │ │ │ +00054cc0: 7269 7479 293b 0a09 7d0a 0a09 646f 776e rity);..}...down │ │ │ +00054cd0: 6c6f 6164 5f70 7269 6f72 6974 795f 7420 load_priority_t │ │ │ +00054ce0: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ +00054cf0: 6669 6c65 5f70 7269 6f72 6974 7928 6669 file_priority(fi │ │ │ +00054d00: 6c65 5f69 6e64 6578 5f74 2069 6e64 6578 le_index_t index │ │ │ +00054d10: 2920 636f 6e73 740a 097b 0a09 0972 6574 ) const..{...ret │ │ │ +00054d20: 7572 6e20 7379 6e63 5f63 616c 6c5f 7265 urn sync_call_re │ │ │ +00054d30: 7426 6c74 3b64 6f77 6e6c 6f61 645f 7072 t<download_pr │ │ │ +00054d40: 696f 7269 7479 5f74 2667 743b 2864 6f6e iority_t>(don │ │ │ +00054d50: 745f 646f 776e 6c6f 6164 2c20 2661 6d70 t_download, & │ │ │ +00054d60: 3b61 7578 3a3a 746f 7272 656e 743a 3a66 ;aux::torrent::f │ │ │ +00054d70: 696c 655f 7072 696f 7269 7479 2c20 696e ile_priority, in │ │ │ +00054d80: 6465 7829 3b0a 097d 0a0a 3c64 6976 2073 dex);..}..
    .void to │ │ │ +00054dc0: 7272 656e 745f 6861 6e64 6c65 3a3a 7072 rrent_handle::pr │ │ │ +00054dd0: 696f 7269 7469 7a65 5f66 696c 6573 2873 ioritize_files(s │ │ │ +00054de0: 7464 3a3a 7665 6374 6f72 266c 743b 646f td::vector<do │ │ │ +00054df0: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ +00054e00: 7426 6774 3b20 636f 6e73 7426 616d 703b t> const& │ │ │ +00054e10: 2066 696c 6573 2920 636f 6e73 740a 3c2f files) const..{...async_c │ │ │ +00054e30: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f all(&aux::to │ │ │ +00054e40: 7272 656e 743a 3a70 7269 6f72 6974 697a rrent::prioritiz │ │ │ +00054e50: 655f 6669 6c65 730a 0909 092c 2073 7461 e_files...., sta │ │ │ +00054e60: 7469 635f 6361 7374 266c 743b 6175 783a tic_cast<aux: │ │ │ +00054e70: 3a76 6563 746f 7226 6c74 3b64 6f77 6e6c :vector<downl │ │ │ +00054e80: 6f61 645f 7072 696f 7269 7479 5f74 2c20 oad_priority_t, │ │ │ +00054e90: 6669 6c65 5f69 6e64 6578 5f74 2667 743b file_index_t> │ │ │ +00054ea0: 2063 6f6e 7374 2661 6d70 3b26 6774 3b28 const&>( │ │ │ +00054eb0: 6669 6c65 7329 293b 0a09 7d0a 0a09 766f files));..}...vo │ │ │ +00054ec0: 6964 2074 6f72 7265 6e74 5f68 616e 646c id torrent_handl │ │ │ +00054ed0: 653a 3a70 6f73 745f 6669 6c65 5f70 7269 e::post_file_pri │ │ │ +00054ee0: 6f72 6974 6965 7328 2920 636f 6e73 740a orities() const. │ │ │ +00054ef0: 097b 0a09 0961 7379 6e63 5f63 616c 6c28 .{...async_call( │ │ │ +00054f00: 2661 6d70 3b61 7578 3a3a 746f 7272 656e &aux::torren │ │ │ +00054f10: 743a 3a70 6f73 745f 6669 6c65 5f70 7269 t::post_file_pri │ │ │ +00054f20: 6f72 6974 6965 7329 3b0a 097d 0a0a 0973 orities);..}...s │ │ │ +00054f30: 7464 3a3a 7665 6374 6f72 266c 743b 646f td::vector<do │ │ │ +00054f40: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ +00054f50: 7426 6774 3b20 746f 7272 656e 745f 6861 t> torrent_ha │ │ │ +00054f60: 6e64 6c65 3a3a 6765 745f 6669 6c65 5f70 ndle::get_file_p │ │ │ +00054f70: 7269 6f72 6974 6965 7328 2920 636f 6e73 riorities() cons │ │ │ +00054f80: 740a 097b 0a09 0961 7578 3a3a 7665 6374 t..{...aux::vect │ │ │ +00054f90: 6f72 266c 743b 646f 776e 6c6f 6164 5f70 or<download_p │ │ │ +00054fa0: 7269 6f72 6974 795f 742c 2066 696c 655f riority_t, file_ │ │ │ +00054fb0: 696e 6465 785f 7426 6774 3b20 7265 743b index_t> ret; │ │ │ +00054fc0: 0a09 0961 7574 6f2a 2063 6f6e 7374 2072 ...auto* const r │ │ │ +00054fd0: 6574 7020 3d20 2661 6d70 3b72 6574 3b0a etp = &ret;. │ │ │ +00054fe0: 0909 7379 6e63 5f63 616c 6c28 2661 6d70 ..sync_call(& │ │ │ +00054ff0: 3b61 7578 3a3a 746f 7272 656e 743a 3a66 ;aux::torrent::f │ │ │ +00055000: 696c 655f 7072 696f 7269 7469 6573 2c20 ile_priorities, │ │ │ +00055010: 7265 7470 293b 0a09 0972 6574 7572 6e20 retp);...return │ │ │ +00055020: 544f 5252 454e 545f 5256 4f28 7265 7429 TORRENT_RVO(ret) │ │ │ +00055030: 3b0a 097d 0a0a 2369 6620 544f 5252 454e ;..}..#if TORREN │ │ │ +00055040: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ +00055050: 2031 0a0a 2f2f 203d 3d3d 3d3d 3d3d 3d3d 1..// ========= │ │ │ +00055060: 3d3d 3d20 7374 6172 7420 6465 7072 6563 === start deprec │ │ │ +00055070: 6174 696f 6e20 3d3d 3d3d 3d3d 3d3d 3d3d ation ========== │ │ │ +00055080: 3d3d 3d3d 3d0a 0a09 766f 6964 2074 6f72 =====...void tor │ │ │ +00055090: 7265 6e74 5f68 616e 646c 653a 3a70 7269 rent_handle::pri │ │ │ +000550a0: 6f72 6974 697a 655f 6669 6c65 7328 7374 oritize_files(st │ │ │ +000550b0: 643a 3a76 6563 746f 7226 6c74 3b69 6e74 d::vector<int │ │ │ +000550c0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ +000550d0: 6669 6c65 7329 2063 6f6e 7374 0a09 7b0a files) const..{. │ │ │ +000550e0: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ +000550f0: 3b64 6f77 6e6c 6f61 645f 7072 696f 7269 ;download_priori │ │ │ +00055100: 7479 5f74 2c20 6669 6c65 5f69 6e64 6578 ty_t, file_index │ │ │ +00055110: 5f74 2667 743b 2066 696c 655f 7072 696f _t> file_prio │ │ │ +00055120: 3b0a 0909 6669 6c65 5f70 7269 6f2e 7265 ;...file_prio.re │ │ │ +00055130: 7365 7276 6528 6669 6c65 732e 7369 7a65 serve(files.size │ │ │ +00055140: 2829 293b 0a09 0966 6f72 2028 6175 746f ());...for (auto │ │ │ +00055150: 2063 6f6e 7374 2070 203a 2066 696c 6573 const p : files │ │ │ +00055160: 2920 7b0a 0909 0966 696c 655f 7072 696f ) {....file_prio │ │ │ +00055170: 2e70 7573 685f 6261 636b 2864 6f77 6e6c .push_back(downl │ │ │ +00055180: 6f61 645f 7072 696f 7269 7479 5f74 2873 oad_priority_t(s │ │ │ +00055190: 7461 7469 635f 6361 7374 266c 743b 7374 tatic_cast<st │ │ │ +000551a0: 643a 3a75 696e 7438 5f74 2667 743b 2870 d::uint8_t>(p │ │ │ +000551b0: 2929 293b 0a09 097d 0a09 0961 7379 6e63 )));...}...async │ │ │ +000551c0: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a _call(&aux:: │ │ │ +000551d0: 746f 7272 656e 743a 3a70 7269 6f72 6974 torrent::priorit │ │ │ +000551e0: 697a 655f 6669 6c65 732c 2066 696c 655f ize_files, file_ │ │ │ +000551f0: 7072 696f 293b 0a3c 2f70 7265 3e3c 2f74 prio);.relevanc │ │ │ +00055230: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ +00055270: 5f68 616e 646c 652e 6370 703a 3833 393c _handle.cpp:839< │ │ │ +00055280: 2f61 3e3c 2f74 643e 3c74 643e 6465 7072 /a>depr │ │ │ +00055290: 6563 6174 6520 7468 6520 6f76 6572 6c6f ecate the overlo │ │ │ +000552a0: 6164 2074 6861 7420 7461 6b65 7320 616e ad that takes an │ │ │ +000552b0: 2069 6e64 6578 3c2f 7464 3e3c 2f74 723e index │ │ │ +000552c0: 3c74 7220 6964 3d22 3230 3022 2073 7479 │ │ │ +000552f0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00055300: 3c68 323e 6465 7072 6563 6174 6520 7468

    deprecate th │ │ │ +00055310: 6520 6f76 6572 6c6f 6164 2074 6861 7420 e overload that │ │ │ +00055320: 7461 6b65 7320 616e 2069 6e64 6578 3c2f takes an index

    ../src/to │ │ │ +00055340: 7272 656e 745f 6861 6e64 6c65 2e63 7070 rrent_handle.cpp │ │ │ +00055350: 3a38 3339 3c2f 6834 3e3c 7072 6520 7374 :839

    ...auto t = m
    │ │ │ +000553a0: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b  _torrent.lock();
    │ │ │ +000553b0: 0a09 0969 6620 2821 7420 7c7c 2021 742d  ...if (!t || !t-
    │ │ │ +000553c0: 2667 743b 6861 735f 7374 6f72 6167 6528  >has_storage(
    │ │ │ +000553d0: 2929 2072 6574 7572 6e3b 0a09 0961 7574  )) return;...aut
    │ │ │ +000553e0: 6f26 616d 703b 2073 6573 203d 2073 7461  o& ses = sta
    │ │ │ +000553f0: 7469 635f 6361 7374 266c 743b 7365 7373  tic_cast<sess
    │ │ │ +00055400: 696f 6e5f 696d 706c 2661 6d70 3b26 6774  ion_impl&>
    │ │ │ +00055410: 3b28 742d 2667 743b 7365 7373 696f 6e28  ;(t->session(
    │ │ │ +00055420: 2929 3b0a 0909 7374 6174 7573 203d 2073  ));...status = s
    │ │ │ +00055430: 6573 2e64 6973 6b5f 7468 7265 6164 2829  es.disk_thread()
    │ │ │ +00055440: 2e67 6574 5f73 7461 7475 7328 742d 2667  .get_status(t-&g
    │ │ │ +00055450: 743b 7374 6f72 6167 6528 2929 3b0a 097d  t;storage());..}
    │ │ │ +00055460: 0a23 656e 6469 660a 0a09 766f 6964 2074  .#endif...void t
    │ │ │ +00055470: 6f72 7265 6e74 5f68 616e 646c 653a 3a66  orrent_handle::f
    │ │ │ +00055480: 6f72 6365 5f64 6874 5f61 6e6e 6f75 6e63  orce_dht_announc
    │ │ │ +00055490: 6528 2920 636f 6e73 740a 097b 0a23 6966  e() const..{.#if
    │ │ │ +000554a0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +000554b0: 4142 4c45 5f44 4854 0a09 0961 7379 6e63  ABLE_DHT...async
    │ │ │ +000554c0: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a  _call(&aux::
    │ │ │ +000554d0: 746f 7272 656e 743a 3a64 6874 5f61 6e6e  torrent::dht_ann
    │ │ │ +000554e0: 6f75 6e63 6529 3b0a 2365 6e64 6966 0a09  ounce);.#endif..
    │ │ │ +000554f0: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74  }...void torrent
    │ │ │ +00055500: 5f68 616e 646c 653a 3a66 6f72 6365 5f6c  _handle::force_l
    │ │ │ +00055510: 7364 5f61 6e6e 6f75 6e63 6528 2920 636f  sd_announce() co
    │ │ │ +00055520: 6e73 740a 097b 0a09 0961 7379 6e63 5f63  nst..{...async_c
    │ │ │ +00055530: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f  all(&aux::to
    │ │ │ +00055540: 7272 656e 743a 3a6c 7364 5f61 6e6e 6f75  rrent::lsd_annou
    │ │ │ +00055550: 6e63 6529 3b0a 097d 0a0a 3c64 6976 2073  nce);..}..
    .void to │ │ │ +00055590: 7272 656e 745f 6861 6e64 6c65 3a3a 666f rrent_handle::fo │ │ │ +000555a0: 7263 655f 7265 616e 6e6f 756e 6365 2869 rce_reannounce(i │ │ │ +000555b0: 6e74 2063 6f6e 7374 2073 2c20 696e 7420 nt const s, int │ │ │ +000555c0: 636f 6e73 7420 6964 782c 2072 6561 6e6e const idx, reann │ │ │ +000555d0: 6f75 6e63 655f 666c 6167 735f 7420 636f ounce_flags_t co │ │ │ +000555e0: 6e73 7420 666c 6167 7329 2063 6f6e 7374 nst flags) const │ │ │ +000555f0: 0a3c 2f64 6976 3e09 7b0a 0909 6173 796e .
    .{...asyn │ │ │ +00055600: 635f 6361 6c6c 2826 616d 703b 6175 783a c_call(&aux: │ │ │ +00055610: 3a74 6f72 7265 6e74 3a3a 666f 7263 655f :torrent::force_ │ │ │ +00055620: 7472 6163 6b65 725f 7265 7175 6573 742c tracker_request, │ │ │ +00055630: 2061 7578 3a3a 7469 6d65 5f6e 6f77 2829 aux::time_now() │ │ │ +00055640: 202b 2073 6563 6f6e 6473 2873 292c 2069 + seconds(s), i │ │ │ +00055650: 6478 2c20 666c 6167 7329 3b0a 097d 0a0a dx, flags);..}.. │ │ │ +00055660: 0976 6f69 6420 746f 7272 656e 745f 6861 .void torrent_ha │ │ │ +00055670: 6e64 6c65 3a3a 666f 7263 655f 7265 616e ndle::force_rean │ │ │ +00055680: 6e6f 756e 6365 2869 6e74 2063 6f6e 7374 nounce(int const │ │ │ +00055690: 2073 2c20 7374 643a 3a73 7472 696e 6720 s, std::string │ │ │ +000556a0: 636f 6e73 7426 616d 703b 2075 726c 2c20 const& url, │ │ │ +000556b0: 7265 616e 6e6f 756e 6365 5f66 6c61 6773 reannounce_flags │ │ │ +000556c0: 5f74 2063 6f6e 7374 2066 6c61 6773 2920 _t const flags) │ │ │ +000556d0: 636f 6e73 740a 097b 0a09 0961 7379 6e63 const..{...async │ │ │ +000556e0: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a _call(&aux:: │ │ │ +000556f0: 746f 7272 656e 743a 3a66 6f72 6365 5f74 torrent::force_t │ │ │ +00055700: 7261 636b 6572 5f72 6571 7565 7374 5f75 racker_request_u │ │ │ +00055710: 726c 2c20 6175 783a 3a74 696d 655f 6e6f rl, aux::time_no │ │ │ +00055720: 7728 2920 2b20 7365 636f 6e64 7328 7329 w() + seconds(s) │ │ │ +00055730: 2c20 7572 6c2c 2066 6c61 6773 293b 0a09 , url, flags);.. │ │ │ +00055740: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ +00055750: 5f68 616e 646c 653a 3a66 6f72 6365 5f72 _handle::force_r │ │ │ +00055760: 6561 6e6e 6f75 6e63 6528 696e 7420 636f eannounce(int co │ │ │ +00055770: 6e73 7420 732c 2072 6561 6e6e 6f75 6e63 nst s, reannounc │ │ │ +00055780: 655f 666c 6167 735f 7420 636f 6e73 7420 e_flags_t const │ │ │ +00055790: 666c 6167 7329 2063 6f6e 7374 0a09 7b0a flags) const..{. │ │ │ +000557a0: 0909 6173 796e 635f 6361 6c6c 2826 616d ..async_call(&am │ │ │ +000557b0: 703b 6175 783a 3a74 6f72 7265 6e74 3a3a p;aux::torrent:: │ │ │ +000557c0: 666f 7263 655f 7472 6163 6b65 725f 7265 force_tracker_re │ │ │ +000557d0: 7175 6573 742c 2061 7578 3a3a 7469 6d65 quest, aux::time │ │ │ +000557e0: 5f6e 6f77 2829 202b 2073 6563 6f6e 6473 _now() + seconds │ │ │ +000557f0: 2873 292c 202d 312c 2066 6c61 6773 293b (s), -1, flags); │ │ │ +00055800: 0a09 7d0a 0a09 7374 643a 3a76 6563 746f ..}...std::vecto │ │ │ +00055810: 7226 6c74 3b6f 7065 6e5f 6669 6c65 5f73 r<open_file_s │ │ │ +00055820: 7461 7465 2667 743b 2074 6f72 7265 6e74 tate> torrent │ │ │ +00055830: 5f68 616e 646c 653a 3a66 696c 655f 7374 _handle::file_st │ │ │ +00055840: 6174 7573 2829 2063 6f6e 7374 0a09 7b0a atus() const..{. │ │ │ +00055850: 0909 6175 746f 2074 203d 206d 5f74 6f72 ..auto t = m_tor │ │ │ +00055860: 7265 6e74 2e6c 6f63 6b28 293b 0a09 0969 rent.lock();...i │ │ │ +00055870: 6620 2821 7420 7c7c 2021 742d 2667 743b f (!t || !t-> │ │ │ +00055880: 6861 735f 7374 6f72 6167 6528 2929 2072 has_storage()) r │ │ │ +00055890: 6574 7572 6e20 7b7d 3b0a 0909 6175 746f eturn {};...auto │ │ │ +000558a0: 2661 6d70 3b20 7365 7320 3d20 7374 6174 & ses = stat │ │ │ +000558b0: 6963 5f63 6173 7426 6c74 3b73 6573 7369 ic_cast<sessi │ │ │ +000558c0: 6f6e 5f69 6d70 6c26 616d 703b 2667 743b on_impl&> │ │ │ +000558d0: 2874 2d26 6774 3b73 6573 7369 6f6e 2829 (t->session() │ │ │ +000558e0: 293b 0a09 0972 6574 7572 6e20 7365 732e );...return ses. │ │ │ +000558f0: 6469 736b 5f74 6872 6561 6428 292e 6765 disk_thread().ge │ │ │ +00055900: 745f 7374 6174 7573 2874 2d26 6774 3b73 t_status(t->s │ │ │ +00055910: 746f 7261 6765 2829 293b 0a09 7d0a 0a09 torage());..}... │ │ │ +00055920: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +00055930: 646c 653a 3a70 6f73 745f 6669 6c65 5f73 dle::post_file_s │ │ │ +00055940: 7461 7475 7328 2920 636f 6e73 740a 097b tatus() const..{ │ │ │ +00055950: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +00055960: 6d70 3b61 7578 3a3a 746f 7272 656e 743a mp;aux::torrent: │ │ │ +00055970: 3a70 6f73 745f 6669 6c65 5f73 7461 7475 :post_file_statu │ │ │ +00055980: 7329 3b0a 097d 0a0a 0976 6f69 6420 746f s);..}...void to │ │ │ +00055990: 7272 656e 745f 6861 6e64 6c65 3a3a 7363 rrent_handle::sc │ │ │ +000559a0: 7261 7065 5f74 7261 636b 6572 2869 6e74 rape_tracker(int │ │ │ +000559b0: 2069 6478 2920 636f 6e73 740a 097b 0a09 idx) const..{.. │ │ │ +000559c0: 0961 7379 6e63 5f63 616c 6c28 2661 6d70 .async_call(& │ │ │ +000559d0: 3b61 7578 3a3a 746f 7272 656e 743a 3a73 ;aux::torrent::s │ │ │ +000559e0: 6372 6170 655f 7472 6163 6b65 722c 2069 crape_tracker, i │ │ │ +000559f0: 6478 2c20 7472 7565 293b 0a3c 2f70 7265 dx, true);.
    rele │ │ │ +00055a30: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0
    ../src/par │ │ │ +00055a70: 745f 6669 6c65 2e63 7070 3a32 3934 3c2f t_file.cpp:294what │ │ │ +00055a90: 646f 2077 6520 646f 2069 6620 736f 6d65 do we do if some │ │ │ +00055aa0: 6f6e 6520 6973 2063 7572 7265 6e74 6c79 one is currently │ │ │ +00055ab0: 2072 6561 6469 6e67 2066 726f 6d20 7468 reading from th │ │ │ +00055ac0: 6520 6469 736b 2066 726f 6d20 7468 6973 e disk from this │ │ │ +00055ad0: 2070 6965 6365 3f20 646f 6573 2069 7420 piece? does it │ │ │ +00055ae0: 6d61 7474 6572 3f20 5369 6e63 6520 7765 matter? Since we │ │ │ +00055af0: 2077 6f6e 2774 2061 6374 6976 656c 7920 won't actively │ │ │ +00055b00: 6572 6173 6520 7468 6520 6461 7461 2066 erase the data f │ │ │ +00055b10: 726f 6d20 6469 736b 2c20 6275 7420 6974 rom disk, but it │ │ │ +00055b20: 206d 6179 2062 6520 6f76 6572 7772 6974 may be overwrit │ │ │ +00055b30: 7465 6e20 736f 6f6e 2c20 6974 2773 2070 ten soon, it's p │ │ │ +00055b40: 726f 6261 626c 7920 6e6f 7420 7468 6174 robably not that │ │ │ +00055b50: 2062 6967 206f 6620 6120 6465 616c 3c2f big of a deal

    what │ │ │ +00055bb0: 2064 6f20 7765 2064 6f20 6966 2073 6f6d do we do if som │ │ │ +00055bc0: 656f 6e65 2069 7320 6375 7272 656e 746c eone is currentl │ │ │ +00055bd0: 7920 7265 6164 696e 6720 6672 6f6d 2074 y reading from t │ │ │ +00055be0: 6865 2064 6973 6b0a 6672 6f6d 2074 6869 he disk.from thi │ │ │ +00055bf0: 7320 7069 6563 653f 2064 6f65 7320 6974 s piece? does it │ │ │ +00055c00: 206d 6174 7465 723f 2053 696e 6365 2077 matter? Since w │ │ │ +00055c10: 6520 776f 6e27 7420 6163 7469 7665 6c79 e won't actively │ │ │ +00055c20: 2065 7261 7365 2074 6865 0a64 6174 6120 erase the.data │ │ │ +00055c30: 6672 6f6d 2064 6973 6b2c 2062 7574 2069 from disk, but i │ │ │ +00055c40: 7420 6d61 7920 6265 206f 7665 7277 7269 t may be overwri │ │ │ +00055c50: 7474 656e 2073 6f6f 6e2c 2069 7427 7320 tten soon, it's │ │ │ +00055c60: 7072 6f62 6162 6c79 206e 6f74 2074 6861 probably not tha │ │ │ +00055c70: 740a 6269 6720 6f66 2061 2064 6561 6c3c t.big of a deal< │ │ │ +00055c80: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00055c90: 6172 745f 6669 6c65 2e63 7070 3a32 3934 art_file.cpp:294 │ │ │ +00055ca0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00055ce0: 0909 0963 7265 6174 655f 6469 7265 6374  ...create_direct
    │ │ │ +00055cf0: 6f72 6965 7328 6d5f 7061 7468 2c20 6563  ories(m_path, ec
    │ │ │ +00055d00: 293b 0a09 0909 0969 6620 2865 6329 2072  );.....if (ec) r
    │ │ │ +00055d10: 6574 7572 6e20 7b7d 3b0a 0909 0909 7265  eturn {};.....re
    │ │ │ +00055d20: 7475 726e 207b 666e 2c20 302c 206d 6f64  turn {fn, 0, mod
    │ │ │ +00055d30: 657d 3b0a 0909 097d 0a09 0909 7265 7475  e};....}....retu
    │ │ │ +00055d40: 726e 207b 7d3b 0a09 097d 0a09 7d0a 0963  rn {};...}..}..c
    │ │ │ +00055d50: 6174 6368 2028 7374 6f72 6167 655f 6572  atch (storage_er
    │ │ │ +00055d60: 726f 7220 636f 6e73 7426 616d 703b 2065  ror const& e
    │ │ │ +00055d70: 290a 097b 0a09 0965 6320 3d20 652e 6563  )..{...ec = e.ec
    │ │ │ +00055d80: 3b0a 0909 7265 7475 726e 207b 7d3b 0a09  ;...return {};..
    │ │ │ +00055d90: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ +00055da0: 6c65 3a3a 6672 6565 5f70 6965 6365 2870  le::free_piece(p
    │ │ │ +00055db0: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e  iece_index_t con
    │ │ │ +00055dc0: 7374 2070 6965 6365 290a 097b 0a09 0973  st piece)..{...s
    │ │ │ +00055dd0: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c  td::lock_guard&l
    │ │ │ +00055de0: 743b 7374 643a 3a6d 7574 6578 2667 743b  t;std::mutex>
    │ │ │ +00055df0: 206c 286d 5f6d 7574 6578 293b 0a0a 0909   l(m_mutex);....
    │ │ │ +00055e00: 6175 746f 2063 6f6e 7374 2069 203d 206d  auto const i = m
    │ │ │ +00055e10: 5f70 6965 6365 5f6d 6170 2e66 696e 6428  _piece_map.find(
    │ │ │ +00055e20: 7069 6563 6529 3b0a 0909 6966 2028 6920  piece);...if (i 
    │ │ │ +00055e30: 3d3d 206d 5f70 6965 6365 5f6d 6170 2e65  == m_piece_map.e
    │ │ │ +00055e40: 6e64 2829 2920 7265 7475 726e 3b0a 0a3c  nd()) return;..<
    │ │ │ +00055e50: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +00055e60: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00055e70: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">...m_free_slo
    │ │ │ +00055e90: 7473 2e70 7573 685f 6261 636b 2869 2d26  ts.push_back(i-&
    │ │ │ +00055ea0: 6774 3b73 6563 6f6e 6429 3b0a 0909 6d5f  gt;second);...m_
    │ │ │ +00055eb0: 7069 6563 655f 6d61 702e 6572 6173 6528  piece_map.erase(
    │ │ │ +00055ec0: 6929 3b0a 0909 6d5f 6469 7274 795f 6d65  i);...m_dirty_me
    │ │ │ +00055ed0: 7461 6461 7461 203d 2074 7275 653b 0a09  tadata = true;..
    │ │ │ +00055ee0: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ +00055ef0: 6c65 3a3a 6d6f 7665 5f70 6172 7466 696c  le::move_partfil
    │ │ │ +00055f00: 6528 7374 643a 3a73 7472 696e 6720 636f  e(std::string co
    │ │ │ +00055f10: 6e73 7426 616d 703b 2070 6174 682c 2065  nst& path, e
    │ │ │ +00055f20: 7272 6f72 5f63 6f64 6526 616d 703b 2065  rror_code& e
    │ │ │ +00055f30: 6329 0a09 7b0a 0909 7374 643a 3a6c 6f63  c)..{...std::loc
    │ │ │ +00055f40: 6b5f 6775 6172 6426 6c74 3b73 7464 3a3a  k_guard<std::
    │ │ │ +00055f50: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ +00055f60: 7465 7829 3b0a 0a09 0966 6c75 7368 5f6d  tex);....flush_m
    │ │ │ +00055f70: 6574 6164 6174 615f 696d 706c 2865 6329  etadata_impl(ec)
    │ │ │ +00055f80: 3b0a 0909 6966 2028 6563 2920 7265 7475  ;...if (ec) retu
    │ │ │ +00055f90: 726e 3b0a 0a09 0969 6620 2821 6d5f 7069  rn;....if (!m_pi
    │ │ │ +00055fa0: 6563 655f 6d61 702e 656d 7074 7928 2929  ece_map.empty())
    │ │ │ +00055fb0: 0a09 097b 0a09 0909 7374 643a 3a73 7472  ...{....std::str
    │ │ │ +00055fc0: 696e 6720 6f6c 645f 7061 7468 203d 2063  ing old_path = c
    │ │ │ +00055fd0: 6f6d 6269 6e65 5f70 6174 6828 6d5f 7061  ombine_path(m_pa
    │ │ │ +00055fe0: 7468 2c20 6d5f 6e61 6d65 293b 0a09 0909  th, m_name);....
    │ │ │ +00055ff0: 7374 643a 3a73 7472 696e 6720 6e65 775f  std::string new_
    │ │ │ +00056000: 7061 7468 203d 2063 6f6d 6269 6e65 5f70  path = combine_p
    │ │ │ +00056010: 6174 6828 7061 7468 2c20 6d5f 6e61 6d65  ath(path, m_name
    │ │ │ +00056020: 293b 0a0a 0909 0972 656e 616d 6528 6f6c  );.....rename(ol
    │ │ │ +00056030: 645f 7061 7468 2c20 6e65 775f 7061 7468  d_path, new_path
    │ │ │ +00056040: 2c20 6563 293b 0a09 0909 6966 2028 6563  , ec);....if (ec
    │ │ │ +00056050: 203d 3d20 626f 6f73 743a 3a73 7973 7465   == boost::syste
    │ │ │ +00056060: 6d3a 3a65 7272 633a 3a6e 6f5f 7375 6368  m::errc::no_such
    │ │ │ +00056070: 5f66 696c 655f 6f72 5f64 6972 6563 746f  _file_or_directo
    │ │ │ +00056080: 7279 290a 0909 0909 6563 2e63 6c65 6172  ry).....ec.clear
    │ │ │ +00056090: 2829 3b0a 0a09 0909 6966 2028 6563 290a  ();.....if (ec).
    │ │ │ +000560a0: 0909 097b 0a09 0909 0973 746f 7261 6765  ...{.....storage
    │ │ │ +000560b0: 5f65 7272 6f72 2073 653b 0a09 0909 0961  _error se;.....a
    │ │ │ +000560c0: 7578 3a3a 636f 7079 5f66 696c 6528 6f6c  ux::copy_file(ol
    │ │ │ +000560d0: 645f 7061 7468 2c20 6e65 775f 7061 7468  d_path, new_path
    │ │ │ +000560e0: 2c20 7365 293b 0a09 0909 0965 6320 3d20  , se);.....ec = 
    │ │ │ +000560f0: 7365 2e65 633b 0a09 0909 0969 6620 2865  se.ec;.....if (e
    │ │ │ +00056100: 6329 2072 6574 7572 6e3b 0a09 0909 0972  c) return;.....r
    │ │ │ +00056110: 656d 6f76 6528 6f6c 645f 7061 7468 2c20  emove(old_path, 
    │ │ │ +00056120: 6563 293b 0a09 0909 7d0a 0909 7d0a 3c2f  ec);....}...}.r
    │ │ │ +00056160: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +00056170: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ +000561a0: 7061 7274 5f66 696c 652e 6370 703a 3430  part_file.cpp:40
    │ │ │ +000561b0: 353c 2f61 3e3c 2f74 643e 3c74 643e 696e  5in
    │ │ │ +000561c0: 7374 6561 6420 6f66 2072 6562 7569 6c64  stead of rebuild
    │ │ │ +000561d0: 696e 6720 7468 6520 7768 6f6c 6520 6669  ing the whole fi
    │ │ │ +000561e0: 6c65 2068 6561 6465 7220 616e 6420 666c  le header and fl
    │ │ │ +000561f0: 7573 6869 6e67 2069 742c 2075 7064 6174  ushing it, updat
    │ │ │ +00056200: 6520 7468 6520 736c 6f74 2065 6e74 7269  e the slot entri
    │ │ │ +00056210: 6573 2061 7320 7765 2067 6f3c 2f74 643e  es as we go
    │ │ │ +00056220: 3c2f 7472 3e3c 7472 2069 643d 2232 3032  

    instead │ │ │ +00056270: 206f 6620 7265 6275 696c 6469 6e67 2074 of rebuilding t │ │ │ +00056280: 6865 2077 686f 6c65 2066 696c 6520 6865 he whole file he │ │ │ +00056290: 6164 6572 0a61 6e64 2066 6c75 7368 696e ader.and flushin │ │ │ +000562a0: 6720 6974 2c20 7570 6461 7465 2074 6865 g it, update the │ │ │ +000562b0: 2073 6c6f 7420 656e 7472 6965 7320 6173 slot entries as │ │ │ +000562c0: 2077 6520 676f 3c2f 6832 3e3c 6834 3e2e we go

    . │ │ │ +000562d0: 2e2f 7372 632f 7061 7274 5f66 696c 652e ./src/part_file. │ │ │ +000562e0: 6370 703a 3430 353c 2f68 343e 3c70 7265 cpp:405

    ......TORR
    │ │ │ +00056330: 454e 545f 4153 5345 5254 286a 2d26 6774  ENT_ASSERT(j->
    │ │ │ +00056340: 3b73 6563 6f6e 6420 3d3d 2073 6c6f 7429  ;second == slot)
    │ │ │ +00056350: 3b0a 0909 0909 0909 6d5f 6672 6565 5f73  ;.......m_free_s
    │ │ │ +00056360: 6c6f 7473 2e70 7573 685f 6261 636b 286a  lots.push_back(j
    │ │ │ +00056370: 2d26 6774 3b73 6563 6f6e 6429 3b0a 0909  ->second);...
    │ │ │ +00056380: 0909 0909 6d5f 7069 6563 655f 6d61 702e  ....m_piece_map.
    │ │ │ +00056390: 6572 6173 6528 6a29 3b0a 0909 0909 0909  erase(j);.......
    │ │ │ +000563a0: 6d5f 6469 7274 795f 6d65 7461 6461 7461  m_dirty_metadata
    │ │ │ +000563b0: 203d 2074 7275 653b 0a09 0909 0909 7d0a   = true;......}.
    │ │ │ +000563c0: 0909 0909 7d0a 0909 097d 0a09 0909 6669  ....}....}....fi
    │ │ │ +000563d0: 6c65 5f6f 6666 7365 7420 2b3d 2062 6c6f  le_offset += blo
    │ │ │ +000563e0: 636b 5f74 6f5f 636f 7079 3b0a 0909 0970  ck_to_copy;....p
    │ │ │ +000563f0: 6965 6365 5f6f 6666 7365 7420 3d20 303b  iece_offset = 0;
    │ │ │ +00056400: 0a09 0909 7369 7a65 202d 3d20 626c 6f63  ....size -= bloc
    │ │ │ +00056410: 6b5f 746f 5f63 6f70 793b 0a09 097d 0a09  k_to_copy;...}..
    │ │ │ +00056420: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ +00056430: 6c65 3a3a 666c 7573 685f 6d65 7461 6461  le::flush_metada
    │ │ │ +00056440: 7461 2865 7272 6f72 5f63 6f64 6526 616d  ta(error_code&am
    │ │ │ +00056450: 703b 2065 6329 0a09 7b0a 0909 7374 643a  p; ec)..{...std:
    │ │ │ +00056460: 3a6c 6f63 6b5f 6775 6172 6426 6c74 3b73  :lock_guard<s
    │ │ │ +00056470: 7464 3a3a 6d75 7465 7826 6774 3b20 6c28  td::mutex> l(
    │ │ │ +00056480: 6d5f 6d75 7465 7829 3b0a 0a09 0966 6c75  m_mutex);....flu
    │ │ │ +00056490: 7368 5f6d 6574 6164 6174 615f 696d 706c  sh_metadata_impl
    │ │ │ +000564a0: 2865 6329 3b0a 097d 0a0a 3c64 6976 2073  (ec);..}..
    .void pa │ │ │ +000564e0: 7274 5f66 696c 653a 3a66 6c75 7368 5f6d rt_file::flush_m │ │ │ +000564f0: 6574 6164 6174 615f 696d 706c 2865 7272 etadata_impl(err │ │ │ +00056500: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ +00056510: 0a3c 2f64 6976 3e09 7b0a 0909 2f2f 2064 .
    .{...// d │ │ │ +00056520: 6f20 7765 206e 6565 6420 746f 2066 6c75 o we need to flu │ │ │ +00056530: 7368 2074 6865 206d 6574 6164 6174 613f sh the metadata? │ │ │ +00056540: 0a09 0969 6620 286d 5f64 6972 7479 5f6d ...if (m_dirty_m │ │ │ +00056550: 6574 6164 6174 6120 3d3d 2066 616c 7365 etadata == false │ │ │ +00056560: 2920 7265 7475 726e 3b0a 0a09 0969 6620 ) return;....if │ │ │ +00056570: 286d 5f70 6965 6365 5f6d 6170 2e65 6d70 (m_piece_map.emp │ │ │ +00056580: 7479 2829 290a 0909 7b0a 0909 092f 2f20 ty())...{....// │ │ │ +00056590: 6966 2077 6520 646f 6e27 7420 6861 7665 if we don't have │ │ │ +000565a0: 2061 6e79 2070 6965 6365 7320 6c65 6674 any pieces left │ │ │ +000565b0: 2069 6e20 7468 650a 0909 092f 2f20 7061 in the....// pa │ │ │ +000565c0: 7274 2066 696c 652c 2072 656d 6f76 6520 rt file, remove │ │ │ +000565d0: 6974 0a09 0909 7374 643a 3a73 7472 696e it....std::strin │ │ │ +000565e0: 6720 636f 6e73 7420 7020 3d20 636f 6d62 g const p = comb │ │ │ +000565f0: 696e 655f 7061 7468 286d 5f70 6174 682c ine_path(m_path, │ │ │ +00056600: 206d 5f6e 616d 6529 3b0a 0909 0972 656d m_name);....rem │ │ │ +00056610: 6f76 6528 702c 2065 6329 3b0a 0a09 0909 ove(p, ec);..... │ │ │ +00056620: 6966 2028 6563 203d 3d20 626f 6f73 743a if (ec == boost: │ │ │ +00056630: 3a73 7973 7465 6d3a 3a65 7272 633a 3a6e :system::errc::n │ │ │ +00056640: 6f5f 7375 6368 5f66 696c 655f 6f72 5f64 o_such_file_or_d │ │ │ +00056650: 6972 6563 746f 7279 290a 0909 0909 6563 irectory).....ec │ │ │ +00056660: 2e63 6c65 6172 2829 3b0a 0909 0972 6574 .clear();....ret │ │ │ +00056670: 7572 6e3b 0a09 097d 0a0a 0909 6175 746f urn;...}....auto │ │ │ +00056680: 2066 203d 206f 7065 6e5f 6669 6c65 2861 f = open_file(a │ │ │ +00056690: 7578 3a3a 6f70 656e 5f6d 6f64 653a 3a77 ux::open_mode::w │ │ │ +000566a0: 7269 7465 207c 2061 7578 3a3a 6f70 656e rite | aux::open │ │ │ +000566b0: 5f6d 6f64 653a 3a68 6964 6465 6e2c 2065 _mode::hidden, e │ │ │ +000566c0: 6329 3b0a 0909 6966 2028 6563 2920 7265 c);...if (ec) re │ │ │ +000566d0: 7475 726e 3b0a 0a09 0973 7464 3a3a 7665 turn;....std::ve │ │ │ +000566e0: 6374 6f72 266c 743b 6368 6172 2667 743b ctor<char> │ │ │ +000566f0: 2068 6561 6465 7228 7374 6174 6963 5f63 header(static_c │ │ │ +00056700: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ +00056710: 5f74 2667 743b 286d 5f68 6561 6465 725f _t>(m_header_ │ │ │ +00056720: 7369 7a65 2929 3b0a 0a09 0975 7369 6e67 size));....using │ │ │ +00056730: 206e 616d 6573 7061 6365 206c 6962 746f namespace libto │ │ │ +00056740: 7272 656e 743a 3a61 7578 3b0a 0a09 0963 rrent::aux;....c │ │ │ +00056750: 6861 722a 2070 7472 203d 2068 6561 6465 har* ptr = heade │ │ │ +00056760: 722e 6461 7461 2829 3b0a 0909 7772 6974 r.data();...writ │ │ │ +00056770: 655f 7569 6e74 3332 286d 5f6d 6178 5f70 e_uint32(m_max_p │ │ │ +00056780: 6965 6365 732c 2070 7472 293b 0a09 0977 ieces, ptr);...w │ │ │ +00056790: 7269 7465 5f75 696e 7433 3228 6d5f 7069 rite_uint32(m_pi │ │ │ +000567a0: 6563 655f 7369 7a65 2c20 7074 7229 3b0a ece_size, ptr);. │ │ │ +000567b0: 0a09 0966 6f72 2028 7069 6563 655f 696e ...for (piece_in │ │ │ +000567c0: 6465 785f 7420 7069 6563 6528 3029 3b20 dex_t piece(0); │ │ │ +000567d0: 7069 6563 6520 266c 743b 2070 6965 6365 piece < piece │ │ │ +000567e0: 5f69 6e64 6578 5f74 286d 5f6d 6178 5f70 _index_t(m_max_p │ │ │ +000567f0: 6965 6365 7329 3b20 2b2b 7069 6563 6529 ieces); ++piece) │ │ │ +00056800: 0a09 097b 0a09 0909 6175 746f 2063 6f6e ...{....auto con │ │ │ +00056810: 7374 2069 203d 206d 5f70 6965 6365 5f6d st i = m_piece_m │ │ │ +00056820: 6170 2e66 696e 6428 7069 6563 6529 3b0a ap.find(piece);. │ │ │ +00056830: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00056840: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00056870: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +000568a0: 632f 6164 645f 746f 7272 656e 745f 7061 c/add_torrent_pa │ │ │ +000568b0: 7261 6d73 2e63 7070 3a33 313c 2f61 3e3c rams.cpp:31< │ │ │ +000568c0: 2f74 643e 3c74 643e 6974 2077 6f75 6c64 /td>it would │ │ │ +000568d0: 2062 6520 6e69 6365 2069 6620 7468 6973 be nice if this │ │ │ +000568e0: 2077 6173 206e 6f74 6872 6f77 2064 6566 was nothrow def │ │ │ +000568f0: 6175 6c74 2063 6f6e 7374 7275 6374 6962 ault constructib │ │ │ +00056900: 6c65 2073 7461 7469 635f 6173 7365 7274 le static_assert │ │ │ +00056910: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77 (std::is_nothrow │ │ │ +00056920: 5f64 6566 6175 6c74 5f63 6f6e 7374 7275 _default_constru │ │ │ +00056930: 6374 6962 6c65 3c61 6464 5f74 6f72 7265 ctible::valu │ │ │ +00056950: 6520 2c20 2273 686f 756c 6420 6265 206e e , "should be n │ │ │ +00056960: 6f74 6872 6f77 2064 6566 6175 6c74 2063 othrow default c │ │ │ +00056970: 6f6e 7374 7275 6374 6962 6c65 2229 3b3c onstructible");< │ │ │ +00056980: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +000569d0: 776f 756c 6420 6265 206e 6963 6520 6966 would be nice if │ │ │ +000569e0: 2074 6869 7320 7761 7320 6e6f 7468 726f this was nothro │ │ │ +000569f0: 7720 6465 6661 756c 7420 636f 6e73 7472 w default constr │ │ │ +00056a00: 7563 7469 626c 650a 7374 6174 6963 5f61 uctible.static_a │ │ │ +00056a10: 7373 6572 7428 7374 643a 3a69 735f 6e6f ssert(std::is_no │ │ │ +00056a20: 7468 726f 775f 6465 6661 756c 745f 636f throw_default_co │ │ │ +00056a30: 6e73 7472 7563 7469 626c 653c 6164 645f nstructible: │ │ │ +00056a50: 3a76 616c 7565 0a2c 2022 7368 6f75 6c64 :value., "should │ │ │ +00056a60: 2062 6520 6e6f 7468 726f 7720 6465 6661 be nothrow defa │ │ │ +00056a70: 756c 7420 636f 6e73 7472 7563 7469 626c ult constructibl │ │ │ +00056a80: 6522 293b 3c2f 6832 3e3c 6834 3e2e 2e2f e");

    ../ │ │ │ +00056a90: 7372 632f 6164 645f 746f 7272 656e 745f src/add_torrent_ │ │ │ +00056aa0: 7061 7261 6d73 2e63 7070 3a33 313c 2f68 params.cpp:31
    #inc
    │ │ │ +00056af0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ +00056b00: 2f61 6464 5f74 6f72 7265 6e74 5f70 6172  /add_torrent_par
    │ │ │ +00056b10: 616d 732e 6870 7022 0a0a 6e61 6d65 7370  ams.hpp"..namesp
    │ │ │ +00056b20: 6163 6520 6c69 6274 6f72 7265 6e74 207b  ace libtorrent {
    │ │ │ +00056b30: 0a0a 0961 6464 5f74 6f72 7265 6e74 5f70  ...add_torrent_p
    │ │ │ +00056b40: 6172 616d 733a 3a61 6464 5f74 6f72 7265  arams::add_torre
    │ │ │ +00056b50: 6e74 5f70 6172 616d 7328 2920 3d20 6465  nt_params() = de
    │ │ │ +00056b60: 6661 756c 743b 0a09 6164 645f 746f 7272  fault;..add_torr
    │ │ │ +00056b70: 656e 745f 7061 7261 6d73 3a3a 7e61 6464  ent_params::~add
    │ │ │ +00056b80: 5f74 6f72 7265 6e74 5f70 6172 616d 7328  _torrent_params(
    │ │ │ +00056b90: 2920 3d20 6465 6661 756c 743b 0a09 6164  ) = default;..ad
    │ │ │ +00056ba0: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00056bb0: 3a3a 6164 645f 746f 7272 656e 745f 7061  ::add_torrent_pa
    │ │ │ +00056bc0: 7261 6d73 2861 6464 5f74 6f72 7265 6e74  rams(add_torrent
    │ │ │ +00056bd0: 5f70 6172 616d 7326 616d 703b 2661 6d70  _params&&
    │ │ │ +00056be0: 3b29 206e 6f65 7863 6570 7420 3d20 6465  ;) noexcept = de
    │ │ │ +00056bf0: 6661 756c 743b 0a09 6164 645f 746f 7272  fault;..add_torr
    │ │ │ +00056c00: 656e 745f 7061 7261 6d73 2661 6d70 3b20  ent_params& 
    │ │ │ +00056c10: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ +00056c20: 6d73 3a3a 6f70 6572 6174 6f72 3d28 6164  ms::operator=(ad
    │ │ │ +00056c30: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00056c40: 2661 6d70 3b26 616d 703b 2920 2661 6d70  &&) &
    │ │ │ +00056c50: 3b20 6e6f 6578 6365 7074 203d 2064 6566  ; noexcept = def
    │ │ │ +00056c60: 6175 6c74 3b0a 0961 6464 5f74 6f72 7265  ault;..add_torre
    │ │ │ +00056c70: 6e74 5f70 6172 616d 733a 3a61 6464 5f74  nt_params::add_t
    │ │ │ +00056c80: 6f72 7265 6e74 5f70 6172 616d 7328 6164  orrent_params(ad
    │ │ │ +00056c90: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00056ca0: 2063 6f6e 7374 2661 6d70 3b29 203d 2064   const&) = d
    │ │ │ +00056cb0: 6566 6175 6c74 3b0a 0961 6464 5f74 6f72  efault;..add_tor
    │ │ │ +00056cc0: 7265 6e74 5f70 6172 616d 7326 616d 703b  rent_params&
    │ │ │ +00056cd0: 2061 6464 5f74 6f72 7265 6e74 5f70 6172   add_torrent_par
    │ │ │ +00056ce0: 616d 733a 3a6f 7065 7261 746f 723d 2861  ams::operator=(a
    │ │ │ +00056cf0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +00056d00: 7320 636f 6e73 7426 616d 703b 2920 2661  s const&) &a
    │ │ │ +00056d10: 6d70 3b20 3d20 6465 6661 756c 743b 0a0a  mp; = default;..
    │ │ │ +00056d20: 0973 7461 7469 635f 6173 7365 7274 2873  .static_assert(s
    │ │ │ +00056d30: 7464 3a3a 6973 5f6e 6f74 6872 6f77 5f6d  td::is_nothrow_m
    │ │ │ +00056d40: 6f76 655f 636f 6e73 7472 7563 7469 626c  ove_constructibl
    │ │ │ +00056d50: 6526 6c74 3b61 6464 5f74 6f72 7265 6e74  e<add_torrent
    │ │ │ +00056d60: 5f70 6172 616d 7326 6774 3b3a 3a76 616c  _params>::val
    │ │ │ +00056d70: 7565 0a09 092c 2022 7368 6f75 6c64 2062  ue..., "should b
    │ │ │ +00056d80: 6520 6e6f 7468 726f 7720 6d6f 7665 2063  e nothrow move c
    │ │ │ +00056d90: 6f6e 7374 7275 6374 6962 6c65 2229 3b0a  onstructible");.
    │ │ │ +00056da0: 0a09 7374 6174 6963 5f61 7373 6572 7428  ..static_assert(
    │ │ │ +00056db0: 7374 643a 3a69 735f 6e6f 7468 726f 775f  std::is_nothrow_
    │ │ │ +00056dc0: 6d6f 7665 5f63 6f6e 7374 7275 6374 6962  move_constructib
    │ │ │ +00056dd0: 6c65 266c 743b 7374 643a 3a73 7472 696e  le<std::strin
    │ │ │ +00056de0: 6726 6774 3b3a 3a76 616c 7565 0a09 092c  g>::value...,
    │ │ │ +00056df0: 2022 7368 6f75 6c64 2062 6520 6e6f 7468   "should be noth
    │ │ │ +00056e00: 726f 7720 6d6f 7665 2063 6f6e 7374 7275  row move constru
    │ │ │ +00056e10: 6374 6962 6c65 2229 3b0a 0a09 7374 6174  ctible");...stat
    │ │ │ +00056e20: 6963 5f61 7373 6572 7428 7374 643a 3a69  ic_assert(std::i
    │ │ │ +00056e30: 735f 6e6f 7468 726f 775f 6d6f 7665 5f61  s_nothrow_move_a
    │ │ │ +00056e40: 7373 6967 6e61 626c 6526 6c74 3b61 6464  ssignable<add
    │ │ │ +00056e50: 5f74 6f72 7265 6e74 5f70 6172 616d 7326  _torrent_params&
    │ │ │ +00056e60: 6774 3b3a 3a76 616c 7565 0a09 092c 2022  gt;::value..., "
    │ │ │ +00056e70: 7368 6f75 6c64 2062 6520 6e6f 7468 726f  should be nothro
    │ │ │ +00056e80: 7720 6d6f 7665 2061 7373 6967 6e61 626c  w move assignabl
    │ │ │ +00056e90: 6522 293b 0a0a 3c64 6976 2073 7479 6c65  e");..
    .
    names │ │ │ +00056ed0: 7061 6365 2061 7578 207b 0a0a 092f 2f20 pace aux {...// │ │ │ +00056ee0: 7265 7475 726e 7320 7768 6574 6865 7220 returns whether │ │ │ +00056ef0: 7468 6973 2061 6464 5f74 6f72 7265 6e74 this add_torrent │ │ │ +00056f00: 5f70 6172 616d 7320 6f62 6a65 6374 2068 _params object h │ │ │ +00056f10: 6173 2022 7265 7375 6d65 2d64 6174 6122 as "resume-data" │ │ │ +00056f20: 2c20 692e 652e 0a09 2f2f 2069 6e66 6f72 , i.e...// infor │ │ │ +00056f30: 6d61 7469 6f6e 2061 626f 7574 2077 6869 mation about whi │ │ │ +00056f40: 6368 2070 6965 6365 7320 7765 2068 6176 ch pieces we hav │ │ │ +00056f50: 652e 0a09 626f 6f6c 2063 6f6e 7461 696e e...bool contain │ │ │ +00056f60: 735f 7265 7375 6d65 5f64 6174 6128 6164 s_resume_data(ad │ │ │ +00056f70: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +00056f80: 2063 6f6e 7374 2661 6d70 3b20 6174 7029 const& atp) │ │ │ +00056f90: 0a09 7b0a 0909 7265 7475 726e 2021 6174 ..{...return !at │ │ │ +00056fa0: 702e 6861 7665 5f70 6965 6365 732e 656d p.have_pieces.em │ │ │ +00056fb0: 7074 7928 290a 0909 097c 7c20 2861 7470 pty()....|| (atp │ │ │ +00056fc0: 2e66 6c61 6773 2026 616d 703b 2074 6f72 .flags & tor │ │ │ +00056fd0: 7265 6e74 5f66 6c61 6773 3a3a 7365 6564 rent_flags::seed │ │ │ +00056fe0: 5f6d 6f64 6529 3b0a 097d 0a7d 0a0a 7d0a _mode);..}.}..}. │ │ │ +00056ff0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00057000: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00057030: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00057060: 632f 6368 6f6b 6572 2e63 7070 3a32 3335 c/choker.cpp:235 │ │ │ +00057070: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ +00057080: 6520 636f 6e66 6967 7572 6162 6c65 3c2f e configurable

    make │ │ │ +000570e0: 2063 6f6e 6669 6775 7261 626c 653c 2f68 configurable

    ../src/cho │ │ │ +00057100: 6b65 722e 6370 703a 3233 353c 2f68 343e ker.cpp:235

    │ │ │ +00057110: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...// 
    │ │ │ +00057150: 6669 7273 7420 7265 7365 7420 7468 6520  first reset the 
    │ │ │ +00057160: 6e75 6d62 6572 206f 6620 756e 6368 6f6b  number of unchok
    │ │ │ +00057170: 6520 736c 6f74 732c 2062 6563 6175 7365  e slots, because
    │ │ │ +00057180: 2077 6527 6c6c 2063 616c 6375 6c61 7465   we'll calculate
    │ │ │ +00057190: 0a09 0909 2f2f 2069 7420 7075 7265 6c79  ....// it purely
    │ │ │ +000571a0: 2062 6173 6564 206f 6e20 7468 6520 6375   based on the cu
    │ │ │ +000571b0: 7272 656e 7420 7374 6174 6520 6f66 206f  rrent state of o
    │ │ │ +000571c0: 7572 2070 6565 7273 2e0a 0909 0975 706c  ur peers.....upl
    │ │ │ +000571d0: 6f61 645f 736c 6f74 7320 3d20 303b 0a0a  oad_slots = 0;..
    │ │ │ +000571e0: 0909 0969 6e74 2072 6174 655f 7468 7265  ...int rate_thre
    │ │ │ +000571f0: 7368 6f6c 6420 3d20 7365 7474 2e67 6574  shold = sett.get
    │ │ │ +00057200: 5f69 6e74 2873 6574 7469 6e67 735f 7061  _int(settings_pa
    │ │ │ +00057210: 636b 3a3a 7261 7465 5f63 686f 6b65 725f  ck::rate_choker_
    │ │ │ +00057220: 696e 6974 6961 6c5f 7468 7265 7368 6f6c  initial_threshol
    │ │ │ +00057230: 6429 3b0a 0a09 0909 7374 643a 3a73 6f72  d);.....std::sor
    │ │ │ +00057240: 7428 7065 6572 732e 6265 6769 6e28 292c  t(peers.begin(),
    │ │ │ +00057250: 2070 6565 7273 2e65 6e64 2829 0a09 0909   peers.end()....
    │ │ │ +00057260: 092c 205b 5d28 7065 6572 5f63 6f6e 6e65  ., [](peer_conne
    │ │ │ +00057270: 6374 696f 6e20 636f 6e73 742a 206c 6873  ction const* lhs
    │ │ │ +00057280: 2c20 7065 6572 5f63 6f6e 6e65 6374 696f  , peer_connectio
    │ │ │ +00057290: 6e20 636f 6e73 742a 2072 6873 290a 0909  n const* rhs)...
    │ │ │ +000572a0: 0909 7b20 7265 7475 726e 2075 706c 6f61  ..{ return uploa
    │ │ │ +000572b0: 645f 7261 7465 5f63 6f6d 7061 7265 286c  d_rate_compare(l
    │ │ │ +000572c0: 6873 2c20 7268 7329 3b20 7d29 3b0a 0a09  hs, rhs); });...
    │ │ │ +000572d0: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +000572e0: 742a 2070 203a 2070 6565 7273 290a 0909  t* p : peers)...
    │ │ │ +000572f0: 097b 0a09 0909 0969 6e74 2063 6f6e 7374  .{.....int const
    │ │ │ +00057300: 2072 6174 6520 3d20 696e 7428 702d 2667   rate = int(p-&g
    │ │ │ +00057310: 743b 7570 6c6f 6164 6564 5f69 6e5f 6c61  t;uploaded_in_la
    │ │ │ +00057320: 7374 5f72 6f75 6e64 2829 0a09 0909 0909  st_round()......
    │ │ │ +00057330: 2a20 3130 3030 202f 2074 6f74 616c 5f6d  * 1000 / total_m
    │ │ │ +00057340: 696c 6c69 7365 636f 6e64 7328 756e 6368  illiseconds(unch
    │ │ │ +00057350: 6f6b 655f 696e 7465 7276 616c 2929 3b0a  oke_interval));.
    │ │ │ +00057360: 0a09 0909 092f 2f20 616c 7761 7973 2068  .....// always h
    │ │ │ +00057370: 6176 6520 6174 206c 6561 7374 2031 2075  ave at least 1 u
    │ │ │ +00057380: 6e63 686f 6b65 2073 6c6f 740a 0909 0909  nchoke slot.....
    │ │ │ +00057390: 6966 2028 7261 7465 2026 6c74 3b20 7261  if (rate < ra
    │ │ │ +000573a0: 7465 5f74 6872 6573 686f 6c64 2920 6272  te_threshold) br
    │ │ │ +000573b0: 6561 6b3b 0a0a 0909 0909 2b2b 7570 6c6f  eak;......++uplo
    │ │ │ +000573c0: 6164 5f73 6c6f 7473 3b0a 0a3c 6469 7620  ad_slots;..
    ....rat │ │ │ +00057400: 655f 7468 7265 7368 6f6c 6420 2b3d 2032 e_threshold += 2 │ │ │ +00057410: 3034 383b 0a3c 2f64 6976 3e09 0909 7d0a 048;.
    ...}. │ │ │ +00057420: 0909 092b 2b75 706c 6f61 645f 736c 6f74 ...++upload_slot │ │ │ +00057430: 733b 0a09 097d 0a0a 0909 2f2f 2073 6f72 s;...}....// sor │ │ │ +00057440: 7473 2074 6865 2070 6565 7273 2074 6861 ts the peers tha │ │ │ +00057450: 7420 6172 6520 656c 6967 6962 6c65 2066 t are eligible f │ │ │ +00057460: 6f72 2075 6e63 686f 6b65 2062 7920 646f or unchoke by do │ │ │ +00057470: 776e 6c6f 6164 2072 6174 6520 616e 640a wnload rate and. │ │ │ +00057480: 0909 2f2f 2073 6563 6f6e 6461 7279 2062 ..// secondary b │ │ │ +00057490: 7920 746f 7461 6c20 7570 6c6f 6164 2e20 y total upload. │ │ │ +000574a0: 5468 6520 7265 6173 6f6e 2066 6f72 2074 The reason for t │ │ │ +000574b0: 6869 7320 6973 2c20 6966 2061 6c6c 2074 his is, if all t │ │ │ +000574c0: 6f72 7265 6e74 7320 6172 650a 0909 2f2f orrents are...// │ │ │ +000574d0: 2062 6569 6e67 2073 6565 6465 642c 2074 being seeded, t │ │ │ +000574e0: 6865 2064 6f77 6e6c 6f61 6420 7261 7465 he download rate │ │ │ +000574f0: 2077 696c 6c20 6265 2030 2c20 616e 6420 will be 0, and │ │ │ +00057500: 7468 6520 7065 6572 7320 7765 2068 6176 the peers we hav │ │ │ +00057510: 6520 7365 6e74 0a09 092f 2f20 7468 6520 e sent...// the │ │ │ +00057520: 6c65 6173 7420 746f 2073 686f 756c 6420 least to should │ │ │ +00057530: 6265 2075 6e63 686f 6b65 640a 0a09 092f be unchoked..../ │ │ │ +00057540: 2f20 7765 2075 7365 2070 6172 7469 616c / we use partial │ │ │ +00057550: 2073 6f72 7420 6865 7265 2c20 6265 6361 sort here, beca │ │ │ +00057560: 7573 6520 7765 206f 6e6c 7920 6361 7265 use we only care │ │ │ +00057570: 2061 626f 7574 2074 6865 2074 6f70 0a09 about the top.. │ │ │ +00057580: 092f 2f20 7570 6c6f 6164 5f73 6c6f 7473 .// upload_slots │ │ │ +00057590: 2070 6565 7273 2e0a 0a09 0969 6e74 2063 peers.....int c │ │ │ +000575a0: 6f6e 7374 2073 6c6f 7473 203d 2073 7464 onst slots = std │ │ │ +000575b0: 3a3a 6d69 6e28 7570 6c6f 6164 5f73 6c6f ::min(upload_slo │ │ │ +000575c0: 7473 2c20 696e 7428 7065 6572 732e 7369 ts, int(peers.si │ │ │ +000575d0: 7a65 2829 2929 3b0a 0909 696e 7420 636f ze()));...int co │ │ │ +000575e0: 6e73 7420 7365 6564 5f63 686f 6b65 203d nst seed_choke = │ │ │ +000575f0: 2073 6574 742e 6765 745f 696e 7428 7365 sett.get_int(se │ │ │ +00057600: 7474 696e 6773 5f70 6163 6b3a 3a73 6565 ttings_pack::see │ │ │ +00057610: 645f 6368 6f6b 696e 675f 616c 676f 7269 d_choking_algori │ │ │ +00057620: 7468 6d29 3b0a 0a09 0969 6620 2873 6565 thm);....if (see │ │ │ +00057630: 645f 6368 6f6b 6520 3d3d 2073 6574 7469 d_choke == setti │ │ │ +00057640: 6e67 735f 7061 636b 3a3a 6661 7374 6573 ngs_pack::fastes │ │ │ +00057650: 745f 7570 6c6f 6164 290a 0909 7b0a 0909 t_upload)...{... │ │ │ +00057660: 0973 7464 3a3a 6e74 685f 656c 656d 656e .std::nth_elemen │ │ │ +00057670: 7428 7065 6572 732e 6265 6769 6e28 292c t(peers.begin(), │ │ │ +00057680: 2070 6565 7273 2e62 6567 696e 2829 0a09 peers.begin().. │ │ │ +00057690: 0909 092b 2073 6c6f 7473 2c20 7065 6572 ...+ slots, peer │ │ │ +000576a0: 732e 656e 6428 290a 0909 0909 2c20 5b5d s.end()....., [] │ │ │ +000576b0: 2870 6565 725f 636f 6e6e 6563 7469 6f6e (peer_connection │ │ │ +000576c0: 2063 6f6e 7374 2a20 6c68 732c 2070 6565 const* lhs, pee │ │ │ +000576d0: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e r_connection con │ │ │ +000576e0: 7374 2a20 7268 7329 0a09 0909 097b 2072 st* rhs).....{ r │ │ │ +000576f0: 6574 7572 6e20 756e 6368 6f6b 655f 636f eturn unchoke_co │ │ │ +00057700: 6d70 6172 655f 6661 7374 6573 745f 7570 mpare_fastest_up │ │ │ +00057710: 6c6f 6164 286c 6873 2c20 7268 7329 3b20 load(lhs, rhs); │ │ │ +00057720: 7d29 3b0a 0909 7d0a 0909 656c 7365 2069 });...}...else i │ │ │ +00057730: 6620 2873 6565 645f 6368 6f6b 6520 3d3d f (seed_choke == │ │ │ +00057740: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ +00057750: 616e 7469 5f6c 6565 6368 290a 0909 7b0a anti_leech)...{. │ │ │ +00057760: 0909 0973 7464 3a3a 6e74 685f 656c 656d ...std::nth_elem │ │ │ +00057770: 656e 7428 7065 6572 732e 6265 6769 6e28 ent(peers.begin( │ │ │ +00057780: 292c 2070 6565 7273 2e62 6567 696e 2829 ), peers.begin() │ │ │ +00057790: 0a09 0909 092b 2073 6c6f 7473 2c20 7065 .....+ slots, pe │ │ │ +000577a0: 6572 732e 656e 6428 290a 0909 0909 2c20 ers.end()....., │ │ │ +000577b0: 5b5d 2870 6565 725f 636f 6e6e 6563 7469 [](peer_connecti │ │ │ +000577c0: 6f6e 2063 6f6e 7374 2a20 6c68 732c 2070 on const* lhs, p │ │ │ +000577d0: 6565 725f 636f 6e6e 6563 7469 6f6e 2063 eer_connection c │ │ │ +000577e0: 6f6e 7374 2a20 7268 7329 0a09 0909 097b onst* rhs).....{ │ │ │ +000577f0: 2072 6574 7572 6e20 756e 6368 6f6b 655f return unchoke_ │ │ │ +00057800: 636f 6d70 6172 655f 616e 7469 5f6c 6565 compare_anti_lee │ │ │ +00057810: 6368 286c 6873 2c20 7268 7329 3b20 7d29 ch(lhs, rhs); }) │ │ │ +00057820: 3b0a 0909 7d0a 0909 656c 7365 0a3c 2f70 ;...}...else.

    re │ │ │ +00057860: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ +000578a0: 6572 6b6c 655f 7472 6565 2e63 7070 3a38 erkle_tree.cpp:8 │ │ │ +000578b0: 383c 2f61 3e3c 2f74 643e 3c74 643e 696e 8in │ │ │ +000578c0: 2043 2b2b 3230 2c20 7573 6520 7374 643a C++20, use std: │ │ │ +000578d0: 3a69 6465 6e74 6974 793c 2f74 643e 3c2f :identity

    in C++20, │ │ │ +00057930: 2075 7365 2073 7464 3a3a 6964 656e 7469 use std::identi │ │ │ +00057940: 7479 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ty

    ../sr │ │ │ +00057950: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ +00057960: 703a 3838 3c2f 6834 3e3c 7072 6520 7374 p:88

    ..allocate_fu
    │ │ │ +000579b0: 6c6c 2829 3b0a 0a09 096d 6572 6b6c 655f  ll();....merkle_
    │ │ │ +000579c0: 7661 6c69 6461 7465 5f63 6f70 7928 742c  validate_copy(t,
    │ │ │ +000579d0: 206d 5f74 7265 652c 2072 6f6f 7428 292c   m_tree, root(),
    │ │ │ +000579e0: 206d 5f62 6c6f 636b 5f76 6572 6966 6965   m_block_verifie
    │ │ │ +000579f0: 6429 3b0a 0a09 096c 6f61 645f 7665 7269  d);....load_veri
    │ │ │ +00057a00: 6669 6564 5f62 6974 7328 7665 7269 6669  fied_bits(verifi
    │ │ │ +00057a10: 6564 293b 0a0a 0909 6f70 7469 6d69 7a65  ed);....optimize
    │ │ │ +00057a20: 5f73 746f 7261 6765 2829 3b0a 0909 6f70  _storage();...op
    │ │ │ +00057a30: 7469 6d69 7a65 5f73 746f 7261 6765 5f70  timize_storage_p
    │ │ │ +00057a40: 6965 6365 5f6c 6179 6572 2829 3b0a 097d  iece_layer();..}
    │ │ │ +00057a50: 0a0a 0976 6f69 6420 6d65 726b 6c65 5f74  ...void merkle_t
    │ │ │ +00057a60: 7265 653a 3a63 6c65 6172 2829 0a09 7b0a  ree::clear()..{.
    │ │ │ +00057a70: 0909 6d5f 7472 6565 2e63 6c65 6172 2829  ..m_tree.clear()
    │ │ │ +00057a80: 3b0a 0909 6d5f 7472 6565 2e73 6872 696e  ;...m_tree.shrin
    │ │ │ +00057a90: 6b5f 746f 5f66 6974 2829 3b0a 0909 6d5f  k_to_fit();...m_
    │ │ │ +00057aa0: 626c 6f63 6b5f 7665 7269 6669 6564 2e63  block_verified.c
    │ │ │ +00057ab0: 6c65 6172 2829 3b0a 0909 6d5f 6d6f 6465  lear();...m_mode
    │ │ │ +00057ac0: 203d 206d 6f64 655f 743a 3a65 6d70 7479   = mode_t::empty
    │ │ │ +00057ad0: 5f74 7265 653b 0a09 7d0a 0a6e 616d 6573  _tree;..}..names
    │ │ │ +00057ae0: 7061 6365 207b 0a0a 3c64 6976 2073 7479  pace {..
    .struct id │ │ │ +00057b20: 656e 7469 7479 0a3c 2f64 6976 3e09 7b0a entity.
    .{. │ │ │ +00057b30: 0909 626f 6f6c 206f 7065 7261 746f 7228 ..bool operator( │ │ │ +00057b40: 2928 626f 6f6c 2062 2920 636f 6e73 7420 )(bool b) const │ │ │ +00057b50: 7b20 7265 7475 726e 2062 3b20 7d0a 097d { return b; }..} │ │ │ +00057b60: 3b0a 7d0a 0a09 766f 6964 206d 6572 6b6c ;.}...void merkl │ │ │ +00057b70: 655f 7472 6565 3a3a 6c6f 6164 5f73 7061 e_tree::load_spa │ │ │ +00057b80: 7273 655f 7472 6565 2873 7061 6e26 6c74 rse_tree(span< │ │ │ +00057b90: 3b73 6861 3235 365f 6861 7368 2063 6f6e ;sha256_hash con │ │ │ +00057ba0: 7374 2667 743b 2074 0a09 092c 2062 6974 st> t..., bit │ │ │ +00057bb0: 6669 656c 6420 636f 6e73 7426 616d 703b field const& │ │ │ +00057bc0: 206d 6173 6b0a 0909 2c20 6269 7466 6965 mask..., bitfie │ │ │ +00057bd0: 6c64 2063 6f6e 7374 2661 6d70 3b20 7665 ld const& ve │ │ │ +00057be0: 7269 6669 6564 290a 097b 0a09 0949 4e56 rified)..{...INV │ │ │ +00057bf0: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09 ARIANT_CHECK;... │ │ │ +00057c00: 092f 2f20 5468 6520 7369 7a65 206f 6620 .// The size of │ │ │ +00057c10: 7468 6520 6d61 736b 2073 686f 756c 6420 the mask should │ │ │ +00057c20: 6e6f 7420 6578 6365 6564 2074 6865 2073 not exceed the s │ │ │ +00057c30: 697a 6520 6f66 2074 6865 2074 7265 652c ize of the tree, │ │ │ +00057c40: 2062 7574 2061 206d 6173 6b20 6c61 7267 but a mask larg │ │ │ +00057c50: 6572 2074 6861 6e0a 0909 2f2f 2074 6865 er than...// the │ │ │ +00057c60: 2074 7265 6520 6361 6e20 6265 2065 6e63 tree can be enc │ │ │ +00057c70: 6f75 6e74 6572 6564 2069 6e20 7468 6520 ountered in the │ │ │ +00057c80: 2272 6573 756d 6520 6461 7461 2220 666f "resume data" fo │ │ │ +00057c90: 7220 736f 6d65 2072 6561 736f 6e2c 2070 r some reason, p │ │ │ +00057ca0: 6572 6861 7073 2074 6865 7265 2069 730a erhaps there is. │ │ │ +00057cb0: 0909 2f2f 2061 2062 7567 2069 6e20 7468 ..// a bug in th │ │ │ +00057cc0: 6520 2272 6573 756d 6520 6461 7461 2220 e "resume data" │ │ │ +00057cd0: 6765 6e65 7261 7469 6f6e 2061 6c67 6f72 generation algor │ │ │ +00057ce0: 6974 686d 2e0a 0909 2f2f 2053 6f20 7765 ithm....// So we │ │ │ +00057cf0: 206a 7573 7420 7072 6f63 6573 7320 6d61 just process ma │ │ │ +00057d00: 736b 2069 7465 6d73 2063 6f75 6e74 2075 sk items count u │ │ │ +00057d10: 7020 746f 2074 7265 6520 7369 7a65 2e0a p to tree size.. │ │ │ +00057d20: 0909 696e 7420 636f 6e73 7420 6d61 736b ..int const mask │ │ │ +00057d30: 5f73 697a 6520 3d20 7374 643a 3a6d 696e _size = std::min │ │ │ +00057d40: 286d 6173 6b2e 7369 7a65 2829 2c20 696e (mask.size(), in │ │ │ +00057d50: 7428 7369 7a65 2829 2929 3b0a 0a09 0969 t(size()));....i │ │ │ +00057d60: 6e74 2063 6f6e 7374 2066 6972 7374 5f62 nt const first_b │ │ │ +00057d70: 6c6f 636b 203d 2062 6c6f 636b 5f6c 6179 lock = block_lay │ │ │ +00057d80: 6572 5f73 7461 7274 2829 3b0a 0909 696e er_start();...in │ │ │ +00057d90: 7420 636f 6e73 7420 656e 645f 626c 6f63 t const end_bloc │ │ │ +00057da0: 6b20 3d20 6669 7273 745f 626c 6f63 6b20 k = first_block │ │ │ +00057db0: 2b20 6d5f 6e75 6d5f 626c 6f63 6b73 3b0a + m_num_blocks;. │ │ │ +00057dc0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00057dd0: 5428 6669 7273 745f 626c 6f63 6b20 266c T(first_block &l │ │ │ +00057de0: 743b 2069 6e74 2873 697a 6528 2929 293b t; int(size())); │ │ │ +00057df0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00057e00: 5428 656e 645f 626c 6f63 6b20 266c 743b T(end_block < │ │ │ +00057e10: 3d20 696e 7428 7369 7a65 2829 2929 3b0a = int(size()));. │ │ │ +00057e20: 0a09 092f 2f20 6966 2074 6865 206d 6173 ...// if the mas │ │ │ +00057e30: 6b20 636f 7665 7273 2061 6c6c 2062 6c6f k covers all blo │ │ │ +00057e40: 636b 732c 2067 6f20 7374 7261 6967 6874 cks, go straight │ │ │ +00057e50: 2074 6f20 626c 6f63 6b5f 6c61 7965 720a to block_layer. │ │ │ +00057e60: 0909 2f2f 206d 6f64 652c 2061 6e64 2076 ..// mode, and v │ │ │ +00057e70: 616c 6964 6174 650a 0909 6966 2028 2866 alidate...if ((f │ │ │ +00057e80: 6972 7374 5f62 6c6f 636b 2026 6c74 3b20 irst_block < │ │ │ +00057e90: 6d61 736b 5f73 697a 6529 2026 616d 703b mask_size) & │ │ │ +00057ea0: 2661 6d70 3b20 2865 6e64 5f62 6c6f 636b & (end_block │ │ │ +00057eb0: 2026 6c74 3b3d 206d 6173 6b5f 7369 7a65 <= mask_size │ │ │ +00057ec0: 290a 0909 0926 616d 703b 2661 6d70 3b20 )....&& │ │ │ +00057ed0: 7374 643a 3a61 6c6c 5f6f 6628 6d61 736b std::all_of(mask │ │ │ +00057ee0: 2e62 6567 696e 2829 202b 2066 6972 7374 .begin() + first │ │ │ +00057ef0: 5f62 6c6f 636b 2c20 6d61 736b 2e62 6567 _block, mask.beg │ │ │ +00057f00: 696e 2829 202b 2065 6e64 5f62 6c6f 636b in() + end_block │ │ │ +00057f10: 2c20 6964 656e 7469 7479 2829 2929 0a09 , identity())).. │ │ │ +00057f20: 097b 0a09 0909 2f2f 2074 6865 2069 6e64 .{....// the ind │ │ │ +00057f30: 6578 2069 6e20 7420 7468 6174 2070 6f69 ex in t that poi │ │ │ +00057f40: 6e74 7320 746f 2066 6972 7374 5f62 6c6f nts to first_blo │ │ │ +00057f50: 636b 0a09 0909 6175 746f 2063 6f6e 7374 ck....auto const │ │ │ +00057f60: 2062 6c6f 636b 5f69 6e64 6578 203d 2073 block_index = s │ │ │ +00057f70: 7464 3a3a 636f 756e 745f 6966 286d 6173 td::count_if(mas │ │ │ +00057f80: 6b2e 6265 6769 6e28 292c 206d 6173 6b2e k.begin(), mask. │ │ │ +00057f90: 6265 6769 6e28 2920 2b20 6669 7273 745f begin() + first_ │ │ │ +00057fa0: 626c 6f63 6b2c 2069 6465 6e74 6974 7928 block, identity( │ │ │ +00057fb0: 2929 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ));.
    < │ │ │ +00057fc0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00057ff0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00058020: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ +00058030: 652e 6370 703a 3330 373c 2f61 3e3c 2f74 e.cpp:307this can b │ │ │ +00058050: 6520 6f70 7469 6d69 7a65 6420 6279 2075 e optimized by u │ │ │ +00058060: 7369 6e67 206d 5f74 7265 6520 6173 2073 sing m_tree as s │ │ │ +00058070: 746f 7261 6765 2074 6f20 6669 6c6c 2074 torage to fill t │ │ │ +00058080: 6869 7320 7472 6565 2069 6e74 6f2c 2061 his tree into, a │ │ │ +00058090: 6e64 2074 6865 6e20 636c 6561 7220 6974 nd then clear it │ │ │ +000580a0: 2069 6620 7468 6520 6861 7368 6573 2066 if the hashes f │ │ │ +000580b0: 6169 6c3c 2f74 643e 3c2f 7472 3e3c 7472 ail

    this can be opt │ │ │ +00058110: 696d 697a 6564 2062 7920 7573 696e 6720 imized by using │ │ │ +00058120: 6d5f 7472 6565 2061 7320 7374 6f72 6167 m_tree as storag │ │ │ +00058130: 6520 746f 2066 696c 6c20 7468 6973 0a74 e to fill this.t │ │ │ +00058140: 7265 6520 696e 746f 2c20 616e 6420 7468 ree into, and th │ │ │ +00058150: 656e 2063 6c65 6172 2069 7420 6966 2074 en clear it if t │ │ │ +00058160: 6865 2068 6173 6865 7320 6661 696c 3c2f he hashes fail

    ../src/me │ │ │ +00058180: 726b 6c65 5f74 7265 652e 6370 703a 3330 rkle_tree.cpp:30 │ │ │ +00058190: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ +000581d0: 097b 0a09 0949 4e56 4152 4941 4e54 5f43  .{...INVARIANT_C
    │ │ │ +000581e0: 4845 434b 3b0a 0a09 092f 2f20 6173 2077  HECK;....// as w
    │ │ │ +000581f0: 6520 7365 7420 7468 6520 6861 7368 6573  e set the hashes
    │ │ │ +00058200: 206f 6620 696e 7465 7269 6f72 206e 6f64   of interior nod
    │ │ │ +00058210: 6573 2c20 7765 206d 6179 2062 6520 6162  es, we may be ab
    │ │ │ +00058220: 6c65 2074 6f20 7661 6c69 6461 7465 0a09  le to validate..
    │ │ │ +00058230: 092f 2f20 626c 6f63 6b20 6861 7368 6573  .// block hashes
    │ │ │ +00058240: 2074 6861 7420 7765 2068 6164 2073 696e   that we had sin
    │ │ │ +00058250: 6365 2065 6172 6c69 6572 2e20 416e 7920  ce earlier. Any 
    │ │ │ +00058260: 626c 6f63 6b73 2074 6861 7420 6361 6e20  blocks that can 
    │ │ │ +00058270: 6265 0a09 092f 2f20 7661 6c69 6461 7465  be...// validate
    │ │ │ +00058280: 642c 2061 6e64 2066 6169 6c65 642c 2061  d, and failed, a
    │ │ │ +00058290: 7265 2061 6464 6564 2074 6f20 7468 6973  re added to this
    │ │ │ +000582a0: 206c 6973 740a 0909 6164 645f 6861 7368   list...add_hash
    │ │ │ +000582b0: 6573 5f72 6573 756c 745f 7420 7265 743b  es_result_t ret;
    │ │ │ +000582c0: 0a0a 0909 2f2f 2077 6520 616c 7265 6164  ....// we alread
    │ │ │ +000582d0: 7920 6861 7665 2061 6c6c 2068 6173 6865  y have all hashe
    │ │ │ +000582e0: 730a 0909 6966 2028 6d5f 6d6f 6465 203d  s...if (m_mode =
    │ │ │ +000582f0: 3d20 6d6f 6465 5f74 3a3a 626c 6f63 6b5f  = mode_t::block_
    │ │ │ +00058300: 6c61 7965 7229 0a09 097b 0a09 0909 2f2f  layer)...{....//
    │ │ │ +00058310: 2073 696e 6365 2077 6527 7265 2061 6c72   since we're alr
    │ │ │ +00058320: 6561 6479 206f 6e20 7468 6520 626c 6f63  eady on the bloc
    │ │ │ +00058330: 6b20 6c61 7965 7220 6d6f 6465 2c20 7765  k layer mode, we
    │ │ │ +00058340: 2068 6176 6520 7468 6520 7768 6f6c 650a   have the whole.
    │ │ │ +00058350: 0909 092f 2f20 7472 6565 2c20 616e 6420  ...// tree, and 
    │ │ │ +00058360: 7765 2776 6520 616c 7265 6164 7920 7265  we've already re
    │ │ │ +00058370: 706f 7274 6564 2061 6e79 2070 6965 6365  ported any piece
    │ │ │ +00058380: 7320 6173 2070 6173 7369 6e67 2074 6861  s as passing tha
    │ │ │ +00058390: 7420 6d61 790a 0909 092f 2f20 6861 7665  t may....// have
    │ │ │ +000583a0: 2065 7869 7374 6564 2069 6e20 7468 6520   existed in the 
    │ │ │ +000583b0: 7472 6565 2077 6865 6e20 7765 2063 6f6d  tree when we com
    │ │ │ +000583c0: 706c 6574 6564 2069 742e 2041 7420 7468  pleted it. At th
    │ │ │ +000583d0: 6973 2070 6f69 6e74 206e 6f0a 0909 092f  is point no..../
    │ │ │ +000583e0: 2f20 6d6f 7265 2070 6965 6365 7320 7368  / more pieces sh
    │ │ │ +000583f0: 6f75 6c64 2062 6520 7265 706f 7274 6564  ould be reported
    │ │ │ +00058400: 2061 7320 7061 7373 6564 0a09 0909 7265   as passed....re
    │ │ │ +00058410: 7475 726e 2072 6574 3b0a 0909 7d0a 0a09  turn ret;...}...
    │ │ │ +00058420: 0961 6c6c 6f63 6174 655f 6675 6c6c 2829  .allocate_full()
    │ │ │ +00058430: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ..int const lea │ │ │ +00058470: 665f 636f 756e 7420 3d20 6d65 726b 6c65 f_count = merkle │ │ │ +00058480: 5f6e 756d 5f6c 6561 6673 2869 6e74 2868 _num_leafs(int(h │ │ │ +00058490: 6173 6865 732e 7369 7a65 2829 2929 3b0a ashes.size()));. │ │ │ +000584a0: 3c2f 6469 763e 0909 6175 783a 3a76 6563
    ..aux::vec │ │ │ +000584b0: 746f 7226 6c74 3b73 6861 3235 365f 6861 tor<sha256_ha │ │ │ +000584c0: 7368 2667 743b 2074 7265 6528 6d65 726b sh> tree(merk │ │ │ +000584d0: 6c65 5f6e 756d 5f6e 6f64 6573 286c 6561 le_num_nodes(lea │ │ │ +000584e0: 665f 636f 756e 7429 293b 0a09 0973 7464 f_count));...std │ │ │ +000584f0: 3a3a 636f 7079 2868 6173 6865 732e 6265 ::copy(hashes.be │ │ │ +00058500: 6769 6e28 292c 2068 6173 6865 732e 656e gin(), hashes.en │ │ │ +00058510: 6428 292c 2074 7265 652e 656e 6428 2920 d(), tree.end() │ │ │ +00058520: 2d20 6c65 6166 5f63 6f75 6e74 293b 0a0a - leaf_count);.. │ │ │ +00058530: 0909 2f2f 2074 6865 2065 6e64 206f 6620 ..// the end of │ │ │ +00058540: 6120 6669 6c65 2069 7320 6120 7370 6563 a file is a spec │ │ │ +00058550: 6961 6c20 6361 7365 2c20 7765 206d 6179 ial case, we may │ │ │ +00058560: 206e 6565 6420 746f 2070 6164 2074 6865 need to pad the │ │ │ +00058570: 206c 6561 6620 6c61 7965 720a 0909 6966 leaf layer...if │ │ │ +00058580: 2028 6c65 6166 5f63 6f75 6e74 2026 6774 (leaf_count > │ │ │ +00058590: 3b20 6861 7368 6573 2e73 697a 6528 2929 ; hashes.size()) │ │ │ +000585a0: 0a09 097b 0a09 0909 696e 7420 636f 6e73 ...{....int cons │ │ │ +000585b0: 7420 6c65 6166 5f6c 6179 6572 5f73 697a t leaf_layer_siz │ │ │ +000585c0: 6520 3d20 6e75 6d5f 6c65 6166 7328 293b e = num_leafs(); │ │ │ +000585d0: 0a09 0909 2f2f 2061 7373 756d 696e 6720 ....// assuming │ │ │ +000585e0: 756e 636c 655f 6861 7368 6573 206c 6561 uncle_hashes lea │ │ │ +000585f0: 6420 616c 6c20 7468 6520 7761 7920 746f d all the way to │ │ │ +00058600: 2074 6865 2072 6f6f 742c 2074 6865 7920 the root, they │ │ │ +00058610: 7465 6c6c 2075 730a 0909 092f 2f20 686f tell us....// ho │ │ │ +00058620: 7720 6d61 6e79 206c 6179 6572 7320 646f w many layers do │ │ │ +00058630: 776e 2077 6520 6172 650a 0909 0969 6e74 wn we are....int │ │ │ +00058640: 2063 6f6e 7374 2069 6e73 6572 745f 6c61 const insert_la │ │ │ +00058650: 7965 725f 7369 7a65 203d 206c 6561 665f yer_size = leaf_ │ │ │ +00058660: 636f 756e 7420 266c 743b 266c 743b 2075 count << u │ │ │ +00058670: 6e63 6c65 5f68 6173 6865 732e 7369 7a65 ncle_hashes.size │ │ │ +00058680: 2829 3b0a 0909 0969 6620 286c 6561 665f ();....if (leaf_ │ │ │ +00058690: 6c61 7965 725f 7369 7a65 2021 3d20 696e layer_size != in │ │ │ +000586a0: 7365 7274 5f6c 6179 6572 5f73 697a 6529 sert_layer_size) │ │ │ +000586b0: 0a09 0909 7b0a 0909 0909 7368 6132 3536 ....{.....sha256 │ │ │ +000586c0: 5f68 6173 6820 636f 6e73 7420 7061 645f _hash const pad_ │ │ │ +000586d0: 6861 7368 203d 206d 6572 6b6c 655f 7061 hash = merkle_pa │ │ │ +000586e0: 6428 6c65 6166 5f6c 6179 6572 5f73 697a d(leaf_layer_siz │ │ │ +000586f0: 652c 2069 6e73 6572 745f 6c61 7965 725f e, insert_layer_ │ │ │ +00058700: 7369 7a65 293b 0a09 0909 0966 6f72 2028 size);.....for ( │ │ │ +00058710: 696e 7420 6920 3d20 696e 7428 6861 7368 int i = int(hash │ │ │ +00058720: 6573 2e73 697a 6528 2929 3b20 6920 266c es.size()); i &l │ │ │ +00058730: 743b 206c 6561 665f 636f 756e 743b 202b t; leaf_count; + │ │ │ +00058740: 2b69 290a 0909 0909 0974 7265 655b 7472 +i)......tree[tr │ │ │ +00058750: 6565 2e65 6e64 5f69 6e64 6578 2829 202d ee.end_index() - │ │ │ +00058760: 206c 6561 665f 636f 756e 7420 2b20 695d leaf_count + i] │ │ │ +00058770: 203d 2070 6164 5f68 6173 683b 0a09 0909 = pad_hash;.... │ │ │ +00058780: 7d0a 0909 7d0a 0a09 096d 6572 6b6c 655f }...}....merkle_ │ │ │ +00058790: 6669 6c6c 5f74 7265 6528 7472 6565 2c20 fill_tree(tree, │ │ │ +000587a0: 6c65 6166 5f63 6f75 6e74 293b 0a0a 0909 leaf_count);.... │ │ │ +000587b0: 696e 7420 636f 6e73 7420 6261 7365 5f6e int const base_n │ │ │ +000587c0: 756d 5f6c 6179 6572 7320 3d20 6d65 726b um_layers = merk │ │ │ +000587d0: 6c65 5f6e 756d 5f6c 6179 6572 7328 6c65 le_num_layers(le │ │ │ +000587e0: 6166 5f63 6f75 6e74 293b 0a0a 0909 2f2f af_count);....// │ │ │ +000587f0: 2074 6869 7320 6973 2074 6865 2069 6e64 this is the ind │ │ │ +00058800: 6578 206f 6620 7468 6520 6e6f 6465 2077 ex of the node w │ │ │ +00058810: 6865 7265 2077 6527 6c6c 2069 6e73 6572 here we'll inser │ │ │ +00058820: 7420 7468 6520 726f 6f74 206f 6620 7468 t the root of th │ │ │ +00058830: 650a 0909 2f2f 2073 7562 7472 6565 2028 e...// subtree ( │ │ │ +00058840: 7472 6565 292e 2049 7427 7320 616c 736f tree). It's also │ │ │ +00058850: 2074 6865 2068 6173 6820 7468 6520 756e the hash the un │ │ │ +00058860: 636c 655f 6861 7368 6573 2061 7265 2068 cle_hashes are h │ │ │ +00058870: 6572 6520 746f 2070 726f 7665 0a09 092f ere to prove.../ │ │ │ +00058880: 2f20 6973 2076 616c 6964 2e0a 0909 696e / is valid....in │ │ │ +00058890: 7420 636f 6e73 7420 696e 7365 7274 5f72 t const insert_r │ │ │ +000588a0: 6f6f 745f 6964 7820 3d20 6465 7374 5f73 oot_idx = dest_s │ │ │ +000588b0: 7461 7274 5f69 6478 2026 6774 3b26 6774 tart_idx >> │ │ │ +000588c0: 3b20 6261 7365 5f6e 756d 5f6c 6179 6572 ; base_num_layer │ │ │ +000588d0: 733b 0a0a 0909 2f2f 2073 7461 7274 2077 s;....// start w │ │ │ +000588e0: 6974 6820 7661 6c69 6461 7469 6e67 2074 ith validating t │ │ │ +000588f0: 6865 2070 726f 6f66 732c 2061 6e64 2069 he proofs, and i │ │ │ +00058900: 6e73 6572 7469 6e67 2074 6865 6d20 6173 nserting them as │ │ │ +00058910: 2077 6520 676f 2e0a 0909 6966 2028 216d we go....if (!m │ │ │ +00058920: 6572 6b6c 655f 7661 6c69 6461 7465 5f61 erkle_validate_a │ │ │ +00058930: 6e64 5f69 6e73 6572 745f 7072 6f6f 6673 nd_insert_proofs │ │ │ +00058940: 286d 5f74 7265 652c 2069 6e73 6572 745f (m_tree, insert_ │ │ │ +00058950: 726f 6f74 5f69 6478 2c20 7472 6565 5b30 root_idx, tree[0 │ │ │ +00058960: 5d2c 2075 6e63 6c65 5f68 6173 6865 7329 ], uncle_hashes) │ │ │ +00058970: 290a 0909 0972 6574 7572 6e20 7b7d 3b0a )....return {};. │ │ │ +00058980: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00058990: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000589c0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +000589f0: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ +00058a00: 703a 3335 353c 2f61 3e3c 2f74 643e 3c74 p:355a piece outsid │ │ │ +00058a20: 6520 6f66 2074 6869 7320 7261 6e67 6520 e of this range │ │ │ +00058a30: 6d61 7920 616c 736f 2066 6169 6c2c 2069 may also fail, i │ │ │ +00058a40: 6620 6f6e 6520 6f66 2074 6865 2075 6e63 f one of the unc │ │ │ +00058a50: 6c65 2068 6173 6865 7320 6973 2061 7420 le hashes is at │ │ │ +00058a60: 7468 6520 6c61 7965 7220 7269 6768 7420 the layer right │ │ │ +00058a70: 6162 6f76 6520 7468 6520 626c 6f63 6b20 above the block │ │ │ +00058a80: 6861 7368 6573 3c2f 7464 3e3c 2f74 723e hashes │ │ │ +00058a90: 3c74 7220 6964 3d22 3230 3722 2073 7479 │ │ │ +00058ac0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00058ad0: 3c68 323e 6120 7069 6563 6520 6f75 7473

    a piece outs │ │ │ +00058ae0: 6964 6520 6f66 2074 6869 7320 7261 6e67 ide of this rang │ │ │ +00058af0: 6520 6d61 7920 616c 736f 2066 6169 6c2c e may also fail, │ │ │ +00058b00: 2069 6620 6f6e 6520 6f66 2074 6865 2075 if one of the u │ │ │ +00058b10: 6e63 6c65 0a68 6173 6865 7320 6973 2061 ncle.hashes is a │ │ │ +00058b20: 7420 7468 6520 6c61 7965 7220 7269 6768 t the layer righ │ │ │ +00058b30: 7420 6162 6f76 6520 7468 6520 626c 6f63 t above the bloc │ │ │ +00058b40: 6b20 6861 7368 6573 3c2f 6832 3e3c 6834 k hashes

    ../src/merkle_t │ │ │ +00058b60: 7265 652e 6370 703a 3335 353c 2f68 343e ree.cpp:355

    │ │ │ +00058b70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..int 
    │ │ │ +00058bb0: 636f 6e73 7420 696e 7365 7274 5f72 6f6f  const insert_roo
    │ │ │ +00058bc0: 745f 6964 7820 3d20 6465 7374 5f73 7461  t_idx = dest_sta
    │ │ │ +00058bd0: 7274 5f69 6478 2026 6774 3b26 6774 3b20  rt_idx >> 
    │ │ │ +00058be0: 6261 7365 5f6e 756d 5f6c 6179 6572 733b  base_num_layers;
    │ │ │ +00058bf0: 0a0a 0909 2f2f 2073 7461 7274 2077 6974  ....// start wit
    │ │ │ +00058c00: 6820 7661 6c69 6461 7469 6e67 2074 6865  h validating the
    │ │ │ +00058c10: 2070 726f 6f66 732c 2061 6e64 2069 6e73   proofs, and ins
    │ │ │ +00058c20: 6572 7469 6e67 2074 6865 6d20 6173 2077  erting them as w
    │ │ │ +00058c30: 6520 676f 2e0a 0909 6966 2028 216d 6572  e go....if (!mer
    │ │ │ +00058c40: 6b6c 655f 7661 6c69 6461 7465 5f61 6e64  kle_validate_and
    │ │ │ +00058c50: 5f69 6e73 6572 745f 7072 6f6f 6673 286d  _insert_proofs(m
    │ │ │ +00058c60: 5f74 7265 652c 2069 6e73 6572 745f 726f  _tree, insert_ro
    │ │ │ +00058c70: 6f74 5f69 6478 2c20 7472 6565 5b30 5d2c  ot_idx, tree[0],
    │ │ │ +00058c80: 2075 6e63 6c65 5f68 6173 6865 7329 290a   uncle_hashes)).
    │ │ │ +00058c90: 0909 0972 6574 7572 6e20 7b7d 3b0a 0a09  ...return {};...
    │ │ │ +00058ca0: 092f 2f20 6669 7273 7420 6669 6c6c 2069  .// first fill i
    │ │ │ +00058cb0: 6e20 7468 6520 7375 6274 7265 6520 6f66  n the subtree of
    │ │ │ +00058cc0: 206b 6e6f 776e 2068 6173 6865 7320 6672   known hashes fr
    │ │ │ +00058cd0: 6f6d 2074 6865 2062 6173 6520 6c61 7965  om the base laye
    │ │ │ +00058ce0: 720a 0909 6175 746f 2063 6f6e 7374 206e  r...auto const n
    │ │ │ +00058cf0: 756d 5f6c 6561 6673 203d 206d 6572 6b6c  um_leafs = merkl
    │ │ │ +00058d00: 655f 6e75 6d5f 6c65 6166 7328 6d5f 6e75  e_num_leafs(m_nu
    │ │ │ +00058d10: 6d5f 626c 6f63 6b73 293b 0a09 0961 7574  m_blocks);...aut
    │ │ │ +00058d20: 6f20 636f 6e73 7420 6669 7273 745f 6c65  o const first_le
    │ │ │ +00058d30: 6166 203d 206d 6572 6b6c 655f 6669 7273  af = merkle_firs
    │ │ │ +00058d40: 745f 6c65 6166 286e 756d 5f6c 6561 6673  t_leaf(num_leafs
    │ │ │ +00058d50: 293b 0a0a 0909 2f2f 2074 6869 7320 6973  );....// this is
    │ │ │ +00058d60: 2074 6865 2073 7461 7274 206f 6620 7468   the start of th
    │ │ │ +00058d70: 6520 6c65 6166 206c 6179 6572 206f 6620  e leaf layer of 
    │ │ │ +00058d80: 2274 7265 6522 2e20 5765 276c 6c20 7573  "tree". We'll us
    │ │ │ +00058d90: 6520 7468 6973 0a09 092f 2f20 7661 7269  e this...// vari
    │ │ │ +00058da0: 6162 6c65 2074 6f20 7374 6570 2075 7077  able to step upw
    │ │ │ +00058db0: 6172 6473 2074 6f77 6172 6473 2074 6865  ards towards the
    │ │ │ +00058dc0: 2072 6f6f 740a 0909 696e 7420 736f 7572   root...int sour
    │ │ │ +00058dd0: 6365 5f63 7572 736f 7220 3d20 696e 7428  ce_cursor = int(
    │ │ │ +00058de0: 7472 6565 2e73 697a 6528 2929 202d 206c  tree.size()) - l
    │ │ │ +00058df0: 6561 665f 636f 756e 743b 0a09 092f 2f20  eaf_count;...// 
    │ │ │ +00058e00: 7468 6520 7275 6e6e 696e 6720 696e 6465  the running inde
    │ │ │ +00058e10: 7820 696e 2074 6865 206c 6f6f 700a 0909  x in the loop...
    │ │ │ +00058e20: 696e 7420 6465 7374 5f63 7572 736f 7220  int dest_cursor 
    │ │ │ +00058e30: 3d20 6465 7374 5f73 7461 7274 5f69 6478  = dest_start_idx
    │ │ │ +00058e40: 3b0a 0a09 092f 2f20 7468 6520 6e75 6d62  ;....// the numb
    │ │ │ +00058e50: 6572 206f 6620 7472 6565 206c 6576 656c  er of tree level
    │ │ │ +00058e60: 7320 696e 2061 2070 6965 6365 2068 6173  s in a piece has
    │ │ │ +00058e70: 682e 2030 206d 6561 6e73 2074 6865 2062  h. 0 means the b
    │ │ │ +00058e80: 6c6f 636b 206c 6179 6572 2069 730a 0909  lock layer is...
    │ │ │ +00058e90: 2f2f 2074 6865 2073 616d 6520 6173 2074  // the same as t
    │ │ │ +00058ea0: 6865 2070 6965 6365 206c 6179 6572 0a09  he piece layer..
    │ │ │ +00058eb0: 0969 6e74 2063 6f6e 7374 2062 6173 6520  .int const base 
    │ │ │ +00058ec0: 3d20 7069 6563 655f 6c65 7665 6c73 2829  = piece_levels()
    │ │ │ +00058ed0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ..for (int laye │ │ │ +00058f10: 725f 7369 7a65 203d 206c 6561 665f 636f r_size = leaf_co │ │ │ +00058f20: 756e 743b 206c 6179 6572 5f73 697a 6520 unt; layer_size │ │ │ +00058f30: 213d 2030 3b20 6c61 7965 725f 7369 7a65 != 0; layer_size │ │ │ +00058f40: 202f 3d20 3229 0a3c 2f64 6976 3e09 097b /= 2).
    ..{ │ │ │ +00058f50: 0a09 0909 666f 7220 2869 6e74 2069 203d ....for (int i = │ │ │ +00058f60: 2030 3b20 6920 266c 743b 206c 6179 6572 0; i < layer │ │ │ +00058f70: 5f73 697a 653b 202b 2b69 290a 0909 097b _size; ++i)....{ │ │ │ +00058f80: 0a09 0909 0969 6e74 2063 6f6e 7374 2064 .....int const d │ │ │ +00058f90: 7374 5f69 6478 203d 2064 6573 745f 6375 st_idx = dest_cu │ │ │ +00058fa0: 7273 6f72 202b 2069 3b0a 0909 0909 696e rsor + i;.....in │ │ │ +00058fb0: 7420 636f 6e73 7420 7372 635f 6964 7820 t const src_idx │ │ │ +00058fc0: 3d20 736f 7572 6365 5f63 7572 736f 7220 = source_cursor │ │ │ +00058fd0: 2b20 693b 0a09 0909 0969 6620 2868 6173 + i;.....if (has │ │ │ +00058fe0: 5f6e 6f64 6528 6473 745f 6964 7829 290a _node(dst_idx)). │ │ │ +00058ff0: 0909 0909 7b0a 0909 0909 0969 6620 286d ....{......if (m │ │ │ +00059000: 5f74 7265 655b 6473 745f 6964 785d 2021 _tree[dst_idx] ! │ │ │ +00059010: 3d20 7472 6565 5b73 7263 5f69 6478 5d29 = tree[src_idx]) │ │ │ +00059020: 0a09 0909 0909 7b0a 0909 0909 0909 2f2f ......{.......// │ │ │ +00059030: 2074 6869 7320 6d75 7374 2062 6520 6120 this must be a │ │ │ +00059040: 626c 6f63 6b20 6861 7368 2062 6563 6175 block hash becau │ │ │ +00059050: 7365 2069 6e6e 6572 206e 6f64 6573 2061 se inner nodes a │ │ │ +00059060: 7265 206e 6f74 2066 696c 6c65 6420 696e re not filled in │ │ │ +00059070: 2075 6e74 696c 0a09 0909 0909 092f 2f20 until.......// │ │ │ +00059080: 7468 6579 2063 616e 2062 6520 7665 7269 they can be veri │ │ │ +00059090: 6669 6564 2e20 5468 6973 2061 7373 6572 fied. This asser │ │ │ +000590a0: 7420 656e 7375 7265 7320 7765 2772 6520 t ensures we're │ │ │ +000590b0: 6174 2074 6865 0a09 0909 0909 092f 2f20 at the.......// │ │ │ +000590c0: 6c65 6166 206c 6179 6572 206f 6620 7468 leaf layer of th │ │ │ +000590d0: 6520 6669 6c65 2074 7265 650a 0909 0909 e file tree..... │ │ │ +000590e0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +000590f0: 2864 7374 5f69 6478 2026 6774 3b3d 2066 (dst_idx >= f │ │ │ +00059100: 6972 7374 5f6c 6561 6629 3b0a 0a09 0909 irst_leaf);..... │ │ │ +00059110: 0909 0969 6e74 2063 6f6e 7374 2070 6f73 ...int const pos │ │ │ +00059120: 203d 2064 7374 5f69 6478 202d 2066 6972 = dst_idx - fir │ │ │ +00059130: 7374 5f6c 6561 663b 0a09 0909 0909 0961 st_leaf;.......a │ │ │ +00059140: 7574 6f20 636f 6e73 7420 7069 6563 6520 uto const piece │ │ │ +00059150: 3d20 7069 6563 655f 696e 6465 785f 747b = piece_index_t{ │ │ │ +00059160: 706f 7320 2667 743b 2667 743b 206d 5f62 pos >> m_b │ │ │ +00059170: 6c6f 636b 735f 7065 725f 7069 6563 655f locks_per_piece_ │ │ │ +00059180: 6c6f 677d 202b 2066 696c 655f 7069 6563 log} + file_piec │ │ │ +00059190: 655f 6f66 6673 6574 3b0a 0909 0909 0909 e_offset;....... │ │ │ +000591a0: 696e 7420 636f 6e73 7420 626c 6f63 6b20 int const block │ │ │ +000591b0: 3d20 706f 7320 2661 6d70 3b20 2828 3120 = pos & ((1 │ │ │ +000591c0: 266c 743b 266c 743b 206d 5f62 6c6f 636b << m_block │ │ │ +000591d0: 735f 7065 725f 7069 6563 655f 6c6f 6729 s_per_piece_log) │ │ │ +000591e0: 202d 2031 293b 0a0a 0909 0909 0909 544f - 1);........TO │ │ │ +000591f0: 5252 454e 545f 4153 5345 5254 2870 6f73 RRENT_ASSERT(pos │ │ │ +00059200: 2026 6c74 3b20 6d5f 6e75 6d5f 626c 6f63 < m_num_bloc │ │ │ +00059210: 6b73 293b 0a09 0909 0909 0969 6620 2821 ks);.......if (! │ │ │ +00059220: 7265 742e 6661 696c 6564 2e65 6d70 7479 ret.failed.empty │ │ │ +00059230: 2829 2026 616d 703b 2661 6d70 3b20 7265 () && re │ │ │ +00059240: 742e 6661 696c 6564 2e62 6163 6b28 292e t.failed.back(). │ │ │ +00059250: 6669 7273 7420 3d3d 2070 6965 6365 290a first == piece). │ │ │ +00059260: 0909 0909 0909 0972 6574 2e66 6169 6c65 .......ret.faile │ │ │ +00059270: 642e 6261 636b 2829 2e73 6563 6f6e 642e d.back().second. │ │ │ +00059280: 7075 7368 5f62 6163 6b28 626c 6f63 6b29 push_back(block) │ │ │ +00059290: 3b0a 0909 0909 0909 656c 7365 0a09 0909 ;.......else.... │ │ │ +000592a0: 0909 0909 7265 742e 6661 696c 6564 2e65 ....ret.failed.e │ │ │ +000592b0: 6d70 6c61 6365 5f62 6163 6b28 7069 6563 mplace_back(piec │ │ │ +000592c0: 652c 2073 7464 3a3a 7665 6374 6f72 266c e, std::vector&l │ │ │ +000592d0: 743b 696e 7426 6774 3b7b 626c 6f63 6b7d t;int>{block} │ │ │ +000592e0: 293b 0a0a 0909 0909 0909 2f2f 206e 6f77 );........// now │ │ │ +000592f0: 2074 6861 7420 7468 6973 2068 6173 6820 that this hash │ │ │ +00059300: 6861 7320 6265 656e 2072 6570 6f72 7465 has been reporte │ │ │ +00059310: 6420 6173 2066 6169 6c69 6e67 2c20 7765 d as failing, we │ │ │ +00059320: 0a09 0909 0909 092f 2f20 6361 6e20 636c .......// can cl │ │ │ +00059330: 6561 7220 6974 2e20 5468 6973 2077 696c ear it. This wil │ │ │ +00059340: 6c20 7072 6576 656e 7420 6974 2066 726f l prevent it fro │ │ │ +00059350: 6d20 6265 696e 670a 0909 0909 0909 2f2f m being.......// │ │ │ +00059360: 2072 6570 6f72 7465 6420 6173 2066 6169 reported as fai │ │ │ +00059370: 6c69 6e67 2061 6761 696e 2e0a 0909 0909 ling again...... │ │ │ +00059380: 0909 6d5f 7472 6565 5b64 7374 5f69 6478 ..m_tree[dst_idx │ │ │ +00059390: 5d2e 636c 6561 7228 293b 0a09 0909 0909 ].clear();...... │ │ │ +000593a0: 7d0a 0909 0909 0965 6c73 6520 6966 2028 }......else if ( │ │ │ +000593b0: 6473 745f 6964 7820 2667 743b 3d20 6669 dst_idx >= fi │ │ │ +000593c0: 7273 745f 6c65 6166 290a 3c2f 7072 653e rst_leaf).
    │ │ │ +000593d0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00059400: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00059410: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/merk │ │ │ +00059440: 6c65 5f74 7265 652e 6370 703a 3433 353c le_tree.cpp:435< │ │ │ +00059450: 2f61 3e3c 2f74 643e 3c74 643e 696e 7374 /a>inst │ │ │ +00059460: 6561 6420 6f66 206f 7665 7277 7269 7469 ead of overwriti │ │ │ +00059470: 6e67 2074 6865 2072 6f6f 7420 616e 6420 ng the root and │ │ │ +00059480: 636f 6d70 6172 696e 6720 6974 2061 6761 comparing it aga │ │ │ +00059490: 696e 7374 2068 6173 6865 735b 5d2c 2077 inst hashes[], w │ │ │ +000594a0: 7269 7465 2061 2066 756e 6374 696f 6e73 rite a functions │ │ │ +000594b0: 2074 6861 7420 2a76 616c 6964 6174 6573 that *validates │ │ │ +000594c0: 2a20 6120 7472 6565 2062 7920 6a75 7374 * a tree by just │ │ │ +000594d0: 2066 696c 6c69 6e67 2069 7420 7570 2074 filling it up t │ │ │ +000594e0: 6f20 7468 6520 6c65 7665 6c20 6265 6c6f o the level belo │ │ │ +000594f0: 7720 7468 6520 726f 6f74 2061 6e64 2074 w the root and t │ │ │ +00059500: 6865 6e20 7661 6c69 6461 7465 7320 6974 hen validates it │ │ │ +00059510: 2e3c 2f74 643e 3c2f 7472 3e3c 7472 2069 .

    i │ │ │ +00059560: 6e73 7465 6164 206f 6620 6f76 6572 7772 nstead of overwr │ │ │ +00059570: 6974 696e 6720 7468 6520 726f 6f74 2061 iting the root a │ │ │ +00059580: 6e64 2063 6f6d 7061 7269 6e67 2069 740a nd comparing it. │ │ │ +00059590: 6167 6169 6e73 7420 6861 7368 6573 5b5d against hashes[] │ │ │ +000595a0: 2c20 7772 6974 6520 6120 6675 6e63 7469 , write a functi │ │ │ +000595b0: 6f6e 7320 7468 6174 202a 7661 6c69 6461 ons that *valida │ │ │ +000595c0: 7465 732a 2061 2074 7265 650a 6279 206a tes* a tree.by j │ │ │ +000595d0: 7573 7420 6669 6c6c 696e 6720 6974 2075 ust filling it u │ │ │ +000595e0: 7020 746f 2074 6865 206c 6576 656c 2062 p to the level b │ │ │ +000595f0: 656c 6f77 2074 6865 2072 6f6f 7420 616e elow the root an │ │ │ +00059600: 6420 7468 656e 0a76 616c 6964 6174 6573 d then.validates │ │ │ +00059610: 2069 742e 3c2f 6832 3e3c 6834 3e2e 2e2f it.

    ../ │ │ │ +00059620: 7372 632f 6d65 726b 6c65 5f74 7265 652e src/merkle_tree. │ │ │ +00059630: 6370 703a 3433 353c 2f68 343e 3c70 7265 cpp:435

    ...&&a
    │ │ │ +00059680: 6d70 3b20 6465 7374 5f73 7461 7274 5f69  mp; dest_start_i
    │ │ │ +00059690: 6478 2026 6c74 3b20 6669 7273 745f 7069  dx < first_pi
    │ │ │ +000596a0: 6563 655f 6964 7820 2b20 6e75 6d5f 7069  ece_idx + num_pi
    │ │ │ +000596b0: 6563 6573 2829 290a 0909 7b0a 0909 0969  eces())...{....i
    │ │ │ +000596c0: 6e74 2063 6f6e 7374 2062 6c6f 636b 735f  nt const blocks_
    │ │ │ +000596d0: 696e 5f70 6965 6365 203d 2031 2026 6c74  in_piece = 1 <
    │ │ │ +000596e0: 3b26 6c74 3b20 6261 7365 3b0a 0a09 0909  ;< base;.....
    │ │ │ +000596f0: 2f2f 2069 7420 6d61 7920 6e6f 7720 6265  // it may now be
    │ │ │ +00059700: 2070 6f73 7369 626c 6520 746f 2076 6572   possible to ver
    │ │ │ +00059710: 6966 7920 7468 6520 6861 7368 6573 206f  ify the hashes o
    │ │ │ +00059720: 6620 7072 6576 696f 7573 6c79 2072 6563  f previously rec
    │ │ │ +00059730: 6569 7665 6420 626c 6f63 6b73 0a09 0909  eived blocks....
    │ │ │ +00059740: 2f2f 2074 7279 2074 6f20 7665 7269 6679  // try to verify
    │ │ │ +00059750: 2061 7320 6d61 6e79 2063 6869 6c64 206e   as many child n
    │ │ │ +00059760: 6f64 6573 206f 6620 7468 6520 7265 6365  odes of the rece
    │ │ │ +00059770: 6976 6564 2068 6173 6865 7320 6173 2070  ived hashes as p
    │ │ │ +00059780: 6f73 7369 626c 650a 0909 0966 6f72 2028  ossible....for (
    │ │ │ +00059790: 696e 7420 6920 3d20 303b 2069 2026 6c74  int i = 0; i <
    │ │ │ +000597a0: 3b20 696e 7428 6861 7368 6573 2e73 697a  ; int(hashes.siz
    │ │ │ +000597b0: 6528 2929 3b20 2b2b 6929 0a09 0909 7b0a  e()); ++i)....{.
    │ │ │ +000597c0: 0909 0909 696e 7420 636f 6e73 7420 7069  ....int const pi
    │ │ │ +000597d0: 6563 6520 3d20 6465 7374 5f73 7461 7274  ece = dest_start
    │ │ │ +000597e0: 5f69 6478 202b 2069 3b0a 0909 0909 6966  _idx + i;.....if
    │ │ │ +000597f0: 2028 7069 6563 6520 2d20 6669 7273 745f   (piece - first_
    │ │ │ +00059800: 7069 6563 655f 6964 7820 2667 743b 3d20  piece_idx >= 
    │ │ │ +00059810: 6e75 6d5f 7069 6563 6573 2829 290a 0909  num_pieces())...
    │ │ │ +00059820: 0909 0962 7265 616b 3b0a 0909 0909 2f2f  ...break;.....//
    │ │ │ +00059830: 2074 6865 2066 6972 7374 2062 6c6f 636b   the first block
    │ │ │ +00059840: 2069 6e20 7468 6973 2070 6965 6365 0a09   in this piece..
    │ │ │ +00059850: 0909 0969 6e74 2063 6f6e 7374 2062 6c6f  ...int const blo
    │ │ │ +00059860: 636b 5f69 6478 203d 206d 6572 6b6c 655f  ck_idx = merkle_
    │ │ │ +00059870: 6765 745f 6669 7273 745f 6368 696c 6428  get_first_child(
    │ │ │ +00059880: 7069 6563 652c 2062 6173 6529 3b0a 0a09  piece, base);...
    │ │ │ +00059890: 0909 0969 6e74 2063 6f6e 7374 2062 6c6f  ...int const blo
    │ │ │ +000598a0: 636b 5f65 6e64 5f69 6478 203d 2073 7464  ck_end_idx = std
    │ │ │ +000598b0: 3a3a 6d69 6e28 626c 6f63 6b5f 6964 7820  ::min(block_idx 
    │ │ │ +000598c0: 2b20 626c 6f63 6b73 5f69 6e5f 7069 6563  + blocks_in_piec
    │ │ │ +000598d0: 652c 2066 6972 7374 5f6c 6561 6620 2b20  e, first_leaf + 
    │ │ │ +000598e0: 6d5f 6e75 6d5f 626c 6f63 6b73 293b 0a09  m_num_blocks);..
    │ │ │ +000598f0: 0909 0969 6620 2873 7464 3a3a 616e 795f  ...if (std::any_
    │ │ │ +00059900: 6f66 286d 5f74 7265 652e 6265 6769 6e28  of(m_tree.begin(
    │ │ │ +00059910: 2920 2b20 626c 6f63 6b5f 6964 780a 0909  ) + block_idx...
    │ │ │ +00059920: 0909 092c 206d 5f74 7265 652e 6265 6769  ..., m_tree.begi
    │ │ │ +00059930: 6e28 2920 2b20 626c 6f63 6b5f 656e 645f  n() + block_end_
    │ │ │ +00059940: 6964 780a 0909 0909 092c 205b 5d28 7368  idx......, [](sh
    │ │ │ +00059950: 6132 3536 5f68 6173 6820 636f 6e73 7426  a256_hash const&
    │ │ │ +00059960: 616d 703b 2068 2920 7b20 7265 7475 726e  amp; h) { return
    │ │ │ +00059970: 2068 2e69 735f 616c 6c5f 7a65 726f 7328   h.is_all_zeros(
    │ │ │ +00059980: 293b 207d 2929 0a09 0909 0909 636f 6e74  ); }))......cont
    │ │ │ +00059990: 696e 7565 3b0a 0a3c 6469 7620 7374 796c  inue;..
    ....merkle_ │ │ │ +000599d0: 6669 6c6c 5f74 7265 6528 6d5f 7472 6565 fill_tree(m_tree │ │ │ +000599e0: 2c20 626c 6f63 6b73 5f69 6e5f 7069 6563 , blocks_in_piec │ │ │ +000599f0: 652c 2062 6c6f 636b 5f69 6478 293b 0a3c e, block_idx);.< │ │ │ +00059a00: 2f64 6976 3e09 0909 0969 6620 286d 5f74 /div>....if (m_t │ │ │ +00059a10: 7265 655b 7069 6563 655d 2021 3d20 6861 ree[piece] != ha │ │ │ +00059a20: 7368 6573 5b69 5d29 0a09 0909 097b 0a09 shes[i]).....{.. │ │ │ +00059a30: 0909 0909 6d65 726b 6c65 5f63 6c65 6172 ....merkle_clear │ │ │ +00059a40: 5f74 7265 6528 6d5f 7472 6565 2c20 626c _tree(m_tree, bl │ │ │ +00059a50: 6f63 6b73 5f69 6e5f 7069 6563 652c 2062 ocks_in_piece, b │ │ │ +00059a60: 6c6f 636b 5f69 6478 293b 0a09 0909 0909 lock_idx);...... │ │ │ +00059a70: 2f2f 2077 7269 7465 2062 6163 6b20 7468 // write back th │ │ │ +00059a80: 6520 636f 7272 6563 7420 6861 7368 0a09 e correct hash.. │ │ │ +00059a90: 0909 0909 6d5f 7472 6565 5b70 6965 6365 ....m_tree[piece │ │ │ +00059aa0: 5d20 3d20 6861 7368 6573 5b69 5d3b 0a09 ] = hashes[i];.. │ │ │ +00059ab0: 0909 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00059ac0: 5254 2862 6c6f 636b 735f 696e 5f70 6965 RT(blocks_in_pie │ │ │ +00059ad0: 6365 203d 3d20 626c 6f63 6b73 5f70 6572 ce == blocks_per │ │ │ +00059ae0: 5f70 6965 6365 2829 293b 0a0a 0909 0909 _piece());...... │ │ │ +00059af0: 092f 2f20 616e 2065 6d70 7479 2062 6c6f .// an empty blo │ │ │ +00059b00: 636b 7320 7665 6374 6f72 2069 6e64 6963 cks vector indic │ │ │ +00059b10: 6174 6573 2074 6861 7420 7765 2064 6f6e ates that we don │ │ │ +00059b20: 2774 2068 6176 6520 7468 650a 0909 0909 't have the..... │ │ │ +00059b30: 092f 2f20 626c 6f63 6b20 6861 7368 6573 .// block hashes │ │ │ +00059b40: 2c20 616e 6420 7765 2063 616e 2774 206b , and we can't k │ │ │ +00059b50: 6e6f 7720 7768 6963 6820 626c 6f63 6b20 now which block │ │ │ +00059b60: 6661 696c 6564 0a09 0909 0909 2f2f 2074 failed......// t │ │ │ +00059b70: 6869 7320 7769 6c6c 2063 6175 7365 2074 his will cause t │ │ │ +00059b80: 6865 2062 6c6f 636b 2068 6173 6865 7320 he block hashes │ │ │ +00059b90: 746f 2062 6520 7265 7175 6573 7465 640a to be requested. │ │ │ +00059ba0: 0909 0909 0972 6574 2e66 6169 6c65 642e .....ret.failed. │ │ │ +00059bb0: 656d 706c 6163 655f 6261 636b 2870 6965 emplace_back(pie │ │ │ +00059bc0: 6365 5f69 6e64 6578 5f74 7b70 6965 6365 ce_index_t{piece │ │ │ +00059bd0: 202d 2066 6972 7374 5f70 6965 6365 5f69 - first_piece_i │ │ │ +00059be0: 6478 7d20 2b20 6669 6c65 5f70 6965 6365 dx} + file_piece │ │ │ +00059bf0: 5f6f 6666 7365 740a 0909 0909 0909 2c20 _offset......., │ │ │ +00059c00: 7374 643a 3a76 6563 746f 7226 6c74 3b69 std::vector<i │ │ │ +00059c10: 6e74 2667 743b 2829 293b 0a09 0909 097d nt>());.....} │ │ │ +00059c20: 0a09 0909 0965 6c73 650a 0909 0909 7b0a .....else.....{. │ │ │ +00059c30: 0909 0909 0972 6574 2e70 6173 7365 642e .....ret.passed. │ │ │ +00059c40: 7075 7368 5f62 6163 6b28 7069 6563 655f push_back(piece_ │ │ │ +00059c50: 696e 6465 785f 747b 7069 6563 6520 2d20 index_t{piece - │ │ │ +00059c60: 6669 7273 745f 7069 6563 655f 6964 787d first_piece_idx} │ │ │ +00059c70: 202b 2066 696c 655f 7069 6563 655f 6f66 + file_piece_of │ │ │ +00059c80: 6673 6574 293b 0a09 0909 0909 2f2f 2072 fset);......// r │ │ │ +00059c90: 6563 6f72 6420 7468 6174 2074 6865 7365 ecord that these │ │ │ +00059ca0: 2062 6c6f 636b 2068 6173 6865 7320 6172 block hashes ar │ │ │ +00059cb0: 6520 636f 7272 6563 7421 0a09 0909 0909 e correct!...... │ │ │ +00059cc0: 696e 7420 636f 6e73 7420 6c65 6166 735f int const leafs_ │ │ │ +00059cd0: 7374 6172 7420 3d20 626c 6f63 6b5f 6964 start = block_id │ │ │ +00059ce0: 7820 2d20 626c 6f63 6b5f 6c61 7965 725f x - block_layer_ │ │ │ +00059cf0: 7374 6172 7428 293b 0a09 0909 0909 696e start();......in │ │ │ +00059d00: 7420 636f 6e73 7420 6c65 6166 735f 656e t const leafs_en │ │ │ +00059d10: 6420 3d20 7374 643a 3a6d 696e 286d 5f6e d = std::min(m_n │ │ │ +00059d20: 756d 5f62 6c6f 636b 732c 206c 6561 6673 um_blocks, leafs │ │ │ +00059d30: 5f73 7461 7274 202b 2062 6c6f 636b 735f _start + blocks_ │ │ │ +00059d40: 696e 5f70 6965 6365 293b 0a3c 2f70 7265 in_piece);.
    rele │ │ │ +00059d80: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0
    ../src/mer │ │ │ +00059dc0: 6b6c 655f 7472 6565 2e63 7070 3a34 3539 kle_tree.cpp:459 │ │ │ +00059dd0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6869 thi │ │ │ +00059de0: 7320 636f 756c 6420 6265 2064 6f6e 6520 s could be done │ │ │ +00059df0: 6d6f 7265 2065 6666 6963 6965 6e74 6c79 more efficiently │ │ │ +00059e00: 2069 6620 6269 7466 6965 6c64 2068 6164 if bitfield had │ │ │ +00059e10: 2061 2066 756e 6374 696f 6e20 746f 2073 a function to s │ │ │ +00059e20: 6574 2061 2072 616e 6765 206f 6620 6269 et a range of bi │ │ │ +00059e30: 7473 3c2f 7464 3e3c 2f74 723e 3c74 7220 ts

    │ │ │ +00059e80: 7468 6973 2063 6f75 6c64 2062 6520 646f this could be do │ │ │ +00059e90: 6e65 206d 6f72 6520 6566 6669 6369 656e ne more efficien │ │ │ +00059ea0: 746c 7920 6966 2062 6974 6669 656c 6420 tly if bitfield │ │ │ +00059eb0: 6861 6420 6120 6675 6e63 7469 6f6e 0a74 had a function.t │ │ │ +00059ec0: 6f20 7365 7420 6120 7261 6e67 6520 6f66 o set a range of │ │ │ +00059ed0: 2062 6974 733c 2f68 323e 3c68 343e 2e2e bits

    .. │ │ │ +00059ee0: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ +00059ef0: 2e63 7070 3a34 3539 3c2f 6834 3e3c 7072 .cpp:459

    ....merkl │ │ │ +00059f40: 655f 6669 6c6c 5f74 7265 6528 6d5f 7472 e_fill_tree(m_tr │ │ │ +00059f50: 6565 2c20 626c 6f63 6b73 5f69 6e5f 7069 ee, blocks_in_pi │ │ │ +00059f60: 6563 652c 2062 6c6f 636b 5f69 6478 293b ece, block_idx); │ │ │ +00059f70: 0a09 0909 0969 6620 286d 5f74 7265 655b .....if (m_tree[ │ │ │ +00059f80: 7069 6563 655d 2021 3d20 6861 7368 6573 piece] != hashes │ │ │ +00059f90: 5b69 5d29 0a09 0909 097b 0a09 0909 0909 [i]).....{...... │ │ │ +00059fa0: 6d65 726b 6c65 5f63 6c65 6172 5f74 7265 merkle_clear_tre │ │ │ +00059fb0: 6528 6d5f 7472 6565 2c20 626c 6f63 6b73 e(m_tree, blocks │ │ │ +00059fc0: 5f69 6e5f 7069 6563 652c 2062 6c6f 636b _in_piece, block │ │ │ +00059fd0: 5f69 6478 293b 0a09 0909 0909 2f2f 2077 _idx);......// w │ │ │ +00059fe0: 7269 7465 2062 6163 6b20 7468 6520 636f rite back the co │ │ │ +00059ff0: 7272 6563 7420 6861 7368 0a09 0909 0909 rrect hash...... │ │ │ +0005a000: 6d5f 7472 6565 5b70 6965 6365 5d20 3d20 m_tree[piece] = │ │ │ +0005a010: 6861 7368 6573 5b69 5d3b 0a09 0909 0909 hashes[i];...... │ │ │ +0005a020: 544f 5252 454e 545f 4153 5345 5254 2862 TORRENT_ASSERT(b │ │ │ +0005a030: 6c6f 636b 735f 696e 5f70 6965 6365 203d locks_in_piece = │ │ │ +0005a040: 3d20 626c 6f63 6b73 5f70 6572 5f70 6965 = blocks_per_pie │ │ │ +0005a050: 6365 2829 293b 0a0a 0909 0909 092f 2f20 ce());.......// │ │ │ +0005a060: 616e 2065 6d70 7479 2062 6c6f 636b 7320 an empty blocks │ │ │ +0005a070: 7665 6374 6f72 2069 6e64 6963 6174 6573 vector indicates │ │ │ +0005a080: 2074 6861 7420 7765 2064 6f6e 2774 2068 that we don't h │ │ │ +0005a090: 6176 6520 7468 650a 0909 0909 092f 2f20 ave the......// │ │ │ +0005a0a0: 626c 6f63 6b20 6861 7368 6573 2c20 616e block hashes, an │ │ │ +0005a0b0: 6420 7765 2063 616e 2774 206b 6e6f 7720 d we can't know │ │ │ +0005a0c0: 7768 6963 6820 626c 6f63 6b20 6661 696c which block fail │ │ │ +0005a0d0: 6564 0a09 0909 0909 2f2f 2074 6869 7320 ed......// this │ │ │ +0005a0e0: 7769 6c6c 2063 6175 7365 2074 6865 2062 will cause the b │ │ │ +0005a0f0: 6c6f 636b 2068 6173 6865 7320 746f 2062 lock hashes to b │ │ │ +0005a100: 6520 7265 7175 6573 7465 640a 0909 0909 e requested..... │ │ │ +0005a110: 0972 6574 2e66 6169 6c65 642e 656d 706c .ret.failed.empl │ │ │ +0005a120: 6163 655f 6261 636b 2870 6965 6365 5f69 ace_back(piece_i │ │ │ +0005a130: 6e64 6578 5f74 7b70 6965 6365 202d 2066 ndex_t{piece - f │ │ │ +0005a140: 6972 7374 5f70 6965 6365 5f69 6478 7d20 irst_piece_idx} │ │ │ +0005a150: 2b20 6669 6c65 5f70 6965 6365 5f6f 6666 + file_piece_off │ │ │ +0005a160: 7365 740a 0909 0909 0909 2c20 7374 643a set......., std: │ │ │ +0005a170: 3a76 6563 746f 7226 6c74 3b69 6e74 2667 :vector<int&g │ │ │ +0005a180: 743b 2829 293b 0a09 0909 097d 0a09 0909 t;());.....}.... │ │ │ +0005a190: 0965 6c73 650a 0909 0909 7b0a 0909 0909 .else.....{..... │ │ │ +0005a1a0: 0972 6574 2e70 6173 7365 642e 7075 7368 .ret.passed.push │ │ │ +0005a1b0: 5f62 6163 6b28 7069 6563 655f 696e 6465 _back(piece_inde │ │ │ +0005a1c0: 785f 747b 7069 6563 6520 2d20 6669 7273 x_t{piece - firs │ │ │ +0005a1d0: 745f 7069 6563 655f 6964 787d 202b 2066 t_piece_idx} + f │ │ │ +0005a1e0: 696c 655f 7069 6563 655f 6f66 6673 6574 ile_piece_offset │ │ │ +0005a1f0: 293b 0a09 0909 0909 2f2f 2072 6563 6f72 );......// recor │ │ │ +0005a200: 6420 7468 6174 2074 6865 7365 2062 6c6f d that these blo │ │ │ +0005a210: 636b 2068 6173 6865 7320 6172 6520 636f ck hashes are co │ │ │ +0005a220: 7272 6563 7421 0a09 0909 0909 696e 7420 rrect!......int │ │ │ +0005a230: 636f 6e73 7420 6c65 6166 735f 7374 6172 const leafs_star │ │ │ +0005a240: 7420 3d20 626c 6f63 6b5f 6964 7820 2d20 t = block_idx - │ │ │ +0005a250: 626c 6f63 6b5f 6c61 7965 725f 7374 6172 block_layer_star │ │ │ +0005a260: 7428 293b 0a09 0909 0909 696e 7420 636f t();......int co │ │ │ +0005a270: 6e73 7420 6c65 6166 735f 656e 6420 3d20 nst leafs_end = │ │ │ +0005a280: 7374 643a 3a6d 696e 286d 5f6e 756d 5f62 std::min(m_num_b │ │ │ +0005a290: 6c6f 636b 732c 206c 6561 6673 5f73 7461 locks, leafs_sta │ │ │ +0005a2a0: 7274 202b 2062 6c6f 636b 735f 696e 5f70 rt + blocks_in_p │ │ │ +0005a2b0: 6965 6365 293b 0a3c 6469 7620 7374 796c iece);.
    .....for (i │ │ │ +0005a2f0: 6e74 206b 203d 206c 6561 6673 5f73 7461 nt k = leafs_sta │ │ │ +0005a300: 7274 3b20 6b20 266c 743b 206c 6561 6673 rt; k < leafs │ │ │ +0005a310: 5f65 6e64 3b20 2b2b 6b29 0a3c 2f64 6976 _end; ++k).
    ......m_block_v │ │ │ +0005a330: 6572 6966 6965 642e 7365 745f 6269 7428 erified.set_bit( │ │ │ +0005a340: 6b29 3b0a 0909 0909 7d0a 0909 0909 544f k);.....}.....TO │ │ │ +0005a350: 5252 454e 545f 4153 5345 5254 2828 7069 RRENT_ASSERT((pi │ │ │ +0005a360: 6563 6520 2d20 6669 7273 745f 7069 6563 ece - first_piec │ │ │ +0005a370: 655f 6964 7829 2026 6774 3b3d 2030 293b e_idx) >= 0); │ │ │ +0005a380: 0a09 0909 7d0a 0909 7d0a 0a09 096f 7074 ....}...}....opt │ │ │ +0005a390: 696d 697a 655f 7374 6f72 6167 6528 293b imize_storage(); │ │ │ +0005a3a0: 0a0a 0909 7265 7475 726e 2072 6574 3b0a ....return ret;. │ │ │ +0005a3b0: 097d 0a0a 0973 7464 3a3a 7475 706c 6526 .}...std::tuple& │ │ │ +0005a3c0: 6c74 3b6d 6572 6b6c 655f 7472 6565 3a3a lt;merkle_tree:: │ │ │ +0005a3d0: 7365 745f 626c 6f63 6b5f 7265 7375 6c74 set_block_result │ │ │ +0005a3e0: 2c20 696e 742c 2069 6e74 2667 743b 206d , int, int> m │ │ │ +0005a3f0: 6572 6b6c 655f 7472 6565 3a3a 7365 745f erkle_tree::set_ │ │ │ +0005a400: 626c 6f63 6b28 696e 7420 636f 6e73 7420 block(int const │ │ │ +0005a410: 626c 6f63 6b5f 696e 6465 780a 0909 2c20 block_index..., │ │ │ +0005a420: 7368 6132 3536 5f68 6173 6820 636f 6e73 sha256_hash cons │ │ │ +0005a430: 7426 616d 703b 2068 290a 097b 0a23 6966 t& h)..{.#if │ │ │ +0005a440: 6465 6620 544f 5252 454e 545f 4558 5045 def TORRENT_EXPE │ │ │ +0005a450: 4e53 4956 455f 494e 5641 5249 414e 545f NSIVE_INVARIANT_ │ │ │ +0005a460: 4348 4543 4b53 0a09 0949 4e56 4152 4941 CHECKS...INVARIA │ │ │ +0005a470: 4e54 5f43 4845 434b 3b0a 2365 6e64 6966 NT_CHECK;.#endif │ │ │ +0005a480: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0005a490: 5428 626c 6f63 6b5f 696e 6465 7820 266c T(block_index &l │ │ │ +0005a4a0: 743b 206d 5f6e 756d 5f62 6c6f 636b 7329 t; m_num_blocks) │ │ │ +0005a4b0: 3b0a 0a09 0961 7574 6f20 636f 6e73 7420 ;....auto const │ │ │ +0005a4c0: 6e75 6d5f 6c65 6166 7320 3d20 6d65 726b num_leafs = merk │ │ │ +0005a4d0: 6c65 5f6e 756d 5f6c 6561 6673 286d 5f6e le_num_leafs(m_n │ │ │ +0005a4e0: 756d 5f62 6c6f 636b 7329 3b0a 0909 6175 um_blocks);...au │ │ │ +0005a4f0: 746f 2063 6f6e 7374 2066 6972 7374 5f6c to const first_l │ │ │ +0005a500: 6561 6620 3d20 6d65 726b 6c65 5f66 6972 eaf = merkle_fir │ │ │ +0005a510: 7374 5f6c 6561 6628 6e75 6d5f 6c65 6166 st_leaf(num_leaf │ │ │ +0005a520: 7329 3b0a 0909 6175 746f 2063 6f6e 7374 s);...auto const │ │ │ +0005a530: 2062 6c6f 636b 5f74 7265 655f 696e 6465 block_tree_inde │ │ │ +0005a540: 7820 3d20 6669 7273 745f 6c65 6166 202b x = first_leaf + │ │ │ +0005a550: 2062 6c6f 636b 5f69 6e64 6578 3b0a 0a09 block_index;... │ │ │ +0005a560: 0969 6620 2862 6c6f 636b 735f 7665 7269 .if (blocks_veri │ │ │ +0005a570: 6669 6564 2862 6c6f 636b 5f69 6e64 6578 fied(block_index │ │ │ +0005a580: 2c20 3129 290a 0909 7b0a 0909 092f 2f20 , 1))...{....// │ │ │ +0005a590: 6966 2074 6869 7320 626c 6f63 6b73 2773 if this blocks's │ │ │ +0005a5a0: 2068 6173 6820 6973 2061 6c72 6561 6479 hash is already │ │ │ +0005a5b0: 206b 6e6f 776e 2c20 6368 6563 6b20 7468 known, check th │ │ │ +0005a5c0: 6520 7061 7373 6564 2d69 6e20 6861 7368 e passed-in hash │ │ │ +0005a5d0: 2061 6761 696e 7374 2069 740a 0909 0969 against it....i │ │ │ +0005a5e0: 6620 2863 6f6d 7061 7265 5f6e 6f64 6528 f (compare_node( │ │ │ +0005a5f0: 626c 6f63 6b5f 7472 6565 5f69 6e64 6578 block_tree_index │ │ │ +0005a600: 2c20 6829 290a 0909 0909 7265 7475 726e , h)).....return │ │ │ +0005a610: 2073 7464 3a3a 6d61 6b65 5f74 7570 6c65 std::make_tuple │ │ │ +0005a620: 2873 6574 5f62 6c6f 636b 5f72 6573 756c (set_block_resul │ │ │ +0005a630: 743a 3a6f 6b2c 2062 6c6f 636b 5f69 6e64 t::ok, block_ind │ │ │ +0005a640: 6578 2c20 3129 3b0a 0909 0965 6c73 650a ex, 1);....else. │ │ │ +0005a650: 0909 0909 7265 7475 726e 2073 7464 3a3a ....return std:: │ │ │ +0005a660: 6d61 6b65 5f74 7570 6c65 2873 6574 5f62 make_tuple(set_b │ │ │ +0005a670: 6c6f 636b 5f72 6573 756c 743a 3a62 6c6f lock_result::blo │ │ │ +0005a680: 636b 5f68 6173 685f 6661 696c 6564 2c20 ck_hash_failed, │ │ │ +0005a690: 626c 6f63 6b5f 696e 6465 782c 2031 293b block_index, 1); │ │ │ +0005a6a0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0005a6e0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0005a710: 7263 2f6d 6572 6b6c 655f 7472 6565 2e63 rc/merkle_tree.c │ │ │ +0005a720: 7070 3a35 3233 3c2f 613e 3c2f 7464 3e3c pp:523< │ │ │ +0005a730: 7464 3e74 6869 7320 636f 756c 6420 6265 td>this could be │ │ │ +0005a740: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ +0005a750: 6965 6e74 6c79 2069 6620 6269 7466 6965 iently if bitfie │ │ │ +0005a760: 6c64 2068 6164 2061 2066 756e 6374 696f ld had a functio │ │ │ +0005a770: 6e20 746f 2073 6574 2061 2072 616e 6765 n to set a range │ │ │ +0005a780: 206f 6620 6269 7473 3c2f 7464 3e3c 2f74 of bits

    this could │ │ │ +0005a7e0: 2062 6520 646f 6e65 206d 6f72 6520 6566 be done more ef │ │ │ +0005a7f0: 6669 6369 656e 746c 7920 6966 2062 6974 ficiently if bit │ │ │ +0005a800: 6669 656c 6420 6861 6420 6120 6675 6e63 field had a func │ │ │ +0005a810: 7469 6f6e 0a74 6f20 7365 7420 6120 7261 tion.to set a ra │ │ │ +0005a820: 6e67 6520 6f66 2062 6974 733c 2f68 323e nge of bits

    │ │ │ +0005a830: 3c68 343e 2e2e 2f73 7263 2f6d 6572 6b6c

    ../src/merkl │ │ │ +0005a840: 655f 7472 6565 2e63 7070 3a35 3233 3c2f e_tree.cpp:523
    ...
    │ │ │ +0005a890: 6d65 726b 6c65 5f66 696e 645f 6b6e 6f77  merkle_find_know
    │ │ │ +0005a8a0: 6e5f 7375 6274 7265 6528 6d5f 7472 6565  n_subtree(m_tree
    │ │ │ +0005a8b0: 2c20 626c 6f63 6b5f 696e 6465 782c 206d  , block_index, m
    │ │ │ +0005a8c0: 5f6e 756d 5f62 6c6f 636b 7329 3b0a 0a09  _num_blocks);...
    │ │ │ +0005a8d0: 092f 2f20 6966 2074 6865 2072 6f6f 7420  .// if the root 
    │ │ │ +0005a8e0: 6e6f 6465 2069 7320 756e 6b6e 6f77 6e20  node is unknown 
    │ │ │ +0005a8f0: 7468 6520 6861 7368 6573 2063 616e 6e6f  the hashes canno
    │ │ │ +0005a900: 7420 6265 2076 6572 6966 6965 6420 7965  t be verified ye
    │ │ │ +0005a910: 740a 0909 6966 2028 6d5f 7472 6565 5b72  t...if (m_tree[r
    │ │ │ +0005a920: 6f6f 745f 696e 6465 785d 2e69 735f 616c  oot_index].is_al
    │ │ │ +0005a930: 6c5f 7a65 726f 7328 2929 0a09 0909 7265  l_zeros())....re
    │ │ │ +0005a940: 7475 726e 2073 7464 3a3a 6d61 6b65 5f74  turn std::make_t
    │ │ │ +0005a950: 7570 6c65 2873 6574 5f62 6c6f 636b 5f72  uple(set_block_r
    │ │ │ +0005a960: 6573 756c 743a 3a75 6e6b 6e6f 776e 2c20  esult::unknown, 
    │ │ │ +0005a970: 6c65 6166 735f 7374 6172 742c 206c 6561  leafs_start, lea
    │ │ │ +0005a980: 6673 5f73 697a 6529 3b0a 0a09 092f 2f20  fs_size);....// 
    │ │ │ +0005a990: 7361 7665 2074 6865 2072 6f6f 7420 6861  save the root ha
    │ │ │ +0005a9a0: 7368 2062 6563 6175 7365 206d 6572 6b6c  sh because merkl
    │ │ │ +0005a9b0: 655f 6669 6c6c 5f74 7265 6520 7769 6c6c  e_fill_tree will
    │ │ │ +0005a9c0: 206f 7665 7277 7269 7465 2069 740a 0909   overwrite it...
    │ │ │ +0005a9d0: 7368 6132 3536 5f68 6173 6820 636f 6e73  sha256_hash cons
    │ │ │ +0005a9e0: 7420 726f 6f74 203d 206d 5f74 7265 655b  t root = m_tree[
    │ │ │ +0005a9f0: 726f 6f74 5f69 6e64 6578 5d3b 0a09 096d  root_index];...m
    │ │ │ +0005aa00: 6572 6b6c 655f 6669 6c6c 5f74 7265 6528  erkle_fill_tree(
    │ │ │ +0005aa10: 6d5f 7472 6565 2c20 6c65 6166 735f 7369  m_tree, leafs_si
    │ │ │ +0005aa20: 7a65 2c20 6669 7273 745f 6c65 6166 202b  ze, first_leaf +
    │ │ │ +0005aa30: 206c 6561 6673 5f73 7461 7274 293b 0a0a   leafs_start);..
    │ │ │ +0005aa40: 0909 6966 2028 726f 6f74 2021 3d20 6d5f  ..if (root != m_
    │ │ │ +0005aa50: 7472 6565 5b72 6f6f 745f 696e 6465 785d  tree[root_index]
    │ │ │ +0005aa60: 290a 0909 7b0a 0909 092f 2f20 6861 7368  )...{....// hash
    │ │ │ +0005aa70: 2066 6169 6c75 7265 2c20 636c 6561 7220   failure, clear 
    │ │ │ +0005aa80: 616c 6c20 7468 6520 696e 7465 726e 616c  all the internal
    │ │ │ +0005aa90: 206e 6f64 6573 0a09 0909 2f2f 2074 6865   nodes....// the
    │ │ │ +0005aaa0: 2077 686f 6c65 2070 6965 6365 2066 6169   whole piece fai
    │ │ │ +0005aab0: 6c65 6420 7468 6520 6861 7368 2063 6865  led the hash che
    │ │ │ +0005aac0: 636b 2e20 436c 6561 7220 616c 6c20 626c  ck. Clear all bl
    │ │ │ +0005aad0: 6f63 6b20 6861 7368 6573 0a09 0909 2f2f  ock hashes....//
    │ │ │ +0005aae0: 2069 6e20 7468 6973 2070 6965 6365 2061   in this piece a
    │ │ │ +0005aaf0: 6e64 2072 6570 6f72 7420 6120 6861 7368  nd report a hash
    │ │ │ +0005ab00: 2066 6169 6c75 7265 0a09 0909 6d65 726b   failure....merk
    │ │ │ +0005ab10: 6c65 5f63 6c65 6172 5f74 7265 6528 6d5f  le_clear_tree(m_
    │ │ │ +0005ab20: 7472 6565 2c20 6c65 6166 735f 7369 7a65  tree, leafs_size
    │ │ │ +0005ab30: 2c20 6669 7273 745f 6c65 6166 202b 206c  , first_leaf + l
    │ │ │ +0005ab40: 6561 6673 5f73 7461 7274 293b 0a09 0909  eafs_start);....
    │ │ │ +0005ab50: 6d5f 7472 6565 5b72 6f6f 745f 696e 6465  m_tree[root_inde
    │ │ │ +0005ab60: 785d 203d 2072 6f6f 743b 0a09 0909 7265  x] = root;....re
    │ │ │ +0005ab70: 7475 726e 2073 7464 3a3a 6d61 6b65 5f74  turn std::make_t
    │ │ │ +0005ab80: 7570 6c65 2873 6574 5f62 6c6f 636b 5f72  uple(set_block_r
    │ │ │ +0005ab90: 6573 756c 743a 3a68 6173 685f 6661 696c  esult::hash_fail
    │ │ │ +0005aba0: 6564 2c20 6c65 6166 735f 7374 6172 742c  ed, leafs_start,
    │ │ │ +0005abb0: 206c 6561 6673 5f73 697a 6529 3b0a 0909   leafs_size);...
    │ │ │ +0005abc0: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    ..int const lea │ │ │ +0005ac00: 6673 5f65 6e64 203d 2073 7464 3a3a 6d69 fs_end = std::mi │ │ │ +0005ac10: 6e28 6d5f 6e75 6d5f 626c 6f63 6b73 2c20 n(m_num_blocks, │ │ │ +0005ac20: 6c65 6166 735f 7374 6172 7420 2b20 6c65 leafs_start + le │ │ │ +0005ac30: 6166 735f 7369 7a65 293b 0a3c 2f64 6976 afs_size);.
    ..for (int i = │ │ │ +0005ac50: 6c65 6166 735f 7374 6172 743b 2069 2026 leafs_start; i & │ │ │ +0005ac60: 6c74 3b20 6c65 6166 735f 656e 643b 202b lt; leafs_end; + │ │ │ +0005ac70: 2b69 290a 0909 096d 5f62 6c6f 636b 5f76 +i)....m_block_v │ │ │ +0005ac80: 6572 6966 6965 642e 7365 745f 6269 7428 erified.set_bit( │ │ │ +0005ac90: 6929 3b0a 0a09 092f 2f20 6174 7465 6d70 i);....// attemp │ │ │ +0005aca0: 7469 6e67 2074 6f20 6f70 7469 6d69 7a65 ting to optimize │ │ │ +0005acb0: 2073 746f 7261 6765 2069 7320 7175 6974 storage is quit │ │ │ +0005acc0: 6520 636f 7374 6c79 2c20 6f6e 6c79 2064 e costly, only d │ │ │ +0005acd0: 6f20 6974 2069 6620 7765 2068 6176 650a o it if we have. │ │ │ +0005ace0: 0909 2f2f 2061 2072 6561 736f 6e20 746f ..// a reason to │ │ │ +0005acf0: 2062 656c 6965 7665 2069 7420 6d69 6768 believe it migh │ │ │ +0005ad00: 7420 6861 7665 2061 6e20 6566 6665 6374 t have an effect │ │ │ +0005ad10: 0a09 0969 6620 2862 6c6f 636b 5f69 6e64 ...if (block_ind │ │ │ +0005ad20: 6578 203d 3d20 6d5f 6e75 6d5f 626c 6f63 ex == m_num_bloc │ │ │ +0005ad30: 6b73 202d 2031 207c 7c20 216d 5f74 7265 ks - 1 || !m_tre │ │ │ +0005ad40: 655b 626c 6f63 6b5f 7472 6565 5f69 6e64 e[block_tree_ind │ │ │ +0005ad50: 6578 202b 2031 5d2e 6973 5f61 6c6c 5f7a ex + 1].is_all_z │ │ │ +0005ad60: 6572 6f73 2829 290a 0909 096f 7074 696d eros())....optim │ │ │ +0005ad70: 697a 655f 7374 6f72 6167 6528 293b 0a0a ize_storage();.. │ │ │ +0005ad80: 0909 7265 7475 726e 2073 7464 3a3a 6d61 ..return std::ma │ │ │ +0005ad90: 6b65 5f74 7570 6c65 2873 6574 5f62 6c6f ke_tuple(set_blo │ │ │ +0005ada0: 636b 5f72 6573 756c 743a 3a6f 6b2c 206c ck_result::ok, l │ │ │ +0005adb0: 6561 6673 5f73 7461 7274 2c20 6c65 6166 eafs_start, leaf │ │ │ +0005adc0: 735f 7369 7a65 293b 0a09 7d0a 0a09 7374 s_size);..}...st │ │ │ +0005add0: 643a 3a73 697a 655f 7420 6d65 726b 6c65 d::size_t merkle │ │ │ +0005ade0: 5f74 7265 653a 3a73 697a 6528 2920 636f _tree::size() co │ │ │ +0005adf0: 6e73 740a 097b 0a09 0972 6574 7572 6e20 nst..{...return │ │ │ +0005ae00: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ +0005ae10: 7464 3a3a 7369 7a65 5f74 2667 743b 286d td::size_t>(m │ │ │ +0005ae20: 6572 6b6c 655f 6e75 6d5f 6e6f 6465 7328 erkle_num_nodes( │ │ │ +0005ae30: 6d65 726b 6c65 5f6e 756d 5f6c 6561 6673 merkle_num_leafs │ │ │ +0005ae40: 286d 5f6e 756d 5f62 6c6f 636b 7329 2929 (m_num_blocks))) │ │ │ +0005ae50: 3b0a 097d 0a0a 0969 6e74 206d 6572 6b6c ;..}...int merkl │ │ │ +0005ae60: 655f 7472 6565 3a3a 6e75 6d5f 7069 6563 e_tree::num_piec │ │ │ +0005ae70: 6573 2829 2063 6f6e 7374 0a09 7b0a 0909 es() const..{... │ │ │ +0005ae80: 696e 7420 636f 6e73 7420 7073 203d 2062 int const ps = b │ │ │ +0005ae90: 6c6f 636b 735f 7065 725f 7069 6563 6528 locks_per_piece( │ │ │ +0005aea0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +0005aeb0: 4552 5428 7073 2026 6774 3b20 3029 3b0a ERT(ps > 0);. │ │ │ +0005aec0: 0909 7265 7475 726e 2028 6d5f 6e75 6d5f ..return (m_num_ │ │ │ +0005aed0: 626c 6f63 6b73 202b 2070 7320 2d20 3129 blocks + ps - 1) │ │ │ +0005aee0: 2026 6774 3b26 6774 3b20 6d5f 626c 6f63 >> m_bloc │ │ │ +0005aef0: 6b73 5f70 6572 5f70 6965 6365 5f6c 6f67 ks_per_piece_log │ │ │ +0005af00: 3b0a 097d 0a0a 0969 6e74 206d 6572 6b6c ;..}...int merkl │ │ │ +0005af10: 655f 7472 6565 3a3a 626c 6f63 6b5f 6c61 e_tree::block_la │ │ │ +0005af20: 7965 725f 7374 6172 7428 2920 636f 6e73 yer_start() cons │ │ │ +0005af30: 740a 097b 0a09 0969 6e74 2063 6f6e 7374 t..{...int const │ │ │ +0005af40: 206e 756d 5f6c 6561 6673 203d 206d 6572 num_leafs = mer │ │ │ +0005af50: 6b6c 655f 6e75 6d5f 6c65 6166 7328 6d5f kle_num_leafs(m_ │ │ │ +0005af60: 6e75 6d5f 626c 6f63 6b73 293b 0a09 0954 num_blocks);...T │ │ │ +0005af70: 4f52 5245 4e54 5f41 5353 4552 5428 6e75 ORRENT_ASSERT(nu │ │ │ +0005af80: 6d5f 6c65 6166 7320 2667 743b 2030 293b m_leafs > 0); │ │ │ +0005af90: 0a09 0972 6574 7572 6e20 6d65 726b 6c65 ...return merkle │ │ │ +0005afa0: 5f66 6972 7374 5f6c 6561 6628 6e75 6d5f _first_leaf(num_ │ │ │ +0005afb0: 6c65 6166 7329 3b0a 097d 0a0a 3c2f 7072 leafs);..}..rel │ │ │ +0005aff0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ +0005b030: 7272 656e 745f 696e 666f 2e63 7070 3a31 rrent_info.cpp:1 │ │ │ +0005b040: 3633 353c 2f61 3e3c 2f74 643e 3c74 643e 635 │ │ │ +0005b050: 636f 6c6c 6563 7469 6f6e 733c 2f74 643e collections │ │ │ +0005b060: 3c2f 7472 3e3c 7472 2069 643d 2232 3131

    collect │ │ │ +0005b0b0: 696f 6e73 3c2f 6832 3e3c 6834 3e2e 2e2f ions

    ../ │ │ │ +0005b0c0: 7372 632f 746f 7272 656e 745f 696e 666f src/torrent_info │ │ │ +0005b0d0: 2e63 7070 3a31 3633 353c 2f68 343e 3c70 .cpp:1635

    relevan │ │ │ +0005b150: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +0005b190: 745f 696e 666f 2e63 7070 3a31 3633 363c t_info.cpp:1636< │ │ │ +0005b1a0: 2f61 3e3c 2f74 643e 3c74 643e 7369 6d69 /a>simi │ │ │ +0005b1b0: 6c61 723c 2f74 643e 3c2f 7472 3e3c 7472 lar

    similar

    ../src/torrent_ │ │ │ +0005b220: 696e 666f 2e63 7070 3a31 3633 363c 2f68 info.cpp:1636
    ...f
    │ │ │ +0005b270: 6f72 2028 6175 746f 2063 6f6e 7374 2661  or (auto const&a
    │ │ │ +0005b280: 6d70 3b20 7572 6c20 3a20 6174 702e 7572  mp; url : atp.ur
    │ │ │ +0005b290: 6c5f 7365 6564 7329 0a09 097b 0a09 0909  l_seeds)...{....
    │ │ │ +0005b2a0: 7765 625f 7365 6564 5f65 6e74 7279 2065  web_seed_entry e
    │ │ │ +0005b2b0: 6e74 2875 726c 293b 0a09 0909 656e 742e  nt(url);....ent.
    │ │ │ +0005b2c0: 7479 7065 203d 2077 6562 5f73 6565 645f  type = web_seed_
    │ │ │ +0005b2d0: 656e 7472 793a 3a75 726c 5f73 6565 643b  entry::url_seed;
    │ │ │ +0005b2e0: 0a09 0909 6d5f 7765 625f 7365 6564 732e  ....m_web_seeds.
    │ │ │ +0005b2f0: 7075 7368 5f62 6163 6b28 7374 643a 3a6d  push_back(std::m
    │ │ │ +0005b300: 6f76 6528 656e 7429 293b 0a09 097d 0a0a  ove(ent));...}..
    │ │ │ +0005b310: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +0005b320: 7426 616d 703b 2075 726c 203a 2061 7470  t& url : atp
    │ │ │ +0005b330: 2e68 7474 705f 7365 6564 7329 0a09 097b  .http_seeds)...{
    │ │ │ +0005b340: 0a09 0909 7765 625f 7365 6564 5f65 6e74  ....web_seed_ent
    │ │ │ +0005b350: 7279 2065 6e74 2875 726c 293b 0a09 0909  ry ent(url);....
    │ │ │ +0005b360: 656e 742e 7479 7065 203d 2077 6562 5f73  ent.type = web_s
    │ │ │ +0005b370: 6565 645f 656e 7472 793a 3a68 7474 705f  eed_entry::http_
    │ │ │ +0005b380: 7365 6564 3b0a 0909 096d 5f77 6562 5f73  seed;....m_web_s
    │ │ │ +0005b390: 6565 6473 2e70 7573 685f 6261 636b 2873  eeds.push_back(s
    │ │ │ +0005b3a0: 7464 3a3a 6d6f 7665 2865 6e74 2929 3b0a  td::move(ent));.
    │ │ │ +0005b3b0: 0909 7d0a 0a09 0966 6f72 2028 6175 746f  ..}....for (auto
    │ │ │ +0005b3c0: 2063 6f6e 7374 2661 6d70 3b20 6e20 3a20   const& n : 
    │ │ │ +0005b3d0: 6174 702e 6468 745f 6e6f 6465 7329 0a09  atp.dht_nodes)..
    │ │ │ +0005b3e0: 097b 0a09 0909 6d5f 6e6f 6465 732e 656d  .{....m_nodes.em
    │ │ │ +0005b3f0: 706c 6163 655f 6261 636b 286e 293b 0a09  place_back(n);..
    │ │ │ +0005b400: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    ..return true; │ │ │ +0005b440: 0a3c 2f64 6976 3e09 7d0a 0a09 766f 6964 .
    .}...void │ │ │ +0005b450: 2074 6f72 7265 6e74 5f69 6e66 6f3a 3a61 torrent_info::a │ │ │ +0005b460: 6464 5f74 7261 636b 6572 2873 7464 3a3a dd_tracker(std:: │ │ │ +0005b470: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +0005b480: 3b20 7572 6c2c 2069 6e74 2063 6f6e 7374 ; url, int const │ │ │ +0005b490: 2074 6965 7229 0a09 7b0a 0909 6164 645f tier)..{...add_ │ │ │ +0005b4a0: 7472 6163 6b65 7228 7572 6c2c 2074 6965 tracker(url, tie │ │ │ +0005b4b0: 722c 2061 6e6e 6f75 6e63 655f 656e 7472 r, announce_entr │ │ │ +0005b4c0: 793a 3a73 6f75 7263 655f 636c 6965 6e74 y::source_client │ │ │ +0005b4d0: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ +0005b4e0: 7265 6e74 5f69 6e66 6f3a 3a61 6464 5f74 rent_info::add_t │ │ │ +0005b4f0: 7261 636b 6572 2873 7464 3a3a 7374 7269 racker(std::stri │ │ │ +0005b500: 6e67 2063 6f6e 7374 2661 6d70 3b20 7572 ng const& ur │ │ │ +0005b510: 6c2c 2069 6e74 2063 6f6e 7374 2074 6965 l, int const tie │ │ │ +0005b520: 720a 0909 2c20 616e 6e6f 756e 6365 5f65 r..., announce_e │ │ │ +0005b530: 6e74 7279 3a3a 7472 6163 6b65 725f 736f ntry::tracker_so │ │ │ +0005b540: 7572 6365 2063 6f6e 7374 2073 6f75 7263 urce const sourc │ │ │ +0005b550: 6529 0a09 7b0a 0909 544f 5252 454e 545f e)..{...TORRENT_ │ │ │ +0005b560: 4153 5345 5254 5f50 5245 434f 4e44 2821 ASSERT_PRECOND(! │ │ │ +0005b570: 7572 6c2e 656d 7074 7928 2929 3b0a 0909 url.empty());... │ │ │ +0005b580: 6175 746f 2063 6f6e 7374 2069 203d 2073 auto const i = s │ │ │ +0005b590: 7464 3a3a 6669 6e64 5f69 6628 6d5f 7572 td::find_if(m_ur │ │ │ +0005b5a0: 6c73 2e62 6567 696e 2829 2c20 6d5f 7572 ls.begin(), m_ur │ │ │ +0005b5b0: 6c73 2e65 6e64 2829 0a09 0909 2c20 5b26 ls.end()...., [& │ │ │ +0005b5c0: 616d 703b 7572 6c5d 2861 6e6e 6f75 6e63 amp;url](announc │ │ │ +0005b5d0: 655f 656e 7472 7920 636f 6e73 7426 616d e_entry const&am │ │ │ +0005b5e0: 703b 2061 6529 207b 2072 6574 7572 6e20 p; ae) { return │ │ │ +0005b5f0: 6165 2e75 726c 203d 3d20 7572 6c3b 207d ae.url == url; } │ │ │ +0005b600: 293b 0a09 0969 6620 2869 2021 3d20 6d5f );...if (i != m_ │ │ │ +0005b610: 7572 6c73 2e65 6e64 2829 2920 7265 7475 urls.end()) retu │ │ │ +0005b620: 726e 3b0a 0909 6966 2028 216c 743a 3a61 rn;...if (!lt::a │ │ │ +0005b630: 7578 3a3a 6973 5f76 616c 6964 5f74 7261 ux::is_valid_tra │ │ │ +0005b640: 636b 6572 5f75 726c 2875 726c 2929 2072 cker_url(url)) r │ │ │ +0005b650: 6574 7572 6e3b 0a0a 0909 616e 6e6f 756e eturn;....announ │ │ │ +0005b660: 6365 5f65 6e74 7279 2065 2875 726c 293b ce_entry e(url); │ │ │ +0005b670: 0a09 0965 2e74 6965 7220 3d20 7374 643a ...e.tier = std: │ │ │ +0005b680: 3a75 696e 7438 5f74 2874 6965 7229 3b0a :uint8_t(tier);. │ │ │ +0005b690: 0909 652e 736f 7572 6365 203d 2073 6f75 ..e.source = sou │ │ │ +0005b6a0: 7263 653b 0a09 096d 5f75 726c 732e 7075 rce;...m_urls.pu │ │ │ +0005b6b0: 7368 5f62 6163 6b28 6529 3b0a 0a09 0973 sh_back(e);....s │ │ │ +0005b6c0: 7464 3a3a 736f 7274 286d 5f75 726c 732e td::sort(m_urls. │ │ │ +0005b6d0: 6265 6769 6e28 292c 206d 5f75 726c 732e begin(), m_urls. │ │ │ +0005b6e0: 656e 6428 290a 0909 092c 205b 5d20 2861 end()...., [] (a │ │ │ +0005b6f0: 6e6e 6f75 6e63 655f 656e 7472 7920 636f nnounce_entry co │ │ │ +0005b700: 6e73 7426 616d 703b 206c 6873 2c20 616e nst& lhs, an │ │ │ +0005b710: 6e6f 756e 6365 5f65 6e74 7279 2063 6f6e nounce_entry con │ │ │ +0005b720: 7374 2661 6d70 3b20 7268 7329 0a09 0909 st& rhs).... │ │ │ +0005b730: 7b20 7265 7475 726e 206c 6873 2e74 6965 { return lhs.tie │ │ │ +0005b740: 7220 266c 743b 2072 6873 2e74 6965 723b r < rhs.tier; │ │ │ +0005b750: 207d 293b 0a09 7d0a 0a09 766f 6964 2074 });..}...void t │ │ │ +0005b760: 6f72 7265 6e74 5f69 6e66 6f3a 3a63 6c65 orrent_info::cle │ │ │ +0005b770: 6172 5f74 7261 636b 6572 7328 290a 097b ar_trackers()..{ │ │ │ +0005b780: 0a09 096d 5f75 726c 732e 636c 6561 7228 ...m_urls.clear( │ │ │ +0005b790: 293b 0a09 7d0a 3c2f 7072 653e 3c2f 7464 );..}.
    relevance │ │ │ +0005b7d0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005b7e0: 3c61 2068 7265 663d 226a 6176 6173 6372
    ../src/cpuid.cp │ │ │ +0005b810: 703a 3131 343c 2f61 3e3c 2f74 643e 3c74 p:114enable when aa │ │ │ +0005b830: 7263 6836 3420 6973 2072 6561 6c6c 7920 rch64 is really │ │ │ +0005b840: 7465 7374 6564 3c2f 7464 3e3c 2f74 723e tested │ │ │ +0005b850: 3c74 7220 6964 3d22 3231 3322 2073 7479 │ │ │ +0005b880: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0005b890: 3c68 323e 656e 6162 6c65 2077 6865 6e20

    enable when │ │ │ +0005b8a0: 6161 7263 6836 3420 6973 2072 6561 6c6c aarch64 is reall │ │ │ +0005b8b0: 7920 7465 7374 6564 3c2f 6832 3e3c 6834 y tested

    ../src/cpuid.cp │ │ │ +0005b8d0: 703a 3131 343c 2f68 343e 3c70 7265 2073 p:114

    .bool suppor
    │ │ │ +0005b920: 7473 5f6d 6d78 2829 206e 6f65 7863 6570  ts_mmx() noexcep
    │ │ │ +0005b930: 740a 097b 0a23 6966 2054 4f52 5245 4e54  t..{.#if TORRENT
    │ │ │ +0005b940: 5f48 4153 5f53 5345 0a09 0973 7464 3a3a  _HAS_SSE...std::
    │ │ │ +0005b950: 7569 6e74 3332 5f74 2063 7075 695b 345d  uint32_t cpui[4]
    │ │ │ +0005b960: 203d 207b 307d 3b0a 0909 6370 7569 6428   = {0};...cpuid(
    │ │ │ +0005b970: 6370 7569 2c20 3129 3b0a 0909 7265 7475  cpui, 1);...retu
    │ │ │ +0005b980: 726e 2028 6370 7569 5b32 5d20 2661 6d70  rn (cpui[2] &
    │ │ │ +0005b990: 3b20 2831 2026 6c74 3b26 6c74 3b20 3233  ; (1 << 23
    │ │ │ +0005b9a0: 2929 2021 3d20 303b 0a23 656c 7365 0a09  )) != 0;.#else..
    │ │ │ +0005b9b0: 0972 6574 7572 6e20 6661 6c73 653b 0a23  .return false;.#
    │ │ │ +0005b9c0: 656e 6469 660a 097d 0a0a 0962 6f6f 6c20  endif..}...bool 
    │ │ │ +0005b9d0: 7375 7070 6f72 7473 5f61 726d 5f6e 656f  supports_arm_neo
    │ │ │ +0005b9e0: 6e28 2920 6e6f 6578 6365 7074 0a09 7b0a  n() noexcept..{.
    │ │ │ +0005b9f0: 2369 6620 544f 5252 454e 545f 4841 535f  #if TORRENT_HAS_
    │ │ │ +0005ba00: 4152 4d5f 4e45 4f4e 2026 616d 703b 2661  ARM_NEON &&a
    │ │ │ +0005ba10: 6d70 3b20 544f 5252 454e 545f 4841 535f  mp; TORRENT_HAS_
    │ │ │ +0005ba20: 4155 5856 0a23 6966 2064 6566 696e 6564  AUXV.#if defined
    │ │ │ +0005ba30: 205f 5f61 726d 5f5f 0a09 092f 2f72 6574   __arm__...//ret
    │ │ │ +0005ba40: 7572 6e20 2867 6574 6175 7876 616c 2841  urn (getauxval(A
    │ │ │ +0005ba50: 545f 4857 4341 5029 2026 616d 703b 2048  T_HWCAP) & H
    │ │ │ +0005ba60: 5743 4150 5f4e 454f 4e29 3b0a 0909 7265  WCAP_NEON);...re
    │ │ │ +0005ba70: 7475 726e 2028 6865 6c70 6572 5f67 6574  turn (helper_get
    │ │ │ +0005ba80: 6175 7876 616c 2831 3629 2026 616d 703b  auxval(16) &
    │ │ │ +0005ba90: 2028 3120 266c 743b 266c 743b 2031 3229   (1 << 12)
    │ │ │ +0005baa0: 293b 0a23 656c 6966 2064 6566 696e 6564  );.#elif defined
    │ │ │ +0005bab0: 205f 5f61 6172 6368 3634 5f5f 0a09 092f   __aarch64__.../
    │ │ │ +0005bac0: 2f72 6574 7572 6e20 2867 6574 6175 7876  /return (getauxv
    │ │ │ +0005bad0: 616c 2841 545f 4857 4341 5029 2026 616d  al(AT_HWCAP) &am
    │ │ │ +0005bae0: 703b 2048 5743 4150 5f41 5349 4d44 293b  p; HWCAP_ASIMD);
    │ │ │ +0005baf0: 0a09 092f 2f72 6574 7572 6e20 2867 6574  ...//return (get
    │ │ │ +0005bb00: 6175 7876 616c 2831 3629 2026 616d 703b  auxval(16) &
    │ │ │ +0005bb10: 2028 3120 266c 743b 266c 743b 2031 2929   (1 << 1))
    │ │ │ +0005bb20: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261  ;.
    │ │ │ +0005bb50: 0909 7265 7475 726e 2066 616c 7365 3b0a ..return false;. │ │ │ +0005bb60: 3c2f 6469 763e 2365 6e64 6966 0a23 656c
    #endif.#el │ │ │ +0005bb70: 7365 0a09 0972 6574 7572 6e20 6661 6c73 se...return fals │ │ │ +0005bb80: 653b 0a23 656e 6469 660a 097d 0a0a 0962 e;.#endif..}...b │ │ │ +0005bb90: 6f6f 6c20 7375 7070 6f72 7473 5f61 726d ool supports_arm │ │ │ +0005bba0: 5f63 7263 3332 6328 2920 6e6f 6578 6365 _crc32c() noexce │ │ │ +0005bbb0: 7074 0a09 7b0a 2369 6620 544f 5252 454e pt..{.#if TORREN │ │ │ +0005bbc0: 545f 4841 535f 4152 4d5f 4352 4333 3220 T_HAS_ARM_CRC32 │ │ │ +0005bbd0: 2661 6d70 3b26 616d 703b 2054 4f52 5245 && TORRE │ │ │ +0005bbe0: 4e54 5f48 4153 5f41 5558 560a 2369 6620 NT_HAS_AUXV.#if │ │ │ +0005bbf0: 6465 6669 6e65 6420 544f 5252 454e 545f defined TORRENT_ │ │ │ +0005bc00: 464f 5243 455f 4152 4d5f 4352 4333 320a FORCE_ARM_CRC32. │ │ │ +0005bc10: 0909 7265 7475 726e 2074 7275 653b 0a23 ..return true;.# │ │ │ +0005bc20: 656c 6966 2064 6566 696e 6564 205f 5f61 elif defined __a │ │ │ +0005bc30: 726d 5f5f 0a09 092f 2f72 6574 7572 6e20 rm__...//return │ │ │ +0005bc40: 2867 6574 6175 7876 616c 2841 545f 4857 (getauxval(AT_HW │ │ │ +0005bc50: 4341 5032 2920 2661 6d70 3b20 4857 4341 CAP2) & HWCA │ │ │ +0005bc60: 5032 5f43 5243 3332 293b 0a09 0972 6574 P2_CRC32);...ret │ │ │ +0005bc70: 7572 6e20 2868 656c 7065 725f 6765 7461 urn (helper_geta │ │ │ +0005bc80: 7578 7661 6c28 3236 2920 2661 6d70 3b20 uxval(26) & │ │ │ +0005bc90: 2831 2026 6c74 3b26 6c74 3b20 3429 293b (1 << 4)); │ │ │ +0005bca0: 0a23 656c 6966 2064 6566 696e 6564 205f .#elif defined _ │ │ │ +0005bcb0: 5f61 6172 6368 3634 5f5f 0a09 092f 2f72 _aarch64__...//r │ │ │ +0005bcc0: 6574 7572 6e20 2867 6574 6175 7876 616c eturn (getauxval │ │ │ +0005bcd0: 2841 545f 4857 4341 5029 2026 616d 703b (AT_HWCAP) & │ │ │ +0005bce0: 2048 5743 4150 5f43 5243 3332 293b 0a09 HWCAP_CRC32);.. │ │ │ +0005bcf0: 0972 6574 7572 6e20 2868 656c 7065 725f .return (helper_ │ │ │ +0005bd00: 6765 7461 7578 7661 6c28 3136 2920 2661 getauxval(16) &a │ │ │ +0005bd10: 6d70 3b20 2831 2026 6c74 3b26 6c74 3b20 mp; (1 << │ │ │ +0005bd20: 3729 293b 0a23 656e 6469 660a 2365 6c73 7));.#endif.#els │ │ │ +0005bd30: 650a 0909 7265 7475 726e 2066 616c 7365 e...return false │ │ │ +0005bd40: 3b0a 2365 6e64 6966 0a09 7d0a 0a23 6966 ;.#endif..}..#if │ │ │ +0005bd50: 6465 6620 5f5f 636c 616e 675f 5f0a 2370 def __clang__.#p │ │ │ +0005bd60: 7261 676d 6120 636c 616e 6720 6469 6167 ragma clang diag │ │ │ +0005bd70: 6e6f 7374 6963 2070 6f70 0a23 656e 6469 nostic pop.#endi │ │ │ +0005bd80: 660a 0a7d 202f 2f20 616e 6f6e 796d 6f75 f..} // anonymou │ │ │ +0005bd90: 7320 6e61 6d65 7370 6163 650a 0a09 626f s namespace...bo │ │ │ +0005bda0: 6f6c 2063 6f6e 7374 2073 7365 3432 5f73 ol const sse42_s │ │ │ +0005bdb0: 7570 706f 7274 203d 2073 7570 706f 7274 upport = support │ │ │ +0005bdc0: 735f 7373 6534 3228 293b 0a3c 2f70 7265 s_sse42();.
    rele │ │ │ +0005be00: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ +0005be40: 7369 6f6e 2e63 7070 3a32 3631 3c2f 613e sion.cpp:261 │ │ │ +0005be50: 3c2f 7464 3e3c 7464 3e73 7461 7274 2829 start() │ │ │ +0005be60: 2073 686f 756c 6420 6a75 7374 2075 7365 should just use │ │ │ +0005be70: 2066 6c61 6773 206f 7574 206f 6620 7468 flags out of th │ │ │ +0005be80: 6520 7365 7373 696f 6e5f 7061 7261 6d73 e session_params │ │ │ +0005be90: 206f 626a 6563 742c 3c2f 7464 3e3c 2f74 object,

    start() sh │ │ │ +0005bef0: 6f75 6c64 206a 7573 7420 7573 6520 666c ould just use fl │ │ │ +0005bf00: 6167 7320 6f75 7420 6f66 2074 6865 2073 ags out of the s │ │ │ +0005bf10: 6573 7369 6f6e 5f70 6172 616d 7320 6f62 ession_params ob │ │ │ +0005bf20: 6a65 6374 2c3c 2f68 323e 3c68 343e 2e2e ject,

    .. │ │ │ +0005bf30: 2f73 7263 2f73 6573 7369 6f6e 2e63 7070 /src/session.cpp │ │ │ +0005bf40: 3a32 3631 3c2f 6834 3e3c 7072 6520 7374 :261

    ..SET_BOOL(re
    │ │ │ +0005bf90: 7374 7269 6374 5f72 6f75 7469 6e67 5f69  strict_routing_i
    │ │ │ +0005bfa0: 7073 293b 0a09 0953 4554 5f42 4f4f 4c28  ps);...SET_BOOL(
    │ │ │ +0005bfb0: 7265 7374 7269 6374 5f73 6561 7263 685f  restrict_search_
    │ │ │ +0005bfc0: 6970 7329 3b0a 0909 5345 545f 424f 4f4c  ips);...SET_BOOL
    │ │ │ +0005bfd0: 2865 7874 656e 6465 645f 726f 7574 696e  (extended_routin
    │ │ │ +0005bfe0: 675f 7461 626c 6529 3b0a 0909 5345 545f  g_table);...SET_
    │ │ │ +0005bff0: 424f 4f4c 2861 6767 7265 7373 6976 655f  BOOL(aggressive_
    │ │ │ +0005c000: 6c6f 6f6b 7570 7329 3b0a 0909 5345 545f  lookups);...SET_
    │ │ │ +0005c010: 424f 4f4c 2870 7269 7661 6379 5f6c 6f6f  BOOL(privacy_loo
    │ │ │ +0005c020: 6b75 7073 293b 0a09 0953 4554 5f42 4f4f  kups);...SET_BOO
    │ │ │ +0005c030: 4c28 656e 666f 7263 655f 6e6f 6465 5f69  L(enforce_node_i
    │ │ │ +0005c040: 6429 3b0a 0909 5345 545f 424f 4f4c 2869  d);...SET_BOOL(i
    │ │ │ +0005c050: 676e 6f72 655f 6461 726b 5f69 6e74 6572  gnore_dark_inter
    │ │ │ +0005c060: 6e65 7429 3b0a 0909 5345 545f 494e 5428  net);...SET_INT(
    │ │ │ +0005c070: 626c 6f63 6b5f 7469 6d65 6f75 7429 3b0a  block_timeout);.
    │ │ │ +0005c080: 0909 5345 545f 494e 5428 626c 6f63 6b5f  ..SET_INT(block_
    │ │ │ +0005c090: 7261 7465 6c69 6d69 7429 3b0a 0909 5345  ratelimit);...SE
    │ │ │ +0005c0a0: 545f 424f 4f4c 2872 6561 645f 6f6e 6c79  T_BOOL(read_only
    │ │ │ +0005c0b0: 293b 0a09 0953 4554 5f49 4e54 2869 7465  );...SET_INT(ite
    │ │ │ +0005c0c0: 6d5f 6c69 6665 7469 6d65 293b 0a09 0953  m_lifetime);...S
    │ │ │ +0005c0d0: 4554 5f49 4e54 2875 706c 6f61 645f 7261  ET_INT(upload_ra
    │ │ │ +0005c0e0: 7465 5f6c 696d 6974 293b 0a09 0953 4554  te_limit);...SET
    │ │ │ +0005c0f0: 5f49 4e54 2873 616d 706c 655f 696e 666f  _INT(sample_info
    │ │ │ +0005c100: 6861 7368 6573 5f69 6e74 6572 7661 6c29  hashes_interval)
    │ │ │ +0005c110: 3b0a 0909 5345 545f 494e 5428 6d61 785f  ;...SET_INT(max_
    │ │ │ +0005c120: 696e 666f 6861 7368 6573 5f73 616d 706c  infohashes_sampl
    │ │ │ +0005c130: 655f 636f 756e 7429 3b0a 2375 6e64 6566  e_count);.#undef
    │ │ │ +0005c140: 2053 4554 5f42 4f4f 4c0a 2375 6e64 6566   SET_BOOL.#undef
    │ │ │ +0005c150: 2053 4554 5f49 4e54 0a09 097d 0a23 656e   SET_INT...}.#en
    │ │ │ +0005c160: 6469 660a 2365 6e64 6966 0a0a 3c64 6976  dif.#endif..
    ..m_im │ │ │ +0005c1a0: 706c 203d 2073 7464 3a3a 6d61 6b65 5f73 pl = std::make_s │ │ │ +0005c1b0: 6861 7265 6426 6c74 3b61 7578 3a3a 7365 hared<aux::se │ │ │ +0005c1c0: 7373 696f 6e5f 696d 706c 2667 743b 2873 ssion_impl>(s │ │ │ +0005c1d0: 7464 3a3a 7265 6628 2a69 6f73 290a 3c2f td::ref(*ios)...., std::mo │ │ │ +0005c1f0: 7665 2870 6172 616d 732e 7365 7474 696e ve(params.settin │ │ │ +0005c200: 6773 290a 0909 092c 2073 7464 3a3a 6d6f gs)...., std::mo │ │ │ +0005c210: 7665 2870 6172 616d 732e 6469 736b 5f69 ve(params.disk_i │ │ │ +0005c220: 6f5f 636f 6e73 7472 7563 746f 7229 0a09 o_constructor).. │ │ │ +0005c230: 0909 2c20 666c 6167 7329 3b0a 0909 2a73 .., flags);...*s │ │ │ +0005c240: 7461 7469 635f 6361 7374 266c 743b 7365 tatic_cast<se │ │ │ +0005c250: 7373 696f 6e5f 6861 6e64 6c65 2a26 6774 ssion_handle*> │ │ │ +0005c260: 3b28 7468 6973 2920 3d20 7365 7373 696f ;(this) = sessio │ │ │ +0005c270: 6e5f 6861 6e64 6c65 286d 5f69 6d70 6c29 n_handle(m_impl) │ │ │ +0005c280: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245 ;..#ifndef TORRE │ │ │ +0005c290: 4e54 5f44 4953 4142 4c45 5f45 5854 454e NT_DISABLE_EXTEN │ │ │ +0005c2a0: 5349 4f4e 530a 0909 666f 7220 2861 7574 SIONS...for (aut │ │ │ +0005c2b0: 6f26 616d 703b 2065 7874 203a 2070 6172 o& ext : par │ │ │ +0005c2c0: 616d 732e 6578 7465 6e73 696f 6e73 290a ams.extensions). │ │ │ +0005c2d0: 0909 7b0a 0909 0965 7874 2d26 6774 3b6c ..{....ext->l │ │ │ +0005c2e0: 6f61 645f 7374 6174 6528 7061 7261 6d73 oad_state(params │ │ │ +0005c2f0: 2e65 7874 5f73 7461 7465 293b 0a09 0909 .ext_state);.... │ │ │ +0005c300: 6d5f 696d 706c 2d26 6774 3b61 6464 5f73 m_impl->add_s │ │ │ +0005c310: 6573 5f65 7874 656e 7369 6f6e 2873 7464 es_extension(std │ │ │ +0005c320: 3a3a 6d6f 7665 2865 7874 2929 3b0a 0909 ::move(ext));... │ │ │ +0005c330: 7d0a 2365 6e64 6966 0a0a 2369 666e 6465 }.#endif..#ifnde │ │ │ +0005c340: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0005c350: 455f 4448 540a 0909 6d5f 696d 706c 2d26 E_DHT...m_impl-& │ │ │ +0005c360: 6774 3b73 6574 5f64 6874 5f73 7461 7465 gt;set_dht_state │ │ │ +0005c370: 2873 7464 3a3a 6d6f 7665 2870 6172 616d (std::move(param │ │ │ +0005c380: 732e 6468 745f 7374 6174 6529 293b 0a0a s.dht_state));.. │ │ │ +0005c390: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0005c3a0: 2870 6172 616d 732e 6468 745f 7374 6f72 (params.dht_stor │ │ │ +0005c3b0: 6167 655f 636f 6e73 7472 7563 746f 7229 age_constructor) │ │ │ +0005c3c0: 3b0a 0909 6d5f 696d 706c 2d26 6774 3b73 ;...m_impl->s │ │ │ +0005c3d0: 6574 5f64 6874 5f73 746f 7261 6765 2873 et_dht_storage(s │ │ │ +0005c3e0: 7464 3a3a 6d6f 7665 2870 6172 616d 732e td::move(params. │ │ │ +0005c3f0: 6468 745f 7374 6f72 6167 655f 636f 6e73 dht_storage_cons │ │ │ +0005c400: 7472 7563 746f 7229 293b 0a23 656e 6469 tructor));.#endi │ │ │ +0005c410: 660a 0a09 0969 6620 2821 7061 7261 6d73 f....if (!params │ │ │ +0005c420: 2e69 705f 6669 6c74 6572 2e65 6d70 7479 .ip_filter.empty │ │ │ +0005c430: 2829 290a 0909 7b0a 0909 0973 7464 3a3a ())...{....std:: │ │ │ +0005c440: 7368 6172 6564 5f70 7472 266c 743b 6970 shared_ptr<ip │ │ │ +0005c450: 5f66 696c 7465 7226 6774 3b20 636f 7079 _filter> copy │ │ │ +0005c460: 203d 2073 7464 3a3a 6d61 6b65 5f73 6861 = std::make_sha │ │ │ +0005c470: 7265 6426 6c74 3b69 705f 6669 6c74 6572 red<ip_filter │ │ │ +0005c480: 2667 743b 2873 7464 3a3a 6d6f 7665 2870 >(std::move(p │ │ │ +0005c490: 6172 616d 732e 6970 5f66 696c 7465 7229 arams.ip_filter) │ │ │ +0005c4a0: 293b 0a09 0909 6d5f 696d 706c 2d26 6774 );....m_impl-> │ │ │ +0005c4b0: 3b73 6574 5f69 705f 6669 6c74 6572 2873 ;set_ip_filter(s │ │ │ +0005c4c0: 7464 3a3a 6d6f 7665 2863 6f70 7929 293b td::move(copy)); │ │ │ +0005c4d0: 0a09 097d 0a0a 0909 6d5f 696d 706c 2d26 ...}....m_impl-& │ │ │ +0005c4e0: 6774 3b73 7461 7274 5f73 6573 7369 6f6e gt;start_session │ │ │ +0005c4f0: 2829 3b0a 0a09 0969 6620 2869 6e74 6572 ();....if (inter │ │ │ +0005c500: 6e61 6c5f 6578 6563 7574 6f72 290a 0909 nal_executor)... │ │ │ +0005c510: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.
    < │ │ │ +0005c540: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0005c550: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0005c580: 7372 632f 7574 705f 736f 636b 6574 5f6d src/utp_socket_m │ │ │ +0005c590: 616e 6167 6572 2e63 7070 3a31 3830 3c2f anager.cpp:180this │ │ │ +0005c5b0: 7368 6f75 6c64 206e 6f74 2062 6520 6865 should not be he │ │ │ +0005c5c0: 6170 2061 6c6c 6f63 6174 6564 2c20 736f ap allocated, so │ │ │ +0005c5d0: 636b 6574 7320 7368 6f75 6c64 2062 6520 ckets should be │ │ │ +0005c5e0: 6d6f 7661 626c 653c 2f74 643e 3c2f 7472 movable

    this should │ │ │ +0005c640: 206e 6f74 2062 6520 6865 6170 2061 6c6c not be heap all │ │ │ +0005c650: 6f63 6174 6564 2c20 736f 636b 6574 7320 ocated, sockets │ │ │ +0005c660: 7368 6f75 6c64 2062 6520 6d6f 7661 626c should be movabl │ │ │ +0005c670: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ +0005c680: 2f75 7470 5f73 6f63 6b65 745f 6d61 6e61 /utp_socket_mana │ │ │ +0005c690: 6765 722e 6370 703a 3138 303c 2f68 343e ger.cpp:180

    │ │ │ +0005c6a0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .//..U
    │ │ │ +0005c6e0: 5450 5f4c 4f47 5628 2269 6e63 6f6d 696e  TP_LOGV("incomin
    │ │ │ +0005c6f0: 6720 7061 636b 6574 2069 643a 2564 2073  g packet id:%d s
    │ │ │ +0005c700: 6f75 7263 653a 2573 5c6e 222c 2069 642c  ource:%s\n", id,
    │ │ │ +0005c710: 2070 7269 6e74 5f65 6e64 706f 696e 7428   print_endpoint(
    │ │ │ +0005c720: 6570 292e 635f 7374 7228 2929 3b0a 0a09  ep).c_str());...
    │ │ │ +0005c730: 0969 6620 2821 6d5f 7365 7474 2e67 6574  .if (!m_sett.get
    │ │ │ +0005c740: 5f62 6f6f 6c28 7365 7474 696e 6773 5f70  _bool(settings_p
    │ │ │ +0005c750: 6163 6b3a 3a65 6e61 626c 655f 696e 636f  ack::enable_inco
    │ │ │ +0005c760: 6d69 6e67 5f75 7470 2929 0a09 0909 7265  ming_utp))....re
    │ │ │ +0005c770: 7475 726e 2066 616c 7365 3b0a 0a09 092f  turn false;..../
    │ │ │ +0005c780: 2f20 6966 206e 6f74 2066 6f75 6e64 2c20  / if not found, 
    │ │ │ +0005c790: 7365 6520 6966 2069 7427 7320 6120 5359  see if it's a SY
    │ │ │ +0005c7a0: 4e20 7061 636b 6574 2c20 6966 2069 7420  N packet, if it 
    │ │ │ +0005c7b0: 6973 2c0a 0909 2f2f 2063 7265 6174 6520  is,...// create 
    │ │ │ +0005c7c0: 6120 6e65 7720 7574 705f 7374 7265 616d  a new utp_stream
    │ │ │ +0005c7d0: 0a09 0969 6620 2870 682d 2667 743b 6765  ...if (ph->ge
    │ │ │ +0005c7e0: 745f 7479 7065 2829 203d 3d20 5354 5f53  t_type() == ST_S
    │ │ │ +0005c7f0: 594e 290a 0909 7b0a 0909 092f 2f20 706f  YN)...{....// po
    │ │ │ +0005c800: 7373 6962 6c65 2053 594e 2066 6c6f 6f64  ssible SYN flood
    │ │ │ +0005c810: 2e20 4a75 7374 2069 676e 6f72 650a 0909  . Just ignore...
    │ │ │ +0005c820: 0969 6620 2869 6e74 286d 5f75 7470 5f73  .if (int(m_utp_s
    │ │ │ +0005c830: 6f63 6b65 7473 2e73 697a 6528 2929 2026  ockets.size()) &
    │ │ │ +0005c840: 6774 3b20 6d5f 7365 7474 2e67 6574 5f69  gt; m_sett.get_i
    │ │ │ +0005c850: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ +0005c860: 3a3a 636f 6e6e 6563 7469 6f6e 735f 6c69  ::connections_li
    │ │ │ +0005c870: 6d69 7429 202a 2032 290a 0909 0909 7265  mit) * 2).....re
    │ │ │ +0005c880: 7475 726e 2066 616c 7365 3b0a 0a09 0909  turn false;.....
    │ │ │ +0005c890: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ +0005c8a0: 5f6e 6577 5f63 6f6e 6e65 6374 696f 6e20  _new_connection 
    │ │ │ +0005c8b0: 3d3d 202d 3129 3b0a 0909 092f 2f20 6372  == -1);....// cr
    │ │ │ +0005c8c0: 6561 7465 2074 6865 206e 6577 2073 6f63  eate the new soc
    │ │ │ +0005c8d0: 6b65 7420 7769 7468 2074 6869 7320 4944  ket with this ID
    │ │ │ +0005c8e0: 0a09 0909 6d5f 6e65 775f 636f 6e6e 6563  ....m_new_connec
    │ │ │ +0005c8f0: 7469 6f6e 203d 2069 643b 0a0a 2f2f 0909  tion = id;..//..
    │ │ │ +0005c900: 0955 5450 5f4c 4f47 5628 226e 6f74 2066  .UTP_LOGV("not f
    │ │ │ +0005c910: 6f75 6e64 2c20 6e65 7720 636f 6e6e 6563  ound, new connec
    │ │ │ +0005c920: 7469 6f6e 2069 643a 2564 5c6e 222c 206d  tion id:%d\n", m
    │ │ │ +0005c930: 5f6e 6577 5f63 6f6e 6e65 6374 696f 6e29  _new_connection)
    │ │ │ +0005c940: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ...aux::socket_ │ │ │ +0005c980: 7479 7065 2063 2861 7578 3a3a 696e 7374 type c(aux::inst │ │ │ +0005c990: 616e 7469 6174 655f 636f 6e6e 6563 7469 antiate_connecti │ │ │ +0005c9a0: 6f6e 286d 5f69 6f73 2c20 6175 783a 3a70 on(m_ios, aux::p │ │ │ +0005c9b0: 726f 7879 5f73 6574 7469 6e67 7328 292c roxy_settings(), │ │ │ +0005c9c0: 206d 5f73 736c 5f63 6f6e 7465 7874 2c20 m_ssl_context, │ │ │ +0005c9d0: 7468 6973 2c20 7472 7565 2c20 6661 6c73 this, true, fals │ │ │ +0005c9e0: 6529 293b 0a3c 2f64 6976 3e0a 0909 0975 e));.
    ....u │ │ │ +0005c9f0: 7470 5f73 7472 6561 6d2a 2073 7472 203d tp_stream* str = │ │ │ +0005ca00: 206e 756c 6c70 7472 3b0a 2369 6664 6566 nullptr;.#ifdef │ │ │ +0005ca10: 2054 4f52 5245 4e54 5f53 534c 5f50 4545 TORRENT_SSL_PEE │ │ │ +0005ca20: 5253 0a09 0909 6966 2028 6973 5f73 736c RS....if (is_ssl │ │ │ +0005ca30: 2863 2929 0a09 0909 0973 7472 203d 2026 (c)).....str = & │ │ │ +0005ca40: 616d 703b 7374 643a 3a67 6574 266c 743b amp;std::get< │ │ │ +0005ca50: 7373 6c5f 7374 7265 616d 266c 743b 7574 ssl_stream<ut │ │ │ +0005ca60: 705f 7374 7265 616d 2667 743b 2667 743b p_stream>> │ │ │ +0005ca70: 2863 292e 6e65 7874 5f6c 6179 6572 2829 (c).next_layer() │ │ │ +0005ca80: 3b0a 0909 0965 6c73 650a 2365 6e64 6966 ;....else.#endif │ │ │ +0005ca90: 0a09 0909 0973 7472 203d 2073 7464 3a3a .....str = std:: │ │ │ +0005caa0: 6765 745f 6966 266c 743b 7574 705f 7374 get_if<utp_st │ │ │ +0005cab0: 7265 616d 2667 743b 2826 616d 703b 6329 ream>(&c) │ │ │ +0005cac0: 3b0a 0a09 0909 544f 5252 454e 545f 4153 ;.....TORRENT_AS │ │ │ +0005cad0: 5345 5254 2873 7472 293b 0a09 0909 696e SERT(str);....in │ │ │ +0005cae0: 7420 636f 6e73 7420 6d74 7520 3d20 6d74 t const mtu = mt │ │ │ +0005caf0: 755f 666f 725f 6465 7374 2865 702e 6164 u_for_dest(ep.ad │ │ │ +0005cb00: 6472 6573 7328 2929 3b0a 0909 0973 7472 dress());....str │ │ │ +0005cb10: 2d26 6774 3b67 6574 5f69 6d70 6c28 292d ->get_impl()- │ │ │ +0005cb20: 2667 743b 696e 6974 5f6d 7475 286d 7475 >init_mtu(mtu │ │ │ +0005cb30: 293b 0a09 0909 7374 722d 2667 743b 6765 );....str->ge │ │ │ +0005cb40: 745f 696d 706c 2829 2d26 6774 3b6d 5f73 t_impl()->m_s │ │ │ +0005cb50: 6f63 6b20 3d20 7374 643a 3a6d 6f76 6528 ock = std::move( │ │ │ +0005cb60: 736f 636b 6574 293b 0a09 0909 626f 6f6c socket);....bool │ │ │ +0005cb70: 2063 6f6e 7374 2072 6574 203d 2073 7472 const ret = str │ │ │ +0005cb80: 2d26 6774 3b67 6574 5f69 6d70 6c28 292d ->get_impl()- │ │ │ +0005cb90: 2667 743b 696e 636f 6d69 6e67 5f70 6163 >incoming_pac │ │ │ +0005cba0: 6b65 7428 702c 2065 702c 2072 6563 6569 ket(p, ep, recei │ │ │ +0005cbb0: 7665 5f74 696d 6529 3b0a 0909 0969 6620 ve_time);....if │ │ │ +0005cbc0: 2821 7265 7429 2072 6574 7572 6e20 6661 (!ret) return fa │ │ │ +0005cbd0: 6c73 653b 0a09 0909 6d5f 6c61 7374 5f73 lse;....m_last_s │ │ │ +0005cbe0: 6f63 6b65 7420 3d20 7374 722d 2667 743b ocket = str-> │ │ │ +0005cbf0: 6765 745f 696d 706c 2829 3b0a 0909 096d get_impl();....m │ │ │ +0005cc00: 5f63 6228 7374 643a 3a6d 6f76 6528 6329 _cb(std::move(c) │ │ │ +0005cc10: 293b 0a09 0909 2f2f 2074 6865 2063 6f6e );....// the con │ │ │ +0005cc20: 6e65 6374 696f 6e20 6d6f 7374 206c 696b nection most lik │ │ │ +0005cc30: 656c 7920 6368 616e 6765 6420 6974 7320 ely changed its │ │ │ +0005cc40: 636f 6e6e 6563 7469 6f6e 2049 4420 6865 connection ID he │ │ │ +0005cc50: 7265 0a09 0909 2f2f 2077 6520 6e65 6564 re....// we need │ │ │ +0005cc60: 2074 6f20 6d6f 7665 2069 7420 746f 2074 to move it to t │ │ │ +0005cc70: 6865 2063 6f72 7265 6374 2049 440a 0909 he correct ID... │ │ │ +0005cc80: 0972 6574 7572 6e20 7472 7565 3b0a 0909 .return true;... │ │ │ +0005cc90: 7d0a 0a09 0969 6620 2870 682d 2667 743b }....if (ph-> │ │ │ +0005cca0: 6765 745f 7479 7065 2829 203d 3d20 5354 get_type() == ST │ │ │ +0005ccb0: 5f52 4553 4554 2920 7265 7475 726e 2066 _RESET) return f │ │ │ +0005ccc0: 616c 7365 3b0a 0a09 092f 2f20 2365 7272 alse;....// #err │ │ │ +0005ccd0: 6f72 2073 656e 6420 7265 7365 740a 0a09 or send reset... │ │ │ +0005cce0: 0972 6574 7572 6e20 6661 6c73 653b 0a09 .return false;.. │ │ │ +0005ccf0: 7d0a 0a09 766f 6964 2075 7470 5f73 6f63 }...void utp_soc │ │ │ +0005cd00: 6b65 745f 6d61 6e61 6765 723a 3a73 7562 ket_manager::sub │ │ │ +0005cd10: 7363 7269 6265 5f77 7269 7461 626c 6528 scribe_writable( │ │ │ +0005cd20: 7574 705f 736f 636b 6574 5f69 6d70 6c2a utp_socket_impl* │ │ │ +0005cd30: 2073 290a 3c2f 7072 653e 3c2f 7464 3e3c s).
    < │ │ │ +0005cd40: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0005cd70: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ +0005cda0: 2e2f 7372 632f 736d 6172 745f 6261 6e2e ./src/smart_ban. │ │ │ +0005cdb0: 6370 703a 3135 383c 2f61 3e3c 2f74 643e cpp:158 │ │ │ +0005cdc0: 3c74 643e 7265 706c 6163 6520 7769 7468 replace with │ │ │ +0005cdd0: 2073 7464 3a3a 6572 6173 655f 6966 2829 std::erase_if() │ │ │ +0005cde0: 206f 6e63 6520 7765 2072 6571 7569 7265 once we require │ │ │ +0005cdf0: 2043 2b2b 3230 3c2f 7464 3e3c 2f74 723e C++20 │ │ │ +0005ce00: 3c74 7220 6964 3d22 3231 3622 2073 7479 │ │ │ +0005ce30: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0005ce40: 3c68 323e 7265 706c 6163 6520 7769 7468

    replace with │ │ │ +0005ce50: 2073 7464 3a3a 6572 6173 655f 6966 2829 std::erase_if() │ │ │ +0005ce60: 206f 6e63 6520 7765 2072 6571 7569 7265 once we require │ │ │ +0005ce70: 2043 2b2b 3230 3c2f 6832 3e3c 6834 3e2e C++20

    . │ │ │ +0005ce80: 2e2f 7372 632f 736d 6172 745f 6261 6e2e ./src/smart_ban. │ │ │ +0005ce90: 6370 703a 3135 383c 2f68 343e 3c70 7265 cpp:158

    ......, di
    │ │ │ +0005cee0: 736b 5f69 6e74 6572 6661 6365 3a3a 666f  sk_interface::fo
    │ │ │ +0005cef0: 7263 655f 636f 7079 293b 0a09 0909 097d  rce_copy);.....}
    │ │ │ +0005cf00: 0a0a 0909 0909 722e 7374 6172 7420 2b3d  ......r.start +=
    │ │ │ +0005cf10: 2031 362a 3130 3234 3b0a 0909 0909 7369   16*1024;.....si
    │ │ │ +0005cf20: 7a65 202d 3d20 3136 2a31 3032 343b 0a09  ze -= 16*1024;..
    │ │ │ +0005cf30: 0909 0972 2e6c 656e 6774 6820 3d20 7374  ...r.length = st
    │ │ │ +0005cf40: 643a 3a6d 696e 2831 362a 3130 3234 2c20  d::min(16*1024, 
    │ │ │ +0005cf50: 7369 7a65 293b 0a09 0909 092b 2b70 622e  size);.....++pb.
    │ │ │ +0005cf60: 626c 6f63 6b5f 696e 6465 783b 0a09 0909  block_index;....
    │ │ │ +0005cf70: 7d0a 0909 0954 4f52 5245 4e54 5f41 5353  }....TORRENT_ASS
    │ │ │ +0005cf80: 4552 5428 7369 7a65 2026 6c74 3b3d 2030  ERT(size <= 0
    │ │ │ +0005cf90: 293b 0a09 097d 0a0a 0909 2f2f 206e 6f74  );...}....// not
    │ │ │ +0005cfa0: 2064 6563 6c61 7265 6420 6f6e 2074 6f72   declared on tor
    │ │ │ +0005cfb0: 7265 6e74 5f70 6c75 6769 6e20 2877 6f75  rent_plugin (wou
    │ │ │ +0005cfc0: 6c64 2072 6571 7569 7265 2061 6e20 4142  ld require an AB
    │ │ │ +0005cfd0: 492d 6272 6561 6b69 6e67 206e 6577 0a09  I-breaking new..
    │ │ │ +0005cfe0: 092f 2f20 7669 7274 7561 6c29 2e20 4361  .// virtual). Ca
    │ │ │ +0005cff0: 6c6c 6564 2076 6961 2061 2064 6f77 6e63  lled via a downc
    │ │ │ +0005d000: 6173 7420 696e 2074 6f72 7265 6e74 3a3a  ast in torrent::
    │ │ │ +0005d010: 7065 6572 735f 6572 6173 6564 2829 20e2  peers_erased() .
    │ │ │ +0005d020: 8094 2073 6565 0a09 092f 2f20 736d 6172  .. see...// smar
    │ │ │ +0005d030: 745f 6261 6e5f 6e6f 7469 6679 5f65 7261  t_ban_notify_era
    │ │ │ +0005d040: 7365 5f70 6565 7273 2829 2062 656c 6f77  se_peers() below
    │ │ │ +0005d050: 0a09 0976 6f69 6420 6f6e 5f65 7261 7365  ...void on_erase
    │ │ │ +0005d060: 5f70 6565 7273 2873 7061 6e26 6c74 3b61  _peers(span<a
    │ │ │ +0005d070: 7578 3a3a 746f 7272 656e 745f 7065 6572  ux::torrent_peer
    │ │ │ +0005d080: 2a20 636f 6e73 7426 6774 3b20 7065 6572  * const> peer
    │ │ │ +0005d090: 7329 0a09 097b 0a09 0909 6966 2028 6d5f  s)...{....if (m_
    │ │ │ +0005d0a0: 626c 6f63 6b5f 6861 7368 6573 2e65 6d70  block_hashes.emp
    │ │ │ +0005d0b0: 7479 2829 207c 7c20 7065 6572 732e 656d  ty() || peers.em
    │ │ │ +0005d0c0: 7074 7928 2929 2072 6574 7572 6e3b 0a0a  pty()) return;..
    │ │ │ +0005d0d0: 0909 0973 7464 3a3a 7665 6374 6f72 266c  ...std::vector&l
    │ │ │ +0005d0e0: 743b 6175 783a 3a74 6f72 7265 6e74 5f70  t;aux::torrent_p
    │ │ │ +0005d0f0: 6565 722a 2667 743b 2065 7261 7365 6428  eer*> erased(
    │ │ │ +0005d100: 7065 6572 732e 6265 6769 6e28 292c 2070  peers.begin(), p
    │ │ │ +0005d110: 6565 7273 2e65 6e64 2829 293b 0a09 0909  eers.end());....
    │ │ │ +0005d120: 7374 643a 3a73 6f72 7428 6572 6173 6564  std::sort(erased
    │ │ │ +0005d130: 2e62 6567 696e 2829 2c20 6572 6173 6564  .begin(), erased
    │ │ │ +0005d140: 2e65 6e64 2829 293b 0a3c 6469 7620 7374  .end());.
    ...for (a │ │ │ +0005d180: 7574 6f20 6920 3d20 6d5f 626c 6f63 6b5f uto i = m_block_ │ │ │ +0005d190: 6861 7368 6573 2e62 6567 696e 2829 3b20 hashes.begin(); │ │ │ +0005d1a0: 6920 213d 206d 5f62 6c6f 636b 5f68 6173 i != m_block_has │ │ │ +0005d1b0: 6865 732e 656e 6428 293b 290a 3c2f 6469 hes.end();)....{.....if (s │ │ │ +0005d1d0: 7464 3a3a 6269 6e61 7279 5f73 6561 7263 td::binary_searc │ │ │ +0005d1e0: 6828 6572 6173 6564 2e62 6567 696e 2829 h(erased.begin() │ │ │ +0005d1f0: 2c20 6572 6173 6564 2e65 6e64 2829 2c20 , erased.end(), │ │ │ +0005d200: 692d 2667 743b 7365 636f 6e64 2e70 6565 i->second.pee │ │ │ +0005d210: 7229 290a 0909 0909 0969 203d 206d 5f62 r))......i = m_b │ │ │ +0005d220: 6c6f 636b 5f68 6173 6865 732e 6572 6173 lock_hashes.eras │ │ │ +0005d230: 6528 6929 3b0a 0909 0909 656c 7365 0a09 e(i);.....else.. │ │ │ +0005d240: 0909 0909 2b2b 693b 0a09 0909 7d0a 0909 ....++i;....}... │ │ │ +0005d250: 7d0a 0a09 7072 6976 6174 653a 0a0a 0909 }...private:.... │ │ │ +0005d260: 2f2f 2074 6869 7320 656e 7472 7920 7469 // this entry ti │ │ │ +0005d270: 6573 2061 2073 7065 6369 6669 6320 626c es a specific bl │ │ │ +0005d280: 6f63 6b20 4352 4320 746f 0a09 092f 2f20 ock CRC to...// │ │ │ +0005d290: 6120 7065 6572 2e0a 0909 7374 7275 6374 a peer....struct │ │ │ +0005d2a0: 2062 6c6f 636b 5f65 6e74 7279 0a09 097b block_entry...{ │ │ │ +0005d2b0: 0a09 0909 6175 783a 3a74 6f72 7265 6e74 ....aux::torrent │ │ │ +0005d2c0: 5f70 6565 722a 2070 6565 723b 0a09 0909 _peer* peer;.... │ │ │ +0005d2d0: 7368 6131 5f68 6173 6820 6469 6765 7374 sha1_hash digest │ │ │ +0005d2e0: 3b0a 0909 7d3b 0a0a 0909 766f 6964 206f ;...};....void o │ │ │ +0005d2f0: 6e5f 7265 6164 5f66 6169 6c65 645f 626c n_read_failed_bl │ │ │ +0005d300: 6f63 6b28 7069 6563 655f 626c 6f63 6b20 ock(piece_block │ │ │ +0005d310: 636f 6e73 7420 622c 2061 6464 7265 7373 const b, address │ │ │ +0005d320: 2063 6f6e 7374 2061 0a09 0909 2c20 6469 const a...., di │ │ │ +0005d330: 736b 5f62 7566 6665 725f 686f 6c64 6572 sk_buffer_holder │ │ │ +0005d340: 2062 7566 6665 722c 2069 6e74 2063 6f6e buffer, int con │ │ │ +0005d350: 7374 2062 6c6f 636b 5f73 697a 650a 0909 st block_size... │ │ │ +0005d360: 092c 2073 746f 7261 6765 5f65 7272 6f72 ., storage_error │ │ │ +0005d370: 2063 6f6e 7374 2661 6d70 3b20 6572 726f const& erro │ │ │ +0005d380: 7229 0a09 097b 0a09 0909 544f 5252 454e r)...{....TORREN │ │ │ +0005d390: 545f 4153 5345 5254 286d 5f74 6f72 7265 T_ASSERT(m_torre │ │ │ +0005d3a0: 6e74 2e73 6573 7369 6f6e 2829 2e69 735f nt.session().is_ │ │ │ +0005d3b0: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ +0005d3c0: 3b0a 0a09 0909 2f2f 2069 676e 6f72 6520 ;.....// ignore │ │ │ +0005d3d0: 7265 6164 2065 7272 6f72 730a 0909 0969 read errors....i │ │ │ +0005d3e0: 6620 2865 7272 6f72 2920 7265 7475 726e f (error) return │ │ │ +0005d3f0: 3b0a 0a09 0909 6861 7368 6572 2068 3b0a ;.....hasher h;. │ │ │ +0005d400: 0909 0968 2e75 7064 6174 6528 7b62 7566 ...h.update({buf │ │ │ +0005d410: 6665 722e 6461 7461 2829 2c20 626c 6f63 fer.data(), bloc │ │ │ +0005d420: 6b5f 7369 7a65 7d29 3b0a 0a3c 2f70 7265 k_size});..
    rele │ │ │ +0005d460: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ut_ │ │ │ +0005d4a0: 6d65 7461 6461 7461 2e63 7070 3a32 3536 metadata.cpp:256 │ │ │ +0005d4b0: 3c2f 613e 3c2f 7464 3e3c 7464 3e77 6520 we │ │ │ +0005d4c0: 7265 616c 6c79 206e 6565 6420 746f 2069 really need to i │ │ │ +0005d4d0: 6e63 7265 6d65 6e74 2074 6865 2072 6566 ncrement the ref │ │ │ +0005d4e0: 636f 756e 7465 7220 6f6e 2074 6865 2074 counter on the t │ │ │ +0005d4f0: 6f72 7265 6e74 2077 6869 6c65 2074 6869 orrent while thi │ │ │ +0005d500: 7320 6275 6666 6572 2069 7320 7374 696c s buffer is stil │ │ │ +0005d510: 6c20 696e 2074 6865 2070 6565 7227 7320 l in the peer's │ │ │ +0005d520: 7365 6e64 2062 7566 6665 723c 2f74 643e send buffer │ │ │ +0005d530: 3c2f 7472 3e3c 7472 2069 643d 2232 3137

    we real │ │ │ +0005d580: 6c79 206e 6565 6420 746f 2069 6e63 7265 ly need to incre │ │ │ +0005d590: 6d65 6e74 2074 6865 2072 6566 636f 756e ment the refcoun │ │ │ +0005d5a0: 7465 7220 6f6e 2074 6865 2074 6f72 7265 ter on the torre │ │ │ +0005d5b0: 6e74 0a77 6869 6c65 2074 6869 7320 6275 nt.while this bu │ │ │ +0005d5c0: 6666 6572 2069 7320 7374 696c 6c20 696e ffer is still in │ │ │ +0005d5d0: 2074 6865 2070 6565 7227 7320 7365 6e64 the peer's send │ │ │ +0005d5e0: 2062 7566 6665 723c 2f68 323e 3c68 343e buffer

    │ │ │ +0005d5f0: 2e2e 2f73 7263 2f75 745f 6d65 7461 6461 ../src/ut_metada │ │ │ +0005d600: 7461 2e63 7070 3a32 3536 3c2f 6834 3e3c ta.cpp:256

    < │ │ │ +0005d610: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0005d620: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0005d630: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0005d640: 7820 2364 6464 3b22 3e09 0909 0969 6e74 x #ddd;">....int │ │ │ +0005d650: 2063 6f6e 7374 206f 6666 7365 7420 3d20 const offset = │ │ │ +0005d660: 7069 6563 6520 2a20 3136 202a 2031 3032 piece * 16 * 102 │ │ │ +0005d670: 343b 0a09 0909 096d 6574 6164 6174 6120 4;.....metadata │ │ │ +0005d680: 3d20 6d5f 7470 2e6d 6574 6164 6174 6128 = m_tp.metadata( │ │ │ +0005d690: 292e 6461 7461 2829 202b 206f 6666 7365 ).data() + offse │ │ │ +0005d6a0: 743b 0a09 0909 096d 6574 6164 6174 615f t;.....metadata_ │ │ │ +0005d6b0: 7069 6563 655f 7369 7a65 203d 2073 7464 piece_size = std │ │ │ +0005d6c0: 3a3a 6d69 6e28 0a09 0909 0909 696e 7428 ::min(......int( │ │ │ +0005d6d0: 6d5f 7470 2e6d 6574 6164 6174 6128 292e m_tp.metadata(). │ │ │ +0005d6e0: 7369 7a65 2829 2920 2d20 6f66 6673 6574 size()) - offset │ │ │ +0005d6f0: 2c20 3136 202a 2031 3032 3429 3b0a 0909 , 16 * 1024);... │ │ │ +0005d700: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0005d710: 286d 6574 6164 6174 615f 7069 6563 655f (metadata_piece_ │ │ │ +0005d720: 7369 7a65 2026 6774 3b20 3029 3b0a 0909 size > 0);... │ │ │ +0005d730: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0005d740: 286f 6666 7365 7420 2667 743b 3d20 3029 (offset >= 0) │ │ │ +0005d750: 3b0a 0909 0909 544f 5252 454e 545f 4153 ;.....TORRENT_AS │ │ │ +0005d760: 5345 5254 286f 6666 7365 7420 2b20 6d65 SERT(offset + me │ │ │ +0005d770: 7461 6461 7461 5f70 6965 6365 5f73 697a tadata_piece_siz │ │ │ +0005d780: 6520 266c 743b 3d20 6d5f 7470 2e6d 6574 e <= m_tp.met │ │ │ +0005d790: 6164 6174 6128 292e 7369 7a65 2829 293b adata().size()); │ │ │ +0005d7a0: 0a09 0909 7d0a 0a09 0909 6368 6172 206d ....}.....char m │ │ │ +0005d7b0: 7367 5b32 3030 5d3b 0a09 0909 6368 6172 sg[200];....char │ │ │ +0005d7c0: 2a20 6865 6164 6572 203d 206d 7367 3b0a * header = msg;. │ │ │ +0005d7d0: 0909 0963 6861 722a 2070 203d 2026 616d ...char* p = &am │ │ │ +0005d7e0: 703b 6d73 675b 365d 3b0a 0909 0969 6e74 p;msg[6];....int │ │ │ +0005d7f0: 2063 6f6e 7374 206c 656e 203d 2062 656e const len = ben │ │ │ +0005d800: 636f 6465 2870 2c20 6529 3b0a 0909 0969 code(p, e);....i │ │ │ +0005d810: 6e74 2063 6f6e 7374 2074 6f74 616c 5f73 nt const total_s │ │ │ +0005d820: 697a 6520 3d20 3220 2b20 6c65 6e20 2b20 ize = 2 + len + │ │ │ +0005d830: 6d65 7461 6461 7461 5f70 6965 6365 5f73 metadata_piece_s │ │ │ +0005d840: 697a 653b 0a09 0909 6e61 6d65 7370 6163 ize;....namespac │ │ │ +0005d850: 6520 696f 203d 2061 7578 3b0a 0909 0969 e io = aux;....i │ │ │ +0005d860: 6f3a 3a77 7269 7465 5f75 696e 7433 3228 o::write_uint32( │ │ │ +0005d870: 746f 7461 6c5f 7369 7a65 2c20 6865 6164 total_size, head │ │ │ +0005d880: 6572 293b 0a09 0909 696f 3a3a 7772 6974 er);....io::writ │ │ │ +0005d890: 655f 7569 6e74 3828 6175 783a 3a62 745f e_uint8(aux::bt_ │ │ │ +0005d8a0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a peer_connection: │ │ │ +0005d8b0: 3a6d 7367 5f65 7874 656e 6465 642c 2068 :msg_extended, h │ │ │ +0005d8c0: 6561 6465 7229 3b0a 0909 0969 6f3a 3a77 eader);....io::w │ │ │ +0005d8d0: 7269 7465 5f75 696e 7438 286d 5f6d 6573 rite_uint8(m_mes │ │ │ +0005d8e0: 7361 6765 5f69 6e64 6578 2c20 6865 6164 sage_index, head │ │ │ +0005d8f0: 6572 293b 0a0a 0909 096d 5f70 632e 7365 er);.....m_pc.se │ │ │ +0005d900: 6e64 5f62 7566 6665 7228 7b6d 7367 2c20 nd_buffer({msg, │ │ │ +0005d910: 6c65 6e20 2b20 367d 293b 0a3c 6469 7620 len + 6});.
    ...if ( │ │ │ +0005d950: 6d65 7461 6461 7461 5f70 6965 6365 5f73 metadata_piece_s │ │ │ +0005d960: 697a 6529 0a3c 2f64 6976 3e09 0909 7b0a ize).
    ...{. │ │ │ +0005d970: 0909 0909 6d5f 7063 2e61 7070 656e 645f ....m_pc.append_ │ │ │ +0005d980: 636f 6e73 745f 7365 6e64 5f62 7566 6665 const_send_buffe │ │ │ +0005d990: 7228 0a09 0909 0909 7370 616e 266c 743b r(......span< │ │ │ +0005d9a0: 6368 6172 2667 743b 2863 6f6e 7374 5f63 char>(const_c │ │ │ +0005d9b0: 6173 7426 6c74 3b63 6861 722a 2667 743b ast<char*> │ │ │ +0005d9c0: 286d 6574 6164 6174 6129 2c20 6d65 7461 (metadata), meta │ │ │ +0005d9d0: 6461 7461 5f70 6965 6365 5f73 697a 6529 data_piece_size) │ │ │ +0005d9e0: 2c20 6d65 7461 6461 7461 5f70 6965 6365 , metadata_piece │ │ │ +0005d9f0: 5f73 697a 6529 3b0a 0909 097d 0a0a 0909 _size);....}.... │ │ │ +0005da00: 096d 5f70 632e 7374 6174 735f 636f 756e .m_pc.stats_coun │ │ │ +0005da10: 7465 7273 2829 2e69 6e63 5f73 7461 7473 ters().inc_stats │ │ │ +0005da20: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572 _counter(counter │ │ │ +0005da30: 733a 3a6e 756d 5f6f 7574 676f 696e 675f s::num_outgoing_ │ │ │ +0005da40: 6578 7465 6e64 6564 293b 0a09 0909 6d5f extended);....m_ │ │ │ +0005da50: 7063 2e73 7461 7473 5f63 6f75 6e74 6572 pc.stats_counter │ │ │ +0005da60: 7328 292e 696e 635f 7374 6174 735f 636f s().inc_stats_co │ │ │ +0005da70: 756e 7465 7228 636f 756e 7465 7273 3a3a unter(counters:: │ │ │ +0005da80: 6e75 6d5f 6f75 7467 6f69 6e67 5f6d 6574 num_outgoing_met │ │ │ +0005da90: 6164 6174 6129 3b0a 0909 7d0a 0a09 0962 adata);...}....b │ │ │ +0005daa0: 6f6f 6c20 6f6e 5f65 7874 656e 6465 6428 ool on_extended( │ │ │ +0005dab0: 696e 7420 636f 6e73 7420 6c65 6e67 7468 int const length │ │ │ +0005dac0: 0a09 0909 2c20 696e 7420 636f 6e73 7420 ...., int const │ │ │ +0005dad0: 6578 7465 6e64 6564 5f6d 7367 2c20 7370 extended_msg, sp │ │ │ +0005dae0: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ +0005daf0: 2667 743b 2062 6f64 7929 206f 7665 7272 > body) overr │ │ │ +0005db00: 6964 650a 0909 7b0a 0909 0969 6620 2865 ide...{....if (e │ │ │ +0005db10: 7874 656e 6465 645f 6d73 6720 213d 2032 xtended_msg != 2 │ │ │ +0005db20: 2920 7265 7475 726e 2066 616c 7365 3b0a ) return false;. │ │ │ +0005db30: 0909 0969 6620 286d 5f6d 6573 7361 6765 ...if (m_message │ │ │ +0005db40: 5f69 6e64 6578 203d 3d20 3029 2072 6574 _index == 0) ret │ │ │ +0005db50: 7572 6e20 6661 6c73 653b 0a0a 0909 0969 urn false;.....i │ │ │ +0005db60: 6620 286c 656e 6774 6820 2667 743b 2031 f (length > 1 │ │ │ +0005db70: 3720 2a20 3130 3234 290a 0909 097b 0a23 7 * 1024)....{.# │ │ │ +0005db80: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +0005db90: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +0005dba0: 0909 096d 5f70 632e 7065 6572 5f6c 6f67 ...m_pc.peer_log │ │ │ +0005dbb0: 2870 6565 725f 6c6f 675f 616c 6572 743a (peer_log_alert: │ │ │ +0005dbc0: 3a69 6e63 6f6d 696e 675f 6d65 7373 6167 :incoming_messag │ │ │ +0005dbd0: 652c 2070 6565 725f 6c6f 675f 616c 6572 e, peer_log_aler │ │ │ +0005dbe0: 743a 3a75 745f 6d65 7461 6461 7461 0a09 t::ut_metadata.. │ │ │ +0005dbf0: 0909 0909 2c20 2270 6163 6b65 7420 746f ...., "packet to │ │ │ +0005dc00: 6f20 6269 6720 2564 222c 206c 656e 6774 o big %d", lengt │ │ │ +0005dc10: 6829 3b0a 2365 6e64 6966 0a09 0909 096d h);.#endif.....m │ │ │ +0005dc20: 5f70 632e 6469 7363 6f6e 6e65 6374 2865 _pc.disconnect(e │ │ │ +0005dc30: 7272 6f72 733a 3a69 6e76 616c 6964 5f6d rrors::invalid_m │ │ │ +0005dc40: 6574 6164 6174 615f 6d65 7373 6167 652c etadata_message, │ │ │ +0005dc50: 206f 7065 7261 7469 6f6e 5f74 3a3a 6269 operation_t::bi │ │ │ +0005dc60: 7474 6f72 7265 6e74 2c20 7065 6572 5f63 ttorrent, peer_c │ │ │ +0005dc70: 6f6e 6e65 6374 696f 6e5f 696e 7465 7266 onnection_interf │ │ │ +0005dc80: 6163 653a 3a70 6565 725f 6572 726f 7229 ace::peer_error) │ │ │ +0005dc90: 3b0a 0909 0909 7265 7475 726e 2074 7275 ;.....return tru │ │ │ +0005dca0: 653b 0a09 0909 7d0a 0a09 0909 6966 2028 e;....}.....if ( │ │ │ +0005dcb0: 216d 5f70 632e 7061 636b 6574 5f66 696e !m_pc.packet_fin │ │ │ +0005dcc0: 6973 6865 6428 2929 2072 6574 7572 6e20 ished()) return │ │ │ +0005dcd0: 7472 7565 3b0a 0a09 0909 6572 726f 725f true;.....error_ │ │ │ +0005dce0: 636f 6465 2065 633b 0a09 0909 6264 6563 code ec;....bdec │ │ │ +0005dcf0: 6f64 655f 6e6f 6465 206d 7367 203d 2062 ode_node msg = b │ │ │ +0005dd00: 6465 636f 6465 2862 6f64 792c 2065 6329 decode(body, ec) │ │ │ +0005dd10: 3b0a 0909 0969 6620 286d 7367 2e74 7970 ;....if (msg.typ │ │ │ +0005dd20: 6528 2920 213d 2062 6465 636f 6465 5f6e e() != bdecode_n │ │ │ +0005dd30: 6f64 653a 3a64 6963 745f 7429 0a3c 2f70 ode::dict_t).

    re │ │ │ +0005dd70: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/d │ │ │ +0005ddb0: 6973 6162 6c65 645f 6469 736b 5f69 6f2e isabled_disk_io. │ │ │ +0005ddc0: 6370 703a 3833 3c2f 613e 3c2f 7464 3e3c cpp:83< │ │ │ +0005ddd0: 7464 3e69 7420 776f 756c 6420 6265 206e td>it would be n │ │ │ +0005dde0: 6963 6520 746f 2072 6574 7572 6e20 6120 ice to return a │ │ │ +0005ddf0: 7661 6c69 6420 6861 7368 206f 6620 7a65 valid hash of ze │ │ │ +0005de00: 726f 6573 2068 6572 653c 2f74 643e 3c2f roes here

    it would │ │ │ +0005de60: 6265 206e 6963 6520 746f 2072 6574 7572 be nice to retur │ │ │ +0005de70: 6e20 6120 7661 6c69 6420 6861 7368 206f n a valid hash o │ │ │ +0005de80: 6620 7a65 726f 6573 2068 6572 653c 2f68 f zeroes here

    ../src/dis │ │ │ +0005dea0: 6162 6c65 645f 6469 736b 5f69 6f2e 6370 abled_disk_io.cp │ │ │ +0005deb0: 703a 3833 3c2f 6834 3e3c 7072 6520 7374 p:83

    ..});..}...bo
    │ │ │ +0005df00: 6f6c 2061 7379 6e63 5f77 7269 7465 2873  ol async_write(s
    │ │ │ +0005df10: 746f 7261 6765 5f69 6e64 6578 5f74 0a09  torage_index_t..
    │ │ │ +0005df20: 092c 2070 6565 725f 7265 7175 6573 7420  ., peer_request 
    │ │ │ +0005df30: 636f 6e73 7426 616d 703b 2072 0a09 092c  const& r...,
    │ │ │ +0005df40: 2063 6861 7220 636f 6e73 742a 2c20 7374   char const*, st
    │ │ │ +0005df50: 643a 3a73 6861 7265 645f 7074 7226 6c74  d::shared_ptr<
    │ │ │ +0005df60: 3b64 6973 6b5f 6f62 7365 7276 6572 2667  ;disk_observer&g
    │ │ │ +0005df70: 743b 0a09 092c 2073 7464 3a3a 6675 6e63  t;..., std::func
    │ │ │ +0005df80: 7469 6f6e 266c 743b 766f 6964 2873 746f  tion<void(sto
    │ │ │ +0005df90: 7261 6765 5f65 7272 6f72 2063 6f6e 7374  rage_error const
    │ │ │ +0005dfa0: 2661 6d70 3b29 2667 743b 2068 616e 646c  &)> handl
    │ │ │ +0005dfb0: 6572 0a09 092c 2064 6973 6b5f 6a6f 625f  er..., disk_job_
    │ │ │ +0005dfc0: 666c 6167 735f 7429 206f 7665 7272 6964  flags_t) overrid
    │ │ │ +0005dfd0: 650a 097b 0a09 0954 4f52 5245 4e54 5f41  e..{...TORRENT_A
    │ │ │ +0005dfe0: 5353 4552 5428 722e 6c65 6e67 7468 2026  SSERT(r.length &
    │ │ │ +0005dff0: 6c74 3b3d 2064 6566 6175 6c74 5f62 6c6f  lt;= default_blo
    │ │ │ +0005e000: 636b 5f73 697a 6529 3b0a 0909 544f 5252  ck_size);...TORR
    │ │ │ +0005e010: 454e 545f 554e 5553 4544 2872 293b 0a0a  ENT_UNUSED(r);..
    │ │ │ +0005e020: 0909 706f 7374 286d 5f69 6f73 2c20 5b68  ..post(m_ios, [h
    │ │ │ +0005e030: 203d 2073 7464 3a3a 6d6f 7665 2868 616e   = std::move(han
    │ │ │ +0005e040: 646c 6572 295d 207b 2068 2873 746f 7261  dler)] { h(stora
    │ │ │ +0005e050: 6765 5f65 7272 6f72 7b7d 293b 207d 293b  ge_error{}); });
    │ │ │ +0005e060: 0a09 0972 6574 7572 6e20 6661 6c73 653b  ...return false;
    │ │ │ +0005e070: 0a09 7d0a 0a09 766f 6964 2061 7379 6e63  ..}...void async
    │ │ │ +0005e080: 5f68 6173 6828 7374 6f72 6167 655f 696e  _hash(storage_in
    │ │ │ +0005e090: 6465 785f 740a 0909 2c20 7069 6563 655f  dex_t..., piece_
    │ │ │ +0005e0a0: 696e 6465 785f 7420 7069 6563 652c 2073  index_t piece, s
    │ │ │ +0005e0b0: 7061 6e26 6c74 3b73 6861 3235 365f 6861  pan<sha256_ha
    │ │ │ +0005e0c0: 7368 2667 743b 2c20 6469 736b 5f6a 6f62  sh>, disk_job
    │ │ │ +0005e0d0: 5f66 6c61 6773 5f74 0a09 092c 2073 7464  _flags_t..., std
    │ │ │ +0005e0e0: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f  ::function<vo
    │ │ │ +0005e0f0: 6964 2870 6965 6365 5f69 6e64 6578 5f74  id(piece_index_t
    │ │ │ +0005e100: 2c20 7368 6131 5f68 6173 6820 636f 6e73  , sha1_hash cons
    │ │ │ +0005e110: 7426 616d 703b 2c20 7374 6f72 6167 655f  t&, storage_
    │ │ │ +0005e120: 6572 726f 7220 636f 6e73 7426 616d 703b  error const&
    │ │ │ +0005e130: 2926 6774 3b20 6861 6e64 6c65 7229 206f  )> handler) o
    │ │ │ +0005e140: 7665 7272 6964 650a 097b 0a3c 6469 7620  verride..{.
    ..post( │ │ │ +0005e180: 6d5f 696f 732c 205b 6820 3d20 7374 643a m_ios, [h = std: │ │ │ +0005e190: 3a6d 6f76 6528 6861 6e64 6c65 7229 2c20 :move(handler), │ │ │ +0005e1a0: 7069 6563 655d 207b 2068 2870 6965 6365 piece] { h(piece │ │ │ +0005e1b0: 2c20 7368 6131 5f68 6173 687b 7d2c 2073 , sha1_hash{}, s │ │ │ +0005e1c0: 746f 7261 6765 5f65 7272 6f72 7b7d 293b torage_error{}); │ │ │ +0005e1d0: 207d 293b 0a3c 2f64 6976 3e09 7d0a 0a09 });.
    .}... │ │ │ +0005e1e0: 766f 6964 2061 7379 6e63 5f68 6173 6832 void async_hash2 │ │ │ +0005e1f0: 2873 746f 7261 6765 5f69 6e64 6578 5f74 (storage_index_t │ │ │ +0005e200: 2c20 7069 6563 655f 696e 6465 785f 7420 , piece_index_t │ │ │ +0005e210: 7069 6563 652c 2069 6e74 0a09 092c 2064 piece, int..., d │ │ │ +0005e220: 6973 6b5f 6a6f 625f 666c 6167 735f 740a isk_job_flags_t. │ │ │ +0005e230: 0909 2c20 7374 643a 3a66 756e 6374 696f .., std::functio │ │ │ +0005e240: 6e26 6c74 3b76 6f69 6428 7069 6563 655f n<void(piece_ │ │ │ +0005e250: 696e 6465 785f 742c 2073 6861 3235 365f index_t, sha256_ │ │ │ +0005e260: 6861 7368 2063 6f6e 7374 2661 6d70 3b2c hash const&, │ │ │ +0005e270: 2073 746f 7261 6765 5f65 7272 6f72 2063 storage_error c │ │ │ +0005e280: 6f6e 7374 2661 6d70 3b29 2667 743b 2068 onst&)> h │ │ │ +0005e290: 616e 646c 6572 2920 6f76 6572 7269 6465 andler) override │ │ │ +0005e2a0: 0a09 7b0a 0909 706f 7374 286d 5f69 6f73 ..{...post(m_ios │ │ │ +0005e2b0: 2c20 5b68 203d 2073 7464 3a3a 6d6f 7665 , [h = std::move │ │ │ +0005e2c0: 2868 616e 646c 6572 292c 2070 6965 6365 (handler), piece │ │ │ +0005e2d0: 5d28 2920 7b20 6828 7069 6563 652c 2073 ]() { h(piece, s │ │ │ +0005e2e0: 6861 3235 365f 6861 7368 7b7d 2c20 7374 ha256_hash{}, st │ │ │ +0005e2f0: 6f72 6167 655f 6572 726f 727b 7d29 3b20 orage_error{}); │ │ │ +0005e300: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ +0005e310: 796e 635f 6d6f 7665 5f73 746f 7261 6765 ync_move_storage │ │ │ +0005e320: 2873 746f 7261 6765 5f69 6e64 6578 5f74 (storage_index_t │ │ │ +0005e330: 0a09 092c 2073 7464 3a3a 7374 7269 6e67 ..., std::string │ │ │ +0005e340: 2070 2c20 6d6f 7665 5f66 6c61 6773 5f74 p, move_flags_t │ │ │ +0005e350: 0a09 092c 2073 7464 3a3a 6675 6e63 7469 ..., std::functi │ │ │ +0005e360: 6f6e 266c 743b 766f 6964 2873 7461 7475 on<void(statu │ │ │ +0005e370: 735f 742c 2073 7464 3a3a 7374 7269 6e67 s_t, std::string │ │ │ +0005e380: 2063 6f6e 7374 2661 6d70 3b2c 2073 746f const&, sto │ │ │ +0005e390: 7261 6765 5f65 7272 6f72 2063 6f6e 7374 rage_error const │ │ │ +0005e3a0: 2661 6d70 3b29 2667 743b 2068 616e 646c &)> handl │ │ │ +0005e3b0: 6572 2920 6f76 6572 7269 6465 0a09 7b0a er) override..{. │ │ │ +0005e3c0: 0909 706f 7374 286d 5f69 6f73 2c20 5b68 ..post(m_ios, [h │ │ │ +0005e3d0: 203d 2073 7464 3a3a 6d6f 7665 2868 616e = std::move(han │ │ │ +0005e3e0: 646c 6572 292c 2070 6174 6820 3d20 7374 dler), path = st │ │ │ +0005e3f0: 643a 3a6d 6f76 6528 7029 5d20 2829 206d d::move(p)] () m │ │ │ +0005e400: 7574 6162 6c65 0a09 0909 7b20 6828 7374 utable....{ h(st │ │ │ +0005e410: 6174 7573 5f74 7b7d 2c20 7374 643a 3a6d atus_t{}, std::m │ │ │ +0005e420: 6f76 6528 7061 7468 292c 2073 746f 7261 ove(path), stora │ │ │ +0005e430: 6765 5f65 7272 6f72 7b7d 293b 207d 293b ge_error{}); }); │ │ │ +0005e440: 0a09 7d0a 0a09 766f 6964 2061 7379 6e63 ..}...void async │ │ │ +0005e450: 5f72 656c 6561 7365 5f66 696c 6573 2873 _release_files(s │ │ │ +0005e460: 746f 7261 6765 5f69 6e64 6578 5f74 2c20 torage_index_t, │ │ │ +0005e470: 7374 643a 3a66 756e 6374 696f 6e26 6c74 std::function< │ │ │ +0005e480: 3b76 6f69 6428 2926 6774 3b20 6861 6e64 ;void()> hand │ │ │ +0005e490: 6c65 7229 206f 7665 7272 6964 650a 097b ler) override..{ │ │ │ +0005e4a0: 0a09 0970 6f73 7428 6d5f 696f 732c 205b ...post(m_ios, [ │ │ │ +0005e4b0: 6820 3d20 7374 643a 3a6d 6f76 6528 6861 h = std::move(ha │ │ │ +0005e4c0: 6e64 6c65 7229 5d20 7b20 6828 293b 207d ndler)] { h(); } │ │ │ +0005e4d0: 293b 0a09 7d0a 0a09 766f 6964 2061 7379 );..}...void asy │ │ │ +0005e4e0: 6e63 5f64 656c 6574 655f 6669 6c65 7328 nc_delete_files( │ │ │ +0005e4f0: 7374 6f72 6167 655f 696e 6465 785f 740a storage_index_t. │ │ │ +0005e500: 0909 2c20 7265 6d6f 7665 5f66 6c61 6773 .., remove_flags │ │ │ +0005e510: 5f74 2c20 7374 643a 3a66 756e 6374 696f _t, std::functio │ │ │ +0005e520: 6e26 6c74 3b76 6f69 6428 7374 6f72 6167 n<void(storag │ │ │ +0005e530: 655f 6572 726f 7220 636f 6e73 7426 616d e_error const&am │ │ │ +0005e540: 703b 2926 6774 3b20 6861 6e64 6c65 7229 p;)> handler) │ │ │ +0005e550: 206f 7665 7272 6964 650a 097b 0a09 0970 override..{...p │ │ │ +0005e560: 6f73 7428 6d5f 696f 732c 205b 6820 3d20 ost(m_ios, [h = │ │ │ +0005e570: 7374 643a 3a6d 6f76 6528 6861 6e64 6c65 std::move(handle │ │ │ +0005e580: 7229 5d20 7b20 6828 7374 6f72 6167 655f r)] { h(storage_ │ │ │ +0005e590: 6572 726f 727b 7d29 3b20 7d29 3b0a 097d error{}); });..} │ │ │ +0005e5a0: 0a0a 0976 6f69 6420 6173 796e 635f 6368 ...void async_ch │ │ │ +0005e5b0: 6563 6b5f 6669 6c65 7328 7374 6f72 6167 eck_files(storag │ │ │ +0005e5c0: 655f 696e 6465 785f 740a 0909 2c20 6164 e_index_t..., ad │ │ │ +0005e5d0: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +0005e5e0: 2063 6f6e 7374 2a0a 3c2f 7072 653e 3c2f const*.
    relevan │ │ │ +0005e620: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/disk_c │ │ │ +0005e660: 6163 6865 2e63 7070 3a37 3035 3c2f 613e ache.cpp:705 │ │ │ +0005e670: 3c2f 7464 3e3c 7464 3e70 6173 7320 7468 pass th │ │ │ +0005e680: 6520 626c 6f63 6b20 6f66 6673 6574 2061 e block offset a │ │ │ +0005e690: 7320 6120 7061 7261 6d65 7465 7220 696e s a parameter in │ │ │ +0005e6a0: 7374 6561 6420 6f66 2063 6f6d 7075 7469 stead of computi │ │ │ +0005e6b0: 6e67 2069 7420 6c69 6b65 2074 6869 733c ng it like this< │ │ │ +0005e6c0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    pas │ │ │ +0005e710: 7320 7468 6520 626c 6f63 6b20 6f66 6673 s the block offs │ │ │ +0005e720: 6574 2061 7320 6120 7061 7261 6d65 7465 et as a paramete │ │ │ +0005e730: 7220 696e 7374 6561 6420 6f66 2063 6f6d r instead of com │ │ │ +0005e740: 7075 7469 6e67 2069 7420 6c69 6b65 2074 puting it like t │ │ │ +0005e750: 6869 733c 2f68 323e 3c68 343e 2e2e 2f73 his

    ../s │ │ │ +0005e760: 7263 2f64 6973 6b5f 6361 6368 652e 6370 rc/disk_cache.cp │ │ │ +0005e770: 703a 3730 353c 2f68 343e 3c70 7265 2073 p:705

    template <
    │ │ │ +0005e7c0: 3b74 7970 656e 616d 6520 4974 6572 2c20  ;typename Iter, 
    │ │ │ +0005e7d0: 7479 7065 6e61 6d65 2056 6965 7726 6774  typename View>
    │ │ │ +0005e7e0: 3b0a 4974 6572 2064 6973 6b5f 6361 6368  ;.Iter disk_cach
    │ │ │ +0005e7f0: 653a 3a66 6c75 7368 5f70 6965 6365 5f69  e::flush_piece_i
    │ │ │ +0005e800: 6d70 6c28 5669 6577 2661 6d70 3b20 7669  mpl(View& vi
    │ │ │ +0005e810: 6577 2c0a 0949 7465 7220 7069 6563 655f  ew,..Iter piece_
    │ │ │ +0005e820: 6974 6572 2c0a 0973 7464 3a3a 6675 6e63  iter,..std::func
    │ │ │ +0005e830: 7469 6f6e 266c 743b 696e 7428 6269 7466  tion<int(bitf
    │ │ │ +0005e840: 6965 6c64 2661 6d70 3b2c 2073 7061 6e26  ield&, span&
    │ │ │ +0005e850: 6c74 3b64 6973 6b5f 6a6f 622a 2063 6f6e  lt;disk_job* con
    │ │ │ +0005e860: 7374 2667 743b 2926 6774 3b20 636f 6e73  st>)> cons
    │ │ │ +0005e870: 7426 616d 703b 2066 2c0a 0973 7464 3a3a  t& f,..std::
    │ │ │ +0005e880: 756e 6971 7565 5f6c 6f63 6b26 6c74 3b73  unique_lock<s
    │ │ │ +0005e890: 7464 3a3a 6d75 7465 7826 6774 3b26 616d  td::mutex>&am
    │ │ │ +0005e8a0: 703b 206c 2c0a 0973 7061 6e26 6c74 3b63  p; l,..span<c
    │ │ │ +0005e8b0: 6163 6865 645f 626c 6f63 6b5f 656e 7472  ached_block_entr
    │ │ │ +0005e8c0: 7926 6774 3b20 636f 6e73 7420 626c 6f63  y> const bloc
    │ │ │ +0005e8d0: 6b73 2c0a 0973 7464 3a3a 6675 6e63 7469  ks,..std::functi
    │ │ │ +0005e8e0: 6f6e 266c 743b 766f 6964 286a 6f62 7175  on<void(jobqu
    │ │ │ +0005e8f0: 6575 655f 742c 2064 6973 6b5f 6a6f 622a  eue_t, disk_job*
    │ │ │ +0005e900: 2926 6774 3b20 636c 6561 725f 7069 6563  )> clear_piec
    │ │ │ +0005e910: 655f 6675 6e29 0a7b 0a09 544f 5252 454e  e_fun).{..TORREN
    │ │ │ +0005e920: 545f 4153 5345 5254 286c 2e6f 776e 735f  T_ASSERT(l.owns_
    │ │ │ +0005e930: 6c6f 636b 2829 293b 0a09 2f2f 2077 6865  lock());..// whe
    │ │ │ +0005e940: 6e20 2262 6c6f 636b 7322 2063 6f76 6572  n "blocks" cover
    │ │ │ +0005e950: 7320 7468 6520 7768 6f6c 6520 7069 6563  s the whole piec
    │ │ │ +0005e960: 6520 7765 2063 616e 2075 7365 2074 6865  e we can use the
    │ │ │ +0005e970: 206d 6169 6e74 6169 6e65 6420 7065 722d   maintained per-
    │ │ │ +0005e980: 7069 6563 650a 092f 2f20 636f 756e 7465  piece..// counte
    │ │ │ +0005e990: 7220 696e 7374 6561 6420 6f66 2073 6361  r instead of sca
    │ │ │ +0005e9a0: 6e6e 696e 672e 2041 2073 7562 7370 616e  nning. A subspan
    │ │ │ +0005e9b0: 2028 7468 6520 6368 6561 702d 666c 7573   (the cheap-flus
    │ │ │ +0005e9c0: 6820 7061 7373 2920 7374 696c 6c20 6e65  h pass) still ne
    │ │ │ +0005e9d0: 6564 730a 092f 2f20 746f 2063 6f75 6e74  eds..// to count
    │ │ │ +0005e9e0: 2074 6865 2077 7269 7465 206a 6f62 7320   the write jobs 
    │ │ │ +0005e9f0: 7769 7468 696e 2074 6861 7420 7261 6e67  within that rang
    │ │ │ +0005ea00: 652e 0a09 696e 7420 636f 6e73 7420 6e75  e...int const nu
    │ │ │ +0005ea10: 6d5f 626c 6f63 6b73 203d 2028 626c 6f63  m_blocks = (bloc
    │ │ │ +0005ea20: 6b73 2e73 697a 6528 2920 3d3d 2070 6965  ks.size() == pie
    │ │ │ +0005ea30: 6365 5f69 7465 722d 2667 743b 626c 6f63  ce_iter->bloc
    │ │ │ +0005ea40: 6b73 5f69 6e5f 7069 6563 6528 2929 0a09  ks_in_piece())..
    │ │ │ +0005ea50: 093f 2069 6e74 2870 6965 6365 5f69 7465  .? int(piece_ite
    │ │ │ +0005ea60: 722d 2667 743b 6e75 6d5f 6a6f 6273 290a  r->num_jobs).
    │ │ │ +0005ea70: 0909 3a20 636f 756e 745f 6a6f 6273 2862  ..: count_jobs(b
    │ │ │ +0005ea80: 6c6f 636b 7329 3b0a 0954 4f52 5245 4e54  locks);..TORRENT
    │ │ │ +0005ea90: 5f41 5353 4552 5428 6e75 6d5f 626c 6f63  _ASSERT(num_bloc
    │ │ │ +0005eaa0: 6b73 203d 3d20 636f 756e 745f 6a6f 6273  ks == count_jobs
    │ │ │ +0005eab0: 2862 6c6f 636b 7329 293b 0a09 6966 2028  (blocks));..if (
    │ │ │ +0005eac0: 6e75 6d5f 626c 6f63 6b73 2026 6c74 3b3d  num_blocks <=
    │ │ │ +0005ead0: 2030 290a 0909 7265 7475 726e 2073 7464   0)...return std
    │ │ │ +0005eae0: 3a3a 6e65 7874 2870 6965 6365 5f69 7465  ::next(piece_ite
    │ │ │ +0005eaf0: 7229 3b0a 0a09 2f2f 2062 6c6f 636b 7320  r);...// blocks 
    │ │ │ +0005eb00: 6d61 7920 6265 2061 2073 7562 7370 616e  may be a subspan
    │ │ │ +0005eb10: 206f 6620 616c 6c20 7468 6520 626c 6f63   of all the bloc
    │ │ │ +0005eb20: 6b73 2069 6e20 7468 6520 7069 6563 652c  ks in the piece,
    │ │ │ +0005eb30: 2073 6f20 7768 656e 2063 6f6d 7061 7269   so when compari
    │ │ │ +0005eb40: 6e67 2066 6c75 7368 6564 5f63 7572 736f  ng flushed_curso
    │ │ │ +0005eb50: 7220 616e 6420 6861 7368 6572 5f63 7572  r and hasher_cur
    │ │ │ +0005eb60: 736f 722c 2077 6520 6e65 6564 2074 6f20  sor, we need to 
    │ │ │ +0005eb70: 6164 6420 7468 6520 6f66 6673 6574 2e0a  add the offset..
    │ │ │ +0005eb80: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .i │ │ │ +0005ebb0: 6e74 2063 6f6e 7374 2062 6c6f 636b 5f6f nt const block_o │ │ │ +0005ebc0: 6666 7365 7420 3d20 7374 6174 6963 5f63 ffset = static_c │ │ │ +0005ebd0: 6173 7426 6c74 3b69 6e74 2667 743b 2862 ast<int>(b │ │ │ +0005ebe0: 6c6f 636b 732e 6461 7461 2829 202d 2070 locks.data() - p │ │ │ +0005ebf0: 6965 6365 5f69 7465 722d 2667 743b 6765 iece_iter->ge │ │ │ +0005ec00: 745f 626c 6f63 6b73 2829 2e64 6174 6128 t_blocks().data( │ │ │ +0005ec10: 2929 3b0a 3c2f 6469 763e 0a09 7669 6577 ));.
    ..view │ │ │ +0005ec20: 2e6d 6f64 6966 7928 7069 6563 655f 6974 .modify(piece_it │ │ │ +0005ec30: 6572 2c20 5b5d 2863 6163 6865 645f 7069 er, [](cached_pi │ │ │ +0005ec40: 6563 655f 656e 7472 7926 616d 703b 2065 ece_entry& e │ │ │ +0005ec50: 2920 7b0a 0909 544f 5252 454e 545f 4153 ) {...TORRENT_AS │ │ │ +0005ec60: 5345 5254 2821 2865 2e66 6c61 6773 2026 SERT(!(e.flags & │ │ │ +0005ec70: 616d 703b 2063 6163 6865 645f 7069 6563 amp; cached_piec │ │ │ +0005ec80: 655f 656e 7472 793a 3a66 6c75 7368 696e e_entry::flushin │ │ │ +0005ec90: 675f 666c 6167 2929 3b0a 0909 652e 666c g_flag));...e.fl │ │ │ +0005eca0: 6167 7320 7c3d 2063 6163 6865 645f 7069 ags |= cached_pi │ │ │ +0005ecb0: 6563 655f 656e 7472 793a 3a66 6c75 7368 ece_entry::flush │ │ │ +0005ecc0: 696e 675f 666c 6167 3b0a 097d 293b 0a0a ing_flag;..});.. │ │ │ +0005ecd0: 092f 2f20 536e 6170 7368 6f74 2074 6865 .// Snapshot the │ │ │ +0005ece0: 2070 656e 6469 6e67 2077 7269 7465 5f6a pending write_j │ │ │ +0005ecf0: 6f62 2070 6f69 6e74 6572 2066 6f72 2065 ob pointer for e │ │ │ +0005ed00: 6163 6820 626c 6f63 6b20 7768 696c 6520 ach block while │ │ │ +0005ed10: 7765 2073 7469 6c6c 0a09 2f2f 2068 6f6c we still..// hol │ │ │ +0005ed20: 6420 7468 6520 6d75 7465 782e 2066 6c75 d the mutex. flu │ │ │ +0005ed30: 7368 696e 675f 666c 6167 2070 7265 7665 shing_flag preve │ │ │ +0005ed40: 6e74 7320 6f74 6865 7220 7468 7265 6164 nts other thread │ │ │ +0005ed50: 7320 6672 6f6d 2066 6c75 7368 696e 670a s from flushing. │ │ │ +0005ed60: 092f 2f20 7468 6973 2070 6965 6365 2c20 .// this piece, │ │ │ +0005ed70: 6275 7420 6469 736b 5f63 6163 6865 3a3a but disk_cache:: │ │ │ +0005ed80: 696e 7365 7274 2829 206d 6179 2073 7469 insert() may sti │ │ │ +0005ed90: 6c6c 2070 6f70 756c 6174 6520 7072 6576 ll populate prev │ │ │ +0005eda0: 696f 7573 6c79 0a09 2f2f 2065 6d70 7479 iously..// empty │ │ │ +0005edb0: 2074 7261 696c 696e 6720 736c 6f74 7320 trailing slots │ │ │ +0005edc0: 2869 6e73 6572 7420 6f6e 6c79 2072 6571 (insert only req │ │ │ +0005edd0: 7569 7265 7320 626c 6f63 6b5f 6964 7820 uires block_idx │ │ │ +0005ede0: 2667 743b 3d20 6861 7368 6572 5f63 7572 >= hasher_cur │ │ │ +0005edf0: 736f 7229 2e0a 092f 2f20 5265 6164 696e sor)...// Readin │ │ │ +0005ee00: 6720 6361 6368 6564 5f62 6c6f 636b 5f65 g cached_block_e │ │ │ +0005ee10: 6e74 7279 3a3a 7772 6974 655f 7374 6174 ntry::write_stat │ │ │ +0005ee20: 6520 6672 6f6d 206f 7574 7369 6465 2074 e from outside t │ │ │ +0005ee30: 6865 206c 6f63 6b20 776f 756c 640a 092f he lock would../ │ │ │ +0005ee40: 2f20 7261 6365 2077 6974 6820 7468 6174 / race with that │ │ │ +0005ee50: 2e20 4f6e 6365 2061 2073 6c6f 7420 686f . Once a slot ho │ │ │ +0005ee60: 6c64 7320 6120 6469 736b 5f6a 6f62 2074 lds a disk_job t │ │ │ +0005ee70: 6865 206e 6574 776f 726b 2074 6872 6561 he network threa │ │ │ +0005ee80: 6420 776f 6e27 740a 092f 2f20 746f 7563 d won't..// touc │ │ │ +0005ee90: 6820 6974 2028 6e6f 7220 7468 6520 6a6f h it (nor the jo │ │ │ +0005eea0: 6227 7320 636f 6e74 656e 7473 2920 756e b's contents) un │ │ │ +0005eeb0: 7469 6c20 7468 6520 6469 736b 2074 6872 til the disk thr │ │ │ +0005eec0: 6561 6420 7461 6b65 7320 6974 0a09 2f2f ead takes it..// │ │ │ +0005eed0: 2062 6163 6b2c 2073 6f20 7468 6520 736e back, so the sn │ │ │ +0005eee0: 6170 7368 6f74 7465 6420 706f 696e 7465 apshotted pointe │ │ │ +0005eef0: 7273 2061 6e64 2074 6865 2062 7566 6665 rs and the buffe │ │ │ +0005ef00: 7273 2074 6865 7920 7265 6665 7265 6e63 rs they referenc │ │ │ +0005ef10: 6520 7374 6179 0a09 2f2f 2076 616c 6964 e stay..// valid │ │ │ +0005ef20: 2066 6f72 2074 6865 2065 6e74 6972 6520 for the entire │ │ │ +0005ef30: 756e 6c6f 636b 6564 2072 6567 696f 6e20 unlocked region │ │ │ +0005ef40: 6265 6c6f 772e 0a09 544f 5252 454e 545f below...TORRENT_ │ │ │ +0005ef50: 414c 4c4f 4341 2873 6e61 7073 686f 742c ALLOCA(snapshot, │ │ │ +0005ef60: 2064 6973 6b5f 6a6f 622a 2c20 626c 6f63 disk_job*, bloc │ │ │ +0005ef70: 6b73 2e73 697a 6528 2929 3b0a 0966 6f72 ks.size());..for │ │ │ +0005ef80: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ +0005ef90: 6c74 3b20 626c 6f63 6b73 2e73 697a 6528 lt; blocks.size( │ │ │ +0005efa0: 293b 202b 2b69 290a 0909 736e 6170 7368 ); ++i)...snapsh │ │ │ +0005efb0: 6f74 5b69 5d20 3d20 626c 6f63 6b73 5b69 ot[i] = blocks[i │ │ │ +0005efc0: 5d2e 6765 745f 7772 6974 655f 6a6f 6228 ].get_write_job( │ │ │ +0005efd0: 293b 0a0a 092f 2f20 7765 2068 6176 6520 );...// we have │ │ │ +0005efe0: 746f 2072 656c 6561 7365 2074 6865 206c to release the l │ │ │ +0005eff0: 6f63 6b20 7768 696c 6520 666c 7573 6869 ock while flushi │ │ │ +0005f000: 6e67 2c20 6275 7420 7369 6e63 6520 7765 ng, but since we │ │ │ +0005f010: 2073 6574 2074 6865 0a09 2f2f 2022 666c set the..// "fl │ │ │ +0005f020: 7573 6869 6e67 2220 6d65 6d62 6572 2074 ushing" member t │ │ │ +0005f030: 6f20 7472 7565 2c20 7468 6973 2070 6965 o true, this pie │ │ │ +0005f040: 6365 2069 7320 7069 6e6e 6564 2074 6f20 ce is pinned to │ │ │ +0005f050: 7468 6520 6361 6368 650a 096c 2e75 6e6c the cache..l.unl │ │ │ +0005f060: 6f63 6b28 293b 0a0a 0969 6e74 2063 6f75 ock();...int cou │ │ │ +0005f070: 6e74 203d 2030 3b0a 0962 6974 6669 656c nt = 0;..bitfiel │ │ │ +0005f080: 6420 666c 7573 6865 645f 626c 6f63 6b73 d flushed_blocks │ │ │ +0005f090: 3b0a 097b 0a09 0961 7574 6f20 7365 203d ;..{...auto se = │ │ │ +0005f0a0: 2073 636f 7065 5f65 6e64 285b 2661 6d70 scope_end([& │ │ │ +0005f0b0: 3b5d 207b 0a09 0909 6c2e 6c6f 636b 2829 ;] {....l.lock() │ │ │ +0005f0c0: 3b0a 0909 0962 6f6f 6c20 6e6f 7469 6679 ;....bool notify │ │ │ +0005f0d0: 203d 2066 616c 7365 3b0a 0909 0976 6965 = false;....vie │ │ │ +0005f0e0: 772e 6d6f 6469 6679 2870 6965 6365 5f69 w.modify(piece_i │ │ │ +0005f0f0: 7465 722c 205b 2661 6d70 3b6e 6f74 6966 ter, [&notif │ │ │ +0005f100: 795d 2863 6163 6865 645f 7069 6563 655f y](cached_piece_ │ │ │ +0005f110: 656e 7472 7926 616d 703b 2065 2920 7b0a entry& e) {. │ │ │ +0005f120: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0005f130: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0005f160: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0005f190: 632f 7069 6563 655f 7069 636b 6572 2e63 c/piece_picker.c │ │ │ +0005f1a0: 7070 3a31 3030 3c2f 613e 3c2f 7464 3e3c pp:100< │ │ │ +0005f1b0: 7464 3e66 696e 6420 6120 6265 7474 6572 td>find a better │ │ │ +0005f1c0: 2070 6c61 6365 2066 6f72 2074 6869 733c place for this< │ │ │ +0005f1d0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    fin │ │ │ +0005f220: 6420 6120 6265 7474 6572 2070 6c61 6365 d a better place │ │ │ +0005f230: 2066 6f72 2074 6869 733c 2f68 323e 3c68 for this

    ../src/piece_p │ │ │ +0005f250: 6963 6b65 722e 6370 703a 3130 303c 2f68 icker.cpp:100
    ...{
    │ │ │ +0005f2a0: 0a09 0909 0973 7464 3a3a 6365 7272 2026  .....std::cerr &
    │ │ │ +0005f2b0: 6c74 3b26 6c74 3b20 2220 2e2e 2e22 3b0a  lt;< " ...";.
    │ │ │ +0005f2c0: 0909 0909 6272 6561 6b3b 0a09 0909 7d0a  ....break;....}.
    │ │ │ +0005f2d0: 0909 0969 6620 282a 6920 3d3d 202d 3129  ...if (*i == -1)
    │ │ │ +0005f2e0: 2062 7265 616b 3b0a 0909 0977 6869 6c65   break;....while
    │ │ │ +0005f2f0: 2028 6a20 213d 2070 2e6d 5f70 7269 6f72   (j != p.m_prior
    │ │ │ +0005f300: 6974 795f 626f 756e 6461 7269 6573 2e65  ity_boundaries.e
    │ │ │ +0005f310: 6e64 2829 2026 616d 703b 2661 6d70 3b20  nd() && 
    │ │ │ +0005f320: 2a6a 2026 6c74 3b3d 2069 6e64 6578 290a  *j <= index).
    │ │ │ +0005f330: 0909 097b 0a09 0909 0973 7464 3a3a 6365  ...{.....std::ce
    │ │ │ +0005f340: 7272 2026 6c74 3b26 6c74 3b20 227c 2022  rr << "| "
    │ │ │ +0005f350: 3b0a 0909 0909 2b2b 6a3b 0a09 0909 7d0a  ;.....++j;....}.
    │ │ │ +0005f360: 0909 0973 7464 3a3a 6365 7272 2026 6c74  ...std::cerr <
    │ │ │ +0005f370: 3b26 6c74 3b20 2a69 2026 6c74 3b26 6c74  ;< *i <<
    │ │ │ +0005f380: 3b20 2228 2220 266c 743b 266c 743b 2070  ; "(" << p
    │ │ │ +0005f390: 2e6d 5f70 6965 6365 5f6d 6170 5b2a 695d  .m_piece_map[*i]
    │ │ │ +0005f3a0: 2e69 6e64 6578 2026 6c74 3b26 6c74 3b20  .index << 
    │ │ │ +0005f3b0: 2229 2022 3b0a 0909 092d 2d6c 696d 6974  ") ";....--limit
    │ │ │ +0005f3c0: 3b0a 0909 7d0a 0909 7374 643a 3a63 6572  ;...}...std::cer
    │ │ │ +0005f3d0: 7220 266c 743b 266c 743b 2073 7464 3a3a  r << std::
    │ │ │ +0005f3e0: 656e 646c 3b0a 097d 0a7d 0a23 656e 6469  endl;..}.}.#endi
    │ │ │ +0005f3f0: 6620 2f2f 2054 4f52 5245 4e54 5f50 4943  f // TORRENT_PIC
    │ │ │ +0005f400: 4b45 525f 4c4f 470a 0a6e 616d 6573 7061  KER_LOG..namespa
    │ │ │ +0005f410: 6365 206c 6962 746f 7272 656e 7420 7b0a  ce libtorrent {.
    │ │ │ +0005f420: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0005f450: 636f 6e73 7420 7069 6563 655f 626c 6f63 const piece_bloc │ │ │ +0005f460: 6b20 7069 6563 655f 626c 6f63 6b3a 3a69 k piece_block::i │ │ │ +0005f470: 6e76 616c 6964 280a 3c2f 6469 763e 0909 nvalid(.
    .. │ │ │ +0005f480: 7374 643a 3a6e 756d 6572 6963 5f6c 696d std::numeric_lim │ │ │ +0005f490: 6974 7326 6c74 3b70 6965 6365 5f69 6e64 its<piece_ind │ │ │ +0005f4a0: 6578 5f74 2667 743b 3a3a 6d61 7828 290a ex_t>::max(). │ │ │ +0005f4b0: 0909 2c20 7374 643a 3a6e 756d 6572 6963 .., std::numeric │ │ │ +0005f4c0: 5f6c 696d 6974 7326 6c74 3b69 6e74 2667 _limits<int&g │ │ │ +0005f4d0: 743b 3a3a 6d61 7828 2929 3b0a 7d0a 0a6e t;::max());.}..n │ │ │ +0005f4e0: 616d 6573 7061 6365 206c 6962 746f 7272 amespace libtorr │ │ │ +0005f4f0: 656e 743a 3a61 7578 207b 0a0a 092f 2f20 ent::aux {...// │ │ │ +0005f500: 7468 6520 6d61 7820 6e75 6d62 6572 206f the max number o │ │ │ +0005f510: 6620 626c 6f63 6b73 2074 6f20 6372 6561 f blocks to crea │ │ │ +0005f520: 7465 2061 6e20 6166 6669 6e69 7479 2066 te an affinity f │ │ │ +0005f530: 6f72 0a09 636f 6e73 7465 7870 7220 696e or..constexpr in │ │ │ +0005f540: 7420 6d61 785f 7069 6563 655f 6166 6669 t max_piece_affi │ │ │ +0005f550: 6e69 7479 5f65 7874 656e 7420 3d20 3420 nity_extent = 4 │ │ │ +0005f560: 2a20 3130 3234 202a 2031 3032 3420 2f20 * 1024 * 1024 / │ │ │ +0005f570: 6465 6661 756c 745f 626c 6f63 6b5f 7369 default_block_si │ │ │ +0005f580: 7a65 3b0a 0a09 7069 6563 655f 7069 636b ze;...piece_pick │ │ │ +0005f590: 6572 3a3a 7069 6563 655f 7069 636b 6572 er::piece_picker │ │ │ +0005f5a0: 2873 7464 3a3a 696e 7436 345f 7420 636f (std::int64_t co │ │ │ +0005f5b0: 6e73 7420 746f 7461 6c5f 7369 7a65 2c20 nst total_size, │ │ │ +0005f5c0: 696e 7420 636f 6e73 7420 7069 6563 655f int const piece_ │ │ │ +0005f5d0: 7369 7a65 290a 0909 3a20 6d5f 7072 696f size)...: m_prio │ │ │ +0005f5e0: 7269 7479 5f62 6f75 6e64 6172 6965 7328 rity_boundaries( │ │ │ +0005f5f0: 312c 206d 5f70 6965 6365 732e 656e 645f 1, m_pieces.end_ │ │ │ +0005f600: 696e 6465 7828 2929 0a09 7b0a 0909 544f index())..{...TO │ │ │ +0005f610: 5252 454e 545f 4153 5345 5254 2874 6f74 RRENT_ASSERT(tot │ │ │ +0005f620: 616c 5f73 697a 6520 2667 743b 2030 293b al_size > 0); │ │ │ +0005f630: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0005f640: 5428 7069 6563 655f 7369 7a65 2026 6774 T(piece_size > │ │ │ +0005f650: 3b20 3029 3b0a 2369 6664 6566 2054 4f52 ; 0);.#ifdef TOR │ │ │ +0005f660: 5245 4e54 5f50 4943 4b45 525f 4c4f 470a RENT_PICKER_LOG. │ │ │ +0005f670: 0909 7374 643a 3a63 6572 7220 266c 743b ..std::cerr < │ │ │ +0005f680: 266c 743b 2022 5b22 2026 6c74 3b26 6c74 < "[" << │ │ │ +0005f690: 3b20 7468 6973 2026 6c74 3b26 6c74 3b20 ; this << │ │ │ +0005f6a0: 225d 2022 2026 6c74 3b26 6c74 3b20 226e "] " << "n │ │ │ +0005f6b0: 6577 2070 6965 6365 5f70 6963 6b65 7222 ew piece_picker" │ │ │ +0005f6c0: 2026 6c74 3b26 6c74 3b20 7374 643a 3a65 << std::e │ │ │ +0005f6d0: 6e64 6c3b 0a23 656e 6469 660a 2369 6620 ndl;.#endif.#if │ │ │ +0005f6e0: 544f 5252 454e 545f 5553 455f 494e 5641 TORRENT_USE_INVA │ │ │ +0005f6f0: 5249 414e 545f 4348 4543 4b53 0a09 0963 RIANT_CHECKS...c │ │ │ +0005f700: 6865 636b 5f69 6e76 6172 6961 6e74 2829 heck_invariant() │ │ │ +0005f710: 3b0a 2365 6e64 6966 0a0a 0909 7265 7369 ;.#endif....resi │ │ │ +0005f720: 7a65 2874 6f74 616c 5f73 697a 652c 2070 ze(total_size, p │ │ │ +0005f730: 6965 6365 5f73 697a 6529 3b0a 097d 0a0a iece_size);..}.. │ │ │ +0005f740: 0976 6f69 6420 7069 6563 655f 7069 636b .void piece_pick │ │ │ +0005f750: 6572 3a3a 7265 7369 7a65 2873 7464 3a3a er::resize(std:: │ │ │ +0005f760: 696e 7436 345f 7420 636f 6e73 7420 746f int64_t const to │ │ │ +0005f770: 7461 6c5f 7369 7a65 2c20 696e 7420 636f tal_size, int co │ │ │ +0005f780: 6e73 7420 7069 6563 655f 7369 7a65 290a nst piece_size). │ │ │ +0005f790: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ +0005f7a0: 4552 5428 746f 7461 6c5f 7369 7a65 2026 ERT(total_size & │ │ │ +0005f7b0: 6774 3b20 3029 3b0a 0909 544f 5252 454e gt; 0);...TORREN │ │ │ +0005f7c0: 545f 4153 5345 5254 2870 6965 6365 5f73 T_ASSERT(piece_s │ │ │ +0005f7d0: 697a 6520 2667 743b 2030 293b 0a0a 0909 ize > 0);.... │ │ │ +0005f7e0: 6d5f 746f 7461 6c5f 7369 7a65 203d 2074 m_total_size = t │ │ │ +0005f7f0: 6f74 616c 5f73 697a 653b 0a3c 2f70 7265 otal_size;.
    rele │ │ │ +0005f830: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pie │ │ │ +0005f870: 6365 5f70 6963 6b65 722e 6370 703a 3230 ce_picker.cpp:20 │ │ │ +0005f880: 3533 3c2f 613e 3c2f 7464 3e3c 7464 3e74 53t │ │ │ +0005f890: 6869 7320 636f 756c 6420 7072 6f62 6162 his could probab │ │ │ +0005f8a0: 6c79 2062 6520 6f70 7469 6d69 7a65 6420 ly be optimized │ │ │ +0005f8b0: 6279 2069 6e63 7265 6d65 6e74 616c 6c79 by incrementally │ │ │ +0005f8c0: 2063 616c 6c69 6e67 2070 6172 7469 616c calling partial │ │ │ +0005f8d0: 5f73 6f72 7420 746f 2073 6f72 7420 6f6e _sort to sort on │ │ │ +0005f8e0: 6520 6d6f 7265 2065 6c65 6d65 6e74 2069 e more element i │ │ │ +0005f8f0: 6e20 7468 6520 6c69 7374 2e20 4265 6361 n the list. Beca │ │ │ +0005f900: 7573 6520 6368 616e 6365 7320 6172 6520 use chances are │ │ │ +0005f910: 7468 6174 2077 6527 6c6c 206a 7573 7420 that we'll just │ │ │ +0005f920: 6e65 6564 2061 2073 696e 676c 6520 7069 need a single pi │ │ │ +0005f930: 6563 652c 2061 6e64 206f 6e63 6520 7765 ece, and once we │ │ │ +0005f940: 2776 6520 7069 636b 6564 2066 726f 6d20 've picked from │ │ │ +0005f950: 6974 2077 6527 7265 2064 6f6e 652e 2053 it we're done. S │ │ │ +0005f960: 6f72 7469 6e67 2074 6865 2072 6573 7420 orting the rest │ │ │ +0005f970: 6f66 2074 6865 206c 6973 7420 696e 2074 of the list in t │ │ │ +0005f980: 6861 7420 6361 7365 2069 7320 6120 7761 hat case is a wa │ │ │ +0005f990: 7374 6520 6f66 2074 696d 652e 3c2f 7464 ste of time.

    this c │ │ │ +0005f9f0: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ +0005fa00: 206f 7074 696d 697a 6564 2062 7920 696e optimized by in │ │ │ +0005fa10: 6372 656d 656e 7461 6c6c 790a 6361 6c6c crementally.call │ │ │ +0005fa20: 696e 6720 7061 7274 6961 6c5f 736f 7274 ing partial_sort │ │ │ +0005fa30: 2074 6f20 736f 7274 206f 6e65 206d 6f72 to sort one mor │ │ │ +0005fa40: 6520 656c 656d 656e 7420 696e 2074 6865 e element in the │ │ │ +0005fa50: 206c 6973 742e 2042 6563 6175 7365 0a63 list. Because.c │ │ │ +0005fa60: 6861 6e63 6573 2061 7265 2074 6861 7420 hances are that │ │ │ +0005fa70: 7765 276c 6c20 6a75 7374 206e 6565 6420 we'll just need │ │ │ +0005fa80: 6120 7369 6e67 6c65 2070 6965 6365 2c20 a single piece, │ │ │ +0005fa90: 616e 6420 6f6e 6365 2077 6527 7665 0a70 and once we've.p │ │ │ +0005faa0: 6963 6b65 6420 6672 6f6d 2069 7420 7765 icked from it we │ │ │ +0005fab0: 2772 6520 646f 6e65 2e20 536f 7274 696e 're done. Sortin │ │ │ +0005fac0: 6720 7468 6520 7265 7374 206f 6620 7468 g the rest of th │ │ │ +0005fad0: 6520 6c69 7374 2069 6e20 7468 6174 0a63 e list in that.c │ │ │ +0005fae0: 6173 6520 6973 2061 2077 6173 7465 206f ase is a waste o │ │ │ +0005faf0: 6620 7469 6d65 2e3c 2f68 323e 3c68 343e f time.

    │ │ │ +0005fb00: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ +0005fb10: 6b65 722e 6370 703a 3230 3533 3c2f 6834 ker.cpp:2053

    ...//
    │ │ │ +0005fb60: 206e 6f77 2c20 636f 7079 206f 7665 7220   now, copy over 
    │ │ │ +0005fb70: 7468 6520 706f 696e 7465 7273 2e20 5765  the pointers. We
    │ │ │ +0005fb80: 2061 6c73 6f20 6170 706c 7920 6120 6669   also apply a fi
    │ │ │ +0005fb90: 6c74 6572 2068 6572 6520 746f 206e 6f74  lter here to not
    │ │ │ +0005fba0: 0a09 0909 2f2f 2069 6e63 6c75 6465 2069  ....// include i
    │ │ │ +0005fbb0: 6e65 6c69 6769 626c 6520 7069 6563 6573  neligible pieces
    │ │ │ +0005fbc0: 2069 6e20 6365 7274 6169 6e20 6d6f 6465   in certain mode
    │ │ │ +0005fbd0: 732e 2046 6f72 2069 6e73 7461 6e63 652c  s. For instance,
    │ │ │ +0005fbe0: 2061 2070 6965 6365 0a09 0909 2f2f 2074   a piece....// t
    │ │ │ +0005fbf0: 6861 7420 7468 6520 6375 7272 656e 7420  hat the current 
    │ │ │ +0005fc00: 7065 6572 2064 6f65 736e 2774 2068 6176  peer doesn't hav
    │ │ │ +0005fc10: 6520 6973 206e 6f74 2069 6e63 6c75 6465  e is not include
    │ │ │ +0005fc20: 642e 0a09 0909 666f 7220 2861 7574 6f20  d.....for (auto 
    │ │ │ +0005fc30: 636f 6e73 7426 616d 703b 2064 7020 3a20  const& dp : 
    │ │ │ +0005fc40: 6d5f 646f 776e 6c6f 6164 735b 7069 6563  m_downloads[piec
    │ │ │ +0005fc50: 655f 706f 733a 3a70 6965 6365 5f64 6f77  e_pos::piece_dow
    │ │ │ +0005fc60: 6e6c 6f61 6469 6e67 5d29 0a09 0909 7b0a  nloading])....{.
    │ │ │ +0005fc70: 0909 0909 7063 2e69 6e63 5f73 7461 7473  ....pc.inc_stats
    │ │ │ +0005fc80: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572  _counter(counter
    │ │ │ +0005fc90: 733a 3a70 6965 6365 5f70 6963 6b65 725f  s::piece_picker_
    │ │ │ +0005fca0: 7061 7274 6961 6c5f 6c6f 6f70 7329 3b0a  partial_loops);.
    │ │ │ +0005fcb0: 0a09 0909 0969 6620 2821 6973 5f70 6965  .....if (!is_pie
    │ │ │ +0005fcc0: 6365 5f66 7265 6528 6470 2e69 6e64 6578  ce_free(dp.index
    │ │ │ +0005fcd0: 2c20 7069 6563 6573 2929 2063 6f6e 7469  , pieces)) conti
    │ │ │ +0005fce0: 6e75 653b 0a0a 0909 0909 544f 5252 454e  nue;......TORREN
    │ │ │ +0005fcf0: 545f 4153 5345 5254 286d 5f70 6965 6365  T_ASSERT(m_piece
    │ │ │ +0005fd00: 5f6d 6170 5b64 702e 696e 6465 785d 2e64  _map[dp.index].d
    │ │ │ +0005fd10: 6f77 6e6c 6f61 645f 7175 6575 6528 290a  ownload_queue().
    │ │ │ +0005fd20: 0909 0909 093d 3d20 7069 6563 655f 706f  .....== piece_po
    │ │ │ +0005fd30: 733a 3a70 6965 6365 5f64 6f77 6e6c 6f61  s::piece_downloa
    │ │ │ +0005fd40: 6469 6e67 293b 0a0a 0909 0909 6f72 6465  ding);......orde
    │ │ │ +0005fd50: 7265 645f 7061 7274 6961 6c73 5b6e 756d  red_partials[num
    │ │ │ +0005fd60: 5f6f 7264 6572 6564 5f70 6172 7469 616c  _ordered_partial
    │ │ │ +0005fd70: 732b 2b5d 203d 2026 616d 703b 6470 3b0a  s++] = &dp;.
    │ │ │ +0005fd80: 0909 097d 0a0a 0909 092f 2f20 6e6f 772c  ...}.....// now,
    │ │ │ +0005fd90: 2073 6f72 7420 7468 6520 6c69 7374 2e0a   sort the list..
    │ │ │ +0005fda0: 0909 0969 6620 286f 7074 696f 6e73 2026  ...if (options &
    │ │ │ +0005fdb0: 616d 703b 2072 6172 6573 745f 6669 7273  amp; rarest_firs
    │ │ │ +0005fdc0: 7429 0a09 0909 7b0a 0909 0909 7265 7420  t)....{.....ret 
    │ │ │ +0005fdd0: 7c3d 2070 6963 6b65 725f 6c6f 675f 616c  |= picker_log_al
    │ │ │ +0005fde0: 6572 743a 3a72 6172 6573 745f 6669 7273  ert::rarest_firs
    │ │ │ +0005fdf0: 745f 7061 7274 6961 6c73 3b0a 0a3c 6469  t_partials;......s
    │ │ │ +0005fe30: 7464 3a3a 736f 7274 286f 7264 6572 6564  td::sort(ordered
    │ │ │ +0005fe40: 5f70 6172 7469 616c 732e 6265 6769 6e28  _partials.begin(
    │ │ │ +0005fe50: 292c 206f 7264 6572 6564 5f70 6172 7469  ), ordered_parti
    │ │ │ +0005fe60: 616c 732e 6265 6769 6e28 2920 2b20 6e75  als.begin() + nu
    │ │ │ +0005fe70: 6d5f 6f72 6465 7265 645f 7061 7274 6961  m_ordered_partia
    │ │ │ +0005fe80: 6c73 0a3c 2f64 6976 3e09 0909 0909 2c20  ls.
    ....., │ │ │ +0005fe90: 7374 643a 3a62 696e 6428 2661 6d70 3b70 std::bind(&p │ │ │ +0005fea0: 6965 6365 5f70 6963 6b65 723a 3a70 6172 iece_picker::par │ │ │ +0005feb0: 7469 616c 5f63 6f6d 7061 7265 5f72 6172 tial_compare_rar │ │ │ +0005fec0: 6573 745f 6669 7273 742c 2074 6869 730a est_first, this. │ │ │ +0005fed0: 0909 0909 0909 2c20 5f31 2c20 5f32 2929 ......, _1, _2)) │ │ │ +0005fee0: 3b0a 0909 097d 0a0a 0909 0966 6f72 2028 ;....}.....for ( │ │ │ +0005fef0: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ +0005ff00: 3b20 6e75 6d5f 6f72 6465 7265 645f 7061 ; num_ordered_pa │ │ │ +0005ff10: 7274 6961 6c73 3b20 2b2b 6929 0a09 0909 rtials; ++i).... │ │ │ +0005ff20: 7b0a 0909 0909 7265 7420 7c3d 2070 6963 {.....ret |= pic │ │ │ +0005ff30: 6b65 725f 6c6f 675f 616c 6572 743a 3a70 ker_log_alert::p │ │ │ +0005ff40: 7269 6f72 6974 697a 655f 7061 7274 6961 rioritize_partia │ │ │ +0005ff50: 6c73 3b0a 0a09 0909 096e 756d 5f62 6c6f ls;......num_blo │ │ │ +0005ff60: 636b 7320 3d20 6164 645f 626c 6f63 6b73 cks = add_blocks │ │ │ +0005ff70: 5f64 6f77 6e6c 6f61 6469 6e67 282a 6f72 _downloading(*or │ │ │ +0005ff80: 6465 7265 645f 7061 7274 6961 6c73 5b69 dered_partials[i │ │ │ +0005ff90: 5d2c 2070 6965 6365 730a 0909 0909 092c ], pieces......, │ │ │ +0005ffa0: 2069 6e74 6572 6573 7469 6e67 5f62 6c6f interesting_blo │ │ │ +0005ffb0: 636b 732c 2062 6163 6b75 705f 626c 6f63 cks, backup_bloc │ │ │ +0005ffc0: 6b73 0a09 0909 0909 2c20 6e75 6d5f 626c ks......, num_bl │ │ │ +0005ffd0: 6f63 6b73 2c20 7072 6566 6572 5f63 6f6e ocks, prefer_con │ │ │ +0005ffe0: 7469 6775 6f75 735f 626c 6f63 6b73 2c20 tiguous_blocks, │ │ │ +0005fff0: 7065 6572 2c20 6f70 7469 6f6e 7329 3b0a peer, options);. │ │ │ +00060000: 0909 0909 6966 2028 6e75 6d5f 626c 6f63 ....if (num_bloc │ │ │ +00060010: 6b73 2026 6c74 3b3d 2030 2920 7265 7475 ks <= 0) retu │ │ │ +00060020: 726e 2072 6574 3b0a 0909 0909 6966 2028 rn ret;.....if ( │ │ │ +00060030: 696e 7428 6261 636b 7570 5f62 6c6f 636b int(backup_block │ │ │ +00060040: 732e 7369 7a65 2829 2920 2667 743b 3d20 s.size()) >= │ │ │ +00060050: 6e75 6d5f 626c 6f63 6b73 290a 0909 0909 num_blocks)..... │ │ │ +00060060: 0962 7265 616b 3b0a 0909 097d 0a0a 0909 .break;....}.... │ │ │ +00060070: 096e 756d 5f62 6c6f 636b 7320 3d20 6170 .num_blocks = ap │ │ │ +00060080: 7065 6e64 5f62 6c6f 636b 7328 696e 7465 pend_blocks(inte │ │ │ +00060090: 7265 7374 696e 675f 626c 6f63 6b73 2c20 resting_blocks, │ │ │ +000600a0: 6261 636b 7570 5f62 6c6f 636b 730a 0909 backup_blocks... │ │ │ +000600b0: 0909 2c20 6e75 6d5f 626c 6f63 6b73 293b .., num_blocks); │ │ │ +000600c0: 0a09 0909 6966 2028 6e75 6d5f 626c 6f63 ....if (num_bloc │ │ │ +000600d0: 6b73 2026 6c74 3b3d 2030 2920 7265 7475 ks <= 0) retu │ │ │ +000600e0: 726e 2072 6574 3b0a 0909 7d0a 0a09 0969 rn ret;...}....i │ │ │ +000600f0: 6620 2821 7375 6767 6573 7465 645f 7069 f (!suggested_pi │ │ │ +00060100: 6563 6573 2e65 6d70 7479 2829 290a 0909 eces.empty())... │ │ │ +00060110: 7b0a 0909 0966 6f72 2028 7069 6563 655f {....for (piece_ │ │ │ +00060120: 696e 6465 785f 7420 6920 3a20 7375 6767 index_t i : sugg │ │ │ +00060130: 6573 7465 645f 7069 6563 6573 290a 0909 ested_pieces)... │ │ │ +00060140: 097b 0a09 0909 0970 632e 696e 635f 7374 .{.....pc.inc_st │ │ │ +00060150: 6174 735f 636f 756e 7465 7228 636f 756e ats_counter(coun │ │ │ +00060160: 7465 7273 3a3a 7069 6563 655f 7069 636b ters::piece_pick │ │ │ +00060170: 6572 5f73 7567 6765 7374 5f6c 6f6f 7073 er_suggest_loops │ │ │ +00060180: 293b 0a09 0909 0969 6620 2821 6973 5f70 );.....if (!is_p │ │ │ +00060190: 6965 6365 5f66 7265 6528 692c 2070 6965 iece_free(i, pie │ │ │ +000601a0: 6365 7329 2920 636f 6e74 696e 7565 3b0a ces)) continue;. │ │ │ +000601b0: 0a09 0909 0972 6574 207c 3d20 7069 636b .....ret |= pick │ │ │ +000601c0: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 7375 er_log_alert::su │ │ │ +000601d0: 6767 6573 7465 645f 7069 6563 6573 3b0a ggested_pieces;. │ │ │ +000601e0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ +00060220: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00060250: 7263 2f70 6965 6365 5f70 6963 6b65 722e rc/piece_picker. │ │ │ +00060260: 6370 703a 3231 3935 3c2f 613e 3c2f 7464 cpp:2195Is it a goo │ │ │ +00060280: 6420 6964 6561 2074 6861 7420 7468 6973 d idea that this │ │ │ +00060290: 2061 6666 696e 6974 7920 7461 6b65 7320 affinity takes │ │ │ +000602a0: 7072 6563 6564 656e 6365 206f 7665 7220 precedence over │ │ │ +000602b0: 7069 6563 6520 7072 696f 7269 7479 3f3c piece priority?< │ │ │ +000602c0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    Is │ │ │ +00060310: 6974 2061 2067 6f6f 6420 6964 6561 2074 it a good idea t │ │ │ +00060320: 6861 7420 7468 6973 2061 6666 696e 6974 hat this affinit │ │ │ +00060330: 7920 7461 6b65 7320 7072 6563 6564 656e y takes preceden │ │ │ +00060340: 6365 206f 7665 720a 7069 6563 6520 7072 ce over.piece pr │ │ │ +00060350: 696f 7269 7479 3f3c 2f68 323e 3c68 343e iority?

    │ │ │ +00060360: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ +00060370: 6b65 722e 6370 703a 3231 3935 3c2f 6834 ker.cpp:2195

    .....
    │ │ │ +000603c0: 0970 632e 696e 635f 7374 6174 735f 636f  .pc.inc_stats_co
    │ │ │ +000603d0: 756e 7465 7228 636f 756e 7465 7273 3a3a  unter(counters::
    │ │ │ +000603e0: 7069 6563 655f 7069 636b 6572 5f72 6576  piece_picker_rev
    │ │ │ +000603f0: 6572 7365 5f72 6172 655f 6c6f 6f70 7329  erse_rare_loops)
    │ │ │ +00060400: 3b0a 0a09 0909 0909 0969 6620 2821 6973  ;........if (!is
    │ │ │ +00060410: 5f70 6965 6365 5f66 7265 6528 6d5f 7069  _piece_free(m_pi
    │ │ │ +00060420: 6563 6573 5b70 5d2c 2070 6965 6365 7329  eces[p], pieces)
    │ │ │ +00060430: 2920 636f 6e74 696e 7565 3b0a 0909 0909  ) continue;.....
    │ │ │ +00060440: 0909 2f2f 2063 7572 736f 7273 2061 7265  ..// cursors are
    │ │ │ +00060450: 206e 6f74 206d 7574 6174 6564 2064 7572   not mutated dur
    │ │ │ +00060460: 696e 6720 7069 636b 696e 673b 206d 616b  ing picking; mak
    │ │ │ +00060470: 6520 7375 7265 2077 6520 646f 6e27 7420  e sure we don't 
    │ │ │ +00060480: 7069 636b 2070 6965 6365 7320 7769 7468  pick pieces with
    │ │ │ +00060490: 696e 2074 6865 0a09 0909 0909 092f 2f20  in the.......// 
    │ │ │ +000604a0: 7365 7175 656e 7469 616c 2072 616e 6765  sequential range
    │ │ │ +000604b0: 2069 6620 696e 2073 6571 7565 6e74 6961   if in sequentia
    │ │ │ +000604c0: 6c20 646f 776e 6c6f 6164 206d 6f64 6520  l download mode 
    │ │ │ +000604d0: 736f 2074 6861 7420 7765 2064 6f6e 2774  so that we don't
    │ │ │ +000604e0: 2070 6963 6b20 6475 706c 6963 6174 6520   pick duplicate 
    │ │ │ +000604f0: 7069 6563 6573 0a09 0909 0909 0969 6620  pieces.......if 
    │ │ │ +00060500: 2828 6f70 7469 6f6e 7320 2661 6d70 3b20  ((options & 
    │ │ │ +00060510: 7365 7175 656e 7469 616c 2920 2661 6d70  sequential) &
    │ │ │ +00060520: 3b26 616d 703b 206d 5f70 6965 6365 735b  ;& m_pieces[
    │ │ │ +00060530: 705d 2026 6774 3b3d 206d 5f63 7572 736f  p] >= m_curso
    │ │ │ +00060540: 7220 2661 6d70 3b26 616d 703b 206d 5f70  r && m_p
    │ │ │ +00060550: 6965 6365 735b 705d 2026 6c74 3b20 6d5f  ieces[p] < m_
    │ │ │ +00060560: 7265 7665 7273 655f 6375 7273 6f72 2920  reverse_cursor) 
    │ │ │ +00060570: 636f 6e74 696e 7565 3b0a 0a09 0909 0909  continue;.......
    │ │ │ +00060580: 0972 6574 207c 3d20 7069 636b 6572 5f6c  .ret |= picker_l
    │ │ │ +00060590: 6f67 5f61 6c65 7274 3a3a 7265 7665 7273  og_alert::revers
    │ │ │ +000605a0: 655f 7261 7265 7374 5f66 6972 7374 3b0a  e_rarest_first;.
    │ │ │ +000605b0: 0a09 0909 0909 096e 756d 5f62 6c6f 636b  .......num_block
    │ │ │ +000605c0: 7320 3d20 6164 645f 626c 6f63 6b73 286d  s = add_blocks(m
    │ │ │ +000605d0: 5f70 6965 6365 735b 705d 2c20 7069 6563  _pieces[p], piec
    │ │ │ +000605e0: 6573 0a09 0909 0909 0909 2c20 696e 7465  es........, inte
    │ │ │ +000605f0: 7265 7374 696e 675f 626c 6f63 6b73 0a09  resting_blocks..
    │ │ │ +00060600: 0909 0909 0909 2c20 6261 636b 7570 5f62  ......, backup_b
    │ │ │ +00060610: 6c6f 636b 732c 206e 756d 5f62 6c6f 636b  locks, num_block
    │ │ │ +00060620: 730a 0909 0909 0909 092c 2070 7265 6665  s........, prefe
    │ │ │ +00060630: 725f 636f 6e74 6967 756f 7573 5f62 6c6f  r_contiguous_blo
    │ │ │ +00060640: 636b 732c 2070 6565 722c 2069 676e 6f72  cks, peer, ignor
    │ │ │ +00060650: 6564 5f70 6965 6365 730a 0909 0909 0909  ed_pieces.......
    │ │ │ +00060660: 092c 206f 7074 696f 6e73 293b 0a09 0909  ., options);....
    │ │ │ +00060670: 0909 0969 6620 286e 756d 5f62 6c6f 636b  ...if (num_block
    │ │ │ +00060680: 7320 266c 743b 3d20 3029 2072 6574 7572  s <= 0) retur
    │ │ │ +00060690: 6e20 7265 743b 0a09 0909 0909 7d0a 0909  n ret;......}...
    │ │ │ +000606a0: 0909 7d0a 0909 097d 0a09 0909 656c 7365  ..}....}....else
    │ │ │ +000606b0: 0a09 0909 7b0a 3c64 6976 2073 7479 6c65  ....{.
    ....if (opti │ │ │ +000606f0: 6f6e 7320 2661 6d70 3b20 7069 6563 655f ons & piece_ │ │ │ +00060700: 6578 7465 6e74 5f61 6666 696e 6974 7929 extent_affinity) │ │ │ +00060710: 0a3c 2f64 6976 3e09 0909 097b 0a09 0909 .
    ....{.... │ │ │ +00060720: 0909 696e 7420 746f 5f65 7261 7365 203d ..int to_erase = │ │ │ +00060730: 202d 313b 0a09 0909 0909 696e 7420 6964 -1;......int id │ │ │ +00060740: 7820 3d20 2d31 3b0a 0909 0909 0966 6f72 x = -1;......for │ │ │ +00060750: 2028 7069 6563 655f 6578 7465 6e74 5f74 (piece_extent_t │ │ │ +00060760: 2063 6f6e 7374 2065 203a 206d 5f72 6563 const e : m_rec │ │ │ +00060770: 656e 745f 6578 7465 6e74 7329 0a09 0909 ent_extents).... │ │ │ +00060780: 0909 7b0a 0909 0909 0909 2b2b 6964 783b ..{.......++idx; │ │ │ +00060790: 0a09 0909 0909 0962 6f6f 6c20 6861 7665 .......bool have │ │ │ +000607a0: 5f61 6c6c 203d 2074 7275 653b 0a09 0909 _all = true;.... │ │ │ +000607b0: 0909 0966 6f72 2028 7069 6563 655f 696e ...for (piece_in │ │ │ +000607c0: 6465 785f 7420 636f 6e73 7420 7020 3a20 dex_t const p : │ │ │ +000607d0: 6578 7465 6e74 5f66 6f72 2865 2929 0a09 extent_for(e)).. │ │ │ +000607e0: 0909 0909 097b 0a09 0909 0909 0909 6966 .....{........if │ │ │ +000607f0: 2028 216d 5f70 6965 6365 5f6d 6170 5b70 (!m_piece_map[p │ │ │ +00060800: 5d2e 666c 7573 6865 6428 2929 2068 6176 ].flushed()) hav │ │ │ +00060810: 655f 616c 6c20 3d20 6661 6c73 653b 0a09 e_all = false;.. │ │ │ +00060820: 0909 0909 0909 6966 2028 2169 735f 7069 ......if (!is_pi │ │ │ +00060830: 6563 655f 6672 6565 2870 2c20 7069 6563 ece_free(p, piec │ │ │ +00060840: 6573 2929 2063 6f6e 7469 6e75 653b 0a09 es)) continue;.. │ │ │ +00060850: 0909 0909 0909 6966 2028 286f 7074 696f ......if ((optio │ │ │ +00060860: 6e73 2026 616d 703b 2073 6571 7565 6e74 ns & sequent │ │ │ +00060870: 6961 6c29 2026 616d 703b 2661 6d70 3b20 ial) && │ │ │ +00060880: 7020 2667 743b 3d20 6d5f 6375 7273 6f72 p >= m_cursor │ │ │ +00060890: 2026 616d 703b 2661 6d70 3b20 7020 266c && p &l │ │ │ +000608a0: 743b 206d 5f72 6576 6572 7365 5f63 7572 t; m_reverse_cur │ │ │ +000608b0: 736f 7229 2063 6f6e 7469 6e75 653b 0a0a sor) continue;.. │ │ │ +000608c0: 0909 0909 0909 0972 6574 207c 3d20 7069 .......ret |= pi │ │ │ +000608d0: 636b 6572 5f6c 6f67 5f61 6c65 7274 3a3a cker_log_alert:: │ │ │ +000608e0: 6578 7465 6e74 5f61 6666 696e 6974 793b extent_affinity; │ │ │ +000608f0: 0a0a 0909 0909 0909 096e 756d 5f62 6c6f .........num_blo │ │ │ +00060900: 636b 7320 3d20 6164 645f 626c 6f63 6b73 cks = add_blocks │ │ │ +00060910: 2870 2c20 7069 6563 6573 0a09 0909 0909 (p, pieces...... │ │ │ +00060920: 0909 092c 2069 6e74 6572 6573 7469 6e67 ..., interesting │ │ │ +00060930: 5f62 6c6f 636b 730a 0909 0909 0909 0909 _blocks......... │ │ │ +00060940: 2c20 6261 636b 7570 5f62 6c6f 636b 732c , backup_blocks, │ │ │ +00060950: 206e 756d 5f62 6c6f 636b 730a 0909 0909 num_blocks..... │ │ │ +00060960: 0909 0909 2c20 7072 6566 6572 5f63 6f6e ...., prefer_con │ │ │ +00060970: 7469 6775 6f75 735f 626c 6f63 6b73 2c20 tiguous_blocks, │ │ │ +00060980: 7065 6572 2c20 6967 6e6f 7265 645f 7069 peer, ignored_pi │ │ │ +00060990: 6563 6573 0a09 0909 0909 0909 092c 206f eces........., o │ │ │ +000609a0: 7074 696f 6e73 293b 0a09 0909 0909 0909 ptions);........ │ │ │ +000609b0: 6966 2028 6e75 6d5f 626c 6f63 6b73 2026 if (num_blocks & │ │ │ +000609c0: 6c74 3b3d 2030 290a 0909 0909 0909 097b lt;= 0)........{ │ │ │ +000609d0: 0a09 0909 0909 0909 092f 2f20 6966 2077 .........// if w │ │ │ +000609e0: 6520 6861 7665 2061 6c6c 2070 6965 6365 e have all piece │ │ │ +000609f0: 7320 6265 6c6f 6e67 696e 6720 746f 2074 s belonging to t │ │ │ +00060a00: 6869 7320 6578 7465 6e74 2c20 7265 6d6f his extent, remo │ │ │ +00060a10: 7665 2069 740a 0909 0909 0909 0909 6966 ve it.........if │ │ │ +00060a20: 2028 746f 5f65 7261 7365 2021 3d20 2d31 (to_erase != -1 │ │ │ +00060a30: 2920 6d5f 7265 6365 6e74 5f65 7874 656e ) m_recent_exten │ │ │ +00060a40: 7473 2e65 7261 7365 286d 5f72 6563 656e ts.erase(m_recen │ │ │ +00060a50: 745f 6578 7465 6e74 732e 6265 6769 6e28 t_extents.begin( │ │ │ +00060a60: 2920 2b20 746f 5f65 7261 7365 293b 0a09 ) + to_erase);.. │ │ │ +00060a70: 0909 0909 0909 0972 6574 7572 6e20 7265 .......return re │ │ │ +00060a80: 743b 0a09 0909 0909 0909 7d0a 0909 0909 t;........}..... │ │ │ +00060a90: 0909 7d0a 0909 0909 0909 2f2f 2069 6620 ..}.......// if │ │ │ +00060aa0: 7765 2068 6176 6520 616c 6c20 7069 6563 we have all piec │ │ │ +00060ab0: 6573 2062 656c 6f6e 6769 6e67 2074 6f20 es belonging to │ │ │ +00060ac0: 7468 6973 2065 7874 656e 742c 2072 656d this extent, rem │ │ │ +00060ad0: 6f76 6520 6974 0a09 0909 0909 0969 6620 ove it.......if │ │ │ +00060ae0: 2868 6176 655f 616c 6c29 2074 6f5f 6572 (have_all) to_er │ │ │ +00060af0: 6173 6520 3d20 6964 783b 0a09 0909 0909 ase = idx;...... │ │ │ +00060b00: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ +00060b30: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00060b40: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00060b70: 7372 632f 7069 6563 655f 7069 636b 6572 src/piece_picker │ │ │ +00060b80: 2e63 7070 3a32 3534 373c 2f61 3e3c 2f74 .cpp:2547
    when expan │ │ │ +00060ba0: 6469 6e67 2070 6965 6365 7320 666f 7220 ding pieces for │ │ │ +00060bb0: 6361 6368 6520 7374 7269 7065 2072 6561 cache stripe rea │ │ │ +00060bc0: 736f 6e73 2c20 7468 6520 2164 6f77 6e6c sons, the !downl │ │ │ +00060bd0: 6f61 6469 6e67 2063 6f6e 6469 7469 6f6e oading condition │ │ │ +00060be0: 2064 6f65 736e 2774 206d 616b 6520 6d75 doesn't make mu │ │ │ +00060bf0: 6368 2073 656e 7365 3c2f 7464 3e3c 2f74 ch sense

    when expan │ │ │ +00060c50: 6469 6e67 2070 6965 6365 7320 666f 7220 ding pieces for │ │ │ +00060c60: 6361 6368 6520 7374 7269 7065 2072 6561 cache stripe rea │ │ │ +00060c70: 736f 6e73 2c0a 7468 6520 2164 6f77 6e6c sons,.the !downl │ │ │ +00060c80: 6f61 6469 6e67 2063 6f6e 6469 7469 6f6e oading condition │ │ │ +00060c90: 2064 6f65 736e 2774 206d 616b 6520 6d75 doesn't make mu │ │ │ +00060ca0: 6368 2073 656e 7365 3c2f 6832 3e3c 6834 ch sense

    ../src/piece_pi │ │ │ +00060cc0: 636b 6572 2e63 7070 3a32 3534 373c 2f68 cker.cpp:2547
    ..TO
    │ │ │ +00060d10: 5252 454e 545f 4153 5345 5254 2869 6e64  RRENT_ASSERT(ind
    │ │ │ +00060d20: 6578 2026 6c74 3b20 6d5f 7069 6563 655f  ex < m_piece_
    │ │ │ +00060d30: 6d61 702e 656e 645f 696e 6465 7828 2929  map.end_index())
    │ │ │ +00060d40: 3b0a 0909 6966 2028 6e65 7874 2869 6e64  ;...if (next(ind
    │ │ │ +00060d50: 6578 2920 3d3d 206d 5f70 6965 6365 5f6d  ex) == m_piece_m
    │ │ │ +00060d60: 6170 2e65 6e64 5f69 6e64 6578 2829 290a  ap.end_index()).
    │ │ │ +00060d70: 0909 0972 6574 7572 6e20 6d5f 626c 6f63  ...return m_bloc
    │ │ │ +00060d80: 6b73 5f69 6e5f 6c61 7374 5f70 6965 6365  ks_in_last_piece
    │ │ │ +00060d90: 3b0a 0909 656c 7365 0a09 0909 7265 7475  ;...else....retu
    │ │ │ +00060da0: 726e 2062 6c6f 636b 735f 7065 725f 7069  rn blocks_per_pi
    │ │ │ +00060db0: 6563 6528 293b 0a09 7d0a 0a09 626f 6f6c  ece();..}...bool
    │ │ │ +00060dc0: 2070 6965 6365 5f70 6963 6b65 723a 3a69   piece_picker::i
    │ │ │ +00060dd0: 735f 7069 6563 655f 6672 6565 2870 6965  s_piece_free(pie
    │ │ │ +00060de0: 6365 5f69 6e64 6578 5f74 2063 6f6e 7374  ce_index_t const
    │ │ │ +00060df0: 2070 6965 6365 0a09 092c 2074 7970 6564   piece..., typed
    │ │ │ +00060e00: 5f62 6974 6669 656c 6426 6c74 3b70 6965  _bitfield<pie
    │ │ │ +00060e10: 6365 5f69 6e64 6578 5f74 2667 743b 2063  ce_index_t> c
    │ │ │ +00060e20: 6f6e 7374 2661 6d70 3b20 6269 746d 6173  onst& bitmas
    │ │ │ +00060e30: 6b29 2063 6f6e 7374 0a09 7b0a 0909 7265  k) const..{...re
    │ │ │ +00060e40: 7475 726e 2062 6974 6d61 736b 5b70 6965  turn bitmask[pie
    │ │ │ +00060e50: 6365 5d0a 0909 0926 616d 703b 2661 6d70  ce]....&&
    │ │ │ +00060e60: 3b20 216d 5f70 6965 6365 5f6d 6170 5b70  ; !m_piece_map[p
    │ │ │ +00060e70: 6965 6365 5d2e 666c 7573 6865 6428 290a  iece].flushed().
    │ │ │ +00060e80: 0909 0926 616d 703b 2661 6d70 3b20 216d  ...&& !m
    │ │ │ +00060e90: 5f70 6965 6365 5f6d 6170 5b70 6965 6365  _piece_map[piece
    │ │ │ +00060ea0: 5d2e 6669 6c74 6572 6564 2829 3b0a 097d  ].filtered();..}
    │ │ │ +00060eb0: 0a0a 0962 6f6f 6c20 7069 6563 655f 7069  ...bool piece_pi
    │ │ │ +00060ec0: 636b 6572 3a3a 6361 6e5f 7069 636b 2870  cker::can_pick(p
    │ │ │ +00060ed0: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e  iece_index_t con
    │ │ │ +00060ee0: 7374 2070 6965 6365 0a09 092c 2074 7970  st piece..., typ
    │ │ │ +00060ef0: 6564 5f62 6974 6669 656c 6426 6c74 3b70  ed_bitfield<p
    │ │ │ +00060f00: 6965 6365 5f69 6e64 6578 5f74 2667 743b  iece_index_t>
    │ │ │ +00060f10: 2063 6f6e 7374 2661 6d70 3b20 6269 746d   const& bitm
    │ │ │ +00060f20: 6173 6b29 2063 6f6e 7374 0a09 7b0a 0909  ask) const..{...
    │ │ │ +00060f30: 7265 7475 726e 2062 6974 6d61 736b 5b70  return bitmask[p
    │ │ │ +00060f40: 6965 6365 5d0a 0909 0926 616d 703b 2661  iece]....&&a
    │ │ │ +00060f50: 6d70 3b20 216d 5f70 6965 6365 5f6d 6170  mp; !m_piece_map
    │ │ │ +00060f60: 5b70 6965 6365 5d2e 666c 7573 6865 6428  [piece].flushed(
    │ │ │ +00060f70: 290a 3c64 6976 2073 7479 6c65 3d22 6261  ).
    │ │ │ +00060fa0: 0909 0926 616d 703b 2661 6d70 3b20 216d ...&& !m │ │ │ +00060fb0: 5f70 6965 6365 5f6d 6170 5b70 6965 6365 _piece_map[piece │ │ │ +00060fc0: 5d2e 646f 776e 6c6f 6164 696e 6728 290a ].downloading(). │ │ │ +00060fd0: 3c2f 6469 763e 0909 0926 616d 703b 2661
    ...&&a │ │ │ +00060fe0: 6d70 3b20 216d 5f70 6965 6365 5f6d 6170 mp; !m_piece_map │ │ │ +00060ff0: 5b70 6965 6365 5d2e 6669 6c74 6572 6564 [piece].filtered │ │ │ +00061000: 2829 3b0a 097d 0a0a 2369 6620 544f 5252 ();..}..#if TORR │ │ │ +00061010: 454e 545f 5553 455f 494e 5641 5249 414e ENT_USE_INVARIAN │ │ │ +00061020: 545f 4348 4543 4b53 0a09 766f 6964 2070 T_CHECKS..void p │ │ │ +00061030: 6965 6365 5f70 6963 6b65 723a 3a63 6865 iece_picker::che │ │ │ +00061040: 636b 5f70 6565 7273 2829 0a09 7b0a 0909 ck_peers()..{... │ │ │ +00061050: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +00061060: 616d 703b 2062 203a 206d 5f62 6c6f 636b amp; b : m_block │ │ │ +00061070: 5f69 6e66 6f29 0a09 097b 0a09 0909 544f _info)...{....TO │ │ │ +00061080: 5252 454e 545f 4153 5345 5254 2862 2e70 RRENT_ASSERT(b.p │ │ │ +00061090: 6565 7220 3d3d 206e 756c 6c70 7472 207c eer == nullptr | │ │ │ +000610a0: 7c20 7374 6174 6963 5f63 6173 7426 6c74 | static_cast< │ │ │ +000610b0: 3b61 7578 3a3a 746f 7272 656e 745f 7065 ;aux::torrent_pe │ │ │ +000610c0: 6572 2a26 6774 3b28 622e 7065 6572 292d er*>(b.peer)- │ │ │ +000610d0: 2667 743b 696e 5f75 7365 293b 0a09 097d >in_use);...} │ │ │ +000610e0: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ +000610f0: 6420 7069 6563 655f 7069 636b 6572 3a3a d piece_picker:: │ │ │ +00061100: 636c 6561 725f 7065 6572 2861 7578 3a3a clear_peer(aux:: │ │ │ +00061110: 746f 7272 656e 745f 7065 6572 2a20 7065 torrent_peer* pe │ │ │ +00061120: 6572 290a 097b 0a09 0966 6f72 2028 6175 er)..{...for (au │ │ │ +00061130: 746f 2661 6d70 3b20 6220 3a20 6d5f 626c to& b : m_bl │ │ │ +00061140: 6f63 6b5f 696e 666f 290a 0909 7b0a 0909 ock_info)...{... │ │ │ +00061150: 0969 6620 2862 2e70 6565 7220 3d3d 2070 .if (b.peer == p │ │ │ +00061160: 6565 7229 2062 2e70 6565 7220 3d20 6e75 eer) b.peer = nu │ │ │ +00061170: 6c6c 7074 723b 0a09 097d 0a09 7d0a 0a09 llptr;...}..}... │ │ │ +00061180: 2f2f 2074 6865 2066 6972 7374 2062 6f6f // the first boo │ │ │ +00061190: 6c20 6973 2074 7275 6520 6966 2074 6869 l is true if thi │ │ │ +000611a0: 7320 6973 2074 6865 206f 6e6c 7920 7065 s is the only pe │ │ │ +000611b0: 6572 2074 6861 7420 6861 7320 7265 7175 er that has requ │ │ │ +000611c0: 6573 7465 6420 616e 6420 646f 776e 6c6f ested and downlo │ │ │ +000611d0: 6164 6564 0a09 2f2f 2062 6c6f 636b 7320 aded..// blocks │ │ │ +000611e0: 6672 6f6d 2074 6869 7320 7069 6563 652e from this piece. │ │ │ +000611f0: 0a09 2f2f 2074 6865 2073 6563 6f6e 6420 ..// the second │ │ │ +00061200: 626f 6f6c 2069 7320 7472 7565 2069 6620 bool is true if │ │ │ +00061210: 7468 6973 2069 7320 7468 6520 6f6e 6c79 this is the only │ │ │ +00061220: 2061 6374 6976 6520 7065 6572 2074 6861 active peer tha │ │ │ +00061230: 7420 6973 2072 6571 7565 7374 696e 670a t is requesting. │ │ │ +00061240: 092f 2f20 616e 6420 646f 776e 6c6f 6164 .// and download │ │ │ +00061250: 696e 6720 626c 6f63 6b73 2066 726f 6d20 ing blocks from │ │ │ +00061260: 7468 6973 2070 6965 6365 2e20 4163 7469 this piece. Acti │ │ │ +00061270: 7665 206d 6561 6e73 2068 6176 696e 6720 ve means having │ │ │ +00061280: 6120 636f 6e6e 6563 7469 6f6e 2e0a 3c2f a connection..r │ │ │ +000612c0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +000612d0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00061300: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ +00061310: 3a33 3131 393c 2f61 3e3c 2f74 643e 3c74 :3119should 5 be co │ │ │ +00061330: 6e66 6967 7572 6162 6c65 3f3c 2f74 643e nfigurable? │ │ │ +00061340: 3c2f 7472 3e3c 7472 2069 643d 2232 3234

    should │ │ │ +00061390: 3520 6265 2063 6f6e 6669 6775 7261 626c 5 be configurabl │ │ │ +000613a0: 653f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 e?

    ../sr │ │ │ +000613b0: 632f 7069 6563 655f 7069 636b 6572 2e63 c/piece_picker.c │ │ │ +000613c0: 7070 3a33 3131 393c 2f68 343e 3c70 7265 pp:3119

    ..bool hav
    │ │ │ +00061410: 655f 616c 6c20 3d20 7472 7565 3b0a 0a09  e_all = true;...
    │ │ │ +00061420: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ +00061430: 2070 6965 6365 203a 2065 7874 656e 745f   piece : extent_
    │ │ │ +00061440: 666f 7228 7468 6973 5f65 7874 656e 7429  for(this_extent)
    │ │ │ +00061450: 290a 0909 7b0a 0909 0969 6620 2870 6965  )...{....if (pie
    │ │ │ +00061460: 6365 203d 3d20 7029 2063 6f6e 7469 6e75  ce == p) continu
    │ │ │ +00061470: 653b 0a0a 0909 0969 6620 2821 6d5f 7069  e;.....if (!m_pi
    │ │ │ +00061480: 6563 655f 6d61 705b 7069 6563 655d 2e66  ece_map[piece].f
    │ │ │ +00061490: 6c75 7368 6564 2829 2920 6861 7665 5f61  lushed()) have_a
    │ │ │ +000614a0: 6c6c 203d 2066 616c 7365 3b0a 0a09 0909  ll = false;.....
    │ │ │ +000614b0: 2f2f 2069 6620 6174 206c 6561 7374 206f  // if at least o
    │ │ │ +000614c0: 6e65 2070 6965 6365 2069 6e20 7468 6973  ne piece in this
    │ │ │ +000614d0: 2065 7874 656e 7420 6861 7320 6120 6469   extent has a di
    │ │ │ +000614e0: 6666 6572 656e 7420 7072 696f 7269 7479  fferent priority
    │ │ │ +000614f0: 2074 6861 6e0a 0909 092f 2f20 7468 6520   than....// the 
    │ │ │ +00061500: 6f6e 6520 7765 206a 7573 7420 7374 6172  one we just star
    │ │ │ +00061510: 7465 6420 646f 776e 6c6f 6164 696e 672c  ted downloading,
    │ │ │ +00061520: 2064 6f6e 2774 2063 7265 6174 6520 616e   don't create an
    │ │ │ +00061530: 2061 6666 696e 6974 7920 666f 720a 0909   affinity for...
    │ │ │ +00061540: 092f 2f20 6164 6a61 6365 6e74 2070 6965  .// adjacent pie
    │ │ │ +00061550: 6365 732e 2054 6869 7320 7072 6f62 6162  ces. This probab
    │ │ │ +00061560: 6c79 206d 6561 6e73 2074 6865 2070 6965  ly means the pie
    │ │ │ +00061570: 6365 7320 6265 6c6f 6e67 2074 6f20 6469  ces belong to di
    │ │ │ +00061580: 6666 6572 656e 740a 0909 092f 2f20 6669  fferent....// fi
    │ │ │ +00061590: 6c65 732c 206f 7220 7468 6174 2073 6f6d  les, or that som
    │ │ │ +000615a0: 6520 6f74 6865 7220 6d65 6368 616e 6973  e other mechanis
    │ │ │ +000615b0: 6d20 6465 7465 726d 696e 696e 6720 7468  m determining th
    │ │ │ +000615c0: 6520 7072 696f 7269 7479 2073 686f 756c  e priority shoul
    │ │ │ +000615d0: 640a 0909 092f 2f20 7461 6b65 2070 7265  d....// take pre
    │ │ │ +000615e0: 6365 6465 6e63 652e 0a09 0909 6966 2028  cedence.....if (
    │ │ │ +000615f0: 7069 6563 655f 7072 696f 7269 7479 2870  piece_priority(p
    │ │ │ +00061600: 6965 6365 2920 213d 2074 6869 735f 7072  iece) != this_pr
    │ │ │ +00061610: 696f 2920 7265 7475 726e 3b0a 0909 7d0a  io) return;...}.
    │ │ │ +00061620: 0a09 092f 2f20 6966 2077 6520 616c 7265  ...// if we alre
    │ │ │ +00061630: 6164 7920 6861 7665 2061 6c6c 2074 6865  ady have all the
    │ │ │ +00061640: 202a 6f74 6865 722a 2070 6965 6365 7320   *other* pieces 
    │ │ │ +00061650: 696e 2074 6869 7320 6578 7465 6e74 2c20  in this extent, 
    │ │ │ +00061660: 7468 6572 6527 7320 6e6f 0a09 092f 2f20  there's no...// 
    │ │ │ +00061670: 6e65 6564 2074 6f20 696e 666c 6174 6520  need to inflate 
    │ │ │ +00061680: 7468 6569 7220 7072 696f 7269 7469 6573  their priorities
    │ │ │ +00061690: 0a09 0969 6620 2868 6176 655f 616c 6c29  ...if (have_all)
    │ │ │ +000616a0: 2072 6574 7572 6e3b 0a0a 3c64 6976 2073   return;..
    ..if (m_ │ │ │ +000616e0: 7265 6365 6e74 5f65 7874 656e 7473 2e73 recent_extents.s │ │ │ +000616f0: 697a 6528 2920 266c 743b 2035 290a 3c2f ize() < 5)....m_recent_ │ │ │ +00061710: 6578 7465 6e74 732e 7075 7368 5f62 6163 extents.push_bac │ │ │ +00061720: 6b28 7468 6973 5f65 7874 656e 7429 3b0a k(this_extent);. │ │ │ +00061730: 0a09 092f 2f20 6c69 6d69 7420 7468 6520 ...// limit the │ │ │ +00061740: 6e75 6d62 6572 206f 6620 6578 7465 6e74 number of extent │ │ │ +00061750: 2061 6666 696e 6974 6965 7320 6163 7469 affinities acti │ │ │ +00061760: 7665 2061 7420 616e 7920 6769 7665 6e20 ve at any given │ │ │ +00061770: 7469 6d65 2074 6f20 6c69 6d69 740a 0909 time to limit... │ │ │ +00061780: 2f2f 2074 6865 2063 6f73 7420 6f66 2063 // the cost of c │ │ │ +00061790: 6865 636b 696e 6720 7468 656d 2e20 416c hecking them. Al │ │ │ +000617a0: 736f 2c20 646f 6e27 7420 7265 706c 6163 so, don't replac │ │ │ +000617b0: 6520 7468 656d 2c20 636f 6d6d 6974 2074 e them, commit t │ │ │ +000617c0: 6f0a 0909 2f2f 2066 696e 6973 6869 6e67 o...// finishing │ │ │ +000617d0: 2074 6865 6d20 6265 666f 7265 2073 7461 them before sta │ │ │ +000617e0: 7274 696e 6720 616e 6f74 6865 7220 6578 rting another ex │ │ │ +000617f0: 7465 6e74 2e20 5468 6973 2069 7320 616e tent. This is an │ │ │ +00061800: 616c 6f67 6f75 7320 746f 0a09 092f 2f20 alogous to...// │ │ │ +00061810: 6c69 6d69 7469 6e67 2074 6865 206e 756d limiting the num │ │ │ +00061820: 6265 7220 6f66 2070 6172 7469 616c 2070 ber of partial p │ │ │ +00061830: 6965 6365 732e 0a09 7d0a 0a09 2f2f 206f ieces...}...// o │ │ │ +00061840: 7074 696f 6e73 206d 6179 2062 6520 3020 ptions may be 0 │ │ │ +00061850: 6f72 2070 6965 6365 5f70 6963 6b65 723a or piece_picker: │ │ │ +00061860: 3a72 6576 6572 7365 0a09 2f2f 2072 6574 :reverse..// ret │ │ │ +00061870: 7572 6e73 2066 616c 7365 2069 6620 7468 urns false if th │ │ │ +00061880: 6520 626c 6f63 6b20 636f 756c 6420 6e6f e block could no │ │ │ +00061890: 7420 6265 206d 6172 6b65 6420 6173 2064 t be marked as d │ │ │ +000618a0: 6f77 6e6c 6f61 6469 6e67 0a09 626f 6f6c ownloading..bool │ │ │ +000618b0: 2070 6965 6365 5f70 6963 6b65 723a 3a6d piece_picker::m │ │ │ +000618c0: 6172 6b5f 6173 5f64 6f77 6e6c 6f61 6469 ark_as_downloadi │ │ │ +000618d0: 6e67 2870 6965 6365 5f62 6c6f 636b 2063 ng(piece_block c │ │ │ +000618e0: 6f6e 7374 2062 6c6f 636b 0a09 092c 2061 onst block..., a │ │ │ +000618f0: 7578 3a3a 746f 7272 656e 745f 7065 6572 ux::torrent_peer │ │ │ +00061900: 2a20 7065 6572 2c20 7069 636b 6572 5f6f * peer, picker_o │ │ │ +00061910: 7074 696f 6e73 5f74 2063 6f6e 7374 206f ptions_t const o │ │ │ +00061920: 7074 696f 6e73 290a 097b 0a23 6966 6465 ptions)..{.#ifde │ │ │ +00061930: 6620 544f 5252 454e 545f 5049 434b 4552 f TORRENT_PICKER │ │ │ +00061940: 5f4c 4f47 0a09 0973 7464 3a3a 6365 7272 _LOG...std::cerr │ │ │ +00061950: 2026 6c74 3b26 6c74 3b20 225b 2220 266c << "[" &l │ │ │ +00061960: 743b 266c 743b 2074 6869 7320 266c 743b t;< this < │ │ │ +00061970: 266c 743b 2022 5d20 2220 266c 743b 266c < "] " <&l │ │ │ +00061980: 743b 2022 6d61 726b 5f61 735f 646f 776e t; "mark_as_down │ │ │ +00061990: 6c6f 6164 696e 6728 207b 220a 0909 0926 loading( {"....& │ │ │ +000619a0: 6c74 3b26 6c74 3b20 626c 6f63 6b2e 7069 lt;< block.pi │ │ │ +000619b0: 6563 655f 696e 6465 7820 266c 743b 266c ece_index <&l │ │ │ +000619c0: 743b 2022 2c20 2220 266c 743b 266c 743b t; ", " << │ │ │ +000619d0: 2062 6c6f 636b 2e62 6c6f 636b 5f69 6e64 block.block_ind │ │ │ +000619e0: 6578 2026 6c74 3b26 6c74 3b20 227d 2029 ex << "} ) │ │ │ +000619f0: 2220 266c 743b 266c 743b 2073 7464 3a3a " << std:: │ │ │ +00061a00: 656e 646c 3b0a 2365 6e64 6966 0a0a 0909 endl;.#endif.... │ │ │ +00061a10: 544f 5252 454e 545f 4153 5345 5254 2870 TORRENT_ASSERT(p │ │ │ +00061a20: 6565 7220 3d3d 206e 756c 6c70 7472 207c eer == nullptr | │ │ │ +00061a30: 7c20 7065 6572 2d26 6774 3b69 6e5f 7573 | peer->in_us │ │ │ +00061a40: 6529 3b0a 0909 544f 5252 454e 545f 4153 e);...TORRENT_AS │ │ │ +00061a50: 5345 5254 2862 6c6f 636b 2e62 6c6f 636b SERT(block.block │ │ │ +00061a60: 5f69 6e64 6578 2021 3d20 7069 6563 655f _index != piece_ │ │ │ +00061a70: 626c 6f63 6b3a 3a69 6e76 616c 6964 2e62 block::invalid.b │ │ │ +00061a80: 6c6f 636b 5f69 6e64 6578 293b 0a09 0954 lock_index);...T │ │ │ +00061a90: 4f52 5245 4e54 5f41 5353 4552 5428 626c ORRENT_ASSERT(bl │ │ │ +00061aa0: 6f63 6b2e 7069 6563 655f 696e 6465 7820 ock.piece_index │ │ │ +00061ab0: 213d 2070 6965 6365 5f62 6c6f 636b 3a3a != piece_block:: │ │ │ +00061ac0: 696e 7661 6c69 642e 7069 6563 655f 696e invalid.piece_in │ │ │ +00061ad0: 6465 7829 3b0a 0909 544f 5252 454e 545f dex);...TORRENT_ │ │ │ +00061ae0: 4153 5345 5254 2862 6c6f 636b 2e70 6965 ASSERT(block.pie │ │ │ +00061af0: 6365 5f69 6e64 6578 2026 6c74 3b20 6d5f ce_index < m_ │ │ │ +00061b00: 7069 6563 655f 6d61 702e 656e 645f 696e piece_map.end_in │ │ │ +00061b10: 6465 7828 2929 3b0a 0909 544f 5252 454e dex());...TORREN │ │ │ +00061b20: 545f 4153 5345 5254 2862 6c6f 636b 2e62 T_ASSERT(block.b │ │ │ +00061b30: 6c6f 636b 5f69 6e64 6578 2026 6c74 3b20 lock_index < │ │ │ +00061b40: 626c 6f63 6b73 5f69 6e5f 7069 6563 6528 blocks_in_piece( │ │ │ +00061b50: 626c 6f63 6b2e 7069 6563 655f 696e 6465 block.piece_inde │ │ │ +00061b60: 7829 293b 0a09 0954 4f52 5245 4e54 5f41 x));...TORRENT_A │ │ │ +00061b70: 5353 4552 5428 216d 5f70 6965 6365 5f6d SSERT(!m_piece_m │ │ │ +00061b80: 6170 5b62 6c6f 636b 2e70 6965 6365 5f69 ap[block.piece_i │ │ │ +00061b90: 6e64 6578 5d2e 666c 7573 6865 6428 2929 ndex].flushed()) │ │ │ +00061ba0: 3b0a 0a09 0970 6965 6365 5f70 6f73 2661 ;....piece_pos&a │ │ │ +00061bb0: 6d70 3b20 7020 3d20 6d5f 7069 6563 655f mp; p = m_piece_ │ │ │ +00061bc0: 6d61 705b 626c 6f63 6b2e 7069 6563 655f map[block.piece_ │ │ │ +00061bd0: 696e 6465 785d 3b0a 0909 6966 2028 702e index];...if (p. │ │ │ +00061be0: 646f 776e 6c6f 6164 5f71 7565 7565 2829 download_queue() │ │ │ +00061bf0: 203d 3d20 7069 6563 655f 706f 733a 3a70 == piece_pos::p │ │ │ +00061c00: 6965 6365 5f6f 7065 6e29 0a09 097b 0a23 iece_open)...{.# │ │ │ +00061c10: 6966 6465 6620 544f 5252 454e 545f 4558 ifdef TORRENT_EX │ │ │ +00061c20: 5045 4e53 4956 455f 494e 5641 5249 414e PENSIVE_INVARIAN │ │ │ +00061c30: 545f 4348 4543 4b53 0a09 0909 494e 5641 T_CHECKS....INVA │ │ │ +00061c40: 5249 414e 545f 4348 4543 4b3b 0a3c 2f70 RIANT_CHECK;.

    re │ │ │ +00061c80: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/i │ │ │ +00061cc0: 705f 6e6f 7469 6669 6572 2e63 7070 3a31 p_notifier.cpp:1 │ │ │ +00061cd0: 383c 2f61 3e3c 2f74 643e 3c74 643e 7369 8si │ │ │ +00061ce0: 6d75 6c61 746f 7220 7375 7070 6f72 743c mulator support< │ │ │ +00061cf0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sim │ │ │ +00061d40: 756c 6174 6f72 2073 7570 706f 7274 3c2f ulator support

    ../src/ip │ │ │ +00061d60: 5f6e 6f74 6966 6965 722e 6370 703a 3138 _notifier.cpp:18 │ │ │ +00061d70: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00061db0: 096d 5f68 6176 655f 7061 645f 6279 7465  .m_have_pad_byte
    │ │ │ +00061dc0: 7320 2d3d 2070 6164 5f62 7974 6573 3b0a  s -= pad_bytes;.
    │ │ │ +00061dd0: 097d 0a7d 0a2f 2a0a 0a43 6f70 7972 6967  .}.}./*..Copyrig
    │ │ │ +00061de0: 6874 2028 6329 2032 3031 362d 3230 3137  ht (c) 2016-2017
    │ │ │ +00061df0: 2c20 3230 3231 2c20 416c 6465 6e20 546f  , 2021, Alden To
    │ │ │ +00061e00: 7272 6573 0a43 6f70 7972 6967 6874 2028  rres.Copyright (
    │ │ │ +00061e10: 6329 2032 3031 362c 2032 3032 302c 2053  c) 2016, 2020, S
    │ │ │ +00061e20: 7465 7665 6e20 5369 6c6f 7469 0a43 6f70  teven Siloti.Cop
    │ │ │ +00061e30: 7972 6967 6874 2028 6329 2032 3031 372d  yright (c) 2017-
    │ │ │ +00061e40: 3230 3232 2c20 4172 7669 6420 4e6f 7262  2022, Arvid Norb
    │ │ │ +00061e50: 6572 670a 436f 7079 7269 6768 7420 2863  erg.Copyright (c
    │ │ │ +00061e60: 2920 3230 3137 2c20 5469 6d20 4e69 6564  ) 2017, Tim Nied
    │ │ │ +00061e70: 6572 6861 7573 656e 0a43 6f70 7972 6967  erhausen.Copyrig
    │ │ │ +00061e80: 6874 2028 6329 2032 3032 302c 2054 6967  ht (c) 2020, Tig
    │ │ │ +00061e90: 6572 2057 616e 670a 416c 6c20 7269 6768  er Wang.All righ
    │ │ │ +00061ea0: 7473 2072 6573 6572 7665 642e 0a0a 596f  ts reserved...Yo
    │ │ │ +00061eb0: 7520 6d61 7920 7573 652c 2064 6973 7472  u may use, distr
    │ │ │ +00061ec0: 6962 7574 6520 616e 6420 6d6f 6469 6679  ibute and modify
    │ │ │ +00061ed0: 2074 6869 7320 636f 6465 2075 6e64 6572   this code under
    │ │ │ +00061ee0: 2074 6865 2074 6572 6d73 206f 6620 7468   the terms of th
    │ │ │ +00061ef0: 6520 4253 4420 6c69 6365 6e73 652c 0a73  e BSD license,.s
    │ │ │ +00061f00: 6565 204c 4943 454e 5345 2066 696c 652e  ee LICENSE file.
    │ │ │ +00061f10: 0a2a 2f0a 0a23 696e 636c 7564 6520 226c  .*/..#include "l
    │ │ │ +00061f20: 6962 746f 7272 656e 742f 6175 785f 2f69  ibtorrent/aux_/i
    │ │ │ +00061f30: 705f 6e6f 7469 6669 6572 2e68 7070 220a  p_notifier.hpp".
    │ │ │ +00061f40: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ +00061f50: 7265 6e74 2f61 7373 6572 742e 6870 7022  rent/assert.hpp"
    │ │ │ +00061f60: 0a0a 2369 6620 6465 6669 6e65 6420 544f  ..#if defined TO
    │ │ │ +00061f70: 5252 454e 545f 4255 494c 445f 5349 4d55  RRENT_BUILD_SIMU
    │ │ │ +00061f80: 4c41 544f 520a 3c64 6976 2073 7479 6c65  LATOR.
    #elif TORREN │ │ │ +00061fc0: 545f 5553 455f 4e45 544c 494e 4b0a 3c2f T_USE_NETLINK.#include "li │ │ │ +00061fe0: 6274 6f72 7265 6e74 2f61 7578 5f2f 6e65 btorrent/aux_/ne │ │ │ +00061ff0: 746c 696e 6b2e 6870 7022 0a23 696e 636c tlink.hpp".#incl │ │ │ +00062000: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ +00062010: 736f 636b 6574 2e68 7070 220a 2369 6e63 socket.hpp".#inc │ │ │ +00062020: 6c75 6465 2026 6c74 3b61 7272 6179 2667 lude <array&g │ │ │ +00062030: 743b 0a23 696e 636c 7564 6520 266c 743b t;.#include < │ │ │ +00062040: 756e 6f72 6465 7265 645f 6d61 7026 6774 unordered_map> │ │ │ +00062050: 3b0a 2365 6c69 6620 544f 5252 454e 545f ;.#elif TORRENT_ │ │ │ +00062060: 5553 455f 5359 5354 454d 434f 4e46 4947 USE_SYSTEMCONFIG │ │ │ +00062070: 5552 4154 494f 4e20 7c7c 2054 4f52 5245 URATION || TORRE │ │ │ +00062080: 4e54 5f55 5345 5f53 435f 4e45 5457 4f52 NT_USE_SC_NETWOR │ │ │ +00062090: 4b5f 5245 4143 4841 4249 4c49 5459 0a23 K_REACHABILITY.# │ │ │ +000620a0: 696e 636c 7564 6520 266c 743b 5379 7374 include <Syst │ │ │ +000620b0: 656d 436f 6e66 6967 7572 6174 696f 6e2f emConfiguration/ │ │ │ +000620c0: 5379 7374 656d 436f 6e66 6967 7572 6174 SystemConfigurat │ │ │ +000620d0: 696f 6e2e 6826 6774 3b0a 2365 6c69 6620 ion.h>.#elif │ │ │ +000620e0: 6465 6669 6e65 6420 544f 5252 454e 545f defined TORRENT_ │ │ │ +000620f0: 5749 4e44 4f57 530a 2369 6e63 6c75 6465 WINDOWS.#include │ │ │ +00062100: 2022 6c69 6274 6f72 7265 6e74 2f61 7578 "libtorrent/aux │ │ │ +00062110: 5f2f 7468 726f 772e 6870 7022 0a23 696e _/throw.hpp".#in │ │ │ +00062120: 636c 7564 6520 226c 6962 746f 7272 656e clude "libtorren │ │ │ +00062130: 742f 6175 785f 2f64 6973 6162 6c65 5f77 t/aux_/disable_w │ │ │ +00062140: 6172 6e69 6e67 735f 7075 7368 2e68 7070 arnings_push.hpp │ │ │ +00062150: 220a 2369 6e63 6c75 6465 2026 6c74 3b69 ".#include <i │ │ │ +00062160: 7068 6c70 6170 692e 6826 6774 3b0a 2369 phlpapi.h>.#i │ │ │ +00062170: 6664 6566 2054 4f52 5245 4e54 5f57 494e fdef TORRENT_WIN │ │ │ +00062180: 5254 0a23 696e 636c 7564 6520 266c 743b RT.#include < │ │ │ +00062190: 6e65 7469 6f61 7069 2e68 2667 743b 0a23 netioapi.h>.# │ │ │ +000621a0: 656e 6469 660a 2369 6e63 6c75 6465 2026 endif.#include & │ │ │ +000621b0: 6c74 3b6d 7574 6578 2667 743b 0a23 696e lt;mutex>.#in │ │ │ +000621c0: 636c 7564 6520 226c 6962 746f 7272 656e clude "libtorren │ │ │ +000621d0: 742f 6175 785f 2f64 6973 6162 6c65 5f77 t/aux_/disable_w │ │ │ +000621e0: 6172 6e69 6e67 735f 706f 702e 6870 7022 arnings_pop.hpp" │ │ │ +000621f0: 0a23 656e 6469 660a 0a23 696e 636c 7564 .#endif..#includ │ │ │ +00062200: 6520 226c 6962 746f 7272 656e 742f 6175 e "libtorrent/au │ │ │ +00062210: 785f 2f6e 6574 6c69 6e6b 5f75 7469 6c73 x_/netlink_utils │ │ │ +00062220: 2e68 7070 220a 0a6e 616d 6573 7061 6365 .hpp"..namespace │ │ │ +00062230: 206c 6962 746f 7272 656e 743a 3a61 7578 libtorrent::aux │ │ │ +00062240: 207b 0a0a 6e61 6d65 7370 6163 6520 7b0a {..namespace {. │ │ │ +00062250: 0a23 6966 2028 544f 5252 454e 545f 5553 .#if (TORRENT_US │ │ │ +00062260: 455f 5359 5354 454d 434f 4e46 4947 5552 E_SYSTEMCONFIGUR │ │ │ +00062270: 4154 494f 4e20 7c7c 2054 4f52 5245 4e54 ATION || TORRENT │ │ │ +00062280: 5f55 5345 5f53 435f 4e45 5457 4f52 4b5f _USE_SC_NETWORK_ │ │ │ +00062290: 5245 4143 4841 4249 4c49 5459 2920 2661 REACHABILITY) &a │ │ │ +000622a0: 6d70 3b26 616d 703b 205c 0a09 2164 6566 mp;& \..!def │ │ │ +000622b0: 696e 6564 2054 4f52 5245 4e54 5f42 5549 ined TORRENT_BUI │ │ │ +000622c0: 4c44 5f53 494d 554c 4154 4f52 0a0a 2f2f LD_SIMULATOR..// │ │ │ +000622d0: 2063 6f6d 6d6f 6e20 7574 696c 6974 6965 common utilitie │ │ │ +000622e0: 7320 666f 7220 4d61 6320 616e 6420 694f s for Mac and iO │ │ │ +000622f0: 530a 7465 6d70 6c61 7465 2026 6c74 3b74 S.template <t │ │ │ +00062300: 7970 656e 616d 6520 5426 6774 3b20 766f ypename T> vo │ │ │ +00062310: 6964 2043 4652 6566 5265 7461 696e 2854 id CFRefRetain(T │ │ │ +00062320: 2068 2920 7b20 4346 5265 7461 696e 2868 h) { CFRetain(h │ │ │ +00062330: 293b 207d 0a74 656d 706c 6174 6520 266c ); }.template &l │ │ │ +00062340: 743b 7479 7065 6e61 6d65 2054 2667 743b t;typename T> │ │ │ +00062350: 2076 6f69 6420 4346 5265 6652 656c 6561 void CFRefRelea │ │ │ +00062360: 7365 2854 2068 2920 7b20 4346 5265 6c65 se(T h) { CFRele │ │ │ +00062370: 6173 6528 6829 3b20 7d0a 0a3c 2f70 7265 ase(h); }..
    rele │ │ │ +000623b0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pe_ │ │ │ +000623f0: 6372 7970 746f 2e63 7070 3a31 3332 3c2f crypto.cpp:132it wo │ │ │ +00062410: 756c 6420 6265 206e 6963 6520 746f 2062 uld be nice to b │ │ │ +00062420: 6520 6162 6c65 2074 6f20 6578 706f 7274 e able to export │ │ │ +00062430: 2074 6f20 6120 6669 7865 6420 7769 6474 to a fixed widt │ │ │ +00062440: 6820 6669 656c 642c 2073 6f20 7765 2077 h field, so we w │ │ │ +00062450: 6f75 6c64 6e27 7420 6861 7665 2074 6f20 ouldn't have to │ │ │ +00062460: 7368 6966 7420 6974 206c 6174 6572 3c2f shift it later

    it w │ │ │ +000624c0: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ +000624d0: 6265 2061 626c 6520 746f 2065 7870 6f72 be able to expor │ │ │ +000624e0: 7420 746f 2061 2066 6978 6564 2077 6964 t to a fixed wid │ │ │ +000624f0: 7468 2066 6965 6c64 2c20 736f 0a77 6520 th field, so.we │ │ │ +00062500: 776f 756c 646e 2774 2068 6176 6520 746f wouldn't have to │ │ │ +00062510: 2073 6869 6674 2069 7420 6c61 7465 723c shift it later< │ │ │ +00062520: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00062530: 655f 6372 7970 746f 2e63 7070 3a31 3332 e_crypto.cpp:132 │ │ │ +00062540: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00062580: 0909 0942 4e5f 4d4f 4e54 5f43 5458 5f6e  ...BN_MONT_CTX_n
    │ │ │ +00062590: 6577 2829 2c20 2661 6d70 3b42 4e5f 4d4f  ew(), &BN_MO
    │ │ │ +000625a0: 4e54 5f43 5458 5f66 7265 6529 3b0a 0909  NT_CTX_free);...
    │ │ │ +000625b0: 0969 6620 2821 7265 7420 7c7c 2021 424e  .if (!ret || !BN
    │ │ │ +000625c0: 5f4d 4f4e 545f 4354 585f 7365 7428 7265  _MONT_CTX_set(re
    │ │ │ +000625d0: 742e 6765 7428 292c 2064 685f 7072 696d  t.get(), dh_prim
    │ │ │ +000625e0: 6528 292e 6765 7428 292c 2063 7478 2829  e().get(), ctx()
    │ │ │ +000625f0: 2929 0a09 0909 0961 7578 3a3a 7468 726f  )).....aux::thro
    │ │ │ +00062600: 775f 6578 266c 743b 7379 7374 656d 5f65  w_ex<system_e
    │ │ │ +00062610: 7272 6f72 2667 743b 2865 7272 6f72 733a  rror>(errors:
    │ │ │ +00062620: 3a6e 6f5f 6d65 6d6f 7279 293b 0a09 0909  :no_memory);....
    │ │ │ +00062630: 7265 7475 726e 2072 6574 3b0a 0909 7d3b  return ret;...};
    │ │ │ +00062640: 0a23 6966 6465 6620 424f 4f53 545f 4e4f  .#ifdef BOOST_NO
    │ │ │ +00062650: 5f43 5858 3131 5f54 4852 4541 445f 4c4f  _CXX11_THREAD_LO
    │ │ │ +00062660: 4341 4c0a 0909 7374 6174 6963 2073 7464  CAL...static std
    │ │ │ +00062670: 3a3a 756e 6971 7565 5f70 7472 266c 743b  ::unique_ptr<
    │ │ │ +00062680: 3a3a 424e 5f4d 4f4e 545f 4354 582c 2076  ::BN_MONT_CTX, v
    │ │ │ +00062690: 6f69 6420 282a 2928 3a3a 424e 5f4d 4f4e  oid (*)(::BN_MON
    │ │ │ +000626a0: 545f 4354 582a 2926 6774 3b20 7368 6172  T_CTX*)> shar
    │ │ │ +000626b0: 6564 5f6d 6f6e 7420 3d20 6d61 6b65 5f6d  ed_mont = make_m
    │ │ │ +000626c0: 6f6e 7428 293b 0a23 656c 7365 0a09 0974  ont();.#else...t
    │ │ │ +000626d0: 6872 6561 645f 6c6f 6361 6c20 7374 6174  hread_local stat
    │ │ │ +000626e0: 6963 2073 7464 3a3a 756e 6971 7565 5f70  ic std::unique_p
    │ │ │ +000626f0: 7472 266c 743b 3a3a 424e 5f4d 4f4e 545f  tr<::BN_MONT_
    │ │ │ +00062700: 4354 582c 2076 6f69 6420 282a 2928 3a3a  CTX, void (*)(::
    │ │ │ +00062710: 424e 5f4d 4f4e 545f 4354 582a 2926 6774  BN_MONT_CTX*)>
    │ │ │ +00062720: 3b20 7368 6172 6564 5f6d 6f6e 7420 3d0a  ; shared_mont =.
    │ │ │ +00062730: 0909 096d 616b 655f 6d6f 6e74 2829 3b0a  ...make_mont();.
    │ │ │ +00062740: 2365 6e64 6966 0a09 0972 6574 7572 6e20  #endif...return 
    │ │ │ +00062750: 7368 6172 6564 5f6d 6f6e 742e 6765 7428  shared_mont.get(
    │ │ │ +00062760: 293b 0a09 7d0a 0a09 7374 643a 3a61 7272  );..}...std::arr
    │ │ │ +00062770: 6179 266c 743b 6368 6172 2c20 3936 2667  ay<char, 96&g
    │ │ │ +00062780: 743b 2064 685f 6b65 795f 6578 6368 616e  t; dh_key_exchan
    │ │ │ +00062790: 6765 3a3a 6578 706f 7274 5f6b 6579 286b  ge::export_key(k
    │ │ │ +000627a0: 6579 5f74 2063 6f6e 7374 2661 6d70 3b20  ey_t const& 
    │ │ │ +000627b0: 6b29 0a09 7b0a 0909 7374 643a 3a61 7272  k)..{...std::arr
    │ │ │ +000627c0: 6179 266c 743b 6368 6172 2c20 3936 2667  ay<char, 96&g
    │ │ │ +000627d0: 743b 2072 6574 3b0a 0909 6175 746f 2a20  t; ret;...auto* 
    │ │ │ +000627e0: 6265 6769 6e20 3d20 7265 696e 7465 7270  begin = reinterp
    │ │ │ +000627f0: 7265 745f 6361 7374 266c 743b 756e 7369  ret_cast<unsi
    │ │ │ +00062800: 676e 6564 2063 6861 722a 2667 743b 2872  gned char*>(r
    │ │ │ +00062810: 6574 2e64 6174 6128 2929 3b0a 0909 696e  et.data());...in
    │ │ │ +00062820: 7420 636f 6e73 7420 6c65 6e20 3d20 424e  t const len = BN
    │ │ │ +00062830: 5f62 6e32 6269 6e28 6b2e 6765 7428 292c  _bn2bin(k.get(),
    │ │ │ +00062840: 2062 6567 696e 293b 0a0a 3c64 6976 2073   begin);..
    ..if (le │ │ │ +00062880: 6e20 266c 743b 2039 3629 0a3c 2f64 6976 n < 96).
    ..{....std::mem │ │ │ +000628a0: 6d6f 7665 2862 6567 696e 202b 2039 3620 move(begin + 96 │ │ │ +000628b0: 2d20 6c65 6e2c 2062 6567 696e 2c20 6175 - len, begin, au │ │ │ +000628c0: 783a 3a6e 756d 6572 6963 5f63 6173 7426 x::numeric_cast& │ │ │ +000628d0: 6c74 3b73 7464 3a3a 7369 7a65 5f74 2667 lt;std::size_t&g │ │ │ +000628e0: 743b 286c 656e 2929 3b0a 0909 0973 7464 t;(len));....std │ │ │ +000628f0: 3a3a 6d65 6d73 6574 2862 6567 696e 2c20 ::memset(begin, │ │ │ +00062900: 302c 2061 7578 3a3a 6e75 6d65 7269 635f 0, aux::numeric_ │ │ │ +00062910: 6361 7374 266c 743b 7374 643a 3a73 697a cast<std::siz │ │ │ +00062920: 655f 7426 6774 3b28 3936 202d 206c 656e e_t>(96 - len │ │ │ +00062930: 2929 3b0a 0909 7d0a 0909 7265 7475 726e ));...}...return │ │ │ +00062940: 2072 6574 3b0a 097d 0a0a 092f 2f20 5365 ret;..}...// Se │ │ │ +00062950: 7420 7468 6520 7072 696d 6520 5020 616e t the prime P an │ │ │ +00062960: 6420 7468 6520 6765 6e65 7261 746f 722c d the generator, │ │ │ +00062970: 2067 656e 6572 6174 6520 6c6f 6361 6c20 generate local │ │ │ +00062980: 7075 626c 6963 206b 6579 0a09 6468 5f6b public key..dh_k │ │ │ +00062990: 6579 5f65 7863 6861 6e67 653a 3a64 685f ey_exchange::dh_ │ │ │ +000629a0: 6b65 795f 6578 6368 616e 6765 2829 0a09 key_exchange().. │ │ │ +000629b0: 7b0a 0909 6175 783a 3a61 7272 6179 266c {...aux::array&l │ │ │ +000629c0: 743b 7374 643a 3a75 696e 7438 5f74 2c20 t;std::uint8_t, │ │ │ +000629d0: 3230 2667 743b 2072 616e 646f 6d5f 6b65 20> random_ke │ │ │ +000629e0: 793b 0a09 0961 7578 3a3a 7261 6e64 6f6d y;...aux::random │ │ │ +000629f0: 5f62 7974 6573 287b 7265 696e 7465 7270 _bytes({reinterp │ │ │ +00062a00: 7265 745f 6361 7374 266c 743b 6368 6172 ret_cast<char │ │ │ +00062a10: 2a26 6774 3b28 7261 6e64 6f6d 5f6b 6579 *>(random_key │ │ │ +00062a20: 2e64 6174 6128 2929 2c0a 0909 0973 7461 .data()),....sta │ │ │ +00062a30: 7469 635f 6361 7374 266c 743b 7374 643a tic_cast<std: │ │ │ +00062a40: 3a70 7472 6469 6666 5f74 2667 743b 2872 :ptrdiff_t>(r │ │ │ +00062a50: 616e 646f 6d5f 6b65 792e 7369 7a65 2829 andom_key.size() │ │ │ +00062a60: 297d 293b 0a0a 0909 2f2f 2063 7265 6174 )});....// creat │ │ │ +00062a70: 6520 6c6f 6361 6c20 6b65 7920 2872 616e e local key (ran │ │ │ +00062a80: 646f 6d29 0a09 0969 6620 2821 424e 5f62 dom)...if (!BN_b │ │ │ +00062a90: 696e 3262 6e28 7261 6e64 6f6d 5f6b 6579 in2bn(random_key │ │ │ +00062aa0: 2e64 6174 6128 292c 2069 6e74 2872 616e .data(), int(ran │ │ │ +00062ab0: 646f 6d5f 6b65 792e 7369 7a65 2829 292c dom_key.size()), │ │ │ +00062ac0: 206d 5f64 685f 6c6f 6361 6c5f 7365 6372 m_dh_local_secr │ │ │ +00062ad0: 6574 2e67 6574 2829 2929 0a09 0909 6175 et.get()))....au │ │ │ +00062ae0: 783a 3a74 6872 6f77 5f65 7826 6c74 3b73 x::throw_ex<s │ │ │ +00062af0: 7973 7465 6d5f 6572 726f 7226 6774 3b28 ystem_error>( │ │ │ +00062b00: 6572 726f 7273 3a3a 6e6f 5f6d 656d 6f72 errors::no_memor │ │ │ +00062b10: 7929 3b0a 0a09 092f 2f20 6b65 7920 3d20 y);....// key = │ │ │ +00062b20: 2832 205e 2073 6563 7265 7429 2025 2070 (2 ^ secret) % p │ │ │ +00062b30: 7269 6d65 0a09 096b 6579 5f74 206c 6f63 rime...key_t loc │ │ │ +00062b40: 616c 5f6b 6579 3b0a 0a09 097b 0a23 6966 al_key;....{.#if │ │ │ +00062b50: 6465 6620 424f 4f53 545f 4e4f 5f43 5858 def BOOST_NO_CXX │ │ │ +00062b60: 3131 5f54 4852 4541 445f 4c4f 4341 4c0a 11_THREAD_LOCAL. │ │ │ +00062b70: 0909 0973 7464 3a3a 6c6f 636b 5f67 7561 ...std::lock_gua │ │ │ +00062b80: 7264 266c 743b 7374 643a 3a6d 7574 6578 rd<std::mutex │ │ │ +00062b90: 2667 743b 206c 2867 5f62 6e5f 6374 785f > l(g_bn_ctx_ │ │ │ +00062ba0: 6d75 7465 7829 3b0a 2365 6e64 6966 0a09 mutex);.#endif.. │ │ │ +00062bb0: 0909 6966 2028 2142 4e5f 6d6f 645f 6578 ..if (!BN_mod_ex │ │ │ +00062bc0: 705f 6d6f 6e74 286c 6f63 616c 5f6b 6579 p_mont(local_key │ │ │ +00062bd0: 2e67 6574 2829 2c0a 0909 0909 0974 776f .get(),......two │ │ │ +00062be0: 2829 2e67 6574 2829 2c0a 0909 0909 096d ().get(),......m │ │ │ +00062bf0: 5f64 685f 6c6f 6361 6c5f 7365 6372 6574 _dh_local_secret │ │ │ +00062c00: 2e67 6574 2829 2c0a 0909 0909 0964 685f .get(),......dh_ │ │ │ +00062c10: 7072 696d 6528 292e 6765 7428 292c 0a09 prime().get(),.. │ │ │ +00062c20: 0909 0909 6374 7828 292c 0a3c 2f70 7265 ....ctx(),.
    rele │ │ │ +00062c60: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0
    ../src/pe_ │ │ │ +00062ca0: 6372 7970 746f 2e63 7070 3a32 3132 3c2f crypto.cpp:212it wo │ │ │ +00062cc0: 756c 6420 6265 206e 6963 6520 746f 2067 uld be nice to g │ │ │ +00062cd0: 6574 2074 6865 206c 6974 6572 616c 2077 et the literal w │ │ │ +00062ce0: 6f72 6b69 6e67 3c2f 7464 3e3c 2f74 723e orking │ │ │ +00062cf0: 3c74 7220 6964 3d22 3232 3722 2073 7479 │ │ │ +00062d20: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00062d30: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +00062d40: 6e69 6365 2074 6f20 6765 7420 7468 6520 nice to get the │ │ │ +00062d50: 6c69 7465 7261 6c20 776f 726b 696e 673c literal working< │ │ │ +00062d60: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00062d70: 655f 6372 7970 746f 2e63 7070 3a32 3132 e_crypto.cpp:212 │ │ │ +00062d80: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00062dc0: 0909 6966 2028 2142 4e5f 6d6f 645f 6578  ..if (!BN_mod_ex
    │ │ │ +00062dd0: 705f 6d6f 6e74 2873 6563 7265 742e 6765  p_mont(secret.ge
    │ │ │ +00062de0: 7428 292c 0a09 0909 0909 6b65 792e 6765  t(),......key.ge
    │ │ │ +00062df0: 7428 292c 0a09 0909 0909 6d5f 6468 5f6c  t(),......m_dh_l
    │ │ │ +00062e00: 6f63 616c 5f73 6563 7265 742e 6765 7428  ocal_secret.get(
    │ │ │ +00062e10: 292c 0a09 0909 0909 6468 5f70 7269 6d65  ),......dh_prime
    │ │ │ +00062e20: 2829 2e67 6574 2829 2c0a 0909 0909 0963  ().get(),......c
    │ │ │ +00062e30: 7478 2829 2c0a 0909 0909 096d 6f6e 7428  tx(),......mont(
    │ │ │ +00062e40: 2929 290a 0909 0909 6175 783a 3a74 6872  ))).....aux::thr
    │ │ │ +00062e50: 6f77 5f65 7826 6c74 3b73 7973 7465 6d5f  ow_ex<system_
    │ │ │ +00062e60: 6572 726f 7226 6774 3b28 6572 726f 7273  error>(errors
    │ │ │ +00062e70: 3a3a 6e6f 5f6d 656d 6f72 7929 3b0a 0909  ::no_memory);...
    │ │ │ +00062e80: 7d0a 0909 6d5f 6468 5f73 6861 7265 645f  }...m_dh_shared_
    │ │ │ +00062e90: 7365 6372 6574 203d 2065 7870 6f72 745f  secret = export_
    │ │ │ +00062ea0: 6b65 7928 7365 6372 6574 293b 0a0a 0909  key(secret);....
    │ │ │ +00062eb0: 7374 6174 6963 2063 6861 7220 636f 6e73  static char cons
    │ │ │ +00062ec0: 7420 7265 7133 5b34 5d20 3d20 7b27 7227  t req3[4] = {'r'
    │ │ │ +00062ed0: 2c20 2765 272c 2027 7127 2c20 2733 277d  , 'e', 'q', '3'}
    │ │ │ +00062ee0: 3b0a 0909 2f2f 2063 616c 6375 6c61 7465  ;...// calculate
    │ │ │ +00062ef0: 2074 6865 2078 6f72 206d 6173 6b20 666f   the xor mask fo
    │ │ │ +00062f00: 7220 7468 6520 6f62 6675 7363 6174 6564  r the obfuscated
    │ │ │ +00062f10: 2068 6173 680a 0909 6d5f 786f 725f 6d61   hash...m_xor_ma
    │ │ │ +00062f20: 736b 203d 2068 6173 6865 7228 7265 7133  sk = hasher(req3
    │ │ │ +00062f30: 292e 7570 6461 7465 286d 5f64 685f 7368  ).update(m_dh_sh
    │ │ │ +00062f40: 6172 6564 5f73 6563 7265 7429 2e66 696e  ared_secret).fin
    │ │ │ +00062f50: 616c 2829 3b0a 0909 7265 7475 726e 2074  al();...return t
    │ │ │ +00062f60: 7275 653b 0a09 7d0a 0a23 656c 7365 202f  rue;..}..#else /
    │ │ │ +00062f70: 2f20 544f 5252 454e 545f 5553 455f 4c49  / TORRENT_USE_LI
    │ │ │ +00062f80: 4243 5259 5054 4f0a 0a09 6468 5f6b 6579  BCRYPTO...dh_key
    │ │ │ +00062f90: 5f65 7863 6861 6e67 653a 3a6b 6579 5f74  _exchange::key_t
    │ │ │ +00062fa0: 2063 6f6e 7374 2661 6d70 3b20 6468 5f6b   const& dh_k
    │ │ │ +00062fb0: 6579 5f65 7863 6861 6e67 653a 3a64 685f  ey_exchange::dh_
    │ │ │ +00062fc0: 7072 696d 6528 290a 097b 0a3c 6469 7620  prime()..{.
    ..stati │ │ │ +00063000: 6320 6b65 795f 7420 636f 6e73 7420 7072 c key_t const pr │ │ │ +00063010: 696d 6528 0a3c 2f64 6976 3e09 0909 2230 ime(.
    ..."0 │ │ │ +00063020: 7846 4646 4646 4646 4646 4646 4646 4646 xFFFFFFFFFFFFFFF │ │ │ +00063030: 4643 3930 4644 4141 3232 3136 3843 3233 FC90FDAA22168C23 │ │ │ +00063040: 3443 3443 3636 3238 4238 3044 4331 4344 4C4C6628B80DC1CD │ │ │ +00063050: 3132 3930 3234 4530 3838 4136 3743 4337 129024E088A67CC7 │ │ │ +00063060: 3430 3230 4242 4541 3633 4231 3339 4232 4020BBEA63B139B2 │ │ │ +00063070: 3235 3134 4122 0a09 0909 2230 3837 3938 2514A"...."08798 │ │ │ +00063080: 4533 3430 3444 4445 4639 3531 3942 3343 E3404DDEF9519B3C │ │ │ +00063090: 4433 4134 3331 4233 3032 4230 4136 4446 D3A431B302B0A6DF │ │ │ +000630a0: 3235 4631 3433 3734 4645 3133 3536 4436 25F14374FE1356D6 │ │ │ +000630b0: 4435 3143 3234 3545 3438 3542 3537 3636 D51C245E485B5766 │ │ │ +000630c0: 3235 4537 4543 3646 3434 4334 3245 3941 25E7EC6F44C42E9A │ │ │ +000630d0: 3622 0a09 0909 2233 4133 3632 3130 3030 6"...."3A3621000 │ │ │ +000630e0: 3030 3030 3030 3030 3930 3536 3322 293b 0000000090563"); │ │ │ +000630f0: 0a09 0972 6574 7572 6e20 7072 696d 653b ...return prime; │ │ │ +00063100: 0a09 7d0a 0a09 7374 643a 3a61 7272 6179 ..}...std::array │ │ │ +00063110: 266c 743b 6368 6172 2c20 3936 2667 743b <char, 96> │ │ │ +00063120: 2064 685f 6b65 795f 6578 6368 616e 6765 dh_key_exchange │ │ │ +00063130: 3a3a 6578 706f 7274 5f6b 6579 286b 6579 ::export_key(key │ │ │ +00063140: 5f74 2063 6f6e 7374 2661 6d70 3b20 6b2 TRUNCATED DUE TO SIZE LIMIT: 10485760 bytes