Skip to content

Commit accd3c8

Browse files
committed
Also update the fee rate cache in sync_wallets
.. which we previously omitted.
1 parent 9dba3ac commit accd3c8

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,8 @@ impl Node {
11241124
}
11251125
}
11261126

1127-
/// Manually sync the LDK and BDK wallets with the current chain state.
1127+
/// Manually sync the LDK and BDK wallets with the current chain state and update the fee rate
1128+
/// cache.
11281129
///
11291130
/// **Note:** The wallets are regularly synced in the background, which is configurable via
11301131
/// [`Config::onchain_wallet_sync_interval_secs`] and [`Config::wallet_sync_interval_secs`].
@@ -1142,6 +1143,7 @@ impl Node {
11421143
let archive_cman = Arc::clone(&self.channel_manager);
11431144
let sync_cmon = Arc::clone(&self.chain_monitor);
11441145
let archive_cmon = Arc::clone(&self.chain_monitor);
1146+
let fee_estimator = Arc::clone(&self.fee_estimator);
11451147
let sync_sweeper = Arc::clone(&self.output_sweeper);
11461148
let sync_logger = Arc::clone(&self.logger);
11471149
let confirmables = vec![
@@ -1150,6 +1152,8 @@ impl Node {
11501152
&*sync_sweeper as &(dyn Confirm + Sync + Send),
11511153
];
11521154
let sync_wallet_timestamp = Arc::clone(&self.latest_wallet_sync_timestamp);
1155+
let sync_fee_rate_update_timestamp =
1156+
Arc::clone(&self.latest_fee_rate_cache_update_timestamp);
11531157
let sync_onchain_wallet_timestamp = Arc::clone(&self.latest_onchain_wallet_sync_timestamp);
11541158
let sync_monitor_archival_height = Arc::clone(&self.latest_channel_monitor_archival_height);
11551159

@@ -1176,6 +1180,26 @@ impl Node {
11761180
},
11771181
};
11781182

1183+
let now = Instant::now();
1184+
match fee_estimator.update_fee_estimates().await {
1185+
Ok(()) => {
1186+
log_info!(
1187+
sync_logger,
1188+
"Fee rate cache update finished in {}ms.",
1189+
now.elapsed().as_millis()
1190+
);
1191+
let unix_time_secs_opt = SystemTime::now()
1192+
.duration_since(UNIX_EPOCH)
1193+
.ok()
1194+
.map(|d| d.as_secs());
1195+
*sync_fee_rate_update_timestamp.write().unwrap() = unix_time_secs_opt;
1196+
},
1197+
Err(e) => {
1198+
log_error!(sync_logger, "Fee rate cache update failed: {}", e,);
1199+
return Err(e);
1200+
},
1201+
}
1202+
11791203
let now = Instant::now();
11801204
match tx_sync.sync(confirmables).await {
11811205
Ok(()) => {

0 commit comments

Comments
 (0)