From 17f074d4604975bbf08e1f8f314b4290223ba103 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Wed, 17 Jan 2024 18:55:21 -0300 Subject: [PATCH] PR Suggestion by @nuttycom: remove the `FullNodeParameters` enum --- zcash_primitives/CHANGELOG.md | 8 +++----- zcash_primitives/src/local_consensus.rs | 24 +++++------------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/zcash_primitives/CHANGELOG.md b/zcash_primitives/CHANGELOG.md index b76aec282..e196e1ff9 100644 --- a/zcash_primitives/CHANGELOG.md +++ b/zcash_primitives/CHANGELOG.md @@ -56,12 +56,10 @@ and this library adheres to Rust's notion of - `impl From for [u8; 32]` - Added feature `local-consensus` to crate `zcash_primitives` - Adds `pub mod local_consensus` - - `local_consensus::FullNodeParameters` adds functionality to refer to Full Node - parameters that can be either (public) Consensus nodes like `Network::MainNetwork` - or `Network::TestNetwork`, or a `Local(P)` with a set of Parameters `P`. `Regtest` - is considered a `LocalConsensus`. - `zcash_primitives::local_consensus::LocalNetwork` provides a type for specifying - network upgrade activation heights for a given `FullNodeParameters::Local(P)` + network upgrade activation heights for a local or specific configuration of a full + node. Developers can make use of this type when connecting to a Regtest node by + replicating the activation heights used on their node configuration. - `impl Parameters for LocalNetwork` that use provided activation heights and defaults to `constants::regtest::` for everything else. diff --git a/zcash_primitives/src/local_consensus.rs b/zcash_primitives/src/local_consensus.rs index 11776106d..807bb08a6 100644 --- a/zcash_primitives/src/local_consensus.rs +++ b/zcash_primitives/src/local_consensus.rs @@ -1,17 +1,8 @@ use crate::{ - consensus::{BlockHeight, Network, NetworkUpgrade, Parameters}, + consensus::{BlockHeight, NetworkUpgrade, Parameters}, constants, }; -/// Represents the Network Parameters of the Full Node the caller connects to. -pub enum FullNodeParameters { - /// Variant indicating a Zcash Full Node running on public Mainnet or Testnet - Consensus(Network), - /// The consensus parameters of a local or non-public network like one or more nodes - /// in `regtest` mode. - Local(P), -} - /// a `LocalNetwork` setup should define the activation heights /// of network upgrades. `None` is considered as "not activated" /// These heights are not validated. Callers shall initialized @@ -60,15 +51,10 @@ pub struct LocalNetwork { /// Parameters default implementation for `LocalNetwork` /// Important note: -/// The following functions return `constants::regtest` values -/// ``` -/// fn coin_type() -/// fn address_network() -/// fn hrp_sapling_extended_spending_key() -/// fn hrp_sapling_extended_full_viewing_key() -/// fn hrp_sapling_payment_address() -/// fn b58_script_address_prefix() -/// ``` +/// The functions `coin_type()`, `address_network()`, +/// `hrp_sapling_extended_spending_key()`, `hrp_sapling_extended_full_viewing_key()`, +/// `hrp_sapling_payment_address()`, `b58_script_address_prefix()` return +/// `constants::regtest` values impl Parameters for LocalNetwork { fn activation_height(&self, nu: NetworkUpgrade) -> Option { match nu {