diff --git a/proxy/miner.go b/proxy/miner.go index a3b8ddb..d8122c9 100644 --- a/proxy/miner.go +++ b/proxy/miner.go @@ -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] @@ -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] +}