fix more clippy warnings

This commit is contained in:
Joakim Frostegård 2020-08-02 00:36:56 +02:00
parent aabdf76a5d
commit 561cc3db55
16 changed files with 83 additions and 106 deletions

View file

@ -172,7 +172,7 @@ fn process_response(
pareto,
info_hashes,
r.connection_id
).to_owned()
)
});
let new_transaction_id = generate_transaction_id(rng);
@ -191,22 +191,22 @@ fn process_response(
},
Response::Announce(r) => {
return if_torrent_peer_move_and_create_random_request(
if_torrent_peer_move_and_create_random_request(
config,
rng,
info_hashes,
torrent_peers,
r.transaction_id
);
)
},
Response::Scrape(r) => {
return if_torrent_peer_move_and_create_random_request(
if_torrent_peer_move_and_create_random_request(
config,
rng,
info_hashes,
torrent_peers,
r.transaction_id
);
)
},
Response::Error(r) => {
if !r.message.to_lowercase().contains("connection"){

View file

@ -122,7 +122,7 @@ fn run(config: Config) -> ::anyhow::Result<()> {
generate_transaction_id(&mut thread_rng())
);
sender.send(request.into())
sender.send(request)
.expect("bootstrap: add initial request to request queue");
}

View file

@ -40,7 +40,7 @@ pub fn create_socket(
}
socket.bind(&addr.into())
.expect(&format!("socket: bind to {}", addr));
.unwrap_or_else(|err| panic!("socket: bind to {}: {:?}", addr, err));
socket.connect(&config.server_address.into())
.expect("socket: connect to server");
@ -80,28 +80,27 @@ pub fn run_socket_thread(
.expect("failed polling");
for event in events.iter(){
if event.token() == token {
if event.is_readable(){
read_responses(
thread_id,
&socket,
&mut buffer,
&mut local_state,
&mut responses
);
if (event.token() == token) & event.is_readable(){
read_responses(
thread_id,
&socket,
&mut buffer,
&mut local_state,
&mut responses
);
for r in responses.drain(..){
response_channel_sender.send(r)
.expect(&format!(
"add response to channel in socket worker {}",
thread_id.0
));
}
poll.registry()
.reregister(&mut socket, token, interests)
.unwrap();
for r in responses.drain(..){
response_channel_sender.send(r)
.unwrap_or_else(|err| panic!(
"add response to channel in socket worker {}: {:?}",
thread_id.0,
err
));
}
poll.registry()
.reregister(&mut socket, token, interests)
.unwrap();
}
send_requests(