fix(mining): stamp hashrate history and label the chart by real time
The hashrate sparkline guessed the age of its oldest sample from the sample count, labelling the left edge "5m ago", "1m ago" or "start" regardless of how fast samples actually arrived. Solo and pool samples come in at different intervals, and a slow or stalled poll made those labels wrong. - Each hashrate sample now carries a wall-clock timestamp, kept in lockstep with the value as the history fills and rolls over, for both the solo and pool histories. - The chart's left-edge label is derived from the oldest sample's actual timestamp, falling back to "start" only when no stamp is available. Tests: a mining refresh records a timestamp per sample, and the timestamp history stays the same length as the value history once the history is capped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2612,6 +2612,16 @@ void testNetworkRefreshResultModels()
|
||||
EXPECT_EQ(state.mining.genproclimit, 4);
|
||||
EXPECT_NEAR(state.mining.localHashrate, 45.0, 0.0001);
|
||||
EXPECT_EQ(state.mining.hashrate_history.size(), static_cast<size_t>(1));
|
||||
EXPECT_EQ(state.mining.hashrate_history_t.size(), static_cast<size_t>(1));
|
||||
EXPECT_EQ(state.mining.hashrate_history_t[0], static_cast<std::time_t>(2345));
|
||||
{
|
||||
auto capState = state;
|
||||
for (int i = 0; i < dragonx::MiningInfo::MAX_HISTORY + 20; ++i) {
|
||||
Refresh::applyMiningRefreshResult(capState, mining, 3000 + i);
|
||||
}
|
||||
EXPECT_EQ(capState.mining.hashrate_history.size(), static_cast<size_t>(dragonx::MiningInfo::MAX_HISTORY));
|
||||
EXPECT_EQ(capState.mining.hashrate_history_t.size(), capState.mining.hashrate_history.size());
|
||||
}
|
||||
EXPECT_NEAR(state.mining.networkHashrate, 900.0, 0.0001);
|
||||
EXPECT_NEAR(state.mining.daemon_memory_mb, 64.0, 0.0001);
|
||||
EXPECT_EQ(state.last_mining_update, static_cast<int64_t>(2345));
|
||||
|
||||
Reference in New Issue
Block a user