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:
2026-10-09 21:09:48 -05:00
co-authored by Claude Opus 5.5
parent 93b6871511
commit ad0f60a747
6 changed files with 182 additions and 88 deletions
+17
View File
@@ -69,6 +69,7 @@
#include "util/xmrig_updater.h"
#include "util/pool_registry.h"
#include "util/daemon_updater.h"
#include "util/http_download.h"
#include "util/lite_server_probe.h"
#include "util/wallet_file_probe.h"
#include "wallet/lite_connection_service.h"
@@ -4431,6 +4432,21 @@ void testFetchBackoff()
}
}
// C73: a cancelled GET returns before touching the network.
void testHttpGetCancel()
{
std::atomic<bool> cancel{true};
dragonx::util::HttpGetOptions o;
o.cancel = &cancel;
const dragonx::util::HttpGetResult r = dragonx::util::httpGet("https://127.0.0.1:9/never", "[test]", o);
EXPECT_TRUE(r.cancelled);
EXPECT_FALSE(r.transportOk);
EXPECT_EQ(r.httpStatus, 0L);
EXPECT_TRUE(r.body.empty());
EXPECT_EQ(r.error, std::string("cancelled"));
EXPECT_EQ(dragonx::util::httpGetString("https://127.0.0.1:9/never", "[test]", o), std::string());
}
void testConnectRetryBackoff()
{
using dragonx::rpc::ConnectRetryBackoff;
@@ -12792,6 +12808,7 @@ int main()
testRpcKindClasses();
testConnectRetryBackoff();
testFetchBackoff();
testHttpGetCancel();
testNetworkRefreshService();
testNetworkRefreshSnapshotHelpers();
testParseDaemonRescanOutput();