@@ -67,7 +67,7 @@ pub enum Policy<Pk: MiniscriptKey> {
6767 /// relative probabilities for each one.
6868 Or ( Vec < ( usize , Arc < Policy < Pk > > ) > ) ,
6969 /// 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 > > > ) ,
7171}
7272
7373impl < Pk > Policy < Pk >
@@ -210,7 +210,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
210210 } )
211211 . collect :: < Vec < _ > > ( )
212212 }
213- Policy :: Threshold ( k, ref subs) if * k == 1 => {
213+ Policy :: Thresh ( k, ref subs) if * k == 1 => {
214214 let total_odds = subs. len ( ) ;
215215 subs. iter ( )
216216 . flat_map ( |policy| policy. to_tapleaf_prob_vec ( prob / total_odds as f64 ) )
@@ -265,7 +265,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
265265 /// ### TapTree compilation
266266 ///
267267 /// 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
269269 /// probabilities derived from odds) of policies.
270270 ///
271271 /// 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> {
317317 /// ### TapTree compilation
318318 ///
319319 /// 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
321321 /// probabilities derived from odds) of policies. For example, the policy
322322 /// `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
323323 /// `[pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)))]`.
@@ -430,13 +430,13 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
430430 . map ( |( odds, pol) | ( prob * * odds as f64 / total_odds as f64 , pol. clone ( ) ) )
431431 . collect :: < Vec < _ > > ( )
432432 }
433- Policy :: Threshold ( k, subs) if * k == 1 => {
433+ Policy :: Thresh ( k, subs) if * k == 1 => {
434434 let total_odds = subs. len ( ) ;
435435 subs. iter ( )
436436 . map ( |pol| ( prob / total_odds as f64 , pol. clone ( ) ) )
437437 . collect :: < Vec < _ > > ( )
438438 }
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) ,
440440 pol => vec ! [ ( prob, Arc :: new( pol. clone( ) ) ) ] ,
441441 }
442442 }
@@ -579,7 +579,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
579579 Hash160 ( ref h) => t. hash160 ( h) . map ( Hash160 ) ?,
580580 Older ( ref n) => Older ( * n) ,
581581 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 ( ) ) ,
583583 And ( ref subs) => And ( ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
584584 Or ( ref subs) => Or ( subs
585585 . iter ( )
@@ -605,9 +605,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
605605
606606 let new_policy = match data. node . as_ref ( ) {
607607 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 ( ) ) ) ,
611609 And ( ref subs) => Some ( And ( ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ) ,
612610 Or ( ref subs) => Some ( Or ( subs
613611 . iter ( )
@@ -638,7 +636,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
638636 }
639637
640638 /// 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`.
642640 #[ cfg( feature = "compiler" ) ]
643641 fn num_tap_leaves ( & self ) -> usize {
644642 use Policy :: * ;
@@ -649,7 +647,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
649647
650648 let num = match data. node {
651649 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 ( ) ,
653651 _ => 1 ,
654652 } ;
655653 nums. push ( num) ;
@@ -724,7 +722,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
724722 cltv_with_time : false ,
725723 contains_combination : false ,
726724 } ,
727- Threshold ( ref k, subs) => {
725+ Thresh ( ref k, subs) => {
728726 let iter = ( 0 ..subs. len ( ) ) . map ( info_for_child_n) ;
729727 TimelockInfo :: combine_threshold ( * k, iter)
730728 }
@@ -772,7 +770,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
772770 Ok ( ( ) )
773771 }
774772 }
775- Policy :: Threshold ( k, ref subs) => {
773+ Policy :: Thresh ( k, ref subs) => {
776774 if k == 0 || k > subs. len ( ) {
777775 Err ( PolicyError :: IncorrectThresh )
778776 } else {
@@ -821,7 +819,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
821819 | Policy :: Hash160 ( _)
822820 | Policy :: After ( _)
823821 | Policy :: Older ( _) => ( false , true ) ,
824- Policy :: Threshold ( k, ref subs) => {
822+ Policy :: Thresh ( k, ref subs) => {
825823 let ( safe_count, non_mall_count) = subs
826824 . iter ( )
827825 . map ( |sub| sub. is_safe_nonmalleable ( ) )
@@ -884,7 +882,7 @@ impl<Pk: MiniscriptKey> fmt::Debug for Policy<Pk> {
884882 }
885883 f. write_str ( ")" )
886884 }
887- Policy :: Threshold ( k, ref subs) => {
885+ Policy :: Thresh ( k, ref subs) => {
888886 write ! ( f, "thresh({}" , k) ?;
889887 for sub in subs {
890888 write ! ( f, ",{:?}" , sub) ?;
@@ -927,7 +925,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Policy<Pk> {
927925 }
928926 f. write_str ( ")" )
929927 }
930- Policy :: Threshold ( k, ref subs) => {
928+ Policy :: Thresh ( k, ref subs) => {
931929 write ! ( f, "thresh({}" , k) ?;
932930 for sub in subs {
933931 write ! ( f, ",{}" , sub) ?;
@@ -1052,7 +1050,7 @@ impl_block_str!(
10521050 for arg in & top. args[ 1 ..] {
10531051 subs. push( Policy :: from_tree( arg) ?) ;
10541052 }
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( ) ) )
10561054 }
10571055 _ => Err ( errstr( top. name) ) ,
10581056 }
@@ -1095,7 +1093,7 @@ fn with_huffman_tree<Pk: MiniscriptKey>(
10951093 Ok ( node)
10961094}
10971095
1098- /// Enumerates a [`Policy::Threshold (k, ..n..)`] into `n` different thresh's.
1096+ /// Enumerates a [`Policy::Thresh (k, ..n..)`] into `n` different thresh's.
10991097///
11001098/// ## Strategy
11011099///
@@ -1117,7 +1115,7 @@ fn generate_combination<Pk: MiniscriptKey>(
11171115 . enumerate ( )
11181116 . filter_map ( |( j, sub) | if j != i { Some ( Arc :: clone ( sub) ) } else { None } )
11191117 . 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) ) ) ) ;
11211119 }
11221120 ret
11231121}
@@ -1165,10 +1163,7 @@ mod compiler_tests {
11651163 . map ( |sub_pol| {
11661164 (
11671165 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 ( ) ) ) ,
11721167 )
11731168 } )
11741169 . collect :: < Vec < _ > > ( ) ;
0 commit comments