diff options
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r-- | cmd/utils/flags.go | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index adc18a203..38c90d801 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -23,12 +23,12 @@ import ( "io/ioutil" "math/big" "os" + "os/user" "path/filepath" "runtime" "strconv" "strings" - "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" @@ -114,6 +114,34 @@ var ( Name: "keystore", Usage: "Directory for the keystore (default = inside the datadir)", } + EthashCacheDirFlag = DirectoryFlag{ + Name: "ethash.cachedir", + Usage: "Directory to store the ethash verification caches (default = inside the datadir)", + } + EthashCachesInMemoryFlag = cli.IntFlag{ + Name: "ethash.cachesinmem", + Usage: "Number of recent ethash caches to keep in memory (16MB each)", + Value: 2, + } + EthashCachesOnDiskFlag = cli.IntFlag{ + Name: "ethash.cachesondisk", + Usage: "Number of recent ethash caches to keep on disk (16MB each)", + Value: 3, + } + EthashDatasetDirFlag = DirectoryFlag{ + Name: "ethash.dagdir", + Usage: "Directory to store the ethash mining DAGs (default = inside home folder)", + } + EthashDatasetsInMemoryFlag = cli.IntFlag{ + Name: "ethash.dagsinmem", + Usage: "Number of recent ethash mining DAGs to keep in memory (1+GB each)", + Value: 1, + } + EthashDatasetsOnDiskFlag = cli.IntFlag{ + Name: "ethash.dagsondisk", + Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)", + Value: 2, + } NetworkIdFlag = cli.IntFlag{ Name: "networkid", Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)", @@ -184,10 +212,6 @@ var ( Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine", Value: params.GenesisGasLimit.Uint64(), } - AutoDAGFlag = cli.BoolFlag{ - Name: "autodag", - Usage: "Enable automatic DAG pregeneration", - } EtherbaseFlag = cli.StringFlag{ Name: "etherbase", Usage: "Public address for block mining rewards (default = first account created)", @@ -244,7 +268,10 @@ var ( Name: "fakepow", Usage: "Disables proof-of-work verification", } - + NoCompactionFlag = cli.BoolFlag{ + Name: "nocompaction", + Usage: "Disables db compaction after import", + } // RPC settings RPCEnabledFlag = cli.BoolFlag{ Name: "rpc", @@ -429,6 +456,36 @@ func MakeDataDir(ctx *cli.Context) string { return "" } +// MakeEthashCacheDir returns the directory to use for storing the ethash cache +// dumps. +func MakeEthashCacheDir(ctx *cli.Context) string { + if ctx.GlobalIsSet(EthashCacheDirFlag.Name) && ctx.GlobalString(EthashCacheDirFlag.Name) == "" { + return "" + } + if !ctx.GlobalIsSet(EthashCacheDirFlag.Name) { + return "ethash" + } + return ctx.GlobalString(EthashCacheDirFlag.Name) +} + +// MakeEthashDatasetDir returns the directory to use for storing the full ethash +// dataset dumps. +func MakeEthashDatasetDir(ctx *cli.Context) string { + if !ctx.GlobalIsSet(EthashDatasetDirFlag.Name) { + home := os.Getenv("HOME") + if home == "" { + if user, err := user.Current(); err == nil { + home = user.HomeDir + } + } + if runtime.GOOS == "windows" { + return filepath.Join(home, "AppData", "Ethash") + } + return filepath.Join(home, ".ethash") + } + return ctx.GlobalString(EthashDatasetDirFlag.Name) +} + // MakeIPCPath creates an IPC path configuration from the set command line flags, // returning an empty string if IPC was explicitly disabled, or the set path. func MakeIPCPath(ctx *cli.Context) string { @@ -749,7 +806,12 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) { GpobaseStepUp: ctx.GlobalInt(GpobaseStepUpFlag.Name), GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name), SolcPath: ctx.GlobalString(SolcPathFlag.Name), - AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name), + EthashCacheDir: MakeEthashCacheDir(ctx), + EthashCachesInMem: ctx.GlobalInt(EthashCachesInMemoryFlag.Name), + EthashCachesOnDisk: ctx.GlobalInt(EthashCachesOnDiskFlag.Name), + EthashDatasetDir: MakeEthashDatasetDir(ctx), + EthashDatasetsInMem: ctx.GlobalInt(EthashDatasetsInMemoryFlag.Name), + EthashDatasetsOnDisk: ctx.GlobalInt(EthashDatasetsOnDiskFlag.Name), EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name), } @@ -919,11 +981,11 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai } chainConfig := MakeChainConfigFromDb(ctx, chainDb) - pow := pow.PoW(core.FakePow{}) + seal := pow.PoW(pow.FakePow{}) if !ctx.GlobalBool(FakePoWFlag.Name) { - pow = ethash.New() + seal = pow.NewFullEthash("", 1, 0, "", 1, 0) } - chain, err = core.NewBlockChain(chainDb, chainConfig, pow, new(event.TypeMux), vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}) + chain, err = core.NewBlockChain(chainDb, chainConfig, seal, new(event.TypeMux), vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}) if err != nil { Fatalf("Could not start chainmanager: %v", err) } |