@@ -876,84 +876,96 @@ func SectorsExtendCmd(getActorAddress ActorAddressGetter) *cli.Command {
876
876
877
877
for l , exts := range extensions {
878
878
for newExp , numbers := range exts {
879
- sectorsWithoutClaimsToExtend := bitfield .New ()
880
- numbersToExtend := make ([]abi.SectorNumber , 0 , len (numbers ))
881
- var sectorsWithClaims []miner.SectorClaim
882
- for _ , sectorNumber := range numbers {
883
- claimIdsToMaintain := make ([]verifreg.ClaimId , 0 )
884
- claimIdsToDrop := make ([]verifreg.ClaimId , 0 )
885
- cannotExtendSector := false
886
- claimIds , ok := claimIdsBySector [sectorNumber ]
887
- // Nothing to check, add to ccSectors
888
- if ! ok {
889
- sectorsWithoutClaimsToExtend .Set (uint64 (sectorNumber ))
890
- numbersToExtend = append (numbersToExtend , sectorNumber )
891
- } else {
892
- for _ , claimId := range claimIds {
893
- claim , ok := claimsMap [claimId ]
894
- if ! ok {
895
- return xerrors .Errorf ("failed to find claim for claimId %d" , claimId )
896
- }
897
- claimExpiration := claim .TermStart + claim .TermMax
898
- // can be maintained in the extended sector
899
- if claimExpiration > newExp {
900
- claimIdsToMaintain = append (claimIdsToMaintain , claimId )
901
- } else {
902
- sectorInfo , ok := activeSectorsInfo [sectorNumber ]
879
+ batchSize := addrSectors
880
+
881
+ for i := 0 ; i < len (numbers ); i += batchSize {
882
+ end := i + batchSize
883
+ if end > len (numbers ) {
884
+ end = len (numbers )
885
+ }
886
+
887
+ batch := numbers [i :end ]
888
+
889
+ sectorsWithoutClaimsToExtend := bitfield .New ()
890
+ numbersToExtend := make ([]abi.SectorNumber , 0 , len (numbers ))
891
+ var sectorsWithClaims []miner.SectorClaim
892
+
893
+ for _ , sectorNumber := range batch {
894
+ claimIdsToMaintain := make ([]verifreg.ClaimId , 0 )
895
+ claimIdsToDrop := make ([]verifreg.ClaimId , 0 )
896
+ cannotExtendSector := false
897
+ claimIds , ok := claimIdsBySector [sectorNumber ]
898
+ // Nothing to check, add to ccSectors
899
+ if ! ok {
900
+ sectorsWithoutClaimsToExtend .Set (uint64 (sectorNumber ))
901
+ numbersToExtend = append (numbersToExtend , sectorNumber )
902
+ } else {
903
+ for _ , claimId := range claimIds {
904
+ claim , ok := claimsMap [claimId ]
903
905
if ! ok {
904
- return xerrors .Errorf ("failed to find sector in active sector set: %w " , err )
906
+ return xerrors .Errorf ("failed to find claim for claimId %d " , claimId )
905
907
}
906
- if ! cctx .Bool ("drop-claims" ) ||
907
- // FIP-0045 requires the claim minimum duration to have passed
908
- currEpoch <= (claim .TermStart + claim .TermMin ) ||
909
- // FIP-0045 requires the sector to be in its last 30 days of life
910
- (currEpoch <= sectorInfo .Expiration - builtin .EndOfLifeClaimDropPeriod ) {
911
- fmt .Printf ("skipping sector %d because claim %d (client f0%s, piece %s) does not live long enough \n " , sectorNumber , claimId , claim .Client , claim .Data )
912
- cannotExtendSector = true
913
- break
908
+ claimExpiration := claim .TermStart + claim .TermMax
909
+ // can be maintained in the extended sector
910
+ if claimExpiration > newExp {
911
+ claimIdsToMaintain = append (claimIdsToMaintain , claimId )
912
+ } else {
913
+ sectorInfo , ok := activeSectorsInfo [sectorNumber ]
914
+ if ! ok {
915
+ return xerrors .Errorf ("failed to find sector in active sector set: %w" , err )
916
+ }
917
+ if ! cctx .Bool ("drop-claims" ) ||
918
+ // FIP-0045 requires the claim minimum duration to have passed
919
+ currEpoch <= (claim .TermStart + claim .TermMin ) ||
920
+ // FIP-0045 requires the sector to be in its last 30 days of life
921
+ (currEpoch <= sectorInfo .Expiration - builtin .EndOfLifeClaimDropPeriod ) {
922
+ fmt .Printf ("skipping sector %d because claim %d (client f0%s, piece %s) does not live long enough \n " , sectorNumber , claimId , claim .Client , claim .Data )
923
+ cannotExtendSector = true
924
+ break
925
+ }
926
+
927
+ claimIdsToDrop = append (claimIdsToDrop , claimId )
914
928
}
915
929
916
- claimIdsToDrop = append (claimIdsToDrop , claimId )
930
+ numbersToExtend = append (numbersToExtend , sectorNumber )
931
+ }
932
+ if cannotExtendSector {
933
+ continue
917
934
}
918
935
919
- numbersToExtend = append (numbersToExtend , sectorNumber )
920
- }
921
- if cannotExtendSector {
922
- continue
936
+ if len (claimIdsToMaintain )+ len (claimIdsToDrop ) != 0 {
937
+ sectorsWithClaims = append (sectorsWithClaims , miner.SectorClaim {
938
+ SectorNumber : sectorNumber ,
939
+ MaintainClaims : claimIdsToMaintain ,
940
+ DropClaims : claimIdsToDrop ,
941
+ })
942
+ }
923
943
}
944
+ }
924
945
925
- if len (claimIdsToMaintain )+ len (claimIdsToDrop ) != 0 {
926
- sectorsWithClaims = append (sectorsWithClaims , miner.SectorClaim {
927
- SectorNumber : sectorNumber ,
928
- MaintainClaims : claimIdsToMaintain ,
929
- DropClaims : claimIdsToDrop ,
930
- })
931
- }
946
+ sectorsWithoutClaimsCount , err := sectorsWithoutClaimsToExtend .Count ()
947
+ if err != nil {
948
+ return xerrors .Errorf ("failed to count cc sectors: %w" , err )
932
949
}
933
- }
934
950
935
- sectorsWithoutClaimsCount , err := sectorsWithoutClaimsToExtend .Count ()
936
- if err != nil {
937
- return xerrors .Errorf ("failed to count cc sectors: %w" , err )
938
- }
951
+ sectorsInDecl := int (sectorsWithoutClaimsCount ) + len (sectorsWithClaims )
952
+ scount += sectorsInDecl
939
953
940
- sectorsInDecl := int (sectorsWithoutClaimsCount ) + len (sectorsWithClaims )
941
- scount += sectorsInDecl
954
+ if scount > addrSectors || len (p .Extensions ) >= declMax {
955
+ params = append (params , p )
956
+ p = miner.ExtendSectorExpiration2Params {}
957
+ scount = sectorsInDecl
958
+ }
942
959
943
- if scount > addrSectors || len (p .Extensions ) >= declMax {
944
- params = append (params , p )
945
- p = miner.ExtendSectorExpiration2Params {}
946
- scount = sectorsInDecl
960
+ p .Extensions = append (p .Extensions , miner.ExpirationExtension2 {
961
+ Deadline : l .Deadline ,
962
+ Partition : l .Partition ,
963
+ Sectors : SectorNumsToBitfield (numbersToExtend ),
964
+ SectorsWithClaims : sectorsWithClaims ,
965
+ NewExpiration : newExp ,
966
+ })
947
967
}
948
968
949
- p .Extensions = append (p .Extensions , miner.ExpirationExtension2 {
950
- Deadline : l .Deadline ,
951
- Partition : l .Partition ,
952
- Sectors : SectorNumsToBitfield (numbersToExtend ),
953
- SectorsWithClaims : sectorsWithClaims ,
954
- NewExpiration : newExp ,
955
- })
956
-
957
969
}
958
970
}
959
971
0 commit comments