pub struct BlockHeight(pub u32);
alloc
only.Expand description
The block height, zero denotes the genesis block.
This type is not meant for constructing height based timelocks, this is a general purpose block
height abstraction. For locktimes please see [locktime::absolute::Height
].
This is a thin wrapper around a u32
that may take on all values of a u32
.
Tuple Fields§
§0: u32
Implementations§
Source§impl BlockHeight
impl BlockHeight
Sourcepub const ZERO: BlockHeight
pub const ZERO: BlockHeight
Block height 0, the genesis block.
Sourcepub const MIN: BlockHeight = Self::ZERO
pub const MIN: BlockHeight = Self::ZERO
The minimum block height (0), the genesis block.
Sourcepub const MAX: BlockHeight
pub const MAX: BlockHeight
The maximum block height.
Sourcepub const fn from_u32(inner: u32) -> BlockHeight
pub const fn from_u32(inner: u32) -> BlockHeight
Creates a block height from a u32
.
Trait Implementations§
Source§impl Add<BlockInterval> for BlockHeight
impl Add<BlockInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
+
operator.Source§fn add(self, rhs: BlockInterval) -> <BlockHeight as Add<BlockInterval>>::Output
fn add(self, rhs: BlockInterval) -> <BlockHeight as Add<BlockInterval>>::Output
+
operation. Read moreSource§impl Clone for BlockHeight
impl Clone for BlockHeight
Source§fn clone(&self) -> BlockHeight
fn clone(&self) -> BlockHeight
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BlockHeight
impl Debug for BlockHeight
Source§impl<'de> Deserialize<'de> for BlockHeight
impl<'de> Deserialize<'de> for BlockHeight
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockHeight, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockHeight, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for BlockHeight
impl Display for BlockHeight
Source§impl From<Height> for BlockHeight
impl From<Height> for BlockHeight
Source§fn from(h: Height) -> BlockHeight
fn from(h: Height) -> BlockHeight
Converts a [locktime::absolute::Height
] to a BlockHeight
.
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
(500,000,000) where as a BlockHeight
is a thin wrapper around a u32
, the two types are
not interchangeable.
Source§impl From<u32> for BlockHeight
impl From<u32> for BlockHeight
Source§fn from(inner: u32) -> BlockHeight
fn from(inner: u32) -> BlockHeight
Source§impl FromStr for BlockHeight
impl FromStr for BlockHeight
Source§type Err = ParseIntError
type Err = ParseIntError
Source§fn from_str(s: &str) -> Result<BlockHeight, <BlockHeight as FromStr>::Err>
fn from_str(s: &str) -> Result<BlockHeight, <BlockHeight as FromStr>::Err>
s
to return a value of this type. Read moreSource§impl Hash for BlockHeight
impl Hash for BlockHeight
Source§impl Ord for BlockHeight
impl Ord for BlockHeight
Source§fn cmp(&self, other: &BlockHeight) -> Ordering
fn cmp(&self, other: &BlockHeight) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BlockHeight
impl PartialEq for BlockHeight
Source§impl PartialOrd for BlockHeight
impl PartialOrd for BlockHeight
Source§impl Serialize for BlockHeight
impl Serialize for BlockHeight
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,
Source§impl Sub<BlockInterval> for BlockHeight
impl Sub<BlockInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
-
operator.Source§fn sub(self, rhs: BlockInterval) -> <BlockHeight as Sub<BlockInterval>>::Output
fn sub(self, rhs: BlockInterval) -> <BlockHeight as Sub<BlockInterval>>::Output
-
operation. Read moreSource§impl Sub for BlockHeight
impl Sub for BlockHeight
Source§type Output = BlockInterval
type Output = BlockInterval
-
operator.Source§fn sub(self, rhs: BlockHeight) -> <BlockHeight as Sub>::Output
fn sub(self, rhs: BlockHeight) -> <BlockHeight as Sub>::Output
-
operation. Read moreSource§impl TryFrom<&str> for BlockHeight
impl TryFrom<&str> for BlockHeight
Source§type Error = ParseIntError
type Error = ParseIntError
Source§fn try_from(
s: &str,
) -> Result<BlockHeight, <BlockHeight as TryFrom<&str>>::Error>
fn try_from( s: &str, ) -> Result<BlockHeight, <BlockHeight as TryFrom<&str>>::Error>
Source§impl TryFrom<BlockHeight> for Height
impl TryFrom<BlockHeight> for Height
Source§fn try_from(
h: BlockHeight,
) -> Result<Height, <Height as TryFrom<BlockHeight>>::Error>
fn try_from( h: BlockHeight, ) -> Result<Height, <Height as TryFrom<BlockHeight>>::Error>
Converts a BlockHeight
to a [locktime::absolute::Height
].
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
(500,000,000) where as a BlockHeight
is a thin wrapper around a u32
, the two types are
not interchangeable.