File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -88,17 +88,15 @@ pub use r#async::AsyncClient;
88
88
89
89
/// Get a fee value in sats/vbytes from the estimates
90
90
/// that matches the confirmation target set as parameter.
91
- pub fn convert_fee_rate ( target : usize , estimates : HashMap < u16 , f64 > ) -> Result < f32 , Error > {
92
- let fee_val = {
93
- let mut pairs = estimates. into_iter ( ) . collect :: < Vec < ( u16 , f64 ) > > ( ) ;
94
- pairs. sort_unstable_by_key ( |( k, _) | std:: cmp:: Reverse ( * k) ) ;
95
- pairs
96
- . into_iter ( )
97
- . find ( |( k, _) | * k as usize <= target)
98
- . map ( |( _, v) | v)
99
- . unwrap_or ( 1.0 )
100
- } ;
101
- Ok ( fee_val as f32 )
91
+ ///
92
+ /// Returns `None` if no feerate estimate is found at or below `target` confirmations.
93
+ pub fn convert_fee_rate ( target : usize , estimates : HashMap < u16 , f64 > ) -> Option < f32 > {
94
+ let mut pairs = estimates. into_iter ( ) . collect :: < Vec < ( u16 , f64 ) > > ( ) ;
95
+ pairs. sort_unstable_by_key ( |( k, _) | std:: cmp:: Reverse ( * k) ) ;
96
+ pairs
97
+ . into_iter ( )
98
+ . find ( |( k, _) | * k as usize <= target)
99
+ . map ( |( _, v) | v as f32 )
102
100
}
103
101
104
102
#[ derive( Debug , Clone ) ]
You can’t perform that action at this time.
0 commit comments