Skip to content

Commit 4fdc8d9

Browse files
authored
web(d-web): emit primary-coin tip in node_topology auto-detect fallback (#454)
web(d-web): emit primary-coin tip in node_topology auto-detect fallback
2 parents 4284e41 + 5c78a33 commit 4fdc8d9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/core/web_server.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5215,6 +5215,17 @@ nlohmann::json MiningInterface::rest_node_topology()
52155215
// so a node never advertises a blank primary symbol.
52165216
std::string primary = node_symbol();
52175217

5218+
// Primary coin's REAL current block height from the embedded daemon's cached
5219+
// template -- the same source rest_local_stats uses. Lets the auto-detect
5220+
// fallback emit "height" (tip) so the topology card shows the primary tip even
5221+
// when no per-coin StatsProvider hook is wired. (synced still needs the hook.)
5222+
uint64_t primary_height = 0;
5223+
{
5224+
std::lock_guard<std::mutex> lock(m_work_mutex);
5225+
if (!m_cached_template.is_null() && m_cached_template.contains("height"))
5226+
primary_height = m_cached_template["height"].get<uint64_t>();
5227+
}
5228+
52185229
nlohmann::json coins = nlohmann::json::array();
52195230
auto has_coin = [&](const std::string& sym) {
52205231
for (const auto& c : coins)
@@ -5231,6 +5242,10 @@ nlohmann::json MiningInterface::rest_node_topology()
52315242
// Real embedded/RPC flags for this node's own daemon.
52325243
entry["embedded"] = (m_coin_node && m_coin_node->is_embedded());
52335244
entry["has_rpc"] = (m_coin_node && m_coin_node->has_rpc());
5245+
// Truthful tip from the embedded daemon's cached template (front-end
5246+
// renders it only when > 0, so omit a meaningless 0).
5247+
if (primary_height > 0)
5248+
entry["height"] = primary_height;
52345249
}
52355250
coins.push_back(std::move(entry));
52365251
};

0 commit comments

Comments
 (0)