2019-11-25 13:46:36 +00:00
package commands
2020-03-30 18:56:53 +00:00
import (
2022-10-11 12:21:32 +00:00
"path"
2022-09-20 15:51:09 +00:00
"github.com/spf13/cobra"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
2022-10-11 12:21:32 +00:00
2022-04-01 08:00:50 +00:00
"github.com/ledgerwatch/erigon/cmd/utils"
2021-05-20 18:25:53 +00:00
"github.com/ledgerwatch/erigon/common/paths"
2020-03-30 18:56:53 +00:00
)
2019-11-25 13:46:36 +00:00
var (
2021-04-19 07:25:26 +00:00
datadir string
2019-12-04 10:10:42 +00:00
chaindata string
statsfile string
block uint64
2020-04-20 10:35:33 +00:00
changeSetBucket string
indexBucket string
2022-06-05 06:33:55 +00:00
snapshotsCli bool
2022-03-10 14:01:37 +00:00
chain string
2022-09-20 15:51:09 +00:00
logdir string
2019-11-25 13:46:36 +00:00
)
2020-04-14 12:51:20 +00:00
func must ( err error ) {
if err != nil {
panic ( err )
}
}
2019-11-25 13:46:36 +00:00
func withBlock ( cmd * cobra . Command ) {
2022-01-16 08:40:16 +00:00
cmd . Flags ( ) . Uint64Var ( & block , "block" , 0 , "specifies a block number for operation" )
2019-11-25 13:46:36 +00:00
}
2022-02-22 17:39:48 +00:00
func withDataDir ( cmd * cobra . Command ) {
2021-04-19 21:58:05 +00:00
cmd . Flags ( ) . StringVar ( & datadir , "datadir" , paths . DefaultDataDir ( ) , "data directory for temporary ELT files" )
2021-04-19 07:25:26 +00:00
must ( cmd . MarkFlagDirname ( "datadir" ) )
cmd . Flags ( ) . StringVar ( & chaindata , "chaindata" , "" , "path to the db" )
must ( cmd . MarkFlagDirname ( "chaindata" ) )
2019-11-25 13:46:36 +00:00
}
func withStatsfile ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & statsfile , "statsfile" , "stateless.csv" , "path where to write the stats file" )
2020-04-14 12:51:20 +00:00
must ( cmd . MarkFlagFilename ( "statsfile" , "csv" ) )
2019-11-25 13:46:36 +00:00
}
2019-12-03 09:55:15 +00:00
2020-04-20 10:35:33 +00:00
func withCSBucket ( cmd * cobra . Command ) {
2021-07-28 02:47:38 +00:00
cmd . Flags ( ) . StringVar ( & changeSetBucket , "changeset-bucket" , kv . AccountChangeSet , kv . AccountChangeSet + " for account and " + kv . StorageChangeSet + " for storage" )
2020-04-20 10:35:33 +00:00
}
func withIndexBucket ( cmd * cobra . Command ) {
2021-07-28 02:47:38 +00:00
cmd . Flags ( ) . StringVar ( & indexBucket , "index-bucket" , kv . AccountsHistory , kv . AccountsHistory + " for account and " + kv . StorageHistory + " for storage" )
2020-04-20 10:35:33 +00:00
}
2022-02-22 01:42:12 +00:00
func withSnapshotBlocks ( cmd * cobra . Command ) {
2022-06-05 06:33:55 +00:00
cmd . Flags ( ) . BoolVar ( & snapshotsCli , "snapshots" , true , utils . SnapshotFlag . Usage )
2022-02-22 01:42:12 +00:00
}
2022-03-10 14:01:37 +00:00
func withChain ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & chain , "chain" , "" , "pick a chain to assume (mainnet, ropsten, etc.)" )
}
2022-09-20 15:51:09 +00:00
func withLogPath ( cmd * cobra . Command ) {
2022-10-11 12:21:32 +00:00
cmd . Flags ( ) . StringVar ( & logdir , "log-dir" , path . Join ( paths . DefaultDataDir ( ) , "logs" ) , "path to write user and error logs to" )
2022-09-20 15:51:09 +00:00
}