mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-14 04:28:49 +00:00
@@ -8,6 +8,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -35,6 +36,7 @@ type Runner struct {
|
|||||||
r wazero.Runtime
|
r wazero.Runtime
|
||||||
code wazero.CompiledModule
|
code wazero.CompiledModule
|
||||||
fname string
|
fname string
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRunner(ctx context.Context, fname string, fin io.ReadCloser) (*Runner, error) {
|
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) {
|
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()
|
t0 := time.Now()
|
||||||
ok, _, err := r.verify(ctx, data, verify, nonce, difficulty)
|
ok, _, err := r.verify(ctx, data, verify, nonce, difficulty)
|
||||||
validationTime.WithLabelValues(r.fname).Observe(float64(time.Since(t0)))
|
validationTime.WithLabelValues(r.fname).Observe(float64(time.Since(t0)))
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ export default {
|
|||||||
fast: fast,
|
fast: fast,
|
||||||
slow: fast, // XXX(Xe): slow is deprecated, but keep this around in case anything goes bad
|
slow: fast, // XXX(Xe): slow is deprecated, but keep this around in case anything goes bad
|
||||||
|
|
||||||
argon2id: wasm,
|
hashx: wasm,
|
||||||
sha256: wasm,
|
sha256: wasm,
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,6 @@ interface AnubisExports {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addEventListener("message", async (event: MessageEvent<Args>) => {
|
addEventListener("message", async (event: MessageEvent<Args>) => {
|
||||||
console.log(event.data);
|
|
||||||
const { data, difficulty, threads, module } = event.data;
|
const { data, difficulty, threads, module } = event.data;
|
||||||
let { nonce } = event.data;
|
let { nonce } = event.data;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user