[#50] object/head: Add right child to Head operation result

Head service receives right child of the processing object in some cases.
Add right child to Head result in order to use it as needed.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-25 15:42:28 +03:00 committed by Alex Vanin
parent 3692f708ca
commit dd16f568c3
2 changed files with 10 additions and 3 deletions

View file

@ -5,9 +5,13 @@ import (
) )
type Response struct { type Response struct {
hdr *object.Object hdr, rightChild *object.Object
} }
func (r *Response) Header() *object.Object { func (r *Response) Header() *object.Object {
return r.hdr return r.hdr
} }
func (r *Response) RightChild() *object.Object {
return r.rightChild
}

View file

@ -77,15 +77,18 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) {
addr.SetContainerID(prm.addr.GetContainerID()) addr.SetContainerID(prm.addr.GetContainerID())
addr.SetObjectID(rightChildID) addr.SetObjectID(rightChildID)
rightChild, err := s.Head(ctx, new(Prm).WithAddress(addr)) r, err = s.Head(ctx, new(Prm).WithAddress(addr))
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "(%T) could not get right child header", s) return nil, errors.Wrapf(err, "(%T) could not get right child header", s)
} }
rightChild := r.Header()
// TODO: check if received parent has requested address // TODO: check if received parent has requested address
return &Response{ return &Response{
hdr: object.NewFromSDK(rightChild.Header().GetParent()), hdr: object.NewFromSDK(rightChild.GetParent()),
rightChild: rightChild,
}, nil }, nil
} }