From fc3d1432f41a0b74d92f4ed629e6d47814aa30b0 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 31 Aug 2023 01:12:46 +0800 Subject: [PATCH] clean up flags rm unused flags LVL_DB_PATH => LEVELDB_PATH ANCIENT_DB_PATH => LEVELDB_ANCIENT --- README.md | 4 ++-- cmd/stateSnapshot.go | 8 ++++---- environments/example.toml | 3 --- pkg/snapshot/config.go | 10 ++++------ pkg/snapshot/env.go | 18 ++++++------------ 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d15e880..f4b09e8 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ Config format: [leveldb] # path to geth leveldb - path = "/Users/user/Library/Ethereum/geth/chaindata" # LVL_DB_PATH + path = "/Users/user/Library/Ethereum/geth/chaindata" # LEVELDB_PATH # path to geth ancient database - ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient" # ANCIENT_DB_PATH + ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient" # LEVELDB_ANCIENT [database] # when operating in 'postgres' output mode diff --git a/cmd/stateSnapshot.go b/cmd/stateSnapshot.go index e5b25af..691cbc3 100644 --- a/cmd/stateSnapshot.go +++ b/cmd/stateSnapshot.go @@ -98,8 +98,8 @@ func stateSnapshot() { func init() { rootCmd.AddCommand(stateSnapshotCmd) - stateSnapshotCmd.PersistentFlags().String(snapshot.LVL_DB_PATH_CLI, "", "path to primary datastore") - stateSnapshotCmd.PersistentFlags().String(snapshot.ANCIENT_DB_PATH_CLI, "", "path to ancient datastore") + stateSnapshotCmd.PersistentFlags().String(snapshot.LEVELDB_PATH_CLI, "", "path to primary datastore") + stateSnapshotCmd.PersistentFlags().String(snapshot.LEVELDB_ANCIENT_CLI, "", "path to ancient datastore") stateSnapshotCmd.PersistentFlags().String(snapshot.SNAPSHOT_BLOCK_HEIGHT_CLI, "", "block height to extract state at") stateSnapshotCmd.PersistentFlags().Int(snapshot.SNAPSHOT_WORKERS_CLI, 1, "number of concurrent workers to use") stateSnapshotCmd.PersistentFlags().String(snapshot.SNAPSHOT_RECOVERY_FILE_CLI, "", "file to recover from a previous iteration") @@ -107,8 +107,8 @@ func init() { stateSnapshotCmd.PersistentFlags().String(snapshot.FILE_OUTPUT_DIR_CLI, "", "directory for writing ouput to while operating in 'file' mode") stateSnapshotCmd.PersistentFlags().StringArray(snapshot.SNAPSHOT_ACCOUNTS_CLI, nil, "list of account addresses to limit snapshot to") - viper.BindPFlag(snapshot.LVL_DB_PATH_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.LVL_DB_PATH_CLI)) - viper.BindPFlag(snapshot.ANCIENT_DB_PATH_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.ANCIENT_DB_PATH_CLI)) + viper.BindPFlag(snapshot.LEVELDB_PATH_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.LEVELDB_PATH_CLI)) + viper.BindPFlag(snapshot.LEVELDB_ANCIENT_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.LEVELDB_ANCIENT_CLI)) viper.BindPFlag(snapshot.SNAPSHOT_BLOCK_HEIGHT_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.SNAPSHOT_BLOCK_HEIGHT_CLI)) viper.BindPFlag(snapshot.SNAPSHOT_WORKERS_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.SNAPSHOT_WORKERS_CLI)) viper.BindPFlag(snapshot.SNAPSHOT_RECOVERY_FILE_TOML, stateSnapshotCmd.PersistentFlags().Lookup(snapshot.SNAPSHOT_RECOVERY_FILE_CLI)) diff --git a/environments/example.toml b/environments/example.toml index f0e4ef0..91f4858 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -26,9 +26,6 @@ blockHeight = 32 recoveryFile = "recovery_file" - startHeight = 1 - endHeight = 12 - [file] outputDir = "output_dir/" diff --git a/pkg/snapshot/config.go b/pkg/snapshot/config.go index 1a6c43c..b553c83 100644 --- a/pkg/snapshot/config.go +++ b/pkg/snapshot/config.go @@ -104,11 +104,11 @@ func (c *Config) Init(mode SnapshotMode) error { ChainID: viper.GetUint64(ETH_CHAIN_ID_TOML), } - viper.BindEnv(ANCIENT_DB_PATH_TOML, ANCIENT_DB_PATH) - viper.BindEnv(LVL_DB_PATH_TOML, LVL_DB_PATH) + viper.BindEnv(LEVELDB_ANCIENT_TOML, LEVELDB_ANCIENT) + viper.BindEnv(LEVELDB_PATH_TOML, LEVELDB_PATH) - c.Eth.AncientDBPath = viper.GetString(ANCIENT_DB_PATH_TOML) - c.Eth.LevelDBPath = viper.GetString(LVL_DB_PATH_TOML) + c.Eth.AncientDBPath = viper.GetString(LEVELDB_ANCIENT_TOML) + c.Eth.LevelDBPath = viper.GetString(LEVELDB_PATH_TOML) switch mode { case FileSnapshot: @@ -159,8 +159,6 @@ func InitFile(c *FileConfig) error { func (c *ServiceConfig) Init() error { viper.BindEnv(SNAPSHOT_BLOCK_HEIGHT_TOML, SNAPSHOT_BLOCK_HEIGHT) - viper.BindEnv(SNAPSHOT_START_HEIGHT_TOML, SNAPSHOT_START_HEIGHT) - viper.BindEnv(SNAPSHOT_END_HEIGHT_TOML, SNAPSHOT_END_HEIGHT) viper.BindEnv(SNAPSHOT_MODE_TOML, SNAPSHOT_MODE) viper.BindEnv(SNAPSHOT_WORKERS_TOML, SNAPSHOT_WORKERS) viper.BindEnv(PROM_HTTP_TOML, PROM_HTTP) diff --git a/pkg/snapshot/env.go b/pkg/snapshot/env.go index a592726..6db2001 100644 --- a/pkg/snapshot/env.go +++ b/pkg/snapshot/env.go @@ -21,8 +21,6 @@ const ( SNAPSHOT_WORKERS = "SNAPSHOT_WORKERS" SNAPSHOT_RECOVERY_FILE = "SNAPSHOT_RECOVERY_FILE" SNAPSHOT_MODE = "SNAPSHOT_MODE" - SNAPSHOT_START_HEIGHT = "SNAPSHOT_START_HEIGHT" - SNAPSHOT_END_HEIGHT = "SNAPSHOT_END_HEIGHT" SNAPSHOT_ACCOUNTS = "SNAPSHOT_ACCOUNTS" LOGRUS_LEVEL = "LOGRUS_LEVEL" @@ -36,8 +34,8 @@ const ( FILE_OUTPUT_DIR = "FILE_OUTPUT_DIR" - ANCIENT_DB_PATH = "ANCIENT_DB_PATH" - LVL_DB_PATH = "LVL_DB_PATH" + LEVELDB_ANCIENT = "LEVELDB_ANCIENT" + LEVELDB_PATH = "LEVELDB_PATH" ETH_CLIENT_NAME = "ETH_CLIENT_NAME" ETH_GENESIS_BLOCK = "ETH_GENESIS_BLOCK" @@ -61,8 +59,6 @@ const ( SNAPSHOT_WORKERS_TOML = "snapshot.workers" SNAPSHOT_RECOVERY_FILE_TOML = "snapshot.recoveryFile" SNAPSHOT_MODE_TOML = "snapshot.mode" - SNAPSHOT_START_HEIGHT_TOML = "snapshot.startHeight" - SNAPSHOT_END_HEIGHT_TOML = "snapshot.endHeight" SNAPSHOT_ACCOUNTS_TOML = "snapshot.accounts" LOGRUS_LEVEL_TOML = "log.level" @@ -76,8 +72,8 @@ const ( FILE_OUTPUT_DIR_TOML = "file.outputDir" - ANCIENT_DB_PATH_TOML = "leveldb.ancient" - LVL_DB_PATH_TOML = "leveldb.path" + LEVELDB_ANCIENT_TOML = "leveldb.ancient" + LEVELDB_PATH_TOML = "leveldb.path" ETH_CLIENT_NAME_TOML = "ethereum.clientName" ETH_GENESIS_BLOCK_TOML = "ethereum.genesisBlock" @@ -101,8 +97,6 @@ const ( SNAPSHOT_WORKERS_CLI = "workers" SNAPSHOT_RECOVERY_FILE_CLI = "recovery-file" SNAPSHOT_MODE_CLI = "snapshot-mode" - SNAPSHOT_START_HEIGHT_CLI = "start-height" - SNAPSHOT_END_HEIGHT_CLI = "end-height" SNAPSHOT_ACCOUNTS_CLI = "snapshot-accounts" LOGRUS_LEVEL_CLI = "log-level" @@ -116,8 +110,8 @@ const ( FILE_OUTPUT_DIR_CLI = "output-dir" - ANCIENT_DB_PATH_CLI = "ancient-path" - LVL_DB_PATH_CLI = "leveldb-path" + LEVELDB_ANCIENT_CLI = "ancient-path" + LEVELDB_PATH_CLI = "leveldb-path" ETH_CLIENT_NAME_CLI = "ethereum-client-name" ETH_GENESIS_BLOCK_CLI = "ethereum-genesis-block"