fix(nicehash): avoid double-counting expired submissions
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
8b47e6a11b
commit
c74f62e6d7
2 changed files with 7 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue