2020-08-17 11:48:08 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2022-12-09 11:16:24 +00:00
|
|
|
netmap "github.com/TrueCloudLab/frostfs-api-go/v2/netmap/grpc"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
refsGRPC "github.com/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
2020-08-17 11:48:08 +00:00
|
|
|
)
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (f *Filter) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.Filter
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if f != nil {
|
|
|
|
m = new(netmap.Filter)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(f.key)
|
|
|
|
m.SetValue(f.value)
|
|
|
|
m.SetName(f.name)
|
|
|
|
m.SetOp(OperationToGRPCMessage(f.op))
|
|
|
|
m.SetFilters(FiltersToGRPC(f.filters))
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (f *Filter) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.Filter)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
f.filters, err = FiltersFromGRPC(v.GetFilters())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
f.key = v.GetKey()
|
|
|
|
f.value = v.GetValue()
|
|
|
|
f.name = v.GetName()
|
|
|
|
f.op = OperationFromGRPCMessage(v.GetOp())
|
|
|
|
|
|
|
|
return nil
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func FiltersToGRPC(fs []Filter) (res []*netmap.Filter) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if fs != nil {
|
|
|
|
res = make([]*netmap.Filter, 0, len(fs))
|
|
|
|
|
|
|
|
for i := range fs {
|
|
|
|
res = append(res, fs[i].ToGRPCMessage().(*netmap.Filter))
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func FiltersFromGRPC(fs []*netmap.Filter) (res []Filter, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if fs != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
res = make([]Filter, len(fs))
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range fs {
|
|
|
|
if fs[i] != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
err = res[i].FromGRPCMessage(fs[i])
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Selector) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.Selector
|
|
|
|
|
|
|
|
if s != nil {
|
|
|
|
m = new(netmap.Selector)
|
|
|
|
|
|
|
|
m.SetName(s.name)
|
|
|
|
m.SetAttribute(s.attribute)
|
|
|
|
m.SetFilter(s.filter)
|
|
|
|
m.SetCount(s.count)
|
|
|
|
m.SetClause(ClauseToGRPCMessage(s.clause))
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (s *Selector) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.Selector)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
s.name = v.GetName()
|
|
|
|
s.attribute = v.GetAttribute()
|
|
|
|
s.filter = v.GetFilter()
|
|
|
|
s.count = v.GetCount()
|
|
|
|
s.clause = ClauseFromGRPCMessage(v.GetClause())
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func SelectorsToGRPC(ss []Selector) (res []*netmap.Selector) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if ss != nil {
|
|
|
|
res = make([]*netmap.Selector, 0, len(ss))
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range ss {
|
|
|
|
res = append(res, ss[i].ToGRPCMessage().(*netmap.Selector))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func SelectorsFromGRPC(ss []*netmap.Selector) (res []Selector, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if ss != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
res = make([]Selector, len(ss))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
for i := range ss {
|
|
|
|
if ss[i] != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
err = res[i].FromGRPCMessage(ss[i])
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Replica) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.Replica
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(netmap.Replica)
|
|
|
|
|
|
|
|
m.SetSelector(r.selector)
|
|
|
|
m.SetCount(r.count)
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *Replica) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.Replica)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.selector = v.GetSelector()
|
|
|
|
r.count = v.GetCount()
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func ReplicasToGRPC(rs []Replica) (res []*netmap.Replica) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if rs != nil {
|
|
|
|
res = make([]*netmap.Replica, 0, len(rs))
|
2020-08-17 11:48:08 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range rs {
|
|
|
|
res = append(res, rs[i].ToGRPCMessage().(*netmap.Replica))
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
func ReplicasFromGRPC(rs []*netmap.Replica) (res []Replica, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if rs != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
res = make([]Replica, len(rs))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
for i := range rs {
|
|
|
|
if rs[i] != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
err = res[i].FromGRPCMessage(rs[i])
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PlacementPolicy) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.PlacementPolicy
|
|
|
|
|
|
|
|
if p != nil {
|
|
|
|
m = new(netmap.PlacementPolicy)
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetFilters(FiltersToGRPC(p.filters))
|
|
|
|
m.SetSelectors(SelectorsToGRPC(p.selectors))
|
|
|
|
m.SetReplicas(ReplicasToGRPC(p.replicas))
|
|
|
|
m.SetContainerBackupFactor(p.backupFactor)
|
2021-12-01 13:42:31 +00:00
|
|
|
m.SetSubnetID(p.subnetID.ToGRPCMessage().(*refsGRPC.SubnetID))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
|
|
|
return m
|
2020-08-17 11:48:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (p *PlacementPolicy) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.PlacementPolicy)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 11:48:08 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
p.filters, err = FiltersFromGRPC(v.GetFilters())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
p.selectors, err = SelectorsFromGRPC(v.GetSelectors())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
p.replicas, err = ReplicasFromGRPC(v.GetReplicas())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-12-01 13:42:31 +00:00
|
|
|
subnetID := v.GetSubnetId()
|
|
|
|
if subnetID == nil {
|
|
|
|
p.subnetID = nil
|
|
|
|
} else {
|
|
|
|
if p.subnetID == nil {
|
|
|
|
p.subnetID = new(refs.SubnetID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = p.subnetID.FromGRPCMessage(subnetID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
p.backupFactor = v.GetContainerBackupFactor()
|
2020-09-04 10:05:56 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-09-04 10:05:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-08 10:19:22 +00:00
|
|
|
func ClauseToGRPCMessage(n Clause) netmap.Clause {
|
|
|
|
return netmap.Clause(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ClauseFromGRPCMessage(n netmap.Clause) Clause {
|
|
|
|
return Clause(n)
|
|
|
|
}
|
|
|
|
|
2020-09-04 10:05:56 +00:00
|
|
|
func OperationToGRPCMessage(n Operation) netmap.Operation {
|
|
|
|
return netmap.Operation(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func OperationFromGRPCMessage(n netmap.Operation) Operation {
|
|
|
|
return Operation(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NodeStateToGRPCMessage(n NodeState) netmap.NodeInfo_State {
|
|
|
|
return netmap.NodeInfo_State(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NodeStateFromRPCMessage(n netmap.NodeInfo_State) NodeState {
|
|
|
|
return NodeState(n)
|
2020-08-17 11:48:08 +00:00
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NodeInfo_Attribute
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if a != nil {
|
|
|
|
m = new(netmap.NodeInfo_Attribute)
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(a.key)
|
|
|
|
m.SetValue(a.value)
|
|
|
|
m.SetParents(a.parents)
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NodeInfo_Attribute)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
a.key = v.GetKey()
|
|
|
|
a.value = v.GetValue()
|
|
|
|
a.parents = v.GetParents()
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 07:40:22 +00:00
|
|
|
func AttributesToGRPC(as []Attribute) (res []*netmap.NodeInfo_Attribute) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if as != nil {
|
|
|
|
res = make([]*netmap.NodeInfo_Attribute, 0, len(as))
|
|
|
|
|
|
|
|
for i := range as {
|
|
|
|
res = append(res, as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute))
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2022-03-02 07:40:22 +00:00
|
|
|
func AttributesFromGRPC(as []*netmap.NodeInfo_Attribute) (res []Attribute, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if as != nil {
|
2022-03-02 07:40:22 +00:00
|
|
|
res = make([]Attribute, len(as))
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range as {
|
|
|
|
if as[i] != nil {
|
2022-03-02 07:40:22 +00:00
|
|
|
err = res[i].FromGRPCMessage(as[i])
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (ni *NodeInfo) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NodeInfo
|
|
|
|
|
|
|
|
if ni != nil {
|
|
|
|
m = new(netmap.NodeInfo)
|
|
|
|
|
|
|
|
m.SetPublicKey(ni.publicKey)
|
2021-06-18 16:08:55 +00:00
|
|
|
m.SetAddresses(ni.addresses)
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetState(NodeStateToGRPCMessage(ni.state))
|
|
|
|
m.SetAttributes(AttributesToGRPC(ni.attributes))
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (ni *NodeInfo) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NodeInfo)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
ni.attributes, err = AttributesFromGRPC(v.GetAttributes())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
ni.publicKey = v.GetPublicKey()
|
2021-06-18 16:08:55 +00:00
|
|
|
ni.addresses = v.GetAddresses()
|
2021-03-12 12:57:23 +00:00
|
|
|
ni.state = NodeStateFromRPCMessage(v.GetState())
|
2020-09-01 07:46:20 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-09-01 07:46:20 +00:00
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.LocalNodeInfoRequest_Body
|
|
|
|
|
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.LocalNodeInfoRequest_Body)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.LocalNodeInfoRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.LocalNodeInfoRequest
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.LocalNodeInfoRequest)
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(l.body.ToGRPCMessage().(*netmap.LocalNodeInfoRequest_Body))
|
|
|
|
l.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.LocalNodeInfoRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
l.body = nil
|
|
|
|
} else {
|
|
|
|
if l.body == nil {
|
|
|
|
l.body = new(LocalNodeInfoRequestBody)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = l.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return l.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.LocalNodeInfoResponse_Body
|
|
|
|
|
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.LocalNodeInfoResponse_Body)
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(l.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetNodeInfo(l.nodeInfo.ToGRPCMessage().(*netmap.NodeInfo))
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.LocalNodeInfoResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
l.version = nil
|
|
|
|
} else {
|
|
|
|
if l.version == nil {
|
|
|
|
l.version = new(refs.Version)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = l.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeInfo := v.GetNodeInfo()
|
|
|
|
if nodeInfo == nil {
|
|
|
|
l.nodeInfo = nil
|
|
|
|
} else {
|
|
|
|
if l.nodeInfo == nil {
|
|
|
|
l.nodeInfo = new(NodeInfo)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = l.nodeInfo.FromGRPCMessage(nodeInfo)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LocalNodeInfoResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.LocalNodeInfoResponse
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.LocalNodeInfoResponse)
|
|
|
|
|
|
|
|
m.SetBody(l.body.ToGRPCMessage().(*netmap.LocalNodeInfoResponse_Body))
|
|
|
|
l.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *LocalNodeInfoResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.LocalNodeInfoResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
l.body = nil
|
|
|
|
} else {
|
|
|
|
if l.body == nil {
|
|
|
|
l.body = new(LocalNodeInfoResponseBody)
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = l.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-10-08 11:22:28 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return l.ResponseHeaders.FromMessage(v)
|
2020-10-08 11:22:28 +00:00
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-09-28 08:10:20 +00:00
|
|
|
func (x *NetworkParameter) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkConfig_Parameter
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetworkConfig_Parameter)
|
|
|
|
|
|
|
|
m.SetKey(x.k)
|
|
|
|
m.SetValue(x.v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetworkParameter) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkConfig_Parameter)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
x.k = v.GetKey()
|
|
|
|
x.v = v.GetValue()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetworkConfig) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkConfig
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetworkConfig)
|
|
|
|
|
|
|
|
var ps []*netmap.NetworkConfig_Parameter
|
|
|
|
|
|
|
|
if ln := len(x.ps); ln > 0 {
|
|
|
|
ps = make([]*netmap.NetworkConfig_Parameter, 0, ln)
|
|
|
|
|
|
|
|
for i := 0; i < ln; i++ {
|
|
|
|
ps = append(ps, x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m.SetParameters(ps)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetworkConfig) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkConfig)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2022-03-01 13:41:42 +00:00
|
|
|
ps []NetworkParameter
|
2021-09-28 08:10:20 +00:00
|
|
|
psV2 = v.GetParameters()
|
|
|
|
)
|
|
|
|
|
|
|
|
if psV2 != nil {
|
|
|
|
ln := len(psV2)
|
|
|
|
|
2022-03-01 13:41:42 +00:00
|
|
|
ps = make([]NetworkParameter, ln)
|
2021-09-28 08:10:20 +00:00
|
|
|
|
|
|
|
for i := 0; i < ln; i++ {
|
|
|
|
if psV2[i] != nil {
|
2022-03-01 13:41:42 +00:00
|
|
|
if err := ps[i].FromGRPCMessage(psV2[i]); err != nil {
|
2021-09-28 08:10:20 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x.ps = ps
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (i *NetworkInfo) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkInfo
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if i != nil {
|
|
|
|
m = new(netmap.NetworkInfo)
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetMagicNumber(i.magicNum)
|
|
|
|
m.SetCurrentEpoch(i.curEpoch)
|
2021-09-28 08:10:20 +00:00
|
|
|
m.SetMsPerBlock(i.msPerBlock)
|
|
|
|
m.SetNetworkConfig(i.netCfg.ToGRPCMessage().(*netmap.NetworkConfig))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (i *NetworkInfo) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkInfo)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 08:10:20 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
netCfg := v.GetNetworkConfig()
|
|
|
|
if netCfg == nil {
|
|
|
|
i.netCfg = nil
|
|
|
|
} else {
|
|
|
|
if i.netCfg == nil {
|
|
|
|
i.netCfg = new(NetworkConfig)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = i.netCfg.FromGRPCMessage(netCfg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
i.magicNum = v.GetMagicNumber()
|
|
|
|
i.curEpoch = v.GetCurrentEpoch()
|
2021-09-28 08:10:20 +00:00
|
|
|
i.msPerBlock = v.GetMsPerBlock()
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkInfoRequest_Body
|
|
|
|
|
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.NetworkInfoRequest_Body)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkInfoRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkInfoRequest
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.NetworkInfoRequest)
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(l.body.ToGRPCMessage().(*netmap.NetworkInfoRequest_Body))
|
|
|
|
l.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkInfoRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
l.body = nil
|
|
|
|
} else {
|
|
|
|
if l.body == nil {
|
|
|
|
l.body = new(NetworkInfoRequestBody)
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = l.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return l.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *NetworkInfoResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkInfoResponse_Body
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if i != nil {
|
|
|
|
m = new(netmap.NetworkInfoResponse_Body)
|
|
|
|
|
|
|
|
m.SetNetworkInfo(i.netInfo.ToGRPCMessage().(*netmap.NetworkInfo))
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (i *NetworkInfoResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkInfoResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
netInfo := v.GetNetworkInfo()
|
|
|
|
if netInfo == nil {
|
|
|
|
i.netInfo = nil
|
|
|
|
} else {
|
|
|
|
if i.netInfo == nil {
|
|
|
|
i.netInfo = new(NetworkInfo)
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = i.netInfo.FromGRPCMessage(netInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetworkInfoResponse
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if l != nil {
|
|
|
|
m = new(netmap.NetworkInfoResponse)
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(l.body.ToGRPCMessage().(*netmap.NetworkInfoResponse_Body))
|
|
|
|
l.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *NetworkInfoResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetworkInfoResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
l.body = nil
|
|
|
|
} else {
|
|
|
|
if l.body == nil {
|
|
|
|
l.body = new(NetworkInfoResponseBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = l.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2021-02-17 17:17:44 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return l.ResponseHeaders.FromMessage(v)
|
2021-02-17 17:17:44 +00:00
|
|
|
}
|
2022-09-17 09:59:54 +00:00
|
|
|
|
|
|
|
func (x *NetMap) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.Netmap
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.Netmap)
|
|
|
|
|
|
|
|
m.SetEpoch(x.epoch)
|
|
|
|
|
|
|
|
if x.nodes != nil {
|
|
|
|
nodes := make([]*netmap.NodeInfo, len(x.nodes))
|
|
|
|
|
|
|
|
for i := range x.nodes {
|
|
|
|
nodes[i] = x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
m.SetNodes(nodes)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *NetMap) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.Netmap)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
nodes := v.GetNodes()
|
|
|
|
if nodes == nil {
|
|
|
|
x.nodes = nil
|
|
|
|
} else {
|
|
|
|
x.nodes = make([]NodeInfo, len(nodes))
|
|
|
|
|
|
|
|
for i := range nodes {
|
|
|
|
err = x.nodes[i].FromGRPCMessage(nodes[i])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x.epoch = v.GetEpoch()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetmapSnapshotRequest_Body
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetmapSnapshotRequest_Body)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetmapSnapshotRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetmapSnapshotRequest
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetmapSnapshotRequest)
|
|
|
|
|
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*netmap.NetmapSnapshotRequest_Body))
|
|
|
|
x.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetmapSnapshotRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
|
|
|
x.body = new(SnapshotRequestBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetmapSnapshotResponse_Body
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetmapSnapshotResponse_Body)
|
|
|
|
|
|
|
|
m.SetNetmap(x.netMap.ToGRPCMessage().(*netmap.Netmap))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetmapSnapshotResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
netMap := v.GetNetmap()
|
|
|
|
if netMap == nil {
|
|
|
|
x.netMap = nil
|
|
|
|
} else {
|
|
|
|
if x.netMap == nil {
|
|
|
|
x.netMap = new(NetMap)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.netMap.FromGRPCMessage(netMap)
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *netmap.NetmapSnapshotResponse
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(netmap.NetmapSnapshotResponse)
|
|
|
|
|
|
|
|
m.SetBody(x.body.ToGRPCMessage().(*netmap.NetmapSnapshotResponse_Body))
|
|
|
|
x.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *SnapshotResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*netmap.NetmapSnapshotResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
x.body = nil
|
|
|
|
} else {
|
|
|
|
if x.body == nil {
|
|
|
|
x.body = new(SnapshotResponseBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return x.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|