From b4689d164178821e611dce13b13f76adc6953769 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Mon, 18 Mar 2019 10:26:44 +0900 Subject: [PATCH] add forceUpdate option to change specific account type --- tools/richlist.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); }); }