diff --git a/pkg/storer/cachestore.go b/pkg/storer/cachestore.go index b4a759e57ac..6cc51e5550e 100644 --- a/pkg/storer/cachestore.go +++ b/pkg/storer/cachestore.go @@ -10,7 +10,7 @@ import ( "fmt" "time" - storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/ethersphere/bee/v2/pkg/storer/internal/transaction" "github.com/ethersphere/bee/v2/pkg/swarm" ) @@ -39,7 +39,7 @@ func (db *DB) cacheWorker(ctx context.Context) { continue } - evict := size - capc + evict := uint64(size - capc) if evict < db.reserveOptions.cacheMinEvictCount { // evict at least a min count evict = db.reserveOptions.cacheMinEvictCount } diff --git a/pkg/storer/internal/cache/cache.go b/pkg/storer/internal/cache/cache.go index 52a2e559d95..bea87954ed8 100644 --- a/pkg/storer/internal/cache/cache.go +++ b/pkg/storer/internal/cache/cache.go @@ -14,7 +14,7 @@ import ( "sync/atomic" "time" - storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/ethersphere/bee/v2/pkg/storer/internal/transaction" "github.com/ethersphere/bee/v2/pkg/swarm" "golang.org/x/sync/errgroup" @@ -61,12 +61,14 @@ func New(ctx context.Context, store storage.Reader, capacity uint64) (*Cache, er } // Size returns the current size of the cache. -func (c *Cache) Size() uint64 { - return uint64(c.size.Load()) +func (c *Cache) Size() int64 { + return c.size.Load() } // Capacity returns the capacity of the cache. -func (c *Cache) Capacity() uint64 { return uint64(c.capacity) } +func (c *Cache) Capacity() int64 { + return int64(c.capacity) +} // Putter returns a Storage.Putter instance which adds the chunk to the underlying // chunkstore and also adds a Cache entry for the chunk. diff --git a/pkg/storer/internal/cache/export_test.go b/pkg/storer/internal/cache/export_test.go index cd552df8b2f..c2ccf11f6b2 100644 --- a/pkg/storer/internal/cache/export_test.go +++ b/pkg/storer/internal/cache/export_test.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/ethersphere/bee/v2/pkg/storer/internal/transaction" "github.com/ethersphere/bee/v2/pkg/swarm" ) @@ -43,7 +43,7 @@ func (c *Cache) RemoveOldestMaxBatch(ctx context.Context, st transaction.Storage func (c *Cache) State(store storage.Reader) CacheState { state := CacheState{} - state.Size = c.Size() + state.Size = uint64(c.Size()) runner := swarm.ZeroAddress err := store.Iterate(