From f0d2741dea30a400144d00596e4effe1e2852d92 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman Date: Tue, 1 Oct 2019 10:09:00 -0500 Subject: [PATCH] Allow storageDiff source to be set through an env variable --- cmd/composeAndExecute.go | 2 +- cmd/execute.go | 2 +- cmd/root.go | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/composeAndExecute.go b/cmd/composeAndExecute.go index 98ccd0ff..eea5e686 100644 --- a/cmd/composeAndExecute.go +++ b/cmd/composeAndExecute.go @@ -181,7 +181,7 @@ func composeAndExecute() { } if len(ethStorageInitializers) > 0 { - switch stateDiffSource { + switch storageDiffsSource { case "geth": log.Debug("fetching storage diffs from geth pub sub") rpcClient, _ := getClients() diff --git a/cmd/execute.go b/cmd/execute.go index ae8230f2..d04bc205 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -125,7 +125,7 @@ func execute() { } if len(ethStorageInitializers) > 0 { - switch stateDiffSource { + switch storageDiffsSource { case "geth": log.Debug("fetching storage diffs from geth pub sub") rpcClient, _ := getClients() diff --git a/cmd/root.go b/cmd/root.go index 1ed338e1..f8174f74 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -48,7 +48,7 @@ var ( recheckHeadersArg bool SubCommand string LogWithCommand log.Entry - stateDiffSource string + storageDiffsSource string ) const ( @@ -81,6 +81,7 @@ func setViperConfigs() { ipc = viper.GetString("client.ipcpath") levelDbPath = viper.GetString("client.leveldbpath") storageDiffsPath = viper.GetString("filesystem.storageDiffsPath") + storageDiffsSource = viper.GetString("storageDiffs.source") databaseConfig = config.Database{ Name: viper.GetString("database.name"), Hostname: viper.GetString("database.hostname"), @@ -119,9 +120,9 @@ func init() { rootCmd.PersistentFlags().String("client-ipcPath", "", "location of geth.ipc file") rootCmd.PersistentFlags().String("client-levelDbPath", "", "location of levelDb chaindata") rootCmd.PersistentFlags().String("filesystem-storageDiffsPath", "", "location of storage diffs csv file") + rootCmd.PersistentFlags().String("storageDiffs-source", "csv", "where to get the state diffs: csv or geth") rootCmd.PersistentFlags().String("exporter-name", "exporter", "name of exporter plugin") rootCmd.PersistentFlags().String("log-level", log.InfoLevel.String(), "Log level (trace, debug, info, warn, error, fatal, panic") - rootCmd.PersistentFlags().StringVar(&stateDiffSource, "state-diff-source", "csv", "where to get the state diffs: csv or geth") viper.BindPFlag("database.name", rootCmd.PersistentFlags().Lookup("database-name")) viper.BindPFlag("database.port", rootCmd.PersistentFlags().Lookup("database-port")) @@ -131,6 +132,7 @@ func init() { viper.BindPFlag("client.ipcPath", rootCmd.PersistentFlags().Lookup("client-ipcPath")) viper.BindPFlag("client.levelDbPath", rootCmd.PersistentFlags().Lookup("client-levelDbPath")) viper.BindPFlag("filesystem.storageDiffsPath", rootCmd.PersistentFlags().Lookup("filesystem-storageDiffsPath")) + viper.BindPFlag("storageDiffs.source", rootCmd.PersistentFlags().Lookup("storageDiffs-source")) viper.BindPFlag("exporter.fileName", rootCmd.PersistentFlags().Lookup("exporter-name")) viper.BindPFlag("log.level", rootCmd.PersistentFlags().Lookup("log-level")) }