2021-01-22 11:36:16 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
|
|
|
|
2021-11-10 07:08:33 +00:00
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
2021-01-22 11:36:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ContainerSizePrm struct {
|
2022-05-31 17:00:41 +00:00
|
|
|
cnr cid.ID
|
2021-01-22 11:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ContainerSizeRes struct {
|
|
|
|
size uint64
|
|
|
|
}
|
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
func (p *ContainerSizePrm) WithContainerID(cnr cid.ID) {
|
2021-01-22 11:36:16 +00:00
|
|
|
if p != nil {
|
2022-05-31 17:00:41 +00:00
|
|
|
p.cnr = cnr
|
2021-01-22 11:36:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-20 18:08:59 +00:00
|
|
|
func (r ContainerSizeRes) Size() uint64 {
|
2021-01-22 11:36:16 +00:00
|
|
|
return r.size
|
|
|
|
}
|
|
|
|
|
2022-05-31 11:50:39 +00:00
|
|
|
func (s *Shard) ContainerSize(prm ContainerSizePrm) (ContainerSizeRes, error) {
|
2022-05-31 17:00:41 +00:00
|
|
|
size, err := s.metaBase.ContainerSize(prm.cnr)
|
2021-01-22 11:36:16 +00:00
|
|
|
if err != nil {
|
2022-05-31 11:50:39 +00:00
|
|
|
return ContainerSizeRes{}, fmt.Errorf("could not get container size: %w", err)
|
2021-01-22 11:36:16 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 11:50:39 +00:00
|
|
|
return ContainerSizeRes{
|
2021-01-22 11:36:16 +00:00
|
|
|
size: size,
|
|
|
|
}, nil
|
|
|
|
}
|