You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
798 B
30 lines
798 B
3 years ago
|
use libp2p::rendezvous::Namespace;
|
||
|
use std::fmt;
|
||
|
|
||
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
||
|
pub enum XmrBtcNamespace {
|
||
|
Mainnet,
|
||
|
Testnet,
|
||
|
}
|
||
|
|
||
|
const MAINNET: &str = "xmr-btc-swap-mainnet";
|
||
|
const TESTNET: &str = "xmr-btc-swap-testnet";
|
||
|
|
||
|
impl fmt::Display for XmrBtcNamespace {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||
|
match self {
|
||
|
XmrBtcNamespace::Mainnet => write!(f, "{}", MAINNET),
|
||
|
XmrBtcNamespace::Testnet => write!(f, "{}", TESTNET),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<XmrBtcNamespace> for Namespace {
|
||
|
fn from(namespace: XmrBtcNamespace) -> Self {
|
||
|
match namespace {
|
||
|
XmrBtcNamespace::Mainnet => Namespace::from_static(MAINNET),
|
||
|
XmrBtcNamespace::Testnet => Namespace::from_static(TESTNET),
|
||
|
}
|
||
|
}
|
||
|
}
|