btc-rpc-explorer/views/peers.pug
Dan Janosik a678c8a6a9
-more styling tweaks/cleanup/consistency
-new fun item showing example of future-dated timelock (coinbase) tx
-special-case code for mainnet genesis coinbase tx, to avoid indicating that satoshi spent these unspendable coins
-tx details: skip displaying locktime when it's meaningless (the raw data is in the json if anyone wants it); show additional info about locktime meaning
-tx details: show byte-size in addition to vByte size, if applicable
-fix for recently broken donut chart on /mining-summary
-changelog
2021-12-06 16:43:10 -05:00

241 lines
8.4 KiB
Text

extends layout
block headContent
title Peers
link(rel="stylesheet", href="./style/dataTables.bootstrap4.min.css", integrity="sha384-EkHEUZ6lErauT712zSr0DZ2uuCmi3DoQj6ecNdHQXpMpFNGAQ48WjfXCE5n20W+R")
link(rel="stylesheet", href="./leaflet/leaflet.css", integrity="sha384-6wKUKNzA6h/S6gZ1lWQppeGaVXvK1AUAsEznGBghzlEu1fNcxJGYVRiroSHr+OwU")
script(src="./leaflet/leaflet.js", integrity="sha384-RFZC58YeKApoNsIbBxf4z6JJXmh+geBSgkCQXFyh+4tiFSJmJBt+2FbjxW7Ar16M")
style.
.versions-hidden-rows, .services-hidden-rows {
display: none;
}
#map { height: 700px; }
block content
+pageTitle(`${peerSummary.getpeerinfo.length} Peer${peerSummary.getpeerinfo.length == 1 ? "" : "s"}`)
+pageTabs(["Details", "JSON"])
.tab-content
+pageTab("Details", true)
if (peerIpSummary && peerIpSummary.ips)
.mb-3(id="map")
.row
.col-md-6
+contentSection("Top Versions")
table.table.table-borderless.table-striped.table-responsive-sm
thead
tr
th
th.text-card-highlight.text-uppercase.fw-light Version
th.text-end.text-card-highlight.text-uppercase.fw-light Count
tbody
each item, index in peerSummary.versionSummary
tr(class=(index >= 5 ? "versions-hidden-rows" : false))
td.small.text-muted #{index + 1}
td #{item[0]}
td.text-end #{item[1].toLocaleString()}
.col-md-6
+contentSection("Top Service Flags")
table.table.table-borderless.table-striped.table-responsive-sm
thead
tr
th
th.text-card-highlight.text-uppercase.fw-light Services
th.text-end.text-card-highlight.text-uppercase.fw-light Count
tbody
each item, index in peerSummary.servicesSummary
tr(class=(index >= 5 ? "services-hidden-rows" : false))
td.small.text-muted #{index + 1}
td
if (!peerSummary.serviceNamesAvailable)
| 0x
| #{item[0].replace(/^0+/, '')}
td.text-end #{item[1].toLocaleString()}
.row
if (peerSummary.networkTypeSummary)
.col-md-6
+contentSection("Network Types")
table.table.table-borderless.table-striped.table-responsive-sm
thead
tr
th
th.text-card-highlight.text-uppercase.fw-light Network Type
th.text-end.text-card-highlight.text-uppercase.fw-light Count
tbody
each item, index in peerSummary.networkTypeSummary
tr
td.small.text-muted #{index + 1}
td #{item[0]}
td.text-end #{item[1].toLocaleString()}
if (peerSummary.connectionTypeSummary)
.col-md-6
+contentSection("Connection Types")
table.table.table-borderless.table-striped.table-responsive-sm
thead
tr
th
th.text-card-highlight.text-uppercase.fw-light Connection Type
th.text-end.text-card-highlight.text-uppercase.fw-light Count
tbody
each item, index in peerSummary.connectionTypeSummary
tr
td.small.text-muted #{index + 1}
td #{item[0]}
td.text-end #{item[1].toLocaleString()}
+contentSection(`${peerSummary.getpeerinfo.length.toLocaleString()} Peer${peerSummary.getpeerinfo.length == 1 ? "" : "s"}`)
table.table.table-borderless.table-striped.table-responsive-sm.data-table.mt-4
thead
tr
th
th.text-card-highlight.text-uppercase.fw-light Version
th.text-card-highlight.text-uppercase.fw-light Address
th.text-card-highlight.text-uppercase.fw-light Services
th.text-card-highlight.text-uppercase.fw-light Conn. Type
if (peerIpSummary && peerIpSummary.ips)
th.text-card-highlight.text-uppercase.fw-light Location
th.text-card-highlight.text-uppercase.fw-light Last Send / Receive
tbody
each item, index in peerSummary.getpeerinfo
- var lastSendAgo = moment.duration(moment.utc(new Date()).diff(moment.utc(new Date(parseInt(item.lastsend) * 1000)))).format().replace("milliseconds", "ms");
- var lastRecvAgo = moment.duration(moment.utc(new Date()).diff(moment.utc(new Date(parseInt(item.lastrecv) * 1000)))).format().replace("milliseconds", "ms");
tr
td.small.text-muted #{index + 1}
td #{item.subver}
td
if (item.addr.length > 20)
span.border-dotted(title=item.addr, data-bs-toggle="tooltip")
| #{utils.ellipsizeMiddle(item.addr, 21)}
else
| #{item.addr}
td
if (item.servicesnames)
- var serviceItems = item.servicesnames;
- var abbreviations = {"NETWORK":"NET", "NETWORK_LIMITED":"NET_LIM", "WITNESS":"WIT", "BLOOM":"BLM"};
each itemAbbr, itemName in abbreviations
if (item.servicesnames.includes(itemName))
span(title=itemName, data-bs-toggle="tooltip")
+darkBadge(itemAbbr)
//| #{item.servicesnames}
else
| 0x#{item.services.replace(/^0+/, '')}
td #{item.connection_type}
if (peerIpSummary.ips)
td
- var ipAddr = item.addr.substring(0, item.addr.lastIndexOf(":"));
if (peerIpSummary.ips && peerIpSummary.ips.includes(ipAddr))
- var ipDetails = peerIpSummary.detailsByIp[ipAddr];
if (ipDetails)
if (ipDetails.city)
span #{ipDetails.city},
if (ipDetails.region_name)
span #{ipDetails.region_name},
if (ipDetails.country_name)
span #{ipDetails.country_name}
else
span ?
- var ipAddr = null;
td #{lastSendAgo} / #{lastRecvAgo}
+pageTab("JSON")
each item, index in peerSummary.getpeerinfo
div.border-bottom.p-1
a.me-2(href="javascript:void(0)" onclick=`$("#peerinfo_${index}").toggle(); $(this).find(".toggle-buttons").toggle();`)
i.far.fa-plus-square.text-muted.toggle-buttons
i.far.fa-minus-square.text-muted.toggle-buttons(style="display: none;")
span #{item.addr}
.p-3(style="display: none;", id=`peerinfo_${index}`)
+contentSection("Peer Details")
pre
code.json #{JSON.stringify(item, null, 4)}
if (peerIpSummary && peerIpSummary.detailsByIp && peerIpSummary.detailsByIp[item.addr.substring(0, item.addr.lastIndexOf(":"))])
+contentSection("Location Info")
pre
code.json #{JSON.stringify(peerIpSummary.detailsByIp[item.addr.substring(0, item.addr.lastIndexOf(":"))], null, 4)}
block endOfBody
script(src="./js/jquery.dataTables.min.js", integrity="sha384-rgWRqC0OFPisxlUvl332tiM/qmaNxnlY46eksSZD84t+s2vZlqGeHrncwIRX7CGp")
script(src="./js/dataTables.bootstrap4.min.js", integrity="sha384-uiSTMvD1kcI19sAHJDVf68medP9HA2E2PzGis9Efmfsdb8p9+mvbQNgFhzii1MEX")
script.
$(document).ready(function() {
$(".data-table").DataTable();
});
if (peerIpSummary && peerIpSummary.ips && (mapBoxComApiAccessKey != undefined))
script.
var mymap = L.map('map').setView([21.505, -0.09], 3);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=!{mapBoxComApiAccessKey}', {
maxZoom: 18,
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> ' +
'© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> ' +
'<strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong> ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox/streets-v11'
}).addTo(mymap);
/*L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);*/
$(document).ready(function() {
window.dispatchEvent(new Event('resize'));
});
each ipAddress, index in peerIpSummary.ips
- var ipDetails = peerIpSummary.detailsByIp[ipAddress];
if (ipDetails && ipDetails.latitude && ipDetails.longitude)
- var ipDetailsPopupHtml = "<b>" + ipAddress + "</b><br>";
if (ipDetails.city)
- var ipDetailsPopupHtml = ipDetailsPopupHtml + ipDetails.city + ", ";
if (ipDetails.region_name)
- var ipDetailsPopupHtml = ipDetailsPopupHtml + ipDetails.region_name + ", ";
if (ipDetails.country_name)
- var ipDetailsPopupHtml = ipDetailsPopupHtml + ipDetails.country_name + " ";
script L.marker([#{ipDetails.latitude}, #{ipDetails.longitude}]).addTo(mymap).bindPopup("!{ipDetailsPopupHtml}");