Put is_satisfied_by functions together
Move the `_by_{height,time}` functions to be underneath the `is_satisfied_by` function. Code move only, no logic change.
This commit is contained in:
parent
480a2cd62a
commit
40bb177bc2
|
@ -213,6 +213,54 @@ impl LockTime {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if an output with this locktime can be spent in the next block.
|
||||
///
|
||||
/// If this function returns true then an output with this locktime can be spent in the next
|
||||
/// block.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if this lock is not lock-by-height.
|
||||
#[inline]
|
||||
pub fn is_satisfied_by_height(
|
||||
self,
|
||||
chain_tip: BlockHeight,
|
||||
utxo_mined_at: BlockHeight,
|
||||
) -> Result<bool, IsSatisfiedByHeightError> {
|
||||
use LockTime as L;
|
||||
|
||||
match self {
|
||||
L::Blocks(blocks) => blocks
|
||||
.is_satisfied_by(chain_tip, utxo_mined_at)
|
||||
.map_err(IsSatisfiedByHeightError::Satisfaction),
|
||||
L::Time(time) => Err(IsSatisfiedByHeightError::Incompatible(time)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if an output with this locktime can be spent in the next block.
|
||||
///
|
||||
/// If this function returns true then an output with this locktime can be spent in the next
|
||||
/// block.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if this lock is not lock-by-time.
|
||||
#[inline]
|
||||
pub fn is_satisfied_by_time(
|
||||
self,
|
||||
chain_tip: BlockMtp,
|
||||
utxo_mined_at: BlockMtp,
|
||||
) -> Result<bool, IsSatisfiedByTimeError> {
|
||||
use LockTime as L;
|
||||
|
||||
match self {
|
||||
L::Time(time) => time
|
||||
.is_satisfied_by(chain_tip, utxo_mined_at)
|
||||
.map_err(IsSatisfiedByTimeError::Satisfaction),
|
||||
L::Blocks(blocks) => Err(IsSatisfiedByTimeError::Incompatible(blocks)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if satisfaction of `other` lock time implies satisfaction of this
|
||||
/// [`relative::LockTime`].
|
||||
///
|
||||
|
@ -281,54 +329,6 @@ impl LockTime {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if an output with this locktime can be spent in the next block.
|
||||
///
|
||||
/// If this function returns true then an output with this locktime can be spent in the next
|
||||
/// block.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if this lock is not lock-by-height.
|
||||
#[inline]
|
||||
pub fn is_satisfied_by_height(
|
||||
self,
|
||||
chain_tip: BlockHeight,
|
||||
utxo_mined_at: BlockHeight,
|
||||
) -> Result<bool, IsSatisfiedByHeightError> {
|
||||
use LockTime as L;
|
||||
|
||||
match self {
|
||||
L::Blocks(blocks) => blocks
|
||||
.is_satisfied_by(chain_tip, utxo_mined_at)
|
||||
.map_err(IsSatisfiedByHeightError::Satisfaction),
|
||||
L::Time(time) => Err(IsSatisfiedByHeightError::Incompatible(time)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if an output with this locktime can be spent in the next block.
|
||||
///
|
||||
/// If this function returns true then an output with this locktime can be spent in the next
|
||||
/// block.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if this lock is not lock-by-time.
|
||||
#[inline]
|
||||
pub fn is_satisfied_by_time(
|
||||
self,
|
||||
chain_tip: BlockMtp,
|
||||
utxo_mined_at: BlockMtp,
|
||||
) -> Result<bool, IsSatisfiedByTimeError> {
|
||||
use LockTime as L;
|
||||
|
||||
match self {
|
||||
L::Time(time) => time
|
||||
.is_satisfied_by(chain_tip, utxo_mined_at)
|
||||
.map_err(IsSatisfiedByTimeError::Satisfaction),
|
||||
L::Blocks(blocks) => Err(IsSatisfiedByTimeError::Incompatible(blocks)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NumberOfBlocks> for LockTime {
|
||||
|
|
Loading…
Reference in New Issue