forked from tari-project/tari
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into core-prune-inputs
* development: feat: implement dht pooled db connection (tari-project#3596) feat: add page for detailed mempool in explorer (tari-project#3613) chore: add pub key in the dailes notify (tari-project#3612) feat: display network for console wallet (tari-project#3611) docs: update covenants links (tari-project#3614)
- Loading branch information
Showing
24 changed files
with
644 additions
and
573 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,94 @@ | ||
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') | ||
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 indexRouter = require("./routes/index"); | ||
var blocksRouter = require("./routes/blocks"); | ||
var mempoolRouter = require("./routes/mempool"); | ||
|
||
var hbs = require('hbs') | ||
hbs.registerHelper('hex', function (buffer) { | ||
var hbs = require("hbs"); | ||
hbs.registerHelper("hex", function (buffer) { | ||
return buffer ? Buffer.from(buffer).toString("hex") : ""; | ||
}); | ||
hbs.registerHelper("json", function (obj) { | ||
return Buffer.from(JSON.stringify(obj)).toString("base64"); | ||
}); | ||
|
||
return buffer ? buffer.toString('hex') : '' | ||
}) | ||
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(); | ||
|
||
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() | ||
return ( | ||
year.toString() + | ||
"-" + | ||
month.toString().padStart(2, "0") + | ||
"-" + | ||
day.toString().padStart(2, "0") + | ||
" " + | ||
hours.toString().padStart(2, "0") + | ||
":" + | ||
minutes.toString().padStart(2, "0") + | ||
":" + | ||
seconds.toString().padStart(2, "0") | ||
); | ||
}); | ||
|
||
return year.toString() + '-' + | ||
month.toString().padStart(2, '0') + '-' + | ||
day.toString().padStart(2, '0') + ' ' + | ||
hours.toString().padStart(2, '0') + ':' + | ||
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) + "% "; | ||
}); | ||
|
||
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) + '% ' | ||
}) | ||
hbs.registerHelper("chart", function (data, height) { | ||
return asciichart.plot(data, { | ||
height: height, | ||
}); | ||
}); | ||
|
||
hbs.registerHelper('chart', function(data, height) { | ||
return asciichart.plot(data, {height: height}) | ||
}) | ||
|
||
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(express.urlencoded({ extended: false })) | ||
app.use(cookieParser()) | ||
app.use(express.static(path.join(__dirname, 'public'))) | ||
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('/', indexRouter) | ||
app.use('/blocks', blocksRouter) | ||
app.use("/", indexRouter); | ||
app.use("/blocks", blocksRouter); | ||
app.use("/mempool", mempoolRouter); | ||
|
||
// 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, next) { | ||
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var { createClient } = require("../baseNodeClient"); | ||
|
||
var express = require("express"); | ||
var router = express.Router(); | ||
|
||
/* GET mempool page. */ | ||
router.get("/:tx", async function (req, res, next) { | ||
let tx = JSON.parse(Buffer.from(req.params.tx, "base64")); | ||
console.log("========== stringify 2 ========"); | ||
console.log(tx.inputs); | ||
console.log("==============="); | ||
res.render("Mempool", { | ||
inputs: tx.inputs, | ||
outputs: tx.outputs, | ||
kernels: tx.kernels, | ||
}); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.