diff --git a/cmd/karlsenminer/config.go b/cmd/karlsenminer/config.go index 24b9fea8fc..e6a9f9cb4b 100644 --- a/cmd/karlsenminer/config.go +++ b/cmd/karlsenminer/config.go @@ -39,7 +39,8 @@ type configFlags struct { MineWhenNotSynced bool `long:"mine-when-not-synced" description:"Mine even if the node is not synced with the rest of the network."` Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"` TargetBlocksPerSecond *float64 `long:"target-blocks-per-second" description:"Sets a maximum block rate. 0 means no limit (The default one is 2 * target network block rate)"` - HashesPath string `long:"hashespath" description:"Path to save hashes.dat. I omitted no file will be created"` + HashesPath string `long:"hashespath" description:"Custom path to save hashes.dat."` + DisableLocalDagFile bool `long:"disable-local-dag-file" description:"Disable saving local dag file."` config.NetworkFlags } diff --git a/cmd/karlsenminer/custoption/customoption.go b/cmd/karlsenminer/custoption/customoption.go index 64f40ca5ba..472ce71402 100644 --- a/cmd/karlsenminer/custoption/customoption.go +++ b/cmd/karlsenminer/custoption/customoption.go @@ -7,8 +7,9 @@ import ( ) type Option struct { - NumThreads uint32 - Path string + NumThreads uint32 + Path string + DisableLocalDagFile bool } func CheckPath(name string) error { diff --git a/cmd/karlsenminer/main.go b/cmd/karlsenminer/main.go index bfd2f224f5..066a32d0ec 100644 --- a/cmd/karlsenminer/main.go +++ b/cmd/karlsenminer/main.go @@ -55,8 +55,9 @@ func main() { } customOpt := &custoption.Option{ - NumThreads: 7, - Path: cfg.HashesPath, + NumThreads: 7, + Path: cfg.HashesPath, + DisableLocalDagFile: cfg.DisableLocalDagFile, } if customOpt.Path != "" { diff --git a/domain/consensus/utils/pow/fishhash.go b/domain/consensus/utils/pow/fishhash.go index 5e9344c1f2..7398231e84 100644 --- a/domain/consensus/utils/pow/fishhash.go +++ b/domain/consensus/utils/pow/fishhash.go @@ -135,10 +135,8 @@ func prebuildDataset(ctx *fishhashContext, numThreads uint32, customOpt *custopt } filename := "hashes.dat" - if customOpt != nil && customOpt.Path != "" { - if customOpt.Path == "/" { - filename = customOpt.Path + filename - } else { + if customOpt != nil && !customOpt.DisableLocalDagFile { + if customOpt.Path != "" { filename = customOpt.Path + "/" + filename } log.Infof("Verifying if DAG local storage file already exists ...") @@ -186,7 +184,7 @@ func prebuildDataset(ctx *fishhashContext, numThreads uint32, customOpt *custopt log.Debugf("debug DAG hash[42] : %x", ctx.FullDataset[42]) log.Debugf("debug DAG hash[12345] : %x", ctx.FullDataset[12345]) - if customOpt != nil && customOpt.Path != "" { + if customOpt != nil && !customOpt.DisableLocalDagFile { log.Infof("Saving DAG to local storage file ...") err := mapHashesToFile(ctx.FullDataset, filename) if err != nil {