Skip to content

Commit 9dc646b

Browse files
authored
Merge pull request #372 from frstrtr/dashboard/v36-status-real-state
web: /v36_status reports real V35->V36 state (de-stub)
2 parents 72a520a + 69693a3 commit 9dc646b

1 file changed

Lines changed: 34 additions & 13 deletions

File tree

src/core/web_server.cpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5959,27 +5959,48 @@ nlohmann::json MiningInterface::rest_version_signaling(const nlohmann::json* cac
59595959
nlohmann::json MiningInterface::rest_v36_status()
59605960
{
59615961
nlohmann::json result = nlohmann::json::object();
5962+
5963+
// Source the real ratchet state + share counts from rest_version_signaling()
5964+
// — the canonical, chain-derived V35→V36 computation — so /v36_status never
5965+
// lies about the cross. The old body returned a frozen "voting" / 0 v36
5966+
// shares regardless of reality (the founding-charter stub class). On
5967+
// non-transition coins version_signaling returns {}, leaving the truthful
5968+
// zeros below; on a too-short chain it early-returns before populating the
5969+
// overall_* fields, which .value() defaults handle.
5970+
nlohmann::json vs = rest_version_signaling();
5971+
5972+
std::string state = "voting";
5973+
if (vs.contains("auto_ratchet") && vs["auto_ratchet"].contains("state"))
5974+
state = vs["auto_ratchet"].value("state", std::string("voting"));
5975+
59625976
result["auto_ratchet"] = {
5963-
{"state", "voting"},
5964-
{"persisted_state", ""},
5977+
{"state", state},
5978+
{"persisted_state", state},
59655979
{"activated_at", nullptr},
59665980
{"activated_height", nullptr},
59675981
{"confirmed_at", nullptr}
59685982
};
5969-
result["share_chain"] = {
5970-
{"height", 0},
5971-
{"sample_size", 0},
5972-
{"v35_shares", 0},
5973-
{"v36_shares", 0},
5974-
{"v36_percentage", 0.0}
5975-
};
5983+
5984+
int sample_size = vs.value("overall_total", 0);
5985+
int v36_shares = vs.value("overall_v36_shares", 0);
5986+
int v35_shares = std::max(0, sample_size - v36_shares);
5987+
double v36_pct = vs.value("overall_v36_share_pct", 0.0);
5988+
5989+
int height = 0;
59765990
if (m_sharechain_stats_fn) {
59775991
auto sc = m_sharechain_stats_fn();
5978-
if (sc.contains("chain_height"))
5979-
result["share_chain"]["height"] = sc["chain_height"];
5980-
if (sc.contains("total_shares"))
5981-
result["share_chain"]["sample_size"] = sc["total_shares"];
5992+
height = sc.value("chain_height", 0);
5993+
if (sample_size == 0)
5994+
sample_size = sc.value("total_shares", 0);
59825995
}
5996+
5997+
result["share_chain"] = {
5998+
{"height", height},
5999+
{"sample_size", sample_size},
6000+
{"v35_shares", v35_shares},
6001+
{"v36_shares", v36_shares},
6002+
{"v36_percentage", v36_pct}
6003+
};
59836004
return result;
59846005
}
59856006

0 commit comments

Comments
 (0)