Adds --no-validator CLI flag (#3348)

* Implement `is_validator` for offchain-workers

* Introduce `--no-validator` flag

* Don't run babe/grandpa/im-online when `--no-validator` is given

* Fixes compilation

* Bump spec version

* Improve error handling in executor

* Add missing extern function

* Revert making error public

* Remove `--no-validator` CLI
This commit is contained in:
Bastian Köcher
2019-08-09 14:24:18 +02:00
committed by GitHub
parent b4b53cbb6e
commit c824c959d7
18 changed files with 97 additions and 28 deletions
+3 -1
View File
@@ -268,6 +268,7 @@ pub trait OffchainWorker<C: Components> {
>,
pool: &Arc<TransactionPool<C::TransactionPoolApi>>,
network_state: &Arc<dyn NetworkStateInfo + Send + Sync>,
is_validator: bool,
) -> error::Result<Box<dyn Future<Item = (), Error = ()> + Send>>;
}
@@ -284,8 +285,9 @@ impl<C: Components> OffchainWorker<Self> for C where
>,
pool: &Arc<TransactionPool<C::TransactionPoolApi>>,
network_state: &Arc<dyn NetworkStateInfo + Send + Sync>,
is_validator: bool,
) -> error::Result<Box<dyn Future<Item = (), Error = ()> + Send>> {
let future = offchain.on_block_imported(number, pool, network_state.clone())
let future = offchain.on_block_imported(number, pool, network_state.clone(), is_validator)
.map(|()| Ok(()));
Ok(Box::new(Compat::new(future)))
}
+3 -1
View File
@@ -153,7 +153,7 @@ impl<Components: components::Components> Service<Components> {
pub fn new(
mut config: FactoryFullConfiguration<Components::Factory>,
) -> Result<Self, error::Error> {
let (signal, exit) = ::exit_future::signal();
let (signal, exit) = exit_future::signal();
// List of asynchronous tasks to spawn. We collect them, then spawn them all at once.
let (to_spawn_tx, to_spawn_rx) =
@@ -250,6 +250,7 @@ impl<Components: components::Components> Service<Components> {
let offchain = offchain_workers.as_ref().map(Arc::downgrade);
let to_spawn_tx_ = to_spawn_tx.clone();
let network_state_info: Arc<dyn NetworkStateInfo + Send + Sync> = network.clone();
let is_validator = config.roles.is_authority();
let events = client.import_notification_stream()
.map(|v| Ok::<_, ()>(v)).compat()
@@ -270,6 +271,7 @@ impl<Components: components::Components> Service<Components> {
&offchain,
&txpool,
&network_state_info,
is_validator,
).map_err(|e| warn!("Offchain workers error processing new block: {:?}", e))?;
let _ = to_spawn_tx_.unbounded_send(future);
}