#[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 LATEST: HardFork = _
pub const LATEST: HardFork = _
The latest HardFork
.
assert_eq!(HardFork::LATEST, HardFork::V16);
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>
Returns the HardFork
version and vote from this block header.
§Errors
Will return Err
if the BlockHeader::hardfork_version
is not a valid HardFork
.
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
Source§impl Ord for HardFork
impl Ord for HardFork
Source§impl PartialOrd for HardFork
impl PartialOrd for HardFork
impl Copy for HardFork
impl Eq for HardFork
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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>
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§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