Skip to content

Commit

Permalink
Update miner.go
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy0803 authored Apr 7, 2024
1 parent 49d9378 commit f84c5e7
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion proxy/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,17 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param
}

if s.config.Proxy.Debug {
log.Printf("Difficulty pool/block/share = %d / %d / %d(%f) from %v@%v", shareDiff, t.Difficulty, shareDiffCalc, shareDiffFloat, login, ip)
hashrateShareDiff := formatHashrate(shareDiffCalc)
hashrateBlockDiff := formatHashrate(t.Difficulty.Int64()) // Konvertieren zu int64
hashrateShare := formatHashrate(shareDiff)

// Ausgabe der formatierten Informationen in der Kommandozeile (cmd)
log.Printf("Mining Information:")
log.Printf("Blockchain Height: %d", t.Height) // Geändert zu "Blockchain Height"
log.Printf("Pool Difficulty: %d (%s)", shareDiff, hashrateShare)
log.Printf("Block Difficulty: %d (%s)", t.Difficulty.Int64(), hashrateBlockDiff)
log.Printf("Share Difficulty: %d (%s)", shareDiffCalc, hashrateShareDiff)
log.Printf("Submitted by: %v@%v", login, ip)
}

h, ok := t.headers[hashNoNonce]
Expand Down Expand Up @@ -159,3 +169,15 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param
s.backend.WriteWorkerShareStatus(login, id, true, false, false)
return false, true
}
func formatHashrate(shareDiffCalc int64) string {
units := []string{"H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s"}
var i int
diff := float64(shareDiffCalc)

for i = 0; i < len(units)-1 && diff >= 1000.0; i++ {
diff /= 1000.0
}

formatted := strconv.FormatFloat(diff, 'f', 2, 64)
return formatted + " " + units[i]
}

0 comments on commit f84c5e7

Please sign in to comment.