Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shardus/monitor-client

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shardus/monitor-client - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

111

large-network.js
;(function main() {
const url = new URL(window.location.href)
// const monitorServerUrl = 'http://52.201.247.225:3000/api'
// const monitorServerUrl = 'http://208.110.82.50:3000/api'
const monitorServerUrl = window.origin + '/api'

@@ -18,3 +18,3 @@ console.log('Monitor server', monitorServerUrl)

syncing: {},
active: {}
active: {},
}

@@ -42,7 +42,7 @@ let n = 0

load: 0,
maxLoad: 0
maxLoad: 0,
},
colorMode: 'state',
shouldShowMaxTps: false,
shouldShowMaxLoad: false
shouldShowMaxLoad: false,
}

@@ -74,3 +74,3 @@ },

y,
degree: angle * n
degree: angle * n,
}

@@ -94,3 +94,3 @@ },

y,
degree: angle
degree: angle,
}

@@ -115,3 +115,3 @@ },

title: this.getTitle(nodeId, node),
color: this.getNodeColor(node)
color: this.getNodeColor(node),
}

@@ -124,6 +124,6 @@ },

x: 0,
y: 0 - 130 + (index * 20),
y: 0 - 130 + index * 20,
physics: false,
title: archiver.publicKey,
color: "#abc2ec"
color: '#abc2ec',
}

@@ -137,3 +137,3 @@ })

title: this.getTitle(nodeId, node),
color: this.getNodeColor(node)
color: this.getNodeColor(node),
}

@@ -172,3 +172,4 @@ },

if (Object.keys(report.nodes.active).length === 0) return // don't update stats if no nodes send the
let reportPercentage = Object.keys(report.nodes.active).length / Object.keys(G.nodes.active).length
let reportPercentage =
Object.keys(report.nodes.active).length / Object.keys(G.nodes.active).length
console.log('reportPercentage', reportPercentage)

@@ -211,3 +212,3 @@ if (reportPercentage < 0.3) return // don't update stats if less than 30% of network updates

if (!activeNode) continue
removedNodeIds.push({id: nodeId})
removedNodeIds.push({ id: nodeId })
delete G.nodes.active[nodeId]

@@ -234,3 +235,3 @@ }

if (!activeNode) continue
removedNodeIds.push({id: nodeId})
removedNodeIds.push({ id: nodeId })
delete G.nodes.active[nodeId]

@@ -258,4 +259,8 @@ }

for (let nodeId in G.nodes.syncing) {
const {externalIp, externalPort} = G.nodes.syncing[nodeId].nodeIpInfo
if (newNode.nodeIpInfo.externalIp === externalIp && newNode.nodeIpInfo.externalPort === externalPort && newNode.nodeId !== nodeId) {
const { externalIp, externalPort } = G.nodes.syncing[nodeId].nodeIpInfo
if (
newNode.nodeIpInfo.externalIp === externalIp &&
newNode.nodeIpInfo.externalPort === externalPort &&
newNode.nodeId !== nodeId
) {
console.log('Found crashed syncing node by ip:port')

@@ -269,3 +274,7 @@ return G.nodes.syncing[nodeId]

let changes = await this.fetchChanges()
console.log(`Total of ${Object.keys(changes.nodes.active).length}/${Object.keys(G.nodes.active).length} nodes updated.`)
console.log(
`Total of ${Object.keys(changes.nodes.active).length}/${
Object.keys(G.nodes.active).length
} nodes updated.`
)
this.updateNetworkStatus(changes)

@@ -365,8 +374,8 @@ let updatedNodes = []

// size: 2,
size: nodeSize
size: nodeSize,
},
interaction: {
zoomSpeed: 0.1,
zoomView: true
}
zoomView: true,
},
}

@@ -405,10 +414,16 @@ G.network.setOptions(options)

mode(arr) {
return arr.reduce(function (current, num) {
const freq = (num in current.numMap) ? ++current.numMap[num] : (current.numMap[num] = 1)
if (freq > current.modeFreq && freq > 1) {
current.modeFreq = freq
current.mode = num
}
return current
}, {mode: null, modeFreq: 0, numMap: {}}).mode
return arr.reduce(
function (current, num) {
const freq =
num in current.numMap
? ++current.numMap[num]
: (current.numMap[num] = 1)
if (freq > current.modeFreq && freq > 1) {
current.modeFreq = freq
current.mode = num
}
return current
},
{ mode: null, modeFreq: 0, numMap: {} }
).mode
},

@@ -418,3 +433,5 @@ async getRandomArchiver() {

const randomConsensorNode = Object.values(G.nodes.active)[0]
let res = await axios.get(`http://${randomConsensorNode.nodeIpInfo.externalIp}:${randomConsensorNode.nodeIpInfo.externalPort}/sync-newest-cycle`)
let res = await axios.get(
`http://${randomConsensorNode.nodeIpInfo.externalIp}:${randomConsensorNode.nodeIpInfo.externalPort}/sync-newest-cycle`
)
let cycle = res.data.newestCycle

@@ -427,3 +444,5 @@ if (cycle.refreshedArchivers && cycle.refreshedArchivers.length > 0) {

if (!G.archiver) await this.getRandomArchiver()
const res = await axios.get(`http://${G.archiver.ip}:${G.archiver.port}/archiverlist`)
const res = await axios.get(
`http://${G.archiver.ip}:${G.archiver.port}/archiverlist`
)
if (res.data.archivers && res.data.archivers.length > 0) {

@@ -441,3 +460,3 @@ return res.data.archivers

let archiverData = {
nodes: G.archiverData
nodes: G.archiverData,
}

@@ -450,4 +469,4 @@ const options = {

size: 12,
face: 'Arial'
}
face: 'Arial',
},
},

@@ -457,4 +476,4 @@ interaction: {

hover: false,
zoomView: false
}
zoomView: false,
},
}

@@ -464,7 +483,5 @@ G.archiverNetwork = new vis.Network(archiverContainer, archiverData, options)

const publicKey = params.nodes[0]
const archiver = G.archivers.find(a => a.publicKey === publicKey)
const archiver = G.archivers.find((a) => a.publicKey === publicKey)
if (!archiver) return
window.open(
`http://${archiver.ip}:${archiver.port}/nodeinfo`
)
window.open(`http://${archiver.ip}:${archiver.port}/nodeinfo`)
})

@@ -482,3 +499,5 @@ } catch (e) {

if (G.nodes.syncing[nodeId]) {
console.log('Found this active node in syncing list. Removing it from syncing list.')
console.log(
'Found this active node in syncing list. Removing it from syncing list.'
)
delete G.nodes.syncing[nodeId]

@@ -505,3 +524,3 @@ }

let data = {
nodes: G.data
nodes: G.data,
}

@@ -514,9 +533,9 @@ const options = {

size: 12,
face: 'Arial'
}
face: 'Arial',
},
},
interaction: {
zoomSpeed: 0.1,
zoomView: true
}
zoomView: true,
},
}

@@ -537,5 +556,5 @@

setInterval(this.updateNodes, 10000)
}
}
},
},
})
})()
{
"name": "@shardus/monitor-client",
"version": "2.1.0",
"version": "2.1.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "app.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc