2020-08-17 09:12:59 +00:00
|
|
|
package storagegroup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
|
|
|
sg "github.com/nspcc-dev/neofs-api-go/v2/storagegroup/grpc"
|
|
|
|
)
|
|
|
|
|
2020-08-17 12:19:36 +00:00
|
|
|
// StorageGroupToGRPCMessage converts unified proto structure into grpc structure.
|
2020-08-17 09:12:59 +00:00
|
|
|
func StorageGroupToGRPCMessage(s *StorageGroup) *sg.StorageGroup {
|
|
|
|
if s == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(sg.StorageGroup)
|
|
|
|
|
|
|
|
m.SetValidationDataSize(s.GetValidationDataSize())
|
2020-08-20 08:04:16 +00:00
|
|
|
m.SetValidationHash(
|
|
|
|
refs.ChecksumToGRPCMessage(s.GetValidationHash()),
|
|
|
|
)
|
2020-08-17 09:12:59 +00:00
|
|
|
m.SetExpirationEpoch(s.GetExpirationEpoch())
|
|
|
|
|
2020-12-21 07:51:45 +00:00
|
|
|
m.SetMembers(
|
|
|
|
refs.ObjectIDListToGRPCMessage(s.GetMembers()),
|
|
|
|
)
|
2020-08-17 09:12:59 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2020-08-17 12:19:36 +00:00
|
|
|
// StorageGroupFromGRPCMessage converts grpc structure into unified proto structure.
|
2020-08-17 09:12:59 +00:00
|
|
|
func StorageGroupFromGRPCMessage(m *sg.StorageGroup) *StorageGroup {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
s := new(StorageGroup)
|
|
|
|
|
|
|
|
s.SetValidationDataSize(m.GetValidationDataSize())
|
2020-08-20 08:04:16 +00:00
|
|
|
s.SetValidationHash(
|
|
|
|
refs.ChecksumFromGRPCMessage(m.GetValidationHash()),
|
|
|
|
)
|
2020-08-17 09:12:59 +00:00
|
|
|
s.SetExpirationEpoch(m.GetExpirationEpoch())
|
|
|
|
|
2020-12-21 07:51:45 +00:00
|
|
|
s.SetMembers(
|
|
|
|
refs.ObjectIDListFromGRPCMessage(m.GetMembers()),
|
|
|
|
)
|
2020-08-17 09:12:59 +00:00
|
|
|
|
|
|
|
return s
|
|
|
|
}
|