chore: cleanups

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-09-28 04:03:39 +00:00
parent 097c9e9586
commit a0df3d4428
3 changed files with 6 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import (
"math"
"os"
"strconv"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
@@ -35,6 +36,7 @@ type Runner struct {
r wazero.Runtime
code wazero.CompiledModule
fname string
lock sync.Mutex
}
func NewRunner(ctx context.Context, fname string, fin io.ReadCloser) (*Runner, error) {
@@ -269,6 +271,9 @@ func (r *Runner) verify(ctx context.Context, data, verify []byte, nonce, difficu
}
func (r *Runner) Verify(ctx context.Context, data, verify []byte, nonce, difficulty uint32) (bool, error) {
r.lock.Lock()
defer r.lock.Unlock()
t0 := time.Now()
ok, _, err := r.verify(ctx, data, verify, nonce, difficulty)
validationTime.WithLabelValues(r.fname).Observe(float64(time.Since(t0)))