@@ -1124,7 +1124,8 @@ impl Node {
1124
1124
}
1125
1125
}
1126
1126
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.
1128
1129
///
1129
1130
/// **Note:** The wallets are regularly synced in the background, which is configurable via
1130
1131
/// [`Config::onchain_wallet_sync_interval_secs`] and [`Config::wallet_sync_interval_secs`].
@@ -1142,6 +1143,7 @@ impl Node {
1142
1143
let archive_cman = Arc :: clone ( & self . channel_manager ) ;
1143
1144
let sync_cmon = Arc :: clone ( & self . chain_monitor ) ;
1144
1145
let archive_cmon = Arc :: clone ( & self . chain_monitor ) ;
1146
+ let fee_estimator = Arc :: clone ( & self . fee_estimator ) ;
1145
1147
let sync_sweeper = Arc :: clone ( & self . output_sweeper ) ;
1146
1148
let sync_logger = Arc :: clone ( & self . logger ) ;
1147
1149
let confirmables = vec ! [
@@ -1150,6 +1152,8 @@ impl Node {
1150
1152
& * sync_sweeper as & ( dyn Confirm + Sync + Send ) ,
1151
1153
] ;
1152
1154
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 ) ;
1153
1157
let sync_onchain_wallet_timestamp = Arc :: clone ( & self . latest_onchain_wallet_sync_timestamp ) ;
1154
1158
let sync_monitor_archival_height = Arc :: clone ( & self . latest_channel_monitor_archival_height ) ;
1155
1159
@@ -1176,6 +1180,26 @@ impl Node {
1176
1180
} ,
1177
1181
} ;
1178
1182
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
+
1179
1203
let now = Instant :: now ( ) ;
1180
1204
match tx_sync. sync ( confirmables) . await {
1181
1205
Ok ( ( ) ) => {
0 commit comments