diff --git a/bin/build-go.sh b/bin/build-go.sh index b1e6d4f..1f87925 100644 --- a/bin/build-go.sh +++ b/bin/build-go.sh @@ -1,27 +1,19 @@ #!/bin/sh -mkdir -p ~/go -echo "export GOPATH=$HOME/go" >> ~/.bashrc -echo "export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin" >> ~/.bashrc - -export GOPATH=$HOME/go -export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin - +# update repository & install dependencies +sudo apt-get install -y software-properties-common sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm -# install go -sudo apt-get install -y golang +# add ethereum repos +sudo add-apt-repository -y ppa:ethereum/ethereum-qt +sudo add-apt-repository -y ppa:ethereum/ethereum +sudo add-apt-repository -y ppa:ethereum/ethereum-dev +sudo apt-get update -y -go get -v github.com/tools/godep -go get -v -d github.com/ethereum/go-ethereum/... - -# install ethereum go -cd $GOPATH/src/github.com/ethereum/go-ethereum -git checkout develop -godep restore -go install -v ./cmd/ethereum +#install ethereum +sudo apt-get install -y ethereum # add node symlink sudo ln -s /usr/bin/nodejs /usr/bin/node diff --git a/bin/eth.sh b/bin/eth.sh index 9faaeba..9bf17b6 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -1,3 +1,8 @@ #!/bin/bash trap "exit" INT -/home/ubuntu/bin/eth -b -x 15 -l 30303 -r poc-8.ethdev.com -p 30303 -m off -j \ No newline at end of file +if [ -f /usr/bin/ethereum ] +then + ethereum -rpc true -rpcport 8080 +else + eth -x 15 -l 30303 -r poc-8.ethdev.com -p 30303 -m off -j +fi \ No newline at end of file diff --git a/lib/node.js b/lib/node.js index 6fdf1fb..c8a7a96 100644 --- a/lib/node.js +++ b/lib/node.js @@ -15,17 +15,17 @@ Socket = Primus.createSocket({ plugin: {emitter: Emitter, sparkLatency: Latency} }); -var INSTANCE_NAME, - ETH_VERSION; +var INSTANCE_NAME = process.env.INSTANCE_NAME; +var ETH_VERSION = "unknown"; if(process.env.NODE_ENV === 'production') { - if(process.env.INSTANCE_NAME !== "") + if(process.env.INSTANCE_NAME === "") { INSTANCE_NAME = shelljs.exec('ec2metadata --instance-id', {silent: true}).output; } - ETH_VERSION = shelljs.exec((process.env.ETH_IMPLEMENTATION === 'go' ? 'ethereum version' : 'eth -V'), {silent: true}).output; + // ETH_VERSION = shelljs.exec((process.env.ETH_IMPLEMENTATION === 'go' ? 'ethereum version' : 'eth -V'), {silent: true}).output; } var socket = new Socket(process.env.WS_SERVER || 'ws://localhost:3000'); @@ -39,7 +39,7 @@ function Node() this.info = { name: INSTANCE_NAME || (process.env.EC2_INSTANCE_ID || os.hostname()), - node: ETH_VERSION || (process.env.ETH_VERSION || 'eth version 0.8.1'), + node: 'unknown', os: os.platform(), os_v: os.release() }; @@ -76,7 +76,7 @@ function Node() this.chainWatch = false; this.updateInterval = false; - web3.setProvider(new web3.providers.HttpSyncProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080'))); + web3.setProvider(new web3.providers.HttpProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080'))); socket.on('open', function open() { socket.emit('hello', { id: self.id, info: self.info, secret: WS_SECRET }); @@ -111,7 +111,7 @@ Node.prototype.isActive = function() this.stats.errors = []; try { - var peers = web3.eth.peerCount; + var peers = web3.net.peerCount; if(peers !== null) { @@ -150,7 +150,7 @@ Node.prototype.getBlock = function(number) if(typeof number === 'undefined'){ try { - number = parseInt(web3.eth.number); + number = parseInt(web3.eth.blockNumber); if(number === this.stats.block.number + 1) return this.stats.block; @@ -165,7 +165,7 @@ Node.prototype.getBlock = function(number) } try { - block = web3.eth.block(number); + block = web3.eth.getBlock(number); block.arrival = Date.now(); block.propagation = block.arrival - (block.timestamp * 1000); @@ -174,7 +174,7 @@ Node.prototype.getBlock = function(number) block.difficulty = web3.toDecimal(block.difficulty); try { - block.txCount = web3.eth.transactionCount(block.hash) || '?'; + block.txCount = web3.eth.getBlockTransactionCount(block.hash) || '?'; } catch (err) { this.stats.errors.push({ @@ -294,7 +294,7 @@ Node.prototype.getStats = function() this.stats.mining = web3.eth.mining; this.stats.gasPrice = web3.toDecimal(web3.eth.gasPrice); - this.stats.listening = web3.eth.listening; + this.stats.listening = web3.net.listening; } this.uptime(); @@ -306,7 +306,6 @@ Node.prototype.changed = function() if(this._tries - this._lastSent > 5) { - // console.log('force send'); this._lastSent = this._tries; return true; @@ -342,17 +341,18 @@ Node.prototype.setWatches = function() { var self = this; - this.pendingWatch = web3.eth.watch('pending'); - this.pendingWatch.changed(function(log) { + this.pendingWatch = web3.eth.filter('pending'); + this.pendingWatch.watch( function(log) { + console.log(log); // console.log('pending changed'); - self.stats.pending = parseInt(log.number); + // self.stats.pending = parseInt(log.number); }); - this.chainWatch = web3.eth.watch('chain'); - this.chainWatch.messages(function(log) { - // console.log('block changed'); - self.update(); - }); + // this.chainWatch = web3.eth.watch('chain'); + // this.chainWatch.messages(function(log) { + // // console.log('block changed'); + // self.update(); + // }); this.updateInterval = setInterval(function(){ self.update(); @@ -386,10 +386,10 @@ Node.prototype.stop = function() clearInterval(this.updateInterval); if(this.pendingWatch) - this.pendingWatch.uninstall(); + this.pendingWatch.stopWatching(); - if(this.chainWatch) - this.chainWatch.uninstall(); + // if(this.chainWatch) + // this.chainWatch.uninstall(); } module.exports = Node; \ No newline at end of file diff --git a/package.json b/package.json index e0082ca..20f3eac 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "debug": "~2.1.1", - "ethereum.js": "*", + "ethereum.js": "0.1.*", "lodash": "^3.2.0", "primus": "^2.4.12", "primus-emit": "^0.1.2", diff --git a/processes-go.json b/processes-go.json deleted file mode 100644 index 900d74b..0000000 --- a/processes-go.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "name" : "eth-go", - "cwd" : "/home/ubuntu/bin/www/", - "script" : "bin/eth-go.sh", - "log_file" : "/home/ubuntu/logs/eth-log.log", - "out_file" : "/home/ubuntu/logs/eth-out.log", - "error_file" : "/home/ubuntu/logs/eth-err.log", - "merge_logs" : true, - "watch" : false, - "cron_restart" : "0 0 * * *", - "exec_interpreter" : "bash", - "exec_mode" : "fork_mode" - }, - { - "name" : "node-app", - "cwd" : "/home/ubuntu/bin/www/", - "script" : "app.js", - "log_file" : "/home/ubuntu/logs/node-app-log.log", - "out_file" : "/home/ubuntu/logs/node-app-out.log", - "error_file" : "/home/ubuntu/logs/node-app-err.log", - "merge_logs" : true, - "watch" : false, - "cron_restart" : "0 0 * * *", - "exec_interpreter" : "node", - "exec_mode" : "fork_mode", - "env": - { - "NODE_ENV" : "production", - "RPC_HOST" : "localhost", - "RPC_PORT" : "8080", - "ETH_IMPLEMENTATION" : "go", - "INSTANCE_NAME" : "", - "WS_SERVER" : "wss://eth-netstats.herokuapp.com", - "WS_SECRET" : "eth-net-stats-has-a-secret", - } - } -] \ No newline at end of file diff --git a/processes.json b/processes.json index 9acfb07..c6489b0 100644 --- a/processes.json +++ b/processes.json @@ -29,7 +29,6 @@ "NODE_ENV" : "production", "RPC_HOST" : "localhost", "RPC_PORT" : "8080", - "ETH_IMPLEMENTATION" : "cpp", "INSTANCE_NAME" : "", "WS_SERVER" : "wss://eth-netstats.herokuapp.com", "WS_SECRET" : "eth-net-stats-has-a-secret",