From 5bd0d7194b3c53fcbfc15a83f340dc4dd4cefe14 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 29 Feb 2024 13:56:03 +1100 Subject: [PATCH] Remove unused absolute::Error The `absolute::Error` is not used, we originally intended it as possibly useful for users of the library. We have not made effort in other modules to provide such errors - lets remove it. --- bitcoin/src/blockdata/locktime/absolute.rs | 86 ---------------------- 1 file changed, 86 deletions(-) diff --git a/bitcoin/src/blockdata/locktime/absolute.rs b/bitcoin/src/blockdata/locktime/absolute.rs index 6cb52c85..cc50330b 100644 --- a/bitcoin/src/blockdata/locktime/absolute.rs +++ b/bitcoin/src/blockdata/locktime/absolute.rs @@ -614,60 +614,6 @@ fn is_block_height(n: u32) -> bool { n < LOCK_TIME_THRESHOLD } /// Returns true if `n` is a UNIX timestamp i.e., greater than or equal to 500,000,000. fn is_block_time(n: u32) -> bool { n >= LOCK_TIME_THRESHOLD } -/// Catchall type for errors that relate to time locks. -#[derive(Debug, Clone, PartialEq, Eq)] -#[non_exhaustive] -pub enum Error { - /// An error occurred while converting a `u32` to a lock time variant. - Conversion(ConversionError), - /// An error occurred while operating on lock times. - Operation(OperationError), - /// An error occurred while parsing a string into an `u32`. - Parse(ParseIntError), -} - -internals::impl_from_infallible!(Error); - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Error::*; - - match *self { - Conversion(ref e) => write_err!(f, "error converting lock time value"; e), - Operation(ref e) => write_err!(f, "error during lock time operation"; e), - Parse(ref e) => write_err!(f, "failed to parse lock time from string"; e), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use Error::*; - - match *self { - Conversion(ref e) => Some(e), - Operation(ref e) => Some(e), - Parse(ref e) => Some(e), - } - } -} - -impl From for Error { - #[inline] - fn from(e: ConversionError) -> Self { Self::Conversion(e) } -} - -impl From for Error { - #[inline] - fn from(e: OperationError) -> Self { Self::Operation(e) } -} - -impl From for Error { - #[inline] - fn from(e: ParseIntError) -> Self { Self::Parse(e) } -} - /// An error that occurs when converting a `u32` to a lock time variant. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] @@ -717,38 +663,6 @@ impl fmt::Display for LockTimeUnit { } } -/// Errors than occur when operating on lock times. -#[derive(Debug, Clone, PartialEq, Eq)] -#[non_exhaustive] -pub enum OperationError { - /// Cannot compare different lock time units (height vs time). - InvalidComparison, -} - -internals::impl_from_infallible!(OperationError); - -impl fmt::Display for OperationError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use OperationError::*; - - match *self { - InvalidComparison => - f.write_str("cannot compare different lock units (height vs time)"), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for OperationError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use OperationError::*; - - match *self { - InvalidComparison => None, - } - } -} - /// Internal - common representation for height and time. #[derive(Debug, Clone, Eq, PartialEq)] enum ParseError {