diff --git a/pkg/mining/xmrig.go b/pkg/mining/xmrig.go index dedf422..8ad85f0 100644 --- a/pkg/mining/xmrig.go +++ b/pkg/mining/xmrig.go @@ -574,6 +574,18 @@ func (m *XMRigMiner) AddHashratePoint(point HashratePoint) { // ReduceHashrateHistory aggregates older high-resolution data into 1-minute averages // and adds them to the low-resolution history. +func (m *XMRigMiner) GetHighResHistoryLength() int { + m.mu.Lock() + defer m.mu.Unlock() + return len(m.HashrateHistory) +} + +func (m *XMRigMiner) GetLowResHistoryLength() int { + m.mu.Lock() + defer m.mu.Unlock() + return len(m.LowResHashrateHistory) +} + func (m *XMRigMiner) ReduceHashrateHistory(now time.Time) { m.mu.Lock() defer m.mu.Unlock() diff --git a/pkg/mining/xmrig_test.go b/pkg/mining/xmrig_test.go index 80d8969..f0bba41 100644 --- a/pkg/mining/xmrig_test.go +++ b/pkg/mining/xmrig_test.go @@ -210,14 +210,12 @@ func TestXMRigMiner_HashrateHistory(t *testing.T) { miner.ReduceHashrateHistory(future) // After reduction, high-res history should be smaller - miner.mu.Lock() - if len(miner.HashrateHistory) >= 10 { - t.Errorf("High-res history not reduced, size: %d", len(miner.HashrateHistory)) + if miner.GetHighResHistoryLength() >= 10 { + t.Errorf("High-res history not reduced, size: %d", miner.GetHighResHistoryLength()) } - if len(miner.LowResHashrateHistory) == 0 { + if miner.GetLowResHistoryLength() == 0 { t.Error("Low-res history not populated") } - miner.mu.Unlock() combinedHistory := miner.GetHashrateHistory() if len(combinedHistory) == 0 {