@@ -67,7 +67,7 @@ pub enum Policy<Pk: MiniscriptKey> {
67
67
/// relative probabilities for each one.
68
68
Or ( Vec < ( usize , Arc < Policy < Pk > > ) > ) ,
69
69
/// A set of descriptors, satisfactions must be provided for `k` of them.
70
- Threshold ( usize , Vec < Arc < Policy < Pk > > > ) ,
70
+ Thresh ( usize , Vec < Arc < Policy < Pk > > > ) ,
71
71
}
72
72
73
73
impl < Pk > Policy < Pk >
@@ -210,7 +210,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
210
210
} )
211
211
. collect :: < Vec < _ > > ( )
212
212
}
213
- Policy :: Threshold ( k, ref subs) if * k == 1 => {
213
+ Policy :: Thresh ( k, ref subs) if * k == 1 => {
214
214
let total_odds = subs. len ( ) ;
215
215
subs. iter ( )
216
216
. flat_map ( |policy| policy. to_tapleaf_prob_vec ( prob / total_odds as f64 ) )
@@ -265,7 +265,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
265
265
/// ### TapTree compilation
266
266
///
267
267
/// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
268
- /// [`Policy::Threshold `](1, ..) which is flattened into a vector (with respective
268
+ /// [`Policy::Thresh `](1, ..) which is flattened into a vector (with respective
269
269
/// probabilities derived from odds) of policies.
270
270
///
271
271
/// For example, the policy `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the
@@ -317,7 +317,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
317
317
/// ### TapTree compilation
318
318
///
319
319
/// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
320
- /// [`Policy::Threshold `](k, ..n..) which is flattened into a vector (with respective
320
+ /// [`Policy::Thresh `](k, ..n..) which is flattened into a vector (with respective
321
321
/// probabilities derived from odds) of policies. For example, the policy
322
322
/// `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
323
323
/// `[pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)))]`.
@@ -430,13 +430,13 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
430
430
. map ( |( odds, pol) | ( prob * * odds as f64 / total_odds as f64 , pol. clone ( ) ) )
431
431
. collect :: < Vec < _ > > ( )
432
432
}
433
- Policy :: Threshold ( k, subs) if * k == 1 => {
433
+ Policy :: Thresh ( k, subs) if * k == 1 => {
434
434
let total_odds = subs. len ( ) ;
435
435
subs. iter ( )
436
436
. map ( |pol| ( prob / total_odds as f64 , pol. clone ( ) ) )
437
437
. collect :: < Vec < _ > > ( )
438
438
}
439
- Policy :: Threshold ( k, subs) if * k != subs. len ( ) => generate_combination ( subs, prob, * k) ,
439
+ Policy :: Thresh ( k, subs) if * k != subs. len ( ) => generate_combination ( subs, prob, * k) ,
440
440
pol => vec ! [ ( prob, Arc :: new( pol. clone( ) ) ) ] ,
441
441
}
442
442
}
@@ -579,7 +579,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
579
579
Hash160 ( ref h) => t. hash160 ( h) . map ( Hash160 ) ?,
580
580
Older ( ref n) => Older ( * n) ,
581
581
After ( ref n) => After ( * n) ,
582
- Threshold ( ref k, ref subs) => Threshold ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
582
+ Thresh ( ref k, ref subs) => Thresh ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
583
583
And ( ref subs) => And ( ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
584
584
Or ( ref subs) => Or ( subs
585
585
. iter ( )
@@ -605,9 +605,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
605
605
606
606
let new_policy = match data. node . as_ref ( ) {
607
607
Policy :: Key ( ref k) if k. clone ( ) == * key => Some ( Policy :: Unsatisfiable ) ,
608
- Threshold ( k, ref subs) => {
609
- Some ( Threshold ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) )
610
- }
608
+ Thresh ( k, ref subs) => Some ( Thresh ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ) ,
611
609
And ( ref subs) => Some ( And ( ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ) ,
612
610
Or ( ref subs) => Some ( Or ( subs
613
611
. iter ( )
@@ -638,7 +636,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
638
636
}
639
637
640
638
/// Gets the number of [TapLeaf](`TapTree::Leaf`)s considering exhaustive root-level [`Policy::Or`]
641
- /// and [`Policy::Threshold `] disjunctions for the `TapTree`.
639
+ /// and [`Policy::Thresh `] disjunctions for the `TapTree`.
642
640
#[ cfg( feature = "compiler" ) ]
643
641
fn num_tap_leaves ( & self ) -> usize {
644
642
use Policy :: * ;
@@ -649,7 +647,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
649
647
650
648
let num = match data. node {
651
649
Or ( subs) => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
652
- Threshold ( k, subs) if * k == 1 => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
650
+ Thresh ( k, subs) if * k == 1 => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
653
651
_ => 1 ,
654
652
} ;
655
653
nums. push ( num) ;
@@ -724,7 +722,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
724
722
cltv_with_time : false ,
725
723
contains_combination : false ,
726
724
} ,
727
- Threshold ( ref k, subs) => {
725
+ Thresh ( ref k, subs) => {
728
726
let iter = ( 0 ..subs. len ( ) ) . map ( info_for_child_n) ;
729
727
TimelockInfo :: combine_threshold ( * k, iter)
730
728
}
@@ -772,7 +770,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
772
770
Ok ( ( ) )
773
771
}
774
772
}
775
- Policy :: Threshold ( k, ref subs) => {
773
+ Policy :: Thresh ( k, ref subs) => {
776
774
if k == 0 || k > subs. len ( ) {
777
775
Err ( PolicyError :: IncorrectThresh )
778
776
} else {
@@ -821,7 +819,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
821
819
| Policy :: Hash160 ( _)
822
820
| Policy :: After ( _)
823
821
| Policy :: Older ( _) => ( false , true ) ,
824
- Policy :: Threshold ( k, ref subs) => {
822
+ Policy :: Thresh ( k, ref subs) => {
825
823
let ( safe_count, non_mall_count) = subs
826
824
. iter ( )
827
825
. map ( |sub| sub. is_safe_nonmalleable ( ) )
@@ -884,7 +882,7 @@ impl<Pk: MiniscriptKey> fmt::Debug for Policy<Pk> {
884
882
}
885
883
f. write_str ( ")" )
886
884
}
887
- Policy :: Threshold ( k, ref subs) => {
885
+ Policy :: Thresh ( k, ref subs) => {
888
886
write ! ( f, "thresh({}" , k) ?;
889
887
for sub in subs {
890
888
write ! ( f, ",{:?}" , sub) ?;
@@ -927,7 +925,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Policy<Pk> {
927
925
}
928
926
f. write_str ( ")" )
929
927
}
930
- Policy :: Threshold ( k, ref subs) => {
928
+ Policy :: Thresh ( k, ref subs) => {
931
929
write ! ( f, "thresh({}" , k) ?;
932
930
for sub in subs {
933
931
write ! ( f, ",{}" , sub) ?;
@@ -1052,7 +1050,7 @@ impl_block_str!(
1052
1050
for arg in & top. args[ 1 ..] {
1053
1051
subs. push( Policy :: from_tree( arg) ?) ;
1054
1052
}
1055
- Ok ( Policy :: Threshold ( thresh as usize , subs. into_iter( ) . map( Arc :: new) . collect( ) ) )
1053
+ Ok ( Policy :: Thresh ( thresh as usize , subs. into_iter( ) . map( Arc :: new) . collect( ) ) )
1056
1054
}
1057
1055
_ => Err ( errstr( top. name) ) ,
1058
1056
}
@@ -1095,7 +1093,7 @@ fn with_huffman_tree<Pk: MiniscriptKey>(
1095
1093
Ok ( node)
1096
1094
}
1097
1095
1098
- /// Enumerates a [`Policy::Threshold (k, ..n..)`] into `n` different thresh's.
1096
+ /// Enumerates a [`Policy::Thresh (k, ..n..)`] into `n` different thresh's.
1099
1097
///
1100
1098
/// ## Strategy
1101
1099
///
@@ -1117,7 +1115,7 @@ fn generate_combination<Pk: MiniscriptKey>(
1117
1115
. enumerate ( )
1118
1116
. filter_map ( |( j, sub) | if j != i { Some ( Arc :: clone ( sub) ) } else { None } )
1119
1117
. collect ( ) ;
1120
- ret. push ( ( prob / policy_vec. len ( ) as f64 , Arc :: new ( Policy :: Threshold ( k, policies) ) ) ) ;
1118
+ ret. push ( ( prob / policy_vec. len ( ) as f64 , Arc :: new ( Policy :: Thresh ( k, policies) ) ) ) ;
1121
1119
}
1122
1120
ret
1123
1121
}
@@ -1165,10 +1163,7 @@ mod compiler_tests {
1165
1163
. map ( |sub_pol| {
1166
1164
(
1167
1165
0.25 ,
1168
- Arc :: new ( Policy :: Threshold (
1169
- 2 ,
1170
- sub_pol. into_iter ( ) . map ( |p| Arc :: new ( p) ) . collect ( ) ,
1171
- ) ) ,
1166
+ Arc :: new ( Policy :: Thresh ( 2 , sub_pol. into_iter ( ) . map ( |p| Arc :: new ( p) ) . collect ( ) ) ) ,
1172
1167
)
1173
1168
} )
1174
1169
. collect :: < Vec < _ > > ( ) ;
0 commit comments