2020-09-30 10:52:14 +00:00
|
|
|
package deletesvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
|
|
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
2022-01-26 12:11:13 +00:00
|
|
|
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
2020-09-30 10:52:14 +00:00
|
|
|
)
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
type tombstoneBodyWriter struct {
|
|
|
|
body *objectV2.DeleteResponseBody
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteResponseBody) (*deletesvc.Prm, error) {
|
2021-01-12 14:55:02 +00:00
|
|
|
commonPrm, err := util.CommonPrmFromV2(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
p := new(deletesvc.Prm)
|
2021-10-26 13:02:46 +00:00
|
|
|
p.SetCommonParameters(commonPrm)
|
2020-12-11 08:04:04 +00:00
|
|
|
|
2020-09-30 10:52:14 +00:00
|
|
|
body := req.GetBody()
|
2022-01-26 12:11:13 +00:00
|
|
|
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
|
2020-12-11 08:04:04 +00:00
|
|
|
p.WithTombstoneAddressTarget(&tombstoneBodyWriter{
|
|
|
|
body: respBody,
|
|
|
|
})
|
2020-09-30 10:52:14 +00:00
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
return p, nil
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 12:11:13 +00:00
|
|
|
func (w *tombstoneBodyWriter) SetAddress(addr *addressSDK.Address) {
|
2020-12-11 08:04:04 +00:00
|
|
|
w.body.SetTombstone(addr.ToV2())
|
|
|
|
}
|