addtion of mempool info started
This commit is contained in:
parent
dfd4191196
commit
6fc2bab65b
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
#list(INSERT
|
#list(INSERT
|
||||||
# CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
|
# CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
#define DB_LMDB 2
|
#define DB_LMDB 2
|
||||||
#define BLOCKCHAIN_DB DB_LMDB
|
#define BLOCKCHAIN_DB DB_LMDB
|
||||||
|
|
||||||
|
|
||||||
|
#include "net/http_base.h"
|
||||||
|
#include "net/http_server_handlers_map2.h"
|
||||||
|
#include "net/http_client.h"
|
||||||
|
#include "storages/http_abstract_invoke.h"
|
||||||
|
|
||||||
#include "cryptonote_core/cryptonote_basic.h"
|
#include "cryptonote_core/cryptonote_basic.h"
|
||||||
#include "cryptonote_core/blockchain_storage.h"
|
#include "cryptonote_core/blockchain_storage.h"
|
||||||
#include "cryptonote_core/blockchain.h"
|
#include "cryptonote_core/blockchain.h"
|
||||||
|
|
93
src/page.h
93
src/page.h
|
@ -23,10 +23,11 @@
|
||||||
|
|
||||||
#include<ctime>
|
#include<ctime>
|
||||||
|
|
||||||
#define TMPL_DIR "./templates"
|
#define TMPL_DIR "./templates"
|
||||||
#define TMPL_INDEX TMPL_DIR "/index.html"
|
#define TMPL_INDEX TMPL_DIR "/index.html"
|
||||||
#define TMPL_HEADER TMPL_DIR "/header.html"
|
#define TMPL_MEMPOOL TMPL_DIR "/mempool.html"
|
||||||
#define TMPL_FOOTER TMPL_DIR "/footer.html"
|
#define TMPL_HEADER TMPL_DIR "/header.html"
|
||||||
|
#define TMPL_FOOTER TMPL_DIR "/footer.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +37,10 @@ namespace xmreg {
|
||||||
using namespace crypto;
|
using namespace crypto;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
using request = cryptonote::COMMAND_RPC_GET_TRANSACTION_POOL::request;
|
||||||
|
using response = cryptonote::COMMAND_RPC_GET_TRANSACTION_POOL::response;
|
||||||
|
using http_simple_client = epee::net_utils::http::http_simple_client;
|
||||||
|
|
||||||
class page {
|
class page {
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,8 +170,14 @@ namespace xmreg {
|
||||||
std::reverse(blocks.begin(), blocks.end());
|
std::reverse(blocks.begin(), blocks.end());
|
||||||
blocks.pop_back();
|
blocks.pop_back();
|
||||||
|
|
||||||
|
string mempool_html = mempool();
|
||||||
|
|
||||||
|
|
||||||
|
context["mempool_info"] = mempool_html;
|
||||||
|
|
||||||
|
|
||||||
// read index.html
|
// read index.html
|
||||||
std::string index_html = xmreg::read(TMPL_INDEX);
|
string index_html = xmreg::read(TMPL_INDEX);
|
||||||
|
|
||||||
// add header and footer
|
// add header and footer
|
||||||
string full_page = get_full_page(index_html);
|
string full_page = get_full_page(index_html);
|
||||||
|
@ -176,6 +187,78 @@ namespace xmreg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string
|
||||||
|
mempool()
|
||||||
|
{
|
||||||
|
string deamon_url {"http:://127.0.0.1:18081"};
|
||||||
|
|
||||||
|
// perform RPC call to deamon to get
|
||||||
|
// its transaction pull
|
||||||
|
boost::mutex m_daemon_rpc_mutex;
|
||||||
|
|
||||||
|
request req;
|
||||||
|
response res;
|
||||||
|
|
||||||
|
http_simple_client m_http_client;
|
||||||
|
|
||||||
|
m_daemon_rpc_mutex.lock();
|
||||||
|
|
||||||
|
bool r = epee::net_utils::invoke_http_json_remote_command2(
|
||||||
|
deamon_url + "/get_transaction_pool",
|
||||||
|
req, res, m_http_client, 200000);
|
||||||
|
|
||||||
|
m_daemon_rpc_mutex.unlock();
|
||||||
|
|
||||||
|
if (!r)
|
||||||
|
{
|
||||||
|
cerr << "Error connecting to Monero deamon at "
|
||||||
|
<< deamon_url << endl;
|
||||||
|
return "Error connecting to Monero deamon to get mempool";
|
||||||
|
}
|
||||||
|
|
||||||
|
// initalise page tempate map with basic info about blockchain
|
||||||
|
mstch::map context {
|
||||||
|
{"mempool_size", fmt::format("{:d}", res.transactions.size())},
|
||||||
|
{"mempooltxs" , mstch::array()}
|
||||||
|
};
|
||||||
|
|
||||||
|
// get reference to blocks template map to be field below
|
||||||
|
mstch::array& txs = boost::get<mstch::array>(context["mempooltxs"]);
|
||||||
|
|
||||||
|
// for each transaction in the memory pool
|
||||||
|
for (size_t i = 0; i < res.transactions.size(); ++i)
|
||||||
|
{
|
||||||
|
// get transaction info of the tx in the mempool
|
||||||
|
cryptonote::tx_info _tx_info = res.transactions.at(i);
|
||||||
|
|
||||||
|
// display basic info
|
||||||
|
fmt::print("Tx hash: {:s}\n", _tx_info.id_hash);
|
||||||
|
|
||||||
|
fmt::print("Fee: {:0.10f} xmr, size {:d} bytes\n",
|
||||||
|
XMR_AMOUNT(_tx_info.fee),
|
||||||
|
_tx_info.blob_size);
|
||||||
|
|
||||||
|
fmt::print("Receive time: {:s}\n",
|
||||||
|
xmreg::timestamp_to_str(_tx_info.receive_time));
|
||||||
|
|
||||||
|
// set output page template map
|
||||||
|
txs.push_back(mstch::map {
|
||||||
|
{"timestamp" , xmreg::timestamp_to_str(_tx_info.receive_time)},
|
||||||
|
{"hash" , fmt::format("<{:s}>", _tx_info.id_hash)},
|
||||||
|
{"fee" , fmt::format("{:0.4f}", XMR_AMOUNT(_tx_info.fee))},
|
||||||
|
{"xmr_outputs" , fmt::format("{:0.4f}", 0.0)},
|
||||||
|
{"mixin_range" , 0}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// read index.html
|
||||||
|
string mempool_html = xmreg::read(TMPL_MEMPOOL);
|
||||||
|
|
||||||
|
// render the page
|
||||||
|
return mstch::render(mempool_html, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
margin: auto;
|
||||||
|
width: 96%;
|
||||||
|
border: 1px solid #73AD21;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
tr {
|
tr {
|
||||||
font-family: "Lucida Console", Monaco, monospace;
|
font-family: "Lucida Console", Monaco, monospace;
|
||||||
font-size : 12px;
|
font-size : 12px;
|
||||||
|
|
|
@ -9,9 +9,16 @@
|
||||||
<a href="/autorefresh">Autorefresh OFF</a>
|
<a href="/autorefresh">Autorefresh OFF</a>
|
||||||
{{/refresh}}
|
{{/refresh}}
|
||||||
</h2>
|
</h2>
|
||||||
<div>
|
|
||||||
<ul>
|
|
||||||
<table>
|
{{{mempool_info}}}
|
||||||
|
|
||||||
|
|
||||||
|
<h2>100 recent blocks</h2>
|
||||||
|
|
||||||
|
<div class="center">
|
||||||
|
|
||||||
|
<table class="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td>height</td>
|
<td>height</td>
|
||||||
<td>timestamp_(Δ mm:ss)</td>
|
<td>timestamp_(Δ mm:ss)</td>
|
||||||
|
@ -34,6 +41,4 @@
|
||||||
{{/blocks}}
|
{{/blocks}}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<h2>
|
||||||
|
Memory pool (size: {{mempool_size}})
|
||||||
|
</h2>
|
||||||
|
<div class="center">
|
||||||
|
|
||||||
|
<table class="center">
|
||||||
|
<tr>
|
||||||
|
<td>height</td>
|
||||||
|
<td>timestamp</td>
|
||||||
|
<td>tx hash</td>
|
||||||
|
<td>tx fee</td>
|
||||||
|
<td>no_of_txs</td>
|
||||||
|
<td>xmr_outputs</td>
|
||||||
|
<td>mixin_range</td>
|
||||||
|
</tr>
|
||||||
|
{{#mempooltxs}}
|
||||||
|
<tr>
|
||||||
|
<td>N/A</td>
|
||||||
|
<td>{{timestamp}}</td>
|
||||||
|
<td>{{hash}}</td>
|
||||||
|
<td>{{fee}}</td>
|
||||||
|
<td>{{xmr_outputs}}</td>
|
||||||
|
<td>{{mixin_range}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/mempooltxs}}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
Loading…
Reference in New Issue