From b0151f381e2e394b59d32d49d70d0edff454aba7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 21 Sep 2023 12:39:57 +1000 Subject: [PATCH] Refactor check_timelocks helper Rename the helper function and local variable at its call site to better describe the functionality. Refactor only, no logic changes. --- src/policy/concrete.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/policy/concrete.rs b/src/policy/concrete.rs index 04b80356d..de03d4ae8 100644 --- a/src/policy/concrete.rs +++ b/src/policy/concrete.rs @@ -700,17 +700,21 @@ impl Policy { /// 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![];