Enum HardFork
#[repr(u8)]pub enum HardFork {
Show 16 variants
V1 = 1,
V2 = 2,
V3 = 3,
V4 = 4,
V5 = 5,
V6 = 6,
V7 = 7,
V8 = 8,
V9 = 9,
V10 = 10,
V11 = 11,
V12 = 12,
V13 = 13,
V14 = 14,
V15 = 15,
V16 = 16,
}Expand description
An identifier for every hard-fork Monero has had.
Variants§
V1 = 1
V2 = 2
V3 = 3
V4 = 4
V5 = 5
V6 = 6
V7 = 7
V8 = 8
V9 = 9
V10 = 10
V11 = 11
V12 = 12
V13 = 13
V14 = 14
V15 = 15
V16 = 16
Implementations§
§impl HardFork
impl HardFork
pub const fn is_v_1(&self) -> bool
pub const fn is_v_1(&self) -> bool
Returns true if the enum is HardFork::V1 otherwise false
pub const fn is_v_2(&self) -> bool
pub const fn is_v_2(&self) -> bool
Returns true if the enum is HardFork::V2 otherwise false
pub const fn is_v_3(&self) -> bool
pub const fn is_v_3(&self) -> bool
Returns true if the enum is HardFork::V3 otherwise false
pub const fn is_v_4(&self) -> bool
pub const fn is_v_4(&self) -> bool
Returns true if the enum is HardFork::V4 otherwise false
pub const fn is_v_5(&self) -> bool
pub const fn is_v_5(&self) -> bool
Returns true if the enum is HardFork::V5 otherwise false
pub const fn is_v_6(&self) -> bool
pub const fn is_v_6(&self) -> bool
Returns true if the enum is HardFork::V6 otherwise false
pub const fn is_v_7(&self) -> bool
pub const fn is_v_7(&self) -> bool
Returns true if the enum is HardFork::V7 otherwise false
pub const fn is_v_8(&self) -> bool
pub const fn is_v_8(&self) -> bool
Returns true if the enum is HardFork::V8 otherwise false
pub const fn is_v_9(&self) -> bool
pub const fn is_v_9(&self) -> bool
Returns true if the enum is HardFork::V9 otherwise false
pub const fn is_v_10(&self) -> bool
pub const fn is_v_10(&self) -> bool
Returns true if the enum is HardFork::V10 otherwise false
pub const fn is_v_11(&self) -> bool
pub const fn is_v_11(&self) -> bool
Returns true if the enum is HardFork::V11 otherwise false
pub const fn is_v_12(&self) -> bool
pub const fn is_v_12(&self) -> bool
Returns true if the enum is HardFork::V12 otherwise false
pub const fn is_v_13(&self) -> bool
pub const fn is_v_13(&self) -> bool
Returns true if the enum is HardFork::V13 otherwise false
pub const fn is_v_14(&self) -> bool
pub const fn is_v_14(&self) -> bool
Returns true if the enum is HardFork::V14 otherwise false
pub const fn is_v_15(&self) -> bool
pub const fn is_v_15(&self) -> bool
Returns true if the enum is HardFork::V15 otherwise false
pub const fn is_v_16(&self) -> bool
pub const fn is_v_16(&self) -> bool
Returns true if the enum is HardFork::V16 otherwise false
§impl HardFork
impl HardFork
pub const fn from_version(version: u8) -> Result<HardFork, HardForkError>
pub const fn from_version(version: u8) -> Result<HardFork, HardForkError>
Returns the hard-fork for a blocks [BlockHeader::hardfork_version] field.
ref: https://monero-book.cuprate.org/consensus_rules/hardforks.html#blocks-version-and-vote
§Errors
Will return Err if the version is not a valid HardFork.
assert_eq!(HardFork::from_version(0), Err(HardForkError::HardForkUnknown));
assert_eq!(HardFork::from_version(17), Err(HardForkError::HardForkUnknown));
for (version, hf) in HardFork::VARIANTS.iter().enumerate() {
// +1 because enumerate starts at 0, hf starts at 1.
assert_eq!(*hf, HardFork::from_version(version as u8 + 1).unwrap());
}pub fn from_vote(vote: u8) -> HardFork
pub fn from_vote(vote: u8) -> HardFork
Returns the hard-fork for a blocks [BlockHeader::hardfork_signal] (vote) field.
https://monero-book.cuprate.org/consensus_rules/hardforks.html#blocks-version-and-vote
// 0 is interpreted as 1.
assert_eq!(HardFork::from_vote(0), HardFork::V1);
// Unknown defaults to `LATEST`.
assert_eq!(HardFork::from_vote(17), HardFork::V16);
for (vote, hf) in HardFork::VARIANTS.iter().enumerate() {
// +1 because enumerate starts at 0, hf starts at 1.
assert_eq!(*hf, HardFork::from_vote(vote as u8 + 1));
}pub fn from_block_header(
header: &BlockHeader,
) -> Result<(HardFork, HardFork), HardForkError>
pub fn from_block_header( header: &BlockHeader, ) -> Result<(HardFork, HardFork), HardForkError>
pub const fn as_u8(self) -> u8
pub const fn as_u8(self) -> u8
Returns the raw hard-fork value, as it would appear in [BlockHeader::hardfork_version].
for (i, hf) in HardFork::VARIANTS.iter().enumerate() {
// +1 because enumerate starts at 0, hf starts at 1.
assert_eq!(hf.as_u8(), i as u8 + 1);
}pub const fn block_time(self) -> Duration
pub const fn block_time(self) -> Duration
Returns the target block time for this hardfork.
ref: https://monero-book.cuprate.org/consensus_rules/blocks/difficulty.html#target-seconds
pub const fn is_latest(self) -> bool
pub const fn is_latest(self) -> bool
Returns true if self is Self::LATEST.
for hf in HardFork::VARIANTS.iter() {
if *hf == HardFork::LATEST {
assert!(hf.is_latest());
} else {
assert!(!hf.is_latest());
}
}Trait Implementations§
§impl Arbitrary for HardFork
impl Arbitrary for HardFork
§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.§type Strategy = TupleUnion<((u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<TupleUnion<((u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>))>>))>
type Strategy = TupleUnion<((u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<TupleUnion<((u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>), (u32, Arc<fn() -> HardFork>))>>))>
Strategy used to generate values of type Self.§fn arbitrary_with(
_top: <HardFork as Arbitrary>::Parameters,
) -> <HardFork as Arbitrary>::Strategy
fn arbitrary_with( _top: <HardFork as Arbitrary>::Parameters, ) -> <HardFork as Arbitrary>::Strategy
impl Copy for HardFork
§impl<'de> Deserialize<'de> for HardFork
impl<'de> Deserialize<'de> for HardFork
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HardFork, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HardFork, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl EpeeValue for HardFork
Available on crate feature epee only.
impl EpeeValue for HardFork
epee only.const MARKER: Marker = u8::MARKER
fn read<B>(
r: &mut B,
marker: &Marker,
limits: EpeeValueLimits,
) -> Result<HardFork, Error>where
B: Buf,
fn write<B>(self, w: &mut B) -> Result<(), Error>where
B: BufMut,
fn should_write(&self) -> bool
§fn epee_default_value() -> Option<Self>
fn epee_default_value() -> Option<Self>
impl Eq for HardFork
§impl Ord for HardFork
impl Ord for HardFork
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialOrd for HardFork
impl PartialOrd for HardFork
§impl Serialize for HardFork
impl Serialize for HardFork
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for HardFork
Auto Trait Implementations§
impl Freeze for HardFork
impl RefUnwindSafe for HardFork
impl Send for HardFork
impl Sync for HardFork
impl Unpin for HardFork
impl UnsafeUnpin for HardFork
impl UnwindSafe for HardFork
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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<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
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
V1: 0 bytesV2: 0 bytesV3: 0 bytesV4: 0 bytesV5: 0 bytesV6: 0 bytesV7: 0 bytesV8: 0 bytesV9: 0 bytesV10: 0 bytesV11: 0 bytesV12: 0 bytesV13: 0 bytesV14: 0 bytesV15: 0 bytesV16: 0 bytes