diff --git a/grpc-server.go b/grpc-server.go index 153c2b10..7d98bf7b 100644 --- a/grpc-server.go +++ b/grpc-server.go @@ -429,3 +429,134 @@ func (multi *MultiEpoch) GetTransaction(ctx context.Context, params *old_faithfu return response, nil } + +func (multi *MultiEpoch) Get(ser old_faithful_grpc.OldFaithful_GetServer) error { + ctx := ser.Context() + + for { + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + req, err := ser.Recv() + if err != nil { + if errors.Is(err, io.EOF) { + return nil + } + return err + } + id := req.GetId() + + switch req.Request.(type) { + case *old_faithful_grpc.GetRequest_Block: + params := req.GetBlock() + resp, err := multi.GetBlock(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send block error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get block: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Block{Block: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send block response: %v", id, err) + } + case *old_faithful_grpc.GetRequest_Transaction: + params := req.GetTransaction() + resp, err := multi.GetTransaction(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send transaction error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get transaction: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Transaction{Transaction: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send transaction response: %v", id, err) + } + case *old_faithful_grpc.GetRequest_Version: + params := req.GetVersion() + resp, err := multi.GetVersion(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send version error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get version: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Version{Version: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send version response: %v", id, err) + } + default: + return status.Errorf(codes.InvalidArgument, "unknown request type %T", req.Request) + } + } +} diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go index 7582fa9e..f82ad7bc 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.1 // source: old-faithful.proto @@ -20,6 +20,52 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type GetResponseErrorCode int32 + +const ( + GetResponseErrorCode_INTERNAL GetResponseErrorCode = 0 + GetResponseErrorCode_NOT_FOUND GetResponseErrorCode = 1 +) + +// Enum value maps for GetResponseErrorCode. +var ( + GetResponseErrorCode_name = map[int32]string{ + 0: "INTERNAL", + 1: "NOT_FOUND", + } + GetResponseErrorCode_value = map[string]int32{ + "INTERNAL": 0, + "NOT_FOUND": 1, + } +) + +func (x GetResponseErrorCode) Enum() *GetResponseErrorCode { + p := new(GetResponseErrorCode) + *p = x + return p +} + +func (x GetResponseErrorCode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (GetResponseErrorCode) Descriptor() protoreflect.EnumDescriptor { + return file_old_faithful_proto_enumTypes[0].Descriptor() +} + +func (GetResponseErrorCode) Type() protoreflect.EnumType { + return &file_old_faithful_proto_enumTypes[0] +} + +func (x GetResponseErrorCode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use GetResponseErrorCode.Descriptor instead. +func (GetResponseErrorCode) EnumDescriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{0} +} + type VersionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -436,6 +482,281 @@ func (x *Transaction) GetIndex() uint64 { return 0 } +type GetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Types that are assignable to Request: + // + // *GetRequest_Version + // *GetRequest_Block + // *GetRequest_Transaction + Request isGetRequest_Request `protobuf_oneof:"request"` +} + +func (x *GetRequest) Reset() { + *x = GetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequest) ProtoMessage() {} + +func (x *GetRequest) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_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 GetRequest.ProtoReflect.Descriptor instead. +func (*GetRequest) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{7} +} + +func (x *GetRequest) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (m *GetRequest) GetRequest() isGetRequest_Request { + if m != nil { + return m.Request + } + return nil +} + +func (x *GetRequest) GetVersion() *VersionRequest { + if x, ok := x.GetRequest().(*GetRequest_Version); ok { + return x.Version + } + return nil +} + +func (x *GetRequest) GetBlock() *BlockRequest { + if x, ok := x.GetRequest().(*GetRequest_Block); ok { + return x.Block + } + return nil +} + +func (x *GetRequest) GetTransaction() *TransactionRequest { + if x, ok := x.GetRequest().(*GetRequest_Transaction); ok { + return x.Transaction + } + return nil +} + +type isGetRequest_Request interface { + isGetRequest_Request() +} + +type GetRequest_Version struct { + Version *VersionRequest `protobuf:"bytes,2,opt,name=version,proto3,oneof"` +} + +type GetRequest_Block struct { + Block *BlockRequest `protobuf:"bytes,3,opt,name=block,proto3,oneof"` +} + +type GetRequest_Transaction struct { + Transaction *TransactionRequest `protobuf:"bytes,4,opt,name=transaction,proto3,oneof"` +} + +func (*GetRequest_Version) isGetRequest_Request() {} + +func (*GetRequest_Block) isGetRequest_Request() {} + +func (*GetRequest_Transaction) isGetRequest_Request() {} + +type GetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Types that are assignable to Response: + // + // *GetResponse_Error + // *GetResponse_Version + // *GetResponse_Block + // *GetResponse_Transaction + Response isGetResponse_Response `protobuf_oneof:"response"` +} + +func (x *GetResponse) Reset() { + *x = GetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResponse) ProtoMessage() {} + +func (x *GetResponse) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_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 GetResponse.ProtoReflect.Descriptor instead. +func (*GetResponse) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{8} +} + +func (x *GetResponse) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (m *GetResponse) GetResponse() isGetResponse_Response { + if m != nil { + return m.Response + } + return nil +} + +func (x *GetResponse) GetError() *GetResponseError { + if x, ok := x.GetResponse().(*GetResponse_Error); ok { + return x.Error + } + return nil +} + +func (x *GetResponse) GetVersion() *VersionResponse { + if x, ok := x.GetResponse().(*GetResponse_Version); ok { + return x.Version + } + return nil +} + +func (x *GetResponse) GetBlock() *BlockResponse { + if x, ok := x.GetResponse().(*GetResponse_Block); ok { + return x.Block + } + return nil +} + +func (x *GetResponse) GetTransaction() *TransactionResponse { + if x, ok := x.GetResponse().(*GetResponse_Transaction); ok { + return x.Transaction + } + return nil +} + +type isGetResponse_Response interface { + isGetResponse_Response() +} + +type GetResponse_Error struct { + Error *GetResponseError `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +type GetResponse_Version struct { + Version *VersionResponse `protobuf:"bytes,3,opt,name=version,proto3,oneof"` +} + +type GetResponse_Block struct { + Block *BlockResponse `protobuf:"bytes,4,opt,name=block,proto3,oneof"` +} + +type GetResponse_Transaction struct { + Transaction *TransactionResponse `protobuf:"bytes,5,opt,name=transaction,proto3,oneof"` +} + +func (*GetResponse_Error) isGetResponse_Response() {} + +func (*GetResponse_Version) isGetResponse_Response() {} + +func (*GetResponse_Block) isGetResponse_Response() {} + +func (*GetResponse_Transaction) isGetResponse_Response() {} + +type GetResponseError struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code GetResponseErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=OldFaithful.GetResponseErrorCode" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *GetResponseError) Reset() { + *x = GetResponseError{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetResponseError) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResponseError) ProtoMessage() {} + +func (x *GetResponseError) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_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 GetResponseError.ProtoReflect.Descriptor instead. +func (*GetResponseError) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{9} +} + +func (x *GetResponseError) GetCode() GetResponseErrorCode { + if x != nil { + return x.Code + } + return GetResponseErrorCode_INTERNAL +} + +func (x *GetResponseError) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_old_faithful_proto protoreflect.FileDescriptor var file_old_faithful_proto_rawDesc = []byte{ @@ -486,28 +807,72 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x19, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x88, - 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x32, 0xee, 0x01, 0x0a, - 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, - 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, - 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, - 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, - 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, - 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, - 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, - 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, - 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, - 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, - 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, - 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xd8, 0x01, 0x0a, + 0x0a, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x37, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, + 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x43, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, + 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x94, 0x02, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x35, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x38, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x44, 0x0a, 0x0b, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x63, + 0x0a, 0x10, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x21, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, + 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2a, 0x33, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x49, + 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x54, + 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x01, 0x32, 0xac, 0x02, 0x0a, 0x0b, 0x4f, 0x6c, 0x64, + 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x2e, + 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x03, 0x47, 0x65, 0x74, + 0x12, 0x17, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, + 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, + 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, + 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, + 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -522,30 +887,45 @@ func file_old_faithful_proto_rawDescGZIP() []byte { return file_old_faithful_proto_rawDescData } -var file_old_faithful_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_old_faithful_proto_goTypes = []interface{}{ - (*VersionRequest)(nil), // 0: OldFaithful.VersionRequest - (*VersionResponse)(nil), // 1: OldFaithful.VersionResponse - (*BlockRequest)(nil), // 2: OldFaithful.BlockRequest - (*BlockResponse)(nil), // 3: OldFaithful.BlockResponse - (*TransactionRequest)(nil), // 4: OldFaithful.TransactionRequest - (*TransactionResponse)(nil), // 5: OldFaithful.TransactionResponse - (*Transaction)(nil), // 6: OldFaithful.Transaction +var file_old_faithful_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_old_faithful_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_old_faithful_proto_goTypes = []any{ + (GetResponseErrorCode)(0), // 0: OldFaithful.GetResponseErrorCode + (*VersionRequest)(nil), // 1: OldFaithful.VersionRequest + (*VersionResponse)(nil), // 2: OldFaithful.VersionResponse + (*BlockRequest)(nil), // 3: OldFaithful.BlockRequest + (*BlockResponse)(nil), // 4: OldFaithful.BlockResponse + (*TransactionRequest)(nil), // 5: OldFaithful.TransactionRequest + (*TransactionResponse)(nil), // 6: OldFaithful.TransactionResponse + (*Transaction)(nil), // 7: OldFaithful.Transaction + (*GetRequest)(nil), // 8: OldFaithful.GetRequest + (*GetResponse)(nil), // 9: OldFaithful.GetResponse + (*GetResponseError)(nil), // 10: OldFaithful.GetResponseError } var file_old_faithful_proto_depIdxs = []int32{ - 6, // 0: OldFaithful.BlockResponse.transactions:type_name -> OldFaithful.Transaction - 6, // 1: OldFaithful.TransactionResponse.transaction:type_name -> OldFaithful.Transaction - 0, // 2: OldFaithful.OldFaithful.GetVersion:input_type -> OldFaithful.VersionRequest - 2, // 3: OldFaithful.OldFaithful.GetBlock:input_type -> OldFaithful.BlockRequest - 4, // 4: OldFaithful.OldFaithful.GetTransaction:input_type -> OldFaithful.TransactionRequest - 1, // 5: OldFaithful.OldFaithful.GetVersion:output_type -> OldFaithful.VersionResponse - 3, // 6: OldFaithful.OldFaithful.GetBlock:output_type -> OldFaithful.BlockResponse - 5, // 7: OldFaithful.OldFaithful.GetTransaction:output_type -> OldFaithful.TransactionResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 7, // 0: OldFaithful.BlockResponse.transactions:type_name -> OldFaithful.Transaction + 7, // 1: OldFaithful.TransactionResponse.transaction:type_name -> OldFaithful.Transaction + 1, // 2: OldFaithful.GetRequest.version:type_name -> OldFaithful.VersionRequest + 3, // 3: OldFaithful.GetRequest.block:type_name -> OldFaithful.BlockRequest + 5, // 4: OldFaithful.GetRequest.transaction:type_name -> OldFaithful.TransactionRequest + 10, // 5: OldFaithful.GetResponse.error:type_name -> OldFaithful.GetResponseError + 2, // 6: OldFaithful.GetResponse.version:type_name -> OldFaithful.VersionResponse + 4, // 7: OldFaithful.GetResponse.block:type_name -> OldFaithful.BlockResponse + 6, // 8: OldFaithful.GetResponse.transaction:type_name -> OldFaithful.TransactionResponse + 0, // 9: OldFaithful.GetResponseError.code:type_name -> OldFaithful.GetResponseErrorCode + 1, // 10: OldFaithful.OldFaithful.GetVersion:input_type -> OldFaithful.VersionRequest + 3, // 11: OldFaithful.OldFaithful.GetBlock:input_type -> OldFaithful.BlockRequest + 5, // 12: OldFaithful.OldFaithful.GetTransaction:input_type -> OldFaithful.TransactionRequest + 8, // 13: OldFaithful.OldFaithful.Get:input_type -> OldFaithful.GetRequest + 2, // 14: OldFaithful.OldFaithful.GetVersion:output_type -> OldFaithful.VersionResponse + 4, // 15: OldFaithful.OldFaithful.GetBlock:output_type -> OldFaithful.BlockResponse + 6, // 16: OldFaithful.OldFaithful.GetTransaction:output_type -> OldFaithful.TransactionResponse + 9, // 17: OldFaithful.OldFaithful.Get:output_type -> OldFaithful.GetResponse + 14, // [14:18] is the sub-list for method output_type + 10, // [10:14] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_old_faithful_proto_init() } @@ -554,7 +934,7 @@ func file_old_faithful_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_old_faithful_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*VersionRequest); i { case 0: return &v.state @@ -566,7 +946,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*VersionResponse); i { case 0: return &v.state @@ -578,7 +958,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*BlockRequest); i { case 0: return &v.state @@ -590,7 +970,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*BlockResponse); i { case 0: return &v.state @@ -602,7 +982,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*TransactionRequest); i { case 0: return &v.state @@ -614,7 +994,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*TransactionResponse); i { case 0: return &v.state @@ -626,7 +1006,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*Transaction); i { case 0: return &v.state @@ -638,21 +1018,69 @@ func file_old_faithful_proto_init() { return nil } } + file_old_faithful_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*GetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*GetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*GetResponseError); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_old_faithful_proto_msgTypes[5].OneofWrappers = []any{} + file_old_faithful_proto_msgTypes[6].OneofWrappers = []any{} + file_old_faithful_proto_msgTypes[7].OneofWrappers = []any{ + (*GetRequest_Version)(nil), + (*GetRequest_Block)(nil), + (*GetRequest_Transaction)(nil), + } + file_old_faithful_proto_msgTypes[8].OneofWrappers = []any{ + (*GetResponse_Error)(nil), + (*GetResponse_Version)(nil), + (*GetResponse_Block)(nil), + (*GetResponse_Transaction)(nil), } - file_old_faithful_proto_msgTypes[5].OneofWrappers = []interface{}{} - file_old_faithful_proto_msgTypes[6].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_old_faithful_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, + NumEnums: 1, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, GoTypes: file_old_faithful_proto_goTypes, DependencyIndexes: file_old_faithful_proto_depIdxs, + EnumInfos: file_old_faithful_proto_enumTypes, MessageInfos: file_old_faithful_proto_msgTypes, }.Build() File_old_faithful_proto = out.File diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go index 40e16525..9dd448db 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go @@ -22,6 +22,7 @@ const ( OldFaithful_GetVersion_FullMethodName = "/OldFaithful.OldFaithful/GetVersion" OldFaithful_GetBlock_FullMethodName = "/OldFaithful.OldFaithful/GetBlock" OldFaithful_GetTransaction_FullMethodName = "/OldFaithful.OldFaithful/GetTransaction" + OldFaithful_Get_FullMethodName = "/OldFaithful.OldFaithful/Get" ) // OldFaithfulClient is the client API for OldFaithful service. @@ -31,6 +32,7 @@ type OldFaithfulClient interface { GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) GetBlock(ctx context.Context, in *BlockRequest, opts ...grpc.CallOption) (*BlockResponse, error) GetTransaction(ctx context.Context, in *TransactionRequest, opts ...grpc.CallOption) (*TransactionResponse, error) + Get(ctx context.Context, opts ...grpc.CallOption) (OldFaithful_GetClient, error) } type oldFaithfulClient struct { @@ -71,6 +73,38 @@ func (c *oldFaithfulClient) GetTransaction(ctx context.Context, in *TransactionR return out, nil } +func (c *oldFaithfulClient) Get(ctx context.Context, opts ...grpc.CallOption) (OldFaithful_GetClient, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &OldFaithful_ServiceDesc.Streams[0], OldFaithful_Get_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &oldFaithfulGetClient{ClientStream: stream} + return x, nil +} + +type OldFaithful_GetClient interface { + Send(*GetRequest) error + Recv() (*GetResponse, error) + grpc.ClientStream +} + +type oldFaithfulGetClient struct { + grpc.ClientStream +} + +func (x *oldFaithfulGetClient) Send(m *GetRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *oldFaithfulGetClient) Recv() (*GetResponse, error) { + m := new(GetResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // OldFaithfulServer is the server API for OldFaithful service. // All implementations must embed UnimplementedOldFaithfulServer // for forward compatibility @@ -78,6 +112,7 @@ type OldFaithfulServer interface { GetVersion(context.Context, *VersionRequest) (*VersionResponse, error) GetBlock(context.Context, *BlockRequest) (*BlockResponse, error) GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) + Get(OldFaithful_GetServer) error mustEmbedUnimplementedOldFaithfulServer() } @@ -94,6 +129,9 @@ func (UnimplementedOldFaithfulServer) GetBlock(context.Context, *BlockRequest) ( func (UnimplementedOldFaithfulServer) GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetTransaction not implemented") } +func (UnimplementedOldFaithfulServer) Get(OldFaithful_GetServer) error { + return status.Errorf(codes.Unimplemented, "method Get not implemented") +} func (UnimplementedOldFaithfulServer) mustEmbedUnimplementedOldFaithfulServer() {} // UnsafeOldFaithfulServer may be embedded to opt out of forward compatibility for this service. @@ -161,6 +199,32 @@ func _OldFaithful_GetTransaction_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _OldFaithful_Get_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(OldFaithfulServer).Get(&oldFaithfulGetServer{ServerStream: stream}) +} + +type OldFaithful_GetServer interface { + Send(*GetResponse) error + Recv() (*GetRequest, error) + grpc.ServerStream +} + +type oldFaithfulGetServer struct { + grpc.ServerStream +} + +func (x *oldFaithfulGetServer) Send(m *GetResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *oldFaithfulGetServer) Recv() (*GetRequest, error) { + m := new(GetRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // OldFaithful_ServiceDesc is the grpc.ServiceDesc for OldFaithful service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -181,6 +245,13 @@ var OldFaithful_ServiceDesc = grpc.ServiceDesc{ Handler: _OldFaithful_GetTransaction_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Get", + Handler: _OldFaithful_Get_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, Metadata: "old-faithful.proto", } diff --git a/old-faithful-proto/proto/old-faithful.proto b/old-faithful-proto/proto/old-faithful.proto index efd1c8ee..f089a4d8 100644 --- a/old-faithful-proto/proto/old-faithful.proto +++ b/old-faithful-proto/proto/old-faithful.proto @@ -8,6 +8,8 @@ service OldFaithful { rpc GetBlock(BlockRequest) returns (BlockResponse); rpc GetTransaction(TransactionRequest) returns (TransactionResponse); + + rpc Get(stream GetRequest) returns (stream GetResponse); } message VersionRequest {} @@ -47,3 +49,32 @@ message Transaction { bytes meta = 2; // bincode or protobuf optional uint64 index = 4; // position in the block } + +message GetRequest { + uint64 id = 1; + oneof request { + VersionRequest version = 2; + BlockRequest block = 3; + TransactionRequest transaction = 4; + } +} + +message GetResponse { + uint64 id = 1; + oneof response { + GetResponseError error = 2; + VersionResponse version = 3; + BlockResponse block = 4; + TransactionResponse transaction = 5; + } +} + +enum GetResponseErrorCode { + INTERNAL = 0; + NOT_FOUND = 1; +} + +message GetResponseError { + GetResponseErrorCode code = 1; + string message = 2; +}