Skip to content

Commit

Permalink
Fix DAG local file cache path parameter karlsen-network#31
Browse files Browse the repository at this point in the history
  • Loading branch information
masben-mb committed Feb 11, 2024
1 parent 0a218ac commit 0eb7ed8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cmd/karlsenminer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/karlsenminer/custoption/customoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
)

type Option struct {
NumThreads uint32
Path string
NumThreads uint32
Path string
DisableLocalDagFile bool
}

func CheckPath(name string) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/karlsenminer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
8 changes: 3 additions & 5 deletions domain/consensus/utils/pow/fishhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0eb7ed8

Please sign in to comment.