Refactor app services and stabilize refresh/UI flows

- Add refresh scheduler and network refresh service boundaries for typed
  refresh results, ordered RPC collectors, applicators, and price parsing.
- Add daemon lifecycle and wallet security workflow helpers while preserving
  App-owned command RPC, decrypt, cancellation, and UI handoff behavior.
- Split balance, console, mining, amount formatting, and async task logic into
  focused modules with expanded Phase 4 test coverage.
- Fix market price loading by triggering price refresh immediately, avoiding
  queue-pressure drops, tracking loading/error state, and adding translations.
- Polish send, explorer, peers, settings, theme/schema, and related tab UI.
- Replace checked-in generated language headers with build-generated resources.
- Document the cleanup audit, UI static-state guidance, and architecture updates.
This commit is contained in:
2026-04-29 12:47:57 -05:00
parent ee8a08e569
commit 9edab31728
95 changed files with 8776 additions and 37563 deletions

View File

@@ -0,0 +1,158 @@
#include "refresh_scheduler.h"
#include <algorithm>
namespace dragonx {
namespace services {
RefreshScheduler::Intervals RefreshScheduler::intervalsForPage(ui::NavPage page)
{
using NP = ui::NavPage;
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::Peers: return {5.0f, 15.0f, 15.0f, 5.0f};
case NP::Market: return {5.0f, 15.0f, 15.0f, 0.0f};
default: return {5.0f, 15.0f, 15.0f, 0.0f};
}
}
void RefreshScheduler::applyPage(ui::NavPage page)
{
setIntervals(intervalsForPage(page));
}
void RefreshScheduler::setIntervals(Intervals intervals)
{
intervals_ = intervals;
}
void RefreshScheduler::tick(float deltaSeconds)
{
float delta = std::max(0.0f, deltaSeconds);
timers_.core += delta;
timers_.transactions += delta;
timers_.addresses += delta;
timers_.peers += delta;
timers_.price += delta;
timers_.fast += delta;
timers_.txAge += delta;
timers_.opid += delta;
}
bool RefreshScheduler::isDue(Timer timer) const
{
float timerInterval = interval(timer);
return timerInterval > 0.0f && timerRef(timer) >= timerInterval;
}
bool RefreshScheduler::consumeDue(Timer timer)
{
if (!isDue(timer)) return false;
reset(timer);
return true;
}
void RefreshScheduler::reset(Timer timer)
{
timerRef(timer) = 0.0f;
}
void RefreshScheduler::markDue(Timer timer)
{
float timerInterval = interval(timer);
timerRef(timer) = timerInterval > 0.0f ? timerInterval : 0.0f;
}
void RefreshScheduler::setTimer(Timer timer, float seconds)
{
timerRef(timer) = std::max(0.0f, seconds);
}
float RefreshScheduler::timer(Timer timer) const
{
return timerRef(timer);
}
float RefreshScheduler::interval(Timer timer) const
{
switch (timer) {
case Timer::Core: return intervals_.core;
case Timer::Transactions: return intervals_.transactions;
case Timer::Addresses: return intervals_.addresses;
case Timer::Peers: return intervals_.peers;
case Timer::Price: return kPrice;
case Timer::Fast: return kFast;
case Timer::TxAge: return kTxMaxAge;
case Timer::Opid: return kOpidPoll;
}
return 0.0f;
}
void RefreshScheduler::markImmediateRefresh()
{
markDue(Timer::Core);
markDue(Timer::Transactions);
markDue(Timer::Addresses);
markDue(Timer::Peers);
}
void RefreshScheduler::markWalletMutationRefresh()
{
markDue(Timer::Core);
markDue(Timer::Transactions);
markDue(Timer::Addresses);
}
void RefreshScheduler::resetTxAge()
{
reset(Timer::TxAge);
}
bool RefreshScheduler::shouldRefreshTransactions(int lastTxBlockHeight,
int currentBlockHeight,
bool transactionsEmpty,
bool transactionsDirty) const
{
return lastTxBlockHeight < 0
|| currentBlockHeight != lastTxBlockHeight
|| transactionsEmpty
|| transactionsDirty
|| isDue(Timer::TxAge);
}
float& RefreshScheduler::timerRef(Timer timer)
{
switch (timer) {
case Timer::Core: return timers_.core;
case Timer::Transactions: return timers_.transactions;
case Timer::Addresses: return timers_.addresses;
case Timer::Peers: return timers_.peers;
case Timer::Price: return timers_.price;
case Timer::Fast: return timers_.fast;
case Timer::TxAge: return timers_.txAge;
case Timer::Opid: return timers_.opid;
}
return timers_.core;
}
const float& RefreshScheduler::timerRef(Timer timer) const
{
switch (timer) {
case Timer::Core: return timers_.core;
case Timer::Transactions: return timers_.transactions;
case Timer::Addresses: return timers_.addresses;
case Timer::Peers: return timers_.peers;
case Timer::Price: return timers_.price;
case Timer::Fast: return timers_.fast;
case Timer::TxAge: return timers_.txAge;
case Timer::Opid: return timers_.opid;
}
return timers_.core;
}
} // namespace services
} // namespace dragonx