@@ -2,9 +2,10 @@ use aptos_config::config::NodeConfig;
22use kestrel:: State ;
33use std:: path:: PathBuf ;
44pub mod rest_api;
5- use anyhow:: Context ;
65use kestrel:: process:: { command:: Command , ProcessOperations } ;
76pub mod runtime;
7+ use crate :: config:: { Config , NodeConfigWrapper } ;
8+ use anyhow:: Context ;
89pub use rest_api:: RestApi ;
910use std:: path:: Path ;
1011
@@ -69,18 +70,23 @@ where
6970 let runtime = R :: try_new ( ) ?;
7071
7172 // create a .debug dir
72- let timestamp = chrono:: Utc :: now ( ) . timestamp_millis ( ) ;
73- let unique_id = uuid:: Uuid :: new_v4 ( ) ;
74- let debug_dir = Path :: new ( ".debug" ) . join ( format ! (
75- "movement-aptos-core-{}-{}" ,
76- timestamp,
77- unique_id. to_string( ) . split( '-' ) . next( ) . unwrap( )
78- ) ) ;
79- std:: fs:: create_dir_all ( debug_dir. clone ( ) )
80- . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?;
73+ let db_dir = if multiprocess {
74+ let timestamp = chrono:: Utc :: now ( ) . timestamp_millis ( ) ;
75+ let unique_id = uuid:: Uuid :: new_v4 ( ) ;
76+ let debug_dir = Path :: new ( ".debug" ) . join ( format ! (
77+ "movement-aptos-core-{}-{}" ,
78+ timestamp,
79+ unique_id. to_string( ) . split( '-' ) . next( ) . unwrap( )
80+ ) ) ;
81+ std:: fs:: create_dir_all ( debug_dir. clone ( ) )
82+ . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?;
83+ debug_dir
84+ } else {
85+ Path :: new ( "" ) . to_path_buf ( )
86+ } ;
8187
8288 let movement_aptos =
83- MovementAptos :: new ( node_config, log_file, runtime, multiprocess, debug_dir ) ;
89+ MovementAptos :: new ( node_config, log_file, runtime, multiprocess, db_dir ) ;
8490 Ok ( movement_aptos)
8591 }
8692
@@ -131,13 +137,21 @@ where
131137 pub ( crate ) async fn run_node_in_process ( & self ) -> Result < ( ) , MovementAptosError > {
132138 // write the config to a file
133139 let config_path = self . workspace . join ( "config.json" ) ;
140+ let config = Config {
141+ node_config : NodeConfigWrapper ( self . node_config . clone ( ) ) ,
142+ log_file : self . log_file . clone ( ) ,
143+ } ;
134144 std:: fs:: write (
135145 config_path. clone ( ) ,
136- serde_json:: to_string ( & self . node_config )
137- . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?,
146+ serde_json:: to_string ( & config) . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?,
138147 )
139148 . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?;
140149
150+ // create node_config data dir
151+ let data_dir = self . node_config . storage . dir . clone ( ) ;
152+ std:: fs:: create_dir_all ( data_dir. clone ( ) )
153+ . map_err ( |e| MovementAptosError :: Internal ( e. into ( ) ) ) ?;
154+
141155 // spawn the node in a new process
142156 let command = Command :: line (
143157 "movement-aptos" ,
@@ -150,7 +164,7 @@ where
150164 . context( "Failed to convert config path to str" )
151165 . map_err( |e| MovementAptosError :: Internal ( e. into( ) ) ) ?,
152166 ] ,
153- Some ( & self . workspace ) ,
167+ None ,
154168 false ,
155169 vec ! [ ] ,
156170 vec ! [ ] ,
0 commit comments