diff --git a/accounting/grpc/service.pb.go b/accounting/grpc/service.pb.go index bbaefff..7c745ac 100644 Binary files a/accounting/grpc/service.pb.go and b/accounting/grpc/service.pb.go differ diff --git a/accounting/grpc/service_grpc.pb.go b/accounting/grpc/service_grpc.pb.go index 0f4d18d..beec45e 100644 Binary files a/accounting/grpc/service_grpc.pb.go and b/accounting/grpc/service_grpc.pb.go differ diff --git a/accounting/grpc/types.pb.go b/accounting/grpc/types.pb.go index 7628708..883a041 100644 Binary files a/accounting/grpc/types.pb.go and b/accounting/grpc/types.pb.go differ diff --git a/acl/grpc/types.pb.go b/acl/grpc/types.pb.go index 9bfca6a..9d5934a 100644 Binary files a/acl/grpc/types.pb.go and b/acl/grpc/types.pb.go differ diff --git a/audit/grpc/types.pb.go b/audit/grpc/types.pb.go index 29ef6ea..bd1d59b 100644 Binary files a/audit/grpc/types.pb.go and b/audit/grpc/types.pb.go differ diff --git a/container/grpc/service.pb.go b/container/grpc/service.pb.go index 78f8825..1e83d89 100644 Binary files a/container/grpc/service.pb.go and b/container/grpc/service.pb.go differ diff --git a/container/grpc/service_grpc.pb.go b/container/grpc/service_grpc.pb.go index ec0a971..e84c9b9 100644 Binary files a/container/grpc/service_grpc.pb.go and b/container/grpc/service_grpc.pb.go differ diff --git a/container/grpc/types.pb.go b/container/grpc/types.pb.go index d8dd62f..29901f2 100644 Binary files a/container/grpc/types.pb.go and b/container/grpc/types.pb.go differ diff --git a/lock/grpc/types.pb.go b/lock/grpc/types.pb.go index d118ca8..d54ad2f 100644 Binary files a/lock/grpc/types.pb.go and b/lock/grpc/types.pb.go differ diff --git a/netmap/convert.go b/netmap/convert.go index 14c3792..d2121b1 100644 --- a/netmap/convert.go +++ b/netmap/convert.go @@ -754,3 +754,181 @@ func (l *NetworkInfoResponse) FromGRPCMessage(m grpc.Message) error { return l.ResponseHeaders.FromMessage(v) } + +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) +} diff --git a/netmap/grpc/service.go b/netmap/grpc/service.go index 0061631..c97f8be 100644 --- a/netmap/grpc/service.go +++ b/netmap/grpc/service.go @@ -79,3 +79,38 @@ func (x *NetworkInfoResponse) SetMetaHeader(v *session.ResponseMetaHeader) { func (x *NetworkInfoResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) { x.VerifyHeader = v } + +// SetBody sets body of the request. +func (x *NetmapSnapshotRequest) SetBody(v *NetmapSnapshotRequest_Body) { + x.Body = v +} + +// SetMetaHeader sets meta header of the request. +func (x *NetmapSnapshotRequest) SetMetaHeader(v *session.RequestMetaHeader) { + x.MetaHeader = v +} + +// SetVerifyHeader sets verification header of the request. +func (x *NetmapSnapshotRequest) SetVerifyHeader(v *session.RequestVerificationHeader) { + x.VerifyHeader = v +} + +// SetNetmap sets current Netmap. +func (x *NetmapSnapshotResponse_Body) SetNetmap(v *Netmap) { + x.Netmap = v +} + +// SetBody sets body of the response. +func (x *NetmapSnapshotResponse) SetBody(v *NetmapSnapshotResponse_Body) { + x.Body = v +} + +// SetMetaHeader sets meta header of the response. +func (x *NetmapSnapshotResponse) SetMetaHeader(v *session.ResponseMetaHeader) { + x.MetaHeader = v +} + +// SetVerifyHeader sets verification header of the response. +func (x *NetmapSnapshotResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) { + x.VerifyHeader = v +} diff --git a/netmap/grpc/service.pb.go b/netmap/grpc/service.pb.go index c200940..f062929 100644 Binary files a/netmap/grpc/service.pb.go and b/netmap/grpc/service.pb.go differ diff --git a/netmap/grpc/service_grpc.pb.go b/netmap/grpc/service_grpc.pb.go index e27cd2c..34c6f80 100644 Binary files a/netmap/grpc/service_grpc.pb.go and b/netmap/grpc/service_grpc.pb.go differ diff --git a/netmap/grpc/types.go b/netmap/grpc/types.go index 940404a..c555180 100644 --- a/netmap/grpc/types.go +++ b/netmap/grpc/types.go @@ -202,3 +202,13 @@ func (x *NetworkConfig_Parameter) SetValue(v []byte) { func (x *NetworkConfig) SetParameters(v []*NetworkConfig_Parameter) { x.Parameters = v } + +// SetEpoch sets revision number of the Netmap. +func (x *Netmap) SetEpoch(v uint64) { + x.Epoch = v +} + +// SetNodes sets nodes presented in the Netmap. +func (x *Netmap) SetNodes(v []*NodeInfo) { + x.Nodes = v +} diff --git a/netmap/grpc/types.pb.go b/netmap/grpc/types.pb.go index a5fd6e5..265bc24 100644 Binary files a/netmap/grpc/types.pb.go and b/netmap/grpc/types.pb.go differ diff --git a/netmap/marshal.go b/netmap/marshal.go index b7f6e08..fcbf920 100644 --- a/netmap/marshal.go +++ b/netmap/marshal.go @@ -481,3 +481,74 @@ func (i *NetworkInfoResponseBody) StableSize() (size int) { func (i *NetworkInfoResponseBody) Unmarshal(data []byte) error { return message.Unmarshal(i, data, new(netmap.NetworkInfoResponse_Body)) } + +const ( + _ = iota + fNumNetMapEpoch + fNumNetMapNodes +) + +func (x *NetMap) StableMarshal(buf []byte) []byte { + if x == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, x.StableSize()) + } + + offset := protoutil.UInt64Marshal(fNumNetMapEpoch, buf, x.epoch) + + for i := range x.nodes { + offset += protoutil.NestedStructureMarshal(fNumNetMapNodes, buf[offset:], &x.nodes[i]) + } + + return buf +} + +func (x *NetMap) StableSize() (size int) { + if x != nil { + size = protoutil.UInt64Size(fNumNetMapEpoch, x.epoch) + + for i := range x.nodes { + size += protoutil.NestedStructureSize(fNumNetMapNodes, &x.nodes[i]) + } + } + + return +} + +func (x *SnapshotRequestBody) StableMarshal([]byte) []byte { + return nil +} + +func (x *SnapshotRequestBody) StableSize() int { + return 0 +} + +const ( + _ = iota + fNumSnapshotResponseBodyNetMap +) + +func (x *SnapshotResponseBody) StableMarshal(buf []byte) []byte { + if x == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, x.StableSize()) + } + + protoutil.NestedStructureMarshal(fNumSnapshotResponseBodyNetMap, buf, x.netMap) + + return buf +} + +func (x *SnapshotResponseBody) StableSize() (size int) { + if x != nil { + size = protoutil.NestedStructureSize(fNumSnapshotResponseBodyNetMap, x.netMap) + } + + return +} diff --git a/netmap/message_test.go b/netmap/message_test.go index bbe6368..92a6027 100644 --- a/netmap/message_test.go +++ b/netmap/message_test.go @@ -23,5 +23,10 @@ func TestMessageConvert(t *testing.T) { func(empty bool) message.Message { return netmaptest.GenerateNetworkInfo(empty) }, func(empty bool) message.Message { return netmaptest.GenerateNetworkInfoRequest(empty) }, func(empty bool) message.Message { return netmaptest.GenerateNetworkInfoResponseBody(empty) }, + func(empty bool) message.Message { return netmaptest.GenerateNetMap(empty) }, + func(empty bool) message.Message { return netmaptest.GenerateSnapshotRequestBody(empty) }, + func(empty bool) message.Message { return netmaptest.GenerateSnapshotRequest(empty) }, + func(empty bool) message.Message { return netmaptest.GenerateSnapshotResponseBody(empty) }, + func(empty bool) message.Message { return netmaptest.GenerateSnapshotResponse(empty) }, ) } diff --git a/netmap/test/generate.go b/netmap/test/generate.go index 7040550..87cdc50 100644 --- a/netmap/test/generate.go +++ b/netmap/test/generate.go @@ -267,3 +267,57 @@ func GenerateNetworkInfoResponse(empty bool) *netmap.NetworkInfoResponse { return m } + +func GenerateNetMap(empty bool) *netmap.NetMap { + m := new(netmap.NetMap) + + if !empty { + m.SetEpoch(987) + m.SetNodes([]netmap.NodeInfo{ + *GenerateNodeInfo(false), + *GenerateNodeInfo(false), + }) + } + + return m +} + +func GenerateSnapshotRequestBody(_ bool) *netmap.SnapshotRequestBody { + return new(netmap.SnapshotRequestBody) +} + +func GenerateSnapshotRequest(empty bool) *netmap.SnapshotRequest { + m := new(netmap.SnapshotRequest) + + if !empty { + m.SetBody(GenerateSnapshotRequestBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GenerateSnapshotResponseBody(empty bool) *netmap.SnapshotResponseBody { + m := new(netmap.SnapshotResponseBody) + + if !empty { + m.SetNetMap(GenerateNetMap(false)) + } + + return m +} + +func GenerateSnapshotResponse(empty bool) *netmap.SnapshotResponse { + m := new(netmap.SnapshotResponse) + + if !empty { + m.SetBody(GenerateSnapshotResponseBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +} diff --git a/netmap/types.go b/netmap/types.go index 122dda1..b581d3e 100644 --- a/netmap/types.go +++ b/netmap/types.go @@ -650,3 +650,98 @@ func (l *NetworkInfoResponse) GetBody() *NetworkInfoResponseBody { func (l *NetworkInfoResponse) SetBody(body *NetworkInfoResponseBody) { l.body = body } + +// NetMap represents structure of NeoFS network map. +type NetMap struct { + epoch uint64 + + nodes []NodeInfo +} + +// Epoch returns revision number of the NetMap. +func (x *NetMap) Epoch() uint64 { + if x != nil { + return x.epoch + } + + return 0 +} + +// SetEpoch sets revision number of the NetMap. +func (x *NetMap) SetEpoch(v uint64) { + x.epoch = v +} + +// Nodes returns nodes presented in the NetMap. +func (x *NetMap) Nodes() []NodeInfo { + if x != nil { + return x.nodes + } + + return nil +} + +// SetNodes sets nodes presented in the NetMap. +func (x *NetMap) SetNodes(v []NodeInfo) { + x.nodes = v +} + +// SnapshotRequestBody represents structure of Snapshot request body. +type SnapshotRequestBody struct{} + +// SnapshotRequest represents structure of Snapshot request. +type SnapshotRequest struct { + body *SnapshotRequestBody + + session.RequestHeaders +} + +func (x *SnapshotRequest) GetBody() *SnapshotRequestBody { + if x != nil { + return x.body + } + + return nil +} + +func (x *SnapshotRequest) SetBody(body *SnapshotRequestBody) { + x.body = body +} + +// SnapshotResponseBody represents structure of Snapshot response body. +type SnapshotResponseBody struct { + netMap *NetMap +} + +// NetMap returns current NetMap. +func (x *SnapshotResponseBody) NetMap() *NetMap { + if x != nil { + return x.netMap + } + + return nil +} + +// SetNetMap sets current NetMap. +func (x *SnapshotResponseBody) SetNetMap(netMap *NetMap) { + x.netMap = netMap +} + +// SnapshotResponse represents structure of Snapshot response. +type SnapshotResponse struct { + body *SnapshotResponseBody + + session.ResponseHeaders +} + +func (x *SnapshotResponse) GetBody() *SnapshotResponseBody { + if x != nil { + return x.body + } + + return nil +} + +func (x *SnapshotResponse) SetBody(body *SnapshotResponseBody) { + x.body = body +} diff --git a/object/grpc/service.pb.go b/object/grpc/service.pb.go index 7f15f44..b0aa9bc 100644 Binary files a/object/grpc/service.pb.go and b/object/grpc/service.pb.go differ diff --git a/object/grpc/service_grpc.pb.go b/object/grpc/service_grpc.pb.go index 72d9eb4..93e5f22 100644 Binary files a/object/grpc/service_grpc.pb.go and b/object/grpc/service_grpc.pb.go differ diff --git a/object/grpc/types.pb.go b/object/grpc/types.pb.go index e1243b5..4809930 100644 Binary files a/object/grpc/types.pb.go and b/object/grpc/types.pb.go differ diff --git a/refs/grpc/types.pb.go b/refs/grpc/types.pb.go index be27e87..2879803 100644 Binary files a/refs/grpc/types.pb.go and b/refs/grpc/types.pb.go differ diff --git a/reputation/grpc/service.pb.go b/reputation/grpc/service.pb.go index 83317ee..c5c3a2d 100644 Binary files a/reputation/grpc/service.pb.go and b/reputation/grpc/service.pb.go differ diff --git a/reputation/grpc/service_grpc.pb.go b/reputation/grpc/service_grpc.pb.go index 545736b..29de655 100644 Binary files a/reputation/grpc/service_grpc.pb.go and b/reputation/grpc/service_grpc.pb.go differ diff --git a/reputation/grpc/types.pb.go b/reputation/grpc/types.pb.go index ff66869..873eab5 100644 Binary files a/reputation/grpc/types.pb.go and b/reputation/grpc/types.pb.go differ diff --git a/rpc/netmap.go b/rpc/netmap.go index b28abef..f67743c 100644 --- a/rpc/netmap.go +++ b/rpc/netmap.go @@ -11,6 +11,7 @@ const serviceNetmap = serviceNamePrefix + "netmap.NetmapService" const ( rpcNetmapNodeInfo = "LocalNodeInfo" rpcNetmapNetInfo = "NetworkInfo" + rpcNetmapSnapshot = "NetmapSnapshot" ) // LocalNodeInfo executes NetmapService.LocalNodeInfo RPC. @@ -44,3 +45,19 @@ func NetworkInfo( return resp, nil } + +// NetMapSnapshot executes NetmapService.NetmapSnapshot RPC. +func NetMapSnapshot( + cli *client.Client, + req *netmap.SnapshotRequest, + opts ...client.CallOption, +) (*netmap.SnapshotResponse, error) { + resp := new(netmap.SnapshotResponse) + + err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceNetmap, rpcNetmapSnapshot), req, resp, opts...) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/session/grpc/service.pb.go b/session/grpc/service.pb.go index 15b645e..0c90cb6 100644 Binary files a/session/grpc/service.pb.go and b/session/grpc/service.pb.go differ diff --git a/session/grpc/service_grpc.pb.go b/session/grpc/service_grpc.pb.go index a596be4..ebda887 100644 Binary files a/session/grpc/service_grpc.pb.go and b/session/grpc/service_grpc.pb.go differ diff --git a/session/grpc/types.pb.go b/session/grpc/types.pb.go index 1fa22f0..81b3f04 100644 Binary files a/session/grpc/types.pb.go and b/session/grpc/types.pb.go differ diff --git a/signature/sign.go b/signature/sign.go index 44ec2c4..ea2e1aa 100644 --- a/signature/sign.go +++ b/signature/sign.go @@ -375,6 +375,10 @@ func serviceMessageBody(req interface{}) stableMarshaler { return v.GetBody() case *netmap.NetworkInfoResponse: return v.GetBody() + case *netmap.SnapshotRequest: + return v.GetBody() + case *netmap.SnapshotResponse: + return v.GetBody() /* Reputation */ case *reputation.AnnounceLocalTrustRequest: diff --git a/status/grpc/types.pb.go b/status/grpc/types.pb.go index 64b257e..b864629 100644 Binary files a/status/grpc/types.pb.go and b/status/grpc/types.pb.go differ diff --git a/storagegroup/grpc/types.pb.go b/storagegroup/grpc/types.pb.go index 1cfe99c..8f5100c 100644 Binary files a/storagegroup/grpc/types.pb.go and b/storagegroup/grpc/types.pb.go differ diff --git a/subnet/grpc/types.pb.go b/subnet/grpc/types.pb.go index 2bec81d..015e66d 100644 Binary files a/subnet/grpc/types.pb.go and b/subnet/grpc/types.pb.go differ diff --git a/tombstone/grpc/types.pb.go b/tombstone/grpc/types.pb.go index d971da2..84b0c3e 100644 Binary files a/tombstone/grpc/types.pb.go and b/tombstone/grpc/types.pb.go differ diff --git a/util/proto/test/test.pb.go b/util/proto/test/test.pb.go index 6ac0c67..f884c08 100644 Binary files a/util/proto/test/test.pb.go and b/util/proto/test/test.pb.go differ