48
48
recheckHeadersArg bool
49
49
SubCommand string
50
50
LogWithCommand log.Entry
51
+ storageDiffsSource string
51
52
)
52
53
53
54
const (
@@ -80,6 +81,7 @@ func setViperConfigs() {
80
81
ipc = viper .GetString ("client.ipcpath" )
81
82
levelDbPath = viper .GetString ("client.leveldbpath" )
82
83
storageDiffsPath = viper .GetString ("filesystem.storageDiffsPath" )
84
+ storageDiffsSource = viper .GetString ("storageDiffs.source" )
83
85
databaseConfig = config.Database {
84
86
Name : viper .GetString ("database.name" ),
85
87
Hostname : viper .GetString ("database.hostname" ),
@@ -118,6 +120,7 @@ func init() {
118
120
rootCmd .PersistentFlags ().String ("client-ipcPath" , "" , "location of geth.ipc file" )
119
121
rootCmd .PersistentFlags ().String ("client-levelDbPath" , "" , "location of levelDb chaindata" )
120
122
rootCmd .PersistentFlags ().String ("filesystem-storageDiffsPath" , "" , "location of storage diffs csv file" )
123
+ rootCmd .PersistentFlags ().String ("storageDiffs-source" , "csv" , "where to get the state diffs: csv or geth" )
121
124
rootCmd .PersistentFlags ().String ("exporter-name" , "exporter" , "name of exporter plugin" )
122
125
rootCmd .PersistentFlags ().String ("log-level" , log .InfoLevel .String (), "Log level (trace, debug, info, warn, error, fatal, panic" )
123
126
@@ -129,6 +132,7 @@ func init() {
129
132
viper .BindPFlag ("client.ipcPath" , rootCmd .PersistentFlags ().Lookup ("client-ipcPath" ))
130
133
viper .BindPFlag ("client.levelDbPath" , rootCmd .PersistentFlags ().Lookup ("client-levelDbPath" ))
131
134
viper .BindPFlag ("filesystem.storageDiffsPath" , rootCmd .PersistentFlags ().Lookup ("filesystem-storageDiffsPath" ))
135
+ viper .BindPFlag ("storageDiffs.source" , rootCmd .PersistentFlags ().Lookup ("storageDiffs-source" ))
132
136
viper .BindPFlag ("exporter.fileName" , rootCmd .PersistentFlags ().Lookup ("exporter-name" ))
133
137
viper .BindPFlag ("log.level" , rootCmd .PersistentFlags ().Lookup ("log-level" ))
134
138
}
@@ -152,15 +156,21 @@ func initConfig() {
152
156
}
153
157
154
158
func getBlockChain () * geth.BlockChain {
159
+ rpcClient , ethClient := getClients ()
160
+ vdbEthClient := client .NewEthClient (ethClient )
161
+ vdbNode := node .MakeNode (rpcClient )
162
+ transactionConverter := vRpc .NewRpcTransactionConverter (ethClient )
163
+ return geth .NewBlockChain (vdbEthClient , rpcClient , vdbNode , transactionConverter )
164
+ }
165
+
166
+ func getClients () (client.RpcClient , * ethclient.Client ) {
155
167
rawRpcClient , err := rpc .Dial (ipc )
156
168
157
169
if err != nil {
158
170
LogWithCommand .Fatal (err )
159
171
}
160
172
rpcClient := client .NewRpcClient (rawRpcClient , ipc )
161
173
ethClient := ethclient .NewClient (rawRpcClient )
162
- vdbEthClient := client .NewEthClient (ethClient )
163
- vdbNode := node .MakeNode (rpcClient )
164
- transactionConverter := vRpc .NewRpcTransactionConverter (ethClient )
165
- return geth .NewBlockChain (vdbEthClient , rpcClient , vdbNode , transactionConverter )
174
+
175
+ return rpcClient , ethClient
166
176
}
0 commit comments