From e7547884a13937159a480092129ffc91ddeddc22 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 26 Jul 2018 07:03:43 +0200 Subject: [PATCH] feat(core): initial node API definition (#15) --- core/api/entity/.gitkeep | 0 core/api/node/.gitkeep | 0 core/api/node/service.pb.go | 814 ++++++++++++++++++++++++++++++++++++ core/api/node/service.proto | 41 ++ core/api/p2p/.gitkeep | 0 core/api/p2p/service.pb.go | 53 +-- core/api/p2p/service.proto | 2 +- 7 files changed, 883 insertions(+), 27 deletions(-) delete mode 100644 core/api/entity/.gitkeep delete mode 100644 core/api/node/.gitkeep create mode 100644 core/api/node/service.pb.go create mode 100644 core/api/node/service.proto delete mode 100644 core/api/p2p/.gitkeep diff --git a/core/api/entity/.gitkeep b/core/api/entity/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/api/node/.gitkeep b/core/api/node/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/api/node/service.pb.go b/core/api/node/service.pb.go new file mode 100644 index 0000000000..3bab42896b --- /dev/null +++ b/core/api/node/service.pb.go @@ -0,0 +1,814 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: api/node/service.proto + +/* + Package node is a generated protocol buffer package. + + It is generated from these files: + api/node/service.proto + + It has these top-level messages: + ContactRequestInput + Void +*/ +package node + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import berty_p2p1 "github.com/berty/berty/core/api/p2p" +import berty_entity "github.com/berty/berty/core/api/entity" + +import context "golang.org/x/net/context" +import grpc "google.golang.org/grpc" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type ContactRequestInput struct { + Contact *berty_entity.Contact `protobuf:"bytes,1,opt,name=contact" json:"contact,omitempty"` + IntroMessage string `protobuf:"bytes,2,opt,name=intro_message,json=introMessage,proto3" json:"intro_message,omitempty"` +} + +func (m *ContactRequestInput) Reset() { *m = ContactRequestInput{} } +func (m *ContactRequestInput) String() string { return proto.CompactTextString(m) } +func (*ContactRequestInput) ProtoMessage() {} +func (*ContactRequestInput) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{0} } + +func (m *ContactRequestInput) GetContact() *berty_entity.Contact { + if m != nil { + return m.Contact + } + return nil +} + +func (m *ContactRequestInput) GetIntroMessage() string { + if m != nil { + return m.IntroMessage + } + return "" +} + +type Void struct { +} + +func (m *Void) Reset() { *m = Void{} } +func (m *Void) String() string { return proto.CompactTextString(m) } +func (*Void) ProtoMessage() {} +func (*Void) Descriptor() ([]byte, []int) { return fileDescriptorService, []int{1} } + +func init() { + proto.RegisterType((*ContactRequestInput)(nil), "berty.node.ContactRequestInput") + proto.RegisterType((*Void)(nil), "berty.node.Void") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for BertyNode service + +type BertyNodeClient interface { + EventStream(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_EventStreamClient, error) + EventList(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_EventListClient, error) + ContactRequest(ctx context.Context, in *ContactRequestInput, opts ...grpc.CallOption) (*berty_entity.Contact, error) + ContactAcceptRequest(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) + ContactRemove(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) + ContactUpdate(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) + ContactList(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_ContactListClient, error) +} + +type bertyNodeClient struct { + cc *grpc.ClientConn +} + +func NewBertyNodeClient(cc *grpc.ClientConn) BertyNodeClient { + return &bertyNodeClient{cc} +} + +func (c *bertyNodeClient) EventStream(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_EventStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_BertyNode_serviceDesc.Streams[0], c.cc, "/berty.node.BertyNode/EventStream", opts...) + if err != nil { + return nil, err + } + x := &bertyNodeEventStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type BertyNode_EventStreamClient interface { + Recv() (*berty_p2p1.Event, error) + grpc.ClientStream +} + +type bertyNodeEventStreamClient struct { + grpc.ClientStream +} + +func (x *bertyNodeEventStreamClient) Recv() (*berty_p2p1.Event, error) { + m := new(berty_p2p1.Event) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *bertyNodeClient) EventList(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_EventListClient, error) { + stream, err := grpc.NewClientStream(ctx, &_BertyNode_serviceDesc.Streams[1], c.cc, "/berty.node.BertyNode/EventList", opts...) + if err != nil { + return nil, err + } + x := &bertyNodeEventListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type BertyNode_EventListClient interface { + Recv() (*berty_p2p1.Event, error) + grpc.ClientStream +} + +type bertyNodeEventListClient struct { + grpc.ClientStream +} + +func (x *bertyNodeEventListClient) Recv() (*berty_p2p1.Event, error) { + m := new(berty_p2p1.Event) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *bertyNodeClient) ContactRequest(ctx context.Context, in *ContactRequestInput, opts ...grpc.CallOption) (*berty_entity.Contact, error) { + out := new(berty_entity.Contact) + err := grpc.Invoke(ctx, "/berty.node.BertyNode/ContactRequest", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bertyNodeClient) ContactAcceptRequest(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) { + out := new(berty_entity.Contact) + err := grpc.Invoke(ctx, "/berty.node.BertyNode/ContactAcceptRequest", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bertyNodeClient) ContactRemove(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) { + out := new(berty_entity.Contact) + err := grpc.Invoke(ctx, "/berty.node.BertyNode/ContactRemove", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bertyNodeClient) ContactUpdate(ctx context.Context, in *berty_entity.Contact, opts ...grpc.CallOption) (*berty_entity.Contact, error) { + out := new(berty_entity.Contact) + err := grpc.Invoke(ctx, "/berty.node.BertyNode/ContactUpdate", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bertyNodeClient) ContactList(ctx context.Context, in *Void, opts ...grpc.CallOption) (BertyNode_ContactListClient, error) { + stream, err := grpc.NewClientStream(ctx, &_BertyNode_serviceDesc.Streams[2], c.cc, "/berty.node.BertyNode/ContactList", opts...) + if err != nil { + return nil, err + } + x := &bertyNodeContactListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type BertyNode_ContactListClient interface { + Recv() (*berty_entity.Contact, error) + grpc.ClientStream +} + +type bertyNodeContactListClient struct { + grpc.ClientStream +} + +func (x *bertyNodeContactListClient) Recv() (*berty_entity.Contact, error) { + m := new(berty_entity.Contact) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for BertyNode service + +type BertyNodeServer interface { + EventStream(*Void, BertyNode_EventStreamServer) error + EventList(*Void, BertyNode_EventListServer) error + ContactRequest(context.Context, *ContactRequestInput) (*berty_entity.Contact, error) + ContactAcceptRequest(context.Context, *berty_entity.Contact) (*berty_entity.Contact, error) + ContactRemove(context.Context, *berty_entity.Contact) (*berty_entity.Contact, error) + ContactUpdate(context.Context, *berty_entity.Contact) (*berty_entity.Contact, error) + ContactList(*Void, BertyNode_ContactListServer) error +} + +func RegisterBertyNodeServer(s *grpc.Server, srv BertyNodeServer) { + s.RegisterService(&_BertyNode_serviceDesc, srv) +} + +func _BertyNode_EventStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Void) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BertyNodeServer).EventStream(m, &bertyNodeEventStreamServer{stream}) +} + +type BertyNode_EventStreamServer interface { + Send(*berty_p2p1.Event) error + grpc.ServerStream +} + +type bertyNodeEventStreamServer struct { + grpc.ServerStream +} + +func (x *bertyNodeEventStreamServer) Send(m *berty_p2p1.Event) error { + return x.ServerStream.SendMsg(m) +} + +func _BertyNode_EventList_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Void) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BertyNodeServer).EventList(m, &bertyNodeEventListServer{stream}) +} + +type BertyNode_EventListServer interface { + Send(*berty_p2p1.Event) error + grpc.ServerStream +} + +type bertyNodeEventListServer struct { + grpc.ServerStream +} + +func (x *bertyNodeEventListServer) Send(m *berty_p2p1.Event) error { + return x.ServerStream.SendMsg(m) +} + +func _BertyNode_ContactRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ContactRequestInput) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BertyNodeServer).ContactRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.BertyNode/ContactRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BertyNodeServer).ContactRequest(ctx, req.(*ContactRequestInput)) + } + return interceptor(ctx, in, info, handler) +} + +func _BertyNode_ContactAcceptRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(berty_entity.Contact) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BertyNodeServer).ContactAcceptRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.BertyNode/ContactAcceptRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BertyNodeServer).ContactAcceptRequest(ctx, req.(*berty_entity.Contact)) + } + return interceptor(ctx, in, info, handler) +} + +func _BertyNode_ContactRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(berty_entity.Contact) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BertyNodeServer).ContactRemove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.BertyNode/ContactRemove", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BertyNodeServer).ContactRemove(ctx, req.(*berty_entity.Contact)) + } + return interceptor(ctx, in, info, handler) +} + +func _BertyNode_ContactUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(berty_entity.Contact) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BertyNodeServer).ContactUpdate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.BertyNode/ContactUpdate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BertyNodeServer).ContactUpdate(ctx, req.(*berty_entity.Contact)) + } + return interceptor(ctx, in, info, handler) +} + +func _BertyNode_ContactList_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Void) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BertyNodeServer).ContactList(m, &bertyNodeContactListServer{stream}) +} + +type BertyNode_ContactListServer interface { + Send(*berty_entity.Contact) error + grpc.ServerStream +} + +type bertyNodeContactListServer struct { + grpc.ServerStream +} + +func (x *bertyNodeContactListServer) Send(m *berty_entity.Contact) error { + return x.ServerStream.SendMsg(m) +} + +var _BertyNode_serviceDesc = grpc.ServiceDesc{ + ServiceName: "berty.node.BertyNode", + HandlerType: (*BertyNodeServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ContactRequest", + Handler: _BertyNode_ContactRequest_Handler, + }, + { + MethodName: "ContactAcceptRequest", + Handler: _BertyNode_ContactAcceptRequest_Handler, + }, + { + MethodName: "ContactRemove", + Handler: _BertyNode_ContactRemove_Handler, + }, + { + MethodName: "ContactUpdate", + Handler: _BertyNode_ContactUpdate_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "EventStream", + Handler: _BertyNode_EventStream_Handler, + ServerStreams: true, + }, + { + StreamName: "EventList", + Handler: _BertyNode_EventList_Handler, + ServerStreams: true, + }, + { + StreamName: "ContactList", + Handler: _BertyNode_ContactList_Handler, + ServerStreams: true, + }, + }, + Metadata: "api/node/service.proto", +} + +func (m *ContactRequestInput) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ContactRequestInput) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Contact != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintService(dAtA, i, uint64(m.Contact.Size())) + n1, err := m.Contact.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if len(m.IntroMessage) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintService(dAtA, i, uint64(len(m.IntroMessage))) + i += copy(dAtA[i:], m.IntroMessage) + } + return i, nil +} + +func (m *Void) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Void) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func encodeVarintService(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *ContactRequestInput) Size() (n int) { + var l int + _ = l + if m.Contact != nil { + l = m.Contact.Size() + n += 1 + l + sovService(uint64(l)) + } + l = len(m.IntroMessage) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + return n +} + +func (m *Void) Size() (n int) { + var l int + _ = l + return n +} + +func sovService(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozService(x uint64) (n int) { + return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ContactRequestInput) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ContactRequestInput: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContactRequestInput: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Contact == nil { + m.Contact = &berty_entity.Contact{} + } + if err := m.Contact.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IntroMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IntroMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Void) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Void: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Void: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipService(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthService + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipService(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowService = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("api/node/service.proto", fileDescriptorService) } + +var fileDescriptorService = []byte{ + // 339 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x4a, 0xc3, 0x40, + 0x10, 0xc6, 0x5d, 0x95, 0x4a, 0xb7, 0x56, 0x64, 0xab, 0x52, 0x72, 0x88, 0xa5, 0x7a, 0xe8, 0x69, + 0xb7, 0xa6, 0x20, 0x5e, 0x3c, 0x58, 0x15, 0x14, 0xd4, 0x43, 0x45, 0x0f, 0x5e, 0x24, 0xdd, 0x0c, + 0x75, 0x91, 0x64, 0xd7, 0x64, 0x5a, 0xe8, 0x9b, 0xf8, 0x2e, 0xbe, 0x80, 0x47, 0x1f, 0x41, 0xe2, + 0x8b, 0x48, 0xfe, 0x55, 0x85, 0x14, 0xd4, 0x4b, 0x18, 0xbe, 0xfd, 0x7e, 0xdf, 0x64, 0x86, 0xa1, + 0x5b, 0xae, 0x51, 0x22, 0xd0, 0x1e, 0x88, 0x08, 0xc2, 0x89, 0x92, 0xc0, 0x4d, 0xa8, 0x51, 0x33, + 0x3a, 0x84, 0x10, 0xa7, 0x3c, 0x79, 0xb1, 0x1a, 0x89, 0xc7, 0x38, 0x46, 0xc0, 0x04, 0x02, 0xcc, + 0x0c, 0x56, 0x33, 0x11, 0x21, 0x40, 0x85, 0x53, 0x21, 0x75, 0x80, 0xae, 0xcc, 0x5f, 0xda, 0x8f, + 0xb4, 0x71, 0x9c, 0x09, 0x03, 0x78, 0x1a, 0x43, 0x84, 0xe7, 0x81, 0x19, 0x23, 0x13, 0x74, 0x25, + 0xf7, 0x35, 0x49, 0x8b, 0x74, 0x6a, 0xce, 0x26, 0xcf, 0x7a, 0x64, 0x21, 0xbc, 0x60, 0x0a, 0x17, + 0xdb, 0xa1, 0x75, 0x15, 0x60, 0xa8, 0xef, 0x7d, 0x88, 0x22, 0x77, 0x04, 0xcd, 0xc5, 0x16, 0xe9, + 0x54, 0x07, 0xab, 0xa9, 0x78, 0x99, 0x69, 0xed, 0x0a, 0x5d, 0xbe, 0xd5, 0xca, 0x73, 0x5e, 0x96, + 0x68, 0xb5, 0x9f, 0xc4, 0x5d, 0x69, 0x0f, 0x58, 0x8f, 0xd6, 0x4e, 0x93, 0x7f, 0xbd, 0xc6, 0x10, + 0x5c, 0x9f, 0xad, 0xf3, 0xaf, 0x69, 0x78, 0x62, 0xb7, 0x0a, 0xc5, 0x38, 0x86, 0xa7, 0xce, 0x2e, + 0x61, 0x7b, 0xb4, 0x9a, 0x96, 0x17, 0x2a, 0xc2, 0x5f, 0x22, 0x67, 0x74, 0xed, 0xe7, 0xa8, 0x6c, + 0xfb, 0x3b, 0x57, 0xb2, 0x06, 0xab, 0x7c, 0x6a, 0x76, 0x42, 0x37, 0xf2, 0xf2, 0x48, 0x4a, 0x30, + 0xb3, 0xbc, 0x72, 0xfb, 0xbc, 0x94, 0x43, 0x5a, 0x9f, 0xf5, 0xf4, 0xf5, 0x04, 0xfe, 0x8d, 0xdf, + 0x18, 0xcf, 0xc5, 0xbf, 0xe2, 0x07, 0xb4, 0x96, 0x97, 0x73, 0x56, 0x58, 0xce, 0x75, 0x49, 0x7f, + 0xff, 0x35, 0xb6, 0xc9, 0x5b, 0x6c, 0x93, 0xf7, 0xd8, 0x26, 0xcf, 0x1f, 0xf6, 0xc2, 0xdd, 0xee, + 0x48, 0xe1, 0xc3, 0x78, 0xc8, 0xa5, 0xf6, 0x45, 0x0a, 0xe5, 0x5f, 0xa9, 0x43, 0x10, 0xc5, 0xcd, + 0x0e, 0x2b, 0xe9, 0xc5, 0xf5, 0x3e, 0x03, 0x00, 0x00, 0xff, 0xff, 0x25, 0x9c, 0x9b, 0xe0, 0xc6, + 0x02, 0x00, 0x00, +} diff --git a/core/api/node/service.proto b/core/api/node/service.proto new file mode 100644 index 0000000000..c70ab11055 --- /dev/null +++ b/core/api/node/service.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package berty.node; + +import "api/p2p/event.proto"; +import "api/entity/contact.proto"; + +option go_package = "github.com/berty/berty/core/api/node"; + +service BertyNode { + + // + // Events + // + + rpc EventStream(Void) returns (stream berty.p2p.Event); // yield new events in real-time + rpc EventList(Void) returns (stream berty.p2p.Event); // list old events + + // + // Contacts + // + + rpc ContactRequest(ContactRequestInput) returns (berty.entity.Contact); + rpc ContactAcceptRequest(berty.entity.Contact) returns (berty.entity.Contact); + rpc ContactRemove(berty.entity.Contact) returns (berty.entity.Contact); + rpc ContactUpdate(berty.entity.Contact) returns (berty.entity.Contact); + rpc ContactList(Void) returns (stream berty.entity.Contact); + + // + // Conversations + // + + // TODO... +} + +message ContactRequestInput { + berty.entity.Contact contact = 1; + string intro_message = 2; +} + +message Void {} \ No newline at end of file diff --git a/core/api/p2p/.gitkeep b/core/api/p2p/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/api/p2p/service.pb.go b/core/api/p2p/service.pb.go index 27014ae4b0..51b611c15c 100644 --- a/core/api/p2p/service.pb.go +++ b/core/api/p2p/service.pb.go @@ -37,64 +37,64 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for Berty service +// Client API for BertyP2P service -type BertyClient interface { +type BertyP2PClient interface { Handle(ctx context.Context, in *Event, opts ...grpc.CallOption) (*Void, error) } -type bertyClient struct { +type bertyP2PClient struct { cc *grpc.ClientConn } -func NewBertyClient(cc *grpc.ClientConn) BertyClient { - return &bertyClient{cc} +func NewBertyP2PClient(cc *grpc.ClientConn) BertyP2PClient { + return &bertyP2PClient{cc} } -func (c *bertyClient) Handle(ctx context.Context, in *Event, opts ...grpc.CallOption) (*Void, error) { +func (c *bertyP2PClient) Handle(ctx context.Context, in *Event, opts ...grpc.CallOption) (*Void, error) { out := new(Void) - err := grpc.Invoke(ctx, "/berty.p2p.Berty/Handle", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/berty.p2p.BertyP2P/Handle", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -// Server API for Berty service +// Server API for BertyP2P service -type BertyServer interface { +type BertyP2PServer interface { Handle(context.Context, *Event) (*Void, error) } -func RegisterBertyServer(s *grpc.Server, srv BertyServer) { - s.RegisterService(&_Berty_serviceDesc, srv) +func RegisterBertyP2PServer(s *grpc.Server, srv BertyP2PServer) { + s.RegisterService(&_BertyP2P_serviceDesc, srv) } -func _Berty_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _BertyP2P_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Event) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(BertyServer).Handle(ctx, in) + return srv.(BertyP2PServer).Handle(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/berty.p2p.Berty/Handle", + FullMethod: "/berty.p2p.BertyP2P/Handle", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BertyServer).Handle(ctx, req.(*Event)) + return srv.(BertyP2PServer).Handle(ctx, req.(*Event)) } return interceptor(ctx, in, info, handler) } -var _Berty_serviceDesc = grpc.ServiceDesc{ - ServiceName: "berty.p2p.Berty", - HandlerType: (*BertyServer)(nil), +var _BertyP2P_serviceDesc = grpc.ServiceDesc{ + ServiceName: "berty.p2p.BertyP2P", + HandlerType: (*BertyP2PServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Handle", - Handler: _Berty_Handle_Handler, + Handler: _BertyP2P_Handle_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -305,15 +305,16 @@ var ( func init() { proto.RegisterFile("api/p2p/service.proto", fileDescriptorService) } var fileDescriptorService = []byte{ - // 159 bytes of a gzipped FileDescriptorProto + // 162 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x2c, 0xc8, 0xd4, 0x2f, 0x30, 0x2a, 0xd0, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4c, 0x4a, 0x2d, 0x2a, 0xa9, 0xd4, 0x2b, 0x30, 0x2a, 0x90, 0x12, 0x86, 0xa9, 0x48, 0x2d, 0x4b, 0xcd, 0x2b, 0x81, 0xc8, 0x2b, 0xb1, 0x71, 0xb1, 0x84, 0xe5, 0x67, 0xa6, 0x18, - 0x99, 0x71, 0xb1, 0x3a, 0x81, 0x54, 0x0a, 0xe9, 0x72, 0xb1, 0x79, 0x24, 0xe6, 0xa5, 0xe4, 0xa4, - 0x0a, 0x09, 0xe8, 0xc1, 0xf5, 0xea, 0xb9, 0x82, 0xb4, 0x48, 0xf1, 0x23, 0x89, 0x80, 0x74, 0x29, - 0x31, 0x38, 0x99, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, - 0x33, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0x83, 0x95, 0x43, 0xc9, 0xe4, 0xfc, 0xa2, 0x54, 0x7d, 0xa8, 0x13, 0x92, 0xd8, 0xc0, 0xb6, - 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x57, 0x98, 0x75, 0x66, 0xb6, 0x00, 0x00, 0x00, + 0x59, 0x72, 0x71, 0x38, 0x81, 0x54, 0x06, 0x18, 0x05, 0x08, 0xe9, 0x72, 0xb1, 0x79, 0x24, 0xe6, + 0xa5, 0xe4, 0xa4, 0x0a, 0x09, 0xe8, 0xc1, 0xb5, 0xeb, 0xb9, 0x82, 0x74, 0x49, 0xf1, 0x23, 0x89, + 0x80, 0x34, 0x2a, 0x31, 0x38, 0x99, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, + 0x47, 0x72, 0x8c, 0x33, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x95, 0x43, 0xc9, 0xe4, 0xfc, 0xa2, 0x54, 0x7d, 0xa8, 0x2b, 0x92, + 0xd8, 0xc0, 0x0e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x02, 0x1c, 0x81, 0xb9, 0x00, + 0x00, 0x00, } diff --git a/core/api/p2p/service.proto b/core/api/p2p/service.proto index b2a8a630d9..47f5bad7e6 100644 --- a/core/api/p2p/service.proto +++ b/core/api/p2p/service.proto @@ -6,7 +6,7 @@ option go_package = "github.com/berty/berty/core/api/p2p"; import "api/p2p/event.proto"; -service Berty { +service BertyP2P { rpc Handle(Event) returns (Void) {}; }