mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-17 08:18:01 +00:00
eead49beb0
* cargo.toml: transfer existing lints * rpc/interface: lints * rpc/json-rpc: lints * rpc/types: lints * storage/blockchain: lints * rpc/types: fix lints * cargo.toml: fix lint group priority * storage/blockchain: fix lints * fix misc lints * storage/database: fixes * storage/txpool: opt in lints + fixes * types: opt in + fixes * helper: opt in + fixes * types: remove borsh * rpc/interface: fix test * test fixes * database: fix lints * fix lint * tabs -> spaces * blockchain: `config/` -> `config.rs`
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
//! This module contains an enum representing every Monero network: mainnet, testnet, stagenet and functionality
|
|
//! related to that.
|
|
//!
|
|
//! This feels out of place for the helper crate but this is needed through out Cuprate and felt too small to split
|
|
//! into it's own crate.
|
|
//!
|
|
//! `#[no_std]` compatible.
|
|
|
|
const MAINNET_NETWORK_ID: [u8; 16] = [
|
|
0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10,
|
|
];
|
|
const TESTNET_NETWORK_ID: [u8; 16] = [
|
|
0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x11,
|
|
];
|
|
const STAGENET_NETWORK_ID: [u8; 16] = [
|
|
0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12,
|
|
];
|
|
|
|
/// An enum representing every Monero network.
|
|
#[derive(Debug, Clone, Copy, Default)]
|
|
pub enum Network {
|
|
/// Mainnet
|
|
#[default]
|
|
Mainnet,
|
|
/// Testnet
|
|
Testnet,
|
|
/// Stagenet
|
|
Stagenet,
|
|
}
|
|
|
|
impl Network {
|
|
/// Returns the network ID for the current network.
|
|
pub const fn network_id(&self) -> [u8; 16] {
|
|
match self {
|
|
Self::Mainnet => MAINNET_NETWORK_ID,
|
|
Self::Testnet => TESTNET_NETWORK_ID,
|
|
Self::Stagenet => STAGENET_NETWORK_ID,
|
|
}
|
|
}
|
|
}
|