From b8721bf244b7105711886a90ffb0ab8789809ffa Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 15 Sep 2022 09:21:24 +1000 Subject: [PATCH] Add method relative::LockTime::is_implied_by As we just did for `absolute::LockTime` add a method `is_implied_by` and deprecate `is_satisfied_by_lock`. Reasoning: it is odd to think of a lock satisfying another lock but it is clear to see that satisfaction of one lock can imply satisfaction of another. --- bitcoin/src/blockdata/locktime/relative.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bitcoin/src/blockdata/locktime/relative.rs b/bitcoin/src/blockdata/locktime/relative.rs index 7502c969..6136f961 100644 --- a/bitcoin/src/blockdata/locktime/relative.rs +++ b/bitcoin/src/blockdata/locktime/relative.rs @@ -62,11 +62,12 @@ impl LockTime { } } - /// Returns true if this [`relative::LockTime`] is satisfied by `other` lock. + /// Returns true if satisfaction of `other` lock time implies satisfaction of this + /// [`relative::LockTime`]. /// /// This function is useful when checking sequence values against a lock, first one checks the /// sequence represents a relative lock time by converting to `LockTime` then use this function - /// to see if [`LockTime`] is satisfied by the newly created lock. + /// to see if satisfaction of the newly created lock time would imply satisfaction of `self`. /// /// # Examples /// @@ -80,16 +81,16 @@ impl LockTime { /// /// let satisfied = match test_sequence.to_relative_lock_time() { /// None => false, // Handle non-lock-time case. - /// Some(test_lock) => lock.is_satisfied_by_lock(test_lock), + /// Some(test_lock) => lock.is_implied_by(test_lock), /// }; /// assert!(satisfied); /// ``` - pub fn is_satisfied_by_lock(&self, other: LockTime) -> bool { + pub fn is_implied_by(&self, other: LockTime) -> bool { use LockTime::*; match (*self, other) { - (Blocks(n), Blocks(m)) => n.value() <= m.value(), - (Time(n), Time(m)) => n.value() <= m.value(), + (Blocks(this), Blocks(other)) => this.value() <= other.value(), + (Time(this), Time(other)) => this.value() <= other.value(), _ => false, // Not the same units. } }