Skip to content

web: report real c2pool peer count + pool hashrate in getinfo/getstats - #304

Merged
frstrtr merged 1 commit into
masterfrom
ltc-doge/web-api-real-peer-hashrate
Jun 21, 2026
Merged

web: report real c2pool peer count + pool hashrate in getinfo/getstats#304
frstrtr merged 1 commit into
masterfrom
ltc-doge/web-api-real-peer-hashrate

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Problem

Operator hit two false "no peers / 0 hashrate" alarms: the dashboard/API (getinfo/getstats) reported connections=0 and poolhashps=0 while the node actually had ~30 LTC peers and ~129 GH/s live (visible in debug.log).

Root cause

getinfo()/getstats() read peer count + hashrate from the m_node accessors (get_connected_peers_count() / get_hashrate_stats()). In the embedded prod build m_node is the unpopulated enhanced_node stub object — those accessors return 0. The REAL values are already wired into the MiningInterface via m_peer_info_fn (real c2pool share peers) and m_pool_hashrate_fn (real attempts/s from get_pool_attempts_per_second), and are already trusted by rest_local_stats.

Fix

getinfo/getstats now prefer the live hooks, falling back to the m_node accessor only when a hook is unset. Web/diagnostic layer only — no consensus / sharechain / wire change. Single-TU compile verified locally.

Follow-up (NOT in this PR)

Separately-labeled embedded LTC and DOGE core-daemon peer counts. Their source is genuinely ambiguous (external litecoind/dogecoind RPC getpeerinfo vs embedded SPV single-peer vs merged coin_peer_manager) and I will not ship a third potentially-misleading number by guessing. Tracking separately; need a one-line confirm on the intended source.

getinfo() and getstats() read connections and poolhashps from the
m_node accessors. In the embedded prod build m_node is the unpopulated
enhanced_node stub whose get_connected_peers_count()/get_hashrate_stats()
return 0, so the dashboard/API showed connections=0 and poolhashps=0
even with ~30 LTC peers and ~129 GH/s live -- two false no-peers/0-hashrate
alarms.

Prefer the live MiningInterface hooks (m_peer_info_fn for real c2pool
share peers, m_pool_hashrate_fn for real attempts/s from the tracker)
which are already wired in c2pool_refactored.cpp and consumed by
rest_local_stats. Fall back to the m_node accessors when a hook is unset.

Web/diagnostic layer only -- no consensus, sharechain, or wire change.
@frstrtr
frstrtr merged commit ca72a84 into master Jun 21, 2026
9 checks passed
frstrtr added a commit that referenced this pull request Jun 23, 2026
web: report real c2pool peer count + pool hashrate in getinfo/getstats
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