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 @@ -135,6 +135,7 @@ enum NodeError {
135135 "ChannelConfigUpdateFailed",
136136 "PersistenceFailed",
137137 "FeerateEstimationUpdateFailed",
138+ "FeerateEstimationUpdateTimeout",
138139 "WalletOperationFailed",
139140 "WalletOperationTimeout",
140141 "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;
4848// The timeout after which we abort a wallet syncing operation.
4949pub ( crate ) const LDK_WALLET_SYNC_TIMEOUT_SECS : u64 = 30 ;
5050
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+
5154// The length in bytes of our wallets' keys seed.
5255pub ( crate ) const WALLET_KEYS_SEED_LEN : usize = 64 ;
5356
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ pub enum Error {
2727 PersistenceFailed ,
2828 /// A fee rate estimation update failed.
2929 FeerateEstimationUpdateFailed ,
30+ /// A fee rate estimation update timed out.
31+ FeerateEstimationUpdateTimeout ,
3032 /// A wallet operation failed.
3133 WalletOperationFailed ,
3234 /// A wallet operation timed out.
@@ -94,6 +96,9 @@ impl fmt::Display for Error {
9496 Self :: FeerateEstimationUpdateFailed => {
9597 write ! ( f, "Failed to update fee rate estimates." )
9698 } ,
99+ Self :: FeerateEstimationUpdateTimeout => {
100+ write ! ( f, "Updating fee rate estimates timed out." )
101+ } ,
97102 Self :: WalletOperationFailed => write ! ( f, "Failed to conduct wallet operation." ) ,
98103 Self :: WalletOperationTimeout => write ! ( f, "A wallet operation timed out." ) ,
99104 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 ;
12use crate :: logger:: { log_error, log_trace, Logger } ;
23use crate :: { Config , Error } ;
34
@@ -14,6 +15,7 @@ use bitcoin::Network;
1415use std:: collections:: HashMap ;
1516use std:: ops:: Deref ;
1617use std:: sync:: { Arc , RwLock } ;
18+ use std:: time:: Duration ;
1719
1820pub ( crate ) struct OnchainFeeEstimator < L : Deref >
1921where
5557 ConfirmationTarget :: OutputSpendingFee => 12 ,
5658 } ;
5759
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| {
5975 log_error ! (
6076 self . logger,
6177 "Failed to retrieve fee rate estimates for {:?}: {}" ,
You can’t perform that action at this time.
0 commit comments