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