I am attempting to modify the masterCounter
variable within the timeKeyAdditionCheck
function. Within the timeKeyAdditionCheck
function, I successfully assign a value to masterCounter
, but this change is not reflected within the scope of getEventsWithTime
. When timeKeyAdditionCheck
is complete, the value of masterCounter
returns to null.
What changes do I need to make with timeKeyAdditionCheck
function?
let masterCounter = null;
let userTracker = {};
let timeKeyAdditionCheck = ('hour') => {
assert((range == 'minute' || range == 'hour'), "In calcArrayof... range value needs to equal 'minute' or 'hours'")
if (masterCounter == null) {
masterCounter = [{timerange: event.timestamp, totalusercount: 0, totalvalidatorcount: 0, totaletherdeposited: 0}]
}
if (event.timestamp > (masterCounter[masterCounter.length - 1] + 3599)) {
let differenceInTime = event.timestamp - (masterCounter[masterCounter.length - 1] + 3599);
let timeKeysNeeded = Math.ceil(differenceInTime / 3600);
i = 0;
while (i < timeKeysNeeded) {
let newEntry = masterCounter[masterCounter.length - 1];
newEntry.timerange = newEntry.timerange + 3600;
masterCounter.push(newEntry);
i++;
}
}
}
(async () => {
let events = await getEventsWithTime(3085928,3089928);
for (event of events) {
timeKeyAdditionCheck('hour');
checkNewUsers();
addValidatorsAndEth();
}
convertToCsv(masterCounter)
console.log(masterCounter)
})()