Skip to content

Commit

Permalink
Refactor check_timelocks helper
Browse files Browse the repository at this point in the history
Rename the helper function and local variable at its call site to better
describe the functionality.

Refactor only, no logic changes.
  • Loading branch information
tcharding committed Sep 21, 2023
1 parent 19ee6fe commit b0151f3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/policy/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,17 +700,21 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
/// Returns an error if there is at least one satisfaction that contains
/// a combination of heightlock and timelock.
pub fn check_timelocks(&self) -> Result<(), PolicyError> {
let timelocks = self.check_timelocks_helper();
if timelocks.contains_combination {
let aggregated_timelock_info = self.timelock_info();
if aggregated_timelock_info.contains_combination {
Err(PolicyError::HeightTimelockCombination)
} else {
Ok(())
}
}

// Checks whether the given concrete policy contains a combination of
// timelocks and heightlocks
fn check_timelocks_helper(&self) -> TimelockInfo {
/// Processes `Policy` using `post_order_iter`, creates a `TimelockInfo` for each `Nullary` node
/// and combines them together for `Nary` nodes.
///
/// # Returns
///
/// A single `TimelockInfo` that is the combination of all others after processing each node.
fn timelock_info(&self) -> TimelockInfo {
use Policy::*;

let mut infos = vec![];
Expand Down

0 comments on commit b0151f3

Please sign in to comment.