@@ -1513,7 +1513,7 @@ contract FilecoinWarmStorageService is
15131513 uint256 provenEpochCount = 0 ;
15141514 uint256 lastProvenEpoch = fromEpoch;
15151515
1516- (provenEpochCount, lastProvenEpoch) = findProvenEpochs (dataSetId, fromEpoch, toEpoch);
1516+ (provenEpochCount, lastProvenEpoch) = _findProvenEpochs (dataSetId, fromEpoch, toEpoch);
15171517
15181518 // If no epochs are proven, we can't settle anything
15191519 if (provenEpochCount == 0 ) {
@@ -1540,14 +1540,15 @@ contract FilecoinWarmStorageService is
15401540 });
15411541 }
15421542
1543- function findProvenEpochs (uint256 dataSetId , uint256 fromEpoch , uint256 toEpoch )
1544- public
1543+ function _findProvenEpochs (uint256 dataSetId , uint256 fromEpoch , uint256 toEpoch )
1544+ internal
15451545 view
15461546 returns (uint256 , uint256 )
15471547 {
15481548 uint256 provenEpochCount = 0 ;
15491549 uint256 lastProvenEpoch = fromEpoch;
15501550 uint256 activationEpoch = provingActivationEpoch[dataSetId];
1551+ uint256 currentPeriod = getProvingPeriodForEpoch (dataSetId, block .number );
15511552 if (toEpoch >= activationEpoch && toEpoch < block .number ) {
15521553 // if `toEpoch` lies after activation, and `fromEpoch` lies before activation, then update the `fromEpoch`, as follows :
15531554 if (fromEpoch < activationEpoch) {
@@ -1562,25 +1563,25 @@ contract FilecoinWarmStorageService is
15621563
15631564 if (toEpoch < startingPeriod_deadline) {
15641565 // alternative way to check the same : `startingPeriod == endingPeriod`
1565- if (_isPeriodProven (dataSetId, startingPeriod)) {
1566+ if (_isPeriodProven (dataSetId, startingPeriod, currentPeriod )) {
15661567 provenEpochCount = (toEpoch - fromEpoch);
15671568 lastProvenEpoch = toEpoch;
15681569 }
15691570 } else {
1570- if (_isPeriodProven (dataSetId, startingPeriod)) {
1571+ if (_isPeriodProven (dataSetId, startingPeriod, currentPeriod )) {
15711572 provenEpochCount += (startingPeriod_deadline - fromEpoch);
15721573 }
15731574
15741575 // now loop through the proving periods between endingPeriod and startingPeriod.
15751576 for (uint256 period = startingPeriod + 1 ; period <= endingPeriod - 1 ; period++ ) {
1576- if (_isPeriodProven (dataSetId, period)) {
1577+ if (_isPeriodProven (dataSetId, period, currentPeriod )) {
15771578 provenEpochCount += maxProvingPeriod;
15781579 lastProvenEpoch = _calcPeriodDeadline (dataSetId, period);
15791580 }
15801581 }
15811582
15821583 // now handle the last period separately
1583- if (_isPeriodProven (dataSetId, endingPeriod)) {
1584+ if (_isPeriodProven (dataSetId, endingPeriod, currentPeriod )) {
15841585 // then the epochs to add = `endingPeriod_starting` to `toEpoch`. But since `endingPeriod_starting` is simply the ending of its previous period, so
15851586 provenEpochCount += (toEpoch - _calcPeriodDeadline (dataSetId, endingPeriod - 1 ));
15861587 lastProvenEpoch = toEpoch;
@@ -1591,8 +1592,7 @@ contract FilecoinWarmStorageService is
15911592 return (provenEpochCount, lastProvenEpoch);
15921593 }
15931594
1594- function _isPeriodProven (uint256 dataSetId , uint256 periodId ) private view returns (bool ) {
1595- uint256 currentPeriod = getProvingPeriodForEpoch (dataSetId, block .number );
1595+ function _isPeriodProven (uint256 dataSetId , uint256 periodId , uint256 currentPeriod ) private view returns (bool ) {
15961596 if (periodId == currentPeriod) {
15971597 return provenThisPeriod[dataSetId];
15981598 }
0 commit comments