Skip to content

Commit c00d6fb

Browse files
committed
Rename comibine methods
Use more descriptive names for the 'combine' methods.
1 parent 6dbf89b commit c00d6fb

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
@@ -62,17 +62,17 @@ impl TimeLockInfo {
6262

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

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

75-
pub(crate) fn combine_thresh_timelocks<I>(k: usize, sub_timelocks: I) -> TimeLockInfo
75+
pub(crate) fn combine_threshold<I>(k: usize, sub_timelocks: I) -> TimeLockInfo
7676
where
7777
I: IntoIterator<Item = TimeLockInfo>,
7878
{
@@ -505,7 +505,7 @@ impl Property for ExtData {
505505
max_dissat_size: l
506506
.max_dissat_size
507507
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
508-
timelock_info: TimeLockInfo::comb_and_timelocks(l.timelock_info, r.timelock_info),
508+
timelock_info: TimeLockInfo::combine_and(l.timelock_info, r.timelock_info),
509509
// Left element leaves a stack result on the stack top and then right element is evaluated
510510
// Therefore + 1 is added to execution size of second element
511511
exec_stack_elem_count_sat: opt_max(
@@ -536,7 +536,7 @@ impl Property for ExtData {
536536
.max_sat_size
537537
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
538538
max_dissat_size: None,
539-
timelock_info: TimeLockInfo::comb_and_timelocks(l.timelock_info, r.timelock_info),
539+
timelock_info: TimeLockInfo::combine_and(l.timelock_info, r.timelock_info),
540540
// [X] leaves no element after evaluation, hence this is the max
541541
exec_stack_elem_count_sat: opt_max(
542542
l.exec_stack_elem_count_sat,
@@ -576,7 +576,7 @@ impl Property for ExtData {
576576
max_dissat_size: l
577577
.max_dissat_size
578578
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
579-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
579+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
580580
exec_stack_elem_count_sat: cmp::max(
581581
opt_max(
582582
l.exec_stack_elem_count_sat,
@@ -619,7 +619,7 @@ impl Property for ExtData {
619619
max_dissat_size: l
620620
.max_dissat_size
621621
.and_then(|(lw, ls)| r.max_dissat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
622-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
622+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
623623
exec_stack_elem_count_sat: cmp::max(
624624
l.exec_stack_elem_count_sat,
625625
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -653,7 +653,7 @@ impl Property for ExtData {
653653
.and_then(|(lw, ls)| r.max_sat_size.map(|(rw, rs)| (lw + rw, ls + rs))),
654654
),
655655
max_dissat_size: None,
656-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
656+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
657657
exec_stack_elem_count_sat: cmp::max(
658658
l.exec_stack_elem_count_sat,
659659
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
@@ -696,7 +696,7 @@ impl Property for ExtData {
696696
(Some(l), None) => Some((2 + l.0, 1 + l.1)),
697697
(None, None) => None,
698698
},
699-
timelock_info: TimeLockInfo::comb_or_timelocks(l.timelock_info, r.timelock_info),
699+
timelock_info: TimeLockInfo::combine_or(l.timelock_info, r.timelock_info),
700700
// TODO: fix elem count dissat bug
701701
exec_stack_elem_count_sat: cmp::max(
702702
l.exec_stack_elem_count_sat,
@@ -739,8 +739,8 @@ impl Property for ExtData {
739739
max_dissat_size: a
740740
.max_dissat_size
741741
.and_then(|(wa, sa)| c.max_dissat_size.map(|(wc, sc)| (wa + wc, sa + sc))),
742-
timelock_info: TimeLockInfo::comb_or_timelocks(
743-
TimeLockInfo::comb_and_timelocks(a.timelock_info, b.timelock_info),
742+
timelock_info: TimeLockInfo::combine_or(
743+
TimeLockInfo::combine_and(a.timelock_info, b.timelock_info),
744744
c.timelock_info,
745745
),
746746
exec_stack_elem_count_sat: cmp::max(
@@ -876,7 +876,7 @@ impl Property for ExtData {
876876
stack_elem_count_dissat,
877877
max_sat_size,
878878
max_dissat_size,
879-
timelock_info: TimeLockInfo::combine_thresh_timelocks(k, timelocks),
879+
timelock_info: TimeLockInfo::combine_threshold(k, timelocks),
880880
exec_stack_elem_count_sat,
881881
exec_stack_elem_count_dissat,
882882
})

src/policy/concrete.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,17 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
297297
},
298298
Policy::Threshold(k, ref subs) => {
299299
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
300-
TimeLockInfo::combine_thresh_timelocks(k, iter)
300+
TimeLockInfo::combine_threshold(k, iter)
301301
}
302302
Policy::And(ref subs) => {
303303
let iter = subs.iter().map(|sub| sub.check_timelocks_helper());
304-
TimeLockInfo::combine_thresh_timelocks(subs.len(), iter)
304+
TimeLockInfo::combine_threshold(subs.len(), iter)
305305
}
306306
Policy::Or(ref subs) => {
307307
let iter = subs
308308
.iter()
309309
.map(|&(ref _p, ref sub)| sub.check_timelocks_helper());
310-
TimeLockInfo::combine_thresh_timelocks(1, iter)
310+
TimeLockInfo::combine_threshold(1, iter)
311311
}
312312
}
313313
}

0 commit comments

Comments
 (0)