From 4c96c8779f2e85c8121336710035bb5b2960fd76 Mon Sep 17 00:00:00 2001 From: Jacky Wang Date: Mon, 1 Mar 2021 02:25:48 -0800 Subject: [PATCH] [stream] added sync stream protobuf message module --- p2p/stream/protocols/sync/message/compose.go | 206 +++ p2p/stream/protocols/sync/message/generate.go | 3 + p2p/stream/protocols/sync/message/msg.pb.go | 1298 +++++++++++++++++ p2p/stream/protocols/sync/message/msg.proto | 80 + p2p/stream/protocols/sync/message/parse.go | 97 ++ 5 files changed, 1684 insertions(+) create mode 100644 p2p/stream/protocols/sync/message/compose.go create mode 100644 p2p/stream/protocols/sync/message/generate.go create mode 100644 p2p/stream/protocols/sync/message/msg.pb.go create mode 100644 p2p/stream/protocols/sync/message/msg.proto create mode 100644 p2p/stream/protocols/sync/message/parse.go diff --git a/p2p/stream/protocols/sync/message/compose.go b/p2p/stream/protocols/sync/message/compose.go new file mode 100644 index 0000000000..e24f73837d --- /dev/null +++ b/p2p/stream/protocols/sync/message/compose.go @@ -0,0 +1,206 @@ +package message + +import ( + "github.com/ethereum/go-ethereum/common" +) + +// MakeGetBlockNumberRequest makes the GetBlockNumber Request +func MakeGetBlockNumberRequest() *Request { + return &Request{ + Request: &Request_GetBlockNumberRequest{ + GetBlockNumberRequest: &GetBlockNumberRequest{}, + }, + } +} + +// MakeGetBlockHashesRequest makes GetBlockHashes Request +func MakeGetBlockHashesRequest(bns []uint64) *Request { + return &Request{ + Request: &Request_GetBlockHashesRequest{ + GetBlockHashesRequest: &GetBlockHashesRequest{ + Nums: bns, + }, + }, + } +} + +// MakeGetBlocksByNumRequest makes the GetBlockByNumber request +func MakeGetBlocksByNumRequest(bns []uint64) *Request { + return &Request{ + Request: &Request_GetBlocksByNumRequest{ + GetBlocksByNumRequest: &GetBlocksByNumRequest{ + Nums: bns, + }, + }, + } +} + +//MakeGetBlockByHashesRequest makes the GetBlocksByHashes request +func MakeGetBlocksByHashesRequest(hashes []common.Hash) *Request { + return &Request{ + Request: &Request_GetBlocksByHashesRequest{ + GetBlocksByHashesRequest: &GetBlocksByHashesRequest{ + BlockHashes: hashesToBytes(hashes), + }, + }, + } +} + +// MakeGetEpochStateRequest make GetEpochBlock request +func MakeGetEpochStateRequest(epoch uint64) *Request { + return &Request{ + Request: &Request_GetEpochStateRequest{ + GetEpochStateRequest: &GetEpochStateRequest{ + Epoch: epoch, + }, + }, + } +} + +// MakeErrorResponse makes the error response +func MakeErrorResponseMessage(rid uint64, err error) *Message { + resp := MakeErrorResponse(rid, err) + return makeMessageFromResponse(resp) +} + +// MakeErrorResponse makes the error response as a response +func MakeErrorResponse(rid uint64, err error) *Response { + return &Response{ + ReqId: rid, + Response: &Response_ErrorResponse{ + &ErrorResponse{ + Error: err.Error(), + }, + }, + } +} + +// MakeGetBlockNumberResponseMessage makes the GetBlockNumber response message +func MakeGetBlockNumberResponseMessage(rid uint64, bn uint64) *Message { + resp := MakeGetBlockNumberResponse(rid, bn) + return makeMessageFromResponse(resp) +} + +// MakeGetBlockNumberResponse makes the GetBlockNumber response +func MakeGetBlockNumberResponse(rid uint64, bn uint64) *Response { + return &Response{ + ReqId: rid, + Response: &Response_GetBlockNumberResponse{ + GetBlockNumberResponse: &GetBlockNumberResponse{ + Number: bn, + }, + }, + } +} + +// MakeGetBlockHashesResponseMessage makes the GetBlockHashes message +func MakeGetBlockHashesResponseMessage(rid uint64, hs []common.Hash) *Message { + resp := MakeGetBlockHashesResponse(rid, hs) + return makeMessageFromResponse(resp) +} + +// MakeGetBlockHashesResponse makes the GetBlockHashes response +func MakeGetBlockHashesResponse(rid uint64, hs []common.Hash) *Response { + return &Response{ + ReqId: rid, + Response: &Response_GetBlockHashesResponse{ + GetBlockHashesResponse: &GetBlockHashesResponse{ + Hashes: hashesToBytes(hs), + }, + }, + } +} + +// MakeGetBlocksByNumResponseMessage makes the GetBlocksByNumResponse of Message type +func MakeGetBlocksByNumResponseMessage(rid uint64, blocksBytes [][]byte) *Message { + resp := MakeGetBlocksByNumResponse(rid, blocksBytes) + return makeMessageFromResponse(resp) +} + +// MakeGetBlocksByNumResponseMessage make the GetBlocksByNumResponse of Response type +func MakeGetBlocksByNumResponse(rid uint64, blocksBytes [][]byte) *Response { + return &Response{ + ReqId: rid, + Response: &Response_GetBlocksByNumResponse{ + GetBlocksByNumResponse: &GetBlocksByNumResponse{ + BlocksBytes: blocksBytes, + }, + }, + } +} + +// MakeGetBlocksByHashesResponseMessage makes the GetBlocksByHashesResponse of Message type +func MakeGetBlocksByHashesResponseMessage(rid uint64, blocksBytes [][]byte) *Message { + resp := MakeGetBlocksByHashesResponse(rid, blocksBytes) + return makeMessageFromResponse(resp) +} + +// MakeGetBlocksByHashesResponse make the GetBlocksByHashesResponse of Response type +func MakeGetBlocksByHashesResponse(rid uint64, blocksBytes [][]byte) *Response { + return &Response{ + ReqId: rid, + Response: &Response_GetBlocksByHashesResponse{ + GetBlocksByHashesResponse: &GetBlocksByHashesResponse{ + BlocksBytes: blocksBytes, + }, + }, + } +} + +// MakeGetEpochStateResponse makes GetEpochStateResponse as message +func MakeGetEpochStateResponseMessage(rid uint64, headerBytes []byte, ssBytes []byte) *Message { + resp := MakeGetEpochStateResponse(rid, headerBytes, ssBytes) + return makeMessageFromResponse(resp) +} + +// MakeEpochStateResponse makes GetEpochStateResponse as response +func MakeGetEpochStateResponse(rid uint64, headerBytes []byte, ssBytes []byte) *Response { + return &Response{ + ReqId: rid, + Response: &Response_GetEpochStateResponse{ + GetEpochStateResponse: &GetEpochStateResponse{ + HeaderBytes: headerBytes, + ShardState: ssBytes, + }, + }, + } +} + +// MakeMessageFromRequest makes a message from the request +func MakeMessageFromRequest(req *Request) *Message { + return &Message{ + ReqOrResp: &Message_Req{ + Req: req, + }, + } +} + +func makeMessageFromResponse(resp *Response) *Message { + return &Message{ + ReqOrResp: &Message_Resp{ + Resp: resp, + }, + } +} + +func hashesToBytes(hashes []common.Hash) [][]byte { + res := make([][]byte, 0, len(hashes)) + + for _, h := range hashes { + b := make([]byte, common.HashLength) + copy(b, h[:]) + res = append(res, b) + } + return res +} + +func bytesToHashes(bs [][]byte) []common.Hash { + res := make([]common.Hash, len(bs)) + + for _, b := range bs { + var h common.Hash + copy(h[:], b) + res = append(res, h) + } + return res +} diff --git a/p2p/stream/protocols/sync/message/generate.go b/p2p/stream/protocols/sync/message/generate.go new file mode 100644 index 0000000000..881c9fc6f5 --- /dev/null +++ b/p2p/stream/protocols/sync/message/generate.go @@ -0,0 +1,3 @@ +package message + +//go:generate protoc msg.proto --go_out=. diff --git a/p2p/stream/protocols/sync/message/msg.pb.go b/p2p/stream/protocols/sync/message/msg.pb.go new file mode 100644 index 0000000000..e1362fdcb2 --- /dev/null +++ b/p2p/stream/protocols/sync/message/msg.pb.go @@ -0,0 +1,1298 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: msg.proto + +package message + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to ReqOrResp: + // *Message_Req + // *Message_Resp + ReqOrResp isMessage_ReqOrResp `protobuf_oneof:"req_or_resp"` +} + +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{0} +} + +func (m *Message) GetReqOrResp() isMessage_ReqOrResp { + if m != nil { + return m.ReqOrResp + } + return nil +} + +func (x *Message) GetReq() *Request { + if x, ok := x.GetReqOrResp().(*Message_Req); ok { + return x.Req + } + return nil +} + +func (x *Message) GetResp() *Response { + if x, ok := x.GetReqOrResp().(*Message_Resp); ok { + return x.Resp + } + return nil +} + +type isMessage_ReqOrResp interface { + isMessage_ReqOrResp() +} + +type Message_Req struct { + Req *Request `protobuf:"bytes,1,opt,name=req,proto3,oneof"` +} + +type Message_Resp struct { + Resp *Response `protobuf:"bytes,2,opt,name=resp,proto3,oneof"` +} + +func (*Message_Req) isMessage_ReqOrResp() {} + +func (*Message_Resp) isMessage_ReqOrResp() {} + +type Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReqId uint64 `protobuf:"varint,1,opt,name=req_id,json=reqId,proto3" json:"req_id,omitempty"` + // Types that are assignable to Request: + // *Request_GetBlockNumberRequest + // *Request_GetBlockHashesRequest + // *Request_GetBlocksByNumRequest + // *Request_GetBlocksByHashesRequest + // *Request_GetEpochStateRequest + Request isRequest_Request `protobuf_oneof:"request"` +} + +func (x *Request) Reset() { + *x = Request{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *Request) GetReqId() uint64 { + if x != nil { + return x.ReqId + } + return 0 +} + +func (m *Request) GetRequest() isRequest_Request { + if m != nil { + return m.Request + } + return nil +} + +func (x *Request) GetGetBlockNumberRequest() *GetBlockNumberRequest { + if x, ok := x.GetRequest().(*Request_GetBlockNumberRequest); ok { + return x.GetBlockNumberRequest + } + return nil +} + +func (x *Request) GetGetBlockHashesRequest() *GetBlockHashesRequest { + if x, ok := x.GetRequest().(*Request_GetBlockHashesRequest); ok { + return x.GetBlockHashesRequest + } + return nil +} + +func (x *Request) GetGetBlocksByNumRequest() *GetBlocksByNumRequest { + if x, ok := x.GetRequest().(*Request_GetBlocksByNumRequest); ok { + return x.GetBlocksByNumRequest + } + return nil +} + +func (x *Request) GetGetBlocksByHashesRequest() *GetBlocksByHashesRequest { + if x, ok := x.GetRequest().(*Request_GetBlocksByHashesRequest); ok { + return x.GetBlocksByHashesRequest + } + return nil +} + +func (x *Request) GetGetEpochStateRequest() *GetEpochStateRequest { + if x, ok := x.GetRequest().(*Request_GetEpochStateRequest); ok { + return x.GetEpochStateRequest + } + return nil +} + +type isRequest_Request interface { + isRequest_Request() +} + +type Request_GetBlockNumberRequest struct { + GetBlockNumberRequest *GetBlockNumberRequest `protobuf:"bytes,2,opt,name=get_block_number_request,json=getBlockNumberRequest,proto3,oneof"` +} + +type Request_GetBlockHashesRequest struct { + GetBlockHashesRequest *GetBlockHashesRequest `protobuf:"bytes,3,opt,name=get_block_hashes_request,json=getBlockHashesRequest,proto3,oneof"` +} + +type Request_GetBlocksByNumRequest struct { + GetBlocksByNumRequest *GetBlocksByNumRequest `protobuf:"bytes,4,opt,name=get_blocks_by_num_request,json=getBlocksByNumRequest,proto3,oneof"` +} + +type Request_GetBlocksByHashesRequest struct { + GetBlocksByHashesRequest *GetBlocksByHashesRequest `protobuf:"bytes,5,opt,name=get_blocks_by_hashes_request,json=getBlocksByHashesRequest,proto3,oneof"` +} + +type Request_GetEpochStateRequest struct { + GetEpochStateRequest *GetEpochStateRequest `protobuf:"bytes,6,opt,name=get_epoch_state_request,json=getEpochStateRequest,proto3,oneof"` +} + +func (*Request_GetBlockNumberRequest) isRequest_Request() {} + +func (*Request_GetBlockHashesRequest) isRequest_Request() {} + +func (*Request_GetBlocksByNumRequest) isRequest_Request() {} + +func (*Request_GetBlocksByHashesRequest) isRequest_Request() {} + +func (*Request_GetEpochStateRequest) isRequest_Request() {} + +type GetBlockNumberRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetBlockNumberRequest) Reset() { + *x = GetBlockNumberRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockNumberRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockNumberRequest) ProtoMessage() {} + +func (x *GetBlockNumberRequest) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockNumberRequest.ProtoReflect.Descriptor instead. +func (*GetBlockNumberRequest) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{2} +} + +type GetBlockHashesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nums []uint64 `protobuf:"varint,1,rep,packed,name=nums,proto3" json:"nums,omitempty"` +} + +func (x *GetBlockHashesRequest) Reset() { + *x = GetBlockHashesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHashesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHashesRequest) ProtoMessage() {} + +func (x *GetBlockHashesRequest) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHashesRequest.ProtoReflect.Descriptor instead. +func (*GetBlockHashesRequest) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *GetBlockHashesRequest) GetNums() []uint64 { + if x != nil { + return x.Nums + } + return nil +} + +type GetBlocksByNumRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nums []uint64 `protobuf:"varint,1,rep,packed,name=nums,proto3" json:"nums,omitempty"` +} + +func (x *GetBlocksByNumRequest) Reset() { + *x = GetBlocksByNumRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlocksByNumRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlocksByNumRequest) ProtoMessage() {} + +func (x *GetBlocksByNumRequest) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlocksByNumRequest.ProtoReflect.Descriptor instead. +func (*GetBlocksByNumRequest) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *GetBlocksByNumRequest) GetNums() []uint64 { + if x != nil { + return x.Nums + } + return nil +} + +type GetBlocksByHashesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockHashes [][]byte `protobuf:"bytes,1,rep,name=block_hashes,json=blockHashes,proto3" json:"block_hashes,omitempty"` +} + +func (x *GetBlocksByHashesRequest) Reset() { + *x = GetBlocksByHashesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlocksByHashesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlocksByHashesRequest) ProtoMessage() {} + +func (x *GetBlocksByHashesRequest) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlocksByHashesRequest.ProtoReflect.Descriptor instead. +func (*GetBlocksByHashesRequest) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *GetBlocksByHashesRequest) GetBlockHashes() [][]byte { + if x != nil { + return x.BlockHashes + } + return nil +} + +type GetEpochStateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` +} + +func (x *GetEpochStateRequest) Reset() { + *x = GetEpochStateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetEpochStateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetEpochStateRequest) ProtoMessage() {} + +func (x *GetEpochStateRequest) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetEpochStateRequest.ProtoReflect.Descriptor instead. +func (*GetEpochStateRequest) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{6} +} + +func (x *GetEpochStateRequest) GetEpoch() uint64 { + if x != nil { + return x.Epoch + } + return 0 +} + +type Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReqId uint64 `protobuf:"varint,1,opt,name=req_id,json=reqId,proto3" json:"req_id,omitempty"` + // Types that are assignable to Response: + // *Response_ErrorResponse + // *Response_GetBlockNumberResponse + // *Response_GetBlockHashesResponse + // *Response_GetBlocksByNumResponse + // *Response_GetBlocksByHashesResponse + // *Response_GetEpochStateResponse + Response isResponse_Response `protobuf_oneof:"response"` +} + +func (x *Response) Reset() { + *x = Response{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Response) ProtoMessage() {} + +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Response.ProtoReflect.Descriptor instead. +func (*Response) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *Response) GetReqId() uint64 { + if x != nil { + return x.ReqId + } + return 0 +} + +func (m *Response) GetResponse() isResponse_Response { + if m != nil { + return m.Response + } + return nil +} + +func (x *Response) GetErrorResponse() *ErrorResponse { + if x, ok := x.GetResponse().(*Response_ErrorResponse); ok { + return x.ErrorResponse + } + return nil +} + +func (x *Response) GetGetBlockNumberResponse() *GetBlockNumberResponse { + if x, ok := x.GetResponse().(*Response_GetBlockNumberResponse); ok { + return x.GetBlockNumberResponse + } + return nil +} + +func (x *Response) GetGetBlockHashesResponse() *GetBlockHashesResponse { + if x, ok := x.GetResponse().(*Response_GetBlockHashesResponse); ok { + return x.GetBlockHashesResponse + } + return nil +} + +func (x *Response) GetGetBlocksByNumResponse() *GetBlocksByNumResponse { + if x, ok := x.GetResponse().(*Response_GetBlocksByNumResponse); ok { + return x.GetBlocksByNumResponse + } + return nil +} + +func (x *Response) GetGetBlocksByHashesResponse() *GetBlocksByHashesResponse { + if x, ok := x.GetResponse().(*Response_GetBlocksByHashesResponse); ok { + return x.GetBlocksByHashesResponse + } + return nil +} + +func (x *Response) GetGetEpochStateResponse() *GetEpochStateResponse { + if x, ok := x.GetResponse().(*Response_GetEpochStateResponse); ok { + return x.GetEpochStateResponse + } + return nil +} + +type isResponse_Response interface { + isResponse_Response() +} + +type Response_ErrorResponse struct { + ErrorResponse *ErrorResponse `protobuf:"bytes,2,opt,name=error_response,json=errorResponse,proto3,oneof"` +} + +type Response_GetBlockNumberResponse struct { + GetBlockNumberResponse *GetBlockNumberResponse `protobuf:"bytes,3,opt,name=get_block_number_response,json=getBlockNumberResponse,proto3,oneof"` +} + +type Response_GetBlockHashesResponse struct { + GetBlockHashesResponse *GetBlockHashesResponse `protobuf:"bytes,4,opt,name=get_block_hashes_response,json=getBlockHashesResponse,proto3,oneof"` +} + +type Response_GetBlocksByNumResponse struct { + GetBlocksByNumResponse *GetBlocksByNumResponse `protobuf:"bytes,5,opt,name=get_blocks_by_num_response,json=getBlocksByNumResponse,proto3,oneof"` +} + +type Response_GetBlocksByHashesResponse struct { + GetBlocksByHashesResponse *GetBlocksByHashesResponse `protobuf:"bytes,6,opt,name=get_blocks_by_hashes_response,json=getBlocksByHashesResponse,proto3,oneof"` +} + +type Response_GetEpochStateResponse struct { + GetEpochStateResponse *GetEpochStateResponse `protobuf:"bytes,7,opt,name=get_epoch_state_response,json=getEpochStateResponse,proto3,oneof"` +} + +func (*Response_ErrorResponse) isResponse_Response() {} + +func (*Response_GetBlockNumberResponse) isResponse_Response() {} + +func (*Response_GetBlockHashesResponse) isResponse_Response() {} + +func (*Response_GetBlocksByNumResponse) isResponse_Response() {} + +func (*Response_GetBlocksByHashesResponse) isResponse_Response() {} + +func (*Response_GetEpochStateResponse) isResponse_Response() {} + +type ErrorResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *ErrorResponse) Reset() { + *x = ErrorResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ErrorResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ErrorResponse) ProtoMessage() {} + +func (x *ErrorResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. +func (*ErrorResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{8} +} + +func (x *ErrorResponse) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type GetBlockNumberResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (x *GetBlockNumberResponse) Reset() { + *x = GetBlockNumberResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockNumberResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockNumberResponse) ProtoMessage() {} + +func (x *GetBlockNumberResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockNumberResponse.ProtoReflect.Descriptor instead. +func (*GetBlockNumberResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{9} +} + +func (x *GetBlockNumberResponse) GetNumber() uint64 { + if x != nil { + return x.Number + } + return 0 +} + +type GetBlockHashesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hashes [][]byte `protobuf:"bytes,1,rep,name=hashes,proto3" json:"hashes,omitempty"` +} + +func (x *GetBlockHashesResponse) Reset() { + *x = GetBlockHashesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHashesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHashesResponse) ProtoMessage() {} + +func (x *GetBlockHashesResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHashesResponse.ProtoReflect.Descriptor instead. +func (*GetBlockHashesResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{10} +} + +func (x *GetBlockHashesResponse) GetHashes() [][]byte { + if x != nil { + return x.Hashes + } + return nil +} + +type GetBlocksByNumResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlocksBytes [][]byte `protobuf:"bytes,1,rep,name=blocks_bytes,json=blocksBytes,proto3" json:"blocks_bytes,omitempty"` +} + +func (x *GetBlocksByNumResponse) Reset() { + *x = GetBlocksByNumResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlocksByNumResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlocksByNumResponse) ProtoMessage() {} + +func (x *GetBlocksByNumResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlocksByNumResponse.ProtoReflect.Descriptor instead. +func (*GetBlocksByNumResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{11} +} + +func (x *GetBlocksByNumResponse) GetBlocksBytes() [][]byte { + if x != nil { + return x.BlocksBytes + } + return nil +} + +type GetBlocksByHashesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlocksBytes [][]byte `protobuf:"bytes,1,rep,name=blocks_bytes,json=blocksBytes,proto3" json:"blocks_bytes,omitempty"` +} + +func (x *GetBlocksByHashesResponse) Reset() { + *x = GetBlocksByHashesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlocksByHashesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlocksByHashesResponse) ProtoMessage() {} + +func (x *GetBlocksByHashesResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlocksByHashesResponse.ProtoReflect.Descriptor instead. +func (*GetBlocksByHashesResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{12} +} + +func (x *GetBlocksByHashesResponse) GetBlocksBytes() [][]byte { + if x != nil { + return x.BlocksBytes + } + return nil +} + +type GetEpochStateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + HeaderBytes []byte `protobuf:"bytes,1,opt,name=header_bytes,json=headerBytes,proto3" json:"header_bytes,omitempty"` + ShardState []byte `protobuf:"bytes,2,opt,name=shard_state,json=shardState,proto3" json:"shard_state,omitempty"` +} + +func (x *GetEpochStateResponse) Reset() { + *x = GetEpochStateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetEpochStateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetEpochStateResponse) ProtoMessage() {} + +func (x *GetEpochStateResponse) ProtoReflect() protoreflect.Message { + mi := &file_msg_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetEpochStateResponse.ProtoReflect.Descriptor instead. +func (*GetEpochStateResponse) Descriptor() ([]byte, []int) { + return file_msg_proto_rawDescGZIP(), []int{13} +} + +func (x *GetEpochStateResponse) GetHeaderBytes() []byte { + if x != nil { + return x.HeaderBytes + } + return nil +} + +func (x *GetEpochStateResponse) GetShardState() []byte { + if x != nil { + return x.ShardState + } + return nil +} + +var File_msg_proto protoreflect.FileDescriptor + +var file_msg_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x68, 0x61, 0x72, + 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, + 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x07, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x03, 0x72, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x03, 0x72, 0x65, 0x71, 0x12, 0x3b, + 0x0a, 0x04, 0x72, 0x65, 0x73, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x68, + 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, + 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x04, 0x72, 0x65, 0x73, 0x70, 0x42, 0x0d, 0x0a, 0x0b, 0x72, + 0x65, 0x71, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x22, 0xde, 0x04, 0x0a, 0x07, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x71, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x72, 0x65, 0x71, 0x49, 0x64, 0x12, 0x6d, 0x0a, + 0x18, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x32, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x6d, 0x0a, 0x18, + 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, + 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, + 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x6e, 0x0a, 0x19, 0x67, + 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x6e, 0x75, 0x6d, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, + 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, + 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x77, 0x0a, 0x1c, 0x67, + 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x68, 0x61, 0x73, + 0x68, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x18, 0x67, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x6a, 0x0a, 0x17, 0x67, 0x65, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, + 0x68, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x14, 0x67, 0x65, 0x74, 0x45, + 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x42, 0x09, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x17, 0x0a, 0x15, 0x47, + 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, + 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52, + 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x2f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, + 0x0a, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, + 0x52, 0x04, 0x6e, 0x75, 0x6d, 0x73, 0x22, 0x3d, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, + 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x22, 0xc4, 0x05, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x15, 0x0a, 0x06, 0x72, 0x65, 0x71, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x05, 0x72, 0x65, 0x71, 0x49, 0x64, 0x12, 0x53, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70, 0x0a, 0x19, + 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x70, + 0x0a, 0x19, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x71, 0x0a, 0x1a, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, + 0x79, 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x67, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x7a, 0x0a, 0x1d, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x68, 0x61, 0x72, + 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, + 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x48, 0x00, 0x52, 0x19, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, + 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x6d, 0x0a, 0x18, 0x67, 0x65, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x32, 0x2e, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2e, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x15, 0x67, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, + 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, + 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0d, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x68, 0x61, 0x73, 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x06, 0x68, + 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0x3b, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x22, 0x3e, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, + 0x79, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0b, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1f, + 0x0a, 0x0b, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, + 0x09, 0x5a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_msg_proto_rawDescOnce sync.Once + file_msg_proto_rawDescData = file_msg_proto_rawDesc +) + +func file_msg_proto_rawDescGZIP() []byte { + file_msg_proto_rawDescOnce.Do(func() { + file_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_msg_proto_rawDescData) + }) + return file_msg_proto_rawDescData +} + +var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_msg_proto_goTypes = []interface{}{ + (*Message)(nil), // 0: harmony.stream.sync.message.Message + (*Request)(nil), // 1: harmony.stream.sync.message.Request + (*GetBlockNumberRequest)(nil), // 2: harmony.stream.sync.message.GetBlockNumberRequest + (*GetBlockHashesRequest)(nil), // 3: harmony.stream.sync.message.GetBlockHashesRequest + (*GetBlocksByNumRequest)(nil), // 4: harmony.stream.sync.message.GetBlocksByNumRequest + (*GetBlocksByHashesRequest)(nil), // 5: harmony.stream.sync.message.GetBlocksByHashesRequest + (*GetEpochStateRequest)(nil), // 6: harmony.stream.sync.message.GetEpochStateRequest + (*Response)(nil), // 7: harmony.stream.sync.message.Response + (*ErrorResponse)(nil), // 8: harmony.stream.sync.message.ErrorResponse + (*GetBlockNumberResponse)(nil), // 9: harmony.stream.sync.message.GetBlockNumberResponse + (*GetBlockHashesResponse)(nil), // 10: harmony.stream.sync.message.GetBlockHashesResponse + (*GetBlocksByNumResponse)(nil), // 11: harmony.stream.sync.message.GetBlocksByNumResponse + (*GetBlocksByHashesResponse)(nil), // 12: harmony.stream.sync.message.GetBlocksByHashesResponse + (*GetEpochStateResponse)(nil), // 13: harmony.stream.sync.message.GetEpochStateResponse +} +var file_msg_proto_depIdxs = []int32{ + 1, // 0: harmony.stream.sync.message.Message.req:type_name -> harmony.stream.sync.message.Request + 7, // 1: harmony.stream.sync.message.Message.resp:type_name -> harmony.stream.sync.message.Response + 2, // 2: harmony.stream.sync.message.Request.get_block_number_request:type_name -> harmony.stream.sync.message.GetBlockNumberRequest + 3, // 3: harmony.stream.sync.message.Request.get_block_hashes_request:type_name -> harmony.stream.sync.message.GetBlockHashesRequest + 4, // 4: harmony.stream.sync.message.Request.get_blocks_by_num_request:type_name -> harmony.stream.sync.message.GetBlocksByNumRequest + 5, // 5: harmony.stream.sync.message.Request.get_blocks_by_hashes_request:type_name -> harmony.stream.sync.message.GetBlocksByHashesRequest + 6, // 6: harmony.stream.sync.message.Request.get_epoch_state_request:type_name -> harmony.stream.sync.message.GetEpochStateRequest + 8, // 7: harmony.stream.sync.message.Response.error_response:type_name -> harmony.stream.sync.message.ErrorResponse + 9, // 8: harmony.stream.sync.message.Response.get_block_number_response:type_name -> harmony.stream.sync.message.GetBlockNumberResponse + 10, // 9: harmony.stream.sync.message.Response.get_block_hashes_response:type_name -> harmony.stream.sync.message.GetBlockHashesResponse + 11, // 10: harmony.stream.sync.message.Response.get_blocks_by_num_response:type_name -> harmony.stream.sync.message.GetBlocksByNumResponse + 12, // 11: harmony.stream.sync.message.Response.get_blocks_by_hashes_response:type_name -> harmony.stream.sync.message.GetBlocksByHashesResponse + 13, // 12: harmony.stream.sync.message.Response.get_epoch_state_response:type_name -> harmony.stream.sync.message.GetEpochStateResponse + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name +} + +func init() { file_msg_proto_init() } +func file_msg_proto_init() { + if File_msg_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockNumberRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockHashesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlocksByNumRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlocksByHashesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetEpochStateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ErrorResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockNumberResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockHashesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlocksByNumResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlocksByHashesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_msg_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetEpochStateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_msg_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Message_Req)(nil), + (*Message_Resp)(nil), + } + file_msg_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*Request_GetBlockNumberRequest)(nil), + (*Request_GetBlockHashesRequest)(nil), + (*Request_GetBlocksByNumRequest)(nil), + (*Request_GetBlocksByHashesRequest)(nil), + (*Request_GetEpochStateRequest)(nil), + } + file_msg_proto_msgTypes[7].OneofWrappers = []interface{}{ + (*Response_ErrorResponse)(nil), + (*Response_GetBlockNumberResponse)(nil), + (*Response_GetBlockHashesResponse)(nil), + (*Response_GetBlocksByNumResponse)(nil), + (*Response_GetBlocksByHashesResponse)(nil), + (*Response_GetEpochStateResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 14, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_msg_proto_goTypes, + DependencyIndexes: file_msg_proto_depIdxs, + MessageInfos: file_msg_proto_msgTypes, + }.Build() + File_msg_proto = out.File + file_msg_proto_rawDesc = nil + file_msg_proto_goTypes = nil + file_msg_proto_depIdxs = nil +} diff --git a/p2p/stream/protocols/sync/message/msg.proto b/p2p/stream/protocols/sync/message/msg.proto new file mode 100644 index 0000000000..90b5edf8f6 --- /dev/null +++ b/p2p/stream/protocols/sync/message/msg.proto @@ -0,0 +1,80 @@ +syntax = "proto3"; +package harmony.stream.sync.message ; + +option go_package = "message"; + +message Message { + oneof req_or_resp { + Request req = 1; + Response resp = 2; + } +} + +message Request { + uint64 req_id = 1; + oneof request { + GetBlockNumberRequest get_block_number_request = 2; + GetBlockHashesRequest get_block_hashes_request = 3; + GetBlocksByNumRequest get_blocks_by_num_request = 4; + GetBlocksByHashesRequest get_blocks_by_hashes_request = 5; + GetEpochStateRequest get_epoch_state_request = 6; + } +} + +message GetBlockNumberRequest {} + +message GetBlockHashesRequest { + repeated uint64 nums = 1 [packed=true]; +} + +message GetBlocksByNumRequest { + repeated uint64 nums = 1 [packed=true]; +} + +message GetBlocksByHashesRequest { + repeated bytes block_hashes = 1; +} + +message GetEpochStateRequest { + uint64 epoch = 1; +} + +message Response { + uint64 req_id = 1; + oneof response { + ErrorResponse error_response = 2; + GetBlockNumberResponse get_block_number_response = 3; + GetBlockHashesResponse get_block_hashes_response = 4; + GetBlocksByNumResponse get_blocks_by_num_response = 5; + GetBlocksByHashesResponse get_blocks_by_hashes_response = 6; + GetEpochStateResponse get_epoch_state_response = 7; + } +} + +message ErrorResponse { + string error = 1; +} + +message GetBlockNumberResponse { + uint64 number = 1; +} + +message GetBlockHashesResponse { + repeated bytes hashes = 1; +} + +message GetBlocksByNumResponse { + repeated bytes blocks_bytes = 1; +} + +message GetBlocksByHashesResponse { + repeated bytes blocks_bytes = 1; +} + +message GetEpochStateResponse { + bytes header_bytes = 1; + bytes shard_state = 2; +} + + + diff --git a/p2p/stream/protocols/sync/message/parse.go b/p2p/stream/protocols/sync/message/parse.go new file mode 100644 index 0000000000..6dd2ff3541 --- /dev/null +++ b/p2p/stream/protocols/sync/message/parse.go @@ -0,0 +1,97 @@ +package message + +import ( + "fmt" + + "github.com/pkg/errors" +) + +// ResponseError is the error from an error response +type ResponseError struct { + msg string +} + +// Error is the error string of ResponseError +func (err *ResponseError) Error() string { + return fmt.Sprintf("[RESPONSE] %v", err.msg) +} + +// GetBlockNumberResponse parse the message to GetBlockNumberResponse +func (msg *Message) GetBlockNumberResponse() (*GetBlockNumberResponse, error) { + resp := msg.GetResp() + if resp == nil { + return nil, errors.New("not response message") + } + if errResp := resp.GetErrorResponse(); errResp != nil { + return nil, &ResponseError{errResp.Error} + } + bnResp := resp.GetGetBlockNumberResponse() + if bnResp == nil { + return nil, errors.New("not GetBlockNumber response") + } + return bnResp, nil +} + +// GetBlockHashesResponse parse the message to GetBlockHashesResponse +func (msg *Message) GetBlockHashesResponse() (*GetBlockHashesResponse, error) { + resp := msg.GetResp() + if resp == nil { + return nil, errors.New("not response message") + } + if errResp := resp.GetErrorResponse(); errResp != nil { + return nil, &ResponseError{errResp.Error} + } + ghResp := resp.GetGetBlockHashesResponse() + if ghResp == nil { + return nil, errors.New("not GetBlockHashesResponse") + } + return ghResp, nil +} + +// GetBlocksByNumberResponse parse the message to GetBlocksByNumberResponse +func (msg *Message) GetBlocksByNumberResponse() (*GetBlocksByNumResponse, error) { + resp := msg.GetResp() + if resp == nil { + return nil, errors.New("not response message") + } + if errResp := resp.GetErrorResponse(); errResp != nil { + return nil, &ResponseError{errResp.Error} + } + gbResp := resp.GetGetBlocksByNumResponse() + if gbResp == nil { + return nil, errors.New("not GetBlocksByNumResponse") + } + return gbResp, nil +} + +// GetBlocksByHashesResponse parse the message to GetBlocksByHashesResponse +func (msg *Message) GetBlocksByHashesResponse() (*GetBlocksByHashesResponse, error) { + resp := msg.GetResp() + if resp == nil { + return nil, errors.New("not response message") + } + if errResp := resp.GetErrorResponse(); errResp != nil { + return nil, &ResponseError{errResp.Error} + } + gbResp := resp.GetGetBlocksByHashesResponse() + if gbResp == nil { + return nil, errors.New("not GetBlocksByHashesResponse") + } + return gbResp, nil +} + +// GetEpochStateResponse parse the message to GetEpochStateResponse +func (msg *Message) GetEpochStateResponse() (*GetEpochStateResponse, error) { + resp := msg.GetResp() + if resp == nil { + return nil, errors.New("not response message") + } + if errResp := resp.GetErrorResponse(); errResp != nil { + return nil, &ResponseError{errResp.Error} + } + gesResp := resp.GetGetEpochStateResponse() + if gesResp == nil { + return nil, errors.New("not GetEpochStateResponse") + } + return gesResp, nil +}