From e94616922d251e18b367d846c1e8c0f891755801 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sun, 5 Apr 2026 00:56:17 +0000 Subject: [PATCH] Fix simple mapper recovery state --- splitter/simple/impl.go | 2 ++ splitter/simple/impl_test.go | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/splitter/simple/impl.go b/splitter/simple/impl.go index ad0597f..01839ec 100644 --- a/splitter/simple/impl.go +++ b/splitter/simple/impl.go @@ -304,6 +304,8 @@ func (m *SimpleMapper) OnJob(job proxy.Job) { m.mu.Lock() m.prevJob = m.currentJob m.currentJob = job + m.stopped = false + m.idleAt = time.Time{} miner := m.miner m.mu.Unlock() if miner == nil { diff --git a/splitter/simple/impl_test.go b/splitter/simple/impl_test.go index c24f70b..8c62267 100644 --- a/splitter/simple/impl_test.go +++ b/splitter/simple/impl_test.go @@ -136,6 +136,29 @@ func TestSimpleSplitter_Upstreams_Ugly(t *testing.T) { } } +func TestSimpleSplitter_Upstreams_RecoveryResetsStopped_Good(t *testing.T) { + splitter := NewSimpleSplitter(&proxy.Config{ReuseTimeout: 30}, nil, func(listener pool.StratumListener) pool.Strategy { + return activeStrategy{} + }) + mapper := &SimpleMapper{id: 1, strategy: activeStrategy{}, stopped: true} + splitter.active[1] = mapper + + before := splitter.Upstreams() + if before.Error != 1 { + t.Fatalf("expected disconnected mapper to count as error, got %+v", before) + } + + mapper.OnJob(proxy.Job{JobID: "job-1", Blob: "blob"}) + + after := splitter.Upstreams() + if after.Active != 1 { + t.Fatalf("expected recovered mapper to count as active, got %+v", after) + } + if after.Error != 0 { + t.Fatalf("expected recovered mapper not to remain in error, got %+v", after) + } +} + type discardConn struct{} func (discardConn) Read([]byte) (int, error) { return 0, io.EOF }