Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into hc-add-subscription-rpc-for-finality
  • Loading branch information
octol committed Jul 27, 2020
commit 80d828a91dbc49cd6c5bc5922140d0ba1c34f14b
115 changes: 31 additions & 84 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,89 +156,33 @@ type LightBackend = service::TLightBackendWithHash<Block, sp_runtime::traits::Bl
type LightClient<RuntimeApi, Executor> =
service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;

let (grandpa_block_import, grandpa_link) =
grandpa::block_import_with_authority_set_hard_forks(
client.clone(),
&(client.clone() as Arc<_>),
select_chain,
grandpa_hard_forks,
)?;

let justification_import = grandpa_block_import.clone();

let (block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
)?;

let import_queue = babe::import_queue(
babe_link.clone(),
block_import.clone(),
Some(Box::new(justification_import)),
None,
client,
inherent_data_providers.clone(),
spawn_task_handle,
registry,
)?;

import_setup = Some((block_import, grandpa_link, babe_link));
Ok(import_queue)
})?
.with_rpc_extensions_builder(|builder| {
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");

let justification_receiver = grandpa_link.justification_receiver();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();

rpc_setup = Some((shared_voter_state.clone()));

let babe_link = import_setup.as_ref().map(|s| &s.2)
.expect("BabeLink is present for full services or set up faile; qed.");

let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();

let client = builder.client().clone();
let pool = builder.pool().clone();
let select_chain = builder.select_chain().cloned()
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();

Ok(move |deny_unsafe, subscriptions| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
select_chain: select_chain.clone(),
deny_unsafe,
babe: polkadot_rpc::BabeDeps {
babe_config: babe_config.clone(),
shared_epoch_changes: shared_epoch_changes.clone(),
keystore: keystore.clone(),
},
grandpa: polkadot_rpc::GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_receiver: justification_receiver.clone(),
subscriptions,
},
};

polkadot_rpc::create_full(deps)
})
})?;

(builder, import_setup, inherent_data_providers, rpc_setup)
}}
}

struct CandidateValidationSubsystem;

impl<C> Subsystem<C> for CandidateValidationSubsystem
where C: SubsystemContext<Message = CandidateValidationMessage>
#[cfg(feature = "full-node")]
fn full_params<RuntimeApi, Executor, Extrinsic>(mut config: Configuration) -> Result<(
service::ServiceParams<
Block,
FullClient<RuntimeApi, Executor>,
babe::BabeImportQueue<Block, FullClient<RuntimeApi, Executor>>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>,
polkadot_rpc::RpcExtension,
FullBackend,
>,
FullSelectChain,
(
babe::BabeBlockImport<
Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>
>,
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
babe::BabeLink<Block>
),
inherents::InherentDataProviders,
grandpa::SharedVoterState,
), Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
set_prometheus_registry(&mut config)?;

Expand Down Expand Up @@ -296,6 +240,7 @@ impl<C> Subsystem<C> for CandidateValidationSubsystem
config.prometheus_registry(),
)?;

let justification_receiver = grandpa_link.justification_receiver();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();

Expand All @@ -311,7 +256,7 @@ impl<C> Subsystem<C> for CandidateValidationSubsystem
let transaction_pool = transaction_pool.clone();
let select_chain = select_chain.clone();

Box::new(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
Box::new(move |deny_unsafe, subscriptions| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
Expand All @@ -325,6 +270,8 @@ impl<C> Subsystem<C> for CandidateValidationSubsystem
grandpa: polkadot_rpc::GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_receiver: justification_receiver.clone(),
subscriptions,
},
};

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.