The full-node wallet polled the daemon at the per-tab cadence regardless of sync state.
On the Peers/Network tab that meant getpeerinfo every 5s + core every 5s + a full
transaction scan on every new block — and blocks arrive fast during sync. Each of those
calls takes the daemon's cs_main lock, the same lock block connection needs, so the node
synced noticeably slower than on the lightweight Console tab (core 10s, no peer polling).
Make the refresh cadence sync-aware:
- RefreshScheduler::kSyncProfile {core 10s, transactions/addresses/peers disabled} is applied
to ALL tabs while state_.sync.syncing, and reverts to the per-tab profile when sync ends.
applyRefreshPolicy() picks the profile; update() re-applies it on the syncing<->synced
transition. This suppresses getpeerinfo and the per-block tx scan during sync (that data is
incomplete mid-sync anyway) — every tab now syncs as fast as Console.
- collectCoreRefreshResult(rpc, includeBalance): skip z_gettotalbalance (wallet lock + cs_main)
while syncing; only getblockchaininfo runs, which is also what drives sync-progress detection.
applyCoreRefreshResult already leaves the balance untouched when balanceOk is false.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "ui/sidebar.h"
|
|
|
|
namespace dragonx {
|
|
namespace services {
|
|
|
|
class RefreshScheduler {
|
|
public:
|
|
enum class Timer {
|
|
Core,
|
|
Transactions,
|
|
Addresses,
|
|
Peers,
|
|
Price,
|
|
Fast,
|
|
TxAge,
|
|
Opid
|
|
};
|
|
|
|
struct Intervals {
|
|
float core;
|
|
float transactions;
|
|
float addresses;
|
|
float peers;
|
|
};
|
|
|
|
static constexpr float kCoreDefault = 5.0f;
|
|
static constexpr float kAddressDefault = 15.0f;
|
|
static constexpr float kTransactionDefault = 10.0f;
|
|
static constexpr float kPeerDefault = 10.0f;
|
|
static constexpr float kPrice = 60.0f;
|
|
static constexpr float kFast = 1.0f;
|
|
static constexpr float kTxMaxAge = 15.0f;
|
|
static constexpr float kOpidPoll = 2.0f;
|
|
|
|
// Low-impact polling profile applied while the daemon is SYNCING, regardless of the active tab.
|
|
// Only a slow progress poll runs (core, 10s); transactions/addresses/peers are disabled (0).
|
|
// Frequent getpeerinfo, per-block transaction scans, and balance polls all contend for the
|
|
// daemon's cs_main lock and measurably slow block connection during sync — this is exactly why
|
|
// the lightweight Console tab syncs faster than the Peers tab. Reverts to the per-tab profile
|
|
// once sync completes. (Tx/address/balance data is incomplete mid-sync anyway.)
|
|
static constexpr Intervals kSyncProfile{10.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
static Intervals intervalsForPage(ui::NavPage page);
|
|
|
|
void applyPage(ui::NavPage page);
|
|
void setIntervals(Intervals intervals);
|
|
const Intervals& intervals() const { return intervals_; }
|
|
|
|
void tick(float deltaSeconds);
|
|
|
|
bool isDue(Timer timer) const;
|
|
bool consumeDue(Timer timer);
|
|
void reset(Timer timer);
|
|
void markDue(Timer timer);
|
|
void setTimer(Timer timer, float seconds);
|
|
float timer(Timer timer) const;
|
|
float interval(Timer timer) const;
|
|
|
|
void markImmediateRefresh();
|
|
void markWalletMutationRefresh();
|
|
void resetTxAge();
|
|
bool shouldRefreshTransactions(int lastTxBlockHeight,
|
|
int currentBlockHeight,
|
|
bool transactionsDirty) const;
|
|
|
|
private:
|
|
struct Timers {
|
|
float core = 0.0f;
|
|
float transactions = 0.0f;
|
|
float addresses = 0.0f;
|
|
float peers = 0.0f;
|
|
float price = 0.0f;
|
|
float fast = 0.0f;
|
|
float txAge = 0.0f;
|
|
float opid = 0.0f;
|
|
};
|
|
|
|
float& timerRef(Timer timer);
|
|
const float& timerRef(Timer timer) const;
|
|
|
|
Intervals intervals_{kCoreDefault, kTransactionDefault, kAddressDefault, kPeerDefault};
|
|
Timers timers_;
|
|
};
|
|
|
|
} // namespace services
|
|
} // namespace dragonx
|