@@ -84,6 +84,9 @@ enum ConfigSub {
8484 /// path to libra config and data files defaults to $HOME/.libra
8585 #[ clap( long) ]
8686 home_path : Option < PathBuf > ,
87+ /// optional, whether to use archive mode (full history) or fast sync mode
88+ #[ clap( long) ]
89+ archive_mode : Option < bool > ,
8790 } ,
8891}
8992
@@ -209,20 +212,28 @@ impl ConfigCli {
209212 }
210213
211214 // Initialize fullnode configuration
212- Some ( ConfigSub :: FullnodeInit { home_path } ) => {
213- download_genesis ( home_path. to_owned ( ) ) . await ?;
214- println ! ( "downloaded genesis block" ) ;
215- let sync_options = vec ! [ "Fast Sync (default)" , "Archive (full history)" ] ;
216- let selection = Select :: new ( )
217- . with_prompt ( "choose fullnode sync mode" )
218- . default ( 0 )
219- . items ( & sync_options)
220- . interact ( ) ?;
215+ Some ( ConfigSub :: FullnodeInit {
216+ home_path,
217+ archive_mode,
218+ } ) => {
219+ let archive = archive_mode. unwrap_or_else ( || {
220+ let sync_options = vec ! [ "Fast Sync (default)" , "Archive (full history)" ] ;
221221
222- let archive_mode = selection != 0 ;
222+ let selection = Select :: new ( )
223+ . with_prompt ( "choose fullnode sync mode" )
224+ . default ( 0 )
225+ . items ( & sync_options)
226+ . interact ( )
227+ . expect ( "user did not select sync mode" ) ;
228+
229+ selection != 0
230+ } ) ;
231+
232+ println ! ( "downloading genesis block" ) ;
233+ download_genesis ( home_path. to_owned ( ) ) . await ?;
223234
224235 // You can now use `archive_mode` to configure the fullnode accordingly.
225- let p = init_fullnode_yaml ( home_path. to_owned ( ) , true , archive_mode ) . await ?;
236+ let p = init_fullnode_yaml ( home_path. to_owned ( ) , true , archive ) . await ?;
226237
227238 println ! ( "config created at {}" , p. display( ) ) ;
228239
0 commit comments