Browse Source

show basic mempool info on homepage tab

fix-133-memory-crash
Dan Janosik 8 years ago
parent
commit
77d6ebd938
  1. 13
      app/rpcApi.js
  2. 22
      routes/baseActionsRouter.js
  3. 11
      views/index.pug

13
app/rpcApi.js

@ -45,6 +45,18 @@ function getInfo() {
});
}
function getMempoolInfo() {
return new Promise(function(resolve, reject) {
client.cmd('getmempoolinfo', function(err, result, resHeaders) {
if (err) {
return console.log("Error 23407rhwe07fg: " + err);
}
resolve(result);
});
});
}
function getBlockByHeight(blockHeight) {
console.log("getBlockByHeight: " + blockHeight);
@ -260,6 +272,7 @@ function getBlockData(rpcClient, blockHash, txLimit, txOffset) {
module.exports = {
getInfo: getInfo,
getMempoolInfo: getMempoolInfo,
getBlockByHeight: getBlockByHeight,
getBlocksByHeight: getBlocksByHeight,
getBlockByHash: getBlockByHash,

22
routes/baseActionsRouter.js

@ -31,19 +31,23 @@ router.get("/", function(req, res) {
var client = global.client;
rpcApi.getInfo().then(function(getinfo) {
res.locals.result = getinfo;
res.locals.getinfo = getinfo;
var blockHeights = [];
if (getinfo.blocks) {
for (var i = 0; i < 10; i++) {
blockHeights.push(getinfo.blocks - i);
rpcApi.getMempoolInfo().then(function(getmempoolinfo) {
res.locals.getmempoolinfo = getmempoolinfo;
var blockHeights = [];
if (getinfo.blocks) {
for (var i = 0; i < 10; i++) {
blockHeights.push(getinfo.blocks - i);
}
}
}
rpcApi.getBlocksByHeight(blockHeights).then(function(latestBlocks) {
res.locals.latestBlocks = latestBlocks;
rpcApi.getBlocksByHeight(blockHeights).then(function(latestBlocks) {
res.locals.latestBlocks = latestBlocks;
res.render("index");
res.render("index");
});
});
});
});

11
views/index.pug

@ -18,6 +18,8 @@ block content
a(data-toggle="tab", href="#tab-latest-tx", class="nav-link active", role="tab") Latest Blocks
li(class="nav-item")
a(data-toggle="tab", href="#tab-getinfo", class="nav-link", role="tab") Node Info
li(class="nav-item")
a(data-toggle="tab", href="#tab-getmempoolinfo", class="nav-link", role="tab") Mempool Info
div(class="tab-content")
div(id="tab-latest-tx", class="tab-pane active", role="tabpanel")
@ -32,6 +34,11 @@ block content
a(href="/blocks", class="btn btn-primary btn-block") See more
div(id="tab-getinfo", class="tab-pane", role="tabpanel")
h3 Node Info (getinfo)
h3 Node Info
pre
code #{JSON.stringify(getinfo, null, 4)}
div(id="tab-getmempoolinfo", class="tab-pane", role="tabpanel")
h3 Mempool Info
pre
code #{JSON.stringify(result, null, 4)}
code #{JSON.stringify(getmempoolinfo, null, 4)}
Loading…
Cancel
Save