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
Constructs a new 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<'a> Arbitrary<'a> for Version
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Version
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read more