@@ -1073,7 +1073,8 @@ impl Node {
1073
1073
}
1074
1074
}
1075
1075
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.
1077
1078
///
1078
1079
/// **Note:** The wallets are regularly synced in the background, which is configurable via
1079
1080
/// [`Config::onchain_wallet_sync_interval_secs`] and [`Config::wallet_sync_interval_secs`].
@@ -1091,6 +1092,7 @@ impl Node {
1091
1092
let archive_cman = Arc :: clone ( & self . channel_manager ) ;
1092
1093
let sync_cmon = Arc :: clone ( & self . chain_monitor ) ;
1093
1094
let archive_cmon = Arc :: clone ( & self . chain_monitor ) ;
1095
+ let fee_estimator = Arc :: clone ( & self . fee_estimator ) ;
1094
1096
let sync_sweeper = Arc :: clone ( & self . output_sweeper ) ;
1095
1097
let sync_logger = Arc :: clone ( & self . logger ) ;
1096
1098
let confirmables = vec ! [
@@ -1099,6 +1101,8 @@ impl Node {
1099
1101
& * sync_sweeper as & ( dyn Confirm + Sync + Send ) ,
1100
1102
] ;
1101
1103
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 ) ;
1102
1106
let sync_onchain_wallet_timestamp = Arc :: clone ( & self . latest_onchain_wallet_sync_timestamp ) ;
1103
1107
let sync_monitor_archival_height = Arc :: clone ( & self . latest_channel_monitor_archival_height ) ;
1104
1108
@@ -1125,6 +1129,26 @@ impl Node {
1125
1129
} ,
1126
1130
} ;
1127
1131
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
+
1128
1152
let now = Instant :: now ( ) ;
1129
1153
match tx_sync. sync ( confirmables) . await {
1130
1154
Ok ( ( ) ) => {
0 commit comments