Skip to content

Commit d6ed487

Browse files
authored
web(d-web): getstats stale/DOA from live sharechain hook, not empty m_node stub (#462)
getstats() seeded orphan/doa/stale_shares from m_node->get_stale_stats(), but m_node is the empty stub on prod (same root cause as the founding 0-stub bug). Result: the pool_statistics block reported orphan=doa=stale=0 while /stale_rates -- which already reads the real m_sharechain_stats_fn -- told the truth. Prefer that same live hook here (orphan/dead/total -> orphan_count/doa_count/stale_count/stale_prop), m_node only as fallback. Charter: a dashboard must never lie about prod health. Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
1 parent 4fdc8d9 commit d6ed487

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/core/web_server.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2946,9 +2946,24 @@ nlohmann::json MiningInterface::getstats(const std::string& request_id)
29462946
block_height = m_cached_template["height"].get<uint64_t>();
29472947
}
29482948

2949+
// Prefer the live sharechain-stats hook over the empty m_node stub: m_node
2950+
// returns zeros on prod, so getstats lied about orphan/DOA/stale shares while
2951+
// /stale_rates (same hook) reported the truth. Charter: dashboards must not lie.
29492952
nlohmann::json stale = {{"orphan_count", 0}, {"doa_count", 0}, {"stale_count", 0}, {"stale_prop", 0.0}};
2950-
if (m_node)
2953+
if (m_sharechain_stats_fn) {
2954+
auto sc = m_sharechain_stats_fn();
2955+
uint64_t total = sc.value("total_shares", uint64_t(0));
2956+
uint64_t orphan = sc.value("orphan_shares", uint64_t(0));
2957+
uint64_t dead = sc.value("dead_shares", uint64_t(0));
2958+
stale["orphan_count"] = orphan;
2959+
stale["doa_count"] = dead;
2960+
stale["stale_count"] = orphan + dead;
2961+
stale["stale_prop"] = total > 0
2962+
? static_cast<double>(orphan + dead) / static_cast<double>(total)
2963+
: 0.0;
2964+
} else if (m_node) {
29512965
stale = m_node->get_stale_stats();
2966+
}
29522967

29532968
nlohmann::json protocol_messages = nlohmann::json::array();
29542969
if (m_protocol_messages_fn) {

0 commit comments

Comments
 (0)