Skip to content

Commit

Permalink
miner: Remove need for dcrd in benchmark mode.
Browse files Browse the repository at this point in the history
This makes it possible to run gominer in benchmark mode (-B) without
having setup a dcrd instance.  This is particularly useful when
comissioning new machines or testing the software, so that users do not
have to setup an entire simnet environment or wait for a full mainnet
dcrd and dcrwallet sync.
  • Loading branch information
matheusd authored and davecgh committed Jan 26, 2024
1 parent b01524d commit 68791b0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func newSoloMiner(ctx context.Context, devices []*Device) (*Miner, error) {
return m, nil
}

func newBenchmarkMiner(devices []*Device) *Miner {
return &Miner{devices: devices}
}

func NewMiner(ctx context.Context) (*Miner, error) {
workDone := make(chan []byte, 10)

Expand All @@ -140,9 +144,12 @@ func NewMiner(ctx context.Context) (*Miner, error) {
}

var m *Miner
if cfg.Pool == "" {
switch {
case cfg.Benchmark:
m = newBenchmarkMiner(devices)
case cfg.Pool == "":
m, err = newSoloMiner(ctx, devices)
} else {
default:
m, err = newStratum(devices)
}
if err != nil {
Expand All @@ -152,6 +159,12 @@ func NewMiner(ctx context.Context) (*Miner, error) {
m.workDone = workDone
m.started = uint32(time.Now().Unix())

// Return early on benchmark mode to avoid requiring a dcrd instance to
// be running.
if cfg.Benchmark {
return m, nil
}

// Perform an initial call to getwork when solo mining so work is available
// immediately.
if cfg.Pool == "" {
Expand Down

0 comments on commit 68791b0

Please sign in to comment.