@@ -6,12 +6,12 @@ mod import;
6
6
7
7
use clap:: { Parser , Subcommand } ;
8
8
use std:: path:: PathBuf ;
9
- use starcoin_storage:: { db_storage:: DBStorage , storage:: StorageInstance , Storage , StorageVersion } ;
10
- use starcoin_statedb:: ChainStateDB ;
11
- use std:: sync:: Arc ;
12
9
13
10
#[ derive( Parser ) ]
14
- #[ clap( name = "resource-code-exporter" , about = "Export and import state data" ) ]
11
+ #[ clap(
12
+ name = "resource-code-exporter" ,
13
+ about = "Export and import state data"
14
+ ) ]
15
15
struct Cli {
16
16
#[ clap( subcommand) ]
17
17
command : Commands ,
@@ -24,7 +24,7 @@ enum Commands {
24
24
#[ clap( long, short = 'o' , parse( from_os_str) ) ]
25
25
/// Output file path, e.g. accounts.csv
26
26
output : PathBuf ,
27
-
27
+
28
28
#[ clap( long, short = 'i' , parse( from_os_str) ) ]
29
29
/// Starcoin node db path, e.g. ~/.starcoin/barnard/starcoindb/db/starcoindb
30
30
db_path : PathBuf ,
@@ -37,9 +37,9 @@ enum Commands {
37
37
Import {
38
38
#[ clap( long, short = 'i' , parse( from_os_str) ) ]
39
39
/// Input CSV file path
40
- input : PathBuf ,
41
-
42
- #[ clap( long, short = 'o ' , parse( from_os_str) ) ]
40
+ csv_input : PathBuf ,
41
+
42
+ #[ clap( long, short = 'd ' , parse( from_os_str) ) ]
43
43
/// Output database path
44
44
db_path : PathBuf ,
45
45
} ,
@@ -54,29 +54,10 @@ fn main() -> anyhow::Result<()> {
54
54
db_path,
55
55
block_id,
56
56
} => {
57
- export:: export (
58
- db_path. display ( ) . to_string ( ) . as_str ( ) ,
59
- & output,
60
- block_id,
61
- ) ?;
57
+ export:: export ( db_path. display ( ) . to_string ( ) . as_str ( ) , & output, block_id) ?;
62
58
}
63
- Commands :: Import { input, db_path } => {
64
- // Create new statedb for import
65
- let db_storage = DBStorage :: open_with_cfs (
66
- & db_path,
67
- StorageVersion :: current_version ( )
68
- . get_column_family_names ( )
69
- . to_vec ( ) ,
70
- false ,
71
- Default :: default ( ) ,
72
- None ,
73
- ) ?;
74
- let storage = Storage :: new ( StorageInstance :: new_db_instance ( db_storage) ) ?;
75
- let storage = Arc :: new ( storage) ;
76
- let statedb = ChainStateDB :: new ( storage. clone ( ) , None ) ;
77
-
78
- // Import data
79
- import:: import ( & statedb, & input) ?;
59
+ Commands :: Import { csv_input, db_path } => {
60
+ import:: import ( & csv_input, & db_path) ?;
80
61
}
81
62
}
82
63
0 commit comments