-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathindex-network-summary.pug
More file actions
388 lines (294 loc) · 18.7 KB
/
Copy pathindex-network-summary.pug
File metadata and controls
388 lines (294 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
- var colClass = "col-lg-6 px-2";
if (exchangeRates || networkVolume)
- colClass = "col-lg-4 px-2";
- var utxoCalculatingDesc = "At startup the app pulls a summary of the UTXO set. Until this summary is retrieved this data can't be displayed. Wait for the summary request to your node to return, then refresh this page.";
- let halvingSoon = false;
- let halvingVerySoon = false;
- let halvingProgressPercent = 0;
if (nextHalvingData)
if (!nextHalvingData.blocksUntilNextHalving)
- nextHalvingData.blocksUntilNextHalving = 0;
- nextHalvingData.halvingBlockInterval = 0;
- halvingProgressPercent = new Decimal(100).minus(new Decimal(nextHalvingData.blocksUntilNextHalving).dividedBy(nextHalvingData.halvingBlockInterval).times(100));
if (halvingProgressPercent > 65)
- halvingSoon = true;
if (halvingProgressPercent > 98)
-halvingVerySoon = true;
if (halvingVerySoon)
#index-halving-countdown-wrapper
.d-flex.justify-content-start
.text-success
+sectionTitle("Halving Countdown 👀")
.ms-2
span.spinner-border.spinner-border-sm
.mb-section
.card.mb-section.shadow-sm.border-2.border-success
.card-body
div#index-halving-countdown
.text-center.text-reset
.mt-2
.spinner-border.spinner-border-sm
if (exchangeRates)
+contentSection("Market")
- var colCount = 3 + (networkVolume ? 1 : 0) + (goldExchangeRates ? 1 : 0);
+summaryRow(colCount)
- var tzDiff = -parseFloat(browserTzOffset);
if (userTzOffset != "unset")
- tzDiff = parseFloat(userTzOffset);
- var tzMoment = moment.utc(global.exchangeRatesUpdateTime).add(tzDiff, "hours");
- var timeText = tzMoment.format("h:mma");
+summaryItem("Exchange Rate", `Source: ${new URL(coinConfig.exchangeRateData.jsonUrl).hostname}<br/>Last Updated: ${timeText} (${new Decimal(new Date().getTime() - global.exchangeRatesUpdateTime.getTime()).dividedBy(1000).dividedBy(60).toDP(0)} min ago)`)
- var formatData = utils.formatExchangedCurrency(1.0, userSettings.localCurrency, 0);
span.text-success
span.me-1 #{formatData.symbol}
| #{formatData.val}
+summaryItem("Sats Rate")
- var satsRateData = utils.satoshisPerUnitOfLocalCurrency(userSettings.localCurrency);
span #{satsRateData.amt}
small #{satsRateData.unit}
+summaryItem("Market Cap")
- var supply = utils.estimatedSupply(getblockchaininfo.blocks);
- var mcapData = utils.formatLargeNumber(parseFloat(supply) * global.exchangeRates[userSettings.localCurrency], 3);
span.me-1 #{global.currencyTypes[userSettings.localCurrency].symbol}
span #{mcapData[0]}
if (mcapData[1].textDesc)
span.ms-1 #{mcapData[1].textDesc}
else
span x 10
sup #{mcapData[1].exponent}
// ["154.9",{"val":1000000000,"name":"giga","abbreviation":"G","exponent":"9"}]
if (global.goldExchangeRates && global.goldExchangeRates["usd"] && global.exchangeRates && global.exchangeRates["usd"])
// usd is the only bridge for our data sources
+summaryItem("Gold Rate", `Source: ${new URL(coinConfig.goldExchangeRateData.jsonUrl).hostname}`)
- var formatData = utils.formatExchangedCurrency(1.0, "au");
span.text-warning #{formatData.val}
small.ms-1.text-muted #{formatData.unit}
if (networkVolume)
+summaryItem("24hr Volume", `Total output of all transactions over the last 24hrs (blocks: [#${networkVolume.d1.endBlock.toLocaleString()} - #${networkVolume.d1.startBlock.toLocaleString()}]).`)
- var currencyValue = parseInt(networkVolume.d1.amt);
- var currencyValueDecimals = 0;
if (userSettings.displayCurrency == "btc")
+valueDisplaySpecial(networkVolume.d1.amt, 0)
else
+valueDisplay(networkVolume.d1.amt)
.clearfix
.float-start
+sectionTitle("Network Summary")
.float-end
if (userSettings.homepageShowTechDetails == "true")
a.me-2(href="./changeSetting?name=homepageShowTechDetails&value=false", title="Hide technical network details", data-bs-toggle="tooltip", data-bs-placement="bottom")
i.bi-hdd-stack.text-muted
else
a.me-2(href="./changeSetting?name=homepageShowTechDetails&value=true", title="Show technical network details", data-bs-toggle="tooltip", data-bs-placement="bottom")
i.bi-hdd-stack.text-muted
+contentSection
+summaryRow(2 + (halvingSoon ? 1 : 0) + (hashrate7d ? 1 : 0) + (chainTxStats && chainTxStats[7 * targetBlocksPerDay] ? 1 : 0) + (difficultyAdjustmentData ? 1 : 0))
if (hashrate7d)
+summaryItem("7d Hashrate", "The average hashrate of the global mining network over the last 7 days. A comparison to the 30-day average is included to help gauge the rate of change.")
- var hashrate7dayData = utils.formatLargeNumber(hashrate7d, 1);
span.me-1 #{hashrate7dayData[0]}
span.small.text-muted.border-dotted(title=`${hashrate7dayData[1].abbreviation}H = ${hashrate7dayData[1].name}-hash (x10^${hashrate7dayData[1].exponent})` data-bs-toggle='tooltip') #{hashrate7dayData[1].abbreviation}H/s
if (hashrate30d)
- var ratio = hashrate7d / hashrate30d;
span.text-tiny.text-muted.ms-2
| (
span.border-dotted(title='7d hashrate vs 30d hashrate.' data-bs-toggle='tooltip')
if (ratio > 1)
- var ratioPercent = new Decimal(ratio).times(100).minus(100);
span.text-success +#{ratioPercent.toDP(2)}%
else
- var ratioPercent = new Decimal(100).minus(new Decimal(ratio).times(100));
span.text-danger -#{ratioPercent.toDP(2)}%
| )
if (halvingSoon)
if (false)
pre #{JSON.stringify(nextHalvingData)}
+summaryItem("Next Halving", "Details about when the next block subsidy halving will occur", null, null, "icon:bi-square-half", "./next-halving", "View next halving details")
span.border-dotted(title=`${nextHalvingData.blocksUntilNextHalving.toLocaleString()} blocks left, ${halvingProgressPercent.toDP(2)}% complete`, data-bs-toggle="tooltip")
if (nextHalvingData.blocksUntilNextHalving > 10000)
- let halvingBlocksData = utils.formatLargeNumber(nextHalvingData.blocksUntilNextHalving)
| #{parseInt(halvingBlocksData[0])}#{halvingBlocksData[1].abbreviation}
else
| #{nextHalvingData.blocksUntilNextHalving.toLocaleString()}
- var utcMoment = moment.utc(nextHalvingData.nextHalvingDate);
- var titleStr = `${utcMoment.format("Y-MM-DD, HH:mm:ss")} utc`;
- let halvingDt = moment.duration(moment.utc(nextHalvingData.nextHalvingDate).diff(moment.utc(new Date())));
i.text-tiny.bi-box.ms-2
small.text-muted.ms-2
| (
span.border-dotted(title=`${utils.summarizeDuration(halvingDt)} (${new Decimal(halvingDt.asDays()).toDP(3)} d) <br/> ${titleStr}`, data-bs-toggle="tooltip", data-bs-html="true")
+timeAgo(nextHalvingData.nextHalvingDate.getTime() / 1000, {hideHoverText:true, decimalPlaces:3})
| )
.progress.mt-1.mx-lg-6.me-6(style="height: 5px;", role="progressbar", aria-label="Difficulty adjustment progress", aria-valuenow=halvingProgressPercent.toDP(0), aria-valuemin="0" aria-valuemax="100")
.progress-bar(style=`width: ${halvingProgressPercent.toDP(0)}%`)
+summaryItem("Difficulty", null, null, null, "icon:bi-clock-history", "./difficulty-history", "View difficulty history")
- var difficultyData = utils.formatLargeNumber(getblockchaininfo.difficulty, 3);
if (getblockchaininfo.difficulty > 1000)
span.border-dotted(title=parseFloat(getblockchaininfo.difficulty).toLocaleString(), data-bs-toggle="tooltip")
span #{difficultyData[0]}
span x 10
sup #{difficultyData[1].exponent}
else
span #{new Decimal(getblockchaininfo.difficulty).toDP(3)}
if (global.athDifficulty)
span.text-tiny.text-muted.ms-2
| (
- var diffX = getblockchaininfo.difficulty;
if (global.athDifficulty == diffX)
span.border-dotted(title='The current difficulty is an All-Time High!' data-bs-toggle='tooltip')
span.text-success ATH
else
- var diffDrop = new Decimal(global.athDifficulty).minus(diffX).dividedBy(global.athDifficulty).times(100).toDP(2);
span.border-dotted(title=`The current difficulty is ${diffDrop}% lower than the All-Time High.` data-bs-toggle='tooltip')
span.text-danger -#{diffDrop}%
| )
if (chainTxStats && chainTxStats[7 * targetBlocksPerDay])
+summaryItem("7d Transactions", "The total number of transactions that have been confirmed in the blockchain over the last 7 days.")
| #{chainTxStats[7 * targetBlocksPerDay].window_tx_count.toLocaleString()}
if (difficultyAdjustmentData)
- let progressPercent = new Decimal(difficultyAdjustmentData.calculationBlockCount).dividedBy(difficultyAdjustmentData.calculationBlockCount + difficultyAdjustmentData.blocksLeft).times(100);
- var desc = `Estimate for the difficulty adjustment that will occur in ${difficultyAdjustmentData.blocksLeft.toLocaleString()} block${difficultyAdjustmentData.blocksLeft == 1 ? "" : "s"} (${difficultyAdjustmentData.timeLeftStr}). This is calculated using the average block time during the current difficulty epoch (currently, the last ${difficultyAdjustmentData.calculationBlockCount.toLocaleString()} block${difficultyAdjustmentData.calculationBlockCount == 1 ? "" : "s"}). Note: This estimate becomes more reliable as the difficulty epoch nears its end.`;
if (false)
pre
code.json #{JSON.stringify(difficultyAdjustmentData, null, 4)}
+summaryItem("Difficulty Δ", difficultyAdjustmentData.estimateAvailable ? desc : null)
if (difficultyAdjustmentData.estimateAvailable)
span(class=(difficultyAdjustmentData.delta >= 0 ? "text-success" : "text-danger"))
if (difficultyAdjustmentData.sign == "+")
| +
| #{difficultyAdjustmentData.delta.toDP(2)}
small.ms-1 %
span.text-tiny.text-muted.ms-2
| (
span.border-dotted(title=`${difficultyAdjustmentData.blocksLeft.toLocaleString()} block${difficultyAdjustmentData.blocksLeft == 1 ? "" : "s"} / ${progressPercent.toDP(1)}% done`, data-bs-toggle="tooltip") #{difficultyAdjustmentData.timeLeftStr}
| )
.progress.mt-1.mx-lg-6.me-6(style="height: 5px;", role="progressbar", aria-label="Difficulty adjustment progress", aria-valuenow=progressPercent.toDP(0), aria-valuemin="0" aria-valuemax="100")
.progress-bar(style=`width: ${progressPercent.toDP(0)}%`)
else
small.border-dotted.text-muted(title="Estimate pending...<br/>A new difficulty epoch just started. Difficulty adjustment estimates made with too little data can be very unreliable, so are not calculated.", data-bs-toggle="tooltip", data-bs-html="true")
i.bi-hourglass-split
+summaryItem("Coins", utxoSetSummary ? null : (config.slowDeviceMode ? `Because this app is configured to conserve resources (SLOW_DEVICE_MODE=true), this value is estimated, using a checkpoint.` : `This value is estimated, using a checkpoint.`))
- var maxSupply = coinConfig.maxSupplyByNetwork[activeBlockchain];
if (utxoSetSummary)
span #{parseFloat(utxoSetSummary.total_amount).toLocaleString()}
span.text-tiny.ms-2.text-muted
| (
span.border-dotted(title=`${new Decimal(utxoSetSummary.total_amount).dividedBy(maxSupply).times(100).toDP(5)}% have been mined into circulation`, data-bs-toggle="tooltip") #{new Decimal(utxoSetSummary.total_amount).dividedBy(maxSupply).times(100).toDP(2, Decimal.ROUND_DOWN)}%
| )
else
- var estimatedSupply = utils.estimatedSupply(getblockchaininfo.blocks);
span #{parseInt(estimatedSupply).toLocaleString()}
span.text-tiny.ms-2.text-muted
| (
span.border-dotted(title=`${estimatedSupply.dividedBy(maxSupply).times(100).toDP(4)}% have been mined into circulation`, data-bs-toggle="tooltip") #{estimatedSupply.dividedBy(maxSupply).times(100).toDP(1)}%
| )
hr.mt-3.mb-3
- var smartFeeEstimateBlocks = [];
- var smartFeeEstimateStrings = [];
- var smartFeeEstimateTimes = [];
if (smartFeeEstimates)
if (smartFeeEstimates[1])
- smartFeeEstimateBlocks.push(1);
- smartFeeEstimateStrings.push(smartFeeEstimates[1]);
- smartFeeEstimateTimes.push('asap');
if (smartFeeEstimates[6])
- smartFeeEstimateBlocks.push(6);
- smartFeeEstimateStrings.push(smartFeeEstimates[6]);
- smartFeeEstimateTimes.push('hr');
if (smartFeeEstimates[144])
- smartFeeEstimateBlocks.push(144);
- smartFeeEstimateStrings.push(smartFeeEstimates[144]);
- smartFeeEstimateTimes.push('day');
+summaryRow((mempoolInfo == undefined ? 0 : 1) + (smartFeeEstimateStrings.length > 0 ? 1 : 0) + ((mempoolInfo && global.activeBlockchain != "signet") ? 1 : 0))
if (mempoolInfo)
- const thresholds_txCount = {warning: 7000, danger: 11000}
- const colorClass_txCount = (mempoolInfo.size > thresholds_txCount.danger) ? "text-danger" : (mempoolInfo.size > thresholds_txCount.warning ? "text-warning" : "text-success")
- const blockCount = new Decimal(mempoolInfo.bytes).dividedBy(coinConfig.maxBlockSize)
- const thresholds_blockCount = {warning: 10, danger: 20}
- const colorClass_blockCount = (blockCount > thresholds_blockCount.danger) ? "text-danger" : (blockCount > thresholds_blockCount.warning ? "text-warning" : "text-success");
- const thresholds_totalFees = {warning: 1, danger: 5}
- const colorClass_totalFees = (mempoolInfo.total_fee > thresholds_totalFees.danger) ? "text-danger" : (mempoolInfo.total_fee > thresholds_totalFees.warning ? "text-warning" : "text-success");
+summaryItem("Mempool", "The number of unconfirmed transactions in your node's mempool, and the number of blocks needed to confirm those transactions", null, null, "icon:bi-hourglass-split", "./mempool-summary", "View mempool summary details")
span.border-dotted(title=`<b># Unconfirmed Transactions</b><br/><span class='text-success'>Low (N ≤ ${thresholds_txCount.warning.toLocaleString()})</span><br/><span class='text-warning'>High (${thresholds_txCount.warning.toLocaleString()} < N ≤ ${thresholds_txCount.danger.toLocaleString()})</span><br/><span class='text-danger'>Very High (N > ${thresholds_txCount.danger.toLocaleString()})</span>`, data-bs-toggle="tooltip", data-bs-html="true")
span(class=colorClass_txCount) #{mempoolInfo.size.toLocaleString()}
span.text-tiny.text-muted.ms-1 tx
span.mx-2.text-muted /
span.small
span.border-dotted(title=`<b># Blocks to clear this node's mempool</b><br/><span class='text-success'>Low (N ≤ ${thresholds_blockCount.warning.toLocaleString()})</span><br/><span class='text-warning'>High (${thresholds_blockCount.warning.toLocaleString()} < N ≤ ${thresholds_blockCount.danger.toLocaleString()})</span><br/><span class='text-danger'>Very High (N > ${thresholds_blockCount.danger.toLocaleString()})</span>`, data-bs-toggle="tooltip", data-bs-html="true")
span(class=colorClass_blockCount) #{blockCount.toDP(2)}
span.text-tiny.text-muted.ms-1
i.bi-box
span.mx-2.text-muted /
span.small
-
// Code inspired from shared-mixins.pug and adapted for inclusion in a tooltip
const formatFees = (inputVal) => {
const displayCurrency = userSettings.displayCurrency == "local" ? userSettings.localCurrency : userSettings.displayCurrency;
const parts = utils.formatCurrencyAmount(inputVal, displayCurrency)
const currencyType = currencyTypes[parts.currencyUnit.toLowerCase()]
let val = parts.val
if (currencyType.type == "exchanged") {
// Remove any decimals
val = val.split('.')[0]
// Currency symbol followed by amount with a non-breaking space in-between
// so that the two elements remain on the same line
return `${currencyType.symbol} ${val}`
}
if (parts.currencyUnit == "sat") {
// Add K, M, G, ... suffix to amount
const largeNumberData = utils.formatLargeNumberSignificant(parts.intVal, 3);
val = `${largeNumberData[0]}${largeNumberData[1].abbreviation}`
}
// Amount followed by minimized currency name (BTC or sat) with a non-breaking space in-between
return `${val} <span class='text-tiny'>${currencyType.name}</span>`
}
- const warningFees = formatFees(thresholds_totalFees.warning)
- const dangerFees = formatFees(thresholds_totalFees.danger)
span.border-dotted(title=`<b>Unconfirmed Transactions' total fees</b><br/><span class='text-success'>Low (N ≤ ${warningFees})</span><br/><span class='text-warning'>High (${warningFees} < N ≤ ${dangerFees})</span><br/><span class='text-danger'>Very High (N > ${dangerFees})</span>`, data-bs-toggle="tooltip", data-bs-html="true") Σ
// Don't embed this span inside previous one to avoid collision of their tooltips
span.ms-1(class=colorClass_totalFees)
+valueDisplay(mempoolInfo.total_fee, {hideLessSignificantDigits:true})
if (mempoolInfo && global.activeBlockchain != "signet")
+summaryRow
+summaryItem("Next Block", "A prediction for what transactions will be included in the next block, yet to be mined. Built from \"getblocktemplate\".", null, null, "icon:bi-minecart-loaded", "./next-block", "View next block details")
#index-next-block
.text-center.text-reset.pb-4
.mt-2
.spinner-border.spinner-border-sm
if (false)
+summaryItem("Next Block (est.)")
| #{new Decimal(nextBlockMinFeeRate).toDP(0)}
a(href=`./tx/${nextBlockMinFeeTxid}`)
i.bi-circle
| - #{new Decimal(nextBlockMaxFeeRate).toDP(0)}
a(href=`./tx/${nextBlockMaxFeeTxid}`)
i.bi-circle
small.ms-2.text-muted sat/vB
if (smartFeeEstimateStrings.length > 0)
+summaryItem(`Smart Fees`, `The recommended fee rate to target confirmation in ${smartFeeEstimateBlocks.join(", ")} blocks`, "sat/vB")
each x, xIndex in smartFeeEstimateStrings
if (xIndex > 0)
span.mx-2.text-muted /
| #{x}
span.text-tiny.text-muted.ms-1 (#{smartFeeEstimateTimes[xIndex]})
if (userSettings.homepageShowTechDetails == "true")
hr.mt-3.mb-3
+summaryRow(1 + (getblockchaininfo.size_on_disk ? 1 : 0) + (utxoSetSummary || utxoSetSummaryPending ? 1 : 0))
if (getblockchaininfo.size_on_disk)
+summaryItem("Disk Usage")
- var sizeData = utils.formatLargeNumber(getblockchaininfo.size_on_disk, 1);
| #{sizeData[0]} #{sizeData[1].abbreviation}B
+summaryItem("Total Hashes", "Estimate of the total work necessary to produce the blockchain, measured in 'hashes'.")
- var chainworkData = utils.formatLargeNumber(parseInt("0x" + getblockchaininfo.chainwork), 2);
span #{chainworkData[0]}
small.px-2.px-lg-0.px-xl-2 x
span 10
sup #{chainworkData[1].exponent}
if (utxoSetSummary || utxoSetSummaryPending)
+summaryItem("UTXOs", "The total number of unspent transaction outputs (spendable coin units).")
if (utxoSetSummary)
- var utxoCount = utils.formatLargeNumber(utxoSetSummary.txouts, 2);
//| #{utxoCount[0]} #{utxoCount[1].abbreviation}
| #{utxoSetSummary.txouts.toLocaleString()}
else
small.text-muted.border-dotted(title=utxoCalculatingDesc, data-bs-toggle="tooltip") calculating...