Skip to content

Commit

Permalink
Adds a -debugminer flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjaap committed Jul 10, 2019
1 parent d2a2e8c commit e5f2ebe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"os"
"path/filepath"
Expand All @@ -14,6 +15,8 @@ import (
)

func main() {
debugMiner := flag.Bool("debugminers", false, "Print the output of the miner binaries to the debug log")
flag.Parse()
js := mewn.String("./frontend/dist/app.js")
css := mewn.String("./frontend/dist/app.css")

Expand Down Expand Up @@ -45,6 +48,7 @@ func main() {
})

core := mining.NewMinerCore()
core.DebugMiners = *debugMiner
app.Bind(core)
app.Run()
core.StopMining()
Expand Down
6 changes: 4 additions & 2 deletions miners/ccminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ func (l *CCMinerImpl) Configure(args BinaryArguments) error {
}

func (l *CCMinerImpl) ParseOutput(line string) {
if l.binaryRunner.Debug {
logging.Debugf("[ccminer] %s\n", line)
}
line = strings.TrimSpace(line)
//logging.Debugf("[ccminer] %s\n", line)

if strings.Contains(line, "GPU #") && strings.HasSuffix(line, "MH/s") {
startDeviceIdx := strings.Index(line, "GPU #")
Expand Down Expand Up @@ -58,5 +60,5 @@ func (l *CCMinerImpl) HashRate() uint64 {
}

func (l *CCMinerImpl) ConstructCommandlineArgs(args BinaryArguments) []string {
return []string{"--max-log-rate","0", "--no-color", "-a", "lyra2v3", "-o", args.StratumUrl, "-u", args.StratumUsername, "-p", args.StratumPassword}
return []string{"--max-log-rate", "0", "--no-color", "-a", "lyra2v3", "-o", args.StratumUrl, "-u", args.StratumUsername, "-p", args.StratumPassword}
}
4 changes: 3 additions & 1 deletion miners/lyclminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func (l *LyclMinerImpl) Configure(args BinaryArguments) error {
}

func (l *LyclMinerImpl) ParseOutput(line string) {
//logging.Debugf("[lyclMiner] %s\n", line)
if l.binaryRunner.Debug {
logging.Debugf("[lyclMiner] %s\n", line)
}
line = strings.TrimSpace(line)
if strings.Contains(line, "Device #") && strings.HasSuffix(line, "MH/s") {
startDeviceIdx := strings.Index(line, "Device #")
Expand Down
1 change: 1 addition & 0 deletions miners/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type BinaryRunner struct {
MinerBinary MinerBinary
MinerImpl MinerImpl
cmd *exec.Cmd
Debug bool
}

func (b *BinaryRunner) logPrefix() string {
Expand Down
2 changes: 2 additions & 0 deletions mining/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MinerCore struct {
stopHash chan bool
stopBalance chan bool
stopRunningState chan bool
DebugMiners bool
}

func NewMinerCore() *MinerCore {
Expand Down Expand Up @@ -159,6 +160,7 @@ func (m *MinerCore) CreateMinerBinaries() ([]*miners.BinaryRunner, error) {
if match {
logging.Debugf("Found compatible binary [%s] for [%s/%d]\n", b.MainExecutableName, b.Platform, b.GPUType)
br, err := miners.NewBinaryRunner(b)
br.Debug = m.DebugMiners
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e5f2ebe

Please sign in to comment.