Browse Source

more error handling

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
23d0979d5d
  1. 3
      routes/baseActionsRouter.js
  2. 117
      views/mempool.pug
  3. 76
      views/node-info.pug

3
routes/baseActionsRouter.js

@ -243,6 +243,7 @@ router.get("/block-height/:blockHeight", function(req, res) {
client.cmd('getblockhash', blockHeight, function(err, result, resHeaders) {
if (err) {
// TODO handle RPC error
return console.log(err);
}
@ -280,6 +281,7 @@ router.get("/block/:blockHash", function(req, res) {
res.locals.offset = offset;
res.locals.paginationBaseUrl = "/block/" + blockHash;
// TODO handle RPC error
rpcApi.getBlockData(client, blockHash, limit, offset).then(function(result) {
res.locals.result.getblock = result.getblock;
res.locals.result.transactions = result.transactions;
@ -302,6 +304,7 @@ router.get("/tx/:transactionId", function(req, res) {
res.locals.result = {};
// TODO handle RPC error
rpcApi.getRawTransaction(txid).then(function(rawTxResult) {
res.locals.result.getrawtransaction = rawTxResult;

117
views/mempool.pug

@ -7,68 +7,69 @@ block content
h1 Mempool Info
hr
p Data from RPC command
a(href="https://bitcoin.org/en/developer-reference#getmempoolinfo") getmempoolinfo
table(class="table")
tr
th(class="table-active properties-header") Transaction Count
td #{getmempoolinfo.size.toLocaleString()}
tr
- var scales = [ {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"kB"} ];
- var scaleDone = false;
th(class="table-active properties-header") Tx Size
td(class="monospace")
span #{getmempoolinfo.bytes.toLocaleString()} bytes
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getmempoolinfo.bytes / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
tr
- var scales = [ {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"kB"} ];
- var scaleDone = false;
th(class="table-active properties-header") Total Size
td(class="monospace")
span #{getmempoolinfo.usage.toLocaleString()} bytes
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getmempoolinfo.usage / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
tr
th(class="table-active properties-header") Max Size
td(class="monospace") #{getmempoolinfo.maxmempool.toLocaleString()}
tr
th(class="table-active properties-header") Min Fee
td(class="monospace") #{getmempoolinfo.mempoolminfee.toLocaleString()}
tr
th(class="table-active properties-header") Total Fees
td(class="monospace") #{mempoolstats.totalFee.toLocaleString()}
if (mempoolinfo)
p Data from RPC command
a(href="https://bitcoin.org/en/developer-reference#getmempoolinfo") getmempoolinfo
table(class="table")
tr
th(class="table-active properties-header") Transaction Count
td #{getmempoolinfo.size.toLocaleString()}
tr
- var scales = [ {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"kB"} ];
- var scaleDone = false;
th(class="table-active properties-header") Tx Size
td(class="monospace")
span #{getmempoolinfo.bytes.toLocaleString()} bytes
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getmempoolinfo.bytes / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
tr
- var scales = [ {val:1000000000, name:"GB"}, {val:1000000, name:"MB"}, {val:1000, name:"kB"} ];
- var scaleDone = false;
th(class="table-active properties-header") Total Size
td(class="monospace")
span #{getmempoolinfo.usage.toLocaleString()} bytes
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getmempoolinfo.usage / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
tr
th(class="table-active properties-header") Max Size
td(class="monospace") #{getmempoolinfo.maxmempool.toLocaleString()}
tr
th(class="table-active properties-header") Min Fee
td(class="monospace") #{getmempoolinfo.mempoolminfee.toLocaleString()}
tr
th(class="table-active properties-header") Total Fees
td(class="monospace") #{mempoolstats.totalFee.toLocaleString()}
h4 Transaction count by fee level
hr
h4 Transaction count by fee level
hr
if (false)
#{JSON.stringify(mempoolstats)}
if (false)
#{JSON.stringify(mempoolstats)}
- var feeBucketLabels = [ "0 - 5 sat/B", "6 - 10 sat/B", "11 - 25 sat/B", "26 - 50 sat/B", "51 - 75 sat/B", "76 - 100 sat/B", "101 - 150 sat/B", "151+ sat/B" ];
- var feeBucketTxCounts = [ mempoolstats.fee_0_5, mempoolstats.fee_6_10, mempoolstats.fee_11_25, mempoolstats.fee_26_50, mempoolstats.fee_51_75, mempoolstats.fee_76_100, mempoolstats.fee_101_150, mempoolstats.fee_151_max ];
- var bgColors = [ "bg-primary", "bg-success", "bg-info", "bg-warning", "bg-danger", "bg-primary progress-bar-striped", "bg-success progress-bar-striped", "bg-info progress-bar-striped" ];
- var feeBucketLabels = [ "0 - 5 sat/B", "6 - 10 sat/B", "11 - 25 sat/B", "26 - 50 sat/B", "51 - 75 sat/B", "76 - 100 sat/B", "101 - 150 sat/B", "151+ sat/B" ];
- var feeBucketTxCounts = [ mempoolstats.fee_0_5, mempoolstats.fee_6_10, mempoolstats.fee_11_25, mempoolstats.fee_26_50, mempoolstats.fee_51_75, mempoolstats.fee_76_100, mempoolstats.fee_101_150, mempoolstats.fee_151_max ];
- var bgColors = [ "bg-primary", "bg-success", "bg-info", "bg-warning", "bg-danger", "bg-primary progress-bar-striped", "bg-success progress-bar-striped", "bg-info progress-bar-striped" ];
table(class="table")
each feeBucketLabel, index in feeBucketLabels
tr
th(class=("properties-header " + bgColors[index])) #{feeBucketLabel}
td(class="monospace") #{feeBucketTxCounts[index].toLocaleString()}
table(class="table")
each feeBucketLabel, index in feeBucketLabels
tr
th(class=("properties-header " + bgColors[index])) #{feeBucketLabel}
td(class="monospace") #{feeBucketTxCounts[index].toLocaleString()}
div(class="progress")
each txCount, index in feeBucketTxCounts
- var percent = 100 * txCount / getmempoolinfo.size;
div(class="progress")
each txCount, index in feeBucketTxCounts
- var percent = 100 * txCount / getmempoolinfo.size;
div(class=("progress-bar " + bgColors[index]), role="progressbar", style=("width: " + percent + "%;"), aria-valuenow=percent, aria-valuemin="0", aria-valuemax="100")
span #{txCount}
div(class=("progress-bar " + bgColors[index]), role="progressbar", style=("width: " + percent + "%;"), aria-valuenow=percent, aria-valuemin="0", aria-valuemax="100")
span #{txCount}

76
views/node-info.pug

@ -7,42 +7,44 @@ block content
h1 Node Info
hr
p Data from RPC command
a(href="https://bitcoin.org/en/developer-reference#getinfo") getinfo
if (getinfo)
p Data from RPC command
a(href="https://bitcoin.org/en/developer-reference#getinfo") getinfo
if (false)
pre
code #{JSON.stringify(getinfo, null, 4)}
if (false)
pre
code #{JSON.stringify(getinfo, null, 4)}
if (true)
table(class="table")
tr
th(class="table-active properties-header") Version
td(class="monospace") #{getinfo.version}
tr
th(class="table-active properties-header") Protocol Version
td(class="monospace") #{getinfo.protocolversion}
tr
th(class="table-active properties-header") Connections
td(class="monospace") #{getinfo.connections.toLocaleString()}
tr
th(class="table-active properties-header") Block Count
td(class="monospace") #{getinfo.blocks.toLocaleString()}
tr
th(class="table-active properties-header") Testnet?
td(class="monospace") #{getinfo.testnet}
tr
th(class="table-active properties-header") Errors
td(class="monospace") #{getinfo.errors}
tr
- var scales = [ {val:1000000000000000, name:"quadrillion"}, {val:1000000000000, name:"trillion"}, {val:1000000000, name:"billion"}, {val:1000000, name:"million"} ];
- var scaleDone = false;
th(class="table-active properties-header") Difficulty
td(class="monospace")
span #{getinfo.difficulty.toLocaleString()}
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getinfo.difficulty / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
if (true)
table(class="table")
tr
th(class="table-active properties-header") Version
td(class="monospace") #{getinfo.version}
tr
th(class="table-active properties-header") Protocol Version
td(class="monospace") #{getinfo.protocolversion}
tr
th(class="table-active properties-header") Connections
td(class="monospace") #{getinfo.connections.toLocaleString()}
tr
th(class="table-active properties-header") Block Count
td(class="monospace") #{getinfo.blocks.toLocaleString()}
tr
th(class="table-active properties-header") Testnet?
td(class="monospace") #{getinfo.testnet}
tr
th(class="table-active properties-header") Errors
td(class="monospace") #{getinfo.errors}
tr
- var scales = [ {val:1000000000000000, name:"quadrillion"}, {val:1000000000000, name:"trillion"}, {val:1000000000, name:"billion"}, {val:1000000, name:"million"} ];
- var scaleDone = false;
th(class="table-active properties-header") Difficulty
td(class="monospace")
span #{getinfo.difficulty.toLocaleString()}
each item in scales
if (!scaleDone)
- var fraction = Math.floor(getinfo.difficulty / item.val);
if (fraction >= 1)
- scaleDone = true;
span(class="text-muted") (#{fraction} #{item.name})
Loading…
Cancel
Save