@@ -1073,7 +1073,8 @@ impl Node {
10731073 }
10741074 }
10751075
1076- /// Manually sync the LDK and BDK wallets with the current chain state.
1076+ /// Manually sync the LDK and BDK wallets with the current chain state and update the fee rate
1077+ /// cache.
10771078 ///
10781079 /// **Note:** The wallets are regularly synced in the background, which is configurable via
10791080 /// [`Config::onchain_wallet_sync_interval_secs`] and [`Config::wallet_sync_interval_secs`].
@@ -1091,6 +1092,7 @@ impl Node {
10911092 let archive_cman = Arc :: clone ( & self . channel_manager ) ;
10921093 let sync_cmon = Arc :: clone ( & self . chain_monitor ) ;
10931094 let archive_cmon = Arc :: clone ( & self . chain_monitor ) ;
1095+ let fee_estimator = Arc :: clone ( & self . fee_estimator ) ;
10941096 let sync_sweeper = Arc :: clone ( & self . output_sweeper ) ;
10951097 let sync_logger = Arc :: clone ( & self . logger ) ;
10961098 let confirmables = vec ! [
@@ -1099,6 +1101,8 @@ impl Node {
10991101 & * sync_sweeper as & ( dyn Confirm + Sync + Send ) ,
11001102 ] ;
11011103 let sync_wallet_timestamp = Arc :: clone ( & self . latest_wallet_sync_timestamp ) ;
1104+ let sync_fee_rate_update_timestamp =
1105+ Arc :: clone ( & self . latest_fee_rate_cache_update_timestamp ) ;
11021106 let sync_onchain_wallet_timestamp = Arc :: clone ( & self . latest_onchain_wallet_sync_timestamp ) ;
11031107 let sync_monitor_archival_height = Arc :: clone ( & self . latest_channel_monitor_archival_height ) ;
11041108
@@ -1125,6 +1129,26 @@ impl Node {
11251129 } ,
11261130 } ;
11271131
1132+ let now = Instant :: now ( ) ;
1133+ match fee_estimator. update_fee_estimates ( ) . await {
1134+ Ok ( ( ) ) => {
1135+ log_info ! (
1136+ sync_logger,
1137+ "Fee rate cache update finished in {}ms." ,
1138+ now. elapsed( ) . as_millis( )
1139+ ) ;
1140+ let unix_time_secs_opt = SystemTime :: now ( )
1141+ . duration_since ( UNIX_EPOCH )
1142+ . ok ( )
1143+ . map ( |d| d. as_secs ( ) ) ;
1144+ * sync_fee_rate_update_timestamp. write ( ) . unwrap ( ) = unix_time_secs_opt;
1145+ } ,
1146+ Err ( e) => {
1147+ log_error ! ( sync_logger, "Fee rate cache update failed: {}" , e, ) ;
1148+ return Err ( e) ;
1149+ } ,
1150+ }
1151+
11281152 let now = Instant :: now ( ) ;
11291153 match tx_sync. sync ( confirmables) . await {
11301154 Ok ( ( ) ) => {
0 commit comments