units: rename TooBigForRelativeHeightError
What changed, and why it matters
This commit is a simple renaming of an error type from TooBigForRelativeHeightError to BlockCountOverflowError to match updated terminology in the codebase. It does not change any behavior, logic, or security properties. It only updates public re-exports and test references to use the new name.
No security action required. Reviewers may verify that downstream consumers update any references to the old error name, as this is a public API rename.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames units::block::TooBigForRelativeHeightError to BlockCountOverflowError and updates all public re-exports in bitcoin/src/blockdata/block.rs, primitives/src/block.rs, and corresponding API tests. The error’s internal u32 payload, Display implementation, std::error::Error impl, and conversion from Infallible remain unchanged. The TryFrom
Changed components
bitcoin/src/blockdata/block.rsprimitives/src/block.rsprimitives/tests/api.rsunits/src/block.rsunits/tests/api.rsInspect captured patch +23 / −23
### bitcoin/src/blockdata/block.rs
@@ -32,8 +32,8 @@ pub use units::block::{
#[doc(no_inline)]
pub use self::error::{
- Bip34Error, BlockDecoderError, BlockHashDecoderError, BlockHeightDecoderError,
- HeaderDecoderError, InvalidBlockError, TooBigForRelativeHeightError, ValidationError,
+ Bip34Error, BlockCountOverflowError, BlockDecoderError, BlockHashDecoderError,
+ BlockHeightDecoderError, HeaderDecoderError, InvalidBlockError, ValidationError,
VersionDecoderError,
};
@@ -234,7 +234,7 @@ pub mod error {
VersionDecoderError,
};
#[doc(no_inline)]
- pub use units::block::{BlockHeightDecoderError, TooBigForRelativeHeightError};
+ pub use units::block::{BlockCountOverflowError, BlockHeightDecoderError};
/// An error when looking up a BIP-0034 block height.
#[derive(Debug, Clone, PartialEq, Eq)]
### primitives/src/block.rs
@@ -102,8 +102,8 @@ pub use units::block::{BlockHeight, BlockHeightDecoder, BlockHeightEncoder, Bloc
pub use self::error::{BlockDecoderError, InvalidBlockError};
#[doc(no_inline)]
pub use self::error::{
- BlockHashDecoderError, BlockHeightDecoderError, HeaderDecoderError,
- TooBigForRelativeHeightError, VersionDecoderError,
+ BlockCountOverflowError, BlockHashDecoderError, BlockHeightDecoderError, HeaderDecoderError,
+ VersionDecoderError,
};
#[doc(inline)]
pub use crate::hash_types::{BlockHash, BlockHashDecoder, BlockHashEncoder, WitnessCommitment};
@@ -1076,7 +1076,7 @@ pub mod error {
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(no_inline)]
- pub use units::block::{BlockHeightDecoderError, TooBigForRelativeHeightError};
+ pub use units::block::{BlockHeightDecoderError, BlockCountOverflowError};
#[doc(inline)]
pub use crate::hash_types::BlockHashDecoderError;
### primitives/tests/api.rs
@@ -712,17 +712,17 @@ fn p_consistent_exports_script() {
#[test]
fn p_consistent_exports_block() {
use bitcoin_primitives::block::error::{
- BlockDecoderError as _, BlockHashDecoderError as _, BlockHeightDecoderError as _,
- HeaderDecoderError as _, InvalidBlockError as _, TooBigForRelativeHeightError as _,
+ BlockCountOverflowError as _, BlockDecoderError as _, BlockHashDecoderError as _,
+ BlockHeightDecoderError as _, HeaderDecoderError as _, InvalidBlockError as _,
VersionDecoderError as _,
};
use bitcoin_primitives::block::{
- Block, BlockDecoder, BlockDecoderError, BlockEncoder, BlockHash, BlockHashDecoder,
- BlockHashDecoderError, BlockHashEncoder, BlockHeight, BlockHeightDecoder,
+ Block, BlockCountOverflowError, BlockDecoder, BlockDecoderError, BlockEncoder, BlockHash,
+ BlockHashDecoder, BlockHashDecoderError, BlockHashEncoder, BlockHeight, BlockHeightDecoder,
BlockHeightDecoderError, BlockHeightEncoder, BlockHeightInterval, BlockMtp,
BlockMtpInterval, Checked, Header, HeaderDecoder, HeaderDecoderError, HeaderEncoder,
- InvalidBlockError, TooBigForRelativeHeightError, Unchecked, Validation, Version,
- VersionDecoder, VersionDecoderError, VersionEncoder, WitnessCommitment,
+ InvalidBlockError, Unchecked, Validation, Version, VersionDecoder, VersionDecoderError,
+ VersionEncoder, WitnessCommitment,
};
}
### units/src/block.rs
@@ -28,7 +28,7 @@ use crate::parse_int::{self, PrefixedHexError, UnprefixedHexError};
#[doc(no_inline)]
pub use self::error::BlockHeightDecoderError;
#[doc(no_inline)]
-pub use self::error::TooBigForRelativeHeightError;
+pub use self::error::BlockCountOverflowError;
macro_rules! impl_u32_wrapper {
{
@@ -301,7 +301,7 @@ impl From<relative::NumberOfBlocks> for BlockHeightInterval {
}
impl TryFrom<BlockHeightInterval> for relative::NumberOfBlocks {
- type Error = TooBigForRelativeHeightError;
+ type Error = BlockCountOverflowError;
/// Converts a [`BlockHeightInterval`] to a [`locktime::relative::NumberOfBlocks`].
///
@@ -311,7 +311,7 @@ impl TryFrom<BlockHeightInterval> for relative::NumberOfBlocks {
fn try_from(h: BlockHeightInterval) -> Result<Self, Self::Error> {
u16::try_from(h.to_u32())
.map(Self::from_count)
- .map_err(|_| TooBigForRelativeHeightError(h.into()))
+ .map_err(|_| BlockCountOverflowError(h.into()))
}
}
@@ -650,14 +650,14 @@ pub mod error {
/// Error returned when the block interval is too big to be used as a relative lock time.
#[derive(Debug, Clone, PartialEq, Eq)]
- pub struct TooBigForRelativeHeightError(pub(super) u32);
+ pub struct BlockCountOverflowError(pub(super) u32);
- impl From<Infallible> for TooBigForRelativeHeightError {
+ impl From<Infallible> for BlockCountOverflowError {
#[inline]
fn from(never: Infallible) -> Self { match never {} }
}
- impl fmt::Display for TooBigForRelativeHeightError {
+ impl fmt::Display for BlockCountOverflowError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -670,7 +670,7 @@ pub mod error {
}
#[cfg(feature = "std")]
- impl std::error::Error for TooBigForRelativeHeightError {
+ impl std::error::Error for BlockCountOverflowError {
#[inline]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
let Self(_) = self;
@@ -966,7 +966,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn error_display_is_non_empty() {
- // TooBigForRelativeHeightError - block interval too big for relative height
+ // BlockCountOverflowError - block interval too big for a number of blocks
let big_interval = BlockHeightInterval::from_u32(u32::MAX);
let e = relative::NumberOfBlocks::try_from(big_interval).unwrap_err();
assert!(!e.to_string().is_empty());
### units/tests/api.rs
@@ -143,7 +143,7 @@ struct Errors {
i: amount::error::PossiblyConfusingDenominationError,
j: amount::error::TooPreciseError,
k: amount::error::UnknownDenominationError,
- l: block::TooBigForRelativeHeightError,
+ l: block::BlockCountOverflowError,
n: locktime::absolute::ConversionError,
o: locktime::absolute::ParseHeightError,
p: locktime::absolute::ParseTimeError,
@@ -264,7 +264,7 @@ fn c_good_err_display() {
assert_display::<amount::error::PossiblyConfusingDenominationError>();
assert_display::<amount::error::TooPreciseError>();
assert_display::<amount::error::UnknownDenominationError>();
- assert_display::<block::TooBigForRelativeHeightError>();
+ assert_display::<block::BlockCountOverflowError>();
assert_display::<locktime::absolute::ConversionError>();
assert_display::<locktime::absolute::ParseHeightError>();
assert_display::<locktime::absolute::ParseTimeError>();
@@ -405,7 +405,7 @@ fn p_consistent_exports_amount_error() {
#[test]
fn p_consistent_exports_block() {
use bitcoin_units::block::{
- BlockHeight, BlockHeightInterval, BlockMtp, BlockMtpInterval, TooBigForRelativeHeightError,
+ BlockCountOverflowError, BlockHeight, BlockHeightInterval, BlockMtp, BlockMtpInterval,
};
#[cfg(feature = "encoding")]
use bitcoin_units::block::{BlockHeightDecoder, BlockHeightDecoderError, BlockHeightEncoder};Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.