Skip to content

Commit 8bd7f4d

Browse files
authored
Merge pull request #631 from moisesPompilio/issue-520
Avoid unnecessary fee_rate updates by checking last_best_block_hash
2 parents 65f49af + 02c2663 commit 8bd7f4d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/chain/bitcoind.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ impl BitcoindChainSource {
261261
log_info!(self.logger, "Starting continuous polling for chain updates.");
262262

263263
// Start the polling loop.
264+
let mut last_best_block_hash = None;
264265
loop {
265266
tokio::select! {
266267
_ = stop_sync_receiver.changed() => {
@@ -278,7 +279,12 @@ impl BitcoindChainSource {
278279
).await;
279280
}
280281
_ = fee_rate_update_interval.tick() => {
281-
let _ = self.update_fee_rate_estimates().await;
282+
if last_best_block_hash != Some(channel_manager.current_best_block().block_hash) {
283+
let update_res = self.update_fee_rate_estimates().await;
284+
if update_res.is_ok() {
285+
last_best_block_hash = Some(channel_manager.current_best_block().block_hash);
286+
}
287+
}
282288
}
283289
}
284290
}

0 commit comments

Comments
 (0)