mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
add api/version call
https://github.com/moneroexamples/openmonero/issues/35
This commit is contained in:
parent
a549f25138
commit
9db09581b6
4 changed files with 68 additions and 2 deletions
21
README.md
21
README.md
|
@ -716,6 +716,27 @@ curl -w "\n" -X GET "http://139.162.32.245:8081/api/emission"
|
|||
|
||||
Emission only works when the emission monitoring thread is enabled.
|
||||
|
||||
#### api/version
|
||||
|
||||
```bash
|
||||
curl -w "\n" -X GET "http://139.162.32.245:8081/api/version"
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"api": 65536,
|
||||
"blockchain_height": 1357031,
|
||||
"git_branch_name": "update_to_current_monero",
|
||||
"last_git_commit_date": "2017-07-25",
|
||||
"last_git_commit_hash": "a549f25",
|
||||
"monero_version_full": "0.10.3.1-ab594cfe"
|
||||
},
|
||||
"status": "success"
|
||||
}
|
||||
```
|
||||
|
||||
api number is store as `uint32_t`.
|
||||
|
||||
#### api/rawblock/<block_number|block_hash>
|
||||
|
||||
|
|
8
main.cpp
8
main.cpp
|
@ -592,6 +592,14 @@ main(int ac, const char* av[])
|
|||
return r;
|
||||
});
|
||||
|
||||
CROW_ROUTE(app, "/api/version")
|
||||
([&](const crow::request &req) {
|
||||
|
||||
myxmr::jsonresponse r{xmrblocks.json_version()};
|
||||
|
||||
return r;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (enable_autorefresh_option)
|
||||
|
|
39
src/page.h
39
src/page.h
|
@ -55,6 +55,11 @@
|
|||
#define TMPL_MY_CHECKRAWOUTPUTKEYS TMPL_DIR "/checkrawoutputkeys.html"
|
||||
|
||||
|
||||
#define ONIONEXPLORER_RPC_VERSION_MAJOR 1
|
||||
#define ONIONEXPLORER_RPC_VERSION_MINOR 0
|
||||
#define MAKE_ONIONEXPLORER_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define ONIONEXPLORER_RPC_VERSION \
|
||||
MAKE_ONIONEXPLORER_RPC_VERSION(ONIONEXPLORER_RPC_VERSION_MAJOR, ONIONEXPLORER_RPC_VERSION_MINOR)
|
||||
|
||||
|
||||
// basic info about tx to be stored in cashe.
|
||||
|
@ -4937,6 +4942,35 @@ namespace xmreg
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lets use this json api convention for success and error
|
||||
* https://labs.omniti.com/labs/jsend
|
||||
*/
|
||||
json
|
||||
json_version()
|
||||
{
|
||||
json j_response {
|
||||
{"status", "fail"},
|
||||
{"data", json {}}
|
||||
};
|
||||
|
||||
json& j_data = j_response["data"];
|
||||
|
||||
j_data = json {
|
||||
{"last_git_commit_hash", string {GIT_COMMIT_HASH}},
|
||||
{"last_git_commit_date", string {GIT_COMMIT_DATETIME}},
|
||||
{"git_branch_name" , string {GIT_BRANCH_NAME}},
|
||||
{"monero_version_full" , string {MONERO_VERSION_FULL}},
|
||||
{"api" , ONIONEXPLORER_RPC_VERSION},
|
||||
{"blockchain_height" , core_storage->get_current_blockchain_height()}
|
||||
};
|
||||
|
||||
j_response["status"] = "success";
|
||||
|
||||
return j_response;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
@ -5884,7 +5918,10 @@ namespace xmreg
|
|||
{"last_git_commit_hash", string {GIT_COMMIT_HASH}},
|
||||
{"last_git_commit_date", string {GIT_COMMIT_DATETIME}},
|
||||
{"git_branch_name" , string {GIT_BRANCH_NAME}},
|
||||
{"monero_version_full" , string {MONERO_VERSION_FULL}}
|
||||
{"monero_version_full" , string {MONERO_VERSION_FULL}},
|
||||
{"api" , std::to_string(ONIONEXPLORER_RPC_VERSION_MAJOR)
|
||||
+ "."
|
||||
+ std::to_string(ONIONEXPLORER_RPC_VERSION_MINOR)},
|
||||
};
|
||||
|
||||
string footer_html = mstch::render(xmreg::read(TMPL_FOOTER), footer_context);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="center">
|
||||
<h6 style="margin-top:10px">
|
||||
<a href="https://github.com/moneroexamples/onion-monero-blockchain-explorer">source code</a>
|
||||
| explorer version: {{git_branch_name}}-{{last_git_commit_date}}-{{last_git_commit_hash}}
|
||||
| explorer version (api): {{git_branch_name}}-{{last_git_commit_date}}-{{last_git_commit_hash}} ({{api}})
|
||||
| monero version: {{monero_version_full}}
|
||||
</h6>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue