66// accordance with one or both of these licenses.
77
88use crate :: config:: {
9- Config , BDK_CLIENT_CONCURRENCY , BDK_CLIENT_STOP_GAP , BDK_WALLET_SYNC_TIMEOUT_SECS ,
10- FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS , LDK_WALLET_SYNC_TIMEOUT_SECS ,
9+ Config , EsploraSyncConfig , BDK_CLIENT_CONCURRENCY , BDK_CLIENT_STOP_GAP ,
10+ BDK_WALLET_SYNC_TIMEOUT_SECS , FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS , LDK_WALLET_SYNC_TIMEOUT_SECS ,
1111 RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL , TX_BROADCAST_TIMEOUT_SECS ,
1212 WALLET_SYNC_INTERVAL_MINIMUM_SECS ,
1313} ;
@@ -96,6 +96,7 @@ impl WalletSyncStatus {
9696
9797pub ( crate ) enum ChainSource {
9898 Esplora {
99+ sync_config : EsploraSyncConfig ,
99100 esplora_client : EsploraAsyncClient ,
100101 onchain_wallet : Arc < Wallet > ,
101102 onchain_wallet_sync_status : Mutex < WalletSyncStatus > ,
@@ -112,9 +113,10 @@ pub(crate) enum ChainSource {
112113
113114impl ChainSource {
114115 pub ( crate ) fn new_esplora (
115- server_url : String , onchain_wallet : Arc < Wallet > , fee_estimator : Arc < OnchainFeeEstimator > ,
116- tx_broadcaster : Arc < Broadcaster > , kv_store : Arc < DynStore > , config : Arc < Config > ,
117- logger : Arc < FilesystemLogger > , node_metrics : Arc < RwLock < NodeMetrics > > ,
116+ server_url : String , sync_config : EsploraSyncConfig , onchain_wallet : Arc < Wallet > ,
117+ fee_estimator : Arc < OnchainFeeEstimator > , tx_broadcaster : Arc < Broadcaster > ,
118+ kv_store : Arc < DynStore > , config : Arc < Config > , logger : Arc < FilesystemLogger > ,
119+ node_metrics : Arc < RwLock < NodeMetrics > > ,
118120 ) -> Self {
119121 let mut client_builder = esplora_client:: Builder :: new ( & server_url) ;
120122 client_builder = client_builder. timeout ( DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS ) ;
@@ -124,6 +126,7 @@ impl ChainSource {
124126 let onchain_wallet_sync_status = Mutex :: new ( WalletSyncStatus :: Completed ) ;
125127 let lightning_wallet_sync_status = Mutex :: new ( WalletSyncStatus :: Completed ) ;
126128 Self :: Esplora {
129+ sync_config,
127130 esplora_client,
128131 onchain_wallet,
129132 onchain_wallet_sync_status,
@@ -144,16 +147,17 @@ impl ChainSource {
144147 output_sweeper : Arc < Sweeper > ,
145148 ) {
146149 match self {
147- Self :: Esplora { config , logger, .. } => {
150+ Self :: Esplora { sync_config , logger, .. } => {
148151 // Setup syncing intervals
149- let onchain_wallet_sync_interval_secs =
150- config. onchain_wallet_sync_interval_secs . max ( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
152+ let onchain_wallet_sync_interval_secs = sync_config
153+ . onchain_wallet_sync_interval_secs
154+ . max ( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
151155 let mut onchain_wallet_sync_interval =
152156 tokio:: time:: interval ( Duration :: from_secs ( onchain_wallet_sync_interval_secs) ) ;
153157 onchain_wallet_sync_interval
154158 . set_missed_tick_behavior ( tokio:: time:: MissedTickBehavior :: Skip ) ;
155159
156- let fee_rate_cache_update_interval_secs = config
160+ let fee_rate_cache_update_interval_secs = sync_config
157161 . fee_rate_cache_update_interval_secs
158162 . max ( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
159163 let mut fee_rate_update_interval =
@@ -163,11 +167,12 @@ impl ChainSource {
163167 fee_rate_update_interval
164168 . set_missed_tick_behavior ( tokio:: time:: MissedTickBehavior :: Skip ) ;
165169
166- let wallet_sync_interval_secs =
167- config. wallet_sync_interval_secs . max ( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
168- let mut wallet_sync_interval =
169- tokio:: time:: interval ( Duration :: from_secs ( wallet_sync_interval_secs) ) ;
170- wallet_sync_interval
170+ let lightning_wallet_sync_interval_secs = sync_config
171+ . lightning_wallet_sync_interval_secs
172+ . max ( WALLET_SYNC_INTERVAL_MINIMUM_SECS ) ;
173+ let mut lightning_wallet_sync_interval =
174+ tokio:: time:: interval ( Duration :: from_secs ( lightning_wallet_sync_interval_secs) ) ;
175+ lightning_wallet_sync_interval
171176 . set_missed_tick_behavior ( tokio:: time:: MissedTickBehavior :: Skip ) ;
172177
173178 // Start the syncing loop.
@@ -186,7 +191,7 @@ impl ChainSource {
186191 _ = fee_rate_update_interval. tick( ) => {
187192 let _ = self . update_fee_rate_estimates( ) . await ;
188193 }
189- _ = wallet_sync_interval . tick( ) => {
194+ _ = lightning_wallet_sync_interval . tick( ) => {
190195 let _ = self . sync_lightning_wallet(
191196 Arc :: clone( & channel_manager) ,
192197 Arc :: clone( & chain_monitor) ,
0 commit comments