@@ -77,13 +77,11 @@ POSSIBILITY OF SUCH DAMAGE.
77
77
78
78
namespace libtorrent {
79
79
80
- namespace mp = boost::multiprecision;
81
-
82
80
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
83
81
namespace {
84
82
85
- std::size_t const handshake_len = 68 ;
86
- std::size_t const dh_key_len = 96 ;
83
+ constexpr std::size_t handshake_len = 68 ;
84
+ constexpr std::size_t dh_key_len = 96 ;
87
85
88
86
// stream key (info hash of attached torrent)
89
87
// secret is the DH shared secret
@@ -135,15 +133,15 @@ namespace {
135
133
if (ep.address ().is_v4 ())
136
134
{
137
135
#endif
138
- peers4_t ::value_type v (ep.address ().to_v4 ().to_bytes (), ep.port ());
139
- auto i = std::lower_bound (m_peers.begin (), m_peers.end (), v);
136
+ peers4_t ::value_type const v (ep.address ().to_v4 ().to_bytes (), ep.port ());
137
+ auto const i = std::lower_bound (m_peers.begin (), m_peers.end (), v);
140
138
return i != m_peers.end () && *i == v;
141
139
#if TORRENT_USE_IPV6
142
140
}
143
141
else
144
142
{
145
- peers6_t ::value_type v (ep.address ().to_v6 ().to_bytes (), ep.port ());
146
- auto i = std::lower_bound (m_peers6.begin (), m_peers6.end (), v);
143
+ peers6_t ::value_type const v (ep.address ().to_v6 ().to_bytes (), ep.port ());
144
+ auto const i = std::lower_bound (m_peers6.begin (), m_peers6.end (), v);
147
145
return i != m_peers6.end () && *i == v;
148
146
}
149
147
#endif
@@ -193,13 +191,13 @@ namespace {
193
191
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
194
192
void bt_peer_connection::switch_send_crypto (std::shared_ptr<crypto_plugin> crypto)
195
193
{
196
- if (m_enc_handler.switch_send_crypto (crypto, send_buffer_size () - get_send_barrier ()))
194
+ if (m_enc_handler.switch_send_crypto (std::move ( crypto) , send_buffer_size () - get_send_barrier ()))
197
195
set_send_barrier (send_buffer_size ());
198
196
}
199
197
200
198
void bt_peer_connection::switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto)
201
199
{
202
- m_enc_handler.switch_recv_crypto (crypto, m_recv_buffer);
200
+ m_enc_handler.switch_recv_crypto (std::move ( crypto) , m_recv_buffer);
203
201
}
204
202
#endif
205
203
@@ -215,7 +213,7 @@ namespace {
215
213
#ifndef TORRENT_DISABLE_LOGGING
216
214
peer_log (peer_log_alert::info, " ON_CONNECTED" , " graceful-paused" );
217
215
#endif
218
- disconnect (error_code ( errors::torrent_paused) , operation_t ::bittorrent);
216
+ disconnect (errors::torrent_paused, operation_t ::bittorrent);
219
217
return ;
220
218
}
221
219
@@ -339,7 +337,7 @@ namespace {
339
337
#endif
340
338
}
341
339
342
- void bt_peer_connection::write_dht_port (int listen_port)
340
+ void bt_peer_connection::write_dht_port (int const listen_port)
343
341
{
344
342
INVARIANT_CHECK;
345
343
@@ -605,7 +603,7 @@ namespace {
605
603
send_buffer ({msg, sizeof (msg) - 512 + pad_size});
606
604
}
607
605
608
- void bt_peer_connection::write_pe4_sync (int crypto_select)
606
+ void bt_peer_connection::write_pe4_sync (int const crypto_select)
609
607
{
610
608
INVARIANT_CHECK;
611
609
@@ -1028,14 +1026,14 @@ namespace {
1028
1026
// ----------- PIECE -----------
1029
1027
// -----------------------------
1030
1028
1031
- void bt_peer_connection::on_piece (int received)
1029
+ void bt_peer_connection::on_piece (int const received)
1032
1030
{
1033
1031
INVARIANT_CHECK;
1034
1032
1035
1033
TORRENT_ASSERT (received >= 0 );
1036
1034
1037
1035
span<char const > recv_buffer = m_recv_buffer.get ();
1038
- int recv_pos = m_recv_buffer.pos (); // recv_buffer.end - recv_buffer.begin;
1036
+ int const recv_pos = m_recv_buffer.pos (); // recv_buffer.end - recv_buffer.begin;
1039
1037
1040
1038
std::shared_ptr<torrent> t = associated_torrent ().lock ();
1041
1039
TORRENT_ASSERT (t);
@@ -1249,7 +1247,7 @@ namespace {
1249
1247
span<char const > recv_buffer = m_recv_buffer.get ();
1250
1248
1251
1249
const char * ptr = recv_buffer.begin () + 1 ;
1252
- int listen_port = detail::read_uint16 (ptr);
1250
+ int const listen_port = detail::read_uint16 (ptr);
1253
1251
1254
1252
incoming_dht_port (listen_port);
1255
1253
@@ -1344,7 +1342,7 @@ namespace {
1344
1342
if (!m_recv_buffer.packet_finished ()) return ;
1345
1343
span<char const > recv_buffer = m_recv_buffer.get ();
1346
1344
const char * ptr = recv_buffer.begin () + 1 ;
1347
- piece_index_t index (detail::read_int32 (ptr));
1345
+ piece_index_t const index (detail::read_int32 (ptr));
1348
1346
1349
1347
incoming_allowed_fast (index );
1350
1348
}
@@ -1597,7 +1595,7 @@ namespace {
1597
1595
TORRENT_ASSERT (recv_buffer.front () == msg_extended);
1598
1596
recv_buffer = recv_buffer.subspan (1 );
1599
1597
1600
- int extended_id = aux::read_uint8 (recv_buffer);
1598
+ int const extended_id = aux::read_uint8 (recv_buffer);
1601
1599
1602
1600
if (extended_id == 0 )
1603
1601
{
@@ -1743,7 +1741,7 @@ namespace {
1743
1741
}
1744
1742
1745
1743
// there is supposed to be a remote listen port
1746
- int listen_port = int (root.dict_find_int_value (" p" ));
1744
+ int const listen_port = int (root.dict_find_int_value (" p" ));
1747
1745
if (listen_port > 0 && peer_info_struct () != nullptr )
1748
1746
{
1749
1747
t->update_peer_port (listen_port, peer_info_struct (), peer_info::incoming);
@@ -1757,10 +1755,10 @@ namespace {
1757
1755
int const last_seen_complete = int (root.dict_find_int_value (" complete_ago" , -1 ));
1758
1756
if (last_seen_complete >= 0 ) set_last_seen_complete (last_seen_complete);
1759
1757
1760
- auto client_info = root.dict_find_string_value (" v" );
1758
+ auto const client_info = root.dict_find_string_value (" v" );
1761
1759
if (!client_info.empty ()) m_client_version = client_info.to_string ();
1762
1760
1763
- int reqq = int (root.dict_find_int_value (" reqq" ));
1761
+ int const reqq = int (root.dict_find_int_value (" reqq" ));
1764
1762
if (reqq > 0 ) max_out_request_queue (reqq);
1765
1763
1766
1764
if (root.dict_find_int_value (" upload_only" , 0 ))
@@ -1770,7 +1768,7 @@ namespace {
1770
1768
&& root.dict_find_int_value (" share_mode" , 0 ))
1771
1769
set_share_mode (true );
1772
1770
1773
- auto myip = root.dict_find_string_value (" yourip" );
1771
+ auto const myip = root.dict_find_string_value (" yourip" );
1774
1772
if (!myip.empty ())
1775
1773
{
1776
1774
if (myip.size () == std::tuple_size<address_v4::bytes_type>::value)
@@ -2080,7 +2078,7 @@ namespace {
2080
2078
2081
2079
// add predictive pieces to the bitfield as well, since we won't
2082
2080
// announce them again
2083
- for (piece_index_t p : t->predictive_pieces ())
2081
+ for (piece_index_t const p : t->predictive_pieces ())
2084
2082
msg[5 + static_cast <int >(p) / 8 ] |= (0x80 >> (static_cast <int >(p) & 7 ));
2085
2083
2086
2084
#ifndef TORRENT_DISABLE_LOGGING
@@ -2255,7 +2253,7 @@ namespace {
2255
2253
send_message (msg_not_interested, counters::num_outgoing_not_interested, 0 );
2256
2254
}
2257
2255
2258
- void bt_peer_connection::write_have (piece_index_t index )
2256
+ void bt_peer_connection::write_have (piece_index_t const index )
2259
2257
{
2260
2258
INVARIANT_CHECK;
2261
2259
TORRENT_ASSERT (associated_torrent ().lock ()->valid_metadata ());
@@ -3325,7 +3323,7 @@ namespace {
3325
3323
int packet_size = detail::read_int32 (ptr);
3326
3324
3327
3325
// don't accept packets larger than 1 MB
3328
- if (packet_size > 1024 * 1024 || packet_size < 0 )
3326
+ if (packet_size > 1024 * 1024 || packet_size < 0 )
3329
3327
{
3330
3328
// packet too large
3331
3329
received_bytes (0 , int (bytes_transferred));
@@ -3409,7 +3407,7 @@ namespace {
3409
3407
// --------------------------
3410
3408
3411
3409
void bt_peer_connection::on_sent (error_code const & error
3412
- , std::size_t bytes_transferred)
3410
+ , std::size_t const bytes_transferred)
3413
3411
{
3414
3412
INVARIANT_CHECK;
3415
3413
0 commit comments