commit
e773225329
@ -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
|
"NODE_ENV" : "production", // tell the client we're in production environment
|
||||||
"RPC_HOST" : "localhost", // eth JSON-RPC host
|
"RPC_HOST" : "localhost", // eth JSON-RPC host
|
||||||
"RPC_PORT" : "8080", // eth JSON-RPC port
|
"RPC_PORT" : "8080", // eth JSON-RPC port
|
||||||
"ETH_IMPLEMENTATION" : "cpp", // eth implementation: "cpp" or "go"
|
|
||||||
"INSTANCE_NAME" : "",
|
"INSTANCE_NAME" : "",
|
||||||
"WS_SERVER" : "", // path to eth-netstats WebSockets api server
|
"WS_SERVER" : "", // path to eth-netstats WebSockets api server
|
||||||
"WS_SECRET" : "", // WebSockets api server secret used for login
|
"WS_SECRET" : "", // WebSockets api server secret used for login
|
||||||
|
@ -22,6 +22,7 @@ cd ~
|
|||||||
# update packages
|
# update packages
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get upgrade -y
|
sudo apt-get upgrade -y
|
||||||
|
sudo apt-get install -y software-properties-common
|
||||||
|
|
||||||
# add ethereum repos
|
# add ethereum repos
|
||||||
sudo add-apt-repository -y ppa:ethereum/ethereum
|
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
|
sudo apt-get update -y
|
||||||
|
|
||||||
# install ethereum & install dependencies
|
# 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
|
# add node symlink if it doesn't exist
|
||||||
[[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node
|
[[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
IP=$(ec2metadata --public-ipv4)
|
||||||
trap "exit" INT
|
trap "exit" INT
|
||||||
if [[ -f /usr/bin/geth ]];
|
if [[ -f /usr/bin/geth ]];
|
||||||
then
|
then
|
||||||
geth -rpc -rpcport "8080" -maxpeers "20" -loglevel "3" -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
|
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 -u $IP
|
||||||
fi
|
fi
|
24
lib/node.js
24
lib/node.js
@ -20,6 +20,7 @@ Socket = Primus.createSocket({
|
|||||||
transformer: 'websockets',
|
transformer: 'websockets',
|
||||||
pathname: '/api',
|
pathname: '/api',
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
|
strategy: 'disconnect,online',
|
||||||
plugin: {emitter: Emitter, sparkLatency: Latency}
|
plugin: {emitter: Emitter, sparkLatency: Latency}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ var PENDING_WORKS = true;
|
|||||||
var MAX_BLOCKS_HISTORY = 36;
|
var MAX_BLOCKS_HISTORY = 36;
|
||||||
var UPDATE_INTERVAL = 5000;
|
var UPDATE_INTERVAL = 5000;
|
||||||
var PING_INTERVAL = 2000;
|
var PING_INTERVAL = 2000;
|
||||||
|
var MINERS_LIMIT = 5;
|
||||||
|
|
||||||
function Node()
|
function Node()
|
||||||
{
|
{
|
||||||
@ -75,6 +77,7 @@ function Node()
|
|||||||
txDensity: [],
|
txDensity: [],
|
||||||
blockTimes: [],
|
blockTimes: [],
|
||||||
gasSpending: [],
|
gasSpending: [],
|
||||||
|
miners: [],
|
||||||
uptime: 0,
|
uptime: 0,
|
||||||
errors: []
|
errors: []
|
||||||
};
|
};
|
||||||
@ -234,11 +237,12 @@ Node.prototype.getLatestBlocks = function()
|
|||||||
this.stats.difficulty = this.difficultyChart();
|
this.stats.difficulty = this.difficultyChart();
|
||||||
this.stats.txDensity = this.txDensityChart();
|
this.stats.txDensity = this.txDensityChart();
|
||||||
this.stats.gasSpending = this.gasSpendingChart();
|
this.stats.gasSpending = this.gasSpendingChart();
|
||||||
|
this.stats.miners = this.minersChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
Node.prototype.addBlockHistory = function(block)
|
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)
|
if(this.blocks.length === MAX_BLOCKS_HISTORY)
|
||||||
{
|
{
|
||||||
@ -296,6 +300,24 @@ 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});
|
||||||
|
});
|
||||||
|
|
||||||
|
var minersArray = _.sortBy(minersArray, 'blocks').reverse();
|
||||||
|
|
||||||
|
return minersArray.slice(0, MINERS_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
Node.prototype.uptime = function()
|
Node.prototype.uptime = function()
|
||||||
{
|
{
|
||||||
this.stats.uptime = ((this._tries - this._down) / this._tries) * 100;
|
this.stats.uptime = ((this._tries - this._down) / this._tries) * 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user