fix: mine-validate throughput timing for short runs
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

This commit is contained in:
AetherForge
2026-06-08 17:00:05 -07:00

View File

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