mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 04:31:02 +00:00
Name changes for GrandPa and Beefy notifications protocols (#10463)
* grandpa: update notif protocol name * grandpa: add chain id prefix to protocol name * grandpa: beautify protocol name handling * grandpa: prepend genesis hash to protocol name * chain-spec: add optional 'fork_id' 'fork_id' is used to uniquely identify forks of the same chain/network 'ChainSpec' trait provides default 'None' implementation, meaning this chain hasn't been forked. * grandpa: protocol_name mod instead of struct * beefy: add genesis hash prefix to protocol name * chainspec: add fork_id * grandpa: simplify protocol name * grandpa: contain protocol name building logic * beefy: contain protocol name building logic * grandpa: fix tests * fix merge damage * fix docs reference visibility Signed-off-by: acatangiu <adrian@parity.io> * Update client/finality-grandpa/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update client/finality-grandpa/src/communication/mod.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update client/beefy/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update client/beefy/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * avoid using hash default, even for protocol names Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -67,9 +67,27 @@ mod periodic;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests;
|
||||
|
||||
/// Name of the notifications protocol used by Grandpa. Must be registered towards the networking
|
||||
/// in order for Grandpa to properly function.
|
||||
pub const GRANDPA_PROTOCOL_NAME: &'static str = "/paritytech/grandpa/1";
|
||||
pub mod grandpa_protocol_name {
|
||||
use sc_chain_spec::ChainSpec;
|
||||
|
||||
pub(crate) const NAME: &'static str = "/grandpa/1";
|
||||
/// Old names for the notifications protocol, used for backward compatibility.
|
||||
pub(crate) const LEGACY_NAMES: [&'static str; 1] = ["/paritytech/grandpa/1"];
|
||||
|
||||
/// Name of the notifications protocol used by GRANDPA.
|
||||
///
|
||||
/// Must be registered towards the networking in order for GRANDPA to properly function.
|
||||
pub fn standard_name<Hash: std::fmt::Display>(
|
||||
genesis_hash: &Hash,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
) -> std::borrow::Cow<'static, str> {
|
||||
let chain_prefix = match chain_spec.fork_id() {
|
||||
Some(fork_id) => format!("/{}/{}", genesis_hash, fork_id),
|
||||
None => format!("/{}", genesis_hash),
|
||||
};
|
||||
format!("{}{}", chain_prefix, NAME).into()
|
||||
}
|
||||
}
|
||||
|
||||
// cost scalars for reporting peers.
|
||||
mod cost {
|
||||
@@ -220,13 +238,14 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
prometheus_registry: Option<&Registry>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Self {
|
||||
let protocol = config.protocol_name.clone();
|
||||
let (validator, report_stream) =
|
||||
GossipValidator::new(config, set_state.clone(), prometheus_registry, telemetry.clone());
|
||||
|
||||
let validator = Arc::new(validator);
|
||||
let gossip_engine = Arc::new(Mutex::new(GossipEngine::new(
|
||||
service.clone(),
|
||||
GRANDPA_PROTOCOL_NAME,
|
||||
protocol,
|
||||
validator.clone(),
|
||||
prometheus_registry,
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user