Rewrite sync and network layers to use futures (#2683)

* Remove background thread from network

* Primarily use tokio-timer instead of tokio

* Minor style fix

* Reintroduce tokio as an optional dependency

* Renames

* Line width

* Ctxt -> Context

* Merge NetworkWorker and NetworkService
This commit is contained in:
Pierre Krieger
2019-05-29 11:58:02 +02:00
committed by Arkadiy Paronyan
parent 643e309411
commit e9a4c80c40
8 changed files with 172 additions and 205 deletions
+4 -4
View File
@@ -80,9 +80,9 @@ const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12);
// Lock must always be taken in order declared here.
pub struct Protocol<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> {
/// Interval at which we call `tick`.
tick_timeout: tokio::timer::Interval,
tick_timeout: tokio_timer::Interval,
/// Interval at which we call `propagate_extrinsics`.
propagate_timeout: tokio::timer::Interval,
propagate_timeout: tokio_timer::Interval,
config: ProtocolConfig,
/// Handler for on-demand requests.
on_demand_core: OnDemandCore<B>,
@@ -395,8 +395,8 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
let info = chain.info()?;
let sync = ChainSync::new(config.roles, &info);
Ok(Protocol {
tick_timeout: tokio::timer::Interval::new_interval(TICK_TIMEOUT),
propagate_timeout: tokio::timer::Interval::new_interval(PROPAGATE_TIMEOUT),
tick_timeout: tokio_timer::Interval::new_interval(TICK_TIMEOUT),
propagate_timeout: tokio_timer::Interval::new_interval(PROPAGATE_TIMEOUT),
config: config,
context_data: ContextData {
peers: HashMap::new(),