diff --git a/pkg/local_object_storage/engine/container.go b/pkg/local_object_storage/engine/container.go index 81acb71a1a..65a6d4f9b0 100644 --- a/pkg/local_object_storage/engine/container.go +++ b/pkg/local_object_storage/engine/container.go @@ -71,7 +71,10 @@ func (e *StorageEngine) containerSize(prm ContainerSizePrm) (res ContainerSizeRe } e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) { - size, err := shard.ContainerSize(sh.Shard, prm.cnr) + var csPrm shard.ContainerSizePrm + csPrm.WithContainerID(prm.cnr) + + csRes, err := sh.Shard.ContainerSize(csPrm) if err != nil { e.reportShardError(sh, "can't get container size", err, zap.Stringer("container_id", prm.cnr), @@ -79,7 +82,7 @@ func (e *StorageEngine) containerSize(prm ContainerSizePrm) (res ContainerSizeRe return false } - res.size += size + res.size += csRes.Size() return false }) @@ -119,16 +122,16 @@ func (e *StorageEngine) listContainers() (ListContainersRes, error) { uniqueIDs := make(map[string]cid.ID) e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) { - cnrs, err := shard.ListContainers(sh.Shard) + res, err := sh.Shard.ListContainers(shard.ListContainersPrm{}) if err != nil { e.reportShardError(sh, "can't get list of containers", err) return false } - for i := range cnrs { - id := cnrs[i].EncodeToString() + for _, cnr := range res.Containers() { + id := cnr.EncodeToString() if _, ok := uniqueIDs[id]; !ok { - uniqueIDs[id] = cnrs[i] + uniqueIDs[id] = cnr } } diff --git a/pkg/local_object_storage/shard/container.go b/pkg/local_object_storage/shard/container.go index 43e2851d10..5204bf50ef 100644 --- a/pkg/local_object_storage/shard/container.go +++ b/pkg/local_object_storage/shard/container.go @@ -34,12 +34,3 @@ func (s *Shard) ContainerSize(prm ContainerSizePrm) (ContainerSizeRes, error) { size: size, }, nil } - -func ContainerSize(s *Shard, cnr cid.ID) (uint64, error) { - res, err := s.ContainerSize(ContainerSizePrm{cnr: cnr}) - if err != nil { - return 0, err - } - - return res.Size(), nil -} diff --git a/pkg/local_object_storage/shard/list.go b/pkg/local_object_storage/shard/list.go index c899f8635a..4ac240bc4b 100644 --- a/pkg/local_object_storage/shard/list.go +++ b/pkg/local_object_storage/shard/list.go @@ -103,15 +103,6 @@ func (s *Shard) ListContainers(_ ListContainersPrm) (ListContainersRes, error) { }, nil } -func ListContainers(s *Shard) ([]cid.ID, error) { - res, err := s.ListContainers(ListContainersPrm{}) - if err != nil { - return nil, err - } - - return res.Containers(), nil -} - // ListWithCursor lists physical objects available in shard starting from // cursor. Includes regular, tombstone and storage group objects. Does not // include inhumed objects. Use cursor value from response for consecutive requests. @@ -132,21 +123,3 @@ func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error) cursor: res.Cursor(), }, nil } - -// ListWithCursor lists physical objects available in shard starting from -// cursor. Includes regular, tombstone and storage group objects. Does not -// include inhumed objects. Use cursor value from response for consecutive requests. -// -// Returns ErrEndOfListing if there are no more objects to return or count -// parameter set to zero. -func ListWithCursor(s *Shard, count uint32, cursor *Cursor) ([]oid.Address, *Cursor, error) { - var prm ListWithCursorPrm - prm.WithCount(count) - prm.WithCursor(cursor) - res, err := s.ListWithCursor(prm) - if err != nil { - return nil, nil, err - } - - return res.AddressList(), res.Cursor(), nil -}