Skip to content

Commit e745b9b

Browse files
committed
Fix duplicate explorer buttons + populate share explorer data
1. Remove server-side explorer nav link injection that duplicated the client-side JS injection on dashboard and share pages. 2. Add heads/verified_heads/tails/verified_tails/my_share_hashes to sharechain_stats_fn so the classic page's share explorer section shows actual data instead of empty fields.
1 parent 2e43a90 commit e745b9b

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

src/c2pool/c2pool_refactored.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,6 +2951,35 @@ int main(int argc, char* argv[]) {
29512951
});
29522952
}
29532953
result["timeline"] = tl;
2954+
2955+
// Share explorer fields for classic page (/web/heads etc.)
2956+
{
2957+
auto& verified = p2p_node->tracker().verified;
2958+
2959+
nlohmann::json heads_arr = nlohmann::json::array();
2960+
for (auto& [h, t] : chain.get_heads())
2961+
heads_arr.push_back(h.GetHex());
2962+
result["heads"] = std::move(heads_arr);
2963+
2964+
nlohmann::json vheads_arr = nlohmann::json::array();
2965+
for (auto& [h, t] : verified.get_heads())
2966+
vheads_arr.push_back(h.GetHex());
2967+
result["verified_heads"] = std::move(vheads_arr);
2968+
2969+
nlohmann::json tails_arr = nlohmann::json::array();
2970+
for (auto& [t, hs] : chain.get_tails())
2971+
tails_arr.push_back(t.GetHex());
2972+
result["tails"] = std::move(tails_arr);
2973+
2974+
nlohmann::json vtails_arr = nlohmann::json::array();
2975+
for (auto& [t, hs] : verified.get_tails())
2976+
vtails_arr.push_back(t.GetHex());
2977+
result["verified_tails"] = std::move(vtails_arr);
2978+
2979+
// my_share_hashes: empty for now (no local share tracking yet)
2980+
result["my_share_hashes"] = nlohmann::json::array();
2981+
}
2982+
29542983
return result;
29552984
});
29562985

src/core/web_server.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,11 @@ void HttpSession::process_request()
620620
}
621621
}
622622

623-
// Inject explorer nav link if configured
624-
const auto& explorer_url = mining_interface_->get_explorer_url();
625-
if (!explorer_url.empty() && mining_interface_->is_explorer_enabled()
626-
&& (ext == ".html" || ext == ".htm"))
627-
{
628-
// Find "Classic" nav link and insert Explorer after it
629-
auto pos = contents.find(R"(>Classic</a>)");
630-
if (pos != std::string::npos) {
631-
pos += 12; // skip ">Classic</a>"
632-
std::string link = "\n <a href=\"" + explorer_url + "\" target=\"_blank\">Explorer</a>";
633-
contents.insert(pos, link);
634-
}
635-
}
623+
// Explorer nav link injection removed — each HTML page has
624+
// client-side JS that checks currency_info.explorer_enabled
625+
// and injects the link dynamically. Server-side injection was
626+
// fragile (depended on exact ">Classic</a>" text) and caused
627+
// duplicate buttons on pages that had both mechanisms.
636628

637629
response.set(http::field::content_type, mime);
638630
response.set(http::field::cache_control, "public, max-age=3600");

0 commit comments

Comments
 (0)