forked from TrueCloudLab/frostfs-node
[#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes: * avoid package-colliding variable naming * avoid using pointers to IDs where unnecessary * avoid using `idSDK` import alias pattern * use `EncodeToString` for protocol string calculation and `String` for printing Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cc6209e8a0
commit
1c30414a6c
218 changed files with 2095 additions and 2521 deletions
|
@ -1,10 +1,14 @@
|
|||
package deletesvc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
)
|
||||
|
||||
type tombstoneBodyWriter struct {
|
||||
|
@ -12,6 +16,20 @@ type tombstoneBodyWriter struct {
|
|||
}
|
||||
|
||||
func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteResponseBody) (*deletesvc.Prm, error) {
|
||||
body := req.GetBody()
|
||||
|
||||
addrV2 := body.GetAddress()
|
||||
if addrV2 == nil {
|
||||
return nil, errors.New("missing object address")
|
||||
}
|
||||
|
||||
var addr oid.Address
|
||||
|
||||
err := addr.ReadFromV2(*addrV2)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid object address: %w", err)
|
||||
}
|
||||
|
||||
commonPrm, err := util.CommonPrmFromV2(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -20,8 +38,7 @@ func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteRe
|
|||
p := new(deletesvc.Prm)
|
||||
p.SetCommonParameters(commonPrm)
|
||||
|
||||
body := req.GetBody()
|
||||
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
|
||||
p.WithAddress(addr)
|
||||
p.WithTombstoneAddressTarget(&tombstoneBodyWriter{
|
||||
body: respBody,
|
||||
})
|
||||
|
@ -29,6 +46,9 @@ func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteRe
|
|||
return p, nil
|
||||
}
|
||||
|
||||
func (w *tombstoneBodyWriter) SetAddress(addr *addressSDK.Address) {
|
||||
w.body.SetTombstone(addr.ToV2())
|
||||
func (w *tombstoneBodyWriter) SetAddress(addr oid.Address) {
|
||||
var addrV2 refs.Address
|
||||
addr.WriteToV2(&addrV2)
|
||||
|
||||
w.body.SetTombstone(&addrV2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue