|
37 | 37 | } |
38 | 38 |
|
39 | 39 | pub(crate) async fn update_fee_estimates(&self) -> Result<(), Error> { |
| 40 | + let estimates = tokio::time::timeout( |
| 41 | + Duration::from_secs(FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS), |
| 42 | + self.esplora_client.get_fee_estimates(), |
| 43 | + ) |
| 44 | + .await |
| 45 | + .map_err(|e| { |
| 46 | + log_error!(self.logger, "Updating fee rate estimates timed out: {}", e); |
| 47 | + Error::FeerateEstimationUpdateTimeout |
| 48 | + })? |
| 49 | + .map_err(|e| { |
| 50 | + log_error!(self.logger, "Failed to retrieve fee rate estimates: {}", e); |
| 51 | + Error::FeerateEstimationUpdateFailed |
| 52 | + })?; |
| 53 | + |
| 54 | + if estimates.is_empty() && self.config.network == Network::Bitcoin { |
| 55 | + // Ensure we fail if we didn't receive any estimates. |
| 56 | + log_error!( |
| 57 | + self.logger, |
| 58 | + "Failed to retrieve fee rate estimates: empty fee estimates are dissallowed on Mainnet.", |
| 59 | + ); |
| 60 | + return Err(Error::FeerateEstimationUpdateFailed); |
| 61 | + } |
| 62 | + |
40 | 63 | let confirmation_targets = vec![ |
41 | 64 | ConfirmationTarget::OnChainSweep, |
42 | 65 | ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, |
|
57 | 80 | ConfirmationTarget::OutputSpendingFee => 12, |
58 | 81 | }; |
59 | 82 |
|
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| { |
75 | | - log_error!( |
76 | | - self.logger, |
77 | | - "Failed to retrieve fee rate estimates for {:?}: {}", |
78 | | - target, |
79 | | - e |
80 | | - ); |
81 | | - Error::FeerateEstimationUpdateFailed |
82 | | - })?; |
83 | | - |
84 | | - if estimates.is_empty() && self.config.network == Network::Bitcoin { |
85 | | - // Ensure we fail if we didn't receive any estimates. |
86 | | - log_error!( |
87 | | - self.logger, |
88 | | - "Failed to retrieve fee rate estimates for {:?}: empty fee estimates are dissallowed on Mainnet.", |
89 | | - target, |
90 | | - ); |
91 | | - return Err(Error::FeerateEstimationUpdateFailed); |
92 | | - } |
93 | | - |
94 | | - let converted_estimates = esplora_client::convert_fee_rate(num_blocks, estimates) |
95 | | - .map_err(|e| { |
| 83 | + let converted_estimates = |
| 84 | + esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(|e| { |
96 | 85 | log_error!( |
97 | 86 | self.logger, |
98 | 87 | "Failed to convert fee rate estimates for {:?}: {}", |
|
0 commit comments