From 96071af0edfb565428c8fc4e133071db6b749b89 Mon Sep 17 00:00:00 2001 From: cubedro Date: Sat, 4 Apr 2015 15:45:08 +0300 Subject: [PATCH 1/6] increased verbosity for geth --- bin/eth.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/eth.sh b/bin/eth.sh index 3d45594..4a2a35b 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -2,7 +2,7 @@ trap "exit" INT if [[ -f /usr/bin/geth ]]; then - geth -rpc -rpcport "8080" -maxpeers "20" -loglevel "3" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" + geth -rpc -rpcport "8080" -maxpeers "20" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" else eth -b -x 20 -r 52.16.188.185 -p 30303 -m off -v 4 -j fi \ No newline at end of file From c4616b497e444a19d59d6d8bc584240f1ca2f0b9 Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 5 Apr 2015 16:04:24 +0300 Subject: [PATCH 2/6] increased maxpeers to 50 --- README.md | 1 - bin/build.sh | 3 ++- bin/eth.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e13600..aff3276 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ Configure the app modifying [processes.json](/eth-net-intelligence-api/blob/mast "NODE_ENV" : "production", // tell the client we're in production environment "RPC_HOST" : "localhost", // eth JSON-RPC host "RPC_PORT" : "8080", // eth JSON-RPC port - "ETH_IMPLEMENTATION" : "cpp", // eth implementation: "cpp" or "go" "INSTANCE_NAME" : "", "WS_SERVER" : "", // path to eth-netstats WebSockets api server "WS_SECRET" : "", // WebSockets api server secret used for login diff --git a/bin/build.sh b/bin/build.sh index 2dc3c05..1739962 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -22,6 +22,7 @@ cd ~ # update packages sudo apt-get update -y sudo apt-get upgrade -y +sudo apt-get install -y software-properties-common # add ethereum repos sudo add-apt-repository -y ppa:ethereum/ethereum @@ -29,7 +30,7 @@ sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get update -y # install ethereum & install dependencies -sudo apt-get install -y software-properties-common build-essential git unzip wget nodejs npm ntp cloud-utils $ethtype +sudo apt-get install -y build-essential git unzip wget nodejs npm ntp cloud-utils $ethtype # add node symlink if it doesn't exist [[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node diff --git a/bin/eth.sh b/bin/eth.sh index 4a2a35b..3ae8420 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -2,7 +2,7 @@ trap "exit" INT if [[ -f /usr/bin/geth ]]; then - geth -rpc -rpcport "8080" -maxpeers "20" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" + geth -rpc -rpcport "8080" -maxpeers "50" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" else - eth -b -x 20 -r 52.16.188.185 -p 30303 -m off -v 4 -j + eth -b -x 50 -r 52.16.188.185 -p 30303 -m off -v 4 -j fi \ No newline at end of file From fac7978a4c43372ec68fae1a9cdf7fa8310ebbfc Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 5 Apr 2015 16:20:45 +0300 Subject: [PATCH 3/6] added external ip flag --- bin/eth.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/eth.sh b/bin/eth.sh index 3ae8420..11eea28 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -1,8 +1,9 @@ #!/bin/bash +IP=$(ec2metadata --public-ipv4) trap "exit" INT if [[ -f /usr/bin/geth ]]; then - geth -rpc -rpcport "8080" -maxpeers "50" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" + geth -rpc -rpcport "8080" -maxpeers "50" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" -nat "extip:$IP" else - eth -b -x 50 -r 52.16.188.185 -p 30303 -m off -v 4 -j + eth -b -x 50 -r 52.16.188.185 -p 30303 -m off -v 4 -j -u $IP fi \ No newline at end of file From 4cc7d88235a8beb9eaefc714ad3bde80998259d3 Mon Sep 17 00:00:00 2001 From: cubedro Date: Sun, 5 Apr 2015 21:29:34 +0300 Subject: [PATCH 4/6] changed reconnect strategy --- lib/node.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index c65f2e9..446101b 100644 --- a/lib/node.js +++ b/lib/node.js @@ -20,6 +20,7 @@ Socket = Primus.createSocket({ transformer: 'websockets', pathname: '/api', timeout: 10000, + strategy: 'disconnect,online', plugin: {emitter: Emitter, sparkLatency: Latency} }); @@ -238,7 +239,7 @@ Node.prototype.getLatestBlocks = function() Node.prototype.addBlockHistory = function(block) { - if(this.blocks.length === 0 || block.number !== this.blocks[0].number) + if(this.blocks.length === 0 || (block !== null && block.number !== this.blocks[0].number)) { if(this.blocks.length === MAX_BLOCKS_HISTORY) { From 7f2f722d5dc2b461954ad70368c49df1c602e42f Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 02:20:14 +0300 Subject: [PATCH 5/6] added miners chart --- lib/node.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/node.js b/lib/node.js index 446101b..c3ca9fa 100644 --- a/lib/node.js +++ b/lib/node.js @@ -76,6 +76,7 @@ function Node() txDensity: [], blockTimes: [], gasSpending: [], + miners: [], uptime: 0, errors: [] }; @@ -235,6 +236,7 @@ Node.prototype.getLatestBlocks = function() this.stats.difficulty = this.difficultyChart(); this.stats.txDensity = this.txDensityChart(); this.stats.gasSpending = this.gasSpendingChart(); + this.stats.miners = this.minersChart(); } Node.prototype.addBlockHistory = function(block) @@ -297,6 +299,22 @@ Node.prototype.gasSpendingChart = function() }); } +Node.prototype.minersChart = function() +{ + var miners = _.countBy(this.blocks, function(block) + { + return block.miner; + }); + + var minersArray = []; + + _.forEach(miners, function(cnt, miner) { + minersArray.push({miner: miner, blocks: cnt}); + }); + + return _.sortBy(minersArray, 'blocks').reverse(); +} + Node.prototype.uptime = function() { this.stats.uptime = ((this._tries - this._down) / this._tries) * 100; From a81bee9502bcf7743ccf0d0c84325ca2b295ed17 Mon Sep 17 00:00:00 2001 From: cubedro Date: Mon, 6 Apr 2015 02:26:43 +0300 Subject: [PATCH 6/6] added miner result limit --- lib/node.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index c3ca9fa..1ca91ec 100644 --- a/lib/node.js +++ b/lib/node.js @@ -36,6 +36,7 @@ var PENDING_WORKS = true; var MAX_BLOCKS_HISTORY = 36; var UPDATE_INTERVAL = 5000; var PING_INTERVAL = 2000; +var MINERS_LIMIT = 5; function Node() { @@ -312,7 +313,9 @@ Node.prototype.minersChart = function() minersArray.push({miner: miner, blocks: cnt}); }); - return _.sortBy(minersArray, 'blocks').reverse(); + var minersArray = _.sortBy(minersArray, 'blocks').reverse(); + + return minersArray.slice(0, MINERS_LIMIT); } Node.prototype.uptime = function()