Skip to content

Commit

Permalink
cmd: better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 2, 2024
1 parent 2472f9f commit 7c4cfc2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/cpuminerd/mine.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func mineBlock(ctx context.Context, cs consensus.State, txns []types.Transaction
return
case <-time.After(10 * time.Second):
rate := float64(atomic.LoadUint64(&hashes)) / time.Since(start).Seconds()
log.Debug("mining", zap.Float64("rate", rate), zap.Int("workers", workers))
log.Info("mining", zap.Float64("rate", rate), zap.Int("workers", workers))
}
}
}()
Expand All @@ -95,8 +95,8 @@ func mineBlock(ctx context.Context, cs consensus.State, txns []types.Transaction
for i := 0; i < workers; i++ {
workerBuf := make([]byte, len(buf))
copy(workerBuf, buf)
log := log.With(zap.Int("worker", i+1))
go func(n int, nonce uint64, buf []byte) {

for {
select {
case <-ctx.Done():
Expand All @@ -106,9 +106,10 @@ func mineBlock(ctx context.Context, cs consensus.State, txns []types.Transaction
h := types.BlockID(types.HashBytes(buf))
atomic.AddUint64(&hashes, 1)
if h.CmpWork(cs.ChildTarget) < 0 {
log.Debug("bad nonce", zap.Uint64("nonce", nonce))
continue
}

log.Debug("found nonce", zap.Uint64("nonce", nonce))
select {
case resultCh <- nonce:
default:
Expand Down

0 comments on commit 7c4cfc2

Please sign in to comment.