perf(market): fetch price and market data on a dedicated HTTP lane
The CoinGecko price, tickers and market chart and the exchange candle GETs ran on the wallet's RPC worker, the same FIFO lane as balance, history and sends. A slow or blocked endpoint held that lane for up to 10-12 s per price or ticker fetch and 2 x 30 s per chart or candle job, and a wallet scan in turn delayed the price. At quit a hung GET held shutdown until the 15 s watchdog cut teardown short. They now run on their own RPCWorker thread; results are applied on the main thread and wake the idle loop. A new util::httpGet takes a cancel flag (checked by libcurl's progress callback), sets CURLOPT_NOSIGNAL and returns the HTTP status and error; httpGetString wraps it. Shutdown sets the flag, so queued GETs return at once and one in flight aborts within about a second. The price uses a plain in-flight flag instead of the connection-scoped refresh job, so a disconnect no longer throws away a good in-flight price and leaves it loading until the next tick. User-visible: - chart and candle GETs use a 5 s connect / 20 s total timeout (were 15 s / 30 s); - the price request goes through the shared GET: User-Agent ObsidianDragon/1.0 (was DragonX-Wallet/1.0) and a 16 MiB reply cap; - market fetches on connect start alongside the wallet refresh instead of queuing behind it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+22
-1
@@ -516,6 +516,9 @@ bool App::init()
|
||||
// Initialize background RPC worker thread
|
||||
worker_ = std::make_unique<rpc::RPCWorker>();
|
||||
worker_->start();
|
||||
// HTTP lane for the market data (price / tickers / charts). Both variants: the lite build has a Market tab.
|
||||
http_worker_ = std::make_unique<rpc::RPCWorker>();
|
||||
http_worker_->start();
|
||||
network_refresh_.markDue(services::NetworkRefreshService::Timer::Price);
|
||||
|
||||
// Warm the Mining tab's data at startup (both async / off the UI thread) so pool
|
||||
@@ -827,6 +830,9 @@ void App::update()
|
||||
if (worker_) {
|
||||
worker_->drainResults();
|
||||
}
|
||||
if (http_worker_) {
|
||||
http_worker_->drainResults(); // market data (update() also runs while minimized)
|
||||
}
|
||||
if (fast_worker_) {
|
||||
fast_worker_->drainResults();
|
||||
}
|
||||
@@ -6235,6 +6241,13 @@ void App::beginShutdown()
|
||||
if (fast_worker_) {
|
||||
fast_worker_->requestStop();
|
||||
}
|
||||
// HTTP lane: requestStop() alone would still run every queued GET to completion (RPCWorker::run drains its
|
||||
// queue). The flag makes queued GETs return at once and aborts an in-flight transfer through libcurl's
|
||||
// progress callback; shutdown() joins.
|
||||
http_cancel_.store(true, std::memory_order_relaxed);
|
||||
if (http_worker_) {
|
||||
http_worker_->requestStop();
|
||||
}
|
||||
|
||||
// Drain + join the mining-control thread FIRST so no async start/stop job runs while we tear the miner
|
||||
// down here (avoids two threads driving xmrig_manager_ during shutdown). (M-03 cluster)
|
||||
@@ -7352,6 +7365,7 @@ void App::shutdown()
|
||||
// do synchronous shutdown as fallback.
|
||||
if (!shutting_down_) {
|
||||
DEBUG_LOGF("Synchronous shutdown fallback...\n");
|
||||
http_cancel_.store(true, std::memory_order_relaxed); // queued / in-flight market GETs end at once
|
||||
async_tasks_.cancelAll();
|
||||
async_tasks_.joinAll();
|
||||
if (rpc_) rpc_->requestAbort(); // unblock any in-flight curl before joining
|
||||
@@ -7362,6 +7376,9 @@ void App::shutdown()
|
||||
if (fast_worker_) {
|
||||
fast_worker_->stop();
|
||||
}
|
||||
if (http_worker_) {
|
||||
http_worker_->stop();
|
||||
}
|
||||
if (settings_) {
|
||||
settings_->save();
|
||||
}
|
||||
@@ -7389,6 +7406,9 @@ void App::shutdown()
|
||||
if (fast_worker_) {
|
||||
fast_worker_->stop();
|
||||
}
|
||||
if (http_worker_) {
|
||||
http_worker_->stop(); // http_cancel_ was set in beginShutdown(): an in-flight GET aborts within ~1 s
|
||||
}
|
||||
// Disconnect RPC after worker is fully stopped (safe — no curl in flight)
|
||||
if (rpc_) {
|
||||
rpc_->disconnect();
|
||||
@@ -7459,7 +7479,8 @@ void App::verifyDebugCredential(const std::string& secret, std::function<void(bo
|
||||
|
||||
bool App::hasPendingBackgroundResults() const {
|
||||
return (worker_ && worker_->hasPendingResults())
|
||||
|| (fast_worker_ && fast_worker_->hasPendingResults());
|
||||
|| (fast_worker_ && fast_worker_->hasPendingResults())
|
||||
|| (http_worker_ && http_worker_->hasPendingResults());
|
||||
}
|
||||
|
||||
std::string App::transactionSendProgressText() const
|
||||
|
||||
Reference in New Issue
Block a user