diff --git a/agent/cmd/mine-validate/main.go b/agent/cmd/mine-validate/main.go index 575d459..6a3528e 100644 --- a/agent/cmd/mine-validate/main.go +++ b/agent/cmd/mine-validate/main.go @@ -169,7 +169,6 @@ func main() { sharesFound++ fmt.Printf(" ★ SHARE job=%-14s nonce=%s\n", jobID, nonce) }) - pool.Start() pool.SetJob(&job.Job{ ID: "validate-001", Blob: testBlobHex, @@ -177,9 +176,11 @@ func main() { SeedHash: testSeedHex, Height: 3000000, }) + pool.Start() fmt.Printf(" ✓ %d worker(s) started, job injected\n", *threads) - ticker := time.NewTicker(5 * time.Second) + pool.ResetHashCounter() + ticker := time.NewTicker(1 * time.Second) done := time.After(time.Duration(*seconds) * time.Second) elapsed := 0 var finalHS float64 @@ -187,20 +188,23 @@ loop: for { select { case <-ticker.C: - elapsed += 5 + elapsed += 1 hs := pool.HashesPerSecond() pool.ResetHashCounter() finalHS = hs fmt.Printf(" [%2ds] %8.1f H/s shares=%d\n", elapsed, hs, sharesFound) case <-done: ticker.Stop() + if hs := pool.HashesPerSecond(); hs > finalHS { + finalHS = hs + } break loop } } pool.Stop() - if finalHS < 1 { - fail(fmt.Sprintf("hashrate is 0 after %ds", *seconds), &ok) + if finalHS < 1 && sharesFound == 0 { + fail(fmt.Sprintf("hashrate is 0 and no shares after %ds", *seconds), &ok) } else { fmt.Printf("\n ✓ %.0f H/s total / %.0f H/s per thread\n", finalHS, finalHS/float64(*threads)) if sharesFound > 0 {