/api/emission added
This commit is contained in:
parent
2c133482af
commit
7b9ee5732d
8
main.cpp
8
main.cpp
|
@ -487,6 +487,14 @@ int main(int ac, const char* av[]) {
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CROW_ROUTE(app, "/api/emission")
|
||||||
|
([&](const crow::request &req) {
|
||||||
|
|
||||||
|
myxmr::jsonresponse r{xmrblocks.json_emission()};
|
||||||
|
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
|
||||||
CROW_ROUTE(app, "/api/outputs").methods("GET"_method)
|
CROW_ROUTE(app, "/api/outputs").methods("GET"_method)
|
||||||
([&](const crow::request &req) {
|
([&](const crow::request &req) {
|
||||||
|
|
||||||
|
|
45
src/page.h
45
src/page.h
|
@ -4802,6 +4802,50 @@ namespace xmreg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lets use this json api convention for success and error
|
||||||
|
* https://labs.omniti.com/labs/jsend
|
||||||
|
*/
|
||||||
|
json
|
||||||
|
json_emission()
|
||||||
|
{
|
||||||
|
json j_response {
|
||||||
|
{"status", "fail"},
|
||||||
|
{"data", json {}}
|
||||||
|
};
|
||||||
|
|
||||||
|
json& j_data = j_response["data"];
|
||||||
|
|
||||||
|
json j_info;
|
||||||
|
|
||||||
|
// get basic network info
|
||||||
|
if (!CurrentBlockchainStatus::is_thread_running())
|
||||||
|
{
|
||||||
|
j_data["title"] = "Emission monitoring thread not enabled.";
|
||||||
|
return j_response;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CurrentBlockchainStatus::Emission current_values
|
||||||
|
= CurrentBlockchainStatus::get_emission();
|
||||||
|
|
||||||
|
string emission_blk_no = std::to_string(current_values.blk_no - 1);
|
||||||
|
string emission_coinbase = xmr_amount_to_str(current_values.coinbase, "{:0.3f}");
|
||||||
|
string emission_fee = xmr_amount_to_str(current_values.fee, "{:0.3f}");
|
||||||
|
|
||||||
|
j_data = json {
|
||||||
|
{"blk_no" , current_values.blk_no - 1},
|
||||||
|
{"coinbase", current_values.coinbase},
|
||||||
|
{"fee" , current_values.fee},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
j_response["status"] = "success";
|
||||||
|
|
||||||
|
return j_response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
json
|
json
|
||||||
|
@ -5657,3 +5701,4 @@ namespace xmreg
|
||||||
|
|
||||||
|
|
||||||
#endif //CROWXMR_PAGE_H
|
#endif //CROWXMR_PAGE_H
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue