difftreelog
Use tokio instead of future-timer
in: master
3 files changed
node/cli/Cargo.tomldiffbeforeafterboth1################################################################################2# Build Dependencies34[build-dependencies.substrate-build-script-utils]5git = 'https://github.com/paritytech/substrate.git'6branch = 'polkadot-v0.9.18'78################################################################################9# Substrate Dependecies1011[dependencies.codec]12default-features = false13features = ['derive']14package = 'parity-scale-codec'15version = '3.1.2'1617[dependencies.frame-benchmarking]18git = 'https://github.com/paritytech/substrate.git'19branch = 'polkadot-v0.9.18'2021[dependencies.frame-benchmarking-cli]22git = 'https://github.com/paritytech/substrate.git'23branch = 'polkadot-v0.9.18'2425[dependencies.pallet-transaction-payment-rpc]26git = 'https://github.com/paritytech/substrate.git'27branch = 'polkadot-v0.9.18'2829[dependencies.substrate-prometheus-endpoint]30git = 'https://github.com/paritytech/substrate.git'31branch = 'polkadot-v0.9.18'3233[dependencies.sc-basic-authorship]34git = 'https://github.com/paritytech/substrate.git'35branch = 'polkadot-v0.9.18'3637[dependencies.sc-chain-spec]38git = 'https://github.com/paritytech/substrate.git'39branch = 'polkadot-v0.9.18'4041[dependencies.sc-cli]42features = ['wasmtime']43git = 'https://github.com/paritytech/substrate.git'44branch = 'polkadot-v0.9.18'4546[dependencies.sc-client-api]47git = 'https://github.com/paritytech/substrate.git'48branch = 'polkadot-v0.9.18'4950[dependencies.sc-consensus]51git = 'https://github.com/paritytech/substrate.git'52branch = 'polkadot-v0.9.18'5354[dependencies.sc-consensus-aura]55git = 'https://github.com/paritytech/substrate.git'56branch = 'polkadot-v0.9.18'5758[dependencies.sc-executor]59features = ['wasmtime']60git = 'https://github.com/paritytech/substrate.git'61branch = 'polkadot-v0.9.18'6263[dependencies.sc-finality-grandpa]64git = 'https://github.com/paritytech/substrate.git'65branch = 'polkadot-v0.9.18'6667[dependencies.sc-keystore]68git = 'https://github.com/paritytech/substrate.git'69branch = 'polkadot-v0.9.18'7071[dependencies.sc-rpc]72git = 'https://github.com/paritytech/substrate.git'73branch = 'polkadot-v0.9.18'7475[dependencies.sc-rpc-api]76git = 'https://github.com/paritytech/substrate.git'77branch = 'polkadot-v0.9.18'7879[dependencies.sc-service]80features = ['wasmtime']81git = 'https://github.com/paritytech/substrate.git'82branch = 'polkadot-v0.9.18'8384[dependencies.sc-telemetry]85git = 'https://github.com/paritytech/substrate.git'86branch = 'polkadot-v0.9.18'8788[dependencies.sc-transaction-pool]89git = 'https://github.com/paritytech/substrate.git'90branch = 'polkadot-v0.9.18'9192[dependencies.sc-tracing]93git = 'https://github.com/paritytech/substrate.git'94branch = 'polkadot-v0.9.18'9596[dependencies.sp-block-builder]97git = 'https://github.com/paritytech/substrate.git'98branch = 'polkadot-v0.9.18'99100[dependencies.sp-api]101git = 'https://github.com/paritytech/substrate.git'102branch = 'polkadot-v0.9.18'103104[dependencies.sp-blockchain]105git = 'https://github.com/paritytech/substrate.git'106branch = 'polkadot-v0.9.18'107108[dependencies.sp-consensus]109git = 'https://github.com/paritytech/substrate.git'110branch = 'polkadot-v0.9.18'111112[dependencies.sp-consensus-aura]113git = 'https://github.com/paritytech/substrate.git'114branch = 'polkadot-v0.9.18'115116[dependencies.sp-core]117git = 'https://github.com/paritytech/substrate.git'118branch = 'polkadot-v0.9.18'119120[dependencies.sp-finality-grandpa]121git = 'https://github.com/paritytech/substrate.git'122branch = 'polkadot-v0.9.18'123124[dependencies.sp-inherents]125git = 'https://github.com/paritytech/substrate.git'126branch = 'polkadot-v0.9.18'127128[dependencies.sp-keystore]129git = 'https://github.com/paritytech/substrate.git'130branch = 'polkadot-v0.9.18'131132[dependencies.sp-offchain]133git = 'https://github.com/paritytech/substrate.git'134branch = 'polkadot-v0.9.18'135136[dependencies.sp-runtime]137git = 'https://github.com/paritytech/substrate.git'138branch = 'polkadot-v0.9.18'139140[dependencies.sp-session]141git = 'https://github.com/paritytech/substrate.git'142branch = 'polkadot-v0.9.18'143144[dependencies.sp-timestamp]145git = 'https://github.com/paritytech/substrate.git'146branch = 'polkadot-v0.9.18'147148[dependencies.sp-transaction-pool]149git = 'https://github.com/paritytech/substrate.git'150branch = 'polkadot-v0.9.18'151152[dependencies.sp-trie]153git = 'https://github.com/paritytech/substrate.git'154branch = 'polkadot-v0.9.18'155156[dependencies.substrate-frame-rpc-system]157git = 'https://github.com/paritytech/substrate.git'158branch = 'polkadot-v0.9.18'159160[dependencies.sc-network]161git = 'https://github.com/paritytech/substrate.git'162branch = 'polkadot-v0.9.18'163164[dependencies.serde]165features = ['derive']166version = '1.0.130'167168[dependencies.serde_json]169version = '1.0.68'170171[dependencies.sc-consensus-manual-seal]172git = 'https://github.com/paritytech/substrate.git'173branch = 'polkadot-v0.9.18'174175################################################################################176# Cumulus dependencies177178[dependencies.cumulus-client-consensus-aura]179git = 'https://github.com/paritytech/cumulus.git'180branch = 'polkadot-v0.9.18'181182[dependencies.cumulus-client-consensus-common]183git = 'https://github.com/paritytech/cumulus.git'184branch = 'polkadot-v0.9.18'185186[dependencies.cumulus-client-collator]187git = 'https://github.com/paritytech/cumulus.git'188branch = 'polkadot-v0.9.18'189190[dependencies.cumulus-client-cli]191git = 'https://github.com/paritytech/cumulus.git'192branch = 'polkadot-v0.9.18'193194[dependencies.cumulus-client-network]195git = 'https://github.com/paritytech/cumulus.git'196branch = 'polkadot-v0.9.18'197198[dependencies.cumulus-primitives-core]199git = 'https://github.com/paritytech/cumulus.git'200branch = 'polkadot-v0.9.18'201202[dependencies.cumulus-primitives-parachain-inherent]203git = 'https://github.com/paritytech/cumulus.git'204branch = 'polkadot-v0.9.18'205206[dependencies.cumulus-client-service]207git = 'https://github.com/paritytech/cumulus.git'208branch = 'polkadot-v0.9.18'209210[dependencies.cumulus-relay-chain-interface]211git = 'https://github.com/paritytech/cumulus.git'212branch = 'polkadot-v0.9.18'213214[dependencies.cumulus-relay-chain-inprocess-interface]215git = 'https://github.com/paritytech/cumulus.git'216branch = 'polkadot-v0.9.18'217218[dependencies.cumulus-relay-chain-rpc-interface]219git = 'https://github.com/paritytech/cumulus.git'220branch = 'polkadot-v0.9.18'221222################################################################################223# Polkadot dependencies224[dependencies.polkadot-primitives]225git = "https://github.com/paritytech/polkadot"226branch = 'release-v0.9.18'227228[dependencies.polkadot-service]229git = "https://github.com/paritytech/polkadot"230branch = 'release-v0.9.18'231232[dependencies.polkadot-cli]233git = "https://github.com/paritytech/polkadot"234branch = 'release-v0.9.18'235236[dependencies.polkadot-test-service]237git = "https://github.com/paritytech/polkadot"238branch = 'release-v0.9.18'239240[dependencies.polkadot-parachain]241git = "https://github.com/paritytech/polkadot"242branch = 'release-v0.9.18'243244245################################################################################246# Local dependencies247248[dependencies.unique-runtime-common]249default-features = false250path = "../../runtime/common"251252[dependencies.unique-runtime]253path = '../../runtime/unique'254optional = true255256[dependencies.quartz-runtime]257path = '../../runtime/quartz'258optional = true259260[dependencies.opal-runtime]261path = '../../runtime/opal'262263[dependencies.up-data-structs]264path = "../../primitives/data-structs"265default-features = false266267[dependencies.up-rpc]268path = "../../primitives/rpc"269270[dependencies.pallet-transaction-payment-rpc-runtime-api]271git = 'https://github.com/paritytech/substrate.git'272branch = 'polkadot-v0.9.18'273274################################################################################275# Package276277[package]278authors = ['Unique Network <support@uniquenetwork.io>']279build = 'build.rs'280description = 'Unique Node'281edition = '2021'282homepage = 'https://unique.network'283license = 'GPLv3'284name = 'unique-node'285repository = 'https://github.com/UniqueNetwork/unique-chain'286version = '0.9.18'287288[[bin]]289name = 'unique-collator'290path = "src/main.rs"291292[package.metadata.docs.rs]293targets = ['x86_64-unknown-linux-gnu']294295[dependencies]296futures = '0.3.17'297futures-timer = '3.0.2'298log = '0.4.14'299flexi_logger = "0.15.7"300parking_lot = '0.11.2'301clap = "3.1.2"302jsonrpc-core = '18.0.0'303jsonrpc-pubsub = "18.0.0"304305fc-rpc-core = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }306fc-consensus = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }307fc-mapping-sync = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }308fc-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }309fc-db = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }310fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }311pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18" }312313unique-rpc = { default-features = false, path = "../rpc" }314315[features]316default = []317runtime-benchmarks = [318 'unique-runtime/runtime-benchmarks',319 'polkadot-service/runtime-benchmarks',320]node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -35,7 +35,7 @@
use crate::{
chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
cli::{Cli, RelayChainCli, Subcommand},
- service::{new_partial, start_node, start_dev_node, AutosealInterval},
+ service::{new_partial, start_node, start_dev_node},
};
#[cfg(feature = "unique-runtime")]
@@ -405,8 +405,7 @@
if is_dev_service {
info!("Running Dev service");
- let autoseal_interval =
- AutosealInterval::new(Duration::from_millis(cli.idle_autoseal_interval))?;
+ let autoseal_interval = Duration::from_millis(cli.idle_autoseal_interval);
return start_node_using_chain_runtime! {
start_dev_node(config, autoseal_interval).map_err(Into::into)
node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -23,13 +23,12 @@
use std::time::Duration;
use std::pin::Pin;
use fc_rpc_core::types::FeeHistoryCache;
-use futures::Future;
use futures::{
Stream, StreamExt,
stream::select,
task::{Context, Poll},
};
-use futures_timer::Delay;
+use tokio::time::Interval;
use unique_rpc::overrides_handle;
@@ -119,36 +118,23 @@
}
pub struct AutosealInterval {
- duration: Duration,
- delay_handle: Pin<Box<Delay>>,
+ interval: Interval,
}
impl AutosealInterval {
- pub fn new(duration: Duration) -> Result<Self, String> {
- if duration.is_zero() {
- return Err("Invalid autoseal interval: 0 seconds".into());
- }
+ pub fn new(config: &Configuration, interval: Duration) -> Self {
+ let _tokio_runtime = config.tokio_handle.enter();
+ let interval = tokio::time::interval(interval);
- Ok(Self {
- duration,
- delay_handle: Box::pin(Delay::new(duration)),
- })
+ Self { interval }
}
}
impl Stream for AutosealInterval {
- type Item = ();
+ type Item = tokio::time::Instant;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
- match self.delay_handle.as_mut().poll(cx) {
- Poll::Ready(_) => {
- let duration = self.duration;
- self.delay_handle.reset(duration);
-
- Poll::Ready(Some(()))
- }
- Poll::Pending => Poll::Pending,
- }
+ self.interval.poll_tick(cx).map(Some)
}
}
@@ -753,7 +739,7 @@
/// the parachain inherent
pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(
config: Configuration,
- autoseal_interval: AutosealInterval,
+ autoseal_interval: Duration,
) -> sc_service::error::Result<TaskManager>
where
Runtime: RuntimeInstance + Send + Sync + 'static,
@@ -855,7 +841,7 @@
}),
);
- let autoseal_interval = Box::pin(autoseal_interval);
+ let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));
let idle_commands_stream: Box<
dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,
> = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {