Skip to content

Commit

Permalink
Merge branch 'development' into core-prune-inputs
Browse files Browse the repository at this point in the history
* 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
sdbondi committed Nov 25, 2021
2 parents 90308ec + 2ac0757 commit 88eeed0
Show file tree
Hide file tree
Showing 24 changed files with 644 additions and 573 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 77 additions & 71 deletions RFC/src/RFC-0250_Covenants.md

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions applications/daily_tests/cron_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ ${logLines.join("\n")}
}

async function runBaseNodeSyncTest(syncType) {
notify(`🚀 ${syncType} basenode sync check has begun 🚀`);
const node_pub_key =
"b0c1f788f137ba0cdc0b61e89ee43b80ebf5cca4136d3229561bf11eba347849";
const node_address = "/ip4/3.8.193.254/tcp/18189";
notify(
`🚀 ${syncType} basenode sync (from ${node_pub_key}) check has begun 🚀`
);

const baseDir = __dirname + "/temp/base-node-sync";

Expand All @@ -97,9 +102,7 @@ async function runBaseNodeSyncTest(syncType) {
log: LOG_FILE,
syncType,
baseDir,
forceSyncPeers: [
"b0c1f788f137ba0cdc0b61e89ee43b80ebf5cca4136d3229561bf11eba347849::/ip4/3.8.193.254/tcp/18189",
],
forceSyncPeers: [`${node_pub_key}::${node_address}`],
});

notify(
Expand Down
42 changes: 29 additions & 13 deletions applications/tari_console_wallet/src/ui/components/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use tari_app_utilities::consts;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
style::{Color, Style},
text::{Span, Spans},
widgets::{Block, Paragraph},
Frame,
Expand All @@ -18,14 +18,15 @@ impl Menu {
}

impl<B: Backend> Component<B> for Menu {
fn draw(&mut self, f: &mut Frame<B>, area: Rect, _app_state: &AppState)
fn draw(&mut self, f: &mut Frame<B>, area: Rect, app_state: &AppState)
where B: Backend {
let columns = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Ratio(1, 5),
Constraint::Ratio(3, 5),
Constraint::Ratio(1, 5),
Constraint::Ratio(2, 5),
Constraint::Ratio(1, 5),
]
.as_ref(),
Expand All @@ -36,31 +37,46 @@ impl<B: Backend> Component<B> for Menu {
Span::styled(" Version: ", Style::default().fg(Color::White)),
Span::styled(consts::APP_VERSION_NUMBER, Style::default().fg(Color::Magenta)),
Span::raw(" "),
match cfg!(feature = "avx2") {
true => Span::styled("Avx2", Style::default().fg(Color::LightGreen)),
false => Span::styled(
"Avx2",
Style::default().fg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT),
),
},
/* In the event this is needed in future, should be put into its' own span
* match cfg!(feature = "avx2") {
* true => Span::styled("Avx2", Style::default().fg(Color::LightGreen)),
* false => Span::styled(
* "Avx2",
* Style::default().fg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT),
* ),
* },
*/
]);

let network = Spans::from(vec![
Span::styled(" Network: ", Style::default().fg(Color::White)),
Span::styled(
app_state.get_network().to_string(),
Style::default().fg(Color::LightGreen),
),
Span::raw(" "),
]);

let tabs = Spans::from(vec![
Span::styled("LeftArrow: ", Style::default().fg(Color::White)),
Span::styled("Previous Tab ", Style::default().fg(Color::Magenta)),
Span::raw(" "),
Span::styled("Tab/RightArrow: ", Style::default().fg(Color::White)),
Span::styled("Next Tab ", Style::default().fg(Color::Magenta)),
]);

let quit = Spans::from(vec![
Span::styled(" F10/Ctrl-Q: ", Style::default().fg(Color::White)),
Span::styled("Quit ", Style::default().fg(Color::Magenta)),
]);

let paragraph = Paragraph::new(version).block(Block::default());
let paragraph = Paragraph::new(network).block(Block::default());
f.render_widget(paragraph, columns[0]);
let paragraph = Paragraph::new(tabs).block(Block::default());
let paragraph = Paragraph::new(version).block(Block::default());
f.render_widget(paragraph, columns[1]);
let paragraph = Paragraph::new(quit).block(Block::default());
let paragraph = Paragraph::new(tabs).block(Block::default());
f.render_widget(paragraph, columns[2]);
let paragraph = Paragraph::new(quit).block(Block::default());
f.render_widget(paragraph, columns[3]);
}
}
4 changes: 4 additions & 0 deletions applications/tari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ impl AppState {
Igor => MicroTari(5),
}
}

pub fn get_network(&self) -> Network {
self.node_config.network
}
}
pub struct AppStateInner {
updated: bool,
Expand Down
129 changes: 73 additions & 56 deletions applications/tari_explorer/app.js
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;
19 changes: 19 additions & 0 deletions applications/tari_explorer/routes/mempool.js
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;
2 changes: 1 addition & 1 deletion applications/tari_explorer/views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
{{#each mempool}}
{{#with this.transaction.body}}
<tr>
<td>{{#each this.kernels}}<span>{{hex this.excess_sig.signature}}</span>{{/each}}</td>
<td><a href="/mempool/{{json this}}">{{#each this.kernels}}<span>{{hex this.excess_sig.signature}}</span>{{/each}}</a></td>
<td>{{this.total_fees}}</td>
<td>{{this.outputs.length}}</td>
<td>{{this.kernels.length}}</td>
Expand Down
Loading

0 comments on commit 88eeed0

Please sign in to comment.