remove on_exit from grandpa (#5098)

This commit is contained in:
Gavin Wood
2020-03-05 13:38:16 +01:00
committed by GitHub
parent 91b44299d8
commit ab58a08a53
5 changed files with 7 additions and 30 deletions
@@ -154,7 +154,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
link: grandpa_link,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry()
-1
View File
@@ -225,7 +225,6 @@ macro_rules! new_full {
link: grandpa_link,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry(),
+4 -8
View File
@@ -536,7 +536,7 @@ fn register_finality_tracker_inherent_data_provider<Block: BlockT, Client>(
}
/// Parameters used to run Grandpa.
pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {
pub struct GrandpaParams<Block: BlockT, C, N, SC, VR> {
/// Configuration for the GRANDPA service.
pub config: Config,
/// A link to the block import worker.
@@ -545,8 +545,6 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {
pub network: N,
/// The inherent data providers.
pub inherent_data_providers: InherentDataProviders,
/// Handle to a future that will resolve on exit.
pub on_exit: X,
/// If supplied, can be used to hook on telemetry connection established events.
pub telemetry_on_connect: Option<futures::channel::mpsc::UnboundedReceiver<()>>,
/// A voting rule used to potentially restrict target votes.
@@ -557,8 +555,8 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR, X> {
/// Run a GRANDPA voter as a task. Provide configuration and a link to a
/// block import worker that has already been instantiated with `block_import`.
pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
grandpa_params: GrandpaParams<Block, C, N, SC, VR, X>,
pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR>(
grandpa_params: GrandpaParams<Block, C, N, SC, VR>,
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static> where
Block::Hash: Ord,
BE: Backend<Block> + 'static,
@@ -567,7 +565,6 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
VR: VotingRule<Block, C> + Clone + 'static,
NumberFor<Block>: BlockNumberOps,
DigestFor<Block>: Encode,
X: futures::Future<Output=()> + Clone + Send + Unpin + 'static,
C: ClientForGrandpa<Block, BE> + 'static,
{
let GrandpaParams {
@@ -575,7 +572,6 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
link,
network,
inherent_data_providers,
on_exit,
telemetry_on_connect,
voting_rule,
prometheus_registry,
@@ -647,7 +643,7 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR, X>(
let telemetry_task = telemetry_task
.then(|_| future::pending::<()>());
Ok(future::select(future::select(voter_work, on_exit), telemetry_task).map(drop))
Ok(future::select(voter_work, telemetry_task).map(drop))
}
/// Future that powers the voter.
@@ -159,8 +159,8 @@ pub fn run_grandpa_observer<BE, Block: BlockT, Client, N, SC>(
config: Config,
link: LinkHalf<Block, Client, SC>,
network: N,
on_exit: impl futures::Future<Output=()> + Clone + Send + Unpin + 'static,
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static> where
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static>
where
BE: Backend<Block> + Unpin + 'static,
N: NetworkT<Block> + Send + Clone + 'static,
SC: SelectChain<Block> + 'static,
@@ -194,7 +194,7 @@ pub fn run_grandpa_observer<BE, Block: BlockT, Client, N, SC>(
warn!("GRANDPA Observer failed: {:?}", e);
});
Ok(future::select(observer_work, on_exit).map(drop))
Ok(observer_work.map(drop))
}
/// Future that powers the observer.
@@ -190,17 +190,6 @@ impl TestNetFactory for GrandpaTestNet {
}
}
#[derive(Clone)]
struct Exit;
impl futures::Future for Exit {
type Output = ();
fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> {
task::Poll::Pending
}
}
#[derive(Default, Clone)]
pub(crate) struct TestApi {
genesis_authorities: AuthorityList,
@@ -444,7 +433,6 @@ fn run_to_completion_with<F>(
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
@@ -576,7 +564,6 @@ fn finalize_3_voters_1_full_observer() {
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
@@ -740,7 +727,6 @@ fn transition_3_voters_twice_1_full_observer() {
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
@@ -1166,7 +1152,6 @@ fn voter_persists_its_votes() {
link,
network: this.net.lock().peers[0].network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: VotingRulesBuilder::default().build(),
prometheus_registry: None,
@@ -1382,7 +1367,6 @@ fn finalize_3_voters_1_light_observer() {
},
link,
net.lock().peers[3].network_service().clone(),
Exit,
).unwrap()
);
@@ -1512,7 +1496,6 @@ fn voter_catches_up_to_latest_round_when_behind() {
link,
network: net.lock().peer(peer_id).network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
on_exit: Exit,
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,