Skip to content

Commit

Permalink
add forceUpdate option to change specific account type
Browse files Browse the repository at this point in the history
  • Loading branch information
hackmod committed Mar 18, 2019
1 parent aa68e32 commit b4689d1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/richlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,18 @@ function makeParityRichList(number, offset, blockNumber, updateCallback) {
/**
* Write accounts to DB
*/
var updateAccounts = function(accounts, blockNumber) {
var updateAccounts = function(accounts, blockNumber, forceUpdate = false) {
// prepare
var bulk = Object.keys(accounts).map(function(j) {
let account = accounts[j];
account.blockNumber = blockNumber;
return account;
});

bulkInsert(bulk);
bulkInsert(bulk, forceUpdate);
}

var bulkInsert = function(bulk) {
var bulkInsert = function(bulk, forceUpdate = false) {
if (!bulk.length) {
return;
}
Expand All @@ -398,7 +398,7 @@ var bulkInsert = function(bulk) {
// upsert accounts
item._id = undefined;
delete item._id; // remove _id field
if (item.type == 0) {
if (item.type == 0 && !forceUpdate) {
// do not update for normal address cases
item.type = undefined;
delete item.type;
Expand Down Expand Up @@ -508,7 +508,7 @@ function readJsonAccounts(json, blockNumber, callback, defaultType = 0) {
}
data[batch.requests[i].params[0]].balance = ether;
});
callback(data, blockNumber);
callback(data, blockNumber, true);
});
}

Expand Down

0 comments on commit b4689d1

Please sign in to comment.