Skip to content

Commit 51de643

Browse files
committed
Rename comibine methods
Use more descriptive names for the 'combine' methods while removing the 'timelocks' bit of the method names.
1 parent ef6803f commit 51de643

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/miniscript/types/extra_props.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ impl TimeLockInfo {
6363

6464
// handy function for combining `and` timelocks
6565
// This can be operator overloaded in future
66-
pub(crate) fn comb_and_timelocks(a: Self, b: Self) -> Self {
67-
Self::combine_thresh_timelocks(2, once(a).chain(once(b)))
66+
pub(crate) fn combine_and(a: Self, b: Self) -> Self {
67+
Self::combine_threshold(2, once(a).chain(once(b)))
6868
}
6969

7070
// handy function for combining `or` timelocks
7171
// This can be operator overloaded in future
72-
pub(crate) fn comb_or_timelocks(a: Self, b: Self) -> Self {
73-
Self::combine_thresh_timelocks(1, once(a).chain(once(b)))
72+
pub(crate) fn combine_or(a: Self, b: Self) -> Self {
73+
Self::combine_threshold(1, once(a).chain(once(b)))
7474
}
7575

76-
pub(crate) fn combine_thresh_timelocks<I>(k: usize, sub_timelocks: I) -> TimeLockInfo
76+
pub(crate) fn combine_threshold<I>(k: usize, sub_timelocks: I) -> TimeLockInfo
7777
where
7878
I: IntoIterator<Item = TimeLockInfo>,
7979
{
@@ -518,7 +518,7 @@ impl Property for ExtData {
518518
max_dissat_size: l
519519
.max_dissat_size
520520
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
521-
timelock_info: TimeLockInfo::comb_and_timelocks(l.timelock_info, r.timelock_info),
521+
timelock_info: TimeLockInfo::combine_and(l.timelock_info, r.timelock_info),
522522
// Left element leaves a stack result on the stack top and then right element is evaluated
523523
// Therefore + 1 is added to execution size of second element
524524
exec_stack_elem_count_sat: opt_max(
@@ -549,7 +549,7 @@ impl Property for ExtData {
549549
.max_sat_size
550550
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
551551
max_dissat_size: None,
552-
timelock_info: TimeLockInfo::comb_and_timelocks(l.timelock_info, r.timelock_info),
552+
timelock_info: TimeLockInfo::combine_and(l.timelock_info, r.timelock_info),
553553
// [X] leaves no element after evaluation, hence this is the max
554554
exec_stack_elem_count_sat: opt_max(
555555
l.exec_stack_elem_count_sat,
@@ -589,7 +589,7 @@ impl Property for ExtData {
589589
max_dissat_size: l
590590
.max_dissat_size
591591
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
592-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
592+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
593593
exec_stack_elem_count_sat: cmp::max(
594594
opt_max(
595595
l.exec_stack_elem_count_sat,
@@ -632,7 +632,7 @@ impl Property for ExtData {
632632
max_dissat_size: l
633633
.max_dissat_size
634634
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
635-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
635+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
636636
exec_stack_elem_count_sat: cmp::max(
637637
l.exec_stack_elem_count_sat,
638638
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -666,7 +666,7 @@ impl Property for ExtData {
666666
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
667667
),
668668
max_dissat_size: None,
669-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
669+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
670670
exec_stack_elem_count_sat: cmp::max(
671671
l.exec_stack_elem_count_sat,
672672
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -709,7 +709,7 @@ impl Property for ExtData {
709709
(Some(l), None) => Some((2 + l.0, 1 + l.1)),
710710
(None, None) => None,
711711
},
712-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
712+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
713713
// TODO: fix elem count dissat bug
714714
exec_stack_elem_count_sat: cmp::max(
715715
l.exec_stack_elem_count_sat,
@@ -752,8 +752,8 @@ impl Property for ExtData {
752752
max_dissat_size: a
753753
.max_dissat_size
754754
.and_then(|(wa, sa)| c.max_dissat_size.map(|(wc, sc)| (wa + wc, sa + sc))),
755-
timelock_info: TimeLockInfo::comb_or_timelocks(
756-
TimeLockInfo::comb_and_timelocks(a.timelock_info, b.timelock_info),
755+
timelock_info: TimeLockInfo::combine_or(
756+
TimeLockInfo::combine_and(a.timelock_info, b.timelock_info),
757757
c.timelock_info,
758758
),
759759
exec_stack_elem_count_sat: cmp::max(
@@ -884,7 +884,7 @@ impl Property for ExtData {
884884
stack_elem_count_dissat,
885885
max_sat_size,
886886
max_dissat_size,
887-
timelock_info: TimeLockInfo::combine_thresh_timelocks(k, timelocks),
887+
timelock_info: TimeLockInfo::combine_threshold(k, timelocks),
888888
exec_stack_elem_count_sat,
889889
exec_stack_elem_count_dissat,
890890
})

src/policy/concrete.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,17 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
458458
},
459459
Policy::Threshold(k, ref subs) => {
460460
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
461-
TimeLockInfo::combine_thresh_timelocks(k, iter)
461+
TimeLockInfo::combine_threshold(k, iter)
462462
}
463463
Policy::And(ref subs) => {
464464
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
465-
TimeLockInfo::combine_thresh_timelocks(subs.len(), iter)
465+
TimeLockInfo::combine_threshold(subs.len(), iter)
466466
}
467467
Policy::Or(ref subs) => {
468468
let iter = subs
469469
.iter()
470470
.map(|&(ref _p, ref sub)| sub.check_timelocks_helper());
471-
TimeLockInfo::combine_thresh_timelocks(1, iter)
471+
TimeLockInfo::combine_threshold(1, iter)
472472
}
473473
}
474474
}

0 commit comments

Comments
 (0)