updated web3 methods to v10 (sync)

This commit is contained in:
Marian Oancea 2015-01-28 02:41:04 +02:00
parent cd0d7ef899
commit b5fd9a0d4f
4 changed files with 64 additions and 81 deletions

1
app.js
View File

@ -23,6 +23,7 @@ app.use(express.static(path.join(__dirname, 'public')));
var nodes = [],
nodeStatus = [];
for(i in config) {
var node = new Node(config[i], i);
console.log(node);

View File

@ -1,28 +1,24 @@
var nodes = [
// {
// name: 'poc-7.ethdev.com',
// rpcProvider: 'HttpRpcProvider',
// rpcHost: '207.12.89.180',
// rpcPort: '30300'
// rpcPort: '8080'
// },
// {
// name: '54.204.10.41',
// rpcProvider: 'WebSocketProvider',
// rpcHost: '54.204.10.41',
// rpcPort: '30303'
// rpcPort: '8080'
// },
// {
// name: 'poc-7.ethdev.com - new IP',
// rpcHost: '5.45.179.140',
// rpcPort: '8080'
// },
{
name: 'poc-7.ethdev.com - new IP',
rpcProvider: 'HttpRpcProvider',
rpcHost: '5.45.179.140',
rpcPort: '30300'
},
// {
// name: 'local',
// rpcProvider: 'HttpRpcProvider',
// rpcHost: '127.0.0.1',
// rpcPort: '8080'
// }
name: 'local',
rpcHost: 'localhost',
rpcPort: '8080'
}
];
module.exports = nodes;

View File

@ -24,35 +24,21 @@ var Node = function Node(options, id)
return this;
}
Node.prototype.update = function(cb)
Node.prototype.update = function()
{
console.log(this);
if( ! this.web3.provider.installed()) {
var sock = new this.web3.providers[this.info.rpcProvider]((this.info.rpcProvider === 'HttpRpcProvider' ? 'http://' : 'ws://' ) + this.info.rpcHost + ':' + this.info.rpcPort);
if( ! this.web3.haveProvider()) {
var sock = new this.web3.providers.HttpSyncProvider('http://' + this.info.rpcHost + ':' + this.info.rpcPort);
this.web3.setProvider(sock);
}
var self = this;
var eth = this.web3.eth;
eth.peerCount.then(function(data){
self.info.stats.peers = data;
this.info.stats.peers = eth.peerCount;
this.info.stats.mining = eth.mining;
this.info.stats.block.height = eth.number;
this.info.stats.block.hash = eth.block(this.info.stats.block.height).hash;
return eth.number;
})
.then(function(data){
self.info.stats.block = data;
return eth.mining;
})
.then(function(data){
self.info.stats.mining = data;
cb(self.info.stats);
}).catch(function(error) {
console.log(error);
});
return this.info;
};
module.exports = Node;

View File

@ -85,47 +85,47 @@ block content
span.small {{node.block.hash}}
td 16 sec
td 98.3%
tr.text-success
td poc-7.ethdev.com
td C++
td 7
td
i.icon-check
td #8196
td.hidden-sm.hidden-xs
span.small 06d1a2c709f23678e716ae8bea400161815a37a16aeced3a4ffed79b96f63566
td 16 sec
td 98.3%
tr.text-warning
td poc-6.ethdev.com
td C++
td 4
td
i.icon-warning-o
td #8186
td.hidden-sm.hidden-xs
span.small 1545f88598e54e56ec5570b08c592f8c8403e3e1c9ec0eec2f9ba619729ec85e
td 3 min
td 94.1%
tr.text-danger
td poc-5.ethdev.com
td C++
td 0
td
i.icon-cancel
td #3196
td.hidden-sm.hidden-xs
span.small 45f4e588bf9a03ba0d7146dd83a6a8faf00df471d7484b92d904b77014d10e01
td 2 days
td 79.4%
tr.text-danger
td poc-4.ethdev.com
td C++
td 0
td
i.icon-cancel
td #1196
td.hidden-sm.hidden-xs
span.small 36d6fe290d52da4518f9017fa7b5dd407007053e345463e7a6fdc905b8d9b2a3
td 1 mon
td 21.8%
//- tr.text-success
//- td poc-7.ethdev.com
//- td C++
//- td 7
//- td
//- i.icon-check
//- td #8196
//- td.hidden-sm.hidden-xs
//- span.small 06d1a2c709f23678e716ae8bea400161815a37a16aeced3a4ffed79b96f63566
//- td 16 sec
//- td 98.3%
//- tr.text-warning
//- td poc-6.ethdev.com
//- td C++
//- td 4
//- td
//- i.icon-warning-o
//- td #8186
//- td.hidden-sm.hidden-xs
//- span.small 1545f88598e54e56ec5570b08c592f8c8403e3e1c9ec0eec2f9ba619729ec85e
//- td 3 min
//- td 94.1%
//- tr.text-danger
//- td poc-5.ethdev.com
//- td C++
//- td 0
//- td
//- i.icon-cancel
//- td #3196
//- td.hidden-sm.hidden-xs
//- span.small 45f4e588bf9a03ba0d7146dd83a6a8faf00df471d7484b92d904b77014d10e01
//- td 2 days
//- td 79.4%
//- tr.text-danger
//- td poc-4.ethdev.com
//- td C++
//- td 0
//- td
//- i.icon-cancel
//- td #1196
//- td.hidden-sm.hidden-xs
//- span.small 36d6fe290d52da4518f9017fa7b5dd407007053e345463e7a6fdc905b8d9b2a3
//- td 1 mon
//- td 21.8%