1
+ use crate :: archive:: download_stacks_dataset_if_required;
1
2
use crate :: block:: DigestingCommand ;
2
3
use crate :: config:: generator:: generate_config;
3
4
use crate :: config:: { Config , PredicatesApi } ;
@@ -238,6 +239,9 @@ enum StacksDbCommand {
238
239
/// Check integrity
239
240
#[ clap( name = "check" , bin_name = "check" ) ]
240
241
Check ( CheckDbCommand ) ,
242
+ /// Update database using latest Stacks archive file
243
+ #[ clap( name = "update" , bin_name = "update" ) ]
244
+ Update ( UpdateDbCommand ) ,
241
245
}
242
246
243
247
#[ derive( Subcommand , PartialEq , Clone , Debug ) ]
@@ -374,6 +378,13 @@ struct CheckDbCommand {
374
378
pub config_path : Option < String > ,
375
379
}
376
380
381
+ #[ derive( Parser , PartialEq , Clone , Debug ) ]
382
+ struct UpdateDbCommand {
383
+ /// Load config file path
384
+ #[ clap( long = "config-path" ) ]
385
+ pub config_path : Option < String > ,
386
+ }
387
+
377
388
#[ derive( Parser , PartialEq , Clone , Debug ) ]
378
389
struct InitHordDbCommand {
379
390
/// Load config file path
@@ -869,6 +880,10 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
869
880
unimplemented ! ( )
870
881
}
871
882
} ,
883
+ Command :: Stacks ( StacksCommand :: Db ( StacksDbCommand :: Update ( cmd) ) ) => {
884
+ let mut config = Config :: default ( false , false , false , & cmd. config_path ) ?;
885
+ download_stacks_dataset_if_required ( & mut config, & ctx) . await ;
886
+ }
872
887
Command :: Stacks ( StacksCommand :: Db ( StacksDbCommand :: Check ( cmd) ) ) => {
873
888
let config = Config :: default ( false , false , false , & cmd. config_path ) ?;
874
889
// Delete data, if any
@@ -891,7 +906,10 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
891
906
}
892
907
}
893
908
if missing_blocks. is_empty ( ) {
894
- info ! ( ctx. expect_logger( ) , "Stacks db successfully checked ({min}, {max})" ) ;
909
+ info ! (
910
+ ctx. expect_logger( ) ,
911
+ "Stacks db successfully checked ({min}, {max})"
912
+ ) ;
895
913
} else {
896
914
warn ! (
897
915
ctx. expect_logger( ) ,
0 commit comments