2019-11-26 22:42:42 -08:00
|
|
|
use crate::{constants::magics, protocol::external::types::Magic};
|
2019-09-24 11:25:06 -07:00
|
|
|
|
|
|
|
/// An enum describing the possible network choices.
|
2019-10-16 15:16:29 -07:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
2019-09-24 11:25:06 -07:00
|
|
|
pub enum Network {
|
|
|
|
/// The production mainnet.
|
|
|
|
Mainnet,
|
|
|
|
/// The testnet.
|
|
|
|
Testnet,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Network {
|
|
|
|
/// Get the magic value associated to this `Network`.
|
2020-02-04 22:53:24 -08:00
|
|
|
pub fn magic(self) -> Magic {
|
2019-09-24 11:25:06 -07:00
|
|
|
match self {
|
|
|
|
Network::Mainnet => magics::MAINNET,
|
|
|
|
Network::Testnet => magics::TESTNET,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|