@@ -33,19 +33,11 @@ pub struct BitcoindClient {
3333 port : u16 ,
3434 rpc_user : String ,
3535 rpc_password : String ,
36- fees : Arc < HashMap < Target , AtomicU32 > > ,
36+ fees : Arc < HashMap < ConfirmationTarget , AtomicU32 > > ,
3737 handle : tokio:: runtime:: Handle ,
3838 logger : Arc < FilesystemLogger > ,
3939}
4040
41- #[ derive( Clone , Eq , Hash , PartialEq ) ]
42- pub enum Target {
43- MempoolMinimum ,
44- Background ,
45- Normal ,
46- HighPriority ,
47- }
48-
4941impl BlockSource for BitcoindClient {
5042 fn get_header < ' a > (
5143 & ' a self , header_hash : & ' a BlockHash , height_hint : Option < u32 > ,
@@ -83,11 +75,11 @@ impl BitcoindClient {
8375 std:: io:: Error :: new ( std:: io:: ErrorKind :: PermissionDenied ,
8476 "Failed to make initial call to bitcoind - please check your RPC user/password and access settings" )
8577 } ) ?;
86- let mut fees: HashMap < Target , AtomicU32 > = HashMap :: new ( ) ;
87- fees. insert ( Target :: MempoolMinimum , AtomicU32 :: new ( MIN_FEERATE ) ) ;
88- fees. insert ( Target :: Background , AtomicU32 :: new ( MIN_FEERATE ) ) ;
89- fees. insert ( Target :: Normal , AtomicU32 :: new ( 2000 ) ) ;
90- fees. insert ( Target :: HighPriority , AtomicU32 :: new ( 5000 ) ) ;
78+ let mut fees: HashMap < ConfirmationTarget , AtomicU32 > = HashMap :: new ( ) ;
79+ fees. insert ( ConfirmationTarget :: MempoolMinimum , AtomicU32 :: new ( MIN_FEERATE ) ) ;
80+ fees. insert ( ConfirmationTarget :: Background , AtomicU32 :: new ( MIN_FEERATE ) ) ;
81+ fees. insert ( ConfirmationTarget :: Normal , AtomicU32 :: new ( 2000 ) ) ;
82+ fees. insert ( ConfirmationTarget :: HighPriority , AtomicU32 :: new ( 5000 ) ) ;
9183 let client = Self {
9284 bitcoind_rpc_client : Arc :: new ( bitcoind_rpc_client) ,
9385 host,
@@ -107,7 +99,7 @@ impl BitcoindClient {
10799 }
108100
109101 fn poll_for_fee_estimates (
110- fees : Arc < HashMap < Target , AtomicU32 > > , rpc_client : Arc < RpcClient > ,
102+ fees : Arc < HashMap < ConfirmationTarget , AtomicU32 > > , rpc_client : Arc < RpcClient > ,
111103 handle : tokio:: runtime:: Handle ,
112104 ) {
113105 handle. spawn ( async move {
@@ -171,14 +163,16 @@ impl BitcoindClient {
171163 }
172164 } ;
173165
174- fees. get ( & Target :: MempoolMinimum )
166+ fees. get ( & ConfirmationTarget :: MempoolMinimum )
175167 . unwrap ( )
176168 . store ( mempoolmin_estimate, Ordering :: Release ) ;
177- fees. get ( & Target :: Background )
169+ fees. get ( & ConfirmationTarget :: Background )
178170 . unwrap ( )
179171 . store ( background_estimate, Ordering :: Release ) ;
180- fees. get ( & Target :: Normal ) . unwrap ( ) . store ( normal_estimate, Ordering :: Release ) ;
181- fees. get ( & Target :: HighPriority )
172+ fees. get ( & ConfirmationTarget :: Normal )
173+ . unwrap ( )
174+ . store ( normal_estimate, Ordering :: Release ) ;
175+ fees. get ( & ConfirmationTarget :: HighPriority )
182176 . unwrap ( )
183177 . store ( high_prio_estimate, Ordering :: Release ) ;
184178 tokio:: time:: sleep ( Duration :: from_secs ( 60 ) ) . await ;
@@ -267,20 +261,7 @@ impl BitcoindClient {
267261
268262impl FeeEstimator for BitcoindClient {
269263 fn get_est_sat_per_1000_weight ( & self , confirmation_target : ConfirmationTarget ) -> u32 {
270- match confirmation_target {
271- ConfirmationTarget :: MempoolMinimum => {
272- self . fees . get ( & Target :: MempoolMinimum ) . unwrap ( ) . load ( Ordering :: Acquire )
273- }
274- ConfirmationTarget :: Background => {
275- self . fees . get ( & Target :: Background ) . unwrap ( ) . load ( Ordering :: Acquire )
276- }
277- ConfirmationTarget :: Normal => {
278- self . fees . get ( & Target :: Normal ) . unwrap ( ) . load ( Ordering :: Acquire )
279- }
280- ConfirmationTarget :: HighPriority => {
281- self . fees . get ( & Target :: HighPriority ) . unwrap ( ) . load ( Ordering :: Acquire )
282- }
283- }
264+ self . fees . get ( & confirmation_target) . unwrap ( ) . load ( Ordering :: Acquire )
284265 }
285266}
286267
0 commit comments