@@ -27,9 +27,9 @@ pub const BITCOIN_MAX_PREDICATE_REGISTRATION: usize = 50;
27
27
pub struct Config {
28
28
pub storage : StorageConfig ,
29
29
pub http_api : PredicatesApi ,
30
- pub event_sources : Vec < EventSourceConfig > ,
31
30
pub limits : LimitsConfig ,
32
31
pub network : IndexerConfig ,
32
+ pub bootstrap : BootstrapConfig ,
33
33
pub logs : LogConfig ,
34
34
}
35
35
@@ -58,9 +58,9 @@ pub struct PredicatesApiConfig {
58
58
}
59
59
60
60
#[ derive( Clone , Debug ) ]
61
- pub enum EventSourceConfig {
62
- OrdinalsSqlitePath ( PathConfig ) ,
63
- OrdinalsSqliteUrl ( UrlConfig ) ,
61
+ pub enum BootstrapConfig {
62
+ Build ,
63
+ Download ( String ) ,
64
64
}
65
65
66
66
#[ derive( Clone , Debug ) ]
@@ -152,21 +152,13 @@ impl Config {
152
152
_ => return Err ( "network.mode not supported" . to_string ( ) ) ,
153
153
} ;
154
154
155
- let mut event_sources = vec ! [ ] ;
156
- for source in config_file. event_source . unwrap_or ( vec ! [ ] ) . iter_mut ( ) {
157
- if let Some ( dst) = source. tsv_file_path . take ( ) {
158
- let mut file_path = PathBuf :: new ( ) ;
159
- file_path. push ( dst) ;
160
- event_sources. push ( EventSourceConfig :: OrdinalsSqlitePath ( PathConfig {
161
- file_path,
162
- } ) ) ;
163
- continue ;
155
+ let bootstrap = match config_file. bootstrap {
156
+ Some ( bootstrap) => match bootstrap. download_url {
157
+ Some ( ref url) => BootstrapConfig :: Download ( url. to_string ( ) ) ,
158
+ None => BootstrapConfig :: Build
164
159
}
165
- if let Some ( file_url) = source. tsv_file_url . take ( ) {
166
- event_sources. push ( EventSourceConfig :: OrdinalsSqliteUrl ( UrlConfig { file_url } ) ) ;
167
- continue ;
168
- }
169
- }
160
+ None => BootstrapConfig :: Build
161
+ } ;
170
162
171
163
let config = Config {
172
164
storage : StorageConfig {
@@ -185,7 +177,7 @@ impl Config {
185
177
} ) ,
186
178
} ,
187
179
} ,
188
- event_sources ,
180
+ bootstrap ,
189
181
limits : LimitsConfig {
190
182
max_number_of_stacks_predicates : config_file
191
183
. limits
@@ -248,28 +240,11 @@ impl Config {
248
240
Ok ( config)
249
241
}
250
242
251
- pub fn is_initial_ingestion_required ( & self ) -> bool {
252
- for source in self . event_sources . iter ( ) {
253
- match source {
254
- EventSourceConfig :: OrdinalsSqlitePath ( _)
255
- | EventSourceConfig :: OrdinalsSqliteUrl ( _) => return true ,
256
- }
243
+ pub fn should_bootstrap_through_download ( & self ) -> bool {
244
+ match & self . bootstrap {
245
+ BootstrapConfig :: Build => false ,
246
+ BootstrapConfig :: Download ( _) => true
257
247
}
258
- return false ;
259
- }
260
-
261
- pub fn add_ordinals_sqlite_remote_source_url ( & mut self , file_url : & str ) {
262
- self . event_sources
263
- . push ( EventSourceConfig :: OrdinalsSqliteUrl ( UrlConfig {
264
- file_url : file_url. to_string ( ) ,
265
- } ) ) ;
266
- }
267
-
268
- pub fn add_local_ordinals_sqlite_source ( & mut self , file_path : & PathBuf ) {
269
- self . event_sources
270
- . push ( EventSourceConfig :: OrdinalsSqlitePath ( PathConfig {
271
- file_path : file_path. clone ( ) ,
272
- } ) ) ;
273
248
}
274
249
275
250
pub fn expected_api_database_uri ( & self ) -> & str {
@@ -289,13 +264,11 @@ impl Config {
289
264
destination_path
290
265
}
291
266
292
- fn expected_remote_ordinals_sqlite_base_url ( & self ) -> & String {
293
- for source in self . event_sources . iter ( ) {
294
- if let EventSourceConfig :: OrdinalsSqliteUrl ( config) = source {
295
- return & config. file_url ;
296
- }
267
+ fn expected_remote_ordinals_sqlite_base_url ( & self ) -> & str {
268
+ match & self . bootstrap {
269
+ BootstrapConfig :: Build => unreachable ! ( ) ,
270
+ BootstrapConfig :: Download ( url) => & url
297
271
}
298
- panic ! ( "expected remote-tsv source" )
299
272
}
300
273
301
274
pub fn expected_remote_ordinals_sqlite_sha256 ( & self ) -> String {
@@ -306,29 +279,6 @@ impl Config {
306
279
format ! ( "{}.gz" , self . expected_remote_ordinals_sqlite_base_url( ) )
307
280
}
308
281
309
- pub fn rely_on_remote_ordinals_sqlite ( & self ) -> bool {
310
- for source in self . event_sources . iter ( ) {
311
- if let EventSourceConfig :: OrdinalsSqliteUrl ( _config) = source {
312
- return true ;
313
- }
314
- }
315
- false
316
- }
317
-
318
- pub fn should_download_remote_ordinals_sqlite ( & self ) -> bool {
319
- let mut rely_on_remote_tsv = false ;
320
- let mut remote_tsv_present_locally = false ;
321
- for source in self . event_sources . iter ( ) {
322
- if let EventSourceConfig :: OrdinalsSqliteUrl ( _config) = source {
323
- rely_on_remote_tsv = true ;
324
- }
325
- if let EventSourceConfig :: OrdinalsSqlitePath ( _config) = source {
326
- remote_tsv_present_locally = true ;
327
- }
328
- }
329
- rely_on_remote_tsv == true && remote_tsv_present_locally == false
330
- }
331
-
332
282
pub fn default (
333
283
devnet : bool ,
334
284
testnet : bool ,
@@ -351,7 +301,7 @@ impl Config {
351
301
working_dir : default_cache_path ( ) ,
352
302
} ,
353
303
http_api : PredicatesApi :: Off ,
354
- event_sources : vec ! [ ] ,
304
+ bootstrap : BootstrapConfig :: Build ,
355
305
limits : LimitsConfig {
356
306
max_number_of_bitcoin_predicates : BITCOIN_MAX_PREDICATE_REGISTRATION ,
357
307
max_number_of_concurrent_bitcoin_scans : BITCOIN_SCAN_THREAD_POOL_SIZE ,
@@ -384,7 +334,7 @@ impl Config {
384
334
working_dir : default_cache_path ( ) ,
385
335
} ,
386
336
http_api : PredicatesApi :: Off ,
387
- event_sources : vec ! [ ] ,
337
+ bootstrap : BootstrapConfig :: Build ,
388
338
limits : LimitsConfig {
389
339
max_number_of_bitcoin_predicates : BITCOIN_MAX_PREDICATE_REGISTRATION ,
390
340
max_number_of_concurrent_bitcoin_scans : BITCOIN_SCAN_THREAD_POOL_SIZE ,
@@ -417,9 +367,7 @@ impl Config {
417
367
working_dir : default_cache_path ( ) ,
418
368
} ,
419
369
http_api : PredicatesApi :: Off ,
420
- event_sources : vec ! [ EventSourceConfig :: OrdinalsSqliteUrl ( UrlConfig {
421
- file_url: DEFAULT_MAINNET_ORDINALS_SQLITE_ARCHIVE . into( ) ,
422
- } ) ] ,
370
+ bootstrap : BootstrapConfig :: Download ( DEFAULT_MAINNET_ORDINALS_SQLITE_ARCHIVE . to_string ( ) ) ,
423
371
limits : LimitsConfig {
424
372
max_number_of_bitcoin_predicates : BITCOIN_MAX_PREDICATE_REGISTRATION ,
425
373
max_number_of_concurrent_bitcoin_scans : BITCOIN_SCAN_THREAD_POOL_SIZE ,
0 commit comments