@@ -33,19 +33,11 @@ pub struct BitcoindClient {
33
33
port : u16 ,
34
34
rpc_user : String ,
35
35
rpc_password : String ,
36
- fees : Arc < HashMap < Target , AtomicU32 > > ,
36
+ fees : Arc < HashMap < ConfirmationTarget , AtomicU32 > > ,
37
37
handle : tokio:: runtime:: Handle ,
38
38
logger : Arc < FilesystemLogger > ,
39
39
}
40
40
41
- #[ derive( Clone , Eq , Hash , PartialEq ) ]
42
- pub enum Target {
43
- MempoolMinimum ,
44
- Background ,
45
- Normal ,
46
- HighPriority ,
47
- }
48
-
49
41
impl BlockSource for BitcoindClient {
50
42
fn get_header < ' a > (
51
43
& ' a self , header_hash : & ' a BlockHash , height_hint : Option < u32 > ,
@@ -83,11 +75,11 @@ impl BitcoindClient {
83
75
std:: io:: Error :: new ( std:: io:: ErrorKind :: PermissionDenied ,
84
76
"Failed to make initial call to bitcoind - please check your RPC user/password and access settings" )
85
77
} ) ?;
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 ) ) ;
91
83
let client = Self {
92
84
bitcoind_rpc_client : Arc :: new ( bitcoind_rpc_client) ,
93
85
host,
@@ -107,7 +99,7 @@ impl BitcoindClient {
107
99
}
108
100
109
101
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 > ,
111
103
handle : tokio:: runtime:: Handle ,
112
104
) {
113
105
handle. spawn ( async move {
@@ -171,14 +163,16 @@ impl BitcoindClient {
171
163
}
172
164
} ;
173
165
174
- fees. get ( & Target :: MempoolMinimum )
166
+ fees. get ( & ConfirmationTarget :: MempoolMinimum )
175
167
. unwrap ( )
176
168
. store ( mempoolmin_estimate, Ordering :: Release ) ;
177
- fees. get ( & Target :: Background )
169
+ fees. get ( & ConfirmationTarget :: Background )
178
170
. unwrap ( )
179
171
. 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 )
182
176
. unwrap ( )
183
177
. store ( high_prio_estimate, Ordering :: Release ) ;
184
178
tokio:: time:: sleep ( Duration :: from_secs ( 60 ) ) . await ;
@@ -267,20 +261,7 @@ impl BitcoindClient {
267
261
268
262
impl FeeEstimator for BitcoindClient {
269
263
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 )
284
265
}
285
266
}
286
267
0 commit comments