2019-11-25 13:46:36 +00:00
package commands
2020-03-30 18:56:53 +00:00
import (
2020-04-20 10:35:33 +00:00
"github.com/ledgerwatch/turbo-geth/common/dbutils"
2021-04-19 21:58:05 +00:00
"github.com/ledgerwatch/turbo-geth/common/paths"
2020-03-30 18:56:53 +00:00
"github.com/spf13/cobra"
)
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
2021-04-19 07:25:26 +00:00
snapshotDir string
snapshotMode string
database string
2019-12-04 10:10:42 +00:00
statsfile string
block uint64
2020-04-20 10:35:33 +00:00
changeSetBucket string
indexBucket 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 ) {
cmd . Flags ( ) . Uint64Var ( & block , "block" , 1 , "specifies a block number for operation" )
}
2021-04-19 07:25:26 +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" ) )
cmd . Flags ( ) . StringVar ( & snapshotMode , "snapshot.mode" , "" , "set of snapshots to use" )
cmd . Flags ( ) . StringVar ( & snapshotDir , "snapshot.dir" , "" , "snapshot dir" )
must ( cmd . MarkFlagDirname ( "snapshot.dir" ) )
cmd . Flags ( ) . StringVar ( & database , "database" , "" , "lmdb|mdbx" )
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 ) {
2020-11-22 21:25:26 +00:00
cmd . Flags ( ) . StringVar ( & changeSetBucket , "changeset-bucket" , dbutils . PlainAccountChangeSetBucket , dbutils . PlainAccountChangeSetBucket + " for account and " + dbutils . PlainStorageChangeSetBucket + " for storage" )
2020-04-20 10:35:33 +00:00
}
func withIndexBucket ( cmd * cobra . Command ) {
2020-11-16 12:08:28 +00:00
cmd . Flags ( ) . StringVar ( & indexBucket , "index-bucket" , dbutils . AccountsHistoryBucket , dbutils . AccountsHistoryBucket + " for account and " + dbutils . StorageHistoryBucket + " for storage" )
2020-04-20 10:35:33 +00:00
}