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

Commit

Permalink
Add a warning when the user passes a legacy PeerId (#6158)
Browse files Browse the repository at this point in the history
* Add a warning when the user passes a legacy PeerId

* Update client/network/src/config.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
  • Loading branch information
tomaka and bkchr authored May 27, 2020
1 parent 1972b3a commit d5336db
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions client/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,21 @@ pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> {
/// Splits a Multiaddress into a Multiaddress and PeerId.
pub fn parse_addr(mut addr: Multiaddr)-> Result<(PeerId, Multiaddr), ParseErr> {
let who = match addr.pop() {
Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key)
.map_err(|_| ParseErr::InvalidPeerId)?,
Some(multiaddr::Protocol::P2p(key)) => {
if !matches!(key.algorithm(), multiaddr::multihash::Code::Identity) {
// (note: this is the "person bowing" emoji)
log::warn!(
"🙇 You are using the peer ID {}. This peer ID uses a legacy, deprecated \
representation that will no longer be supported in the future. \
Please refresh it by performing a RPC query to the appropriate node, \
by looking at its logs, or by using `subkey inspect-node-key` on its \
private key.",
bs58::encode(key.as_bytes()).into_string()
);
}

PeerId::from_multihash(key).map_err(|_| ParseErr::InvalidPeerId)?
},
_ => return Err(ParseErr::PeerIdMissing),
};

Expand Down

0 comments on commit d5336db

Please sign in to comment.