diff --git a/api/proto/message/gen.sh b/api/proto/message/gen.sh index 27fdc96c8..c0ac17c89 100755 --- a/api/proto/message/gen.sh +++ b/api/proto/message/gen.sh @@ -1 +1,2 @@ -protoc -I ./ message.proto --go_out=./ +protoc -I ./ message.proto --go_out=plugins=grpc:./ +# protoc -I ./ message.proto --go_out=./ diff --git a/api/proto/message/message.pb.go b/api/proto/message/message.pb.go index 03566e668..0587aedc1 100644 --- a/api/proto/message/message.pb.go +++ b/api/proto/message/message.pb.go @@ -4,8 +4,10 @@ package message import ( + context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" math "math" ) @@ -125,6 +127,31 @@ func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_33c57e4bae7b9afd, []int{2} } +type LotteryRequest_Type int32 + +const ( + LotteryRequest_ENTER LotteryRequest_Type = 0 + LotteryRequest_RESULT LotteryRequest_Type = 1 +) + +var LotteryRequest_Type_name = map[int32]string{ + 0: "ENTER", + 1: "RESULT", +} + +var LotteryRequest_Type_value = map[string]int32{ + "ENTER": 0, + "RESULT": 1, +} + +func (x LotteryRequest_Type) String() string { + return proto.EnumName(LotteryRequest_Type_name, int32(x)) +} + +func (LotteryRequest_Type) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_33c57e4bae7b9afd, []int{3, 0} +} + // This is universal message for all communication protocols. // There are different Requests for different message types. // As we introduce a new type of message just add a new MessageType and new type of request in Message. @@ -139,6 +166,7 @@ type Message struct { // *Message_Staking // *Message_Consensus // *Message_Drand + // *Message_LotteryRequest Request isMessage_Request `protobuf_oneof:"request"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -214,12 +242,18 @@ type Message_Drand struct { Drand *DrandRequest `protobuf:"bytes,7,opt,name=drand,proto3,oneof"` } +type Message_LotteryRequest struct { + LotteryRequest *LotteryRequest `protobuf:"bytes,8,opt,name=lottery_request,json=lotteryRequest,proto3,oneof"` +} + func (*Message_Staking) isMessage_Request() {} func (*Message_Consensus) isMessage_Request() {} func (*Message_Drand) isMessage_Request() {} +func (*Message_LotteryRequest) isMessage_Request() {} + func (m *Message) GetRequest() isMessage_Request { if m != nil { return m.Request @@ -248,13 +282,204 @@ func (m *Message) GetDrand() *DrandRequest { return nil } +func (m *Message) GetLotteryRequest() *LotteryRequest { + if x, ok := m.GetRequest().(*Message_LotteryRequest); ok { + return x.LotteryRequest + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*Message) XXX_OneofWrappers() []interface{} { return []interface{}{ (*Message_Staking)(nil), (*Message_Consensus)(nil), (*Message_Drand)(nil), + (*Message_LotteryRequest)(nil), + } +} + +type Response struct { + ReceiverType ReceiverType `protobuf:"varint,1,opt,name=receiver_type,json=receiverType,proto3,enum=message.ReceiverType" json:"receiver_type,omitempty"` + ServiceType ServiceType `protobuf:"varint,2,opt,name=service_type,json=serviceType,proto3,enum=message.ServiceType" json:"service_type,omitempty"` + Type MessageType `protobuf:"varint,3,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"` + // Types that are valid to be assigned to Response: + // *Response_LotteryResponse + Response isResponse_Response `protobuf_oneof:"response"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_33c57e4bae7b9afd, []int{1} +} + +func (m *Response) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Response.Unmarshal(m, b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return xxx_messageInfo_Response.Size(m) +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetReceiverType() ReceiverType { + if m != nil { + return m.ReceiverType + } + return ReceiverType_NEWNODE +} + +func (m *Response) GetServiceType() ServiceType { + if m != nil { + return m.ServiceType + } + return ServiceType_CONSENSUS +} + +func (m *Response) GetType() MessageType { + if m != nil { + return m.Type + } + return MessageType_NEWNODE_BEACON_STAKING +} + +type isResponse_Response interface { + isResponse_Response() +} + +type Response_LotteryResponse struct { + LotteryResponse *LotteryResponse `protobuf:"bytes,4,opt,name=lottery_response,json=lotteryResponse,proto3,oneof"` +} + +func (*Response_LotteryResponse) isResponse_Response() {} + +func (m *Response) GetResponse() isResponse_Response { + if m != nil { + return m.Response + } + return nil +} + +func (m *Response) GetLotteryResponse() *LotteryResponse { + if x, ok := m.GetResponse().(*Response_LotteryResponse); ok { + return x.LotteryResponse } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Response) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Response_LotteryResponse)(nil), + } +} + +type LotteryResponse struct { + Players []string `protobuf:"bytes,1,rep,name=players,proto3" json:"players,omitempty"` + Balances []uint64 `protobuf:"varint,3,rep,packed,name=balances,proto3" json:"balances,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LotteryResponse) Reset() { *m = LotteryResponse{} } +func (m *LotteryResponse) String() string { return proto.CompactTextString(m) } +func (*LotteryResponse) ProtoMessage() {} +func (*LotteryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_33c57e4bae7b9afd, []int{2} +} + +func (m *LotteryResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LotteryResponse.Unmarshal(m, b) +} +func (m *LotteryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LotteryResponse.Marshal(b, m, deterministic) +} +func (m *LotteryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LotteryResponse.Merge(m, src) +} +func (m *LotteryResponse) XXX_Size() int { + return xxx_messageInfo_LotteryResponse.Size(m) +} +func (m *LotteryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LotteryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LotteryResponse proto.InternalMessageInfo + +func (m *LotteryResponse) GetPlayers() []string { + if m != nil { + return m.Players + } + return nil +} + +func (m *LotteryResponse) GetBalances() []uint64 { + if m != nil { + return m.Balances + } + return nil +} + +type LotteryRequest struct { + Type LotteryRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=message.LotteryRequest_Type" json:"type,omitempty"` + PrivateKey string `protobuf:"bytes,2,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LotteryRequest) Reset() { *m = LotteryRequest{} } +func (m *LotteryRequest) String() string { return proto.CompactTextString(m) } +func (*LotteryRequest) ProtoMessage() {} +func (*LotteryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_33c57e4bae7b9afd, []int{3} +} + +func (m *LotteryRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LotteryRequest.Unmarshal(m, b) +} +func (m *LotteryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LotteryRequest.Marshal(b, m, deterministic) +} +func (m *LotteryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_LotteryRequest.Merge(m, src) +} +func (m *LotteryRequest) XXX_Size() int { + return xxx_messageInfo_LotteryRequest.Size(m) +} +func (m *LotteryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_LotteryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_LotteryRequest proto.InternalMessageInfo + +func (m *LotteryRequest) GetType() LotteryRequest_Type { + if m != nil { + return m.Type + } + return LotteryRequest_ENTER +} + +func (m *LotteryRequest) GetPrivateKey() string { + if m != nil { + return m.PrivateKey + } + return "" } // Staking Request from new node to beacon node. @@ -270,7 +495,7 @@ func (m *StakingRequest) Reset() { *m = StakingRequest{} } func (m *StakingRequest) String() string { return proto.CompactTextString(m) } func (*StakingRequest) ProtoMessage() {} func (*StakingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{1} + return fileDescriptor_33c57e4bae7b9afd, []int{4} } func (m *StakingRequest) XXX_Unmarshal(b []byte) error { @@ -319,7 +544,7 @@ func (m *ConsensusRequest) Reset() { *m = ConsensusRequest{} } func (m *ConsensusRequest) String() string { return proto.CompactTextString(m) } func (*ConsensusRequest) ProtoMessage() {} func (*ConsensusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{2} + return fileDescriptor_33c57e4bae7b9afd, []int{5} } func (m *ConsensusRequest) XXX_Unmarshal(b []byte) error { @@ -381,7 +606,7 @@ func (m *DrandRequest) Reset() { *m = DrandRequest{} } func (m *DrandRequest) String() string { return proto.CompactTextString(m) } func (*DrandRequest) ProtoMessage() {} func (*DrandRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{3} + return fileDescriptor_33c57e4bae7b9afd, []int{6} } func (m *DrandRequest) XXX_Unmarshal(b []byte) error { @@ -427,7 +652,11 @@ func init() { proto.RegisterEnum("message.ReceiverType", ReceiverType_name, ReceiverType_value) proto.RegisterEnum("message.ServiceType", ServiceType_name, ServiceType_value) proto.RegisterEnum("message.MessageType", MessageType_name, MessageType_value) + proto.RegisterEnum("message.LotteryRequest_Type", LotteryRequest_Type_name, LotteryRequest_Type_value) proto.RegisterType((*Message)(nil), "message.Message") + proto.RegisterType((*Response)(nil), "message.Response") + proto.RegisterType((*LotteryResponse)(nil), "message.LotteryResponse") + proto.RegisterType((*LotteryRequest)(nil), "message.LotteryRequest") proto.RegisterType((*StakingRequest)(nil), "message.StakingRequest") proto.RegisterType((*ConsensusRequest)(nil), "message.ConsensusRequest") proto.RegisterType((*DrandRequest)(nil), "message.DrandRequest") @@ -436,39 +665,123 @@ func init() { func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 541 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0xda, 0x40, - 0x10, 0xc6, 0x31, 0x04, 0x1c, 0x8f, 0x4d, 0xb4, 0x1a, 0xb5, 0x8d, 0xfb, 0x4f, 0xa2, 0x9c, 0x50, - 0xa4, 0xe6, 0x90, 0x54, 0xaa, 0xda, 0x9b, 0xc1, 0x56, 0x63, 0x05, 0xd6, 0xd1, 0xe2, 0xb4, 0x47, - 0xcb, 0xc1, 0x2b, 0xb0, 0x92, 0xda, 0xd4, 0x6b, 0x22, 0xf1, 0x0c, 0x3d, 0xf4, 0x55, 0xfb, 0x08, - 0x95, 0xd7, 0x06, 0x1b, 0x2e, 0xbd, 0xed, 0xf7, 0xcd, 0xfc, 0x66, 0x3e, 0x96, 0x35, 0xf4, 0x7f, - 0x72, 0x21, 0xc2, 0x25, 0xbf, 0x5c, 0x67, 0x69, 0x9e, 0xa2, 0x5a, 0xc9, 0xe1, 0xdf, 0x36, 0xa8, - 0xb3, 0xf2, 0x8c, 0x5f, 0xa1, 0x9f, 0xf1, 0x05, 0x8f, 0x9f, 0x79, 0x16, 0xe4, 0xdb, 0x35, 0x37, - 0x95, 0x81, 0x32, 0x3a, 0xbb, 0x7a, 0x79, 0xb9, 0x63, 0x59, 0x55, 0xf5, 0xb7, 0x6b, 0xce, 0x8c, - 0xac, 0xa1, 0xf0, 0x33, 0x18, 0x82, 0x67, 0xcf, 0xf1, 0x82, 0x97, 0x68, 0x5b, 0xa2, 0x2f, 0xf6, - 0xe8, 0xbc, 0x2c, 0x4a, 0x52, 0x17, 0xb5, 0xc0, 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 0x21, 0x01, 0xa3, 0xd4, 0x15, 0xa0, 0x3e, 0xf4, 0xe4, 0xf7, 0x7c, 0xfd, - 0x2f, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xfe, 0xce, 0xbf, 0xe0, 0x03, 0x00, 0x00, + // 730 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0x4d, 0x6f, 0x9b, 0x4c, + 0x10, 0xc7, 0x8d, 0xb1, 0x8d, 0x19, 0xb0, 0xb3, 0xcf, 0xea, 0x69, 0x43, 0xd3, 0x44, 0x75, 0x39, + 0x59, 0x91, 0x1a, 0x45, 0x4e, 0xa5, 0xaa, 0xbd, 0x61, 0x83, 0x12, 0x14, 0x07, 0x47, 0x6b, 0xd2, + 0x1e, 0x11, 0x31, 0xab, 0x04, 0x85, 0x82, 0xcb, 0x92, 0x48, 0xbe, 0xf6, 0xda, 0x43, 0xbf, 0x4c, + 0x3f, 0x5e, 0x0f, 0x15, 0x0b, 0x36, 0xd8, 0x55, 0xd5, 0x6b, 0x6f, 0xcc, 0x7f, 0xf6, 0x37, 0x6f, + 0x3b, 0x6b, 0x43, 0xef, 0x33, 0x65, 0xcc, 0xbf, 0xa3, 0x27, 0xcb, 0x34, 0xc9, 0x12, 0x2c, 0x95, + 0xa6, 0xfe, 0x43, 0x04, 0xe9, 0xaa, 0xf8, 0xc6, 0x1f, 0xa0, 0x97, 0xd2, 0x05, 0x0d, 0x9f, 0x68, + 0xea, 0x65, 0xab, 0x25, 0xd5, 0x84, 0x81, 0x30, 0xec, 0x8f, 0x9e, 0x9d, 0xac, 0x59, 0x52, 0x7a, + 0xdd, 0xd5, 0x92, 0x12, 0x35, 0xad, 0x59, 0xf8, 0x1d, 0xa8, 0x8c, 0xa6, 0x4f, 0xe1, 0x82, 0x16, + 0x68, 0x93, 0xa3, 0xff, 0x6f, 0xd0, 0x79, 0xe1, 0xe4, 0xa4, 0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, 0xed, 0x30, 0xc2, 0x4e, 0x98, 0xbf, 0x94, 0x50, 0xcb, 0x22, + 0x6e, 0x65, 0x39, 0x1e, 0x83, 0x5a, 0x5f, 0x71, 0xac, 0x80, 0xe4, 0x58, 0x9f, 0x9c, 0x99, 0x69, + 0x15, 0x93, 0x9e, 0x5a, 0x86, 0x69, 0x11, 0x24, 0xe0, 0x1e, 0xc8, 0x1f, 0x8d, 0xa9, 0x6d, 0x1a, + 0xee, 0x8c, 0xa0, 0x66, 0xee, 0x9a, 0x4c, 0x6d, 0xcb, 0x71, 0x91, 0x78, 0xfc, 0x16, 0x94, 0xda, + 0xae, 0xe7, 0x27, 0x27, 0x33, 0x67, 0x6e, 0x39, 0xf3, 0x9b, 0x39, 0x6a, 0xe4, 0x11, 0xe7, 0xae, + 0x71, 0x69, 0x3b, 0xe7, 0x48, 0xc8, 0xaf, 0xd1, 0x24, 0x86, 0x63, 0xa2, 0xe6, 0xf1, 0x77, 0x01, + 0x94, 0xda, 0xc6, 0xe3, 0x03, 0x78, 0x5e, 0x66, 0xf6, 0xc6, 0x96, 0x31, 0x99, 0x39, 0xde, 0x1a, + 0x6b, 0x60, 0x15, 0xba, 0x86, 0xe3, 0xcc, 0x6e, 0x9c, 0x89, 0x85, 0x84, 0x3c, 0xe2, 0x35, 0xb1, + 0xae, 0x0d, 0x62, 0xa1, 0x66, 0xee, 0x2a, 0x0d, 0x13, 0x89, 0xbc, 0xac, 0xd9, 0xd5, 0x95, 0xed, + 0xa2, 0x56, 0x51, 0x47, 0xfe, 0xed, 0x5a, 0x26, 0x6a, 0xe3, 0x3e, 0x00, 0x4f, 0xed, 0xd9, 0x8e, + 0xed, 0xa2, 0x0e, 0x46, 0xa0, 0x16, 0x76, 0x09, 0x48, 0x23, 0x03, 0x7a, 0x93, 0x28, 0xa4, 0x71, + 0x56, 0x76, 0x83, 0x4f, 0x41, 0xba, 0x4e, 0x93, 0x05, 0x65, 0x0c, 0xa3, 0xdd, 0x57, 0x7a, 0xf0, + 0x5f, 0xed, 0x37, 0xa2, 0x7c, 0x5b, 0x8d, 0xdb, 0x0e, 0xff, 0x8f, 0x38, 0xfb, 0x15, 0x00, 0x00, + 0xff, 0xff, 0x47, 0x7e, 0x88, 0xb5, 0x34, 0x06, 0x00, 0x00, +} + +// 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 + +// ClientServiceClient is the client API for ClientService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ClientServiceClient interface { + Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error) +} + +type clientServiceClient struct { + cc *grpc.ClientConn +} + +func NewClientServiceClient(cc *grpc.ClientConn) ClientServiceClient { + return &clientServiceClient{cc} +} + +func (c *clientServiceClient) Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, "/message.ClientService/Process", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ClientServiceServer is the server API for ClientService service. +type ClientServiceServer interface { + Process(context.Context, *Message) (*Response, error) +} + +func RegisterClientServiceServer(s *grpc.Server, srv ClientServiceServer) { + s.RegisterService(&_ClientService_serviceDesc, srv) +} + +func _ClientService_Process_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Message) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClientServiceServer).Process(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/message.ClientService/Process", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClientServiceServer).Process(ctx, req.(*Message)) + } + return interceptor(ctx, in, info, handler) +} + +var _ClientService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "message.ClientService", + HandlerType: (*ClientServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Process", + Handler: _ClientService_Process_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "message.proto", } diff --git a/api/proto/message/message.proto b/api/proto/message/message.proto index c5a2c4ecf..39d6e9f7f 100644 --- a/api/proto/message/message.proto +++ b/api/proto/message/message.proto @@ -1,6 +1,12 @@ syntax = "proto3"; package message; + +// Client is the service used for any client-facing requests. +service ClientService { + rpc Process(Message) returns (Response) {} +} + // ReceiverType indicates who is the receiver of this message. enum ReceiverType { NEWNODE = 0; @@ -42,7 +48,32 @@ message Message { StakingRequest staking = 5; ConsensusRequest consensus = 6; DrandRequest drand = 7; + // Refactor this later after demo. + LotteryRequest lottery_request = 8; + } +} + +message Response { + ReceiverType receiver_type = 1; + ServiceType service_type = 2; + MessageType type = 3; + oneof response { + LotteryResponse lottery_response = 4; + } +} + +message LotteryResponse { + repeated string players = 1; + repeated uint64 balances = 3; +} + +message LotteryRequest { + enum Type { + ENTER = 0; + RESULT = 1; } + Type type = 1; + string private_key = 2; } // Staking Request from new node to beacon node. diff --git a/cmd/demo/main.go b/cmd/demo/main.go new file mode 100644 index 000000000..252a82724 --- /dev/null +++ b/cmd/demo/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "net" + "net/http" + + "github.com/gorilla/mux" +) + +var ( + server *http.Server +) + +const ( + Port = "313131" +) + +func main() { + addr := net.JoinHostPort("", Port) + + router := mux.NewRouter() + // Set up router for blocks. + // s.router.Path("/blocks").Queries("from", "{[0-9]*?}", "to", "{[0-9]*?}").HandlerFunc(s.GetExplorerBlocks).Methods("GET") + // s.router.Path("/blocks").HandlerFunc(s.GetExplorerBlocks) + + server := &http.Server{Addr: addr, Handler: router} + server.ListenAndServe() +}