Skip to content
Snippets Groups Projects
Commit 0a7fe822 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[add] network: heads: explicitely show prefered/privileged nodes we don't have HEAD information yet

parent 14187c2d
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@
module.exports = ($scope, Webmin, heads, info, conf, ws) => {
const SPECIFIC_SUFFIX = '--------'
const UNKNOWN_VALUE = '-'
$scope.discriminateNodes = (info) => {
info.connections.level1.concat(info.connections.level2).forEach(c => {
c.prefered = (conf.preferedNodes || []).indexOf(c.pubkey) !== -1
......@@ -15,6 +17,34 @@ module.exports = ($scope, Webmin, heads, info, conf, ws) => {
const headsMap = {}
$scope.removeBlanks = (confPrefPriv, headsMap) => {
for (const pp of confPrefPriv) {
const ws2pFullId = pp + '-' + SPECIFIC_SUFFIX
if (headsMap[ws2pFullId]) {
delete headsMap[ws2pFullId]
}
}
}
$scope.addBlanks = (confPrefPriv, headsMap) => {
const pubkeys = Object.keys(headsMap).map(k => k.split('-')[0])
const unknown = confPrefPriv.filter(pub => !pubkeys.includes(pub))
for (const pp of unknown) {
const ws2pFullId = pp + '-' + SPECIFIC_SUFFIX
headsMap[ws2pFullId] = {
api: UNKNOWN_VALUE,
blockstamp: UNKNOWN_VALUE,
uid: UNKNOWN_VALUE,
ws2pId: UNKNOWN_VALUE,
software: UNKNOWN_VALUE,
softVersion: UNKNOWN_VALUE,
prefix: UNKNOWN_VALUE,
freeRooms: UNKNOWN_VALUE,
step: UNKNOWN_VALUE
}
}
}
$scope.headsIntoMap = (heads) => {
for (const value of heads) {
const sp = value.message.split(':')
......@@ -48,6 +78,11 @@ module.exports = ($scope, Webmin, heads, info, conf, ws) => {
api, blockstamp, uid, ws2pId, software, softVersion, prefix, freeRooms, step
}
}
const confPreferedPrivileged = conf.preferedNodes.concat(conf.privilegedNodes)
$scope.removeBlanks(confPreferedPrivileged, headsMap)
$scope.addBlanks(confPreferedPrivileged, headsMap)
$scope.heads = Object.keys(headsMap).map(k => {
const pubkey = k.split('-')[0]
return {
......
......@@ -413,7 +413,7 @@ blockquote.info
}
.legend span {
width: 500px;
width: 100%;
display: block;
margin-bottom: 4px;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment