Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,45 @@ impl Parameters for TestNetwork {
}
}

/// The enumeration of known Zcash networks.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
/// Marker struct for the regtest network.
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct RegtestNetwork;

memuse::impl_no_dynamic_usage!(RegtestNetwork);

pub const REGTEST_NETWORK: RegtestNetwork = RegtestNetwork;

impl Parameters for RegtestNetwork {
fn network_type(&self) -> NetworkType {
NetworkType::Regtest
}

fn activation_height(&self, nu: NetworkUpgrade) -> Option<BlockHeight> {
match nu {
NetworkUpgrade::Overwinter => Some(BlockHeight(1)),
NetworkUpgrade::Sapling => Some(BlockHeight(1)),
NetworkUpgrade::Blossom => Some(BlockHeight(1)),
NetworkUpgrade::Heartwood => Some(BlockHeight(1)),
NetworkUpgrade::Canopy => Some(BlockHeight(1)),
NetworkUpgrade::Nu5 => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(1)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
}
}

#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
pub enum Network {
/// Zcash Mainnet.
MainNetwork,
/// Zcash Testnet.
TestNetwork,
/// Zcash Regtest.
RegtestNetwork,
}

memuse::impl_no_dynamic_usage!(Network);
Expand All @@ -412,13 +444,15 @@ impl Parameters for Network {
match self {
Network::MainNetwork => NetworkType::Main,
Network::TestNetwork => NetworkType::Test,
Network::RegtestNetwork => NetworkType::Regtest,
}
}

fn activation_height(&self, nu: NetworkUpgrade) -> Option<BlockHeight> {
match self {
Network::MainNetwork => MAIN_NETWORK.activation_height(nu),
Network::TestNetwork => TEST_NETWORK.activation_height(nu),
Network::RegtestNetwork => REGTEST_NETWORK.activation_height(nu),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions zcash_primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ pub mod testing {
#[cfg(zcash_unstable = "zfuture")]
use super::components::tze::testing::{self as tze};

#[cfg(not(zcash_unstable = "zfuture"))]
use crate::transaction::components::issuance;

pub fn arb_txid() -> impl Strategy<Value = TxId> {
Expand Down