Unverified Commit 472d62fd authored by Fedor Sakharov's avatar Fedor Sakharov Committed by GitHub
Browse files

Collator protocol should choose side (#1872)



* Collator protocol should choose side

* Update node/service/src/lib.rs
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
parent 6a42be29
Pipeline #112464 failed with stages
in 20 minutes and 17 seconds
......@@ -295,6 +295,7 @@ fn real_overseer<Spawner, RuntimeClient>(
authority_discovery: AuthorityDiscoveryService,
registry: Option<&Registry>,
spawner: Spawner,
is_collator: IsCollator,
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
......@@ -357,9 +358,15 @@ where
collation_generation: CollationGenerationSubsystem::new(
Metrics::register(registry)?,
),
collator_protocol: CollatorProtocolSubsystem::new(
ProtocolSide::Validator(Metrics::register(registry)?),
),
collator_protocol: {
let side = match is_collator {
IsCollator::Yes(id) => ProtocolSide::Collator(id, Metrics::register(registry)?),
IsCollator::No => ProtocolSide::Validator(Metrics::register(registry)?),
};
CollatorProtocolSubsystem::new(
side,
)
},
network_bridge: NetworkBridgeSubsystem::new(
network_service,
authority_discovery,
......@@ -418,10 +425,10 @@ impl<C> NewFull<C> {
/// Is this node a collator?
#[cfg(feature = "full-node")]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum IsCollator {
/// This node is a collator.
Yes,
Yes(CollatorId),
/// This node is not a collator.
No,
}
......@@ -430,7 +437,7 @@ pub enum IsCollator {
impl IsCollator {
/// Is this a collator?
fn is_collator(&self) -> bool {
*self == Self::Yes
matches!(self, Self::Yes(_))
}
}
......@@ -573,6 +580,7 @@ pub fn new_full<RuntimeApi, Executor>(
authority_discovery_service,
prometheus_registry.as_ref(),
spawner,
is_collator,
)?;
let overseer_handler_clone = overseer_handler.clone();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment