Skip to content

Fix silently-broken block height and fee stats (mempool.space HTTP redirect) - #44

Open
BurtonJeff wants to merge 1 commit into
SneezeGUI:mainfrom
BurtonJeff:fix/broken-stat-fetches
Open

Fix silently-broken block height and fee stats (mempool.space HTTP redirect)#44
BurtonJeff wants to merge 1 commit into
SneezeGUI:mainfrom
BurtonJeff:fix/broken-stat-fetches

Conversation

@BurtonJeff

Copy link
Copy Markdown

Symptoms

Block height and fees show ---/0 forever, on every board, regardless of config. The code comments say "HTTP API - always works", but these two fetches have never returned data.

Root cause

mempool.space 301-redirects HTTP to HTTPS, and HTTPClient doesn't follow redirects — so the plain-HTTP fetchHttp()/raw-client paths get the redirect page's status and fail silently on every call.

Separately, updateNetworkHashrate() is proxy-only (it opens a raw socket to the proxy host), but its guard let direct-HTTPS mode fall through to client.connect(s_proxyHost, ...) with an empty hostname, producing repeated [E] hostByName(): DNS Failed for log spam.

Fix

  • Point API_BLOCK_HEIGHT and API_FEES at https:// and route both through the shared fetchJson() path, which selects proxy or direct HTTPS per config. The block-height endpoint returns a bare number, which is a valid JSON document, so it parses through the same path — updateBlockHeight() loses its bespoke raw-client code.
  • Require a healthy proxy in updateNetworkHashrate().

Behavior notes

With HTTPS disabled (the current default) these stats now skip cleanly instead of failing noisily — they were never being fetched anyway, so nothing regresses. With a proxy or direct HTTPS enabled, height and fees populate for the first time. Direct HTTPS itself is made stable by #43 (the SHA engine collision fix) — the two PRs are independent to merge but complementary in effect.

Verified on an ESP32-2432S028R with direct HTTPS enabled: height and fee values populate within the first stats cycle and refresh on schedule.

🤖 Generated with Claude Code

mempool.space 301-redirects HTTP to HTTPS and HTTPClient does not
follow redirects, so the "HTTP API - always works" block-height and fee
fetches have in fact never worked: both failed silently on every boot
and the screen showed "---"/0 forever.

- Point both endpoints at https:// and route them through the shared
  fetchJson() path, which picks proxy or direct HTTPS per config. The
  block-height endpoint returns a bare number, which is a valid JSON
  document, so it parses through the same path.
- updateNetworkHashrate() is proxy-only (it opens a raw socket to the
  proxy host) but its guard allowed direct-HTTPS mode through, causing
  a connect to an empty hostname and repeated "[E] hostByName(): DNS
  Failed for" log spam. Require a healthy proxy instead.

Note: with HTTPS disabled (the current default), height and fees now
skip cleanly rather than fail noisily - they were never being fetched
anyway. Enabling direct HTTPS is stable once the SHA engine collision
is fixed (see companion PR).
jmarquez84 pushed a commit to jmarquez84/SparkMiner that referenced this pull request Jul 22, 2026
jmarquez84 added a commit to jmarquez84/SparkMiner that referenced this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant