fix(network): keep the status-bar peer count current on every tab
The peer count in the status bar is state_.peers.size(), refreshed only by getpeerinfo — and the peers refresh interval was 0 (disabled) on every tab except Peers. So the count never changed until you opened the Peers/Network tab. Give peers a slow 20s cadence on all tabs (30s on Console); the Peers tab keeps its fast 5s for the live list. During sync this is still overridden by kSyncProfile (peers 0) so it can't contend with block download. Test updated to the new intervals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,16 +8,21 @@ namespace services {
|
||||
RefreshScheduler::Intervals RefreshScheduler::intervalsForPage(ui::NavPage page)
|
||||
{
|
||||
using NP = ui::NavPage;
|
||||
// Intervals are {core, transactions, addresses, peers} in seconds (0 = disabled).
|
||||
// The peers value keeps the status-bar peer count current on EVERY tab — previously it was 0
|
||||
// off the Peers tab, so the count never updated until you opened Peers. A slow 20s cadence is
|
||||
// plenty for a status-bar number; the Peers tab itself stays fast (5s) for its live list. During
|
||||
// sync this is overridden by kSyncProfile (peers 0) so it can't contend with block download.
|
||||
switch (page) {
|
||||
case NP::Overview: return {2.0f, 10.0f, 15.0f, 0.0f};
|
||||
case NP::Send: return {3.0f, 10.0f, 5.0f, 0.0f};
|
||||
case NP::Receive: return {5.0f, 15.0f, 5.0f, 0.0f};
|
||||
case NP::History: return {5.0f, 3.0f, 15.0f, 0.0f};
|
||||
case NP::Mining: return {5.0f, 15.0f, 15.0f, 0.0f};
|
||||
case NP::Overview: return {2.0f, 10.0f, 15.0f, 20.0f};
|
||||
case NP::Send: return {3.0f, 10.0f, 5.0f, 20.0f};
|
||||
case NP::Receive: return {5.0f, 15.0f, 5.0f, 20.0f};
|
||||
case NP::History: return {5.0f, 3.0f, 15.0f, 20.0f};
|
||||
case NP::Mining: return {5.0f, 15.0f, 15.0f, 20.0f};
|
||||
case NP::Peers: return {5.0f, 15.0f, 15.0f, 5.0f};
|
||||
case NP::Market: return {5.0f, 15.0f, 15.0f, 0.0f};
|
||||
case NP::Console: return {10.0f, 30.0f, 30.0f, 0.0f};
|
||||
default: return {5.0f, 15.0f, 15.0f, 0.0f};
|
||||
case NP::Market: return {5.0f, 15.0f, 15.0f, 20.0f};
|
||||
case NP::Console: return {10.0f, 30.0f, 30.0f, 30.0f};
|
||||
default: return {5.0f, 15.0f, 15.0f, 20.0f};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -757,7 +757,8 @@ void testRefreshScheduler()
|
||||
RefreshScheduler scheduler;
|
||||
scheduler.applyPage(dragonx::ui::NavPage::Overview);
|
||||
EXPECT_NEAR(scheduler.intervals().core, 2.0, 0.0001);
|
||||
EXPECT_NEAR(scheduler.intervals().peers, 0.0, 0.0001);
|
||||
// Peers now polls on every tab (slow cadence) so the status-bar peer count stays current.
|
||||
EXPECT_NEAR(scheduler.intervals().peers, 20.0, 0.0001);
|
||||
|
||||
scheduler.tick(1.99f);
|
||||
EXPECT_FALSE(scheduler.isDue(Timer::Core));
|
||||
@@ -779,7 +780,7 @@ void testRefreshScheduler()
|
||||
EXPECT_NEAR(scheduler.intervals().core, 10.0, 0.0001);
|
||||
EXPECT_NEAR(scheduler.intervals().transactions, 30.0, 0.0001);
|
||||
EXPECT_NEAR(scheduler.intervals().addresses, 30.0, 0.0001);
|
||||
EXPECT_NEAR(scheduler.intervals().peers, 0.0, 0.0001);
|
||||
EXPECT_NEAR(scheduler.intervals().peers, 30.0, 0.0001);
|
||||
|
||||
EXPECT_FALSE(scheduler.isDue(Timer::Price));
|
||||
scheduler.markDue(Timer::Price);
|
||||
|
||||
Reference in New Issue
Block a user