@@ -69,7 +69,7 @@ pub enum Policy<Pk: MiniscriptKey> {
6969 /// relative probabilities for each one.
7070 Or ( Vec < ( usize , Arc < Policy < Pk > > ) > ) ,
7171 /// A set of descriptors, satisfactions must be provided for `k` of them.
72- Threshold ( usize , Vec < Arc < Policy < Pk > > > ) ,
72+ Thresh ( usize , Vec < Arc < Policy < Pk > > > ) ,
7373}
7474
7575/// Detailed error type for concrete policies.
@@ -187,7 +187,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
187187 } )
188188 . collect :: < Vec < _ > > ( )
189189 }
190- Policy :: Threshold ( k, ref subs) if * k == 1 => {
190+ Policy :: Thresh ( k, ref subs) if * k == 1 => {
191191 let total_odds = subs. len ( ) ;
192192 subs. iter ( )
193193 . flat_map ( |policy| policy. to_tapleaf_prob_vec ( prob / total_odds as f64 ) )
@@ -242,7 +242,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
242242 /// ### TapTree compilation
243243 ///
244244 /// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
245- /// [`Policy::Threshold `](1, ..) which is flattened into a vector (with respective
245+ /// [`Policy::Thresh `](1, ..) which is flattened into a vector (with respective
246246 /// probabilities derived from odds) of policies.
247247 ///
248248 /// For example, the policy `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the
@@ -294,7 +294,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
294294 /// ### TapTree compilation
295295 ///
296296 /// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
297- /// [`Policy::Threshold `](k, ..n..) which is flattened into a vector (with respective
297+ /// [`Policy::Thresh `](k, ..n..) which is flattened into a vector (with respective
298298 /// probabilities derived from odds) of policies. For example, the policy
299299 /// `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
300300 /// `[pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)))]`.
@@ -407,13 +407,13 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
407407 . map ( |( odds, pol) | ( prob * * odds as f64 / total_odds as f64 , pol. clone ( ) ) )
408408 . collect :: < Vec < _ > > ( )
409409 }
410- Policy :: Threshold ( k, subs) if * k == 1 => {
410+ Policy :: Thresh ( k, subs) if * k == 1 => {
411411 let total_odds = subs. len ( ) ;
412412 subs. iter ( )
413413 . map ( |pol| ( prob / total_odds as f64 , pol. clone ( ) ) )
414414 . collect :: < Vec < _ > > ( )
415415 }
416- Policy :: Threshold ( k, subs) if * k != subs. len ( ) => generate_combination ( subs, prob, * k) ,
416+ Policy :: Thresh ( k, subs) if * k != subs. len ( ) => generate_combination ( subs, prob, * k) ,
417417 pol => vec ! [ ( prob, Arc :: new( pol. clone( ) ) ) ] ,
418418 }
419419 }
@@ -562,7 +562,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
562562 . enumerate ( )
563563 . map ( |( i, ( prob, _) ) | ( * prob, child_n ( i) ) )
564564 . collect ( ) ) ,
565- Threshold ( ref k, ref subs) => Threshold ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
565+ Thresh ( ref k, ref subs) => Thresh ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ,
566566 } ;
567567 translated. push ( Arc :: new ( new_policy) ) ;
568568 }
@@ -588,9 +588,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
588588 . enumerate ( )
589589 . map ( |( i, ( prob, _) ) | ( * prob, child_n ( i) ) )
590590 . collect ( ) ) ) ,
591- Threshold ( k, ref subs) => {
592- Some ( Threshold ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) )
593- }
591+ Thresh ( k, ref subs) => Some ( Thresh ( * k, ( 0 ..subs. len ( ) ) . map ( child_n) . collect ( ) ) ) ,
594592 _ => None ,
595593 } ;
596594 match new_policy {
@@ -615,7 +613,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
615613 }
616614
617615 /// Gets the number of [TapLeaf](`TapTree::Leaf`)s considering exhaustive root-level [`Policy::Or`]
618- /// and [`Policy::Threshold `] disjunctions for the `TapTree`.
616+ /// and [`Policy::Thresh `] disjunctions for the `TapTree`.
619617 #[ cfg( feature = "compiler" ) ]
620618 fn num_tap_leaves ( & self ) -> usize {
621619 use Policy :: * ;
@@ -626,7 +624,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
626624
627625 let num = match data. node {
628626 Or ( subs) => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
629- Threshold ( k, subs) if * k == 1 => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
627+ Thresh ( k, subs) if * k == 1 => ( 0 ..subs. len ( ) ) . map ( num_for_child_n) . sum ( ) ,
630628 _ => 1 ,
631629 } ;
632630 nums. push ( num) ;
@@ -709,7 +707,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
709707 let iter = ( 0 ..subs. len ( ) ) . map ( info_for_child_n) ;
710708 TimelockInfo :: combine_threshold ( 1 , iter)
711709 }
712- Threshold ( ref k, subs) => {
710+ Thresh ( ref k, subs) => {
713711 let iter = ( 0 ..subs. len ( ) ) . map ( info_for_child_n) ;
714712 TimelockInfo :: combine_threshold ( * k, iter)
715713 }
@@ -745,7 +743,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
745743 return Err ( PolicyError :: NonBinaryArgOr ) ;
746744 }
747745 }
748- Threshold ( k, ref subs) => {
746+ Thresh ( k, ref subs) => {
749747 if k == 0 || k > subs. len ( ) {
750748 return Err ( PolicyError :: IncorrectThresh ) ;
751749 }
@@ -789,7 +787,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
789787 } ) ;
790788 ( all_safe, atleast_one_safe && all_non_mall)
791789 }
792- Threshold ( k, ref subs) => {
790+ Thresh ( k, ref subs) => {
793791 let ( safe_count, non_mall_count) = ( 0 ..subs. len ( ) ) . map ( acc_for_child_n) . fold (
794792 ( 0 , 0 ) ,
795793 |( safe_count, non_mall_count) , ( safe, non_mall) | {
@@ -841,7 +839,7 @@ impl<Pk: MiniscriptKey> fmt::Debug for Policy<Pk> {
841839 }
842840 f. write_str ( ")" )
843841 }
844- Policy :: Threshold ( k, ref subs) => {
842+ Policy :: Thresh ( k, ref subs) => {
845843 write ! ( f, "thresh({}" , k) ?;
846844 for sub in subs {
847845 write ! ( f, ",{:?}" , sub) ?;
@@ -884,7 +882,7 @@ impl<Pk: MiniscriptKey> fmt::Display 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) ?;
@@ -999,7 +997,7 @@ impl<Pk: FromStrKey> Policy<Pk> {
999997 for arg in & top. args [ 1 ..] {
1000998 subs. push ( Policy :: from_tree ( arg) ?) ;
1001999 }
1002- Ok ( Policy :: Threshold ( thresh as usize , subs. into_iter ( ) . map ( Arc :: new) . collect ( ) ) )
1000+ Ok ( Policy :: Thresh ( thresh as usize , subs. into_iter ( ) . map ( Arc :: new) . collect ( ) ) )
10031001 }
10041002 _ => Err ( errstr ( top. name ) ) ,
10051003 }
@@ -1041,7 +1039,7 @@ fn with_huffman_tree<Pk: MiniscriptKey>(
10411039 Ok ( node)
10421040}
10431041
1044- /// Enumerates a [`Policy::Threshold (k, ..n..)`] into `n` different thresh's.
1042+ /// Enumerates a [`Policy::Thresh (k, ..n..)`] into `n` different thresh's.
10451043///
10461044/// ## Strategy
10471045///
@@ -1063,7 +1061,7 @@ fn generate_combination<Pk: MiniscriptKey>(
10631061 . enumerate ( )
10641062 . filter_map ( |( j, sub) | if j != i { Some ( Arc :: clone ( sub) ) } else { None } )
10651063 . collect ( ) ;
1066- ret. push ( ( prob / policy_vec. len ( ) as f64 , Arc :: new ( Policy :: Threshold ( k, policies) ) ) ) ;
1064+ ret. push ( ( prob / policy_vec. len ( ) as f64 , Arc :: new ( Policy :: Thresh ( k, policies) ) ) ) ;
10671065 }
10681066 ret
10691067}
@@ -1077,7 +1075,7 @@ impl<'a, Pk: MiniscriptKey> TreeLike for &'a Policy<Pk> {
10771075 | Ripemd160 ( _) | Hash160 ( _) => Tree :: Nullary ,
10781076 And ( ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: as_ref) . collect ( ) ) ,
10791077 Or ( ref v) => Tree :: Nary ( v. iter ( ) . map ( |( _, p) | p. as_ref ( ) ) . collect ( ) ) ,
1080- Threshold ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: as_ref) . collect ( ) ) ,
1078+ Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: as_ref) . collect ( ) ) ,
10811079 }
10821080 }
10831081}
@@ -1091,7 +1089,7 @@ impl<Pk: MiniscriptKey> TreeLike for Arc<Policy<Pk>> {
10911089 | Ripemd160 ( _) | Hash160 ( _) => Tree :: Nullary ,
10921090 And ( ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: clone) . collect ( ) ) ,
10931091 Or ( ref v) => Tree :: Nary ( v. iter ( ) . map ( |( _, p) | Arc :: clone ( p) ) . collect ( ) ) ,
1094- Threshold ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: clone) . collect ( ) ) ,
1092+ Thresh ( _, ref subs) => Tree :: Nary ( subs. iter ( ) . map ( Arc :: clone) . collect ( ) ) ,
10951093 }
10961094 }
10971095}
@@ -1137,10 +1135,7 @@ mod compiler_tests {
11371135 . map ( |sub_pol| {
11381136 (
11391137 0.25 ,
1140- Arc :: new ( Policy :: Threshold (
1141- 2 ,
1142- sub_pol. into_iter ( ) . map ( |p| Arc :: new ( p) ) . collect ( ) ,
1143- ) ) ,
1138+ Arc :: new ( Policy :: Thresh ( 2 , sub_pol. into_iter ( ) . map ( |p| Arc :: new ( p) ) . collect ( ) ) ) ,
11441139 )
11451140 } )
11461141 . collect :: < Vec < _ > > ( ) ;
0 commit comments