Merge branch 'master' of github.com:harmony-one/harmony into rj_branch

pull/318/head
Rongjian Lan 6 years ago
commit 191b190547
  1. 1
      api/proto/message/gen.sh
  2. 241
      api/proto/message/message.pb.go
  3. 33
      api/proto/message/message.proto
  4. 1
      scripts/message_gen.sh
  5. 6
      scripts/protobuf_setup.md

@ -0,0 +1 @@
protoc -I ./ message.proto --go_out=./

@ -0,0 +1,241 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: message.proto
package message
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// 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.ProtoPackageIsVersion3 // please upgrade the proto package
type MessageType int32
const (
MessageType_UNKNOWN MessageType = 0
MessageType_NEWNODE_BOOTNODE MessageType = 1
MessageType_BOOTNODE_NEWNODE MessageType = 2
MessageType_NEWNODE_BEACON MessageType = 3
MessageType_BEACON_NEWNODE MessageType = 4
)
var MessageType_name = map[int32]string{
0: "UNKNOWN",
1: "NEWNODE_BOOTNODE",
2: "BOOTNODE_NEWNODE",
3: "NEWNODE_BEACON",
4: "BEACON_NEWNODE",
}
var MessageType_value = map[string]int32{
"UNKNOWN": 0,
"NEWNODE_BOOTNODE": 1,
"BOOTNODE_NEWNODE": 2,
"NEWNODE_BEACON": 3,
"BEACON_NEWNODE": 4,
}
func (x MessageType) String() string {
return proto.EnumName(MessageType_name, int32(x))
}
func (MessageType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{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.
//
// The request field will be either one of the structure corresponding to the MessageType type.
type Message struct {
Type MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=message.MessageType" json:"type,omitempty"`
// Types that are valid to be assigned to Request:
// *Message_NewnodeBootnodeRequest
// *Message_BootnodeNewnodeRequest
Request isMessage_Request `protobuf_oneof:"request"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{0}
}
func (m *Message) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Message.Unmarshal(m, b)
}
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
}
func (m *Message) XXX_Merge(src proto.Message) {
xxx_messageInfo_Message.Merge(m, src)
}
func (m *Message) XXX_Size() int {
return xxx_messageInfo_Message.Size(m)
}
func (m *Message) XXX_DiscardUnknown() {
xxx_messageInfo_Message.DiscardUnknown(m)
}
var xxx_messageInfo_Message proto.InternalMessageInfo
func (m *Message) GetType() MessageType {
if m != nil {
return m.Type
}
return MessageType_UNKNOWN
}
type isMessage_Request interface {
isMessage_Request()
}
type Message_NewnodeBootnodeRequest struct {
NewnodeBootnodeRequest *NewNodeBootNodeRequest `protobuf:"bytes,2,opt,name=newnode_bootnode_request,json=newnodeBootnodeRequest,proto3,oneof"`
}
type Message_BootnodeNewnodeRequest struct {
BootnodeNewnodeRequest *BootNodeNewNodeRequest `protobuf:"bytes,3,opt,name=bootnode_newnode_request,json=bootnodeNewnodeRequest,proto3,oneof"`
}
func (*Message_NewnodeBootnodeRequest) isMessage_Request() {}
func (*Message_BootnodeNewnodeRequest) isMessage_Request() {}
func (m *Message) GetRequest() isMessage_Request {
if m != nil {
return m.Request
}
return nil
}
func (m *Message) GetNewnodeBootnodeRequest() *NewNodeBootNodeRequest {
if x, ok := m.GetRequest().(*Message_NewnodeBootnodeRequest); ok {
return x.NewnodeBootnodeRequest
}
return nil
}
func (m *Message) GetBootnodeNewnodeRequest() *BootNodeNewNodeRequest {
if x, ok := m.GetRequest().(*Message_BootnodeNewnodeRequest); ok {
return x.BootnodeNewnodeRequest
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*Message) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Message_NewnodeBootnodeRequest)(nil),
(*Message_BootnodeNewnodeRequest)(nil),
}
}
// Message of NewNode talking to BootNode.
type NewNodeBootNodeRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NewNodeBootNodeRequest) Reset() { *m = NewNodeBootNodeRequest{} }
func (m *NewNodeBootNodeRequest) String() string { return proto.CompactTextString(m) }
func (*NewNodeBootNodeRequest) ProtoMessage() {}
func (*NewNodeBootNodeRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{1}
}
func (m *NewNodeBootNodeRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NewNodeBootNodeRequest.Unmarshal(m, b)
}
func (m *NewNodeBootNodeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NewNodeBootNodeRequest.Marshal(b, m, deterministic)
}
func (m *NewNodeBootNodeRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_NewNodeBootNodeRequest.Merge(m, src)
}
func (m *NewNodeBootNodeRequest) XXX_Size() int {
return xxx_messageInfo_NewNodeBootNodeRequest.Size(m)
}
func (m *NewNodeBootNodeRequest) XXX_DiscardUnknown() {
xxx_messageInfo_NewNodeBootNodeRequest.DiscardUnknown(m)
}
var xxx_messageInfo_NewNodeBootNodeRequest proto.InternalMessageInfo
// Message of BootNode talking to NewNode.
type BootNodeNewNodeRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BootNodeNewNodeRequest) Reset() { *m = BootNodeNewNodeRequest{} }
func (m *BootNodeNewNodeRequest) String() string { return proto.CompactTextString(m) }
func (*BootNodeNewNodeRequest) ProtoMessage() {}
func (*BootNodeNewNodeRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{2}
}
func (m *BootNodeNewNodeRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BootNodeNewNodeRequest.Unmarshal(m, b)
}
func (m *BootNodeNewNodeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BootNodeNewNodeRequest.Marshal(b, m, deterministic)
}
func (m *BootNodeNewNodeRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_BootNodeNewNodeRequest.Merge(m, src)
}
func (m *BootNodeNewNodeRequest) XXX_Size() int {
return xxx_messageInfo_BootNodeNewNodeRequest.Size(m)
}
func (m *BootNodeNewNodeRequest) XXX_DiscardUnknown() {
xxx_messageInfo_BootNodeNewNodeRequest.DiscardUnknown(m)
}
var xxx_messageInfo_BootNodeNewNodeRequest proto.InternalMessageInfo
func init() {
proto.RegisterEnum("message.MessageType", MessageType_name, MessageType_value)
proto.RegisterType((*Message)(nil), "message.Message")
proto.RegisterType((*NewNodeBootNodeRequest)(nil), "message.NewNodeBootNodeRequest")
proto.RegisterType((*BootNodeNewNodeRequest)(nil), "message.BootNodeNewNodeRequest")
}
func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) }
var fileDescriptor_33c57e4bae7b9afd = []byte{
// 253 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x41, 0x4b, 0xc3, 0x40,
0x10, 0x85, 0xbb, 0x6d, 0x31, 0x38, 0xc1, 0xb2, 0x2c, 0xa5, 0xe4, 0x66, 0xe9, 0x29, 0x78, 0xe8,
0xa1, 0xfe, 0x02, 0xa3, 0x01, 0x41, 0x9c, 0x85, 0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x7f, 0x78, 0xb4, 0xa8, 0x27, 0xbe, 0xd7, 0xe9, 0x3e, 0x37, 0xdd, 0x5f, 0xb5, 0xdf, 0x75, 0xff,
0x17, 0x00, 0x00, 0xff, 0xff, 0x37, 0x30, 0xd0, 0xfb, 0xbf, 0x01, 0x00, 0x00,
}

@ -0,0 +1,33 @@
syntax = "proto3";
package message;
enum MessageType {
UNKNOWN = 0;
NEWNODE_BOOTNODE = 1;
BOOTNODE_NEWNODE = 2;
NEWNODE_BEACON = 3;
BEACON_NEWNODE = 4;
}
// 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.
//
// The request field will be either one of the structure corresponding to the MessageType type.
message Message {
MessageType type = 1;
oneof request {
NewNodeBootNodeRequest newnode_bootnode_request = 2;
BootNodeNewNodeRequest bootnode_newnode_request = 3;
}
}
// Message of NewNode talking to BootNode.
message NewNodeBootNodeRequest {
}
// Message of BootNode talking to NewNode.
message BootNodeNewNodeRequest {
}
// TODO(minhdoan): refactor and introduce consensus message as one of possible Message.request.

@ -0,0 +1 @@
protoc -I ./api/proto/message api/proto/message/message.proto --go_out=./api/proto/message

@ -0,0 +1,6 @@
# Setup
You need to install protoc (protobuf compiler) and protoc-gen-go.
- For protoc-gen-go just simple install by `go get -u github.com/golang/protobuf/protoc-gen-go`
- For protoc, you install from the release https://github.com/protocolbuffers/protobuf/releases.
Loading…
Cancel
Save