mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-27 08:29:38 -05:00
ec4234fbb9
This simplifies the CLI's interface.
16 lines
385 B
Rust
16 lines
385 B
Rust
use libp2p::multiaddr::Protocol;
|
|
use libp2p::{Multiaddr, PeerId};
|
|
|
|
pub trait MultiAddrExt {
|
|
fn extract_peer_id(&self) -> Option<PeerId>;
|
|
}
|
|
|
|
impl MultiAddrExt for Multiaddr {
|
|
fn extract_peer_id(&self) -> Option<PeerId> {
|
|
match self.iter().last()? {
|
|
Protocol::P2p(multihash) => PeerId::from_multihash(multihash).ok(),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|