Enum zebra_chain::parameters::NetworkUpgrade
source · pub enum NetworkUpgrade {
Genesis,
BeforeOverwinter,
Overwinter,
Sapling,
Blossom,
Heartwood,
Canopy,
Nu5,
}Expand description
A Zcash network upgrade.
Network upgrades can change the Zcash network protocol or consensus rules in incompatible ways.
Variants§
Genesis
The Zcash protocol for a Genesis block.
Zcash genesis blocks use a different set of consensus rules from other BeforeOverwinter blocks, so we treat them like a separate network upgrade.
BeforeOverwinter
The Zcash protocol before the Overwinter upgrade.
We avoid using Sprout, because the specification says that Sprout
is the name of the pre-Sapling protocol, before and after Overwinter.
Overwinter
The Zcash protocol after the Overwinter upgrade.
Sapling
The Zcash protocol after the Sapling upgrade.
Blossom
The Zcash protocol after the Blossom upgrade.
Heartwood
The Zcash protocol after the Heartwood upgrade.
Canopy
The Zcash protocol after the Canopy upgrade.
Nu5
The Zcash protocol after the Nu5 upgrade.
Note: Network Upgrade 5 includes the Orchard Shielded Protocol, non-malleable transaction IDs, and other changes. There is no special code name for Nu5.
Implementations§
source§impl NetworkUpgrade
impl NetworkUpgrade
sourcepub fn activation_list(network: Network) -> BTreeMap<Height, NetworkUpgrade>
pub fn activation_list(network: Network) -> BTreeMap<Height, NetworkUpgrade>
Returns a map between activation heights and network upgrades for network,
in ascending height order.
If the activation height of a future upgrade is not known, that network upgrade does not appear in the list.
This is actually a bijective map.
When the environment variable TEST_FAKE_ACTIVATION_HEIGHTS is set and it’s a test build, this returns a list of fake activation heights used by some tests.
sourcepub fn current(network: Network, height: Height) -> NetworkUpgrade
pub fn current(network: Network, height: Height) -> NetworkUpgrade
Returns the current network upgrade for network and height.
sourcepub fn next(network: Network, height: Height) -> Option<NetworkUpgrade>
pub fn next(network: Network, height: Height) -> Option<NetworkUpgrade>
Returns the next network upgrade for network and height.
Returns None if the next upgrade has not been implemented in Zebra yet.
sourcepub fn activation_height(&self, network: Network) -> Option<Height>
pub fn activation_height(&self, network: Network) -> Option<Height>
Returns the activation height for this network upgrade on network.
Returns None if this network upgrade is a future upgrade, and its activation height has not been set yet.
sourcepub fn is_activation_height(network: Network, height: Height) -> bool
pub fn is_activation_height(network: Network, height: Height) -> bool
Returns true if height is the activation height of any network upgrade
on network.
Use NetworkUpgrade::activation_height to get the specific network
upgrade.
sourcepub fn branch_id(&self) -> Option<ConsensusBranchId>
pub fn branch_id(&self) -> Option<ConsensusBranchId>
Returns the consensus branch id for this network upgrade.
Returns None if this network upgrade has no consensus branch id.
sourcepub fn target_spacing(&self) -> Duration
pub fn target_spacing(&self) -> Duration
Returns the target block spacing for the network upgrade.
Based on [PRE_BLOSSOM_POW_TARGET_SPACING] and
POST_BLOSSOM_POW_TARGET_SPACING from the Zcash specification.
sourcepub fn target_spacing_for_height(network: Network, height: Height) -> Duration
pub fn target_spacing_for_height(network: Network, height: Height) -> Duration
Returns the target block spacing for network and height.
See NetworkUpgrade::target_spacing for details.
sourcepub fn target_spacings(
network: Network
) -> impl Iterator<Item = (Height, Duration)>
pub fn target_spacings( network: Network ) -> impl Iterator<Item = (Height, Duration)>
Returns all the target block spacings for network and the heights where they start.
sourcepub fn minimum_difficulty_spacing_for_height(
network: Network,
height: Height
) -> Option<Duration>
pub fn minimum_difficulty_spacing_for_height( network: Network, height: Height ) -> Option<Duration>
Returns the minimum difficulty block spacing for network and height.
Returns None if the testnet minimum difficulty consensus rule is not active.
Based on https://zips.z.cash/zip-0208#minimum-difficulty-blocks-on-the-test-network
sourcepub fn is_testnet_min_difficulty_block(
network: Network,
block_height: Height,
block_time: DateTime<Utc>,
previous_block_time: DateTime<Utc>
) -> bool
pub fn is_testnet_min_difficulty_block( network: Network, block_height: Height, block_time: DateTime<Utc>, previous_block_time: DateTime<Utc> ) -> bool
Returns true if the gap between block_time and previous_block_time is
greater than the Testnet minimum difficulty time gap. This time gap
depends on the network and block_height.
Returns false on Mainnet, when block_height is less than the minimum
difficulty start height, and when the time gap is too small.
block_time can be less than, equal to, or greater than
previous_block_time, because block times are provided by miners.
Implements the Testnet minimum difficulty adjustment from ZIPs 205 and 208.
Spec Note: Some parts of ZIPs 205 and 208 previously specified an incorrect check for the time gap. This function implements the correct “greater than” check.
sourcepub fn averaging_window_timespan(&self) -> Duration
pub fn averaging_window_timespan(&self) -> Duration
Returns the averaging window timespan for the network upgrade.
AveragingWindowTimespan from the Zcash specification.
sourcepub fn averaging_window_timespan_for_height(
network: Network,
height: Height
) -> Duration
pub fn averaging_window_timespan_for_height( network: Network, height: Height ) -> Duration
Returns the averaging window timespan for network and height.
See NetworkUpgrade::averaging_window_timespan for details.
sourcepub fn is_max_block_time_enforced(network: Network, height: Height) -> bool
pub fn is_max_block_time_enforced(network: Network, height: Height) -> bool
Returns true if the maximum block time rule is active for network and height.
Always returns true if network is the Mainnet.
If network is the Testnet, the height should be at least
TESTNET_MAX_TIME_START_HEIGHT to return true.
Returns false otherwise.
Part of the consensus rules at https://zips.z.cash/protocol/protocol.pdf#blockheader
sourcepub fn from_branch_id(branch_id: u32) -> Option<NetworkUpgrade>
pub fn from_branch_id(branch_id: u32) -> Option<NetworkUpgrade>
Returns the NetworkUpgrade given an u32 as ConsensusBranchId
Trait Implementations§
source§impl Clone for NetworkUpgrade
impl Clone for NetworkUpgrade
source§fn clone(&self) -> NetworkUpgrade
fn clone(&self) -> NetworkUpgrade
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for NetworkUpgrade
impl Debug for NetworkUpgrade
source§impl<'de> Deserialize<'de> for NetworkUpgrade
impl<'de> Deserialize<'de> for NetworkUpgrade
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for NetworkUpgrade
impl Display for NetworkUpgrade
source§impl Hash for NetworkUpgrade
impl Hash for NetworkUpgrade
source§impl PartialEq for NetworkUpgrade
impl PartialEq for NetworkUpgrade
source§fn eq(&self, other: &NetworkUpgrade) -> bool
fn eq(&self, other: &NetworkUpgrade) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for NetworkUpgrade
impl Serialize for NetworkUpgrade
impl Copy for NetworkUpgrade
impl Eq for NetworkUpgrade
impl StructuralPartialEq for NetworkUpgrade
Auto Trait Implementations§
impl RefUnwindSafe for NetworkUpgrade
impl Send for NetworkUpgrade
impl Sync for NetworkUpgrade
impl Unpin for NetworkUpgrade
impl UnwindSafe for NetworkUpgrade
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.