2020-12-10 08:30:14 +00:00
|
|
|
package tombstone
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
2021-11-16 17:30:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
2020-12-10 08:30:14 +00:00
|
|
|
tombstone "github.com/nspcc-dev/neofs-api-go/v2/tombstone/grpc"
|
|
|
|
)
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (s *Tombstone) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *tombstone.Tombstone
|
2020-12-10 08:30:14 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if s != nil {
|
|
|
|
m = new(tombstone.Tombstone)
|
2020-12-10 08:30:14 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members))
|
|
|
|
m.SetExpirationEpoch(s.exp)
|
|
|
|
m.SetSplitId(s.splitID)
|
2020-12-10 08:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (s *Tombstone) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*tombstone.Tombstone)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-12-10 08:30:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-12-10 08:30:14 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-12-10 08:30:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
s.exp = v.GetExpirationEpoch()
|
|
|
|
s.splitID = v.GetSplitId()
|
2020-12-10 08:30:14 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-12-10 08:30:14 +00:00
|
|
|
}
|