Skip to content

Commit

Permalink
internal: export SectorsCache
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Aug 16, 2024
1 parent c9f70ad commit c578d2a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/bus/sectorscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
)

type (
sectorsCache struct {
SectorsCache struct {
mu sync.Mutex
uploads map[api.UploadID]*ongoingUpload
renewedTo map[types.FileContractID]types.FileContractID
Expand All @@ -41,14 +41,14 @@ func (ou *ongoingUpload) sectors(fcid types.FileContractID) (roots []types.Hash2
return
}

func NewSectorsCache() *sectorsCache {
return &sectorsCache{
func NewSectorsCache() *SectorsCache {
return &SectorsCache{
uploads: make(map[api.UploadID]*ongoingUpload),
renewedTo: make(map[types.FileContractID]types.FileContractID),
}
}

func (sc *sectorsCache) AddSector(uID api.UploadID, fcid types.FileContractID, root types.Hash256) error {
func (sc *SectorsCache) AddSector(uID api.UploadID, fcid types.FileContractID, root types.Hash256) error {
sc.mu.Lock()
defer sc.mu.Unlock()

Expand All @@ -62,7 +62,7 @@ func (sc *sectorsCache) AddSector(uID api.UploadID, fcid types.FileContractID, r
return nil
}

func (sc *sectorsCache) FinishUpload(uID api.UploadID) {
func (sc *SectorsCache) FinishUpload(uID api.UploadID) {
sc.mu.Lock()
defer sc.mu.Unlock()
delete(sc.uploads, uID)
Expand All @@ -82,7 +82,7 @@ func (sc *sectorsCache) FinishUpload(uID api.UploadID) {
}
}

func (sc *sectorsCache) HandleRenewal(fcid, renewedFrom types.FileContractID) {
func (sc *SectorsCache) HandleRenewal(fcid, renewedFrom types.FileContractID) {
sc.mu.Lock()
defer sc.mu.Unlock()

Expand All @@ -95,7 +95,7 @@ func (sc *sectorsCache) HandleRenewal(fcid, renewedFrom types.FileContractID) {
sc.renewedTo[renewedFrom] = fcid
}

func (sc *sectorsCache) Pending(fcid types.FileContractID) (size uint64) {
func (sc *SectorsCache) Pending(fcid types.FileContractID) (size uint64) {
sc.mu.Lock()
defer sc.mu.Unlock()

Expand All @@ -106,7 +106,7 @@ func (sc *sectorsCache) Pending(fcid types.FileContractID) (size uint64) {
return
}

func (sc *sectorsCache) Sectors(fcid types.FileContractID) (roots []types.Hash256) {
func (sc *SectorsCache) Sectors(fcid types.FileContractID) (roots []types.Hash256) {
sc.mu.Lock()
defer sc.mu.Unlock()

Expand All @@ -117,7 +117,7 @@ func (sc *sectorsCache) Sectors(fcid types.FileContractID) (roots []types.Hash25
return
}

func (sc *sectorsCache) StartUpload(uID api.UploadID) error {
func (sc *SectorsCache) StartUpload(uID api.UploadID) error {
sc.mu.Lock()
defer sc.mu.Unlock()

Expand All @@ -133,7 +133,7 @@ func (sc *sectorsCache) StartUpload(uID api.UploadID) error {
return nil
}

func (um *sectorsCache) latestFCID(fcid types.FileContractID) types.FileContractID {
func (um *SectorsCache) latestFCID(fcid types.FileContractID) types.FileContractID {
if latest, ok := um.renewedTo[fcid]; ok {
return latest
}
Expand Down

0 comments on commit c578d2a

Please sign in to comment.