pub struct Version(/* private fields */);
Expand description
Bitcoin block version number.
Originally used as a protocol version, but repurposed for soft-fork signaling.
The inner value is a signed integer in Bitcoin Core for historical reasons, if version bits is being used the top three bits must be 001, this gives us a useful range of [0x20000000…0x3FFFFFFF].
When a block nVersion does not have top bits 001, it is treated as if all bits are 0 for the purposes of deployments.
§Relevant BIPs
Implementations§
source§impl Version
impl Version
sourcepub const NO_SOFT_FORK_SIGNALLING: Self = _
pub const NO_SOFT_FORK_SIGNALLING: Self = _
BIP-9 compatible version number that does not signal for any softforks.
sourcepub const fn from_consensus(v: i32) -> Self
pub const fn from_consensus(v: i32) -> Self
Creates a Version
from a signed 32 bit integer value.
This is the data type used in consensus code in Bitcoin Core.
sourcepub fn to_consensus(self) -> i32
pub fn to_consensus(self) -> i32
Returns the inner i32
value.
This is the data type used in consensus code in Bitcoin Core.
sourcepub fn is_signalling_soft_fork(&self, bit: u8) -> bool
pub fn is_signalling_soft_fork(&self, bit: u8) -> bool
Checks whether the version number is signalling a soft fork at the given bit.
A block is signalling for a soft fork under BIP-9 if the first 3 bits are 001
and
the version bit for the specific soft fork is toggled on.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Version
impl<'de> Deserialize<'de> for Version
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 Ord for Version
impl Ord for Version
source§impl PartialEq for Version
impl PartialEq for Version
source§impl PartialOrd for Version
impl PartialOrd for Version
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Version
impl Eq for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)