Skip to content

Commit

Permalink
refactor to support p2p sockets, bump to version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roks0n committed May 12, 2019
1 parent fd620f7 commit c344997
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 208 deletions.
9 changes: 6 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ const report = (crawler) => {
const blockStats = {}
const versionStats = {}

for (const item of crawler.heights) {
const nodes = Object.values(crawler.nodes)

for (const item of nodes) {
if (blockStats[item.height]) {
blockStats[item.height].count += 1
blockStats[item.height].ids[item.id] += 1
} else {
blockStats[item.height] = {}
blockStats[item.height].count = 1
blockStats[item.height].height = item.height
// todo block ids
blockStats[item.height].ids = {}
blockStats[item.height].ids[item.id] = 1
}
Expand All @@ -31,7 +34,7 @@ const report = (crawler) => {
}
}

const allDelays = crawler.heights.filter(item => item.delay).map(item => item.delay)
const allDelays = nodes.filter(item => item.latency).map(item => item.latency)
const averageDelay = allDelays.reduce((a, b) => a + b, 0) / allDelays.length
const maxDelay = Math.max(...allDelays)
const minDelay = Math.min(...allDelays)
Expand Down Expand Up @@ -78,4 +81,4 @@ if (args.length === 1) {
node.port = url.port
}

crawler.run(node).then(report)
crawler.run(node).then(report).catch(err => console.error(err))
123 changes: 93 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Crawler",
"version": "1.0.0",
"version": "1.1.0",
"description": "Crawler scans the ARK network to get information about the peers in the network.",
"main": "app.js",
"scripts": {
Expand All @@ -14,9 +14,14 @@
"engines": {
"node": "^8.11.2"
},
"keywords": [],
"author": "A(rk)-Team",
"license": "Apache-2.0",
"keywords": [
"ark acosystem",
"network",
"scanner",
"blockchain"
],
"author": "roks0n",
"license": "MIT",
"homepage": "https://github.com/deadlock-delegate/crawler#readme",
"devDependencies": {
"eslint": "^5.16.0",
Expand All @@ -27,7 +32,7 @@
"eslint-plugin-standard": "^4.0.0"
},
"dependencies": {
"axios": "^0.18.0",
"lodash": "^4.17.11"
"lodash": "^4.17.11",
"socketcluster-client": "^14.2.2"
}
}
Loading

0 comments on commit c344997

Please sign in to comment.