From 02c2663715041a6c04e0627f7095d981505d37af Mon Sep 17 00:00:00 2001 From: moisesPomilio <93723302+moisesPompilio@users.noreply.github.com> Date: Tue, 9 Sep 2025 10:24:53 -0300 Subject: [PATCH] Check last_best_block_hash before updating fee_rate to avoid unnecessary updates Close #520 --- src/chain/bitcoind.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/chain/bitcoind.rs b/src/chain/bitcoind.rs index c282a6141..a808f6294 100644 --- a/src/chain/bitcoind.rs +++ b/src/chain/bitcoind.rs @@ -261,6 +261,7 @@ impl BitcoindChainSource { log_info!(self.logger, "Starting continuous polling for chain updates."); // Start the polling loop. + let mut last_best_block_hash = None; loop { tokio::select! { _ = stop_sync_receiver.changed() => { @@ -278,7 +279,12 @@ impl BitcoindChainSource { ).await; } _ = fee_rate_update_interval.tick() => { - let _ = self.update_fee_rate_estimates().await; + if last_best_block_hash != Some(channel_manager.current_best_block().block_hash) { + let update_res = self.update_fee_rate_estimates().await; + if update_res.is_ok() { + last_best_block_hash = Some(channel_manager.current_best_block().block_hash); + } + } } } }