@@ -1634,7 +1634,7 @@ contract FilecoinWarmStorageService is
16341634 uint256 provenEpochCount = 0 ;
16351635 uint256 lastProvenEpoch = fromEpoch;
16361636
1637- (provenEpochCount, lastProvenEpoch) = findProvenEpochs (dataSetId, fromEpoch, toEpoch);
1637+ (provenEpochCount, lastProvenEpoch) = _findProvenEpochs (dataSetId, fromEpoch, toEpoch);
16381638
16391639 // If no epochs are proven, we can't settle anything
16401640 if (provenEpochCount == 0 ) {
@@ -1661,14 +1661,15 @@ contract FilecoinWarmStorageService is
16611661 });
16621662 }
16631663
1664- function findProvenEpochs (uint256 dataSetId , uint256 fromEpoch , uint256 toEpoch )
1665- public
1664+ function _findProvenEpochs (uint256 dataSetId , uint256 fromEpoch , uint256 toEpoch )
1665+ internal
16661666 view
16671667 returns (uint256 , uint256 )
16681668 {
16691669 uint256 provenEpochCount = 0 ;
16701670 uint256 lastProvenEpoch = fromEpoch;
16711671 uint256 activationEpoch = provingActivationEpoch[dataSetId];
1672+ uint256 currentPeriod = getProvingPeriodForEpoch (dataSetId, block .number );
16721673 if (toEpoch >= activationEpoch && toEpoch < block .number ) {
16731674 // if `toEpoch` lies after activation, and `fromEpoch` lies before activation, then update the `fromEpoch`, as follows :
16741675 if (fromEpoch < activationEpoch) {
@@ -1683,25 +1684,25 @@ contract FilecoinWarmStorageService is
16831684
16841685 if (toEpoch < startingPeriod_deadline) {
16851686 // alternative way to check the same : `startingPeriod == endingPeriod`
1686- if (_isPeriodProven (dataSetId, startingPeriod)) {
1687+ if (_isPeriodProven (dataSetId, startingPeriod, currentPeriod )) {
16871688 provenEpochCount = (toEpoch - fromEpoch);
16881689 lastProvenEpoch = toEpoch;
16891690 }
16901691 } else {
1691- if (_isPeriodProven (dataSetId, startingPeriod)) {
1692+ if (_isPeriodProven (dataSetId, startingPeriod, currentPeriod )) {
16921693 provenEpochCount += (startingPeriod_deadline - fromEpoch);
16931694 }
16941695
16951696 // now loop through the proving periods between endingPeriod and startingPeriod.
16961697 for (uint256 period = startingPeriod + 1 ; period <= endingPeriod - 1 ; period++ ) {
1697- if (_isPeriodProven (dataSetId, period)) {
1698+ if (_isPeriodProven (dataSetId, period, currentPeriod )) {
16981699 provenEpochCount += maxProvingPeriod;
16991700 lastProvenEpoch = _calcPeriodDeadline (dataSetId, period);
17001701 }
17011702 }
17021703
17031704 // now handle the last period separately
1704- if (_isPeriodProven (dataSetId, endingPeriod)) {
1705+ if (_isPeriodProven (dataSetId, endingPeriod, currentPeriod )) {
17051706 // then the epochs to add = `endingPeriod_starting` to `toEpoch`. But since `endingPeriod_starting` is simply the ending of its previous period, so
17061707 provenEpochCount += (toEpoch - _calcPeriodDeadline (dataSetId, endingPeriod - 1 ));
17071708 lastProvenEpoch = toEpoch;
@@ -1712,8 +1713,7 @@ contract FilecoinWarmStorageService is
17121713 return (provenEpochCount, lastProvenEpoch);
17131714 }
17141715
1715- function _isPeriodProven (uint256 dataSetId , uint256 periodId ) private view returns (bool ) {
1716- uint256 currentPeriod = getProvingPeriodForEpoch (dataSetId, block .number );
1716+ function _isPeriodProven (uint256 dataSetId , uint256 periodId , uint256 currentPeriod ) private view returns (bool ) {
17171717 if (periodId == currentPeriod) {
17181718 return provenThisPeriod[dataSetId];
17191719 }
0 commit comments