Skip to content

Commit

Permalink
Added hashrate parsing for cryptodredge
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjaap committed Jul 10, 2019
1 parent e53ed2c commit c0e8375
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions miners/cryptodredge.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ func (l *CryptoDredgeMinerImpl) ParseOutput(line string) {
}
line = strings.TrimSpace(line)

if strings.Contains(line, "GPU #") && strings.HasSuffix(line, "H/s") {
startDeviceIdx := strings.Index(line, "GPU #")
endDeviceIdx := strings.Index(line[startDeviceIdx:], ":")
deviceIdxString := line[startDeviceIdx+5 : startDeviceIdx+endDeviceIdx]
if strings.Contains(line, "INFO - GPU") && strings.Contains(line, "H/s") {
startDeviceIdx := strings.Index(line, "INFO - GPU")
endDeviceIdx := strings.Index(line[startDeviceIdx+9:], " ")
deviceIdxString := line[startDeviceIdx+11 : startDeviceIdx+9+endDeviceIdx]
deviceIdx, err := strconv.ParseInt(deviceIdxString, 10, 64)
if err != nil {
return
}

startMHs := strings.LastIndex(line, ", ")
if startMHs > -1 {
hashRateUnit := strings.ToUpper(line[len(line)-4 : len(line)-3])
line = line[startMHs+2 : len(line)-5]
endMHs := strings.Index(line, "H/s")
if endMHs > -1 {
hashRateUnit := strings.ToUpper(line[endMHs-1 : endMHs])
line = line[:endMHs-1]
line = line[strings.LastIndex(line, " ")+1:]
line = strings.ReplaceAll(line, ",", ".")
f, err := strconv.ParseFloat(line, 64)
if err != nil {
logging.Errorf("Error parsing hashrate: %s\n", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion miners/teamredminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ func (l *TeamRedMinerImpl) HashRate() uint64 {
}

func (l *TeamRedMinerImpl) ConstructCommandlineArgs(args BinaryArguments) []string {
return []string{"--log_interval=1", "--disable_colors", "-a", "lyra2rev3", "-o", args.StratumUrl, "-u", args.StratumUsername, "-p", args.StratumPassword}
return []string{"--log_interval=10", "--disable_colors", "-a", "lyra2rev3", "-o", args.StratumUrl, "-u", args.StratumUsername, "-p", args.StratumPassword}
}

0 comments on commit c0e8375

Please sign in to comment.