mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-14 01:05:58 -04:00
Merge --seller-addr
and --seller-peer-id
into --seller
parameter
This simplifies the CLI's interface.
This commit is contained in:
parent
206c98d71b
commit
ec4234fbb9
6 changed files with 121 additions and 95 deletions
15
swap/src/libp2p_ext.rs
Normal file
15
swap/src/libp2p_ext.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
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,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue