Skip to content

Commit

Permalink
Add api endpoints for circulating supply
Browse files Browse the repository at this point in the history
  • Loading branch information
havenprotocol committed Apr 5, 2018
1 parent a64dfb4 commit f0c49d3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,22 @@ main(int ac, const char* av[])
return r;
});

CROW_ROUTE(app, "/api/emission/circulating")
([&](const crow::request &req) {

myxmr::jsonresponse r{xmrblocks.json_emission_circulating()};

return r;
});

CROW_ROUTE(app, "/api/emission/circulating_nodec")
([&](const crow::request &req) {

myxmr::jsonresponse r{xmrblocks.json_emission_circulating_nodec()};

return r;
});

CROW_ROUTE(app, "/api/outputs").methods("GET"_method)
([&](const crow::request &req) {

Expand Down
37 changes: 37 additions & 0 deletions src/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -5091,6 +5091,43 @@ namespace xmreg
return j_response;
}

json
json_emission_circulating()
{

// get basic network info
if (!CurrentBlockchainStatus::is_thread_running())
{
return {"status", "fail"};
}
else
{
CurrentBlockchainStatus::Emission current_values
= CurrentBlockchainStatus::get_emission();

return get_xmr(current_values.coinbase);
}

}

json
json_emission_circulating_nodec()
{

// get basic network info
if (!CurrentBlockchainStatus::is_thread_running())
{
return {"status", "fail"};
}
else
{
CurrentBlockchainStatus::Emission current_values
= CurrentBlockchainStatus::get_emission();

return current_values.coinbase;
}
}


/*
* Lets use this json api convention for success and error
Expand Down

0 comments on commit f0c49d3

Please sign in to comment.