Skip to content

Commit

Permalink
added comments for clarity, etc
Browse files Browse the repository at this point in the history
 * AccountsController: fixed for clarity
  • Loading branch information
hackmod committed Nov 19, 2018
1 parent a82c74e commit de3ee7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion public/js/controllers/AccountsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ angular.module('BlocksApp').controller('AccountsController', function($statePara

// fixup data to show percentages
var newdata = resp.data.data.map(function(item) {
return [item[0], item[1], item[2], item[3], (item[3] / $scope.totalSupply) * 100, item[4]];
var num = item[0];
var addr = item[1];
var type = item[2];
var balance = item[3];
var lastmod = item[4];
return [num, addr, type, balance, (balance / $scope.totalSupply) * 100, lastmod];
});
resp.data.data = newdata;
callback(resp.data);
Expand Down
7 changes: 5 additions & 2 deletions tools/richlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ var Account = require('../db.js').Account;
var Transaction = require('../db.js').Transaction;
var Block = require('../db.js').Block;

mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/blockDB');

const ADDRESS_CACHE_MAX = 10000; // address cache threshold

// RichList for Geth Classic, Geth
function makeRichList(toBlock, blocks, updateCallback) {
var self = makeRichList;
if (!self.cached) {
Expand Down Expand Up @@ -117,8 +116,11 @@ function makeRichList(toBlock, blocks, updateCallback) {
self.index += len;
console.log("* update " + len + " accounts ...");

// split accounts into chunks to make proper sized json-rpc batch job.
var accounts = Object.keys(self.accounts);
var chunks = [];

// about ~1000 `eth_getBalance` json rpc calls are possible in one json-rpc batchjob.
while (accounts.length > 800) {
var chunk = accounts.splice(0, 500);
chunks.push(chunk);
Expand Down Expand Up @@ -390,6 +392,7 @@ var bulkInsert = function(bulk) {
Account.collection.insert(localbulk, function(error, data) {
if (error) {
if (error.code == 11000) {
// For already exists case, try upsert method.
async.eachSeries(localbulk, function(item, eachCallback) {
// upsert accounts
item._id = undefined;
Expand Down
1 change: 1 addition & 0 deletions tools/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ if (config.patch === true){
}

// check NORICHLIST env
// you can use it like as 'NORICHLIST=1 node tools/sync.js' to disable balance updater temporary.
if (process.env.NORICHLIST) {
config.useRichList = false;
}
Expand Down

0 comments on commit de3ee7b

Please sign in to comment.