From f9d6453d5b2893fe6b025f05485ae71b04c3052e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 12 May 2025 12:26:06 +1000 Subject: [PATCH] Shorten locktime type term Use lock-by-time and lock-by-height instead of lock-by-blocktime and lock-by-blockheight respectively with no loss of clarity. --- bitcoin/src/blockdata/mod.rs | 4 ++-- primitives/src/locktime/absolute.rs | 2 +- primitives/src/locktime/relative.rs | 2 +- units/src/locktime/absolute.rs | 10 +++++----- units/src/locktime/relative.rs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bitcoin/src/blockdata/mod.rs b/bitcoin/src/blockdata/mod.rs index 13ffc6059..7974ba807 100644 --- a/bitcoin/src/blockdata/mod.rs +++ b/bitcoin/src/blockdata/mod.rs @@ -32,7 +32,7 @@ pub mod locktime { pub mod absolute { //! Provides type [`LockTime`] that implements the logic around nLockTime/OP_CHECKLOCKTIMEVERIFY. //! - //! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by + //! There are two types of lock time: lock-by-height and lock-by-time, distinguished by //! whether `LockTime < LOCKTIME_THRESHOLD`. use io::{BufRead, Write}; @@ -66,7 +66,7 @@ pub mod locktime { pub mod relative { //! Provides type [`LockTime`] that implements the logic around nSequence/OP_CHECKSEQUENCEVERIFY. //! - //! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by + //! There are two types of lock time: lock-by-height and lock-by-time, distinguished by //! whether bit 22 of the `u32` consensus value is set. /// Re-export everything from the `primitives::locktime::relative` module. diff --git a/primitives/src/locktime/absolute.rs b/primitives/src/locktime/absolute.rs index 0ec07fb14..4971aadb6 100644 --- a/primitives/src/locktime/absolute.rs +++ b/primitives/src/locktime/absolute.rs @@ -2,7 +2,7 @@ //! Provides type [`LockTime`] that implements the logic around `nLockTime`/`OP_CHECKLOCKTIMEVERIFY`. //! -//! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by +//! There are two types of lock time: lock-by-height and lock-by-time, distinguished by //! whether `LockTime < LOCKTIME_THRESHOLD`. use core::fmt; diff --git a/primitives/src/locktime/relative.rs b/primitives/src/locktime/relative.rs index 343ebd682..56edad60b 100644 --- a/primitives/src/locktime/relative.rs +++ b/primitives/src/locktime/relative.rs @@ -2,7 +2,7 @@ //! Provides type [`LockTime`] that implements the logic around `nSequence`/`OP_CHECKSEQUENCEVERIFY`. //! -//! There are two types of lock time: lock-by-blockheight and lock-by-blocktime, distinguished by +//! There are two types of lock time: lock-by-height and lock-by-time, distinguished by //! whether bit 22 of the `u32` consensus value is set. use core::{convert, fmt}; diff --git a/units/src/locktime/absolute.rs b/units/src/locktime/absolute.rs index c256df2e0..96e1bf1fd 100644 --- a/units/src/locktime/absolute.rs +++ b/units/src/locktime/absolute.rs @@ -349,7 +349,7 @@ impl std::error::Error for ConversionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } } -/// Describes the two types of locking, lock-by-blockheight and lock-by-blocktime. +/// Describes the two types of locking, lock-by-height and lock-by-time. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] enum LockTimeUnit { /// Lock by blockheight. @@ -364,9 +364,9 @@ impl fmt::Display for LockTimeUnit { match *self { L::Blocks => - write!(f, "expected lock-by-blockheight (must be < {})", LOCK_TIME_THRESHOLD), + write!(f, "expected lock-by-height (must be < {})", LOCK_TIME_THRESHOLD), L::Seconds => - write!(f, "expected lock-by-blocktime (must be >= {})", LOCK_TIME_THRESHOLD), + write!(f, "expected lock-by-time (must be >= {})", LOCK_TIME_THRESHOLD), } } } @@ -580,8 +580,8 @@ mod tests { let blocks = LockTimeUnit::Blocks; let seconds = LockTimeUnit::Seconds; - assert_eq!(format!("{}", blocks), "expected lock-by-blockheight (must be < 500000000)"); - assert_eq!(format!("{}", seconds), "expected lock-by-blocktime (must be >= 500000000)"); + assert_eq!(format!("{}", blocks), "expected lock-by-height (must be < 500000000)"); + assert_eq!(format!("{}", seconds), "expected lock-by-time (must be >= 500000000)"); } #[test] diff --git a/units/src/locktime/relative.rs b/units/src/locktime/relative.rs index 1fb3db1db..e3d9f8d69 100644 --- a/units/src/locktime/relative.rs +++ b/units/src/locktime/relative.rs @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize}; #[doc(hidden)] pub type Height = NumberOfBlocks; -/// A relative lock time lock-by-blockheight value. +/// A relative lock time lock-by-height value. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct NumberOfBlocks(u16); @@ -94,9 +94,9 @@ impl fmt::Display for NumberOfBlocks { #[doc(hidden)] pub type Time = NumberOf512Seconds; -/// A relative lock time lock-by-blocktime value. +/// A relative lock time lock-by-time value. /// -/// For BIP 68 relative lock-by-blocktime locks, time is measured in 512 second intervals. +/// For BIP 68 relative lock-by-time locks, time is measured in 512 second intervals. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct NumberOf512Seconds(u16);