added eth js and geo

pull/5/head
Marian Oancea 10 years ago
parent 3054ad1921
commit 00fc14bad0
  1. 4
      app.js
  2. 10
      config/nodes.js
  3. 6
      models/node.js
  4. 12
      package.json
  5. 23
      routes/stats.js

@ -2,12 +2,13 @@ var express = require('express.io');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var stats = require('./routes/stats');
require('es6-promise').polyfill();
express().http().io();
var app = express();
@ -21,7 +22,6 @@ app.set('view engine', 'jade');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

@ -0,0 +1,10 @@
var nodes = [
{
nodeName: 'poc-7.ethdev.com',
rpcProvider: 'HttpRpcProvider',
rpcHost: '207.12.89.180',
rpcPort: '8080'
}
];
module.exports = nodes;

@ -0,0 +1,6 @@
var web3 = require('ethereum.js');
var geoip = require('geoip-lite');
var Node = {};
module.exports = Node;

@ -6,13 +6,15 @@
"start": "node ./bin/www"
},
"dependencies": {
"express.io": "^1.1.13",
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"morgan": "~1.3.0",
"serve-favicon": "~2.1.3",
"debug": "~2.0.0",
"es6-promise": "*",
"ethereum.js": "*",
"express.io": "^1.1.13",
"geoip-lite": "^1.1.4",
"jade": "~1.6.0",
"morgan": "~1.3.0",
"serve-favicon": "~2.1.3",
"stylus": "0.42.3"
}
}
}

@ -1,4 +1,27 @@
var router = require('express.io')();
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);
});
/* GET stats listing. */
router.get('/', function(req, res) {

Loading…
Cancel
Save