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 committed Jan 26, 2024
1 parent b01524d commit cd896d2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ func newSoloMiner(ctx context.Context, devices []*Device) (*Miner, error) {
return m, nil
}

func newBenchmarkMiner(devices []*Device) (*Miner, error) {

Check failure on line 131 in miner.go

View workflow job for this annotation

GitHub Actions / Go CI (1.20)

newBenchmarkMiner - result 1 (error) is always nil (unparam)
return &Miner{
devices: devices,
}, nil
}

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

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

var m *Miner
if cfg.Pool == "" {
switch {
case cfg.Benchmark:
m, err = newBenchmarkMiner(devices)
case cfg.Pool == "":
m, err = newSoloMiner(ctx, devices)
} else {
default:
m, err = newStratum(devices)
}
if err != nil {
Expand All @@ -152,6 +161,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 cd896d2

Please sign in to comment.