Add examples

This commit is contained in:
Igor Katson 2023-11-19 22:48:19 +00:00
parent adb98a2d89
commit 2ebbc0a828
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
9 changed files with 541 additions and 30 deletions

View file

@ -251,7 +251,10 @@ impl Session {
torrent_from_file(url)?
};
let dht_rx = match self.dht.as_ref() {
Some(dht) => Some(dht.get_peers(torrent.info_hash).await?),
Some(dht) => {
debug!("reading peers for {:?} from DHT", torrent.info_hash);
Some(dht.get_peers(torrent.info_hash).await?)
}
None => None,
};
let trackers = torrent

View file

@ -38,3 +38,14 @@ impl BlockingSpawner {
f()
}
}
impl Default for BlockingSpawner {
fn default() -> Self {
let allow_block_in_place = match tokio::runtime::Handle::current().runtime_flavor() {
tokio::runtime::RuntimeFlavor::CurrentThread => false,
tokio::runtime::RuntimeFlavor::MultiThread => true,
_ => true,
};
Self::new(allow_block_in_place)
}
}