#[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§
Source§impl HardFork
impl HardFork
Sourcepub 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());
}Sourcepub 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));
}Sourcepub fn from_block_header(
header: &BlockHeader,
) -> Result<(HardFork, HardFork), HardForkError>
pub fn from_block_header( header: &BlockHeader, ) -> Result<(HardFork, HardFork), HardForkError>
Sourcepub 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);
}Sourcepub 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
Sourcepub 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§
Source§impl Arbitrary for HardFork
impl Arbitrary for HardFork
Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§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.Source§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
Source§impl<'de> Deserialize<'de> for HardFork
impl<'de> Deserialize<'de> for HardFork
Source§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>,
Source§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) -> Result<HardFork, Error>where
B: Buf,
fn write<B>(self, w: &mut B) -> Result<(), Error>where
B: BufMut,
fn should_write(&self) -> bool
Source§fn epee_default_value() -> Option<Self>
fn epee_default_value() -> Option<Self>
impl Eq for HardFork
Source§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,
Source§impl PartialOrd for HardFork
impl PartialOrd for HardFork
Source§impl Serialize for HardFork
impl Serialize for HardFork
Source§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