@@ -304,18 +304,18 @@ impl ChainSource {
304304 channel_manager : Arc < ChannelManager > , chain_monitor : Arc < ChainMonitor > ,
305305 output_sweeper : Arc < Sweeper > ,
306306 ) {
307- match self {
308- Self :: Esplora { sync_config , logger, .. } => {
307+ macro_rules! start_tx_based_sync_loop {
308+ ( $sync_config : expr , $ logger: expr ) => { {
309309 // Setup syncing intervals
310- let onchain_wallet_sync_interval_secs = sync_config
310+ let onchain_wallet_sync_interval_secs = $ sync_config
311311 . onchain_wallet_sync_interval_secs
312312 . max( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
313313 let mut onchain_wallet_sync_interval =
314314 tokio:: time:: interval( Duration :: from_secs( onchain_wallet_sync_interval_secs) ) ;
315315 onchain_wallet_sync_interval
316316 . set_missed_tick_behavior( tokio:: time:: MissedTickBehavior :: Skip ) ;
317317
318- let fee_rate_cache_update_interval_secs = sync_config
318+ let fee_rate_cache_update_interval_secs = $ sync_config
319319 . fee_rate_cache_update_interval_secs
320320 . max( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
321321 let mut fee_rate_update_interval =
@@ -325,7 +325,7 @@ impl ChainSource {
325325 fee_rate_update_interval
326326 . set_missed_tick_behavior( tokio:: time:: MissedTickBehavior :: Skip ) ;
327327
328- let lightning_wallet_sync_interval_secs = sync_config
328+ let lightning_wallet_sync_interval_secs = $ sync_config
329329 . lightning_wallet_sync_interval_secs
330330 . max( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
331331 let mut lightning_wallet_sync_interval =
@@ -338,9 +338,9 @@ impl ChainSource {
338338 tokio:: select! {
339339 _ = stop_sync_receiver. changed( ) => {
340340 log_trace!(
341- logger,
341+ $ logger,
342342 "Stopping background syncing on-chain wallet." ,
343- ) ;
343+ ) ;
344344 return ;
345345 }
346346 _ = onchain_wallet_sync_interval. tick( ) => {
@@ -354,12 +354,20 @@ impl ChainSource {
354354 Arc :: clone( & channel_manager) ,
355355 Arc :: clone( & chain_monitor) ,
356356 Arc :: clone( & output_sweeper) ,
357- ) . await ;
357+ ) . await ;
358358 }
359359 }
360360 }
361+ } } ;
362+ }
363+
364+ match self {
365+ Self :: Esplora { sync_config, logger, .. } => {
366+ start_tx_based_sync_loop ! ( sync_config, logger)
367+ } ,
368+ Self :: Electrum { sync_config, logger, .. } => {
369+ start_tx_based_sync_loop ! ( sync_config, logger)
361370 } ,
362- Self :: Electrum { .. } => todo ! ( ) ,
363371 Self :: BitcoindRpc {
364372 bitcoind_rpc_client,
365373 header_cache,
0 commit comments