2014-12-03 04:47:43 +01:00
|
|
|
var router = require('express.io')();
|
2014-12-04 22:35:09 +01:00
|
|
|
var web3 = require('ethereum.js');
|
|
|
|
var geoip = require('geoip-lite');
|
|
|
|
var config = require('../config/nodes');
|
|
|
|
|
|
|
|
var geo = geoip.lookup(config[0].rpcHost);
|
|
|
|
console.log(geo);
|
|
|
|
|
|
|
|
if( ! web3.provider.installed()) {
|
|
|
|
var sock = new web3.providers[config[0].rpcProvider]((config[0].rpcProvider === 'HttpRpcProvider' ? 'http://' : 'ws://' ) + config[0].rpcHost + ':' + config[0].rpcPort);
|
|
|
|
web3.setProvider(sock);
|
|
|
|
}
|
|
|
|
|
|
|
|
web3.eth.mining.then(function(data){
|
|
|
|
console.log("is mining: " + data);
|
|
|
|
});
|
|
|
|
|
|
|
|
web3.eth.peerCount.then(function(data){
|
|
|
|
console.log("peers: " + data);§
|
|
|
|
});
|
|
|
|
|
|
|
|
web3.eth.number.then(function(data){
|
|
|
|
console.log("latest block: " + data);
|
|
|
|
});
|
2014-12-03 04:08:49 +01:00
|
|
|
|
2014-12-03 04:47:43 +01:00
|
|
|
/* GET stats listing. */
|
2014-12-03 04:08:49 +01:00
|
|
|
router.get('/', function(req, res) {
|
|
|
|
res.send('respond with a resource');
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|