Merge pull request #53 from cubedro/master

Update from master
This commit is contained in:
Marian OANCΞA 2015-04-06 02:29:31 +03:00
commit e773225329
4 changed files with 28 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -1,8 +1,9 @@
#!/bin/bash
IP=$(ec2metadata --public-ipv4)
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 "50" -loglevel "4" -bootnodes "enode://09fbeec0d047e9a37e63f60f8618aa9df0e49271f3fadb2c070dc09e2099b95827b63a8b837c6fd01d0802d457dd83e3bd48bd3e6509f8209ed90dabbc30e3d3@52.16.188.185:30303" -nat "extip:$IP"
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

View File

@ -20,6 +20,7 @@ Socket = Primus.createSocket({
transformer: 'websockets',
pathname: '/api',
timeout: 10000,
strategy: 'disconnect,online',
plugin: {emitter: Emitter, sparkLatency: Latency}
});
@ -35,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()
{
@ -75,6 +77,7 @@ function Node()
txDensity: [],
blockTimes: [],
gasSpending: [],
miners: [],
uptime: 0,
errors: []
};
@ -234,11 +237,12 @@ 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)
{
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)
{
@ -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()
{
this.stats.uptime = ((this._tries - this._down) / this._tries) * 100;