Skip to content

Commit

Permalink
pool: Remove old relations methods
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Jul 6, 2023
1 parent 9ec17c9 commit 4dedbc6
Showing 1 changed file with 0 additions and 110 deletions.
110 changes: 0 additions & 110 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2245,116 +2245,6 @@ func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, p *
return nil
}

// GetSplitInfo implements relations.Relations.
func (p *Pool) GetSplitInfo(ctx context.Context, cnrID cid.ID, objID oid.ID, tokens relations.Tokens) (*object.SplitInfo, error) {
var prm PrmObjectHead
if tokens.Bearer != nil {
prm.UseBearer(*tokens.Bearer)
}
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}
prm.MarkRaw()

res, err := p.HeadObject(ctx, cnrID, objID, prm)

var errSplit *object.SplitInfoError

switch {
case errors.As(err, &errSplit):
return errSplit.SplitInfo(), nil
case err == nil:
if res.SplitID() == nil {
return nil, relations.ErrNoSplitInfo
}

splitInfo := object.NewSplitInfo()
splitInfo.SetSplitID(res.SplitID())
if res.HasParent() {
if len(res.Children()) > 0 {
splitInfo.SetLink(objID)
} else {
splitInfo.SetLastPart(objID)
}
}

return splitInfo, nil
default:
return nil, fmt.Errorf("failed to get raw object header: %w", err)
}
}

// ListChildrenByLinker implements relations.Relations.
func (p *Pool) ListChildrenByLinker(ctx context.Context, cnrID cid.ID, objID oid.ID, tokens relations.Tokens) ([]oid.ID, error) {
var prm PrmObjectHead
if tokens.Bearer != nil {
prm.UseBearer(*tokens.Bearer)
}
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}

res, err := p.HeadObject(ctx, cnrID, objID, prm)
if err != nil {
return nil, fmt.Errorf("failed to get linking object's header: %w", err)
}

return res.Children(), nil
}

// GetLeftSibling implements relations.Relations.
func (p *Pool) GetLeftSibling(ctx context.Context, cnrID cid.ID, objID oid.ID, tokens relations.Tokens) (oid.ID, error) {
var prm PrmObjectHead
if tokens.Bearer != nil {
prm.UseBearer(*tokens.Bearer)
}
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}

res, err := p.HeadObject(ctx, cnrID, objID, prm)
if err != nil {
return oid.ID{}, fmt.Errorf("failed to read split chain member's header: %w", err)
}

idMember, ok := res.PreviousID()
if !ok {
return oid.ID{}, relations.ErrNoLeftSibling
}
return idMember, nil
}

// FindSiblingByParentID implements relations.Relations.
func (p *Pool) FindSiblingByParentID(ctx context.Context, cnrID cid.ID, objID oid.ID, tokens relations.Tokens) ([]oid.ID, error) {
var query object.SearchFilters
query.AddParentIDFilter(object.MatchStringEqual, objID)

var prm PrmObjectSearch
prm.SetFilters(query)
if tokens.Bearer != nil {
prm.UseBearer(*tokens.Bearer)
}
if tokens.Session != nil {
prm.UseSession(*tokens.Session)
}

resSearch, err := p.SearchObjects(ctx, cnrID, prm)
if err != nil {
return nil, fmt.Errorf("failed to find object children: %w", err)
}

var res []oid.ID
err = resSearch.Iterate(func(id oid.ID) bool {
res = append(res, id)
return false
})
if err != nil {
return nil, fmt.Errorf("failed to iterate found objects: %w", err)
}

return res, nil
}

func (p *Pool) sdkClient() (*sdkClient.Client, error) {
conn, err := p.connection()
if err != nil {
Expand Down

0 comments on commit 4dedbc6

Please sign in to comment.