mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
* service: don't use the grandpa observer * service: remove unnecessary boxing * service: fix indentation * service: remove unnecessary on_exit tasks spawned with `spawn_task`/`spawn_essential_task` are already guarded by `on_exit`. * Update service/src/lib.rs Co-Authored-By: Gavin Wood <gavin@parity.io>
This commit is contained in:
+17
-19
@@ -27,7 +27,6 @@ use polkadot_runtime::GenesisConfig;
|
|||||||
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
||||||
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
|
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
|
||||||
use transaction_pool::txpool::{Pool as TransactionPool};
|
use transaction_pool::txpool::{Pool as TransactionPool};
|
||||||
use babe::{import_queue, start_babe};
|
|
||||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||||
use inherents::InherentDataProviders;
|
use inherents::InherentDataProviders;
|
||||||
use log::info;
|
use log::info;
|
||||||
@@ -261,30 +260,32 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
babe_link,
|
babe_link,
|
||||||
};
|
};
|
||||||
|
|
||||||
let babe = start_babe(babe_config)?;
|
let babe = babe::start_babe(babe_config)?;
|
||||||
service.spawn_essential_task(babe);
|
service.spawn_essential_task(babe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let keystore = if is_authority {
|
||||||
|
Some(service.keystore())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let config = grandpa::Config {
|
let config = grandpa::Config {
|
||||||
// FIXME substrate#1578 make this available through chainspec
|
// FIXME substrate#1578 make this available through chainspec
|
||||||
gossip_duration: Duration::from_millis(333),
|
gossip_duration: Duration::from_millis(333),
|
||||||
justification_period: 512,
|
justification_period: 512,
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
keystore: Some(service.keystore()),
|
keystore,
|
||||||
};
|
};
|
||||||
|
|
||||||
match (is_authority, disable_grandpa) {
|
let enable_grandpa = !disable_grandpa;
|
||||||
(false, false) => {
|
if enable_grandpa {
|
||||||
// start the lightweight GRANDPA observer
|
|
||||||
service.spawn_task(grandpa::run_grandpa_observer(
|
|
||||||
config,
|
|
||||||
link_half,
|
|
||||||
service.network(),
|
|
||||||
service.on_exit(),
|
|
||||||
)?);
|
|
||||||
},
|
|
||||||
(true, false) => {
|
|
||||||
// start the full GRANDPA voter
|
// start the full GRANDPA voter
|
||||||
|
// NOTE: unlike in substrate we are currently running the full
|
||||||
|
// GRANDPA voter protocol for all full nodes (regardless of whether
|
||||||
|
// they're validators or not). at this point the full voter should
|
||||||
|
// provide better guarantees of block and vote data availability than
|
||||||
|
// the observer.
|
||||||
let grandpa_config = grandpa::GrandpaParams {
|
let grandpa_config = grandpa::GrandpaParams {
|
||||||
config: config,
|
config: config,
|
||||||
link: link_half,
|
link: link_half,
|
||||||
@@ -295,14 +296,12 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
voting_rule: grandpa::VotingRulesBuilder::default().build(),
|
voting_rule: grandpa::VotingRulesBuilder::default().build(),
|
||||||
};
|
};
|
||||||
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
|
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
|
||||||
},
|
} else {
|
||||||
(_, true) => {
|
|
||||||
grandpa::setup_disabled_grandpa(
|
grandpa::setup_disabled_grandpa(
|
||||||
service.client(),
|
service.client(),
|
||||||
&inherent_data_providers,
|
&inherent_data_providers,
|
||||||
service.network(),
|
service.network(),
|
||||||
)?;
|
)?;
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(service)
|
Ok(service)
|
||||||
@@ -338,7 +337,6 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
let finality_proof_request_builder =
|
let finality_proof_request_builder =
|
||||||
finality_proof_import.create_finality_proof_request_builder();
|
finality_proof_import.create_finality_proof_request_builder();
|
||||||
|
|
||||||
|
|
||||||
let (babe_block_import, babe_link) = babe::block_import(
|
let (babe_block_import, babe_link) = babe::block_import(
|
||||||
babe::Config::get_or_compute(&*client)?,
|
babe::Config::get_or_compute(&*client)?,
|
||||||
grandpa_block_import,
|
grandpa_block_import,
|
||||||
@@ -347,7 +345,7 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
||||||
let import_queue = import_queue(
|
let import_queue = babe::import_queue(
|
||||||
babe_link,
|
babe_link,
|
||||||
babe_block_import,
|
babe_block_import,
|
||||||
None,
|
None,
|
||||||
|
|||||||
Reference in New Issue
Block a user