_calculateGrainEarnedPerInterval = (account, intervals) => {
let allocationIndex = 0;
return intervals.map(interval => {
let grain = sc.ledger.grain.ZERO;
while (
account.allocationHistory.length - 1 >= allocationIndex &&
interval.startTimeMs <
account.allocationHistory[allocationIndex].credTimestampMs &&
account.allocationHistory[allocationIndex].credTimestampMs <=
interval.endTimeMs
) {
grain = sc.ledger.grain.add(
grain,
account.allocationHistory[allocationIndex].grainReceipt.amount
);
allocationIndex++;
}
return grain;
});
}