From 2d35ab5e23a42815c1dafeca9ca9af0ffa864705 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Fri, 4 May 2018 15:53:32 +0900 Subject: [PATCH] stash commit (DO NOT MERGE) --- config.json | 25 +++++++++++----------- public/js/controllers/AddressController.js | 7 ++++-- public/views/address.html | 2 +- routes/index.js | 22 ++++++++++++++++++- tools/stats.js | 2 +- 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/config.json b/config.json index d86ce3502..8bc31bd38 100644 --- a/config.json +++ b/config.json @@ -1,10 +1,11 @@ { "nodeAddr": "localhost", - "gethPort": 8545, + "gethPort": 9547, "startBlock": 0, + "endBlock": "latest", "quiet": true, - "syncAll": true, - "patch": true, + "syncAll": false, + "patch": false, "patchBlocks": 100, "settings": { "symbol": "ETC", @@ -12,15 +13,13 @@ "title": "Ethereum Classic Block Explorer", "author": "Elaine", "miners": { - "0xdf7d7e053933b5cc24372f878c90e62dadad5d42": "EtherMine", - "0xc91716199ccde49dc4fafaeb68925127ac80443f": "F2Pool", - "0x9eab4b0fc468a7f5d46228bf5a76cb52370d068d": "NanoPool", - "0x8c5535afdbdeea80adedc955420f684931bf91e0": "MiningPoolHub", - "0x4750e296949b747df1585aa67beee8be903dd560": "UUPool", - "0xef224fa5fad302b51f38898f4df499d7af127af0": "91pool", - "0x00d29bfdf5f8d2d0466da4b948f37692ca50867a": "2miners", - "0x4c2b4e716883a2c3f6b980b70b577e54b9441060": "ETCPool PL", - "0xd144e30a0571aaf0d0c050070ac435deba461fab": "Clona Network" + "0xe3ec5ebd3e822c972d802a0ee4e0ec080b8237ba": "SejunPool", + "0xc734480388db099cb43fd1c3ed530b39b9d8d567": "GonsPool", + "0x2eb64b8ab13f0d7823158217d15ba310ed3d0e58": "TopMining", + "0x0b292a321fe5e20cc943648a782184f8ab44d2eb": "MoricPool", + "0x2930822031420731f09dce572554a8b8c1eaa09b": "Gonsmine", + "0xfc35930abb108ae6cae33fd065dfb799808ea326": "Comining", + "0x90d7c82615f151953a8d71a68096cee4d428619c": "privatePool" } } -} \ No newline at end of file +} diff --git a/public/js/controllers/AddressController.js b/public/js/controllers/AddressController.js index ab30a5b02..172cbdd83 100755 --- a/public/js/controllers/AddressController.js +++ b/public/js/controllers/AddressController.js @@ -9,7 +9,7 @@ angular.module('BlocksApp').controller('AddressController', function($stateParam $rootScope.$state.current.data["pageSubTitle"] = $stateParams.hash; $scope.addrHash = $stateParams.hash; - $scope.addr = {"balance": 0, "count": 0}; + $scope.addr = {"balance": 0, "count": 0, "mined": 0}; $scope.settings = $rootScope.setup; //fetch web3 stuff @@ -18,7 +18,7 @@ angular.module('BlocksApp').controller('AddressController', function($stateParam url: '/web3relay', data: {"addr": $scope.addrHash, "options": ["balance", "count", "bytecode"]} }).success(function(data) { - $scope.addr = data; + $scope.addr = $.extend($scope.addr, data); fetchTxs($scope.addr.count); if (data.isContract) { $rootScope.$state.current.data["pageTitle"] = "Contract Address"; @@ -80,6 +80,9 @@ angular.module('BlocksApp').controller('AddressController', function($stateParam return getDuration(data).toString(); }, "targets": [6]}, ] + }).on('xhr', function(e, settings, json) { + $scope.addr.count = json.recordsTotal; + $scope.addr.mined = parseInt(json.mined); }); } diff --git a/public/views/address.html b/public/views/address.html index 9de540ad9..b63ca4b50 100644 --- a/public/views/address.html +++ b/public/views/address.html @@ -18,7 +18,7 @@
- 0 Mined + {{ addr.mined }} Mined
{{ addr.count }} Transactions diff --git a/routes/index.js b/routes/index.js index d5a21c6a4..03a235b7e 100644 --- a/routes/index.js +++ b/routes/index.js @@ -44,7 +44,7 @@ var getAddr = function(req, res){ var limit = parseInt(req.body.length); var start = parseInt(req.body.start); - var data = { draw: parseInt(req.body.draw), recordsFiltered: count, recordsTotal: count }; + var data = { draw: parseInt(req.body.draw), recordsFiltered: count, recordsTotal: count, mined: 0 }; var addrFind = Transaction.find( { $or: [{"to": addr}, {"from": addr}] }) @@ -58,6 +58,25 @@ var getAddr = function(req, res){ } } + Transaction.aggregate([ + {$match: { $or: [{"to": addr}, {"from": addr}] }}, + {$group: { _id: null, count: { $sum: 1 } }} + ]).exec(function(err, results) { + if (!err && results && results.length > 0) { + // fix recordsTotal + data.recordsTotal = results[0].count; + data.recordsFiltered = results[0].count; + } + }); + + Block.aggregate([ + { $match: { "miner": addr } }, + { $group: { _id: '$miner', count: { $sum: 1 } } + }]).exec(function(err, results) { + if (!err && results && results.length > 0) { + data.mined = results[0].count; + console.log(results); + } addrFind.lean(true).sort(sortOrder).skip(start).limit(limit) .exec("find", function (err, docs) { if (docs) @@ -67,6 +86,7 @@ var getAddr = function(req, res){ res.write(JSON.stringify(data)); res.end(); }); + }); }; var getBlock = function(req, res) { diff --git a/tools/stats.js b/tools/stats.js index 11154cbc4..0f623e8a3 100644 --- a/tools/stats.js +++ b/tools/stats.js @@ -8,7 +8,7 @@ var mongoose = require( 'mongoose' ); var BlockStat = require( '../db.js' ).BlockStat; var updateStats = function(range, interval, rescan) { - var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); + var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:9545')); mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/blockDB'); mongoose.set('debug', true);