From c74f62e6d74cd5f7db725190fc83a39d1557a42c Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 21:45:57 +0000 Subject: [PATCH] fix(nicehash): avoid double-counting expired submissions Co-Authored-By: Virgil --- splitter/nicehash/impl.go | 1 - splitter/nicehash/mapper_start_test.go | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/splitter/nicehash/impl.go b/splitter/nicehash/impl.go index d32c2ab..9d5d85d 100644 --- a/splitter/nicehash/impl.go +++ b/splitter/nicehash/impl.go @@ -299,7 +299,6 @@ func (m *NonceMapper) OnResultAccepted(sequence int64, accepted bool, errorMessa job := m.storage.job prevJob := m.storage.prevJob m.storage.mu.Unlock() - _ = m.storage.IsValidJobID(ctx.JobID) job, expired := resolveSubmissionJob(ctx.JobID, job, prevJob) m.mu.Unlock() if !ok || miner == nil { diff --git a/splitter/nicehash/mapper_start_test.go b/splitter/nicehash/mapper_start_test.go index 189c0bc..cb8eb96 100644 --- a/splitter/nicehash/mapper_start_test.go +++ b/splitter/nicehash/mapper_start_test.go @@ -137,6 +137,9 @@ func TestMapper_OnResultAccepted_ExpiredUsesPreviousJob(t *testing.T) { mapper.storage.job = proxy.Job{JobID: "job-new", Blob: "blob-new", Target: "b88d0600"} mapper.storage.prevJob = proxy.Job{JobID: "job-old", Blob: "blob-old", Target: "b88d0600"} mapper.storage.miners[miner.ID()] = miner + if !mapper.storage.IsValidJobID("job-old") { + t.Fatal("expected previous job to validate before result handling") + } mapper.pending[9] = SubmitContext{ RequestID: 42, MinerID: miner.ID(), @@ -146,6 +149,10 @@ func TestMapper_OnResultAccepted_ExpiredUsesPreviousJob(t *testing.T) { mapper.OnResultAccepted(9, true, "") + if got := mapper.storage.expired; got != 1 { + t.Fatalf("expected one expired validation, got %d", got) + } + select { case event := <-events: if !event.Expired {