From bf53c16e4bf20695e8cfedd893c5ec5f81f6aa5d Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Mon, 2 Sep 2019 11:42:45 +0100 Subject: [PATCH 1/3] Rough outline of Network introspection interface --- network/default.go | 11 +- network/handler/handler.go | 51 +++++++++ network/network.go | 2 + network/proto/network.micro.go | 16 +-- network/proto/network.pb.go | 189 ++++++++++++++++++++++++++++----- network/proto/network.proto | 24 ++++- 6 files changed, 255 insertions(+), 38 deletions(-) create mode 100644 network/handler/handler.go diff --git a/network/default.go b/network/default.go index 1b5669c6..564262e5 100644 --- a/network/default.go +++ b/network/default.go @@ -52,7 +52,7 @@ type network struct { // client is network client client client.Client - // tunClient is a mao of tunnel clients keyed over channel names + // tunClient is a map of tunnel clients keyed over tunnel channel names tunClient map[string]transport.Client sync.RWMutex @@ -118,6 +118,15 @@ func newNetwork(opts ...Option) Network { } } +// Options returns network options +func (n *network) Options() Options { + n.Lock() + options := n.options + n.Unlock() + + return options +} + // Name returns network name func (n *network) Name() string { return n.options.Name diff --git a/network/handler/handler.go b/network/handler/handler.go new file mode 100644 index 00000000..9fe1b3fb --- /dev/null +++ b/network/handler/handler.go @@ -0,0 +1,51 @@ +package handler + +import ( + "context" + + "github.com/micro/go-micro/errors" + "github.com/micro/go-micro/network" + pbNet "github.com/micro/go-micro/network/proto" + pbRtr "github.com/micro/go-micro/router/proto" +) + +// Network implements network handler +type Network struct { + Network network.Network +} + +// ListRoutes returns a list of routing table routes +func (n *Network) ListRoutes(ctx context.Context, req *pbRtr.Request, resp *pbRtr.ListResponse) error { + routes, err := n.Network.Options().Router.Table().List() + if err != nil { + return errors.InternalServerError("go.micro.network", "failed to list routes: %s", err) + } + + var respRoutes []*pbRtr.Route + for _, route := range routes { + respRoute := &pbRtr.Route{ + Service: route.Service, + Address: route.Address, + Gateway: route.Gateway, + Network: route.Network, + Router: route.Router, + Link: route.Link, + Metric: int64(route.Metric), + } + respRoutes = append(respRoutes, respRoute) + } + + resp.Routes = respRoutes + + return nil +} + +// ListNodes returns a list of all accessible nodes in the network +func (n *Network) ListNodes(ctx context.Context, req *pbNet.ListRequest, resp *pbNet.ListResponse) error { + return nil +} + +// ListNeighbours returns a list of immediate neighbours +func (n *Network) ListNeighbours(ctx context.Context, req *pbNet.NeighbourhoodRequest, resp *pbNet.NeighbourhoodResponse) error { + return nil +} diff --git a/network/network.go b/network/network.go index d9d10a55..1c810638 100644 --- a/network/network.go +++ b/network/network.go @@ -21,6 +21,8 @@ var ( // Network is micro network type Network interface { + // Options returns the network options + Options() Options // Name of the network Name() string // Address returns network bind address diff --git a/network/proto/network.micro.go b/network/proto/network.micro.go index fa0eefaf..c114ee96 100644 --- a/network/proto/network.micro.go +++ b/network/proto/network.micro.go @@ -37,7 +37,7 @@ var _ server.Option type NetworkService interface { ListRoutes(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.ListResponse, error) ListNodes(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) - ListNeighbours(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) + Neighbourhood(ctx context.Context, in *NeighbourhoodRequest, opts ...client.CallOption) (*NeighbourhoodResponse, error) } type networkService struct { @@ -78,9 +78,9 @@ func (c *networkService) ListNodes(ctx context.Context, in *ListRequest, opts .. return out, nil } -func (c *networkService) ListNeighbours(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { - req := c.c.NewRequest(c.name, "Network.ListNeighbours", in) - out := new(ListResponse) +func (c *networkService) Neighbourhood(ctx context.Context, in *NeighbourhoodRequest, opts ...client.CallOption) (*NeighbourhoodResponse, error) { + req := c.c.NewRequest(c.name, "Network.Neighbourhood", in) + out := new(NeighbourhoodResponse) err := c.c.Call(ctx, req, out, opts...) if err != nil { return nil, err @@ -93,14 +93,14 @@ func (c *networkService) ListNeighbours(ctx context.Context, in *ListRequest, op type NetworkHandler interface { ListRoutes(context.Context, *proto1.Request, *proto1.ListResponse) error ListNodes(context.Context, *ListRequest, *ListResponse) error - ListNeighbours(context.Context, *ListRequest, *ListResponse) error + Neighbourhood(context.Context, *NeighbourhoodRequest, *NeighbourhoodResponse) error } func RegisterNetworkHandler(s server.Server, hdlr NetworkHandler, opts ...server.HandlerOption) error { type network interface { ListRoutes(ctx context.Context, in *proto1.Request, out *proto1.ListResponse) error ListNodes(ctx context.Context, in *ListRequest, out *ListResponse) error - ListNeighbours(ctx context.Context, in *ListRequest, out *ListResponse) error + Neighbourhood(ctx context.Context, in *NeighbourhoodRequest, out *NeighbourhoodResponse) error } type Network struct { network @@ -121,6 +121,6 @@ func (h *networkHandler) ListNodes(ctx context.Context, in *ListRequest, out *Li return h.NetworkHandler.ListNodes(ctx, in, out) } -func (h *networkHandler) ListNeighbours(ctx context.Context, in *ListRequest, out *ListResponse) error { - return h.NetworkHandler.ListNeighbours(ctx, in, out) +func (h *networkHandler) Neighbourhood(ctx context.Context, in *NeighbourhoodRequest, out *NeighbourhoodResponse) error { + return h.NetworkHandler.Neighbourhood(ctx, in, out) } diff --git a/network/proto/network.pb.go b/network/proto/network.pb.go index 9b5ccbaf..d7853f09 100644 --- a/network/proto/network.pb.go +++ b/network/proto/network.pb.go @@ -93,6 +93,136 @@ func (m *ListResponse) GetNodes() []*Node { return nil } +// NeighbourhoodRequest is sent to query node neighbourhood +type NeighbourhoodRequest struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NeighbourhoodRequest) Reset() { *m = NeighbourhoodRequest{} } +func (m *NeighbourhoodRequest) String() string { return proto.CompactTextString(m) } +func (*NeighbourhoodRequest) ProtoMessage() {} +func (*NeighbourhoodRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8571034d60397816, []int{2} +} + +func (m *NeighbourhoodRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NeighbourhoodRequest.Unmarshal(m, b) +} +func (m *NeighbourhoodRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NeighbourhoodRequest.Marshal(b, m, deterministic) +} +func (m *NeighbourhoodRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_NeighbourhoodRequest.Merge(m, src) +} +func (m *NeighbourhoodRequest) XXX_Size() int { + return xxx_messageInfo_NeighbourhoodRequest.Size(m) +} +func (m *NeighbourhoodRequest) XXX_DiscardUnknown() { + xxx_messageInfo_NeighbourhoodRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_NeighbourhoodRequest proto.InternalMessageInfo + +func (m *NeighbourhoodRequest) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +// NeighbourhoodResponse contains node neighbourhood hierarchy +type NeighbourhoodResponse struct { + Neighbourhood *Neighbour `protobuf:"bytes,1,opt,name=neighbourhood,proto3" json:"neighbourhood,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NeighbourhoodResponse) Reset() { *m = NeighbourhoodResponse{} } +func (m *NeighbourhoodResponse) String() string { return proto.CompactTextString(m) } +func (*NeighbourhoodResponse) ProtoMessage() {} +func (*NeighbourhoodResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8571034d60397816, []int{3} +} + +func (m *NeighbourhoodResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NeighbourhoodResponse.Unmarshal(m, b) +} +func (m *NeighbourhoodResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NeighbourhoodResponse.Marshal(b, m, deterministic) +} +func (m *NeighbourhoodResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_NeighbourhoodResponse.Merge(m, src) +} +func (m *NeighbourhoodResponse) XXX_Size() int { + return xxx_messageInfo_NeighbourhoodResponse.Size(m) +} +func (m *NeighbourhoodResponse) XXX_DiscardUnknown() { + xxx_messageInfo_NeighbourhoodResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_NeighbourhoodResponse proto.InternalMessageInfo + +func (m *NeighbourhoodResponse) GetNeighbourhood() *Neighbour { + if m != nil { + return m.Neighbourhood + } + return nil +} + +// Neighbourhood is node neighbourhood +type Neighbourhood struct { + // network node + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` + // node neighbours + Neighbour []*Neighbour `protobuf:"bytes,2,rep,name=neighbour,proto3" json:"neighbour,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Neighbourhood) Reset() { *m = Neighbourhood{} } +func (m *Neighbourhood) String() string { return proto.CompactTextString(m) } +func (*Neighbourhood) ProtoMessage() {} +func (*Neighbourhood) Descriptor() ([]byte, []int) { + return fileDescriptor_8571034d60397816, []int{4} +} + +func (m *Neighbourhood) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Neighbourhood.Unmarshal(m, b) +} +func (m *Neighbourhood) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Neighbourhood.Marshal(b, m, deterministic) +} +func (m *Neighbourhood) XXX_Merge(src proto.Message) { + xxx_messageInfo_Neighbourhood.Merge(m, src) +} +func (m *Neighbourhood) XXX_Size() int { + return xxx_messageInfo_Neighbourhood.Size(m) +} +func (m *Neighbourhood) XXX_DiscardUnknown() { + xxx_messageInfo_Neighbourhood.DiscardUnknown(m) +} + +var xxx_messageInfo_Neighbourhood proto.InternalMessageInfo + +func (m *Neighbourhood) GetNode() *Node { + if m != nil { + return m.Node + } + return nil +} + +func (m *Neighbourhood) GetNeighbour() []*Neighbour { + if m != nil { + return m.Neighbour + } + return nil +} + // Node is network node type Node struct { // node ide @@ -108,7 +238,7 @@ func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{2} + return fileDescriptor_8571034d60397816, []int{5} } func (m *Node) XXX_Unmarshal(b []byte) error { @@ -156,7 +286,7 @@ func (m *Connect) Reset() { *m = Connect{} } func (m *Connect) String() string { return proto.CompactTextString(m) } func (*Connect) ProtoMessage() {} func (*Connect) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{3} + return fileDescriptor_8571034d60397816, []int{6} } func (m *Connect) XXX_Unmarshal(b []byte) error { @@ -186,7 +316,7 @@ func (m *Connect) GetNode() *Node { // Close is sent when the node disconnects from the network type Close struct { - // network mode + // network node Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -197,7 +327,7 @@ func (m *Close) Reset() { *m = Close{} } func (m *Close) String() string { return proto.CompactTextString(m) } func (*Close) ProtoMessage() {} func (*Close) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{4} + return fileDescriptor_8571034d60397816, []int{7} } func (m *Close) XXX_Unmarshal(b []byte) error { @@ -227,7 +357,7 @@ func (m *Close) GetNode() *Node { // Neighbour is used to nnounce node neighbourhood type Neighbour struct { - // network mode + // network node Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // neighbours Neighbours []*Node `protobuf:"bytes,3,rep,name=neighbours,proto3" json:"neighbours,omitempty"` @@ -240,7 +370,7 @@ func (m *Neighbour) Reset() { *m = Neighbour{} } func (m *Neighbour) String() string { return proto.CompactTextString(m) } func (*Neighbour) ProtoMessage() {} func (*Neighbour) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{5} + return fileDescriptor_8571034d60397816, []int{8} } func (m *Neighbour) XXX_Unmarshal(b []byte) error { @@ -278,6 +408,9 @@ func (m *Neighbour) GetNeighbours() []*Node { func init() { proto.RegisterType((*ListRequest)(nil), "go.micro.network.ListRequest") proto.RegisterType((*ListResponse)(nil), "go.micro.network.ListResponse") + proto.RegisterType((*NeighbourhoodRequest)(nil), "go.micro.network.NeighbourhoodRequest") + proto.RegisterType((*NeighbourhoodResponse)(nil), "go.micro.network.NeighbourhoodResponse") + proto.RegisterType((*Neighbourhood)(nil), "go.micro.network.Neighbourhood") proto.RegisterType((*Node)(nil), "go.micro.network.Node") proto.RegisterType((*Connect)(nil), "go.micro.network.Connect") proto.RegisterType((*Close)(nil), "go.micro.network.Close") @@ -287,24 +420,28 @@ func init() { func init() { proto.RegisterFile("network.proto", fileDescriptor_8571034d60397816) } var fileDescriptor_8571034d60397816 = []byte{ - // 302 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x5d, 0x4b, 0xc3, 0x30, - 0x14, 0xb5, 0xfb, 0x70, 0xec, 0xce, 0x0d, 0xc9, 0x83, 0x84, 0xc2, 0x64, 0xe4, 0x69, 0x88, 0xa6, - 0xb2, 0xa2, 0x4f, 0xbe, 0xed, 0xc1, 0x97, 0x51, 0xb0, 0xff, 0xc0, 0x36, 0xa1, 0x0b, 0xba, 0xdc, - 0x99, 0xa4, 0xf8, 0xc3, 0xfd, 0x03, 0xd2, 0xb4, 0x9b, 0xc5, 0x31, 0x61, 0xf8, 0x96, 0x73, 0xcf, - 0x3d, 0xe7, 0x5e, 0xee, 0x09, 0x8c, 0xb5, 0x74, 0x9f, 0x68, 0xde, 0xf8, 0xd6, 0xa0, 0x43, 0x72, - 0x59, 0x20, 0xdf, 0xa8, 0xdc, 0x20, 0x6f, 0xea, 0x61, 0x5c, 0x28, 0xb7, 0x2e, 0x33, 0x9e, 0xe3, - 0x26, 0xf2, 0x4c, 0x54, 0xe0, 0x5d, 0xfd, 0x30, 0x58, 0x3a, 0x69, 0x22, 0xaf, 0x6c, 0x40, 0x6d, - 0xc3, 0xc6, 0x30, 0x5a, 0x29, 0xeb, 0x52, 0xf9, 0x51, 0x4a, 0xeb, 0xd8, 0x13, 0x5c, 0xd4, 0xd0, - 0x6e, 0x51, 0x5b, 0x49, 0x6e, 0xa1, 0xaf, 0x51, 0x48, 0x4b, 0x83, 0x59, 0x77, 0x3e, 0x5a, 0x5c, - 0xf1, 0xdf, 0x53, 0x79, 0x82, 0x42, 0xa6, 0x75, 0x13, 0xbb, 0x87, 0x5e, 0x05, 0xc9, 0x04, 0x3a, - 0x4a, 0xd0, 0x60, 0x16, 0xcc, 0x87, 0x69, 0x47, 0x09, 0x42, 0x61, 0xf0, 0x2a, 0x84, 0x91, 0xd6, - 0xd2, 0x8e, 0x2f, 0xee, 0x20, 0x7b, 0x80, 0xc1, 0x12, 0xb5, 0x96, 0xb9, 0x23, 0x37, 0xd0, 0xab, - 0x5c, 0xbc, 0xec, 0xf8, 0x24, 0xdf, 0xc3, 0x62, 0xe8, 0x2f, 0xdf, 0xd1, 0xca, 0x93, 0x44, 0x08, - 0xc3, 0x44, 0xaa, 0x62, 0x9d, 0x61, 0x69, 0x4e, 0x11, 0x92, 0x47, 0x00, 0xbd, 0x13, 0x5a, 0xda, - 0xfd, 0xf3, 0x12, 0xad, 0xce, 0xc5, 0x57, 0x00, 0x83, 0xa4, 0x26, 0xc9, 0x33, 0x80, 0x3f, 0x6c, - 0x75, 0x7b, 0x4b, 0xe8, 0x8f, 0xba, 0x49, 0xa3, 0x09, 0x20, 0x9c, 0x1e, 0x30, 0xed, 0x3c, 0xd8, - 0x19, 0x59, 0xc1, 0xb0, 0xaa, 0x54, 0xc3, 0x2c, 0x99, 0x1e, 0x6e, 0xd1, 0x4a, 0x33, 0xbc, 0x3e, - 0x46, 0xef, 0xdd, 0x5e, 0x60, 0xe2, 0xdd, 0xf6, 0x4b, 0xff, 0xdb, 0x32, 0x3b, 0xf7, 0x1f, 0x2b, - 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x19, 0x6e, 0xfe, 0x91, 0xb0, 0x02, 0x00, 0x00, + // 367 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x4e, 0xc2, 0x40, + 0x10, 0x95, 0x02, 0x92, 0x0e, 0x62, 0xcc, 0x46, 0x4d, 0x53, 0x83, 0x21, 0x7b, 0x40, 0x62, 0xb4, + 0x18, 0x88, 0x26, 0x26, 0x5e, 0x0c, 0x07, 0x2f, 0x84, 0x43, 0x8f, 0xde, 0x2c, 0xbb, 0x29, 0x8d, + 0xd2, 0xc1, 0xdd, 0xad, 0xfe, 0x80, 0x1f, 0x6e, 0xba, 0x5d, 0x4a, 0x29, 0x82, 0xe1, 0xd6, 0x99, + 0x79, 0xf3, 0xde, 0xbc, 0xf6, 0x15, 0x5a, 0x31, 0x57, 0xdf, 0x28, 0xde, 0xbd, 0x85, 0x40, 0x85, + 0xe4, 0x24, 0x44, 0x6f, 0x1e, 0x4d, 0x05, 0x7a, 0xa6, 0xef, 0x0e, 0xc3, 0x48, 0xcd, 0x92, 0xc0, + 0x9b, 0xe2, 0xbc, 0xaf, 0x27, 0xfd, 0x10, 0x6f, 0xb3, 0x07, 0x81, 0x89, 0xe2, 0xa2, 0xaf, 0x37, + 0x4d, 0x91, 0xd1, 0xd0, 0x16, 0x34, 0xc7, 0x91, 0x54, 0x3e, 0xff, 0x4c, 0xb8, 0x54, 0xf4, 0x09, + 0x8e, 0xb2, 0x52, 0x2e, 0x30, 0x96, 0x9c, 0xdc, 0x40, 0x3d, 0x46, 0xc6, 0xa5, 0x53, 0xe9, 0x54, + 0x7b, 0xcd, 0xc1, 0xb9, 0x57, 0x56, 0xf5, 0x26, 0xc8, 0xb8, 0x9f, 0x81, 0x68, 0x17, 0x4e, 0x27, + 0x3c, 0x0a, 0x67, 0x01, 0x26, 0x62, 0x86, 0xc8, 0x0c, 0x2b, 0x39, 0x06, 0x2b, 0x62, 0x4e, 0xa5, + 0x53, 0xe9, 0xd9, 0xbe, 0x15, 0x31, 0xfa, 0x0a, 0x67, 0x25, 0x9c, 0x91, 0x7b, 0x4e, 0x5d, 0x16, + 0x06, 0x7a, 0xa7, 0x39, 0xb8, 0xf8, 0x43, 0x76, 0x09, 0xf3, 0xd7, 0x37, 0xe8, 0x17, 0xb4, 0xd6, + 0xb8, 0xc9, 0x35, 0xd4, 0xd2, 0xeb, 0x0c, 0xd5, 0x36, 0x07, 0x1a, 0x43, 0x1e, 0xc1, 0xce, 0xd9, + 0x1c, 0x4b, 0x5b, 0xde, 0xa9, 0xbd, 0x42, 0xd3, 0x3b, 0xa8, 0xa5, 0x44, 0x65, 0xaf, 0xc4, 0x81, + 0xc6, 0x1b, 0x63, 0x82, 0x4b, 0xe9, 0x58, 0xba, 0xb9, 0x2c, 0xe9, 0x3d, 0x34, 0x46, 0x18, 0xc7, + 0x7c, 0xaa, 0xf6, 0xb9, 0x91, 0x0e, 0xa1, 0x3e, 0xfa, 0x40, 0xc9, 0xf7, 0x5a, 0x42, 0xb0, 0xf3, + 0xab, 0xf7, 0x7a, 0x23, 0x0f, 0x00, 0xb9, 0x47, 0xe9, 0x54, 0x77, 0xa6, 0xa0, 0x80, 0x1c, 0xfc, + 0x58, 0xd0, 0x98, 0x64, 0x43, 0xf2, 0x02, 0xa0, 0x43, 0x95, 0xe6, 0x4e, 0x12, 0x67, 0xb5, 0x6d, + 0x92, 0x68, 0x62, 0xe2, 0xb6, 0x37, 0x26, 0xc5, 0x2c, 0xd2, 0x03, 0x32, 0x06, 0x3b, 0xed, 0xa4, + 0x62, 0x92, 0xb4, 0x37, 0xaf, 0x28, 0x24, 0xd9, 0xbd, 0xdc, 0x36, 0xce, 0xd9, 0x82, 0x72, 0x52, + 0xba, 0x3b, 0x3e, 0x75, 0x21, 0xce, 0xee, 0xd5, 0xbf, 0xb8, 0xa5, 0x46, 0x70, 0xa8, 0xff, 0xb2, + 0xe1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x4f, 0xab, 0x3f, 0xbd, 0x03, 0x00, 0x00, } diff --git a/network/proto/network.proto b/network/proto/network.proto index 2b3e3a2c..0fb854d6 100644 --- a/network/proto/network.proto +++ b/network/proto/network.proto @@ -8,7 +8,7 @@ import "github.com/micro/go-micro/router/proto/router.proto"; service Network { rpc ListRoutes(go.micro.router.Request) returns (go.micro.router.ListResponse) {}; rpc ListNodes(ListRequest) returns (ListResponse) {}; - rpc ListNeighbours(ListRequest) returns (ListResponse) {}; + rpc Neighbourhood(NeighbourhoodRequest) returns (NeighbourhoodResponse) {}; } // Empty request @@ -19,6 +19,24 @@ message ListResponse { repeated Node nodes = 1; } +// NeighbourhoodRequest is sent to query node neighbourhood +message NeighbourhoodRequest { + string id = 1; +} + +// NeighbourhoodResponse contains node neighbourhood hierarchy +message NeighbourhoodResponse { + Neighbour neighbourhood = 1; +} + +// Neighbourhood is node neighbourhood +message Neighbourhood { + // network node + Node node = 1; + // node neighbours + repeated Neighbour neighbour = 2; +} + // Node is network node message Node { // node ide @@ -35,13 +53,13 @@ message Connect { // Close is sent when the node disconnects from the network message Close { - // network mode + // network node Node node = 1; } // Neighbour is used to nnounce node neighbourhood message Neighbour { - // network mode + // network node Node node = 1; // neighbours repeated Node neighbours = 3; From 4f5a8492118ca0165b8c3f8373dfe79071a277a5 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Mon, 2 Sep 2019 12:39:26 +0100 Subject: [PATCH 2/3] Added Nodes method to Network interface --- network/default.go | 54 +++++++++++++++++++++++++++++++++++----------- network/network.go | 16 ++++++++++++-- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/network/default.go b/network/default.go index 564262e5..9c0ae579 100644 --- a/network/default.go +++ b/network/default.go @@ -33,12 +33,31 @@ type node struct { id string // address is node address address string - // neighbours are node neightbours + // neighbours maps the node neighbourhood neighbours map[string]*node + // network returns network node is in + network Network +} + +// Id is node ide +func (n *node) Id() string { + return n.id +} + +// Address returns node address +func (n *node) Address() string { + return n.address +} + +// Network returns node network +func (n *node) Network() Network { + return n.network } // network implements Network interface type network struct { + // node is network node + *node // options configure the network options Options // rtr is network router @@ -60,8 +79,6 @@ type network struct { connected bool // closed closes the network closed chan bool - // neighbours maps the node neighbourhood - neighbours map[string]*node } // newNetwork returns a new network node @@ -106,16 +123,24 @@ func newNetwork(opts ...Option) Network { ), ) - return &network{ - options: options, - Router: options.Router, - Proxy: options.Proxy, - Tunnel: options.Tunnel, - server: server, - client: client, - tunClient: make(map[string]transport.Client), - neighbours: make(map[string]*node), + network := &network{ + node: &node{ + id: options.Id, + address: options.Address, + neighbours: make(map[string]*node), + }, + options: options, + Router: options.Router, + Proxy: options.Proxy, + Tunnel: options.Tunnel, + server: server, + client: client, + tunClient: make(map[string]transport.Client), } + + network.node.network = network + + return network } // Options returns network options @@ -695,6 +720,11 @@ func (n *network) Connect() error { return nil } +// Nodes returns a list of all network nodes +func (n *network) Nodes() []Node { + return nil +} + func (n *network) close() error { // stop the server if err := n.server.Stop(); err != nil { diff --git a/network/network.go b/network/network.go index 1c810638..df9c6045 100644 --- a/network/network.go +++ b/network/network.go @@ -21,14 +21,16 @@ var ( // Network is micro network type Network interface { + // Node is network node + Node // Options returns the network options Options() Options // Name of the network Name() string - // Address returns network bind address - Address() string // Connect starts the resolver and tunnel server Connect() error + // Nodes returns list of network nodes + Nodes() []Node // Close stops the tunnel and resolving Close() error // Client is micro client @@ -37,6 +39,16 @@ type Network interface { Server() server.Server } +// Node is network node +type Node interface { + // Id is node id + Id() string + // Address is node bind address + Address() string + // Network is the network node is in + Network() Network +} + // NewNetwork returns a new network interface func NewNetwork(opts ...Option) Network { return newNetwork(opts...) From 86665454e70b2e0dbbb95224b72bb10558a941a6 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Mon, 2 Sep 2019 17:06:21 +0100 Subject: [PATCH 3/3] Implementation of Nodes method. First take on full handler --- network/default.go | 47 +++++++++++++- network/handler/handler.go | 56 ++++++++++++++++- network/network.go | 22 ++++--- network/proto/network.pb.go | 118 ++++++++++-------------------------- network/proto/network.proto | 10 +-- 5 files changed, 146 insertions(+), 107 deletions(-) diff --git a/network/default.go b/network/default.go index 9c0ae579..7be7a68a 100644 --- a/network/default.go +++ b/network/default.go @@ -54,6 +54,16 @@ func (n *node) Network() Network { return n.network } +// Neighbourhood returns node neighbourhood +func (n *node) Neighbourhood() []Node { + var nodes []Node + for _, node := range n.neighbours { + nodes = append(nodes, node) + } + + return nodes +} + // network implements Network interface type network struct { // node is network node @@ -721,8 +731,43 @@ func (n *network) Connect() error { } // Nodes returns a list of all network nodes +// NOTE: this is a naive i.e. inefficient BFS implementation func (n *network) Nodes() []Node { - return nil + // map to track visited nodes + visited := make(map[string]*node) + // queue of the nodes to visit + queue := make([]*node, 1) + queue[0] = n.node + // add the root node to the map of the visited nodes + visited[n.node.id] = n.node + + for { + // pop a node from the queue + qnode := queue[0] + // pop is done by reslicing of the queue + // https://github.com/golang/go/wiki/SliceTricks + queue = queue[1:] + // iterate through all of its neighbours + // mark the visited nodes; enqueue the non-visted + for id, node := range qnode.neighbours { + if _, ok := visited[id]; !ok { + visited[id] = node + queue = append(queue, node) + } + } + // if no nodes are in the queue break + if len(queue) == 0 { + break + } + } + + nodes := make([]Node, 0) + // collecte all the nodes into slice + for _, node := range visited { + nodes = append(nodes, node) + } + + return nodes } func (n *network) close() error { diff --git a/network/handler/handler.go b/network/handler/handler.go index 9fe1b3fb..cd64dbac 100644 --- a/network/handler/handler.go +++ b/network/handler/handler.go @@ -2,6 +2,7 @@ package handler import ( "context" + "sort" "github.com/micro/go-micro/errors" "github.com/micro/go-micro/network" @@ -42,10 +43,61 @@ func (n *Network) ListRoutes(ctx context.Context, req *pbRtr.Request, resp *pbRt // ListNodes returns a list of all accessible nodes in the network func (n *Network) ListNodes(ctx context.Context, req *pbNet.ListRequest, resp *pbNet.ListResponse) error { + nodes := n.Network.Nodes() + + var respNodes []*pbNet.Node + for _, node := range nodes { + respNode := &pbNet.Node{ + Id: node.Id(), + Address: node.Address(), + } + respNodes = append(respNodes, respNode) + } + + resp.Nodes = respNodes + return nil } -// ListNeighbours returns a list of immediate neighbours -func (n *Network) ListNeighbours(ctx context.Context, req *pbNet.NeighbourhoodRequest, resp *pbNet.NeighbourhoodResponse) error { +// Neighbourhood returns a list of immediate neighbours +func (n *Network) Neighbourhood(ctx context.Context, req *pbNet.NeighbourhoodRequest, resp *pbNet.NeighbourhoodResponse) error { + // extract the id of the node to query + id := req.Id + // if no id is passed, we assume local node + if id == "" { + id = n.Network.Id() + } + + // get all the nodes in the network + nodes := n.Network.Nodes() + + var neighbours []*pbNet.Neighbour + // find a node with a given id + i := sort.Search(len(nodes), func(i int) bool { return nodes[i].Id() == id }) + // collect all the nodes in the neighbourhood of the found node + if i < len(nodes) && nodes[i].Id() == id { + for _, neighbour := range nodes[i].Neighbourhood() { + var nodeNeighbours []*pbNet.Node + for _, nodeNeighbour := range neighbour.Neighbourhood() { + nn := &pbNet.Node{ + Id: nodeNeighbour.Id(), + Address: nodeNeighbour.Address(), + } + nodeNeighbours = append(nodeNeighbours, nn) + } + // node is present at node[i] + neighbour := &pbNet.Neighbour{ + Node: &pbNet.Node{ + Id: neighbour.Id(), + Address: neighbour.Address(), + }, + Neighbours: nodeNeighbours, + } + neighbours = append(neighbours, neighbour) + } + } + + resp.Neighbours = neighbours + return nil } diff --git a/network/network.go b/network/network.go index df9c6045..f68cc147 100644 --- a/network/network.go +++ b/network/network.go @@ -19,6 +19,18 @@ var ( AnnounceTime = 30 * time.Second ) +// Node is network node +type Node interface { + // Id is node id + Id() string + // Address is node bind address + Address() string + // Neighbourhood is node neighbourhood + Neighbourhood() []Node + // Network is the network node is in + Network() Network +} + // Network is micro network type Network interface { // Node is network node @@ -39,16 +51,6 @@ type Network interface { Server() server.Server } -// Node is network node -type Node interface { - // Id is node id - Id() string - // Address is node bind address - Address() string - // Network is the network node is in - Network() Network -} - // NewNetwork returns a new network interface func NewNetwork(opts ...Option) Network { return newNetwork(opts...) diff --git a/network/proto/network.pb.go b/network/proto/network.pb.go index d7853f09..a6837679 100644 --- a/network/proto/network.pb.go +++ b/network/proto/network.pb.go @@ -135,10 +135,10 @@ func (m *NeighbourhoodRequest) GetId() string { // NeighbourhoodResponse contains node neighbourhood hierarchy type NeighbourhoodResponse struct { - Neighbourhood *Neighbour `protobuf:"bytes,1,opt,name=neighbourhood,proto3" json:"neighbourhood,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Neighbours []*Neighbour `protobuf:"bytes,1,rep,name=neighbours,proto3" json:"neighbours,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *NeighbourhoodResponse) Reset() { *m = NeighbourhoodResponse{} } @@ -166,59 +166,9 @@ func (m *NeighbourhoodResponse) XXX_DiscardUnknown() { var xxx_messageInfo_NeighbourhoodResponse proto.InternalMessageInfo -func (m *NeighbourhoodResponse) GetNeighbourhood() *Neighbour { +func (m *NeighbourhoodResponse) GetNeighbours() []*Neighbour { if m != nil { - return m.Neighbourhood - } - return nil -} - -// Neighbourhood is node neighbourhood -type Neighbourhood struct { - // network node - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - // node neighbours - Neighbour []*Neighbour `protobuf:"bytes,2,rep,name=neighbour,proto3" json:"neighbour,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Neighbourhood) Reset() { *m = Neighbourhood{} } -func (m *Neighbourhood) String() string { return proto.CompactTextString(m) } -func (*Neighbourhood) ProtoMessage() {} -func (*Neighbourhood) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{4} -} - -func (m *Neighbourhood) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Neighbourhood.Unmarshal(m, b) -} -func (m *Neighbourhood) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Neighbourhood.Marshal(b, m, deterministic) -} -func (m *Neighbourhood) XXX_Merge(src proto.Message) { - xxx_messageInfo_Neighbourhood.Merge(m, src) -} -func (m *Neighbourhood) XXX_Size() int { - return xxx_messageInfo_Neighbourhood.Size(m) -} -func (m *Neighbourhood) XXX_DiscardUnknown() { - xxx_messageInfo_Neighbourhood.DiscardUnknown(m) -} - -var xxx_messageInfo_Neighbourhood proto.InternalMessageInfo - -func (m *Neighbourhood) GetNode() *Node { - if m != nil { - return m.Node - } - return nil -} - -func (m *Neighbourhood) GetNeighbour() []*Neighbour { - if m != nil { - return m.Neighbour + return m.Neighbours } return nil } @@ -238,7 +188,7 @@ func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{5} + return fileDescriptor_8571034d60397816, []int{4} } func (m *Node) XXX_Unmarshal(b []byte) error { @@ -286,7 +236,7 @@ func (m *Connect) Reset() { *m = Connect{} } func (m *Connect) String() string { return proto.CompactTextString(m) } func (*Connect) ProtoMessage() {} func (*Connect) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{6} + return fileDescriptor_8571034d60397816, []int{5} } func (m *Connect) XXX_Unmarshal(b []byte) error { @@ -327,7 +277,7 @@ func (m *Close) Reset() { *m = Close{} } func (m *Close) String() string { return proto.CompactTextString(m) } func (*Close) ProtoMessage() {} func (*Close) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{7} + return fileDescriptor_8571034d60397816, []int{6} } func (m *Close) XXX_Unmarshal(b []byte) error { @@ -370,7 +320,7 @@ func (m *Neighbour) Reset() { *m = Neighbour{} } func (m *Neighbour) String() string { return proto.CompactTextString(m) } func (*Neighbour) ProtoMessage() {} func (*Neighbour) Descriptor() ([]byte, []int) { - return fileDescriptor_8571034d60397816, []int{8} + return fileDescriptor_8571034d60397816, []int{7} } func (m *Neighbour) XXX_Unmarshal(b []byte) error { @@ -410,7 +360,6 @@ func init() { proto.RegisterType((*ListResponse)(nil), "go.micro.network.ListResponse") proto.RegisterType((*NeighbourhoodRequest)(nil), "go.micro.network.NeighbourhoodRequest") proto.RegisterType((*NeighbourhoodResponse)(nil), "go.micro.network.NeighbourhoodResponse") - proto.RegisterType((*Neighbourhood)(nil), "go.micro.network.Neighbourhood") proto.RegisterType((*Node)(nil), "go.micro.network.Node") proto.RegisterType((*Connect)(nil), "go.micro.network.Connect") proto.RegisterType((*Close)(nil), "go.micro.network.Close") @@ -420,28 +369,27 @@ func init() { func init() { proto.RegisterFile("network.proto", fileDescriptor_8571034d60397816) } var fileDescriptor_8571034d60397816 = []byte{ - // 367 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x4e, 0xc2, 0x40, - 0x10, 0x95, 0x02, 0x92, 0x0e, 0x62, 0xcc, 0x46, 0x4d, 0x53, 0x83, 0x21, 0x7b, 0x40, 0x62, 0xb4, - 0x18, 0x88, 0x26, 0x26, 0x5e, 0x0c, 0x07, 0x2f, 0x84, 0x43, 0x8f, 0xde, 0x2c, 0xbb, 0x29, 0x8d, - 0xd2, 0xc1, 0xdd, 0xad, 0xfe, 0x80, 0x1f, 0x6e, 0xba, 0x5d, 0x4a, 0x29, 0x82, 0xe1, 0xd6, 0x99, - 0x79, 0xf3, 0xde, 0xbc, 0xf6, 0x15, 0x5a, 0x31, 0x57, 0xdf, 0x28, 0xde, 0xbd, 0x85, 0x40, 0x85, - 0xe4, 0x24, 0x44, 0x6f, 0x1e, 0x4d, 0x05, 0x7a, 0xa6, 0xef, 0x0e, 0xc3, 0x48, 0xcd, 0x92, 0xc0, - 0x9b, 0xe2, 0xbc, 0xaf, 0x27, 0xfd, 0x10, 0x6f, 0xb3, 0x07, 0x81, 0x89, 0xe2, 0xa2, 0xaf, 0x37, - 0x4d, 0x91, 0xd1, 0xd0, 0x16, 0x34, 0xc7, 0x91, 0x54, 0x3e, 0xff, 0x4c, 0xb8, 0x54, 0xf4, 0x09, - 0x8e, 0xb2, 0x52, 0x2e, 0x30, 0x96, 0x9c, 0xdc, 0x40, 0x3d, 0x46, 0xc6, 0xa5, 0x53, 0xe9, 0x54, - 0x7b, 0xcd, 0xc1, 0xb9, 0x57, 0x56, 0xf5, 0x26, 0xc8, 0xb8, 0x9f, 0x81, 0x68, 0x17, 0x4e, 0x27, - 0x3c, 0x0a, 0x67, 0x01, 0x26, 0x62, 0x86, 0xc8, 0x0c, 0x2b, 0x39, 0x06, 0x2b, 0x62, 0x4e, 0xa5, - 0x53, 0xe9, 0xd9, 0xbe, 0x15, 0x31, 0xfa, 0x0a, 0x67, 0x25, 0x9c, 0x91, 0x7b, 0x4e, 0x5d, 0x16, - 0x06, 0x7a, 0xa7, 0x39, 0xb8, 0xf8, 0x43, 0x76, 0x09, 0xf3, 0xd7, 0x37, 0xe8, 0x17, 0xb4, 0xd6, - 0xb8, 0xc9, 0x35, 0xd4, 0xd2, 0xeb, 0x0c, 0xd5, 0x36, 0x07, 0x1a, 0x43, 0x1e, 0xc1, 0xce, 0xd9, - 0x1c, 0x4b, 0x5b, 0xde, 0xa9, 0xbd, 0x42, 0xd3, 0x3b, 0xa8, 0xa5, 0x44, 0x65, 0xaf, 0xc4, 0x81, - 0xc6, 0x1b, 0x63, 0x82, 0x4b, 0xe9, 0x58, 0xba, 0xb9, 0x2c, 0xe9, 0x3d, 0x34, 0x46, 0x18, 0xc7, - 0x7c, 0xaa, 0xf6, 0xb9, 0x91, 0x0e, 0xa1, 0x3e, 0xfa, 0x40, 0xc9, 0xf7, 0x5a, 0x42, 0xb0, 0xf3, - 0xab, 0xf7, 0x7a, 0x23, 0x0f, 0x00, 0xb9, 0x47, 0xe9, 0x54, 0x77, 0xa6, 0xa0, 0x80, 0x1c, 0xfc, - 0x58, 0xd0, 0x98, 0x64, 0x43, 0xf2, 0x02, 0xa0, 0x43, 0x95, 0xe6, 0x4e, 0x12, 0x67, 0xb5, 0x6d, - 0x92, 0x68, 0x62, 0xe2, 0xb6, 0x37, 0x26, 0xc5, 0x2c, 0xd2, 0x03, 0x32, 0x06, 0x3b, 0xed, 0xa4, - 0x62, 0x92, 0xb4, 0x37, 0xaf, 0x28, 0x24, 0xd9, 0xbd, 0xdc, 0x36, 0xce, 0xd9, 0x82, 0x72, 0x52, - 0xba, 0x3b, 0x3e, 0x75, 0x21, 0xce, 0xee, 0xd5, 0xbf, 0xb8, 0xa5, 0x46, 0x70, 0xa8, 0xff, 0xb2, - 0xe1, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x4f, 0xab, 0x3f, 0xbd, 0x03, 0x00, 0x00, + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0x4f, 0xf2, 0x40, + 0x10, 0xfd, 0x28, 0xf0, 0x11, 0x06, 0x31, 0x66, 0xa3, 0xa6, 0xa9, 0xc1, 0x90, 0x3d, 0x20, 0x31, + 0x5a, 0x0c, 0x44, 0x2f, 0x7a, 0xe3, 0xe0, 0x85, 0x70, 0x68, 0xfc, 0x03, 0x96, 0xdd, 0x94, 0x8d, + 0xb2, 0x83, 0xbb, 0xdb, 0xf8, 0x07, 0xfc, 0xe1, 0xa6, 0xdb, 0x2d, 0x16, 0x10, 0x0c, 0xb7, 0xce, + 0xcc, 0x7b, 0xf3, 0x66, 0xfb, 0x1e, 0xb4, 0x25, 0x37, 0x9f, 0xa8, 0xde, 0xc2, 0xa5, 0x42, 0x83, + 0xe4, 0x24, 0xc1, 0x70, 0x21, 0x66, 0x0a, 0x43, 0xd7, 0x0f, 0x46, 0x89, 0x30, 0xf3, 0x34, 0x0e, + 0x67, 0xb8, 0x18, 0xd8, 0xc9, 0x20, 0xc1, 0xdb, 0xfc, 0x43, 0x61, 0x6a, 0xb8, 0x1a, 0x58, 0xa6, + 0x2b, 0xf2, 0x35, 0xb4, 0x0d, 0xad, 0x89, 0xd0, 0x26, 0xe2, 0x1f, 0x29, 0xd7, 0x86, 0x3e, 0xc1, + 0x51, 0x5e, 0xea, 0x25, 0x4a, 0xcd, 0xc9, 0x0d, 0xd4, 0x25, 0x32, 0xae, 0xfd, 0x4a, 0xb7, 0xda, + 0x6f, 0x0d, 0xcf, 0xc3, 0x4d, 0xd5, 0x70, 0x8a, 0x8c, 0x47, 0x39, 0x88, 0xf6, 0xe0, 0x74, 0xca, + 0x45, 0x32, 0x8f, 0x31, 0x55, 0x73, 0x44, 0xe6, 0xb6, 0x92, 0x63, 0xf0, 0x04, 0xf3, 0x2b, 0xdd, + 0x4a, 0xbf, 0x19, 0x79, 0x82, 0xd1, 0x17, 0x38, 0xdb, 0xc0, 0x39, 0xb9, 0x47, 0x00, 0x59, 0x0c, + 0x0a, 0xcd, 0x8b, 0x5f, 0x34, 0x0b, 0x4c, 0x54, 0x82, 0xd3, 0x3b, 0xa8, 0x65, 0xc7, 0x6c, 0xaa, + 0x11, 0x1f, 0x1a, 0xaf, 0x8c, 0x29, 0xae, 0xb5, 0xef, 0xd9, 0x66, 0x51, 0xd2, 0x7b, 0x68, 0x8c, + 0x51, 0x4a, 0x3e, 0x33, 0xe4, 0x1a, 0x6a, 0xd9, 0x1b, 0x2c, 0x6d, 0xf7, 0x3b, 0x2d, 0x86, 0x8e, + 0xa0, 0x3e, 0x7e, 0x47, 0xcd, 0x0f, 0x22, 0x21, 0x34, 0x57, 0x67, 0x1f, 0x42, 0x24, 0x0f, 0x6b, + 0xff, 0xa4, 0xba, 0xd7, 0x87, 0x12, 0x72, 0xf8, 0xe5, 0x41, 0x63, 0x9a, 0x0f, 0xc9, 0x33, 0x80, + 0xb5, 0x35, 0x73, 0x5e, 0x13, 0xff, 0x87, 0xed, 0xb2, 0xe0, 0x8c, 0x0a, 0x3a, 0x5b, 0x93, 0x72, + 0x1a, 0xe8, 0x3f, 0x32, 0x81, 0x66, 0xd6, 0xc9, 0xc4, 0x34, 0xe9, 0x6c, 0x5f, 0x51, 0xca, 0x52, + 0x70, 0xb9, 0x6b, 0xbc, 0xda, 0x16, 0x43, 0x7b, 0x2d, 0x07, 0xa4, 0xb7, 0xc7, 0xeb, 0x52, 0xa0, + 0x82, 0xab, 0x3f, 0x71, 0x85, 0x46, 0xfc, 0xdf, 0xe6, 0x7c, 0xf4, 0x1d, 0x00, 0x00, 0xff, 0xff, + 0x11, 0x41, 0xd2, 0x02, 0x3f, 0x03, 0x00, 0x00, } diff --git a/network/proto/network.proto b/network/proto/network.proto index 0fb854d6..f540aafe 100644 --- a/network/proto/network.proto +++ b/network/proto/network.proto @@ -26,15 +26,7 @@ message NeighbourhoodRequest { // NeighbourhoodResponse contains node neighbourhood hierarchy message NeighbourhoodResponse { - Neighbour neighbourhood = 1; -} - -// Neighbourhood is node neighbourhood -message Neighbourhood { - // network node - Node node = 1; - // node neighbours - repeated Neighbour neighbour = 2; + repeated Neighbour neighbours = 1; } // Node is network node