22
33use std:: net:: SocketAddr ;
44use std:: path:: PathBuf ;
5- use std:: time:: Duration ;
65
76use dashcore:: Network ;
87// Serialization removed due to complex Address types
@@ -41,21 +40,6 @@ pub struct ClientConfig {
4140 /// Validation mode.
4241 pub validation_mode : ValidationMode ,
4342
44- /// BIP157 filter checkpoint interval.
45- pub filter_checkpoint_interval : u32 ,
46-
47- /// Maximum headers per message.
48- pub max_headers_per_message : u32 ,
49-
50- /// Connection timeout.
51- pub connection_timeout : Duration ,
52-
53- /// Message timeout.
54- pub message_timeout : Duration ,
55-
56- /// Sync timeout.
57- pub sync_timeout : Duration ,
58-
5943 /// Whether to enable filter syncing.
6044 pub enable_filters : bool ,
6145
@@ -65,22 +49,13 @@ pub struct ClientConfig {
6549 /// Maximum number of peers to connect to.
6650 pub max_peers : u32 ,
6751
68- /// Whether to persist state to disk.
69- pub enable_persistence : bool ,
70-
7152 /// Log level for tracing.
7253 pub log_level : String ,
7354
7455 /// Optional user agent string to advertise in the P2P version message.
7556 /// If not set, a sensible default is used (includes crate version).
7657 pub user_agent : Option < String > ,
7758
78- /// Maximum concurrent filter requests (default: 8).
79- pub max_concurrent_filter_requests : usize ,
80-
81- /// Delay between filter requests in milliseconds (default: 50).
82- pub filter_request_delay_ms : u64 ,
83-
8459 // Mempool configuration
8560 /// Enable tracking of unconfirmed (mempool) transactions.
8661 pub enable_mempool_tracking : bool ,
@@ -100,58 +75,13 @@ pub struct ClientConfig {
10075 /// Whether to persist mempool transactions.
10176 pub persist_mempool : bool ,
10277
103- // Request control configuration
104- /// Maximum concurrent header requests (default: 1).
105- pub max_concurrent_headers_requests : Option < usize > ,
106-
107- /// Maximum concurrent masternode list requests (default: 1).
108- pub max_concurrent_mnlist_requests : Option < usize > ,
109-
110- /// Maximum concurrent CF header requests (default: 1).
111- pub max_concurrent_cfheaders_requests : Option < usize > ,
112-
113- /// Maximum concurrent block requests (default: 5).
114- pub max_concurrent_block_requests : Option < usize > ,
115-
116- /// Rate limit for header requests per second (default: 10.0).
117- pub headers_request_rate_limit : Option < f64 > ,
118-
119- /// Rate limit for masternode list requests per second (default: 5.0).
120- pub mnlist_request_rate_limit : Option < f64 > ,
121-
122- /// Rate limit for CF header requests per second (default: 10.0).
123- pub cfheaders_request_rate_limit : Option < f64 > ,
124-
125- // CFHeaders flow control configuration
126- /// Maximum concurrent CFHeaders requests for parallel sync (default: 50).
127- pub max_concurrent_cfheaders_requests_parallel : usize ,
128-
129- /// Timeout for CFHeaders requests in seconds (default: 30).
130- pub cfheaders_request_timeout_secs : u64 ,
131-
132- /// Maximum retry attempts for failed CFHeaders batches (default: 3).
133- pub max_cfheaders_retries : u32 ,
134-
135- /// Rate limit for filter requests per second (default: 50.0).
136- pub filters_request_rate_limit : Option < f64 > ,
137-
138- /// Rate limit for block requests per second (default: 10.0).
139- pub blocks_request_rate_limit : Option < f64 > ,
140-
14178 /// Start syncing from a specific block height.
14279 /// The client will use the nearest checkpoint at or before this height.
14380 pub start_from_height : Option < u32 > ,
14481
14582 /// Wallet creation time as Unix timestamp.
14683 /// Used to determine appropriate checkpoint for sync.
14784 pub wallet_creation_time : Option < u32 > ,
148-
149- // QRInfo configuration (simplified per plan)
150- /// Request extra share data in QRInfo (default: false per DMLviewer.patch).
151- pub qr_info_extra_share : bool ,
152-
153- /// Timeout for QRInfo requests (default: 30 seconds).
154- pub qr_info_timeout : Duration ,
15585}
15686
15787impl Default for ClientConfig {
@@ -162,45 +92,20 @@ impl Default for ClientConfig {
16292 restrict_to_configured_peers : false ,
16393 storage_path : None ,
16494 validation_mode : ValidationMode :: Full ,
165- filter_checkpoint_interval : 1000 ,
166- max_headers_per_message : 2000 ,
167- connection_timeout : Duration :: from_secs ( 30 ) ,
168- message_timeout : Duration :: from_secs ( 60 ) ,
169- sync_timeout : Duration :: from_secs ( 300 ) ,
17095 enable_filters : true ,
17196 enable_masternodes : true ,
17297 max_peers : 8 ,
173- enable_persistence : true ,
17498 log_level : "info" . to_string ( ) ,
17599 user_agent : None ,
176- max_concurrent_filter_requests : 16 ,
177- filter_request_delay_ms : 0 ,
178100 // Mempool defaults
179101 enable_mempool_tracking : true ,
180102 mempool_strategy : MempoolStrategy :: FetchAll ,
181103 max_mempool_transactions : 1000 ,
182104 mempool_timeout_secs : 3600 , // 1 hour
183105 fetch_mempool_transactions : true ,
184106 persist_mempool : false ,
185- // Request control defaults
186- max_concurrent_headers_requests : None ,
187- max_concurrent_mnlist_requests : None ,
188- max_concurrent_cfheaders_requests : None ,
189- max_concurrent_block_requests : None ,
190- headers_request_rate_limit : None ,
191- mnlist_request_rate_limit : None ,
192- cfheaders_request_rate_limit : None ,
193- filters_request_rate_limit : None ,
194- blocks_request_rate_limit : None ,
195107 start_from_height : None ,
196108 wallet_creation_time : None ,
197- // CFHeaders flow control defaults
198- max_concurrent_cfheaders_requests_parallel : 50 ,
199- cfheaders_request_timeout_secs : 30 ,
200- max_cfheaders_retries : 3 ,
201- // QRInfo defaults (simplified per plan)
202- qr_info_extra_share : false , // Matches DMLviewer.patch default
203- qr_info_timeout : Duration :: from_secs ( 30 ) ,
204109 }
205110 }
206111}
@@ -246,7 +151,6 @@ impl ClientConfig {
246151 /// Set storage path.
247152 pub fn with_storage_path ( mut self , path : PathBuf ) -> Self {
248153 self . storage_path = Some ( path) ;
249- self . enable_persistence = true ;
250154 self
251155 }
252156
@@ -268,12 +172,6 @@ impl ClientConfig {
268172 self
269173 }
270174
271- /// Set connection timeout.
272- pub fn with_connection_timeout ( mut self , timeout : Duration ) -> Self {
273- self . connection_timeout = timeout;
274- self
275- }
276-
277175 /// Set log level.
278176 pub fn with_log_level ( mut self , level : & str ) -> Self {
279177 self . log_level = level. to_string ( ) ;
@@ -287,18 +185,6 @@ impl ClientConfig {
287185 self
288186 }
289187
290- /// Set maximum concurrent filter requests.
291- pub fn with_max_concurrent_filter_requests ( mut self , max_requests : usize ) -> Self {
292- self . max_concurrent_filter_requests = max_requests;
293- self
294- }
295-
296- /// Set delay between filter requests.
297- pub fn with_filter_request_delay ( mut self , delay_ms : u64 ) -> Self {
298- self . filter_request_delay_ms = delay_ms;
299- self
300- }
301-
302188 /// Enable mempool tracking with specified strategy.
303189 pub fn with_mempool_tracking ( mut self , strategy : MempoolStrategy ) -> Self {
304190 self . enable_mempool_tracking = true ;
@@ -330,38 +216,14 @@ impl ClientConfig {
330216 self
331217 }
332218
333- /// Set whether to request extra share data in QRInfo.
334- pub fn with_qr_info_extra_share ( mut self , enabled : bool ) -> Self {
335- self . qr_info_extra_share = enabled;
336- self
337- }
338-
339- /// Set QRInfo request timeout.
340- pub fn with_qr_info_timeout ( mut self , timeout : Duration ) -> Self {
341- self . qr_info_timeout = timeout;
342- self
343- }
344-
345219 /// Validate the configuration.
346220 pub fn validate ( & self ) -> Result < ( ) , String > {
347221 // Note: Empty peers list is now valid - DNS discovery will be used automatically
348222
349- if self . max_headers_per_message == 0 {
350- return Err ( "max_headers_per_message must be > 0" . to_string ( ) ) ;
351- }
352-
353- if self . filter_checkpoint_interval == 0 {
354- return Err ( "filter_checkpoint_interval must be > 0" . to_string ( ) ) ;
355- }
356-
357223 if self . max_peers == 0 {
358224 return Err ( "max_peers must be > 0" . to_string ( ) ) ;
359225 }
360226
361- if self . max_concurrent_filter_requests == 0 {
362- return Err ( "max_concurrent_filter_requests must be > 0" . to_string ( ) ) ;
363- }
364-
365227 // Mempool validation
366228 if self . enable_mempool_tracking {
367229 if self . max_mempool_transactions == 0 {
0 commit comments