diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-03-06 17:37:32 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-03-09 22:50:14 +0800 |
commit | 023670f6bafcfed28c01857da215217a5dadfaa1 (patch) | |
tree | 2ced9d0178bfd8d101356a64522cf0225f98362e /cmd | |
parent | 567d41d9363706b4b13ce0903804e8acf214af49 (diff) | |
download | dexon-023670f6bafcfed28c01857da215217a5dadfaa1.tar.gz dexon-023670f6bafcfed28c01857da215217a5dadfaa1.tar.zst dexon-023670f6bafcfed28c01857da215217a5dadfaa1.zip |
cmd, eth, les, node, pow: disk caching and progress reports
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/main.go | 5 | ||||
-rw-r--r-- | cmd/geth/usage.go | 10 | ||||
-rw-r--r-- | cmd/utils/flags.go | 61 |
3 files changed, 75 insertions, 1 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 1f6f2bb29..bf5e81d45 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -91,6 +91,11 @@ func init() { utils.BootnodesFlag, utils.DataDirFlag, utils.KeyStoreDirFlag, + utils.EthashCacheDirFlag, + utils.EthashCachesInMemoryFlag, + utils.EthashCachesOnDiskFlag, + utils.EthashDatasetDirFlag, + utils.EthashDatasetsOnDiskFlag, utils.FastSyncFlag, utils.LightModeFlag, utils.LightServFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 9349857e9..34910daa5 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -78,6 +78,16 @@ var AppHelpFlagGroups = []flagGroup{ }, }, { + Name: "ETHASH", + Flags: []cli.Flag{ + utils.EthashCacheDirFlag, + utils.EthashCachesInMemoryFlag, + utils.EthashCachesOnDiskFlag, + utils.EthashDatasetDirFlag, + utils.EthashDatasetsOnDiskFlag, + }, + }, + { Name: "PERFORMANCE TUNING", Flags: []cli.Flag{ utils.CacheFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 00599e82a..b92be8464 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "math/big" "os" + "os/user" "path/filepath" "runtime" "strconv" @@ -113,6 +114,29 @@ 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)", + } + EthashDatasetsOnDiskFlag = cli.IntFlag{ + Name: "ethash.dagsondisk", + Usage: "Number of 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)", @@ -431,6 +455,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 { @@ -751,6 +805,11 @@ 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), + EthashCacheDir: MakeEthashCacheDir(ctx), + EthashCachesInMem: ctx.GlobalInt(EthashCachesInMemoryFlag.Name), + EthashCachesOnDisk: ctx.GlobalInt(EthashCachesOnDiskFlag.Name), + EthashDatasetDir: MakeEthashDatasetDir(ctx), + EthashDatasetsOnDisk: ctx.GlobalInt(EthashDatasetsOnDiskFlag.Name), AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name), EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name), } @@ -923,7 +982,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai seal := pow.PoW(pow.FakePow{}) if !ctx.GlobalBool(FakePoWFlag.Name) { - seal = pow.NewFullEthash("", "") + seal = pow.NewFullEthash("", 1, 0, "", 0) } chain, err = core.NewBlockChain(chainDb, chainConfig, seal, new(event.TypeMux), vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}) if err != nil { |