2020-07-14 01:56:29 +00:00
package commands
2020-07-05 06:18:21 +00:00
2020-08-22 10:12:33 +00:00
import (
"github.com/ledgerwatch/turbo-geth/node"
"github.com/spf13/cobra"
)
2020-07-05 06:18:21 +00:00
var (
2020-07-07 07:11:10 +00:00
chaindata string
2020-10-28 03:18:10 +00:00
database string
2020-10-13 12:56:16 +00:00
snapshotMode string
snapshotDir string
2020-10-28 03:18:10 +00:00
toChaindata string
2020-07-07 07:11:10 +00:00
referenceChaindata string
block uint64
unwind uint64
unwindEvery uint64
2020-12-08 09:44:29 +00:00
cacheSizeStr string
2020-10-21 17:01:40 +00:00
batchSizeStr string
2020-07-07 07:11:10 +00:00
reset bool
bucket string
2020-07-28 13:07:36 +00:00
datadir string
2020-10-13 22:42:04 +00:00
mapSizeStr string
2020-10-17 13:00:12 +00:00
freelistReuse int
migration string
2021-02-21 18:41:59 +00:00
integritySlow bool
integrityFast bool
2020-11-28 15:08:02 +00:00
silkwormPath string
2020-12-16 14:35:14 +00:00
file string
2020-07-05 06:18:21 +00:00
)
func must ( err error ) {
if err != nil {
panic ( err )
}
}
func withChaindata ( cmd * cobra . Command ) {
2020-07-07 04:00:25 +00:00
cmd . Flags ( ) . StringVar ( & chaindata , "chaindata" , "" , "path to the db" )
must ( cmd . MarkFlagDirname ( "chaindata" ) )
must ( cmd . MarkFlagRequired ( "chaindata" ) )
2020-10-13 12:56:16 +00:00
cmd . Flags ( ) . StringVar ( & snapshotMode , "snapshotMode" , "" , "set of snapshots to use" )
cmd . Flags ( ) . StringVar ( & snapshotDir , "snapshotDir" , "" , "snapshot dir" )
2020-10-28 03:18:10 +00:00
cmd . Flags ( ) . StringVar ( & database , "database" , "" , "lmdb|mdbx" )
2020-07-05 06:18:21 +00:00
}
2020-12-16 14:35:14 +00:00
func withFile ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & file , "file" , "" , "path to file" )
must ( cmd . MarkFlagFilename ( "file" ) )
must ( cmd . MarkFlagRequired ( "file" ) )
}
2020-10-28 03:18:10 +00:00
func withLmdbFlags ( cmd * cobra . Command ) {
2020-10-13 22:42:04 +00:00
cmd . Flags ( ) . StringVar ( & mapSizeStr , "lmdb.mapSize" , "" , "map size for LMDB" )
2020-10-17 13:00:12 +00:00
cmd . Flags ( ) . IntVar ( & freelistReuse , "maxFreelistReuse" , 0 , "Find a big enough contiguous page range for large values in freelist is hard just allocate new pages and even don't try to search if value is bigger than this limit. Measured in pages." )
}
2020-07-07 07:11:10 +00:00
func withReferenceChaindata ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . StringVar ( & referenceChaindata , "chaindata.reference" , "" , "path to the 2nd (reference/etalon) db" )
must ( cmd . MarkFlagDirname ( "chaindata.reference" ) )
2020-07-07 07:11:10 +00:00
}
2020-10-28 03:18:10 +00:00
func withToChaindata ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . StringVar ( & toChaindata , "chaindata.to" , "" , "target chaindata" )
must ( cmd . MarkFlagDirname ( "chaindata.to" ) )
2020-10-28 03:18:10 +00:00
}
2020-07-07 04:00:25 +00:00
func withBlock ( cmd * cobra . Command ) {
cmd . Flags ( ) . Uint64Var ( & block , "block" , 0 , "block test at this block" )
}
func withUnwind ( cmd * cobra . Command ) {
cmd . Flags ( ) . Uint64Var ( & unwind , "unwind" , 0 , "how much blocks unwind on each iteration" )
}
func withUnwindEvery ( cmd * cobra . Command ) {
2021-02-21 18:41:59 +00:00
cmd . Flags ( ) . Uint64Var ( & unwindEvery , "unwind.every" , 0 , "each iteration test will move forward `--unwind.every` blocks, then unwind `--unwind` blocks" )
2020-07-07 04:00:25 +00:00
}
2020-07-07 07:11:10 +00:00
func withReset ( cmd * cobra . Command ) {
2020-07-07 04:00:25 +00:00
cmd . Flags ( ) . BoolVar ( & reset , "reset" , false , "reset given stage" )
2020-07-05 06:18:21 +00:00
}
2020-07-07 07:11:10 +00:00
func withBucket ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & bucket , "bucket" , "" , "reset given stage" )
}
2020-07-28 13:07:36 +00:00
func withDatadir ( cmd * cobra . Command ) {
2020-08-22 10:12:33 +00:00
cmd . Flags ( ) . StringVar ( & datadir , "datadir" , node . DefaultDataDir ( ) , "data directory for temporary ELT files" )
2020-07-28 13:07:36 +00:00
}
2020-09-05 06:27:47 +00:00
2020-10-21 17:01:40 +00:00
func withBatchSize ( cmd * cobra . Command ) {
2020-12-08 09:44:29 +00:00
cmd . Flags ( ) . StringVar ( & cacheSizeStr , "cacheSize" , "0" , "cache size for execution stage" )
2020-10-21 17:01:40 +00:00
cmd . Flags ( ) . StringVar ( & batchSizeStr , "batchSize" , "512M" , "batch size for execution stage" )
2020-09-05 06:27:47 +00:00
}
2020-10-17 13:00:12 +00:00
2021-02-21 18:41:59 +00:00
func withIntegrityChecks ( cmd * cobra . Command ) {
cmd . Flags ( ) . BoolVar ( & integritySlow , "integrity.slow" , true , "enable slow data-integrity checks" )
cmd . Flags ( ) . BoolVar ( & integrityFast , "integrity.fast" , true , "enable fast data-integrity checks" )
}
2020-10-17 13:00:12 +00:00
func withMigration ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & migration , "migration" , "" , "action to apply to given migration" )
}
2020-10-31 11:51:56 +00:00
2020-11-28 15:08:02 +00:00
func withSilkworm ( cmd * cobra . Command ) {
cmd . Flags ( ) . StringVar ( & silkwormPath , "silkworm" , "" , "file path of libsilkworm_tg_api.so" )
must ( cmd . MarkFlagFilename ( "silkworm" ) )
}