Skip to content

Commit

Permalink
fix: remove hack
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Feb 26, 2024
1 parent ad22034 commit 5cb6e9c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/storer/fix_refcnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ import (
"github.com/ethersphere/bee/pkg/swarm"
)

type ItemInfo struct {
item *chunkstore.RetrievalIndexItem
pinCnt uint32
reserveCnt uint32
cacheCnt uint32
uploadCnt uint32
batches [][]byte
}

// FixRefCnt attempts to correct the RefCnt in all RetrievalIndexItems by scanning the actual chunk referers.
func FixRefCnt(ctx context.Context, basePath string, opts *Options, repair bool) error {
logger := opts.Logger
Expand Down Expand Up @@ -71,15 +80,6 @@ func FixRefCnt(ctx context.Context, basePath string, opts *Options, repair bool)
logger.Info("pin count finished", "total", pinTotal, "elapsed", time.Since(startPinCount).Round(time.Second))
}

type ItemInfo struct {
item *chunkstore.RetrievalIndexItem
pinCnt uint32
reserveCnt uint32
cacheCnt uint32
uploadCnt uint32
batches [][]byte
}

start := time.Now()
repaired := 0
processed := 0
Expand Down Expand Up @@ -226,7 +226,7 @@ func FixRefCnt(ctx context.Context, basePath string, opts *Options, repair bool)
refs := make(map[uint32]uint32)
for _, item := range items {
refs[item.item.RefCnt]++
newRefCnt := item.pinCnt*100 + item.reserveCnt + item.cacheCnt + item.uploadCnt
newRefCnt := item.pinCnt + item.reserveCnt + item.cacheCnt + item.uploadCnt
if newRefCnt != item.item.RefCnt {
discovered++
if item.item.RefCnt == 1 && newRefCnt == 0 {
Expand Down

0 comments on commit 5cb6e9c

Please sign in to comment.