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