diff --git a/tools/richlist.js b/tools/richlist.js index de7484d33..feaf9b3bb 100644 --- a/tools/richlist.js +++ b/tools/richlist.js @@ -368,7 +368,7 @@ 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]; @@ -376,10 +376,10 @@ var updateAccounts = function(accounts, blockNumber) { return account; }); - bulkInsert(bulk); + bulkInsert(bulk, forceUpdate); } -var bulkInsert = function(bulk) { +var bulkInsert = function(bulk, forceUpdate = false) { if (!bulk.length) { return; } @@ -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; @@ -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); }); }