[#1147] node: Use public fields for shard.ExistsPrm

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-05-30 09:26:06 +03:00 committed by Evgenii Stratonikov
parent c1af13b47e
commit 92e19feb57
9 changed files with 26 additions and 30 deletions

View file

@ -13,8 +13,10 @@ import (
// ExistsPrm groups the parameters of Exists operation.
type ExistsPrm struct {
addr oid.Address
paddr oid.Address
// Exists option to set object checked for existence.
Address oid.Address
// Exists option to set parent object checked for existence.
ParentAddress oid.Address
}
// ExistsRes groups the resulting values of Exists operation.
@ -23,16 +25,6 @@ type ExistsRes struct {
lc bool
}
// SetAddress is an Exists option to set object checked for existence.
func (p *ExistsPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
// SetParentAddress is an Exists option to set parent object checked for existence.
func (p *ExistsPrm) SetParentAddress(addr oid.Address) {
p.paddr = addr
}
// Exists returns the fact that the object is in the shard.
func (p ExistsRes) Exists() bool {
return p.ex
@ -55,7 +47,7 @@ func (s *Shard) Exists(ctx context.Context, prm ExistsPrm) (ExistsRes, error) {
ctx, span := tracing.StartSpanFromContext(ctx, "Shard.Exists",
trace.WithAttributes(
attribute.String("shard_id", s.ID().String()),
attribute.String("address", prm.addr.EncodeToString()),
attribute.String("address", prm.Address.EncodeToString()),
))
defer span.End()
@ -70,15 +62,15 @@ func (s *Shard) Exists(ctx context.Context, prm ExistsPrm) (ExistsRes, error) {
return ExistsRes{}, ErrShardDisabled
} else if s.info.Mode.NoMetabase() {
var p common.ExistsPrm
p.Address = prm.addr
p.Address = prm.Address
var res common.ExistsRes
res, err = s.blobStor.Exists(ctx, p)
exists = res.Exists
} else {
var existsPrm meta.ExistsPrm
existsPrm.SetAddress(prm.addr)
existsPrm.SetParent(prm.paddr)
existsPrm.SetAddress(prm.Address)
existsPrm.SetParent(prm.ParentAddress)
var res meta.ExistsRes
res, err = s.metaBase.Exists(ctx, existsPrm)