fix(daemon): reset the console offset to the watermark on restart
When the daemon was restarted, the output-parse offset was reset to 0. The daemon's output buffer is retained across runs, so the next poll re-read the whole retained tail of the previous run and fed it to the busy tracker as if it were fresh. A witness rebuild or rescan line left over from the old run could then be mistaken for activity in the new one. - On restart the offset is now reset to the absolute end of the output at that moment, captured on the lifecycle thread after the stop and before the start, so the UI resumes parsing only the new run's output rather than replaying the old tail. - The capture is handed to the UI thread through a pending flag and applied there before the next read, both on the normal poll and when skipping the backlog, so the offset is only ever moved on the thread that owns it. Tests cover reading from the captured watermark (only the new run is seen) versus the old reset-to-0 behaviour (the previous run replays). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6105,6 +6105,24 @@ void testOutputWindowSaturation()
|
||||
EXPECT_EQ(offset, total);
|
||||
}
|
||||
|
||||
void testOutputEndWatermarkReplay()
|
||||
{
|
||||
using dragonx::daemon::appendBounded;
|
||||
using dragonx::daemon::outputWindowSince;
|
||||
const size_t cap = 1024 * 1024;
|
||||
std::string buf;
|
||||
size_t total = 0;
|
||||
const std::string run1 = "run1 rescanning\nrun1 rescan complete\n";
|
||||
appendBounded(buf, total, run1.data(), run1.size(), cap);
|
||||
const size_t end = total; // what getOutputEnd() reports at the pre-start boundary
|
||||
const std::string run2 = "run2 start\n";
|
||||
appendBounded(buf, total, run2.data(), run2.size(), cap);
|
||||
size_t off = end;
|
||||
EXPECT_EQ(outputWindowSince(buf, total, off), run2); // only the new run, none of run1
|
||||
size_t zero = 0;
|
||||
EXPECT_EQ(outputWindowSince(buf, total, zero), run1 + run2); // the old reset-to-0 replayed run1
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// S6: the busy gate (don't flood a busy node's RPC queue) and the connect backoff.
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
@@ -18656,6 +18674,7 @@ int main()
|
||||
testShouldConfirmStop();
|
||||
testOutputSinceAcrossTrim();
|
||||
testOutputWindowSaturation();
|
||||
testOutputEndWatermarkReplay();
|
||||
testChooseDaemonStatus();
|
||||
testDaemonStopStringsTranslated();
|
||||
testMiningAddressStringsTranslated();
|
||||
|
||||
Reference in New Issue
Block a user