Skip to content

Commit

Permalink
Merge pull request 'add-inflation-runrate' (iquidus#6) from add-infla…
Browse files Browse the repository at this point in the history
…tion-runrate into master

Reviewed-on: http://172.16.10.89:3000/maff1989/lotus-explorer/pulls/6
  • Loading branch information
Matthew Urgero committed Oct 29, 2022
2 parents ff26a8c + 2d1fdcd commit 272d27e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
24 changes: 18 additions & 6 deletions routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,25 @@ router.get('/stats', async (req, res) => {
return route_get_index(res, null);
}
try {
const difficulty = await lib.explorer.get_difficulty();
const hashrate = await lib.explorer.get_hashrate();
const connections = await lib.explorer.get_connectioncount();
const blockcount = await lib.explorer.get_blockcount();
const mempool = await lib.explorer.get_mempoolinfo();
const dbStats = await db.get_stats(settings.coin);
// calculate runrate inflation
//
const block = await db.get_latest_block();
const inflation =
((block.subsidy - block.burned) * 720 * 365) / dbStats.supply;
const stats = {
difficulty: await lib.explorer.get_difficulty(),
hashrate: await lib.explorer.get_hashrate(),
connections: await lib.explorer.get_connectioncount(),
blockcount: await lib.explorer.get_blockcount(),
mempool: await lib.explorer.get_mempoolinfo(),
dbStats: await db.get_stats(settings.coin)
difficulty,
hashrate,
connections,
blockcount,
mempool,
inflation,
dbStats
};
const dbCharts = await db.get_charts();
return res.render('stats', {
Expand Down
24 changes: 1 addition & 23 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ html
link(rel='stylesheet', href='/vendor/flags-css/css/flag-icon.min.css')
link(res='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css')
link(rel='stylesheet', href='//cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css')
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css')
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js')
script(src='//stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js')
Expand Down Expand Up @@ -197,28 +197,6 @@ html
span.fa.fa-info-circle
span.menu-text #{settings.locale.menu_api}
.col-md-12
.row.text-center.d-flex.justify-content-center
//- don't need the BTC Price card
.col-md-2
.card.card-default.d-none.d-md-block.d-block
if settings.index.show_market_cap != true || settings.index.show_market_cap_over_price != true
.card-header
strong #{settings.markets.exchange} Price
.card-body
#pricecard
span.header-icons.fa.fa-rocket
if settings.index.difficulty == 'Hybrid'
label#lastPrice -
<br>
label#lblX1
else
label#lastPrice -
if settings.index.show_market_cap == true && settings.index.show_market_cap_over_price == true
.card-header
strong Market Cap
.card-body
label#marketCap -
.row.text-center(style='margin-top:10px;margin-bottom:20px;')
form.form-inline.col-12.d-flex.justify-content-center(method='post', action='/search')
#index-search.form-group.d-flex.justify-content-center
Expand Down
26 changes: 21 additions & 5 deletions views/stats.pug
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ block content
});
.col-md-12
.row.text-center.d-flex.justify-content-center
- const inflation = (stats.inflation * 100).toFixed(3);
- const difficulty = stats.difficulty.toFixed(5);
- const mempoolSize = stats.mempool.size.toLocaleString('en');
- const mempoolKB = stats.mempool.bytes.toFixed(3) / 1000;
Expand Down Expand Up @@ -587,6 +588,14 @@ block content
label#difficultyHybrid -
else
label#difficulty #{difficulty}
.col-md-2
.card.card-default.d-none.d-sm-block.d-block
.card-header
strong #{settings.locale.ex_mempoolinfo}
.card-body
#mempoolinfocard
span.header-icons.fa.fa-th-list
label#mempoolinfo #{mempoolSize} (#{mempoolKB} KB)
//-
.col-md-2.col-md-12
img(src=settings.logo, style='margin-top:-15px;height:128px;')
Expand Down Expand Up @@ -616,15 +625,22 @@ block content
.card-body
span.header-icons.fa.fa-fire
label#burnedSupply #{burned}

.col-md-2
.card.card-default.d-none.d-sm-block.d-block
.card-header
strong #{settings.locale.ex_mempoolinfo}
strong Inflation
span.fa.fa-info-circle(
data-toggle = 'popover'
data-content = 'At the inflation rate of the latest block, supply will increase by this % over the span of 1 year'
)#inflationPopover
.card-body
#mempoolinfocard
span.header-icons.fa.fa-th-list
label#mempoolinfo #{mempoolSize} (#{mempoolKB} KB)
span.header-icons.fa.fa-percent
label#inflation #{inflation}
script.
$('#inflationPopover').popover({
placement: 'top',
trigger: 'hover'
});
hr
.col-md-12
.row
Expand Down

0 comments on commit 272d27e

Please sign in to comment.