Merge --seller-addr and --seller-peer-id into --seller parameter

This simplifies the CLI's interface.
This commit is contained in:
Thomas Eizinger 2021-07-06 14:39:05 +10:00
parent 206c98d71b
commit ec4234fbb9
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
6 changed files with 121 additions and 95 deletions

15
swap/src/libp2p_ext.rs Normal file
View 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,
}
}
}