fix: mine-validate throughput timing for short runs

Seed the pool job before workers start and sample hashrate every second so sub-5s validations reflect real hashing.
This commit is contained in:
AetherForge
2026-06-08 16:58:46 -07:00
parent 9b2eafd583
commit d4ac5d435a

View File

@@ -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 {