Applies suggestions from code review

This commit is contained in:
Arya 2024-04-01 20:17:33 -04:00
parent cb8726b38a
commit d5a807a508
3 changed files with 11 additions and 15 deletions

View File

@ -78,7 +78,8 @@ pub enum NetworkKind {
/// A test network.
Testnet,
/// Regtest mode
/// Regtest mode, not yet implemented
// TODO: Add `new_regtest()` and `is_regtest` methods on `Network`.
Regtest,
}

View File

@ -51,6 +51,7 @@ impl TryFrom<zcash_address::Network> for Network {
match network {
zcash_address::Network::Main => Ok(Network::Mainnet),
zcash_address::Network::Test => Ok(Network::new_default_testnet()),
// TODO: Add conversion to regtest (#7839)
zcash_address::Network::Regtest => Err("unsupported Zcash network parameters".into()),
}
}

View File

@ -343,11 +343,14 @@ impl TryFrom<&Network> for zcash_primitives::consensus::Network {
fn try_from(network: &Network) -> Result<Self, Self::Error> {
match network {
Network::Mainnet => Ok(zcash_primitives::consensus::Network::MainNetwork),
// Note: There are differences between the `TestNetwork` parameters and those returned by
// `CRegTestParams()` in zcashd, so this function can't return `TestNetwork` unless
// Zebra is using the default public Testnet.
// TODO: Try to remove this conversion, if possible, by implementing `zcash_primitives::consensus::Parameters`
// on `Network` (#8365).
// # Correctness:
//
// There are differences between the `TestNetwork` parameters and those returned by
// `CRegTestParams()` in zcashd, so this function can't return `TestNetwork` unless
// Zebra is using the default public Testnet.
//
// TODO: Remove this conversion by implementing `zcash_primitives::consensus::Parameters`
// for `Network` (#8365).
Network::Testnet(_params) if network.is_default_testnet() => {
Ok(zcash_primitives::consensus::Network::TestNetwork)
}
@ -369,12 +372,3 @@ impl From<NetworkKind> for zcash_primitives::consensus::Network {
}
}
}
impl From<zcash_primitives::consensus::Network> for Network {
fn from(network: zcash_primitives::consensus::Network) -> Self {
match network {
zcash_primitives::consensus::Network::MainNetwork => Network::Mainnet,
zcash_primitives::consensus::Network::TestNetwork => Network::new_default_testnet(),
}
}
}