Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Use sc_network::protocol_name::standard_protocol_name() for BEEFY and…
Browse files Browse the repository at this point in the history
… GRANDPA
  • Loading branch information
dmitry-markin committed Jul 29, 2022
1 parent 4c1be8c commit 29aa556
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub use beefy_protocol_name::standard_name as protocol_standard_name;

pub(crate) mod beefy_protocol_name {
use sc_chain_spec::ChainSpec;
use sc_network::protocol_name::standard_protocol_name;

const NAME: &str = "/beefy/1";
/// Old names for the notifications protocol, used for backward compatibility.
Expand All @@ -62,11 +63,7 @@ pub(crate) mod beefy_protocol_name {
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!("/{}/{}", hex::encode(genesis_hash), fork_id),
None => format!("/{}", hex::encode(genesis_hash)),
};
format!("{}{}", chain_prefix, NAME).into()
standard_protocol_name(genesis_hash, &chain_spec.fork_id().map(ToOwned::to_owned), NAME)
}
}

Expand Down
7 changes: 2 additions & 5 deletions client/finality-grandpa/src/communication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub(crate) mod tests;

pub mod grandpa_protocol_name {
use sc_chain_spec::ChainSpec;
use sc_network::protocol_name::standard_protocol_name;

pub(crate) const NAME: &str = "/grandpa/1";
/// Old names for the notifications protocol, used for backward compatibility.
Expand All @@ -81,11 +82,7 @@ pub mod grandpa_protocol_name {
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!("/{}/{}", hex::encode(genesis_hash), fork_id),
None => format!("/{}", hex::encode(genesis_hash)),
};
format!("{}{}", chain_prefix, NAME).into()
standard_protocol_name(genesis_hash, &chain_spec.fork_id().map(ToOwned::to_owned), NAME)
}
}

Expand Down

0 comments on commit 29aa556

Please sign in to comment.