Dude this is like production ready!

This commit is contained in:
Igor Katson 2021-06-28 21:06:00 +01:00
parent 34dd074310
commit df282ae9d8
4 changed files with 15 additions and 26 deletions

View file

@ -123,7 +123,7 @@ impl PeerConnection {
WriterRequest::Message(msg) => msg.serialize(&mut buf),
WriterRequest::ReadChunkRequest(chunk) => {
// this whole section is an optimization
buf.resize(PIECE_MESSAGE_DEFAULT_LEN, 0);
let preamble_len = serialize_piece_preamble(&chunk, &mut buf);
let full_len = preamble_len + chunk.size as usize;
buf.resize(full_len, 0);
@ -280,7 +280,7 @@ impl PeerConnection {
// Theoretically, this could be done in the sending code, so that it reads straight into
// the send buffer.
let request = WriterRequest::ReadChunkRequest(chunk_info);
info!("sending to {}: {:?}", peer_handle, &request);
debug!("sending to {}: {:?}", peer_handle, &request);
Ok::<_, anyhow::Error>(tx.send(request).await?)
}

View file

@ -286,6 +286,7 @@ impl TorrentManager {
match this.tracker_one_request(tracker_url.clone()).await {
Ok(interval) => {
event = None;
let interval = 30;
let duration = Duration::from_secs(interval);
debug!(
"sleeping for {:?} after calling tracker {}",
@ -295,7 +296,7 @@ impl TorrentManager {
tokio::time::sleep(duration).await;
}
Err(e) => {
error!("error calling the tracker {}: {:#}", tracker_url, e);
debug!("error calling the tracker {}: {:#}", tracker_url, e);
tokio::time::sleep(Duration::from_secs(60)).await;
}
};