Can decode extended messages now

This commit is contained in:
Igor Katson 2021-07-02 01:38:07 +01:00
parent 5f60f9e1b4
commit e666f063ff
7 changed files with 248 additions and 23 deletions

View file

@ -21,6 +21,7 @@ use crate::{
file_ops::FileOps,
http_api::make_and_run_http_api,
lengths::Lengths,
peer_id::generate_peer_id,
spawn_utils::{spawn, BlockingSpawner},
speed_estimator::SpeedEstimator,
torrent_metainfo::TorrentMetaV1Owned,
@ -104,13 +105,6 @@ struct TorrentManager {
force_tracker_interval: Option<Duration>,
}
fn generate_peer_id() -> [u8; 20] {
let mut peer_id = [0u8; 20];
let u = uuid::Uuid::new_v4();
(&mut peer_id[..16]).copy_from_slice(&u.as_bytes()[..]);
peer_id
}
fn make_lengths(torrent: &TorrentMetaV1Owned) -> anyhow::Result<Lengths> {
let total_length = torrent.info.iter_file_lengths().sum();
Lengths::new(total_length, torrent.info.piece_length, None)