Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
kill futures01
  • Loading branch information
kigawas committed Oct 29, 2019
commit 2afed11da40c9ac0500e7c5086e309ccb75ec7e1
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ bytes = "0.4.12"
client = { package = "substrate-client", path = "../../core/client" }
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
derive_more = "0.15.0"
futures = "0.1.29"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
libp2p = { version = "0.12.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
log = "0.4.8"
Expand Down
31 changes: 7 additions & 24 deletions core/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ use std::pin::Pin;
use std::sync::Arc;
use std::time::Duration;

use futures::future::Future as Future01;
use futures::sync::mpsc::Receiver as Receiver01;
use futures03::compat::Stream01CompatExt;
use futures03::future::{FutureExt, TryFutureExt};
use futures03::channel::mpsc::Receiver;
use futures03::stream::StreamExt;
use futures03::task::{Context, Poll};
use futures03::{Future, Stream};
use futures03::Future;
use futures_timer::Interval;

use authority_discovery_primitives::{AuthorityDiscoveryApi, AuthorityId, Signature};
Expand Down Expand Up @@ -87,7 +84,7 @@ where

network: Arc<Network>,
/// Channel we receive Dht events on.
dht_event_rx: Pin<Box<dyn Stream<Item = DhtEvent> + Send>>,
dht_event_rx: Receiver<DhtEvent>,

/// Interval to be proactive, publishing own addresses.
publish_interval: Interval,
Expand Down Expand Up @@ -115,7 +112,7 @@ where
pub fn new(
client: Arc<Client>,
network: Arc<Network>,
dht_event_rx: Pin<Box<dyn Stream<Item = DhtEvent> + Send>>,
dht_event_rx: Receiver<DhtEvent>,
) -> Self {
// Kademlia's default time-to-live for Dht records is 36h, republishing records every 24h. Given that a node
// could restart at any point in time, one can not depend on the republishing process, thus publishing own
Expand All @@ -139,20 +136,6 @@ where
}
}

/// Return futures 01 authority discovery
pub fn new_compat(
client: Arc<Client>,
network: Arc<Network>,
dht_event_rx: Receiver01<DhtEvent>,
) -> impl Future01<Item = (), Error = ()> {
// TODO remove this function when we switch to futures 03
let dht_event_rx = dht_event_rx.compat().map(|x| x.unwrap()).boxed();

Self::new(client, network, dht_event_rx)
.map(|x| Ok(x))
.compat()
}

fn publish_own_ext_addresses(&mut self) -> Result<()> {
let id = BlockId::hash(self.client.info().best_hash);

Expand Down Expand Up @@ -624,7 +607,7 @@ mod tests {
let network: Arc<TestNetwork> = Arc::new(Default::default());

let mut authority_discovery =
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx.boxed());
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx);

authority_discovery.publish_own_ext_addresses().unwrap();

Expand All @@ -639,7 +622,7 @@ mod tests {
let network: Arc<TestNetwork> = Arc::new(Default::default());

let mut authority_discovery =
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx.boxed());
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx);

authority_discovery.request_addresses_of_others().unwrap();

Expand All @@ -656,7 +639,7 @@ mod tests {
let network: Arc<TestNetwork> = Arc::new(Default::default());

let mut authority_discovery =
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx.boxed());
AuthorityDiscovery::new(test_api, network.clone(), dht_event_rx);

// Create sample dht event.

Expand Down