Move block announcement protocol config out of Protocol (#12441)

* Move Role(s) to `sc-network-common`

* Introduce `NotificationHandshake` type

* Move block announce protocol config creation to `ChainSync`

* Include block announcement into `notification_protocols`

* Apply review comments

* Remove unneeded include

* Add missing include

* Apply review comments
This commit is contained in:
Aaro Altonen
2022-10-10 10:10:53 +03:00
committed by GitHub
parent 0b77060986
commit ce9ce49bc6
23 changed files with 439 additions and 263 deletions
+4 -25
View File
@@ -23,6 +23,7 @@
pub use sc_network_common::{
config::ProtocolId,
protocol::role::Role,
request_responses::{
IncomingRequest, OutgoingResponse, ProtocolConfig as RequestResponseConfig,
},
@@ -93,6 +94,9 @@ where
/// Registry for recording prometheus metrics to.
pub metrics_registry: Option<Registry>,
/// Block announce protocol configuration
pub block_announce_config: NonDefaultSetConfig,
/// Request response configuration for the block request protocol.
///
/// [`RequestResponseConfig::name`] is used to tag outgoing block requests with the correct
@@ -130,31 +134,6 @@ where
pub request_response_protocol_configs: Vec<RequestResponseConfig>,
}
/// Role of the local node.
#[derive(Debug, Clone)]
pub enum Role {
/// Regular full node.
Full,
/// Actual authority.
Authority,
}
impl Role {
/// True for [`Role::Authority`].
pub fn is_authority(&self) -> bool {
matches!(self, Self::Authority { .. })
}
}
impl fmt::Display for Role {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Full => write!(f, "FULL"),
Self::Authority { .. } => write!(f, "AUTHORITY"),
}
}
}
/// Sync operation mode.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SyncMode {