Upgrade tokio to 1.22.0 and replace async-std with tokio (#12646)

* Replace deprecated libp2p feature specs with correct ones

* Bump tokio to 1.21.2

* Replace async-std libp2p primitives with tokio ones

* minor: rustfmt

* Fix TestNet to run initialization in the tokio context

* Convert telemetry test from async-std to tokio

* Convert notifications tests from async-std to tokio

* Convert chain sync tests from async-std to tokio

* Ditch async-std completely

* Make executor mandatory

* Bump tokio to 1.22.0

* minor: rustfmt

* Explicitly use tokio runtime in tests

* Move more tests to explicit tokio runtime

* Explicitly set multithreaded runtime in tokio test

* minor: rustfmt

* minor: fix comment

* Replace async-std with tokio in MMR tests
This commit is contained in:
Dmitry Markin
2022-12-05 11:18:46 +03:00
committed by GitHub
parent 1943e25cb9
commit 5eb84f9cc6
60 changed files with 747 additions and 634 deletions
+3 -3
View File
@@ -64,7 +64,7 @@ use libp2p::{
GetClosestPeersError, Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent,
QueryId, QueryResult, Quorum, Record,
},
mdns::{Mdns, MdnsConfig, MdnsEvent},
mdns::{MdnsConfig, MdnsEvent, TokioMdns},
multiaddr::Protocol,
swarm::{
behaviour::toggle::{Toggle, ToggleIntoConnectionHandler},
@@ -235,7 +235,7 @@ impl DiscoveryConfig {
allow_private_ipv4,
discovery_only_if_under_num,
mdns: if enable_mdns {
match Mdns::new(MdnsConfig::default()) {
match TokioMdns::new(MdnsConfig::default()) {
Ok(mdns) => Some(mdns),
Err(err) => {
warn!(target: "sub-libp2p", "Failed to initialize mDNS: {:?}", err);
@@ -266,7 +266,7 @@ pub struct DiscoveryBehaviour {
/// it's always enabled in `NetworkWorker::new()`.
kademlia: Toggle<Kademlia<MemoryStore>>,
/// Discovers nodes on the local network.
mdns: Option<Mdns>,
mdns: Option<TokioMdns>,
/// Stream that fires when we need to perform the next random Kademlia query. `None` if
/// random walking is disabled.
next_kad_random_query: Option<Delay>,