Skip to content

Commit

Permalink
worker: add isUploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Dec 6, 2023
1 parent 0d1301a commit 15bf037
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions worker/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ func (mgr *uploadManager) tryRecomputeStats() {

func (u *upload) finishSlabUpload(upload *slabUpload) {
for _, sector := range upload.sectors {
if sector.uploaded.Root == (types.Hash256{}) {
if !sector.isUploaded() {
sector.cancel()
}
}
Expand Down Expand Up @@ -1458,7 +1458,7 @@ func (s *slabUpload) nextRequest(responseChan chan sectorUploadResp) *sectorUplo
lowestNumOverdrives := math.MaxInt
var nextSector *sectorUpload
for _, sector := range s.sectors {
if sector.uploaded.Root == (types.Hash256{}) && sector.numOverdriving() < lowestNumOverdrives {
if !sector.isUploaded() && sector.numOverdriving() < lowestNumOverdrives {
nextSector = sector
}
}
Expand Down Expand Up @@ -1558,6 +1558,10 @@ func (u *upload) isAllowed(fcid ...types.FileContractID) bool {
return false
}

func (s *sectorUpload) isUploaded() bool {
return s.uploaded.Root != (types.Hash256{})
}

func (s *sectorUpload) numOverdriving() int {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down

0 comments on commit 15bf037

Please sign in to comment.