mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Pass an executor through the Configuration (#4688)
* Pass an executor through the Configuration * Make tasks_executor mandatory * Fix tests
This commit is contained in:
committed by
Bastian Köcher
parent
b7a63e3b77
commit
169a48c0c5
@@ -19,9 +19,11 @@
|
||||
use std::iter;
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use std::net::Ipv4Addr;
|
||||
use std::pin::Pin;
|
||||
use std::time::Duration;
|
||||
use log::info;
|
||||
use futures01::{Future, Stream, Poll};
|
||||
use futures::{FutureExt as _, TryFutureExt as _};
|
||||
use tempfile::TempDir;
|
||||
use tokio::{runtime::Runtime, prelude::FutureExt};
|
||||
use tokio::timer::Interval;
|
||||
@@ -131,6 +133,7 @@ fn node_config<G, E: Clone> (
|
||||
index: usize,
|
||||
spec: &ChainSpec<G, E>,
|
||||
role: Roles,
|
||||
tasks_executor: Box<dyn Fn(Pin<Box<dyn futures::Future<Output = ()> + Send>>) + Send>,
|
||||
key_seed: Option<String>,
|
||||
base_port: u16,
|
||||
root: &TempDir,
|
||||
@@ -172,6 +175,7 @@ fn node_config<G, E: Clone> (
|
||||
impl_version: "0.1",
|
||||
impl_commit: "",
|
||||
roles: role,
|
||||
tasks_executor: Some(tasks_executor),
|
||||
transaction_pool: Default::default(),
|
||||
network: network_config,
|
||||
keystore: KeystoreConfig::Path {
|
||||
@@ -251,10 +255,15 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
|
||||
let executor = self.runtime.executor();
|
||||
|
||||
for (key, authority) in authorities {
|
||||
let tasks_executor = {
|
||||
let executor = executor.clone();
|
||||
Box::new(move |fut: Pin<Box<dyn futures::Future<Output = ()> + Send>>| executor.spawn(fut.unit_error().compat()))
|
||||
};
|
||||
let node_config = node_config(
|
||||
self.nodes,
|
||||
&self.chain_spec,
|
||||
Roles::AUTHORITY,
|
||||
tasks_executor,
|
||||
Some(key),
|
||||
self.base_port,
|
||||
&temp,
|
||||
@@ -270,7 +279,11 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
|
||||
}
|
||||
|
||||
for full in full {
|
||||
let node_config = node_config(self.nodes, &self.chain_spec, Roles::FULL, None, self.base_port, &temp);
|
||||
let tasks_executor = {
|
||||
let executor = executor.clone();
|
||||
Box::new(move |fut: Pin<Box<dyn futures::Future<Output = ()> + Send>>| executor.spawn(fut.unit_error().compat()))
|
||||
};
|
||||
let node_config = node_config(self.nodes, &self.chain_spec, Roles::FULL, tasks_executor, None, self.base_port, &temp);
|
||||
let addr = node_config.network.listen_addresses.iter().next().unwrap().clone();
|
||||
let (service, user_data) = full(node_config).expect("Error creating test node service");
|
||||
let service = SyncService::from(service);
|
||||
@@ -282,7 +295,11 @@ impl<G, E, F, L, U> TestNet<G, E, F, L, U> where
|
||||
}
|
||||
|
||||
for light in light {
|
||||
let node_config = node_config(self.nodes, &self.chain_spec, Roles::LIGHT, None, self.base_port, &temp);
|
||||
let tasks_executor = {
|
||||
let executor = executor.clone();
|
||||
Box::new(move |fut: Pin<Box<dyn futures::Future<Output = ()> + Send>>| executor.spawn(fut.unit_error().compat()))
|
||||
};
|
||||
let node_config = node_config(self.nodes, &self.chain_spec, Roles::LIGHT, tasks_executor, None, self.base_port, &temp);
|
||||
let addr = node_config.network.listen_addresses.iter().next().unwrap().clone();
|
||||
let service = SyncService::from(light(node_config).expect("Error creating test node service"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user