Skip to content

Commit

Permalink
stash commit (DO NOT MERGE)
Browse files Browse the repository at this point in the history
  • Loading branch information
hackmod committed May 4, 2018
1 parent 08b3f98 commit 2d35ab5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
25 changes: 12 additions & 13 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"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",
"name": "Ethereum Classic",
"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"
}
}
}
}
7 changes: 5 additions & 2 deletions public/js/controllers/AddressController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -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);
});
}

Expand Down
2 changes: 1 addition & 1 deletion public/views/address.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</span> <a href="http://etherscan.io/address/{{addrHash}}" target="_blank"><i class="fa fa-external-link"></i></a>
</div>
<div class="margin-top-20">
0 <span class="eth-stat-text">Mined</span>
{{ addr.mined }} <span class="eth-stat-text">Mined</span>
</div>
<div class="margin-top-20">
{{ addr.count }} <span class="eth-stat-text">Transactions</span>
Expand Down
22 changes: 21 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}] })

Expand All @@ -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)
Expand All @@ -67,6 +86,7 @@ var getAddr = function(req, res){
res.write(JSON.stringify(data));
res.end();
});
});

};
var getBlock = function(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion tools/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2d35ab5

Please sign in to comment.