From 5cb6e9cf545b99487f2547c167f697d499622278 Mon Sep 17 00:00:00 2001 From: notanatol Date: Mon, 26 Feb 2024 03:11:14 -0600 Subject: [PATCH] fix: remove hack --- pkg/storer/fix_refcnt.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/storer/fix_refcnt.go b/pkg/storer/fix_refcnt.go index 0bc9f46152f..5cb42780225 100644 --- a/pkg/storer/fix_refcnt.go +++ b/pkg/storer/fix_refcnt.go @@ -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 @@ -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 @@ -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 {