diff --git a/Makefile b/Makefile index afdfa9d2..50b46882 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ proto: protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. net/streampool/testservice/protos/*.proto protoc --gogofaster_out=:. net/secureservice/handshake/handshakeproto/protos/*.proto + protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. coordinator/coordinatorproto/protos/*.proto deps: go mod download diff --git a/coordinator/coordinatorproto/coordinator.pb.go b/coordinator/coordinatorproto/coordinator.pb.go new file mode 100644 index 00000000..fdd764ad --- /dev/null +++ b/coordinator/coordinatorproto/coordinator.pb.go @@ -0,0 +1,1485 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: coordinator/coordinatorproto/protos/coordinator.proto + +package coordinatorproto + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type SpaceSignRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` +} + +func (m *SpaceSignRequest) Reset() { *m = SpaceSignRequest{} } +func (m *SpaceSignRequest) String() string { return proto.CompactTextString(m) } +func (*SpaceSignRequest) ProtoMessage() {} +func (*SpaceSignRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{0} +} +func (m *SpaceSignRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceSignRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceSignRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpaceSignRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceSignRequest.Merge(m, src) +} +func (m *SpaceSignRequest) XXX_Size() int { + return m.Size() +} +func (m *SpaceSignRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceSignRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceSignRequest proto.InternalMessageInfo + +func (m *SpaceSignRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +type SpaceSignResponse struct { + Receipt *SpaceReceiptWithSignature `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` +} + +func (m *SpaceSignResponse) Reset() { *m = SpaceSignResponse{} } +func (m *SpaceSignResponse) String() string { return proto.CompactTextString(m) } +func (*SpaceSignResponse) ProtoMessage() {} +func (*SpaceSignResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{1} +} +func (m *SpaceSignResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceSignResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceSignResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpaceSignResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceSignResponse.Merge(m, src) +} +func (m *SpaceSignResponse) XXX_Size() int { + return m.Size() +} +func (m *SpaceSignResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceSignResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceSignResponse proto.InternalMessageInfo + +func (m *SpaceSignResponse) GetReceipt() *SpaceReceiptWithSignature { + if m != nil { + return m.Receipt + } + return nil +} + +// SpaceReceiptWithSignature contains protobuf encoded receipt and its signature +type SpaceReceiptWithSignature struct { + SpaceReceiptPayload []byte `protobuf:"bytes,1,opt,name=spaceReceiptPayload,proto3" json:"spaceReceiptPayload,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *SpaceReceiptWithSignature) Reset() { *m = SpaceReceiptWithSignature{} } +func (m *SpaceReceiptWithSignature) String() string { return proto.CompactTextString(m) } +func (*SpaceReceiptWithSignature) ProtoMessage() {} +func (*SpaceReceiptWithSignature) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{2} +} +func (m *SpaceReceiptWithSignature) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceReceiptWithSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceReceiptWithSignature.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpaceReceiptWithSignature) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceReceiptWithSignature.Merge(m, src) +} +func (m *SpaceReceiptWithSignature) XXX_Size() int { + return m.Size() +} +func (m *SpaceReceiptWithSignature) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceReceiptWithSignature.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceReceiptWithSignature proto.InternalMessageInfo + +func (m *SpaceReceiptWithSignature) GetSpaceReceiptPayload() []byte { + if m != nil { + return m.SpaceReceiptPayload + } + return nil +} + +func (m *SpaceReceiptWithSignature) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +// SpaceReceipt contains permission to SpacePush operation +type SpaceReceipt struct { + // spaceId + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + // peerId of receipt requester + PeerId string `protobuf:"bytes,2,opt,name=peerId,proto3" json:"peerId,omitempty"` + // identity of space owner + AccountIdentity []byte `protobuf:"bytes,3,opt,name=accountIdentity,proto3" json:"accountIdentity,omitempty"` + // identity of control node + ControlNodeIdentity []byte `protobuf:"bytes,4,opt,name=controlNodeIdentity,proto3" json:"controlNodeIdentity,omitempty"` + // unix-timestamp with a deadline time of receipt validity + ValidUntil uint64 `protobuf:"varint,5,opt,name=validUntil,proto3" json:"validUntil,omitempty"` +} + +func (m *SpaceReceipt) Reset() { *m = SpaceReceipt{} } +func (m *SpaceReceipt) String() string { return proto.CompactTextString(m) } +func (*SpaceReceipt) ProtoMessage() {} +func (*SpaceReceipt) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{3} +} +func (m *SpaceReceipt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceReceipt.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpaceReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceReceipt.Merge(m, src) +} +func (m *SpaceReceipt) XXX_Size() int { + return m.Size() +} +func (m *SpaceReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceReceipt.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceReceipt proto.InternalMessageInfo + +func (m *SpaceReceipt) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *SpaceReceipt) GetPeerId() string { + if m != nil { + return m.PeerId + } + return "" +} + +func (m *SpaceReceipt) GetAccountIdentity() []byte { + if m != nil { + return m.AccountIdentity + } + return nil +} + +func (m *SpaceReceipt) GetControlNodeIdentity() []byte { + if m != nil { + return m.ControlNodeIdentity + } + return nil +} + +func (m *SpaceReceipt) GetValidUntil() uint64 { + if m != nil { + return m.ValidUntil + } + return 0 +} + +// FileLimitCheckRequest contains an account identity and spaceId +// control node checks that identity owns a given space +type FileLimitCheckRequest struct { + AccountIdentity []byte `protobuf:"bytes,1,opt,name=accountIdentity,proto3" json:"accountIdentity,omitempty"` + SpaceId string `protobuf:"bytes,2,opt,name=spaceId,proto3" json:"spaceId,omitempty"` +} + +func (m *FileLimitCheckRequest) Reset() { *m = FileLimitCheckRequest{} } +func (m *FileLimitCheckRequest) String() string { return proto.CompactTextString(m) } +func (*FileLimitCheckRequest) ProtoMessage() {} +func (*FileLimitCheckRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{4} +} +func (m *FileLimitCheckRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FileLimitCheckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FileLimitCheckRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FileLimitCheckRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileLimitCheckRequest.Merge(m, src) +} +func (m *FileLimitCheckRequest) XXX_Size() int { + return m.Size() +} +func (m *FileLimitCheckRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FileLimitCheckRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FileLimitCheckRequest proto.InternalMessageInfo + +func (m *FileLimitCheckRequest) GetAccountIdentity() []byte { + if m != nil { + return m.AccountIdentity + } + return nil +} + +func (m *FileLimitCheckRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +// FileLimitCheckResponse returns a current space limit in bytes +type FileLimitCheckResponse struct { + Limit uint64 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` +} + +func (m *FileLimitCheckResponse) Reset() { *m = FileLimitCheckResponse{} } +func (m *FileLimitCheckResponse) String() string { return proto.CompactTextString(m) } +func (*FileLimitCheckResponse) ProtoMessage() {} +func (*FileLimitCheckResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{5} +} +func (m *FileLimitCheckResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FileLimitCheckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FileLimitCheckResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FileLimitCheckResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileLimitCheckResponse.Merge(m, src) +} +func (m *FileLimitCheckResponse) XXX_Size() int { + return m.Size() +} +func (m *FileLimitCheckResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FileLimitCheckResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_FileLimitCheckResponse proto.InternalMessageInfo + +func (m *FileLimitCheckResponse) GetLimit() uint64 { + if m != nil { + return m.Limit + } + return 0 +} + +func init() { + proto.RegisterType((*SpaceSignRequest)(nil), "coordinator.SpaceSignRequest") + proto.RegisterType((*SpaceSignResponse)(nil), "coordinator.SpaceSignResponse") + proto.RegisterType((*SpaceReceiptWithSignature)(nil), "coordinator.SpaceReceiptWithSignature") + proto.RegisterType((*SpaceReceipt)(nil), "coordinator.SpaceReceipt") + proto.RegisterType((*FileLimitCheckRequest)(nil), "coordinator.FileLimitCheckRequest") + proto.RegisterType((*FileLimitCheckResponse)(nil), "coordinator.FileLimitCheckResponse") +} + +func init() { + proto.RegisterFile("coordinator/coordinatorproto/protos/coordinator.proto", fileDescriptor_d94f6f99586adae2) +} + +var fileDescriptor_d94f6f99586adae2 = []byte{ + // 409 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xdd, 0x6a, 0xe2, 0x40, + 0x14, 0x76, 0x5c, 0x7f, 0xc8, 0x51, 0xf6, 0x67, 0x76, 0x57, 0xb2, 0xe2, 0x0e, 0x92, 0x85, 0xc5, + 0x8b, 0x45, 0x17, 0x97, 0xdd, 0xeb, 0xa5, 0x42, 0xc1, 0x52, 0x4a, 0x19, 0x91, 0xd2, 0xf6, 0x2a, + 0x4d, 0x86, 0x3a, 0x98, 0x66, 0xd2, 0x64, 0x2c, 0xf8, 0x16, 0x7d, 0x98, 0x5e, 0xf6, 0x01, 0x7a, + 0xe9, 0x65, 0x2f, 0x8b, 0xbe, 0x48, 0xc9, 0xc4, 0xe8, 0x68, 0xa3, 0x37, 0x49, 0xce, 0x77, 0xbe, + 0xef, 0x9c, 0x6f, 0x72, 0xce, 0xc0, 0x5f, 0x47, 0x88, 0xd0, 0xe5, 0xbe, 0x2d, 0x45, 0xd8, 0xd1, + 0xbe, 0x83, 0x50, 0x48, 0xd1, 0x51, 0xcf, 0x48, 0xc7, 0xdb, 0x0a, 0xc2, 0x15, 0x0d, 0xb2, 0x7e, + 0xc1, 0xc7, 0x41, 0x60, 0x3b, 0x6c, 0xc0, 0xaf, 0x7d, 0xca, 0x6e, 0x27, 0x2c, 0x92, 0xd8, 0x84, + 0x72, 0x14, 0x63, 0x7d, 0xd7, 0x44, 0x4d, 0xd4, 0x32, 0x68, 0x1a, 0x5a, 0x43, 0xf8, 0xa4, 0xb1, + 0xa3, 0x40, 0xf8, 0x11, 0xc3, 0xff, 0xa1, 0x1c, 0x32, 0x87, 0xf1, 0x40, 0x2a, 0x7a, 0xa5, 0xfb, + 0xb3, 0xad, 0x37, 0x55, 0x02, 0x9a, 0x10, 0xce, 0xb8, 0x1c, 0xc5, 0x5a, 0x5b, 0x4e, 0x42, 0x46, + 0x53, 0x99, 0x35, 0x86, 0x6f, 0x3b, 0x59, 0xf8, 0x37, 0x7c, 0x8e, 0xb4, 0xe4, 0xa9, 0x3d, 0xf5, + 0x84, 0x9d, 0x38, 0xab, 0xd2, 0xac, 0x14, 0x6e, 0x80, 0x11, 0xa5, 0x72, 0x33, 0xaf, 0x78, 0x6b, + 0xc0, 0x7a, 0x44, 0x50, 0xd5, 0xbb, 0xed, 0x3e, 0x2e, 0xae, 0x41, 0x29, 0x60, 0x2c, 0xec, 0xbb, + 0xaa, 0x8a, 0x41, 0x97, 0x11, 0x6e, 0xc1, 0x07, 0xdb, 0x71, 0xc4, 0xc4, 0x97, 0x7d, 0x97, 0xf9, + 0x92, 0xcb, 0xa9, 0xf9, 0x4e, 0xb5, 0xd9, 0x86, 0x63, 0xf3, 0x8e, 0xf0, 0x65, 0x28, 0xbc, 0x13, + 0xe1, 0xb2, 0x15, 0xbb, 0x90, 0x98, 0xcf, 0x48, 0x61, 0x02, 0x70, 0x67, 0x7b, 0xdc, 0x1d, 0xfa, + 0x92, 0x7b, 0x66, 0xb1, 0x89, 0x5a, 0x05, 0xaa, 0x21, 0xd6, 0x25, 0x7c, 0x3d, 0xe4, 0x1e, 0x3b, + 0xe6, 0x37, 0x5c, 0xf6, 0x46, 0xcc, 0x19, 0xa7, 0x53, 0xcb, 0x30, 0x85, 0xb2, 0x4d, 0x69, 0x07, + 0xce, 0x6f, 0xce, 0xb7, 0x0d, 0xb5, 0xed, 0xe2, 0xcb, 0x21, 0x7f, 0x81, 0xa2, 0x17, 0xa3, 0xaa, + 0x66, 0x81, 0x26, 0x41, 0xf7, 0x01, 0x41, 0xa5, 0xb7, 0x9e, 0x35, 0x3e, 0x02, 0x63, 0xb5, 0x1f, + 0xf8, 0xfb, 0xdb, 0x35, 0xd0, 0xb6, 0xac, 0x4e, 0x76, 0xa5, 0x97, 0x1d, 0xcf, 0xe1, 0xfd, 0xa6, + 0x17, 0x6c, 0x6d, 0x28, 0x32, 0xff, 0x42, 0xfd, 0xc7, 0x5e, 0x4e, 0x52, 0xfa, 0xe0, 0xdf, 0xd3, + 0x9c, 0xa0, 0xd9, 0x9c, 0xa0, 0x97, 0x39, 0x41, 0xf7, 0x0b, 0x92, 0x9b, 0x2d, 0x48, 0xee, 0x79, + 0x41, 0x72, 0x17, 0x8d, 0x7d, 0x57, 0xea, 0xaa, 0xa4, 0x5e, 0x7f, 0x5e, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x77, 0x20, 0x0a, 0xe9, 0x79, 0x03, 0x00, 0x00, +} + +func (m *SpaceSignRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceSignRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceSignRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SpaceSignResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceSignResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceSignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Receipt != nil { + { + size, err := m.Receipt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCoordinator(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SpaceReceiptWithSignature) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceReceiptWithSignature) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceReceiptWithSignature) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceReceiptPayload) > 0 { + i -= len(m.SpaceReceiptPayload) + copy(dAtA[i:], m.SpaceReceiptPayload) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.SpaceReceiptPayload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SpaceReceipt) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceReceipt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ValidUntil != 0 { + i = encodeVarintCoordinator(dAtA, i, uint64(m.ValidUntil)) + i-- + dAtA[i] = 0x28 + } + if len(m.ControlNodeIdentity) > 0 { + i -= len(m.ControlNodeIdentity) + copy(dAtA[i:], m.ControlNodeIdentity) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.ControlNodeIdentity))) + i-- + dAtA[i] = 0x22 + } + if len(m.AccountIdentity) > 0 { + i -= len(m.AccountIdentity) + copy(dAtA[i:], m.AccountIdentity) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.AccountIdentity))) + i-- + dAtA[i] = 0x1a + } + if len(m.PeerId) > 0 { + i -= len(m.PeerId) + copy(dAtA[i:], m.PeerId) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.PeerId))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FileLimitCheckRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FileLimitCheckRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FileLimitCheckRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x12 + } + if len(m.AccountIdentity) > 0 { + i -= len(m.AccountIdentity) + copy(dAtA[i:], m.AccountIdentity) + i = encodeVarintCoordinator(dAtA, i, uint64(len(m.AccountIdentity))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FileLimitCheckResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FileLimitCheckResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FileLimitCheckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Limit != 0 { + i = encodeVarintCoordinator(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCoordinator(dAtA []byte, offset int, v uint64) int { + offset -= sovCoordinator(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SpaceSignRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + return n +} + +func (m *SpaceSignResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Receipt != nil { + l = m.Receipt.Size() + n += 1 + l + sovCoordinator(uint64(l)) + } + return n +} + +func (m *SpaceReceiptWithSignature) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceReceiptPayload) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + return n +} + +func (m *SpaceReceipt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + l = len(m.PeerId) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + l = len(m.AccountIdentity) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + l = len(m.ControlNodeIdentity) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + if m.ValidUntil != 0 { + n += 1 + sovCoordinator(uint64(m.ValidUntil)) + } + return n +} + +func (m *FileLimitCheckRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AccountIdentity) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovCoordinator(uint64(l)) + } + return n +} + +func (m *FileLimitCheckResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Limit != 0 { + n += 1 + sovCoordinator(uint64(m.Limit)) + } + return n +} + +func sovCoordinator(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCoordinator(x uint64) (n int) { + return sovCoordinator(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SpaceSignRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpaceSignRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceSignRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SpaceSignResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpaceSignResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceSignResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Receipt == nil { + m.Receipt = &SpaceReceiptWithSignature{} + } + if err := m.Receipt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SpaceReceiptWithSignature) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpaceReceiptWithSignature: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceReceiptWithSignature: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceReceiptPayload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceReceiptPayload = append(m.SpaceReceiptPayload[:0], dAtA[iNdEx:postIndex]...) + if m.SpaceReceiptPayload == nil { + m.SpaceReceiptPayload = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SpaceReceipt) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpaceReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountIdentity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountIdentity = append(m.AccountIdentity[:0], dAtA[iNdEx:postIndex]...) + if m.AccountIdentity == nil { + m.AccountIdentity = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ControlNodeIdentity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ControlNodeIdentity = append(m.ControlNodeIdentity[:0], dAtA[iNdEx:postIndex]...) + if m.ControlNodeIdentity == nil { + m.ControlNodeIdentity = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidUntil", wireType) + } + m.ValidUntil = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidUntil |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FileLimitCheckRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FileLimitCheckRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FileLimitCheckRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountIdentity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountIdentity = append(m.AccountIdentity[:0], dAtA[iNdEx:postIndex]...) + if m.AccountIdentity == nil { + m.AccountIdentity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCoordinator + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCoordinator + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FileLimitCheckResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FileLimitCheckResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FileLimitCheckResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoordinator + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCoordinator(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoordinator + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCoordinator(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoordinator + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoordinator + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoordinator + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCoordinator + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCoordinator + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCoordinator + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCoordinator = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCoordinator = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCoordinator = fmt.Errorf("proto: unexpected end of group") +) diff --git a/coordinator/coordinatorproto/coordinator_drpc.pb.go b/coordinator/coordinatorproto/coordinator_drpc.pb.go new file mode 100644 index 00000000..67f72ef7 --- /dev/null +++ b/coordinator/coordinatorproto/coordinator_drpc.pb.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-go-drpc. DO NOT EDIT. +// protoc-gen-go-drpc version: v0.0.32 +// source: coordinator/coordinatorproto/protos/coordinator.proto + +package coordinatorproto + +import ( + bytes "bytes" + context "context" + errors "errors" + jsonpb "github.com/gogo/protobuf/jsonpb" + proto "github.com/gogo/protobuf/proto" + drpc "storj.io/drpc" + drpcerr "storj.io/drpc/drpcerr" +) + +type drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto struct{} + +func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) Marshal(msg drpc.Message) ([]byte, error) { + return proto.Marshal(msg.(proto.Message)) +} + +func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) Unmarshal(buf []byte, msg drpc.Message) error { + return proto.Unmarshal(buf, msg.(proto.Message)) +} + +func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) JSONMarshal(msg drpc.Message) ([]byte, error) { + var buf bytes.Buffer + err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message)) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error { + return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message)) +} + +type DRPCCoordinatorClient interface { + DRPCConn() drpc.Conn + + SpaceSign(ctx context.Context, in *SpaceSignRequest) (*SpaceSignResponse, error) + FileLimitCheck(ctx context.Context, in *FileLimitCheckRequest) (*FileLimitCheckResponse, error) +} + +type drpcCoordinatorClient struct { + cc drpc.Conn +} + +func NewDRPCCoordinatorClient(cc drpc.Conn) DRPCCoordinatorClient { + return &drpcCoordinatorClient{cc} +} + +func (c *drpcCoordinatorClient) DRPCConn() drpc.Conn { return c.cc } + +func (c *drpcCoordinatorClient) SpaceSign(ctx context.Context, in *SpaceSignRequest) (*SpaceSignResponse, error) { + out := new(SpaceSignResponse) + err := c.cc.Invoke(ctx, "/coordinator.Coordinator/SpaceSign", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcCoordinatorClient) FileLimitCheck(ctx context.Context, in *FileLimitCheckRequest) (*FileLimitCheckResponse, error) { + out := new(FileLimitCheckResponse) + err := c.cc.Invoke(ctx, "/coordinator.Coordinator/FileLimitCheck", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +type DRPCCoordinatorServer interface { + SpaceSign(context.Context, *SpaceSignRequest) (*SpaceSignResponse, error) + FileLimitCheck(context.Context, *FileLimitCheckRequest) (*FileLimitCheckResponse, error) +} + +type DRPCCoordinatorUnimplementedServer struct{} + +func (s *DRPCCoordinatorUnimplementedServer) SpaceSign(context.Context, *SpaceSignRequest) (*SpaceSignResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCCoordinatorUnimplementedServer) FileLimitCheck(context.Context, *FileLimitCheckRequest) (*FileLimitCheckResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +type DRPCCoordinatorDescription struct{} + +func (DRPCCoordinatorDescription) NumMethods() int { return 2 } + +func (DRPCCoordinatorDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { + switch n { + case 0: + return "/coordinator.Coordinator/SpaceSign", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCCoordinatorServer). + SpaceSign( + ctx, + in1.(*SpaceSignRequest), + ) + }, DRPCCoordinatorServer.SpaceSign, true + case 1: + return "/coordinator.Coordinator/FileLimitCheck", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCCoordinatorServer). + FileLimitCheck( + ctx, + in1.(*FileLimitCheckRequest), + ) + }, DRPCCoordinatorServer.FileLimitCheck, true + default: + return "", nil, nil, nil, false + } +} + +func DRPCRegisterCoordinator(mux drpc.Mux, impl DRPCCoordinatorServer) error { + return mux.Register(impl, DRPCCoordinatorDescription{}) +} + +type DRPCCoordinator_SpaceSignStream interface { + drpc.Stream + SendAndClose(*SpaceSignResponse) error +} + +type drpcCoordinator_SpaceSignStream struct { + drpc.Stream +} + +func (x *drpcCoordinator_SpaceSignStream) SendAndClose(m *SpaceSignResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCCoordinator_FileLimitCheckStream interface { + drpc.Stream + SendAndClose(*FileLimitCheckResponse) error +} + +type drpcCoordinator_FileLimitCheckStream struct { + drpc.Stream +} + +func (x *drpcCoordinator_FileLimitCheckStream) SendAndClose(m *FileLimitCheckResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}); err != nil { + return err + } + return x.CloseSend() +} diff --git a/coordinator/coordinatorproto/protos/coordinator.proto b/coordinator/coordinatorproto/protos/coordinator.proto new file mode 100644 index 00000000..b7e539bb --- /dev/null +++ b/coordinator/coordinatorproto/protos/coordinator.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package coordinator; + +option go_package = "coordinator/coordinatorproto"; + +service Coordinator { + // SpaceSign signs a space creation operation + rpc SpaceSign(SpaceSignRequest) returns (SpaceSignResponse); + + // FileLimitCheck checks a limit by account and space + // can be used only: + // - if a handshake identity matches a given identity + // - if a requester contains in nodeconf list + rpc FileLimitCheck(FileLimitCheckRequest) returns (FileLimitCheckResponse); +} + +message SpaceSignRequest { + string spaceId = 1; +} + +message SpaceSignResponse { + SpaceReceiptWithSignature receipt = 1; +} + +// SpaceReceiptWithSignature contains protobuf encoded receipt and its signature +message SpaceReceiptWithSignature { + bytes spaceReceiptPayload = 1; + bytes signature = 2; +} + +// SpaceReceipt contains permission to SpacePush operation +message SpaceReceipt { + // spaceId + string spaceId = 1; + // peerId of receipt requester + string peerId = 2; + // identity of space owner + bytes accountIdentity = 3; + // identity of control node + bytes controlNodeIdentity = 4; + // unix-timestamp with a deadline time of receipt validity + uint64 validUntil = 5; +} + +// FileLimitCheckRequest contains an account identity and spaceId +// control node checks that identity owns a given space +message FileLimitCheckRequest { + bytes accountIdentity = 1; + string spaceId = 2; +} + +// FileLimitCheckResponse returns a current space limit in bytes +message FileLimitCheckResponse { + uint64 limit = 1; +} diff --git a/go.mod b/go.mod index a88ae2f1..0b286677 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/ipfs/go-ipfs-chunker v0.0.5 github.com/ipfs/go-ipfs-exchange-interface v0.2.0 github.com/ipfs/go-ipld-format v0.4.0 - github.com/ipfs/go-merkledag v0.9.0 + github.com/ipfs/go-merkledag v0.10.0 github.com/ipfs/go-unixfs v0.4.3 github.com/libp2p/go-libp2p v0.24.1 github.com/minio/sha256-simd v1.0.0 @@ -30,7 +30,7 @@ require ( github.com/zeebo/errs v1.3.0 go.uber.org/zap v1.24.0 golang.org/x/exp v0.0.0-20230105202349-8879d0199aa3 - golang.org/x/net v0.6.0 + golang.org/x/net v0.7.0 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/yaml.v3 v3.0.1 storj.io/drpc v0.0.32 @@ -64,8 +64,8 @@ require ( github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/ipfs/go-verifcid v0.0.2 // indirect - github.com/ipld/go-codec-dagpb v1.5.0 // indirect - github.com/ipld/go-ipld-prime v0.19.0 // indirect + github.com/ipld/go-codec-dagpb v1.6.0 // indirect + github.com/ipld/go-ipld-prime v0.20.0 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect github.com/klauspost/cpuid/v2 v2.2.2 // indirect @@ -78,7 +78,7 @@ require ( github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect github.com/multiformats/go-multiaddr v0.8.0 // indirect - github.com/multiformats/go-multicodec v0.7.0 // indirect + github.com/multiformats/go-multicodec v0.8.0 // indirect github.com/multiformats/go-multistream v0.3.3 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect diff --git a/go.sum b/go.sum index 07877edd..23ed1abf 100644 --- a/go.sum +++ b/go.sum @@ -87,7 +87,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -248,8 +248,8 @@ github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JP github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipfs/go-merkledag v0.9.0 h1:DFC8qZ96Dz1hMT7dtIpcY524eFFDiEWAF8hNJHWW2pk= -github.com/ipfs/go-merkledag v0.9.0/go.mod h1:bPHqkHt5OZ0p1n3iqPeDiw2jIBkjAytRjS3WSBwjq90= +github.com/ipfs/go-merkledag v0.10.0 h1:IUQhj/kzTZfam4e+LnaEpoiZ9vZF6ldimVlby+6OXL4= +github.com/ipfs/go-merkledag v0.10.0/go.mod h1:zkVav8KiYlmbzUzNM6kENzkdP5+qR7+2mCwxkQ6GIj8= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-peertaskqueue v0.8.0 h1:JyNO144tfu9bx6Hpo119zvbEL9iQ760FHOiJYsUjqaU= @@ -257,11 +257,11 @@ github.com/ipfs/go-unixfs v0.4.3 h1:EdDc1sNZNFDUlo4UrVAvvAofVI5EwTnKu8Nv8mgXkWQ= github.com/ipfs/go-unixfs v0.4.3/go.mod h1:TSG7G1UuT+l4pNj91raXAPkX0BhJi3jST1FDTfQ5QyM= github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs= github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU= -github.com/ipld/go-codec-dagpb v1.5.0 h1:RspDRdsJpLfgCI0ONhTAnbHdySGD4t+LHSPK4X1+R0k= -github.com/ipld/go-codec-dagpb v1.5.0/go.mod h1:0yRIutEFD8o1DGVqw4RSHh+BUTlJA9XWldxaaWR/o4g= +github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc= +github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s= github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8= -github.com/ipld/go-ipld-prime v0.19.0 h1:5axC7rJmPc17Emw6TelxGwnzALk0PdupZ2oj2roDj04= -github.com/ipld/go-ipld-prime v0.19.0/go.mod h1:Q9j3BaVXwaA3o5JUDNvptDDr/x8+F7FG6XJ8WI3ILg4= +github.com/ipld/go-ipld-prime v0.20.0 h1:Ud3VwE9ClxpO2LkCYP7vWPc0Fo+dYdYzgxUJZ3uRG4g= +github.com/ipld/go-ipld-prime v0.20.0/go.mod h1:PzqZ/ZR981eKbgdr3y2DJYeD/8bgMawdGVlJDE8kK+M= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= @@ -296,7 +296,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -355,8 +355,8 @@ github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/g github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI= github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8= -github.com/multiformats/go-multicodec v0.7.0 h1:rTUjGOwjlhGHbEMbPoSUJowG1spZTVsITRANCjKTUAQ= -github.com/multiformats/go-multicodec v0.7.0/go.mod h1:GUC8upxSBE4oG+q3kWZRw/+6yC1BqO550bjhWsJbZlw= +github.com/multiformats/go-multicodec v0.8.0 h1:evBmgkbSQux+Ds2IgfhkO38Dl2GDtRW8/Rp6YiSHX/Q= +github.com/multiformats/go-multicodec v0.8.0/go.mod h1:GUC8upxSBE4oG+q3kWZRw/+6yC1BqO550bjhWsJbZlw= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= @@ -414,7 +414,7 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -445,7 +445,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/warpfork/go-testmark v0.10.0 h1:E86YlUMYfwIacEsQGlnTvjk1IgYkyTGjPhF0RnwTCmw= +github.com/warpfork/go-testmark v0.11.0 h1:J6LnV8KpceDvo7spaNU4+DauH2n1x+6RaO2rJrmpQ9U= github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= @@ -576,8 +576,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/nodeconf/config.go b/nodeconf/config.go index a1985be2..17093019 100644 --- a/nodeconf/config.go +++ b/nodeconf/config.go @@ -6,6 +6,8 @@ const ( NodeTypeTree NodeType = "tree" NodeTypeConsensus NodeType = "consensus" NodeTypeFile NodeType = "file" + + NodeTypeCoordinator NodeType = "coordinator" ) type configGetter interface { @@ -15,8 +17,7 @@ type configGetter interface { type NodeConfig struct { PeerId string `yaml:"peerId"` Addresses []string `yaml:"address"` - SigningKey string `yaml:"signingKey,omitempty"` - EncryptionKey string `yaml:"encryptionKey,omitempty"` + EncryptionKey string `yaml:"encryptionPubKey,omitempty"` Types []NodeType `yaml:"types,omitempty"` } diff --git a/nodeconf/configuration.go b/nodeconf/configuration.go index bc913fd6..121b79fa 100644 --- a/nodeconf/configuration.go +++ b/nodeconf/configuration.go @@ -17,6 +17,8 @@ type Configuration interface { FilePeers() []string // ConsensusPeers returns list of consensusnodes ConsensusPeers() []string + // CoordinatorPeers returns list of coordinator nodes + CoordinatorPeers() []string // Addresses returns map[peerId][]addr with connection addresses for all known nodes Addresses() map[string][]string // CHash returns nodes consistent table @@ -28,12 +30,13 @@ type Configuration interface { } type configuration struct { - id string - accountId string - filePeers []string - consensusPeers []string - chash chash.CHash - allMembers []NodeConfig + id string + accountId string + filePeers []string + consensusPeers []string + coordinatorPeers []string + chash chash.CHash + allMembers []NodeConfig } func (c *configuration) Id() string { @@ -68,6 +71,10 @@ func (c *configuration) ConsensusPeers() []string { return c.consensusPeers } +func (c *configuration) CoordinatorPeers() []string { + return c.coordinatorPeers +} + func (c *configuration) Addresses() map[string][]string { res := make(map[string][]string) for _, m := range c.allMembers { diff --git a/nodeconf/service.go b/nodeconf/service.go index e78b4a93..9b242a0f 100644 --- a/nodeconf/service.go +++ b/nodeconf/service.go @@ -8,6 +8,7 @@ import ( "github.com/anytypeio/any-sync/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/any-sync/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-chash" + "github.com/libp2p/go-libp2p/core/peer" ) const CName = "common.nodeconf" @@ -80,6 +81,9 @@ func (s *service) Init(a *app.App) (err error) { if n.HasType(NodeTypeFile) { fileConfig.filePeers = append(fileConfig.filePeers, n.PeerId) } + if n.HasType(NodeTypeCoordinator) { + fileConfig.coordinatorPeers = append(fileConfig.coordinatorPeers, n.PeerId) + } fileConfig.allMembers = append(fileConfig.allMembers, n) } if err = fileConfig.chash.AddMembers(members...); err != nil { @@ -103,17 +107,28 @@ func (s *service) GetById(id string) Configuration { } func nodeFromConfigNode(n NodeConfig) (*Node, error) { - decodedSigningKey, err := keys.DecodeKeyFromString( - n.SigningKey, - signingkey.UnmarshalEd25519PrivateKey, - nil) + p, err := peer.Decode(n.PeerId) + if err != nil { + return nil, err + } + ic, err := p.ExtractPublicKey() if err != nil { return nil, err } - decodedEncryptionKey, err := keys.DecodeKeyFromString( + icRaw, err := ic.Raw() + if err != nil { + return nil, err + } + + sigPubKey, err := signingkey.UnmarshalEd25519PublicKey(icRaw) + if err != nil { + return nil, err + } + + encPubKey, err := keys.DecodeKeyFromString( n.EncryptionKey, - encryptionkey.NewEncryptionRsaPrivKeyFromBytes, + encryptionkey.NewEncryptionRsaPubKeyFromBytes, nil) if err != nil { return nil, err @@ -122,7 +137,7 @@ func nodeFromConfigNode(n NodeConfig) (*Node, error) { return &Node{ Addresses: n.Addresses, PeerId: n.PeerId, - SigningKey: decodedSigningKey.GetPublic(), - EncryptionKey: decodedEncryptionKey.GetPublic(), + SigningKey: sigPubKey, + EncryptionKey: encPubKey, }, nil } diff --git a/testutil/accounttest/accountservice.go b/testutil/accounttest/accountservice.go index 6b5cedac..26941504 100644 --- a/testutil/accounttest/accountservice.go +++ b/testutil/accounttest/accountservice.go @@ -62,18 +62,13 @@ func (s *AccountTestService) Account() *accountdata.AccountData { } func (s *AccountTestService) NodeConf(addrs []string) nodeconf.NodeConfig { - encSk, err := keys.EncodeKeyToString(s.acc.SignKey) - if err != nil { - panic(err) - } - encEk, err := keys.EncodeKeyToString(s.acc.EncKey) + encEk, err := keys.EncodeKeyToString(s.acc.EncKey.GetPublic()) if err != nil { panic(err) } return nodeconf.NodeConfig{ PeerId: s.acc.PeerId, Addresses: addrs, - SigningKey: encSk, EncryptionKey: encEk, Types: []nodeconf.NodeType{nodeconf.NodeTypeTree}, }