File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ enum NodeError {
156
156
"ChannelConfigUpdateFailed",
157
157
"PersistenceFailed",
158
158
"FeerateEstimationUpdateFailed",
159
+ "FeerateEstimationUpdateTimeout",
159
160
"WalletOperationFailed",
160
161
"WalletOperationTimeout",
161
162
"OnchainTxSigningFailed",
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ pub(crate) const BDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 90;
48
48
// The timeout after which we abort a wallet syncing operation.
49
49
pub ( crate ) const LDK_WALLET_SYNC_TIMEOUT_SECS : u64 = 30 ;
50
50
51
+ // The timeout after which we abort a fee rate cache update operation.
52
+ pub ( crate ) const FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS : u64 = 5 ;
53
+
51
54
// The length in bytes of our wallets' keys seed.
52
55
pub ( crate ) const WALLET_KEYS_SEED_LEN : usize = 64 ;
53
56
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ pub enum Error {
33
33
PersistenceFailed ,
34
34
/// A fee rate estimation update failed.
35
35
FeerateEstimationUpdateFailed ,
36
+ /// A fee rate estimation update timed out.
37
+ FeerateEstimationUpdateTimeout ,
36
38
/// A wallet operation failed.
37
39
WalletOperationFailed ,
38
40
/// A wallet operation timed out.
@@ -111,6 +113,9 @@ impl fmt::Display for Error {
111
113
Self :: FeerateEstimationUpdateFailed => {
112
114
write ! ( f, "Failed to update fee rate estimates." )
113
115
} ,
116
+ Self :: FeerateEstimationUpdateTimeout => {
117
+ write ! ( f, "Updating fee rate estimates timed out." )
118
+ } ,
114
119
Self :: WalletOperationFailed => write ! ( f, "Failed to conduct wallet operation." ) ,
115
120
Self :: WalletOperationTimeout => write ! ( f, "A wallet operation timed out." ) ,
116
121
Self :: OnchainTxSigningFailed => write ! ( f, "Failed to sign given transaction." ) ,
Original file line number Diff line number Diff line change
1
+ use crate :: config:: FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS ;
1
2
use crate :: logger:: { log_error, log_trace, Logger } ;
2
3
use crate :: { Config , Error } ;
3
4
@@ -14,6 +15,7 @@ use bitcoin::Network;
14
15
use std:: collections:: HashMap ;
15
16
use std:: ops:: Deref ;
16
17
use std:: sync:: { Arc , RwLock } ;
18
+ use std:: time:: Duration ;
17
19
18
20
pub ( crate ) struct OnchainFeeEstimator < L : Deref >
19
21
where
55
57
ConfirmationTarget :: OutputSpendingFee => 12 ,
56
58
} ;
57
59
58
- let estimates = self . esplora_client . get_fee_estimates ( ) . await . map_err ( |e| {
60
+ let estimates = tokio:: time:: timeout (
61
+ Duration :: from_secs ( FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS ) ,
62
+ self . esplora_client . get_fee_estimates ( ) ,
63
+ )
64
+ . await
65
+ . map_err ( |e| {
66
+ log_error ! (
67
+ self . logger,
68
+ "Updating fee rate estimates for {:?} timed out: {}" ,
69
+ target,
70
+ e
71
+ ) ;
72
+ Error :: FeerateEstimationUpdateTimeout
73
+ } ) ?
74
+ . map_err ( |e| {
59
75
log_error ! (
60
76
self . logger,
61
77
"Failed to retrieve fee rate estimates for {:?}: {}" ,
You can’t perform that action at this time.
0 commit comments