too much time taken to add a torrent
Hey,
It takes around 35 seconds to add a torrent. anything. I can fix on the options ?
` let t1 = chrono::Utc::now().timestamp();
let options = AddTorrentOptions {
paused: true,
only_files_regex: None,
only_files: None,
overwrite: true,
list_only: true,
output_folder: None,
sub_folder: None,
peer_opts: None,
force_tracker_interval: None,
disable_trackers: false,
ratelimits: LimitsConfig::default(),
initial_peers: None,
preferred_id: None,
storage_factory: None,
defer_writes: None,
trackers: None
};
let managed_torrent_handle = tsession.add_torrent(
AddTorrent::from_url("magnet?somenastytorrenthere"),
Some(options)
).await.unwrap();
let t2 = chrono::Utc::now().timestamp();
println!("Time taken: {}", t2 - t1);`
It's just the time to resolve the magnet through DHT/trackers. It's as slow as finding + connecting to peers of particular torrent is. It may even hang forever if there's no peers.
What's the issue with it though? Can you design your usage around it? E.g. just tokio::spawn(async {...add_torrent()}) or smth.
There's an unfinished branch with "deferred" flag where adding the torrent is instant btw. The only difference is that it let's you have a TorrentHandle before the torrent is resolved. But I'm not sure if this would resolve your confusion
What you can do to speed this up:
- enable DHT
- pass a hard-coded list of trackers, e.g. https://github.com/ngosang/trackerslist
- enable uTP listen