From a5dacf2bcc51ae754d88f9af66cd0632a49b8a1b Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Mon, 31 Jan 2022 17:52:32 +0200 Subject: [PATCH] fix: text explorer show sha-3 correctly + minor fixes (#3779) Description --- - change tari_explorer `.prettierrc` to match other packages in the repo, this meant a big formatting change, but it's a separate commit for ease of review - fix the display of SHA-3 blocks pow algo - some styling improvements + basic dark mode - adds the block header info to the block view - check for valid prev/next blocks to display navigation between blocks --- applications/launchpad/gui-vue/.gitignore | 3 +- applications/launchpad/gui-vue/dist/.gitkeep | 0 applications/tari_explorer/.prettierrc | 3 +- applications/tari_explorer/app.js | 125 +++++++++--------- applications/tari_explorer/baseNodeClient.js | 6 +- applications/tari_explorer/bin/www | 62 +++++---- applications/tari_explorer/routes/assets.js | 34 ++--- applications/tari_explorer/routes/blocks.js | 56 +++++--- applications/tari_explorer/routes/index.js | 109 +++++++-------- applications/tari_explorer/routes/mempool.js | 42 +++--- applications/tari_explorer/routes/search.js | 30 ++--- .../tari_explorer/routes/validator.js | 35 ++--- .../tari_explorer/validatorNodeClient.js | 9 +- applications/tari_explorer/views/assets.hbs | 2 +- applications/tari_explorer/views/blocks.hbs | 109 ++++++++++++--- applications/tari_explorer/views/index.hbs | 16 +-- applications/tari_explorer/views/layout.hbs | 8 +- 17 files changed, 368 insertions(+), 281 deletions(-) create mode 100644 applications/launchpad/gui-vue/dist/.gitkeep diff --git a/applications/launchpad/gui-vue/.gitignore b/applications/launchpad/gui-vue/.gitignore index 403adbc1e5..140d0b7681 100644 --- a/applications/launchpad/gui-vue/.gitignore +++ b/applications/launchpad/gui-vue/.gitignore @@ -1,6 +1,7 @@ .DS_Store node_modules -/dist +dist/* +!dist/.gitkeep # local env files diff --git a/applications/launchpad/gui-vue/dist/.gitkeep b/applications/launchpad/gui-vue/dist/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/tari_explorer/.prettierrc b/applications/tari_explorer/.prettierrc index 8406771c0a..168d9d2a0c 100644 --- a/applications/tari_explorer/.prettierrc +++ b/applications/tari_explorer/.prettierrc @@ -1,4 +1,3 @@ { - "endOfLine": "auto", - "semi": false + "endOfLine": "auto" } diff --git a/applications/tari_explorer/app.js b/applications/tari_explorer/app.js index 94fa4883b2..6873db5174 100644 --- a/applications/tari_explorer/app.js +++ b/applications/tari_explorer/app.js @@ -1,35 +1,34 @@ -const createError = require('http-errors') -const express = require('express') -const path = require('path') -const cookieParser = require('cookie-parser') -const logger = require('morgan') -const asciichart = require('asciichart') - - -var indexRouter = require("./routes/index") -var blocksRouter = require("./routes/blocks") -var mempoolRouter = require("./routes/mempool") -var searchRouter = require("./routes/search") - -var assetsRouter = require('./routes/assets'); -var validatorRouter = require('./routes/validator'); - -var hbs = require("hbs") +const createError = require("http-errors"); +const express = require("express"); +const path = require("path"); +const cookieParser = require("cookie-parser"); +const logger = require("morgan"); +const asciichart = require("asciichart"); + +var indexRouter = require("./routes/index"); +var blocksRouter = require("./routes/blocks"); +var mempoolRouter = require("./routes/mempool"); +var searchRouter = require("./routes/search"); + +var assetsRouter = require("./routes/assets"); +var validatorRouter = require("./routes/validator"); + +var hbs = require("hbs"); hbs.registerHelper("hex", function (buffer) { - return buffer ? Buffer.from(buffer).toString("hex") : "" -}) + return buffer ? Buffer.from(buffer).toString("hex") : ""; +}); hbs.registerHelper("json", function (obj) { - return Buffer.from(JSON.stringify(obj)).toString("base64") -}) + return Buffer.from(JSON.stringify(obj)).toString("base64"); +}); hbs.registerHelper("timestamp", function (timestamp) { - var dateObj = new Date(timestamp.seconds * 1000) - const day = dateObj.getUTCDate() - const month = dateObj.getUTCMonth() + 1 - const year = dateObj.getUTCFullYear() - const hours = dateObj.getUTCHours() - const minutes = dateObj.getUTCMinutes() - const seconds = dateObj.getSeconds() + var dateObj = new Date(timestamp.seconds * 1000); + const day = dateObj.getUTCDate(); + const month = dateObj.getUTCMonth() + 1; + const year = dateObj.getUTCFullYear(); + const hours = dateObj.getUTCHours(); + const minutes = dateObj.getUTCMinutes(); + const seconds = dateObj.getSeconds(); return ( year.toString() + @@ -43,68 +42,68 @@ hbs.registerHelper("timestamp", function (timestamp) { minutes.toString().padStart(2, "0") + ":" + seconds.toString().padStart(2, "0") - ) -}) + ); +}); hbs.registerHelper("percentbar", function (a, b) { - var percent = (a / (a + b)) * 100 - var barWidth = percent / 10 - var bar = "**********".slice(0, barWidth) - var space = "...........".slice(0, 10 - barWidth) - return bar + space + " " + parseInt(percent) + "% " -}) + var percent = (a / (a + b)) * 100; + var barWidth = percent / 10; + var bar = "**********".slice(0, barWidth); + var space = "...........".slice(0, 10 - barWidth); + return bar + space + " " + parseInt(percent) + "% "; +}); hbs.registerHelper("chart", function (data, height) { if (data.length > 0) { return asciichart.plot(data, { height: height, - }) + }); } else { - return "**No data**" + return "**No data**"; } -}) +}); -hbs.registerHelper('json', function(obj) { +hbs.registerHelper("json", function (obj) { return JSON.stringify(obj); -}) +}); -var app = express() +var app = express(); // view engine setup -app.set("views", path.join(__dirname, "views")) -app.set("view engine", "hbs") +app.set("views", path.join(__dirname, "views")); +app.set("view engine", "hbs"); -app.use(logger("dev")) -app.use(express.json()) +app.use(logger("dev")); +app.use(express.json()); app.use( express.urlencoded({ extended: false, }) -) -app.use(cookieParser()) -app.use(express.static(path.join(__dirname, "public"))) +); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, "public"))); -app.use('/', indexRouter); -app.use('/blocks', blocksRouter); -app.use('/assets', assetsRouter); -app.use('/validator', validatorRouter); -app.use("/mempool", mempoolRouter) -app.use("/search", searchRouter) +app.use("/", indexRouter); +app.use("/blocks", blocksRouter); +app.use("/assets", assetsRouter); +app.use("/validator", validatorRouter); +app.use("/mempool", mempoolRouter); +app.use("/search", searchRouter); // catch 404 and forward to error handler app.use(function (req, res, next) { - next(createError(404)) -}) + next(createError(404)); +}); // error handler app.use(function (err, req, res) { // set locals, only providing error in development - res.locals.message = err.message - res.locals.error = req.app.get("env") === "development" ? err : {} + res.locals.message = err.message; + res.locals.error = req.app.get("env") === "development" ? err : {}; // render the error page - res.status(err.status || 500) - res.render("error") -}) + res.status(err.status || 500); + res.render("error"); +}); -module.exports = app +module.exports = app; diff --git a/applications/tari_explorer/baseNodeClient.js b/applications/tari_explorer/baseNodeClient.js index 73267e8da5..11852781b8 100644 --- a/applications/tari_explorer/baseNodeClient.js +++ b/applications/tari_explorer/baseNodeClient.js @@ -1,9 +1,9 @@ -var { Client } = require("base-node-grpc-client") +var { Client } = require("base-node-grpc-client"); function createClient() { - return Client.connect("localhost:18142") + return Client.connect("localhost:18142"); } module.exports = { createClient, -} +}; diff --git a/applications/tari_explorer/bin/www b/applications/tari_explorer/bin/www index cc31eafa52..255b127045 100755 --- a/applications/tari_explorer/bin/www +++ b/applications/tari_explorer/bin/www @@ -4,49 +4,49 @@ * Module dependencies. */ -var app = require('../app'); -var debug = require('debug')('tari-explorer:server'); -var http = require('http'); +var app = require("../app") +var debug = require("debug")("tari-explorer:server") +var http = require("http") /** * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '4000'); -app.set('port', port); +var port = normalizePort(process.env.PORT || "4000") +app.set("port", port) /** * Create HTTP server. */ -var server = http.createServer(app); +var server = http.createServer(app) /** * Listen on provided port, on all network interfaces. */ -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); +server.listen(port) +server.on("error", onError) +server.on("listening", onListening) /** * Normalize a port into a number, string, or false. */ function normalizePort(val) { - var port = parseInt(val, 10); + var port = parseInt(val, 10) if (isNaN(port)) { // named pipe - return val; + return val } if (port >= 0) { // port number - return port; + return port } - return false; + return false } /** @@ -54,26 +54,24 @@ function normalizePort(val) { */ function onError(error) { - if (error.syscall !== 'listen') { - throw error; + if (error.syscall !== "listen") { + throw error } - var bind = typeof port === 'string' - ? 'Pipe ' + port - : 'Port ' + port; + var bind = typeof port === "string" ? "Pipe " + port : "Port " + port // handle specific listen errors with friendly messages switch (error.code) { - case 'EACCES': - console.error(bind + ' requires elevated privileges'); - process.exit(1); - break; - case 'EADDRINUSE': - console.error(bind + ' is already in use'); - process.exit(1); - break; + case "EACCES": + console.error(bind + " requires elevated privileges") + process.exit(1) + break + case "EADDRINUSE": + console.error(bind + " is already in use") + process.exit(1) + break default: - throw error; + throw error } } @@ -82,9 +80,9 @@ function onError(error) { */ function onListening() { - var addr = server.address(); - var bind = typeof addr === 'string' - ? 'pipe ' + addr - : 'port ' + addr.port; - debug('Listening on ' + bind); + var addr = server.address() + console.log("Address: ", addr) + var bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port + debug("Listening on " + bind) + console.log("Listening on " + bind) } diff --git a/applications/tari_explorer/routes/assets.js b/applications/tari_explorer/routes/assets.js index fb91877ceb..ae6480ad95 100644 --- a/applications/tari_explorer/routes/assets.js +++ b/applications/tari_explorer/routes/assets.js @@ -20,40 +20,40 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -var { createClient: createBaseNodeClient } = require('../baseNodeClient') +var { createClient: createBaseNodeClient } = require("../baseNodeClient"); -var express = require('express') -var router = express.Router() +var express = require("express"); +var router = express.Router(); /* GET home page. */ -router.get('/:asset_public_key', async function (req, res, next) { - let baseNodeClient = createBaseNodeClient() +router.get("/:asset_public_key", async function (req, res) { + let baseNodeClient = createBaseNodeClient(); // let validatorNodeClient = createValidatorNodeClient() - let asset_public_key = req.params.asset_public_key + let asset_public_key = req.params.asset_public_key; try { - let tokens = await baseNodeClient.getTokens({ asset_public_key: Buffer.from(asset_public_key, "hex") }) - console.log(tokens) + let tokens = await baseNodeClient.getTokens({ + asset_public_key: Buffer.from(asset_public_key, "hex"), + }); + console.log(tokens); if (!tokens || tokens.length === 0) { res.status(404); - res.render('404', { message: `No tokens for asset found`}); + res.render("404", { message: `No tokens for asset found` }); return; } // let headers = validatorNodeClient.listHeaders({ from_height: 0, num_headers: 101 }) - res.render('assets', { + res.render("assets", { title: `Asset with pub key: ${asset_public_key}`, tokens: tokens, // headers - }) - - + }); } catch (error) { - res.status(500) - res.render('error', { error: error }) + res.status(500); + res.render("error", { error: error }); } -}) +}); -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/routes/blocks.js b/applications/tari_explorer/routes/blocks.js index c8d6b3b205..9bc9b3cf1b 100644 --- a/applications/tari_explorer/routes/blocks.js +++ b/applications/tari_explorer/routes/blocks.js @@ -20,38 +20,50 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -var { createClient } = require('../baseNodeClient') +var { createClient } = require("../baseNodeClient"); -var express = require("express") -var router = express.Router() +var express = require("express"); +var router = express.Router(); router.get("/:height", async function (req, res) { - let client = createClient() - let height = req.params.height - try { - let block = await client.getBlocks({ heights: [height] }) + let client = createClient(); + let height = parseInt(req.params.height); + let block = await client.getBlocks({ heights: [height] }); if (!block || block.length === 0) { res.status(404); - res.render('404', { message: `Block at height ${height} not found`}); + res.render("404", { message: `Block at height ${height} not found` }); return; } - console.log(block) - console.log(block[0].block.body.outputs[0]) - res.render('blocks', { - title: `Block at height:${block[0].block.header.height}`, - height: height, - prevHeight: parseInt(height) - 1, - nextHeight: parseInt(height) + 1, - block: block[0].block, - pows: { '0': 'Monero', '2': 'SHA' } - }) + let tipInfo = await client.getTipInfo({}); + let tipHeight = parseInt(tipInfo.metadata.height_of_longest_chain); + + let prevHeight = height - 1; + let prevLink = `/blocks/${prevHeight}`; + if (height === 0) prevLink = null; + + let nextHeight = height + 1; + let nextLink = `/blocks/${nextHeight}`; + if (height === tipHeight) nextLink = null; + + // console.log(block); + res.render("blocks", { + title: `Block at height: ${block[0].block.header.height}`, + header: block[0].block.header, + height, + prevLink, + prevHeight, + nextLink, + nextHeight, + block: block[0].block, + pows: { 0: "Monero", 1: "SHA-3" }, + }); } catch (error) { - res.status(500) - res.render('error', { error: error }) + res.status(500); + res.render("error", { error: error }); } -}) +}); -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/routes/index.js b/applications/tari_explorer/routes/index.js index fe9cdd9273..06fb08d681 100644 --- a/applications/tari_explorer/routes/index.js +++ b/applications/tari_explorer/routes/index.js @@ -1,39 +1,39 @@ -var { createClient } = require("../baseNodeClient") +var { createClient } = require("../baseNodeClient"); -var express = require("express") -var router = express.Router() +var express = require("express"); +var router = express.Router(); /* GET home page. */ router.get("/", async function (req, res) { try { - let client = createClient() - let from = parseInt(req.query.from || 0) - let limit = parseInt(req.query.limit || "20") + let client = createClient(); + let from = parseInt(req.query.from || 0); + let limit = parseInt(req.query.limit || "20"); - let tipInfo = await client.getTipInfo({}) + let tipInfo = await client.getTipInfo({}); // Algo split let last100Headers = await client.listHeaders({ from_height: 0, num_headers: 101, - }) - let monero = [0, 0, 0, 0] - let sha = [0, 0, 0, 0] + }); + let monero = [0, 0, 0, 0]; + let sha = [0, 0, 0, 0]; // console.log(last100Headers) for (let i = 0; i < last100Headers.length - 1; i++) { - let arr = last100Headers[i].pow.pow_algo === "0" ? monero : sha + let arr = last100Headers[i].pow.pow_algo === "0" ? monero : sha; if (i < 10) { - arr[0] += 1 + arr[0] += 1; } if (i < 20) { - arr[1] += 1 + arr[1] += 1; } if (i < 50) { - arr[2] += 1 + arr[2] += 1; } - arr[3] += 1 + arr[3] += 1; } const algoSplit = { monero10: monero[0], @@ -44,95 +44,96 @@ router.get("/", async function (req, res) { sha20: sha[1], sha50: sha[2], sha100: sha[3], - } + }; // console.log(algoSplit) // Get one more header than requested so we can work out the difference in MMR_size let headers = await client.listHeaders({ from_height: from, num_headers: limit + 1, - }) + }); for (var i = headers.length - 2; i >= 0; i--) { headers[i].kernels = - headers[i].kernel_mmr_size - headers[i + 1].kernel_mmr_size + headers[i].kernel_mmr_size - headers[i + 1].kernel_mmr_size; headers[i].outputs = - headers[i].output_mmr_size - headers[i + 1].output_mmr_size + headers[i].output_mmr_size - headers[i + 1].output_mmr_size; } - let lastHeader = headers[headers.length - 1] + let lastHeader = headers[headers.length - 1]; if (lastHeader.height === "0") { // If the block is the genesis block, then the MMR sizes are the values to use - lastHeader.kernels = lastHeader.kernel_mmr_size - lastHeader.outputs = lastHeader.output_mmr_size + lastHeader.kernels = lastHeader.kernel_mmr_size; + lastHeader.outputs = lastHeader.output_mmr_size; } else { // Otherwise remove the last one, as we don't want to show it - headers.splice(headers.length - 1, 1) + headers.splice(headers.length - 1, 1); } // console.log(headers); - let firstHeight = parseInt(headers[0].height || "0") + let firstHeight = parseInt(headers[0].height || "0"); // -- mempool - let mempool = await client.getMempoolTransactions({}) + let mempool = await client.getMempoolTransactions({}); - console.log(mempool) + console.log(mempool); for (let i = 0; i < mempool.length; i++) { - let sum = 0 + let sum = 0; for (let j = 0; j < mempool[i].transaction.body.kernels.length; j++) { - sum += parseInt(mempool[i].transaction.body.kernels[j].fee) + sum += parseInt(mempool[i].transaction.body.kernels[j].fee); } - mempool[i].transaction.body.total_fees = sum + mempool[i].transaction.body.total_fees = sum; } - res.render("index", { + const result = { title: "Blocks", - tipInfo: tipInfo, - mempool: mempool, - headers: headers, - pows: { 0: "Monero", 2: "SHA" }, + tipInfo, + mempool, + headers, + pows: { 0: "Monero", 1: "SHA-3" }, nextPage: firstHeight - limit, prevPage: firstHeight + limit, - limit: limit, - from: from, - algoSplit: algoSplit, + limit, + from, + algoSplit, blockTimes: getBlockTimes(last100Headers), moneroTimes: getBlockTimes(last100Headers, "0"), shaTimes: getBlockTimes(last100Headers, "1"), - }) + }; + res.render("index", result); } catch (error) { - res.status(500) - res.render("error", { error: error }) + res.status(500); + res.render("error", { error: error }); } -}) +}); function getBlockTimes(last100Headers, algo) { - let blocktimes = [] - let i = 0 + let blocktimes = []; + let i = 0; if (algo === "0" || algo === "1") { while ( i < last100Headers.length && last100Headers[i].pow.pow_algo !== algo ) { - i++ - blocktimes.push(0) + i++; + blocktimes.push(0); } } if (i >= last100Headers.length) { // This happens if there are no blocks for a specific algorithm in last100headers - return blocktimes + return blocktimes; } - let lastBlockTime = parseInt(last100Headers[i].timestamp.seconds) - i++ + let lastBlockTime = parseInt(last100Headers[i].timestamp.seconds); + i++; while (i < last100Headers.length && blocktimes.length < 60) { if (!algo || last100Headers[i].pow.pow_algo === algo) { blocktimes.push( (lastBlockTime - parseInt(last100Headers[i].timestamp.seconds)) / 60 - ) - lastBlockTime = parseInt(last100Headers[i].timestamp.seconds) + ); + lastBlockTime = parseInt(last100Headers[i].timestamp.seconds); } else { - blocktimes.push(0) + blocktimes.push(0); } - i++ + i++; } - return blocktimes + return blocktimes; } -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/routes/mempool.js b/applications/tari_explorer/routes/mempool.js index 1d8408b0fa..d24441fc9e 100644 --- a/applications/tari_explorer/routes/mempool.js +++ b/applications/tari_explorer/routes/mempool.js @@ -1,15 +1,15 @@ -var express = require("express") -const { createClient } = require("../baseNodeClient") -var router = express.Router() +var express = require("express"); +const { createClient } = require("../baseNodeClient"); +var router = express.Router(); /* GET mempool page. */ router.get("/:excessSigs", async function (req, res) { try { - let client = createClient() - let txId = req.params.excessSigs.split("+") - console.log(txId) - let mempool = await client.getMempoolTransactions({}) - let tx = null + let client = createClient(); + let txId = req.params.excessSigs.split("+"); + console.log(txId); + let mempool = await client.getMempoolTransactions({}); + let tx = null; for (let i = 0; i < mempool.length; i++) { for (let j = 0; j < mempool[i].transaction.body.kernels.length; j++) { for (let k = 0; k < txId.length; k++) { @@ -19,30 +19,30 @@ router.get("/:excessSigs", async function (req, res) { mempool[i].transaction.body.kernels[j].excess_sig.signature ).toString("hex") ) { - tx = mempool[i].transaction - break + tx = mempool[i].transaction; + break; } } if (tx) { - break + break; } } } if (!tx) { - res.status(404) - res.render("error", { error: "Tx not found" }) - return + res.status(404); + res.render("error", { error: "Tx not found" }); + return; } - console.log(tx) - console.log("===============") + console.log(tx); + console.log("==============="); res.render("Mempool", { tx, - }) + }); } catch (error) { - res.status(500) - res.render("error", { error: error }) + res.status(500); + res.render("error", { error: error }); } -}) +}); -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/routes/search.js b/applications/tari_explorer/routes/search.js index f59c7caaa9..120526793d 100644 --- a/applications/tari_explorer/routes/search.js +++ b/applications/tari_explorer/routes/search.js @@ -20,37 +20,37 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -var { createClient } = require("../baseNodeClient") +var { createClient } = require("../baseNodeClient"); -var express = require("express") -var router = express.Router() +var express = require("express"); +var router = express.Router(); router.get("/", async function (req, res) { - let client = createClient() + let client = createClient(); let commitments = ( req.query.comm || req.query.commitment || req.query.c || "" - ).split(",") + ).split(","); if (commitments.length === 0) { - res.status(404) - return + res.status(404); + return; } - let hexCommitments = [] + let hexCommitments = []; for (let i = 0; i < commitments.length; i++) { - hexCommitments.push(Buffer.from(commitments[i], "hex")) + hexCommitments.push(Buffer.from(commitments[i], "hex")); } - console.log(hexCommitments) + console.log(hexCommitments); let result = await client.searchUtxos({ hexCommitments, - }) + }); - console.log(result) + console.log(result); res.render("search", { items: result, - }) -}) + }); +}); -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/routes/validator.js b/applications/tari_explorer/routes/validator.js index 9bd11d2518..e5a0643ecb 100644 --- a/applications/tari_explorer/routes/validator.js +++ b/applications/tari_explorer/routes/validator.js @@ -19,26 +19,27 @@ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -var {createClient: createValidatorNodeClient} = require('../validatorNodeClient') +var { + createClient: createValidatorNodeClient, +} = require("../validatorNodeClient"); -var express = require('express') -var router = express.Router() +var express = require("express"); +var router = express.Router(); router.get("/", async function (req, res) { - try { - let client = createValidatorNodeClient(); - let metadata = await client.getMetadata(); - console.log(metadata); + try { + let client = createValidatorNodeClient(); + let metadata = await client.getMetadata(); + console.log(metadata); - res.render('validator', { - title: `Validator node`, - sidechains: metadata.sidechains - }) - - } catch (error) { - res.status(500) - res.render('error', {error: error}) - } + res.render("validator", { + title: `Validator node`, + sidechains: metadata.sidechains, + }); + } catch (error) { + res.status(500); + res.render("error", { error: error }); + } }); -module.exports = router +module.exports = router; diff --git a/applications/tari_explorer/validatorNodeClient.js b/applications/tari_explorer/validatorNodeClient.js index 2a83954d29..f4cb4d3572 100644 --- a/applications/tari_explorer/validatorNodeClient.js +++ b/applications/tari_explorer/validatorNodeClient.js @@ -1,10 +1,9 @@ -var {Client} = require("validator-node-grpc-client"); +var { Client } = require("validator-node-grpc-client"); function createClient() { - return Client.connect("localhost:18144"); + return Client.connect("localhost:18144"); } module.exports = { - createClient -} - + createClient, +}; diff --git a/applications/tari_explorer/views/assets.hbs b/applications/tari_explorer/views/assets.hbs index 46e2073af3..f63fe806ef 100644 --- a/applications/tari_explorer/views/assets.hbs +++ b/applications/tari_explorer/views/assets.hbs @@ -1,7 +1,7 @@

{{this.title}}

Tokens

- +
diff --git a/applications/tari_explorer/views/blocks.hbs b/applications/tari_explorer/views/blocks.hbs index 3fa2cc8a60..f1fe50a674 100644 --- a/applications/tari_explorer/views/blocks.hbs +++ b/applications/tari_explorer/views/blocks.hbs @@ -1,12 +1,81 @@ Back to all blocks

{{title}}

- < Block {{prevHeight}} - Block {{nextHeight}} > + {{#if prevLink}} + < Block {{prevHeight}} + {{/if}} + {{#if nextLink}} + Block {{nextHeight}} > + {{/if}}

+
+

Header

+
Unique ID
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Hash{{hex this.header.hash}}
Proof of Work{{lookup this.pows this.header.pow.pow_algo}}
Height{{this.header.height}}
Version{{this.header.version}}
Timestamp{{timestamp this.header.timestamp}}
Previous Hash{{hex this.header.prev_hash}}
Nonce{{this.header.nonce}}
Output Merkle Root{{hex this.header.output_mr}}
Witness Merkle Root{{hex this.header.witness_mr}}
Kernel Merkle Root{{hex this.header.kernel_mr}}
Input Merkle Root{{hex this.header.input_mr}}
Kernel MMR Size{{this.header.kernel_mmr_size}}
Output MMR Size{{this.header.output_mmr_size}}
Total Kernel Offset{{hex this.header.total_kernel_offset}}
Total Script Offset{{hex this.header.total_script_offset}}
+

Kernels

- +
@@ -34,38 +103,40 @@

Outputs

-
Hash
+
- - - - + + + + {{#each this.block.body.outputs}} - - - - - - - - - - + + + + + + + + + + {{/each}}
Hash Commitment Flags MaturityParent PKUnique IdOther FeaturesScriptParent PKUnique IdOther FeaturesScript
{{hex hash}}{{hex commitment}}{{features.flags}}{{features.maturity}}{{ hex features.parent_public_key }}{{ hex features.unique_id}}{{ json features }}{{hex script}}
{{hex hash}}{{hex commitment}}{{features.flags}}{{features.maturity}}{{hex + features.parent_public_key + }}{{hex features.unique_id}}{{json features}}{{hex script}}

Spent Inputs

- +
diff --git a/applications/tari_explorer/views/index.hbs b/applications/tari_explorer/views/index.hbs index 6a3ba79797..f565983768 100644 --- a/applications/tari_explorer/views/index.hbs +++ b/applications/tari_explorer/views/index.hbs @@ -1,24 +1,24 @@

Tip

-
Hash
+
- + - +
Chain height Best blockPruning horizonPruned height
{{this.tipInfo.metadata.height_of_longest_chain}} {{hex this.tipInfo.metadata.best_block}}{{this.tipInfo.metadata.pruning_horizon}}{{this.tipInfo.metadata.pruned_height}}

Proof of work split

- +
@@ -42,7 +42,7 @@ - + @@ -53,7 +53,7 @@
 {{this.algoSplit.monero100}} {{percentbar this.algoSplit.monero100 this.algoSplit.sha100}}
Sha3SHA-3 {{this.algoSplit.sha10}} {{percentbar this.algoSplit.sha10 this.algoSplit.monero10}} {{this.algoSplit.sha20}} {{percentbar this.algoSplit.sha20 this.algoSplit.monero20}}

- +

Block times (minutes)

@@ -83,7 +83,7 @@

{{title}}

- +
@@ -123,7 +123,7 @@

Mempool

-
Height
+
diff --git a/applications/tari_explorer/views/layout.hbs b/applications/tari_explorer/views/layout.hbs index 3c0ee74010..9afc72630d 100644 --- a/applications/tari_explorer/views/layout.hbs +++ b/applications/tari_explorer/views/layout.hbs @@ -4,11 +4,17 @@

A simple, no Javascript, (almost) no CSS block explorer for Tari

+

tari.com


{{{body}}}
Excess