Merge rust-bitcoin/rust-bitcoin#4508: units: Make block-related types have private inner fields
9a9b41008f
units: Make block-related types have private inner fields (Tobin C. Harding)
Pull request description:
We recently added a bunch of types in the `block` module that are wrappers around `u32`. When we did we slapped `pub` on the inner fields.
Lets be more mindful and make the inner fields private. Note all these types have `to_u32`, `from_u32` and `From` in both directions.
ACKs for top commit:
apoelstra:
ACK 9a9b41008f72cb8a00cfed2890d839aea2ea27c7; successfully ran local tests
Tree-SHA512: d4719bef57944000142ec110d4701486b4a7e5c5b24426379ed596ad83555ca1f75191fe618cc62f12b78b9d7a1ac5d18eff96bc407c9688b1210529c25329b3
This commit is contained in:
commit
532345bd11
|
@ -85,8 +85,7 @@ impl_u32_wrapper! {
|
||||||
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
// Public to try and make it really clear that there are no invariants.
|
pub struct BlockHeight(u32);
|
||||||
pub struct BlockHeight(pub u32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockHeight {
|
impl BlockHeight {
|
||||||
|
@ -130,8 +129,7 @@ impl_u32_wrapper! {
|
||||||
/// purpose block interval abstraction. For locktimes please see [`locktime::relative::Height`].
|
/// purpose block interval abstraction. For locktimes please see [`locktime::relative::Height`].
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
// Public to try and make it really clear that there are no invariants.
|
pub struct BlockHeightInterval(u32);
|
||||||
pub struct BlockHeightInterval(pub u32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockHeightInterval {
|
impl BlockHeightInterval {
|
||||||
|
@ -173,8 +171,7 @@ impl_u32_wrapper! {
|
||||||
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
// Public to try and make it really clear that there are no invariants.
|
pub struct BlockMtp(u32);
|
||||||
pub struct BlockMtp(pub u32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockMtp {
|
impl BlockMtp {
|
||||||
|
@ -228,8 +225,7 @@ impl_u32_wrapper! {
|
||||||
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
/// This is a thin wrapper around a `u32` that may take on all values of a `u32`.
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
// Public to try and make it really clear that there are no invariants.
|
pub struct BlockMtpInterval(u32);
|
||||||
pub struct BlockMtpInterval(pub u32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockMtpInterval {
|
impl BlockMtpInterval {
|
||||||
|
|
Loading…
Reference in New Issue