From 0a5d0ff1a2212af7100c98573fd375bf69dd1a3b Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 12 Aug 2020 09:37:59 +0300 Subject: [PATCH] Remove v1 code --- accounting/fixtures/cheque.sh | 8 - accounting/fixtures/cheque_data | Bin 650 -> 0 bytes accounting/service.go | 46 - accounting/service.pb.go | 776 ----- accounting/service.proto | 36 - accounting/sign.go | 167 - accounting/sign_test.go | 185 -- accounting/types.go | 453 --- accounting/types.pb.go | 3463 --------------------- accounting/types.proto | 125 - accounting/types_test.go | 193 -- accounting/withdraw.go | 35 - accounting/withdraw.pb.go | 2819 ----------------- accounting/withdraw.proto | 101 - acl/extended/enum.go | 126 - acl/extended/marshal.go | 333 -- acl/extended/types.go | 73 - acl/extended/wrappers.go | 528 ---- acl/extended/wrappers_test.go | 136 - acl/types.go | 57 - acl/types.pb.go | 1408 --------- acl/types.proto | 106 - bootstrap/service.go | 8 - bootstrap/service.pb.go | 628 ---- bootstrap/service.proto | 42 - bootstrap/sign.go | 46 - bootstrap/sign_test.go | 82 - bootstrap/types.go | 137 - bootstrap/types.pb.go | 705 ----- bootstrap/types.proto | 29 - bootstrap/types_test.go | 39 - chain/address.go | 30 - chain/address_test.go | 41 - container/service.go | 60 - container/service.pb.go | 3733 ----------------------- container/service.proto | 146 - container/sign.go | 194 -- container/sign_test.go | 187 -- container/types.go | 188 -- container/types.pb.go | 507 ---- container/types.proto | 24 - container/types_test.go | 162 - decimal/decimal.go | 110 - decimal/decimal.pb.go | 349 --- decimal/decimal.proto | 18 - decimal/decimal_test.go | 445 --- hash/hash.go | 106 - hash/hash_test.go | 166 - hash/hashesslice.go | 20 - hash/salt.go | 17 - internal/error.go | 7 - internal/proto.go | 19 - object/doc.go | 143 - object/extensions.go | 64 - object/service.go | 196 -- object/service.pb.go | 5050 ------------------------------- object/service.proto | 197 -- object/service_test.go | 43 - object/sg.go | 43 - object/sg_test.go | 88 - object/sign.go | 272 -- object/sign_test.go | 239 -- object/types.go | 422 --- object/types.pb.go | 3568 ---------------------- object/types.proto | 134 - object/types_test.go | 234 -- object/utils.go | 100 - object/utils_test.go | 53 - object/verification.go | 149 - object/verification_test.go | 144 - query/types.go | 43 - query/types.pb.go | 641 ---- query/types.proto | 33 - refs/address.go | 80 - refs/cid.go | 104 - refs/owner.go | 77 - refs/sgid.go | 14 - refs/types.go | 123 - refs/types.pb.go | 372 --- refs/types.proto | 19 - refs/types_test.go | 141 - refs/uuid.go | 84 - service/alias.go | 20 - service/bearer.go | 140 - service/bearer_test.go | 199 -- service/epoch.go | 11 - service/epoch_test.go | 21 - service/errors.go | 53 - service/meta.go | 131 - service/meta.pb.go | 1118 ------- service/meta.proto | 49 - service/meta_test.go | 99 - service/raw.go | 6 - service/raw_test.go | 24 - service/role.go | 37 - service/role_test.go | 23 - service/sign.go | 404 --- service/sign_test.go | 400 --- service/token.go | 265 -- service/token_test.go | 248 -- service/ttl.go | 63 - service/ttl_test.go | 99 - service/types.go | 317 -- service/utils.go | 18 - service/utils_test.go | 34 - service/verify.go | 174 -- service/verify.pb.go | 2225 -------------- service/verify.proto | 119 - service/verify_test.go | 140 - service/verify_test.pb.go | 572 ---- service/verify_test.proto | 18 - service/version.go | 11 - service/version_test.go | 21 - session/alias.go | 15 - session/create.go | 62 - session/create_test.go | 103 - session/errors.go | 19 - session/private.go | 67 - session/private_test.go | 76 - session/request.go | 62 - session/request_test.go | 92 - session/response.go | 16 - session/response_test.go | 27 - session/service.pb.go | 800 ----- session/service.proto | 39 - session/store.go | 64 - session/store_test.go | 111 - session/types.go | 80 - state/service.go | 88 - state/service.pb.go | 2811 ----------------- state/service.proto | 124 - state/service_test.go | 118 - state/sign.go | 67 - state/sign_test.go | 94 - state/types.go | 24 - state/types_test.go | 18 - storagegroup/storage.go | 39 - storagegroup/types.go | 97 - storagegroup/types.pb.go | 664 ---- storagegroup/types.proto | 36 - 140 files changed, 45161 deletions(-) delete mode 100755 accounting/fixtures/cheque.sh delete mode 100644 accounting/fixtures/cheque_data delete mode 100644 accounting/service.go delete mode 100644 accounting/service.pb.go delete mode 100644 accounting/service.proto delete mode 100644 accounting/sign.go delete mode 100644 accounting/sign_test.go delete mode 100644 accounting/types.go delete mode 100644 accounting/types.pb.go delete mode 100644 accounting/types.proto delete mode 100644 accounting/types_test.go delete mode 100644 accounting/withdraw.go delete mode 100644 accounting/withdraw.pb.go delete mode 100644 accounting/withdraw.proto delete mode 100644 acl/extended/enum.go delete mode 100644 acl/extended/marshal.go delete mode 100644 acl/extended/types.go delete mode 100644 acl/extended/wrappers.go delete mode 100644 acl/extended/wrappers_test.go delete mode 100644 acl/types.go delete mode 100644 acl/types.pb.go delete mode 100644 acl/types.proto delete mode 100644 bootstrap/service.go delete mode 100644 bootstrap/service.pb.go delete mode 100644 bootstrap/service.proto delete mode 100644 bootstrap/sign.go delete mode 100644 bootstrap/sign_test.go delete mode 100644 bootstrap/types.go delete mode 100644 bootstrap/types.pb.go delete mode 100644 bootstrap/types.proto delete mode 100644 bootstrap/types_test.go delete mode 100644 chain/address.go delete mode 100644 chain/address_test.go delete mode 100644 container/service.go delete mode 100644 container/service.pb.go delete mode 100644 container/service.proto delete mode 100644 container/sign.go delete mode 100644 container/sign_test.go delete mode 100644 container/types.go delete mode 100644 container/types.pb.go delete mode 100644 container/types.proto delete mode 100644 container/types_test.go delete mode 100644 decimal/decimal.go delete mode 100644 decimal/decimal.pb.go delete mode 100644 decimal/decimal.proto delete mode 100644 decimal/decimal_test.go delete mode 100644 hash/hash.go delete mode 100644 hash/hash_test.go delete mode 100644 hash/hashesslice.go delete mode 100644 hash/salt.go delete mode 100644 internal/error.go delete mode 100644 internal/proto.go delete mode 100644 object/doc.go delete mode 100644 object/extensions.go delete mode 100644 object/service.go delete mode 100644 object/service.pb.go delete mode 100644 object/service.proto delete mode 100644 object/service_test.go delete mode 100644 object/sg.go delete mode 100644 object/sg_test.go delete mode 100644 object/sign.go delete mode 100644 object/sign_test.go delete mode 100644 object/types.go delete mode 100644 object/types.pb.go delete mode 100644 object/types.proto delete mode 100644 object/types_test.go delete mode 100644 object/utils.go delete mode 100644 object/utils_test.go delete mode 100644 object/verification.go delete mode 100644 object/verification_test.go delete mode 100644 query/types.go delete mode 100644 query/types.pb.go delete mode 100644 query/types.proto delete mode 100644 refs/address.go delete mode 100644 refs/cid.go delete mode 100644 refs/owner.go delete mode 100644 refs/sgid.go delete mode 100644 refs/types.go delete mode 100644 refs/types.pb.go delete mode 100644 refs/types.proto delete mode 100644 refs/types_test.go delete mode 100644 refs/uuid.go delete mode 100644 service/alias.go delete mode 100644 service/bearer.go delete mode 100644 service/bearer_test.go delete mode 100644 service/epoch.go delete mode 100644 service/epoch_test.go delete mode 100644 service/errors.go delete mode 100644 service/meta.go delete mode 100644 service/meta.pb.go delete mode 100644 service/meta.proto delete mode 100644 service/meta_test.go delete mode 100644 service/raw.go delete mode 100644 service/raw_test.go delete mode 100644 service/role.go delete mode 100644 service/role_test.go delete mode 100644 service/sign.go delete mode 100644 service/sign_test.go delete mode 100644 service/token.go delete mode 100644 service/token_test.go delete mode 100644 service/ttl.go delete mode 100644 service/ttl_test.go delete mode 100644 service/types.go delete mode 100644 service/utils.go delete mode 100644 service/utils_test.go delete mode 100644 service/verify.go delete mode 100644 service/verify.pb.go delete mode 100644 service/verify.proto delete mode 100644 service/verify_test.go delete mode 100644 service/verify_test.pb.go delete mode 100644 service/verify_test.proto delete mode 100644 service/version.go delete mode 100644 service/version_test.go delete mode 100644 session/alias.go delete mode 100644 session/create.go delete mode 100644 session/create_test.go delete mode 100644 session/errors.go delete mode 100644 session/private.go delete mode 100644 session/private_test.go delete mode 100644 session/request.go delete mode 100644 session/request_test.go delete mode 100644 session/response.go delete mode 100644 session/response_test.go delete mode 100644 session/service.pb.go delete mode 100644 session/service.proto delete mode 100644 session/store.go delete mode 100644 session/store_test.go delete mode 100644 session/types.go delete mode 100644 state/service.go delete mode 100644 state/service.pb.go delete mode 100644 state/service.proto delete mode 100644 state/service_test.go delete mode 100644 state/sign.go delete mode 100644 state/sign_test.go delete mode 100644 state/types.go delete mode 100644 state/types_test.go delete mode 100644 storagegroup/storage.go delete mode 100644 storagegroup/types.go delete mode 100644 storagegroup/types.pb.go delete mode 100644 storagegroup/types.proto diff --git a/accounting/fixtures/cheque.sh b/accounting/fixtures/cheque.sh deleted file mode 100755 index 581402a..0000000 --- a/accounting/fixtures/cheque.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -CHEQUE=7849b02d01cc7f7734295fa815ea64ec4d2012e45b8781eb891723ba2703c53263e8d6e522dc32203339dcd8eee9c6b7439a00ea56fa00000000611e000000000000060003012d47e76210aec73be39ab3d186e0a40fe8d86bfa3d4fabfda57ba13b88f96a8ebe4360627a1326f13fb9516c0dbc4af90f116e44bd33f4d04a0d1633afa243ad4f2fa9cd933e7631a619b5132cec6983906aba757af5590434124b232a43e302f7528ce97c9a93558efe7d4f62577aabdf771c931f54a71be6ad21e7d9cc177744b4b9781cf0c29adb503f33d2df9f810ebf33a774849848984cf7e2bbebd48ef0cd8592fbf9b6aee1dc74803e31c95a02dbbd5fd9783f9ecbcbf444b5942f830368a6f5829fb2a34fa03d0308ae6b05f433f2904d9a852fed1f5d2eb598ca794770adb1ece9dccd1c7ad98f709cfb890e3bdd5973dcdd838111fae2efa4c3c09ea2133e5d7c6eac6ae24afcce46db7c9f4dc154f123c835adff4e0b7e19bcffda0340750b92789821683283bcb98e32b7e032b94f267b6964613fc31a7ce5813fddad8298f71dfdc4f9b3e353f969727af476d43b12a25727cf6b9c73ae7152266d995bec807068ad2156288c4d946aeb17ebca787d498a1b87b9dae1bcd935763403fef27f744e829131d0ec980829fafa51db1714c2761d9f78762c008c323e9d66db9b5086d355897e52fe065e14f1cc70334248349aa4c7a3e6e3dc8f8693b1511c73dc88e6d6e8b6c6c68de922f351b5b1543917af2f2a3588aebfbd1ff3fac6023e00f03a16e8707ce045eb42ee80d392451541ee510dc18e1c8befbac54d742648b58f379b5337d9b74c5a61afb8ef3db7f3eb0454d6823777b613a3ee22cd6ce47e4fa72170d49267b773cc09c123654e0bcd7278aa2ae1e7c85d049b557a3c -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) - -echo $CHEQUE | xxd -p -r > $DIR/cheque_data - -exit 0 diff --git a/accounting/fixtures/cheque_data b/accounting/fixtures/cheque_data deleted file mode 100644 index a1530960f321d4d6d1cb7f11f9cf1de82006ffc4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 650 zcmV;50(Jd(Nw6&e%zt+@DPO1+>SXLqAQI$Thk@&f7bChS1I039=+@;T+%h0DIo#Op z>BhH1ngHrn`Tzg`0AU^g0000000sa90WC-8Vi2y!JL8(O(T3op59ruy`aMsp{iS=M zJBayej=n=+VtNxM@jtmyYz@3h`416pM7=Zg&`J#!Gq0jUtxqqh&67TMF{T-{6D;g$ zgOF;vb$az#1T+#$BPv7V0{2pk>3o`#RgV6BPhwYktKWAVlOI&48|JMc=h@5`cSN+g zcpUJ;n%hu6Gt%Fmfeybjr*wpvNSI9b;=AkAj_}QelKc6#uHoEtfIczFS_0d>U)gv+ zp3BShM75MJg9B)$^@5+Wqfekc0|>5b1@trWkWHF}FYO;)F147-c}H-qvFz#G%^Z5! zk8qs(i4Hs6S##XogMktH;_sxxz@DNLK3#lntZL#){LV((e4kChRPiIoHLd?n3w{~A z|JnmUbqkVsm?3B~gS@$pGPmF|xlbm0X=GtP!y0_$fj`}?f|&Om{lxjR<5T%*a(eW3 z)H@QQS0~SFoO7;mQYLMgTkL>vXssbuD2z>%YU>y4%6NTAiW`Ty+Tpy}HFh)u{_=lx zPJ)p!(CnB9Df;?R+ZPnVb{(I1b}RslGCrMV+nZ2^(^ZLnQvL>B6!FY(GeSr-nxx00 z=HuLthLf>T9CO@==GN%8#>S25BJ)wTu~a!1uP-V!h_1iAAM^Ug0zLrnIu__~eBedv zLhgXml0_9k?okcFjvR~cy2VX&CP=l9H=9#8*|$tuVXwIFJ-74g1XR|7H+QxZqwXTj kY~+4Vry+3El4rMb%n89GWljsta(JpL;pfO*1e;ZQJiRSO_W%F@ diff --git a/accounting/service.go b/accounting/service.go deleted file mode 100644 index 229707f..0000000 --- a/accounting/service.go +++ /dev/null @@ -1,46 +0,0 @@ -package accounting - -import ( - "github.com/nspcc-dev/neofs-api-go/decimal" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" -) - -type ( - // OwnerID type alias. - OwnerID = refs.OwnerID - - // Decimal type alias. - Decimal = decimal.Decimal - - // Filter is used to filter accounts by criteria. - Filter func(acc *Account) bool -) - -const ( - // ErrEmptyAddress is raised when passed Address is empty. - ErrEmptyAddress = internal.Error("empty address") - - // ErrEmptyLockTarget is raised when passed LockTarget is empty. - ErrEmptyLockTarget = internal.Error("empty lock target") - - // ErrEmptyContainerID is raised when passed CID is empty. - ErrEmptyContainerID = internal.Error("empty container ID") - - // ErrEmptyParentAddress is raised when passed ParentAddress is empty. - ErrEmptyParentAddress = internal.Error("empty parent address") -) - -// SumFunds goes through all accounts and sums up active funds. -func SumFunds(accounts []*Account) (res *decimal.Decimal) { - res = decimal.Zero.Copy() - - for i := range accounts { - if accounts[i] == nil { - continue - } - - res = res.Add(accounts[i].ActiveFunds) - } - return -} diff --git a/accounting/service.pb.go b/accounting/service.pb.go deleted file mode 100644 index 8dd146b..0000000 --- a/accounting/service.pb.go +++ /dev/null @@ -1,776 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: accounting/service.proto - -package accounting - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - decimal "github.com/nspcc-dev/neofs-api-go/decimal" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type BalanceRequest struct { - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BalanceRequest) Reset() { *m = BalanceRequest{} } -func (m *BalanceRequest) String() string { return proto.CompactTextString(m) } -func (*BalanceRequest) ProtoMessage() {} -func (*BalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7f9514b8f1d4c7fe, []int{0} -} -func (m *BalanceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *BalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_BalanceRequest.Merge(m, src) -} -func (m *BalanceRequest) XXX_Size() int { - return m.Size() -} -func (m *BalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_BalanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_BalanceRequest proto.InternalMessageInfo - -type BalanceResponse struct { - // Balance contains current account balance state - Balance *decimal.Decimal `protobuf:"bytes,1,opt,name=Balance,proto3" json:"Balance,omitempty"` - // LockAccounts contains information about locked funds. Locked funds appear - // when user pays for storage or withdraw assets. - LockAccounts []*Account `protobuf:"bytes,2,rep,name=LockAccounts,proto3" json:"LockAccounts,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BalanceResponse) Reset() { *m = BalanceResponse{} } -func (m *BalanceResponse) String() string { return proto.CompactTextString(m) } -func (*BalanceResponse) ProtoMessage() {} -func (*BalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7f9514b8f1d4c7fe, []int{1} -} -func (m *BalanceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *BalanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BalanceResponse.Merge(m, src) -} -func (m *BalanceResponse) XXX_Size() int { - return m.Size() -} -func (m *BalanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BalanceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BalanceResponse proto.InternalMessageInfo - -func (m *BalanceResponse) GetBalance() *decimal.Decimal { - if m != nil { - return m.Balance - } - return nil -} - -func (m *BalanceResponse) GetLockAccounts() []*Account { - if m != nil { - return m.LockAccounts - } - return nil -} - -func init() { - proto.RegisterType((*BalanceRequest)(nil), "accounting.BalanceRequest") - proto.RegisterType((*BalanceResponse)(nil), "accounting.BalanceResponse") -} - -func init() { proto.RegisterFile("accounting/service.proto", fileDescriptor_7f9514b8f1d4c7fe) } - -var fileDescriptor_7f9514b8f1d4c7fe = []byte{ - // 399 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0xcd, 0x8e, 0xd3, 0x30, - 0x18, 0x5c, 0x2f, 0x68, 0x17, 0xb9, 0x2b, 0x16, 0x99, 0x05, 0x45, 0x41, 0x4a, 0xab, 0x9e, 0x0a, - 0x22, 0x8e, 0x14, 0x0e, 0x70, 0x6d, 0x54, 0x21, 0x56, 0xe2, 0x67, 0x15, 0x24, 0x24, 0xb8, 0x39, - 0xee, 0xd7, 0x60, 0xb1, 0xb5, 0x43, 0xec, 0x04, 0xed, 0x9b, 0xf0, 0x0c, 0xbc, 0x02, 0x2f, 0xb0, - 0xc7, 0x1e, 0x11, 0x87, 0x0a, 0x85, 0x17, 0x41, 0x75, 0x9c, 0xa6, 0x05, 0x4e, 0xb6, 0x67, 0xbe, - 0x19, 0x8f, 0xc7, 0xd8, 0x63, 0x9c, 0xab, 0x4a, 0x1a, 0x21, 0xf3, 0x48, 0x43, 0x59, 0x0b, 0x0e, - 0xb4, 0x28, 0x95, 0x51, 0x04, 0xf7, 0x8c, 0x4f, 0x1c, 0x15, 0x2d, 0xc1, 0xb0, 0x96, 0xf7, 0xcf, - 0x3a, 0xac, 0x86, 0x52, 0x2c, 0xae, 0x1c, 0x7a, 0x6f, 0x0e, 0x5c, 0x2c, 0xd9, 0x65, 0xe4, 0x56, - 0x07, 0xdf, 0xdf, 0xb9, 0xc6, 0x5c, 0x15, 0xa0, 0x1d, 0x1e, 0xe6, 0xc2, 0x7c, 0xac, 0x32, 0xca, - 0xd5, 0x32, 0xca, 0x55, 0xae, 0x22, 0x0b, 0x67, 0xd5, 0xc2, 0x9e, 0xec, 0xc1, 0xee, 0xda, 0xf1, - 0xf1, 0x77, 0x84, 0x6f, 0x27, 0xec, 0x92, 0x49, 0x0e, 0x29, 0x7c, 0xae, 0x40, 0x1b, 0xf2, 0x10, - 0x1f, 0xbf, 0xf9, 0x22, 0xa1, 0x3c, 0x9f, 0x79, 0x68, 0x84, 0x26, 0x27, 0xc9, 0xe9, 0xf5, 0x7a, - 0x78, 0xf0, 0x73, 0x3d, 0xec, 0xe0, 0xb4, 0xdb, 0x90, 0x67, 0xf8, 0xe6, 0x2b, 0x30, 0xcc, 0xcb, - 0x46, 0x68, 0x32, 0x88, 0x7d, 0xda, 0xbd, 0xd7, 0x59, 0x6d, 0xb8, 0x17, 0xc0, 0xe6, 0x50, 0x26, - 0xb7, 0x36, 0x1e, 0xab, 0xf5, 0x10, 0xa5, 0x56, 0x41, 0x66, 0xf8, 0xe8, 0x9d, 0x7d, 0xa5, 0xc7, - 0xad, 0x76, 0xfc, 0xb7, 0xd6, 0xb2, 0x82, 0x33, 0x23, 0x94, 0xfc, 0xc7, 0xc3, 0x69, 0xc7, 0x35, - 0x3e, 0xdd, 0x86, 0xd7, 0x85, 0x92, 0x1a, 0xc8, 0x23, 0x7c, 0xec, 0x20, 0x9b, 0x7e, 0x10, 0xdf, - 0xa1, 0x5d, 0x71, 0xb3, 0x76, 0x4d, 0xbb, 0x01, 0xf2, 0x14, 0x9f, 0xbc, 0x54, 0xfc, 0xd3, 0xb4, - 0x6d, 0x52, 0x7b, 0x87, 0xa3, 0x1b, 0x93, 0x41, 0x7c, 0x97, 0xf6, 0xd5, 0x52, 0xc7, 0xa5, 0x7b, - 0x83, 0xf1, 0x05, 0xc6, 0xd3, 0xed, 0x0c, 0x49, 0xb6, 0x57, 0x12, 0x7f, 0x57, 0xbb, 0xdf, 0xab, - 0xff, 0xe0, 0xbf, 0x5c, 0x1b, 0x3b, 0x79, 0x7f, 0xdd, 0x04, 0x68, 0xd5, 0x04, 0xe8, 0x47, 0x13, - 0xa0, 0x5f, 0x4d, 0x80, 0xbe, 0xfe, 0x0e, 0x0e, 0x3e, 0x3c, 0xde, 0xf9, 0x4c, 0xa9, 0x0b, 0xce, - 0xc3, 0x39, 0xd4, 0x91, 0x04, 0xb5, 0xd0, 0x21, 0x2b, 0x44, 0x98, 0xab, 0xa8, 0xf7, 0xfc, 0x76, - 0x78, 0xf6, 0x1a, 0xd4, 0xf3, 0xb7, 0x74, 0x7a, 0x71, 0x4e, 0xfb, 0x78, 0xd9, 0x91, 0xfd, 0xe9, - 0x27, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x81, 0x29, 0x02, 0x99, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// AccountingClient is the client API for Accounting service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AccountingClient interface { - // Balance returns current balance status of the NeoFS user - Balance(ctx context.Context, in *BalanceRequest, opts ...grpc.CallOption) (*BalanceResponse, error) -} - -type accountingClient struct { - cc *grpc.ClientConn -} - -func NewAccountingClient(cc *grpc.ClientConn) AccountingClient { - return &accountingClient{cc} -} - -func (c *accountingClient) Balance(ctx context.Context, in *BalanceRequest, opts ...grpc.CallOption) (*BalanceResponse, error) { - out := new(BalanceResponse) - err := c.cc.Invoke(ctx, "/accounting.Accounting/Balance", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AccountingServer is the server API for Accounting service. -type AccountingServer interface { - // Balance returns current balance status of the NeoFS user - Balance(context.Context, *BalanceRequest) (*BalanceResponse, error) -} - -// UnimplementedAccountingServer can be embedded to have forward compatible implementations. -type UnimplementedAccountingServer struct { -} - -func (*UnimplementedAccountingServer) Balance(ctx context.Context, req *BalanceRequest) (*BalanceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented") -} - -func RegisterAccountingServer(s *grpc.Server, srv AccountingServer) { - s.RegisterService(&_Accounting_serviceDesc, srv) -} - -func _Accounting_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(BalanceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccountingServer).Balance(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounting.Accounting/Balance", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccountingServer).Balance(ctx, req.(*BalanceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Accounting_serviceDesc = grpc.ServiceDesc{ - ServiceName: "accounting.Accounting", - HandlerType: (*AccountingServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Balance", - Handler: _Accounting_Balance_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "accounting/service.proto", -} - -func (m *BalanceRequest) 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 *BalanceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *BalanceResponse) 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 *BalanceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.LockAccounts) > 0 { - for iNdEx := len(m.LockAccounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LockAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.Balance != nil { - { - size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *BalanceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BalanceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Balance != nil { - l = m.Balance.Size() - n += 1 + l + sovService(uint64(l)) - } - if len(m.LockAccounts) > 0 { - for _, e := range m.LockAccounts { - l = e.Size() - n += 1 + l + sovService(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *BalanceRequest) 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 ErrIntOverflowService - } - 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: BalanceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BalanceResponse) 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 ErrIntOverflowService - } - 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: BalanceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Balance == nil { - m.Balance = &decimal.Decimal{} - } - if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LockAccounts", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LockAccounts = append(m.LockAccounts, &Account{}) - if err := m.LockAccounts[len(m.LockAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/accounting/service.proto b/accounting/service.proto deleted file mode 100644 index d1540c4..0000000 --- a/accounting/service.proto +++ /dev/null @@ -1,36 +0,0 @@ -syntax = "proto3"; -package accounting; -option go_package = "github.com/nspcc-dev/neofs-api-go/accounting"; -option csharp_namespace = "NeoFS.API.Accounting"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "decimal/decimal.proto"; -import "accounting/types.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Accounting is a service that provides access for accounting balance -// information -service Accounting { - // Balance returns current balance status of the NeoFS user - rpc Balance(BalanceRequest) returns (BalanceResponse); -} - -message BalanceRequest { - // OwnerID is a wallet address - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message BalanceResponse { - // Balance contains current account balance state - decimal.Decimal Balance = 1; - // LockAccounts contains information about locked funds. Locked funds appear - // when user pays for storage or withdraw assets. - repeated Account LockAccounts = 2; -} diff --git a/accounting/sign.go b/accounting/sign.go deleted file mode 100644 index 1eabed4..0000000 --- a/accounting/sign.go +++ /dev/null @@ -1,167 +0,0 @@ -package accounting - -import ( - "encoding/binary" - "io" - - "github.com/nspcc-dev/neofs-api-go/service" -) - -// SignedData returns payload bytes of the request. -func (m BalanceRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m BalanceRequest) SignedDataSize() int { - return m.GetOwnerID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m BalanceRequest) ReadSignedData(p []byte) (int, error) { - sz := m.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - copy(p, m.GetOwnerID().Bytes()) - - return sz, nil -} - -// SignedData returns payload bytes of the request. -func (m GetRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m GetRequest) SignedDataSize() int { - return m.GetID().Size() + m.GetOwnerID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetRequest) ReadSignedData(p []byte) (int, error) { - sz := m.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetID().Bytes()) - - copy(p[off:], m.GetOwnerID().Bytes()) - - return sz, nil -} - -// SignedData returns payload bytes of the request. -func (m PutRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m PutRequest) SignedDataSize() (sz int) { - sz += m.GetOwnerID().Size() - - sz += m.GetMessageID().Size() - - sz += 8 - - if amount := m.GetAmount(); amount != nil { - sz += amount.Size() - } - - return -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m PutRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetOwnerID().Bytes()) - - off += copy(p[off:], m.GetMessageID().Bytes()) - - binary.BigEndian.PutUint64(p[off:], m.GetHeight()) - off += 8 - - if amount := m.GetAmount(); amount != nil { - n, err := amount.MarshalTo(p[off:]) - off += n - if err != nil { - return off + n, err - } - } - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m ListRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m ListRequest) SignedDataSize() int { - return m.GetOwnerID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m ListRequest) ReadSignedData(p []byte) (int, error) { - sz := m.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - copy(p, m.GetOwnerID().Bytes()) - - return sz, nil -} - -// SignedData returns payload bytes of the request. -func (m DeleteRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m DeleteRequest) SignedDataSize() (sz int) { - sz += m.GetID().Size() - - sz += m.GetOwnerID().Size() - - sz += m.GetMessageID().Size() - - return -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m DeleteRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetID().Bytes()) - - off += copy(p[off:], m.GetOwnerID().Bytes()) - - off += copy(p[off:], m.GetMessageID().Bytes()) - - return off, nil -} diff --git a/accounting/sign_test.go b/accounting/sign_test.go deleted file mode 100644 index ebc683b..0000000 --- a/accounting/sign_test.go +++ /dev/null @@ -1,185 +0,0 @@ -package accounting - -import ( - "testing" - - "github.com/nspcc-dev/neofs-api-go/decimal" - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestSignBalanceRequest(t *testing.T) { - sk := test.DecodeKey(0) - - type sigType interface { - service.RequestData - service.SignKeyPairAccumulator - service.SignKeyPairSource - SetToken(*service.Token) - } - - items := []struct { - constructor func() sigType - payloadCorrupt []func(sigType) - }{ - { // BalanceRequest - constructor: func() sigType { - return new(BalanceRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*BalanceRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - }, - }, - { // GetRequest - constructor: func() sigType { - return new(GetRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*GetRequest) - - id, err := NewChequeID() - require.NoError(t, err) - - req.SetID(id) - }, - func(s sigType) { - req := s.(*GetRequest) - - id := req.GetOwnerID() - id[0]++ - - req.SetOwnerID(id) - }, - }, - }, - { // PutRequest - constructor: func() sigType { - req := new(PutRequest) - - amount := decimal.New(1) - req.SetAmount(amount) - - return req - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*PutRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - func(s sigType) { - req := s.(*PutRequest) - - mid := req.GetMessageID() - mid[0]++ - - req.SetMessageID(mid) - }, - func(s sigType) { - req := s.(*PutRequest) - - req.SetHeight(req.GetHeight() + 1) - }, - func(s sigType) { - req := s.(*PutRequest) - - amount := req.GetAmount() - if amount == nil { - req.SetAmount(decimal.New(0)) - } else { - req.SetAmount(amount.Add(decimal.New(amount.GetValue()))) - } - }, - }, - }, - { // ListRequest - constructor: func() sigType { - return new(ListRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*ListRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - }, - }, - { - constructor: func() sigType { - return new(DeleteRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*DeleteRequest) - - id, err := NewChequeID() - require.NoError(t, err) - - req.SetID(id) - }, - func(s sigType) { - req := s.(*DeleteRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - func(s sigType) { - req := s.(*DeleteRequest) - - mid := req.GetMessageID() - mid[0]++ - - req.SetMessageID(mid) - }, - }, - }, - } - - for _, item := range items { - { // token corruptions - v := item.constructor() - - token := new(service.Token) - v.SetToken(token) - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - token.SetSessionKey(append(token.GetSessionKey(), 1)) - - require.Error(t, service.VerifyRequestData(v)) - } - - { // payload corruptions - for _, corruption := range item.payloadCorrupt { - v := item.constructor() - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - corruption(v) - - require.Error(t, service.VerifyRequestData(v)) - } - } - } -} diff --git a/accounting/types.go b/accounting/types.go deleted file mode 100644 index e16fa99..0000000 --- a/accounting/types.go +++ /dev/null @@ -1,453 +0,0 @@ -package accounting - -import ( - "crypto/ecdsa" - "crypto/rand" - "encoding/binary" - "reflect" - - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/chain" - "github.com/nspcc-dev/neofs-api-go/decimal" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/pkg/errors" -) - -type ( - // Cheque structure that describes a user request for withdrawal of funds. - Cheque struct { - ID ChequeID - Owner refs.OwnerID - Amount *decimal.Decimal - Height uint64 - Signatures []ChequeSignature - } - - // BalanceReceiver interface that is used to retrieve user balance by address. - BalanceReceiver interface { - Balance(accountAddress string) (*Account, error) - } - - // ChequeID is identifier of user request for withdrawal of funds. - ChequeID string - - // CID type alias. - CID = refs.CID - - // SGID type alias. - SGID = refs.SGID - - // ChequeSignature contains public key and hash, and is used to verify signatures. - ChequeSignature struct { - Key *ecdsa.PublicKey - Hash []byte - } -) - -const ( - // ErrWrongSignature is raised when wrong signature is passed. - ErrWrongSignature = internal.Error("wrong signature") - - // ErrWrongPublicKey is raised when wrong public key is passed. - ErrWrongPublicKey = internal.Error("wrong public key") - - // ErrWrongChequeData is raised when passed bytes cannot not be parsed as valid Cheque. - ErrWrongChequeData = internal.Error("wrong cheque data") - - // ErrInvalidLength is raised when passed bytes cannot not be parsed as valid ChequeID. - ErrInvalidLength = internal.Error("invalid length") - - u16size = 2 - u64size = 8 - - signaturesOffset = chain.AddressLength + refs.OwnerIDSize + u64size + u64size -) - -// NewChequeID generates valid random ChequeID using crypto/rand.Reader. -func NewChequeID() (ChequeID, error) { - d := make([]byte, chain.AddressLength) - if _, err := rand.Read(d); err != nil { - return "", err - } - - id := base58.Encode(d) - - return ChequeID(id), nil -} - -// String returns string representation of ChequeID. -func (b ChequeID) String() string { return string(b) } - -// Empty returns true, if ChequeID is empty. -func (b ChequeID) Empty() bool { return len(b) == 0 } - -// Valid validates ChequeID. -func (b ChequeID) Valid() bool { - d, err := base58.Decode(string(b)) - return err == nil && len(d) == chain.AddressLength -} - -// Bytes returns bytes representation of ChequeID. -func (b ChequeID) Bytes() []byte { - d, err := base58.Decode(string(b)) - if err != nil { - return make([]byte, chain.AddressLength) - } - return d -} - -// Equal checks that current ChequeID is equal to passed ChequeID. -func (b ChequeID) Equal(b2 ChequeID) bool { - return b.Valid() && b2.Valid() && string(b) == string(b2) -} - -// Unmarshal tries to parse []byte into valid ChequeID. -func (b *ChequeID) Unmarshal(data []byte) error { - *b = ChequeID(base58.Encode(data)) - if !b.Valid() { - return ErrInvalidLength - } - return nil -} - -// Size returns size (chain.AddressLength). -func (b ChequeID) Size() int { - return chain.AddressLength -} - -// MarshalTo tries to marshal ChequeID into passed bytes and returns -// count of copied bytes or error, if bytes len is not enough to contain ChequeID. -func (b ChequeID) MarshalTo(data []byte) (int, error) { - if len(data) < chain.AddressLength { - return 0, ErrInvalidLength - } - return copy(data, b.Bytes()), nil -} - -// Equals checks that m and tx are valid and equal Tx values. -func (m Tx) Equals(tx Tx) bool { - return m.From == tx.From && - m.To == tx.To && - m.Type == tx.Type && - m.Amount == tx.Amount -} - -// Verify validates current Cheque and Signatures that are generated for current Cheque. -func (b Cheque) Verify() error { - data := b.marshalBody() - for i, sign := range b.Signatures { - if err := crypto.VerifyRFC6979(sign.Key, data, sign.Hash); err != nil { - return errors.Wrapf(ErrWrongSignature, "item #%d: %s", i, err.Error()) - } - } - - return nil -} - -// Sign is used to sign current Cheque and stores result inside b.Signatures. -func (b *Cheque) Sign(key *ecdsa.PrivateKey) error { - hash, err := crypto.SignRFC6979(key, b.marshalBody()) - if err != nil { - return err - } - - b.Signatures = append(b.Signatures, ChequeSignature{ - Key: &key.PublicKey, - Hash: hash, - }) - - return nil -} - -func (b *Cheque) marshalBody() []byte { - buf := make([]byte, signaturesOffset) - - var offset int - - offset += copy(buf, b.ID.Bytes()) - offset += copy(buf[offset:], b.Owner.Bytes()) - - binary.LittleEndian.PutUint64(buf[offset:], uint64(b.Amount.Value)) - offset += u64size - - binary.LittleEndian.PutUint64(buf[offset:], b.Height) - - return buf -} - -func (b *Cheque) unmarshalBody(buf []byte) error { - var offset int - - if len(buf) < signaturesOffset { - return ErrWrongChequeData - } - - { // unmarshal UUID - if err := b.ID.Unmarshal(buf[offset : offset+chain.AddressLength]); err != nil { - return err - } - offset += chain.AddressLength - } - - { // unmarshal OwnerID - if err := b.Owner.Unmarshal(buf[offset : offset+refs.OwnerIDSize]); err != nil { - return err - } - offset += refs.OwnerIDSize - } - - { // unmarshal amount - amount := int64(binary.LittleEndian.Uint64(buf[offset:])) - b.Amount = decimal.New(amount) - offset += u64size - } - - { // unmarshal height - b.Height = binary.LittleEndian.Uint64(buf[offset:]) - offset += u64size - } - - return nil -} - -// MarshalBinary is used to marshal Cheque into bytes. -func (b Cheque) MarshalBinary() ([]byte, error) { - var ( - count = len(b.Signatures) - buf = make([]byte, b.Size()) - offset = copy(buf, b.marshalBody()) - ) - - binary.LittleEndian.PutUint16(buf[offset:], uint16(count)) - offset += u16size - - for _, sign := range b.Signatures { - key := crypto.MarshalPublicKey(sign.Key) - offset += copy(buf[offset:], key) - offset += copy(buf[offset:], sign.Hash) - } - - return buf, nil -} - -// Size returns size of Cheque (count of bytes needs to store it). -func (b Cheque) Size() int { - return signaturesOffset + u16size + - len(b.Signatures)*(crypto.PublicKeyCompressedSize+crypto.RFC6979SignatureSize) -} - -// UnmarshalBinary tries to parse []byte into valid Cheque. -func (b *Cheque) UnmarshalBinary(buf []byte) error { - if err := b.unmarshalBody(buf); err != nil { - return err - } - - body := buf[:signaturesOffset] - - count := int64(binary.LittleEndian.Uint16(buf[signaturesOffset:])) - offset := signaturesOffset + u16size - - if ln := count * int64(crypto.PublicKeyCompressedSize+crypto.RFC6979SignatureSize); ln > int64(len(buf[offset:])) { - return ErrWrongChequeData - } - - for i := int64(0); i < count; i++ { - sign := ChequeSignature{ - Key: crypto.UnmarshalPublicKey(buf[offset : offset+crypto.PublicKeyCompressedSize]), - Hash: make([]byte, crypto.RFC6979SignatureSize), - } - - offset += crypto.PublicKeyCompressedSize - if sign.Key == nil { - return errors.Wrapf(ErrWrongPublicKey, "item #%d", i) - } - - offset += copy(sign.Hash, buf[offset:offset+crypto.RFC6979SignatureSize]) - if err := crypto.VerifyRFC6979(sign.Key, body, sign.Hash); err != nil { - return errors.Wrapf(ErrWrongSignature, "item #%d: %s (offset=%d, len=%d)", i, err.Error(), offset, len(sign.Hash)) - } - - b.Signatures = append(b.Signatures, sign) - } - - return nil -} - -// ErrNotEnoughFunds generates error using address and amounts. -func ErrNotEnoughFunds(addr string, needed, residue *decimal.Decimal) error { - return errors.Errorf("not enough funds (requested=%s, residue=%s, addr=%s", needed, residue, addr) -} - -func (m *Account) hasLockAcc(addr string) bool { - for i := range m.LockAccounts { - if m.LockAccounts[i].Address == addr { - return true - } - } - return false -} - -// ValidateLock checks that account can be locked. -func (m *Account) ValidateLock() error { - switch { - case m.Address == "": - return ErrEmptyAddress - case m.ParentAddress == "": - return ErrEmptyParentAddress - case m.LockTarget == nil: - return ErrEmptyLockTarget - } - - switch v := m.LockTarget.Target.(type) { - case *LockTarget_WithdrawTarget: - if v.WithdrawTarget.Cheque != m.Address { - return errors.Errorf("wrong cheque ID: expected %s, has %s", m.Address, v.WithdrawTarget.Cheque) - } - case *LockTarget_ContainerCreateTarget: - switch { - case v.ContainerCreateTarget.CID.Empty(): - return ErrEmptyContainerID - } - } - return nil -} - -// CanLock checks possibility to lock funds. -func (m *Account) CanLock(lockAcc *Account) error { - switch { - case m.ActiveFunds.LT(lockAcc.ActiveFunds): - return ErrNotEnoughFunds(lockAcc.ParentAddress, lockAcc.ActiveFunds, m.ActiveFunds) - case m.hasLockAcc(lockAcc.Address): - return errors.Errorf("could not lock account(%s) funds: duplicating lock(%s)", m.Address, lockAcc.Address) - default: - return nil - } -} - -// LockForWithdraw checks that account contains locked funds by passed ChequeID. -func (m *Account) LockForWithdraw(chequeID string) bool { - switch v := m.LockTarget.Target.(type) { - case *LockTarget_WithdrawTarget: - return v.WithdrawTarget.Cheque == chequeID - } - return false -} - -// LockForContainerCreate checks that account contains locked funds for container creation. -func (m *Account) LockForContainerCreate(cid refs.CID) bool { - switch v := m.LockTarget.Target.(type) { - case *LockTarget_ContainerCreateTarget: - return v.ContainerCreateTarget.CID.Equal(cid) - } - return false -} - -// Equal checks that current Settlement is equal to passed Settlement. -func (m *Settlement) Equal(s *Settlement) bool { - if s == nil || m.Epoch != s.Epoch || len(m.Transactions) != len(s.Transactions) { - return false - } - return len(m.Transactions) == 0 || reflect.DeepEqual(m.Transactions, s.Transactions) -} - -// GetOwnerID is an OwnerID field getter. -func (m BalanceRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *BalanceRequest) SetOwnerID(owner OwnerID) { - m.OwnerID = owner -} - -// GetID is an ID field getter. -func (m GetRequest) GetID() ChequeID { - return m.ID -} - -// SetID is an ID field setter. -func (m *GetRequest) SetID(id ChequeID) { - m.ID = id -} - -// GetOwnerID is an OwnerID field getter. -func (m GetRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *GetRequest) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// GetOwnerID is an OwnerID field getter. -func (m PutRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *PutRequest) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// GetMessageID is a MessageID field getter. -func (m PutRequest) GetMessageID() MessageID { - return m.MessageID -} - -// SetMessageID is a MessageID field setter. -func (m *PutRequest) SetMessageID(id MessageID) { - m.MessageID = id -} - -// SetAmount is an Amount field setter. -func (m *PutRequest) SetAmount(amount *decimal.Decimal) { - m.Amount = amount -} - -// SetHeight is a Height field setter. -func (m *PutRequest) SetHeight(h uint64) { - m.Height = h -} - -// GetOwnerID is an OwnerID field getter. -func (m ListRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *ListRequest) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// GetID is an ID field getter. -func (m DeleteRequest) GetID() ChequeID { - return m.ID -} - -// SetID is an ID field setter. -func (m *DeleteRequest) SetID(id ChequeID) { - m.ID = id -} - -// GetOwnerID is an OwnerID field getter. -func (m DeleteRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *DeleteRequest) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// GetMessageID is a MessageID field getter. -func (m DeleteRequest) GetMessageID() MessageID { - return m.MessageID -} - -// SetMessageID is a MessageID field setter. -func (m *DeleteRequest) SetMessageID(id MessageID) { - m.MessageID = id -} diff --git a/accounting/types.pb.go b/accounting/types.pb.go deleted file mode 100644 index 576ba1f..0000000 --- a/accounting/types.pb.go +++ /dev/null @@ -1,3463 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: accounting/types.proto - -package accounting - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - decimal "github.com/nspcc-dev/neofs-api-go/decimal" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Unit can be Unlimited, based on NeoFS epoch or Neo block -type Lifetime_Unit int32 - -const ( - Lifetime_Unlimited Lifetime_Unit = 0 - Lifetime_NeoFSEpoch Lifetime_Unit = 1 - Lifetime_NeoBlock Lifetime_Unit = 2 -) - -var Lifetime_Unit_name = map[int32]string{ - 0: "Unlimited", - 1: "NeoFSEpoch", - 2: "NeoBlock", -} - -var Lifetime_Unit_value = map[string]int32{ - "Unlimited": 0, - "NeoFSEpoch": 1, - "NeoBlock": 2, -} - -func (x Lifetime_Unit) String() string { - return proto.EnumName(Lifetime_Unit_name, int32(x)) -} - -func (Lifetime_Unit) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{4, 0} -} - -// Type can be withdrawal, payIO or inner -type Tx_Type int32 - -const ( - Tx_Unknown Tx_Type = 0 - Tx_Withdraw Tx_Type = 1 - Tx_PayIO Tx_Type = 2 - Tx_Inner Tx_Type = 3 -) - -var Tx_Type_name = map[int32]string{ - 0: "Unknown", - 1: "Withdraw", - 2: "PayIO", - 3: "Inner", -} - -var Tx_Type_value = map[string]int32{ - "Unknown": 0, - "Withdraw": 1, - "PayIO": 2, - "Inner": 3, -} - -func (x Tx_Type) String() string { - return proto.EnumName(Tx_Type_name, int32(x)) -} - -func (Tx_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{5, 0} -} - -type Account struct { - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Address is identifier of accounting record - Address string `protobuf:"bytes,2,opt,name=Address,proto3" json:"Address,omitempty"` - // ParentAddress is identifier of parent accounting record - ParentAddress string `protobuf:"bytes,3,opt,name=ParentAddress,proto3" json:"ParentAddress,omitempty"` - // ActiveFunds is amount of active (non locked) funds for account - ActiveFunds *decimal.Decimal `protobuf:"bytes,4,opt,name=ActiveFunds,proto3" json:"ActiveFunds,omitempty"` - // Lifetime is time until account is valid (used for lock accounts) - Lifetime Lifetime `protobuf:"bytes,5,opt,name=Lifetime,proto3" json:"Lifetime"` - // LockTarget is the purpose of lock funds (it might be withdraw or payment for storage) - LockTarget *LockTarget `protobuf:"bytes,6,opt,name=LockTarget,proto3" json:"LockTarget,omitempty"` - // LockAccounts contains child accounts with locked funds - LockAccounts []*Account `protobuf:"bytes,7,rep,name=LockAccounts,proto3" json:"LockAccounts,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Account) Reset() { *m = Account{} } -func (m *Account) String() string { return proto.CompactTextString(m) } -func (*Account) ProtoMessage() {} -func (*Account) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{0} -} -func (m *Account) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Account) XXX_Merge(src proto.Message) { - xxx_messageInfo_Account.Merge(m, src) -} -func (m *Account) XXX_Size() int { - return m.Size() -} -func (m *Account) XXX_DiscardUnknown() { - xxx_messageInfo_Account.DiscardUnknown(m) -} - -var xxx_messageInfo_Account proto.InternalMessageInfo - -func (m *Account) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *Account) GetParentAddress() string { - if m != nil { - return m.ParentAddress - } - return "" -} - -func (m *Account) GetActiveFunds() *decimal.Decimal { - if m != nil { - return m.ActiveFunds - } - return nil -} - -func (m *Account) GetLifetime() Lifetime { - if m != nil { - return m.Lifetime - } - return Lifetime{} -} - -func (m *Account) GetLockTarget() *LockTarget { - if m != nil { - return m.LockTarget - } - return nil -} - -func (m *Account) GetLockAccounts() []*Account { - if m != nil { - return m.LockAccounts - } - return nil -} - -// LockTarget must be one of two options -type LockTarget struct { - // Types that are valid to be assigned to Target: - // *LockTarget_WithdrawTarget - // *LockTarget_ContainerCreateTarget - Target isLockTarget_Target `protobuf_oneof:"Target"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LockTarget) Reset() { *m = LockTarget{} } -func (m *LockTarget) String() string { return proto.CompactTextString(m) } -func (*LockTarget) ProtoMessage() {} -func (*LockTarget) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{1} -} -func (m *LockTarget) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LockTarget) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *LockTarget) XXX_Merge(src proto.Message) { - xxx_messageInfo_LockTarget.Merge(m, src) -} -func (m *LockTarget) XXX_Size() int { - return m.Size() -} -func (m *LockTarget) XXX_DiscardUnknown() { - xxx_messageInfo_LockTarget.DiscardUnknown(m) -} - -var xxx_messageInfo_LockTarget proto.InternalMessageInfo - -type isLockTarget_Target interface { - isLockTarget_Target() - MarshalTo([]byte) (int, error) - Size() int -} - -type LockTarget_WithdrawTarget struct { - WithdrawTarget *WithdrawTarget `protobuf:"bytes,1,opt,name=WithdrawTarget,proto3,oneof" json:"WithdrawTarget,omitempty"` -} -type LockTarget_ContainerCreateTarget struct { - ContainerCreateTarget *ContainerCreateTarget `protobuf:"bytes,2,opt,name=ContainerCreateTarget,proto3,oneof" json:"ContainerCreateTarget,omitempty"` -} - -func (*LockTarget_WithdrawTarget) isLockTarget_Target() {} -func (*LockTarget_ContainerCreateTarget) isLockTarget_Target() {} - -func (m *LockTarget) GetTarget() isLockTarget_Target { - if m != nil { - return m.Target - } - return nil -} - -func (m *LockTarget) GetWithdrawTarget() *WithdrawTarget { - if x, ok := m.GetTarget().(*LockTarget_WithdrawTarget); ok { - return x.WithdrawTarget - } - return nil -} - -func (m *LockTarget) GetContainerCreateTarget() *ContainerCreateTarget { - if x, ok := m.GetTarget().(*LockTarget_ContainerCreateTarget); ok { - return x.ContainerCreateTarget - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*LockTarget) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*LockTarget_WithdrawTarget)(nil), - (*LockTarget_ContainerCreateTarget)(nil), - } -} - -type Balances struct { - // Accounts contains multiple account snapshots - Accounts []Account `protobuf:"bytes,1,rep,name=Accounts,proto3" json:"Accounts"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Balances) Reset() { *m = Balances{} } -func (m *Balances) String() string { return proto.CompactTextString(m) } -func (*Balances) ProtoMessage() {} -func (*Balances) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{2} -} -func (m *Balances) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Balances) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Balances) XXX_Merge(src proto.Message) { - xxx_messageInfo_Balances.Merge(m, src) -} -func (m *Balances) XXX_Size() int { - return m.Size() -} -func (m *Balances) XXX_DiscardUnknown() { - xxx_messageInfo_Balances.DiscardUnknown(m) -} - -var xxx_messageInfo_Balances proto.InternalMessageInfo - -func (m *Balances) GetAccounts() []Account { - if m != nil { - return m.Accounts - } - return nil -} - -type PayIO struct { - // BlockID contains id of the NEO block where withdraw or deposit - // call was invoked - BlockID uint64 `protobuf:"varint,1,opt,name=BlockID,proto3" json:"BlockID,omitempty"` - // Transactions contains all transactions that founded in block - // and used for PayIO - Transactions []Tx `protobuf:"bytes,2,rep,name=Transactions,proto3" json:"Transactions"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PayIO) Reset() { *m = PayIO{} } -func (m *PayIO) String() string { return proto.CompactTextString(m) } -func (*PayIO) ProtoMessage() {} -func (*PayIO) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{3} -} -func (m *PayIO) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PayIO) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PayIO) XXX_Merge(src proto.Message) { - xxx_messageInfo_PayIO.Merge(m, src) -} -func (m *PayIO) XXX_Size() int { - return m.Size() -} -func (m *PayIO) XXX_DiscardUnknown() { - xxx_messageInfo_PayIO.DiscardUnknown(m) -} - -var xxx_messageInfo_PayIO proto.InternalMessageInfo - -func (m *PayIO) GetBlockID() uint64 { - if m != nil { - return m.BlockID - } - return 0 -} - -func (m *PayIO) GetTransactions() []Tx { - if m != nil { - return m.Transactions - } - return nil -} - -type Lifetime struct { - // Unit describes how lifetime is measured in account - Unit Lifetime_Unit `protobuf:"varint,1,opt,name=unit,proto3,enum=accounting.Lifetime_Unit" json:"unit,omitempty"` - // Value describes how long lifetime will be valid - Value int64 `protobuf:"varint,2,opt,name=Value,proto3" json:"Value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Lifetime) Reset() { *m = Lifetime{} } -func (m *Lifetime) String() string { return proto.CompactTextString(m) } -func (*Lifetime) ProtoMessage() {} -func (*Lifetime) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{4} -} -func (m *Lifetime) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Lifetime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Lifetime) XXX_Merge(src proto.Message) { - xxx_messageInfo_Lifetime.Merge(m, src) -} -func (m *Lifetime) XXX_Size() int { - return m.Size() -} -func (m *Lifetime) XXX_DiscardUnknown() { - xxx_messageInfo_Lifetime.DiscardUnknown(m) -} - -var xxx_messageInfo_Lifetime proto.InternalMessageInfo - -func (m *Lifetime) GetUnit() Lifetime_Unit { - if m != nil { - return m.Unit - } - return Lifetime_Unlimited -} - -func (m *Lifetime) GetValue() int64 { - if m != nil { - return m.Value - } - return 0 -} - -type Tx struct { - // Type describes target of transaction - Type Tx_Type `protobuf:"varint,1,opt,name=type,proto3,enum=accounting.Tx_Type" json:"type,omitempty"` - // From describes sender of funds - From string `protobuf:"bytes,2,opt,name=From,proto3" json:"From,omitempty"` - // To describes receiver of funds - To string `protobuf:"bytes,3,opt,name=To,proto3" json:"To,omitempty"` - // Amount describes amount of funds - Amount *decimal.Decimal `protobuf:"bytes,4,opt,name=Amount,proto3" json:"Amount,omitempty"` - // PublicKeys contains public key of sender - PublicKeys []byte `protobuf:"bytes,5,opt,name=PublicKeys,proto3" json:"PublicKeys,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Tx) Reset() { *m = Tx{} } -func (m *Tx) String() string { return proto.CompactTextString(m) } -func (*Tx) ProtoMessage() {} -func (*Tx) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{5} -} -func (m *Tx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Tx) XXX_Merge(src proto.Message) { - xxx_messageInfo_Tx.Merge(m, src) -} -func (m *Tx) XXX_Size() int { - return m.Size() -} -func (m *Tx) XXX_DiscardUnknown() { - xxx_messageInfo_Tx.DiscardUnknown(m) -} - -var xxx_messageInfo_Tx proto.InternalMessageInfo - -func (m *Tx) GetType() Tx_Type { - if m != nil { - return m.Type - } - return Tx_Unknown -} - -func (m *Tx) GetFrom() string { - if m != nil { - return m.From - } - return "" -} - -func (m *Tx) GetTo() string { - if m != nil { - return m.To - } - return "" -} - -func (m *Tx) GetAmount() *decimal.Decimal { - if m != nil { - return m.Amount - } - return nil -} - -func (m *Tx) GetPublicKeys() []byte { - if m != nil { - return m.PublicKeys - } - return nil -} - -type Settlement struct { - // Epoch contains an epoch when settlement was accepted - Epoch uint64 `protobuf:"varint,1,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - // Transactions is a set of transactions - Transactions []*Settlement_Tx `protobuf:"bytes,2,rep,name=Transactions,proto3" json:"Transactions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Settlement) Reset() { *m = Settlement{} } -func (m *Settlement) String() string { return proto.CompactTextString(m) } -func (*Settlement) ProtoMessage() {} -func (*Settlement) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{6} -} -func (m *Settlement) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Settlement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Settlement) XXX_Merge(src proto.Message) { - xxx_messageInfo_Settlement.Merge(m, src) -} -func (m *Settlement) XXX_Size() int { - return m.Size() -} -func (m *Settlement) XXX_DiscardUnknown() { - xxx_messageInfo_Settlement.DiscardUnknown(m) -} - -var xxx_messageInfo_Settlement proto.InternalMessageInfo - -func (m *Settlement) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *Settlement) GetTransactions() []*Settlement_Tx { - if m != nil { - return m.Transactions - } - return nil -} - -type Settlement_Receiver struct { - // To is the address of funds recipient - To string `protobuf:"bytes,1,opt,name=To,proto3" json:"To,omitempty"` - // Amount is the amount of funds that will be sent - Amount *decimal.Decimal `protobuf:"bytes,2,opt,name=Amount,proto3" json:"Amount,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Settlement_Receiver) Reset() { *m = Settlement_Receiver{} } -func (m *Settlement_Receiver) String() string { return proto.CompactTextString(m) } -func (*Settlement_Receiver) ProtoMessage() {} -func (*Settlement_Receiver) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{6, 0} -} -func (m *Settlement_Receiver) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Settlement_Receiver) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Settlement_Receiver) XXX_Merge(src proto.Message) { - xxx_messageInfo_Settlement_Receiver.Merge(m, src) -} -func (m *Settlement_Receiver) XXX_Size() int { - return m.Size() -} -func (m *Settlement_Receiver) XXX_DiscardUnknown() { - xxx_messageInfo_Settlement_Receiver.DiscardUnknown(m) -} - -var xxx_messageInfo_Settlement_Receiver proto.InternalMessageInfo - -func (m *Settlement_Receiver) GetTo() string { - if m != nil { - return m.To - } - return "" -} - -func (m *Settlement_Receiver) GetAmount() *decimal.Decimal { - if m != nil { - return m.Amount - } - return nil -} - -type Settlement_Container struct { - // CID is container identifier - CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - // SGIDs is a set of storage groups that successfully passed the audit - SGIDs []SGID `protobuf:"bytes,2,rep,name=SGIDs,proto3,customtype=SGID" json:"SGIDs"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Settlement_Container) Reset() { *m = Settlement_Container{} } -func (m *Settlement_Container) String() string { return proto.CompactTextString(m) } -func (*Settlement_Container) ProtoMessage() {} -func (*Settlement_Container) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{6, 1} -} -func (m *Settlement_Container) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Settlement_Container) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Settlement_Container) XXX_Merge(src proto.Message) { - xxx_messageInfo_Settlement_Container.Merge(m, src) -} -func (m *Settlement_Container) XXX_Size() int { - return m.Size() -} -func (m *Settlement_Container) XXX_DiscardUnknown() { - xxx_messageInfo_Settlement_Container.DiscardUnknown(m) -} - -var xxx_messageInfo_Settlement_Container proto.InternalMessageInfo - -type Settlement_Tx struct { - // From is the address of the sender of funds - From string `protobuf:"bytes,1,opt,name=From,proto3" json:"From,omitempty"` - // Container that successfully had passed the audit - Container Settlement_Container `protobuf:"bytes,2,opt,name=Container,proto3" json:"Container"` - // Receivers is a set of addresses of funds recipients - Receivers []Settlement_Receiver `protobuf:"bytes,3,rep,name=Receivers,proto3" json:"Receivers"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Settlement_Tx) Reset() { *m = Settlement_Tx{} } -func (m *Settlement_Tx) String() string { return proto.CompactTextString(m) } -func (*Settlement_Tx) ProtoMessage() {} -func (*Settlement_Tx) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{6, 2} -} -func (m *Settlement_Tx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Settlement_Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Settlement_Tx) XXX_Merge(src proto.Message) { - xxx_messageInfo_Settlement_Tx.Merge(m, src) -} -func (m *Settlement_Tx) XXX_Size() int { - return m.Size() -} -func (m *Settlement_Tx) XXX_DiscardUnknown() { - xxx_messageInfo_Settlement_Tx.DiscardUnknown(m) -} - -var xxx_messageInfo_Settlement_Tx proto.InternalMessageInfo - -func (m *Settlement_Tx) GetFrom() string { - if m != nil { - return m.From - } - return "" -} - -func (m *Settlement_Tx) GetContainer() Settlement_Container { - if m != nil { - return m.Container - } - return Settlement_Container{} -} - -func (m *Settlement_Tx) GetReceivers() []Settlement_Receiver { - if m != nil { - return m.Receivers - } - return nil -} - -type ContainerCreateTarget struct { - // CID is container identifier - CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ContainerCreateTarget) Reset() { *m = ContainerCreateTarget{} } -func (m *ContainerCreateTarget) String() string { return proto.CompactTextString(m) } -func (*ContainerCreateTarget) ProtoMessage() {} -func (*ContainerCreateTarget) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{7} -} -func (m *ContainerCreateTarget) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ContainerCreateTarget) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ContainerCreateTarget) XXX_Merge(src proto.Message) { - xxx_messageInfo_ContainerCreateTarget.Merge(m, src) -} -func (m *ContainerCreateTarget) XXX_Size() int { - return m.Size() -} -func (m *ContainerCreateTarget) XXX_DiscardUnknown() { - xxx_messageInfo_ContainerCreateTarget.DiscardUnknown(m) -} - -var xxx_messageInfo_ContainerCreateTarget proto.InternalMessageInfo - -type WithdrawTarget struct { - // Cheque is a string representation of cheque id - Cheque string `protobuf:"bytes,1,opt,name=Cheque,proto3" json:"Cheque,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *WithdrawTarget) Reset() { *m = WithdrawTarget{} } -func (m *WithdrawTarget) String() string { return proto.CompactTextString(m) } -func (*WithdrawTarget) ProtoMessage() {} -func (*WithdrawTarget) Descriptor() ([]byte, []int) { - return fileDescriptor_437c556d7375b726, []int{8} -} -func (m *WithdrawTarget) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WithdrawTarget) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *WithdrawTarget) XXX_Merge(src proto.Message) { - xxx_messageInfo_WithdrawTarget.Merge(m, src) -} -func (m *WithdrawTarget) XXX_Size() int { - return m.Size() -} -func (m *WithdrawTarget) XXX_DiscardUnknown() { - xxx_messageInfo_WithdrawTarget.DiscardUnknown(m) -} - -var xxx_messageInfo_WithdrawTarget proto.InternalMessageInfo - -func (m *WithdrawTarget) GetCheque() string { - if m != nil { - return m.Cheque - } - return "" -} - -func init() { - proto.RegisterEnum("accounting.Lifetime_Unit", Lifetime_Unit_name, Lifetime_Unit_value) - proto.RegisterEnum("accounting.Tx_Type", Tx_Type_name, Tx_Type_value) - proto.RegisterType((*Account)(nil), "accounting.Account") - proto.RegisterType((*LockTarget)(nil), "accounting.LockTarget") - proto.RegisterType((*Balances)(nil), "accounting.Balances") - proto.RegisterType((*PayIO)(nil), "accounting.PayIO") - proto.RegisterType((*Lifetime)(nil), "accounting.Lifetime") - proto.RegisterType((*Tx)(nil), "accounting.Tx") - proto.RegisterType((*Settlement)(nil), "accounting.Settlement") - proto.RegisterType((*Settlement_Receiver)(nil), "accounting.Settlement.Receiver") - proto.RegisterType((*Settlement_Container)(nil), "accounting.Settlement.Container") - proto.RegisterType((*Settlement_Tx)(nil), "accounting.Settlement.Tx") - proto.RegisterType((*ContainerCreateTarget)(nil), "accounting.ContainerCreateTarget") - proto.RegisterType((*WithdrawTarget)(nil), "accounting.WithdrawTarget") -} - -func init() { proto.RegisterFile("accounting/types.proto", fileDescriptor_437c556d7375b726) } - -var fileDescriptor_437c556d7375b726 = []byte{ - // 840 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0xcb, 0x6e, 0x23, 0x45, - 0x14, 0x75, 0xb5, 0x1d, 0x3f, 0xae, 0x3d, 0xc6, 0xaa, 0xc9, 0x44, 0xc6, 0x12, 0x8e, 0x69, 0xb1, - 0x30, 0x12, 0x69, 0x8b, 0x8c, 0x48, 0xd8, 0xb0, 0xf0, 0x83, 0x30, 0x16, 0xa3, 0x4c, 0x54, 0x71, - 0x40, 0x03, 0xab, 0x4e, 0xbb, 0xe2, 0x94, 0x62, 0x57, 0x99, 0xee, 0xea, 0x3c, 0x7e, 0x82, 0x35, - 0x1b, 0x56, 0xec, 0xf8, 0x01, 0x7e, 0x61, 0x96, 0xb0, 0x43, 0x2c, 0x22, 0x64, 0x7e, 0x04, 0x55, - 0x75, 0x75, 0xbb, 0x3b, 0xb2, 0x61, 0x63, 0xdf, 0xc7, 0xb9, 0xa7, 0xee, 0xab, 0xaa, 0x61, 0xcf, - 0xf5, 0x3c, 0x11, 0x72, 0xc9, 0xf8, 0xac, 0x27, 0x1f, 0x96, 0x34, 0x70, 0x96, 0xbe, 0x90, 0x02, - 0xc3, 0xda, 0xde, 0x7a, 0x31, 0xa5, 0x1e, 0x5b, 0xb8, 0xf3, 0x9e, 0xf9, 0x8f, 0x20, 0xad, 0x83, - 0x19, 0x93, 0xd7, 0xe1, 0xa5, 0xe3, 0x89, 0x45, 0x6f, 0x26, 0x66, 0xa2, 0xa7, 0xcd, 0x97, 0xe1, - 0x95, 0xd6, 0xb4, 0xa2, 0xa5, 0x08, 0x6e, 0xff, 0x61, 0x41, 0xa9, 0x1f, 0x91, 0xe2, 0x8f, 0xa1, - 0xf4, 0xe6, 0x8e, 0x53, 0x7f, 0x3c, 0x6a, 0xa2, 0x0e, 0xea, 0xd6, 0x06, 0xef, 0xbd, 0x7b, 0xdc, - 0xcf, 0xfd, 0xf5, 0xb8, 0x1f, 0x9b, 0x49, 0x2c, 0xe0, 0x26, 0x94, 0xfa, 0xd3, 0xa9, 0x4f, 0x83, - 0xa0, 0x69, 0x75, 0x50, 0xb7, 0x42, 0x62, 0x15, 0x7f, 0x04, 0xcf, 0xce, 0x5c, 0x9f, 0x72, 0x19, - 0xfb, 0xf3, 0xda, 0x9f, 0x35, 0xe2, 0x43, 0xa8, 0xf6, 0x3d, 0xc9, 0x6e, 0xe9, 0x49, 0xc8, 0xa7, - 0x41, 0xb3, 0xd0, 0x41, 0xdd, 0xea, 0x61, 0xc3, 0x89, 0x4b, 0x19, 0x45, 0xff, 0x24, 0x0d, 0xc2, - 0x47, 0x50, 0x7e, 0xcd, 0xae, 0xa8, 0x64, 0x0b, 0xda, 0xdc, 0xd1, 0x01, 0xbb, 0xce, 0xba, 0x1f, - 0x4e, 0xec, 0x1b, 0x14, 0x54, 0xd6, 0x24, 0xc1, 0xe2, 0x23, 0x80, 0xd7, 0xc2, 0xbb, 0x99, 0xb8, - 0xfe, 0x8c, 0xca, 0x66, 0x51, 0x47, 0xee, 0x65, 0x22, 0x13, 0x2f, 0x49, 0x21, 0xf1, 0x31, 0xd4, - 0x94, 0x66, 0xba, 0x13, 0x34, 0x4b, 0x9d, 0x7c, 0xb7, 0x7a, 0xf8, 0x3c, 0x1d, 0x69, 0x7c, 0x24, - 0x03, 0xb4, 0x7f, 0x43, 0xe9, 0x13, 0xf1, 0x08, 0xea, 0xdf, 0x32, 0x79, 0x3d, 0xf5, 0xdd, 0x3b, - 0x93, 0x03, 0xd2, 0x39, 0xb4, 0xd2, 0x4c, 0x59, 0xc4, 0xab, 0x1c, 0x79, 0x12, 0x83, 0xdf, 0xc2, - 0x8b, 0xa1, 0xe0, 0xd2, 0x65, 0x9c, 0xfa, 0x43, 0x9f, 0xba, 0x92, 0x1a, 0x32, 0x4b, 0x93, 0x7d, - 0x98, 0x26, 0xdb, 0x08, 0x7c, 0x95, 0x23, 0x9b, 0x19, 0x06, 0x65, 0x28, 0x46, 0x92, 0xdd, 0x87, - 0xf2, 0xc0, 0x9d, 0xbb, 0xdc, 0xa3, 0x01, 0xfe, 0x0c, 0xca, 0x49, 0xe9, 0x68, 0x6b, 0xe9, 0x71, - 0xb7, 0x93, 0xe2, 0xbf, 0x87, 0x9d, 0x33, 0xf7, 0x61, 0xfc, 0x46, 0xad, 0xc8, 0x60, 0x2e, 0xbc, - 0x1b, 0xb3, 0x4d, 0x05, 0x12, 0xab, 0xf8, 0x73, 0xa8, 0x4d, 0x7c, 0x97, 0x07, 0xae, 0x27, 0x99, - 0xe0, 0x6a, 0x83, 0x14, 0x7b, 0x3d, 0xcd, 0x3e, 0xb9, 0x37, 0xc4, 0x19, 0xa4, 0xfd, 0x23, 0x5a, - 0xef, 0x00, 0x3e, 0x86, 0x42, 0xc8, 0x59, 0xd4, 0xcd, 0xfa, 0xe1, 0xfb, 0x9b, 0x76, 0xc1, 0xb9, - 0xe0, 0x4c, 0x0e, 0xca, 0xab, 0xc7, 0xfd, 0x82, 0x92, 0x88, 0x0e, 0xc0, 0xbb, 0xb0, 0xf3, 0x8d, - 0x3b, 0x0f, 0xa9, 0x6e, 0x5d, 0x9e, 0x44, 0x8a, 0xfd, 0x12, 0x34, 0x06, 0x3f, 0x83, 0xca, 0x05, - 0x9f, 0xb3, 0x05, 0x93, 0x74, 0xda, 0xc8, 0xe1, 0x3a, 0xc0, 0x29, 0x15, 0x27, 0xe7, 0x5f, 0x2e, - 0x85, 0x77, 0xdd, 0x40, 0xb8, 0x06, 0xe5, 0x53, 0x2a, 0x74, 0x29, 0x0d, 0xcb, 0x7e, 0x44, 0x60, - 0x4d, 0xee, 0xf1, 0xa7, 0x50, 0x50, 0xd7, 0xd4, 0xa4, 0xf2, 0x3c, 0x5b, 0x89, 0x33, 0x79, 0x58, - 0xd2, 0x28, 0x09, 0x25, 0x11, 0x0d, 0xc5, 0x18, 0x0a, 0x27, 0xbe, 0x58, 0x98, 0xeb, 0xa3, 0x65, - 0x5c, 0x07, 0x6b, 0x22, 0xcc, 0x85, 0xb1, 0x26, 0x02, 0x77, 0xa1, 0xd8, 0x5f, 0x28, 0xa2, 0xad, - 0x17, 0xc4, 0xf8, 0x71, 0x1b, 0xe0, 0x2c, 0xbc, 0x9c, 0x33, 0xef, 0x6b, 0xfa, 0x10, 0xe8, 0xdb, - 0x51, 0x23, 0x29, 0x8b, 0x7d, 0x0c, 0xfa, 0x6c, 0x5c, 0x85, 0xd2, 0x05, 0xbf, 0xe1, 0xe2, 0x8e, - 0x37, 0x72, 0xaa, 0x94, 0x78, 0xc9, 0x1a, 0x08, 0x57, 0xcc, 0xe0, 0x1a, 0x96, 0x12, 0xc7, 0x9c, - 0x53, 0xbf, 0x91, 0xb7, 0x7f, 0xce, 0x03, 0x9c, 0x53, 0x29, 0xe7, 0x74, 0x41, 0xb9, 0x6e, 0x9d, - 0x6e, 0x84, 0x19, 0x69, 0xa4, 0xe0, 0x2f, 0x36, 0x0e, 0x34, 0x33, 0x91, 0x35, 0x87, 0x33, 0xb9, - 0xcf, 0x4e, 0xb5, 0x35, 0x82, 0x32, 0xa1, 0x1e, 0x65, 0xb7, 0xd4, 0x37, 0x2d, 0x40, 0x1b, 0x5a, - 0x60, 0xfd, 0x77, 0x0b, 0x5a, 0xa7, 0x50, 0x49, 0xd6, 0x1b, 0x7f, 0x00, 0xf9, 0x61, 0xf2, 0x8c, - 0x55, 0xcd, 0x33, 0xa6, 0x4c, 0x44, 0xfd, 0x60, 0x1b, 0x76, 0xce, 0xbf, 0x1a, 0x8f, 0xa2, 0x4c, - 0x6b, 0x83, 0x9a, 0x01, 0x14, 0x94, 0x91, 0x44, 0xae, 0xd6, 0x2f, 0xd1, 0x68, 0xe3, 0x39, 0xa1, - 0xd4, 0x9c, 0x46, 0xa9, 0xa3, 0x4c, 0x5e, 0x9d, 0x2d, 0xc5, 0x26, 0x38, 0xb3, 0xcf, 0xa9, 0x1c, - 0x87, 0x50, 0x89, 0xcb, 0x56, 0xaf, 0xa4, 0x6a, 0xd9, 0xfe, 0x16, 0x96, 0x18, 0x17, 0x93, 0x24, - 0x71, 0xf6, 0xd1, 0x96, 0x67, 0xe1, 0x7f, 0x3a, 0x60, 0x77, 0x9f, 0x3e, 0x4a, 0x78, 0x0f, 0x8a, - 0xc3, 0x6b, 0xfa, 0x43, 0x48, 0x4d, 0xa9, 0x46, 0x1b, 0xbc, 0x7d, 0xb7, 0x6a, 0xa3, 0xdf, 0x57, - 0x6d, 0xf4, 0xe7, 0xaa, 0x8d, 0xfe, 0x5e, 0xb5, 0xd1, 0x4f, 0xff, 0xb4, 0x73, 0xdf, 0x7d, 0x92, - 0xfa, 0xcc, 0xf0, 0x60, 0xe9, 0x79, 0x07, 0x53, 0x7a, 0xdb, 0xe3, 0x54, 0x5c, 0x05, 0x07, 0xee, - 0x92, 0x1d, 0xcc, 0x44, 0x6f, 0x5d, 0xca, 0xaf, 0xd6, 0xae, 0xbe, 0x43, 0x4e, 0xff, 0x6c, 0x1c, - 0x3f, 0x1c, 0x8c, 0xcf, 0x2e, 0x8b, 0xfa, 0x1b, 0xf4, 0xf2, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xc4, 0xae, 0x74, 0x80, 0xef, 0x06, 0x00, 0x00, -} - -func (m *Account) 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 *Account) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Account) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.LockAccounts) > 0 { - for iNdEx := len(m.LockAccounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LockAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if m.LockTarget != nil { - { - size, err := m.LockTarget.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - { - size, err := m.Lifetime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.ActiveFunds != nil { - { - size, err := m.ActiveFunds.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.ParentAddress) > 0 { - i -= len(m.ParentAddress) - copy(dAtA[i:], m.ParentAddress) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ParentAddress))) - i-- - dAtA[i] = 0x1a - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *LockTarget) 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 *LockTarget) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LockTarget) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Target != nil { - { - size := m.Target.Size() - i -= size - if _, err := m.Target.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *LockTarget_WithdrawTarget) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LockTarget_WithdrawTarget) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.WithdrawTarget != nil { - { - size, err := m.WithdrawTarget.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *LockTarget_ContainerCreateTarget) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LockTarget_ContainerCreateTarget) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ContainerCreateTarget != nil { - { - size, err := m.ContainerCreateTarget.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *Balances) 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 *Balances) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Balances) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Accounts) > 0 { - for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Accounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *PayIO) 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 *PayIO) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PayIO) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Transactions) > 0 { - for iNdEx := len(m.Transactions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Transactions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.BlockID != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.BlockID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Lifetime) 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 *Lifetime) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Lifetime) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Value != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Value)) - i-- - dAtA[i] = 0x10 - } - if m.Unit != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Unit)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Tx) 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 *Tx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Tx) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PublicKeys) > 0 { - i -= len(m.PublicKeys) - copy(dAtA[i:], m.PublicKeys) - i = encodeVarintTypes(dAtA, i, uint64(len(m.PublicKeys))) - i-- - dAtA[i] = 0x2a - } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTypes(dAtA, i, uint64(len(m.To))) - i-- - dAtA[i] = 0x1a - } - if len(m.From) > 0 { - i -= len(m.From) - copy(dAtA[i:], m.From) - i = encodeVarintTypes(dAtA, i, uint64(len(m.From))) - i-- - dAtA[i] = 0x12 - } - if m.Type != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Settlement) 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 *Settlement) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Settlement) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Transactions) > 0 { - for iNdEx := len(m.Transactions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Transactions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.Epoch != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Settlement_Receiver) 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 *Settlement_Receiver) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Settlement_Receiver) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTypes(dAtA, i, uint64(len(m.To))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Settlement_Container) 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 *Settlement_Container) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Settlement_Container) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.SGIDs) > 0 { - for iNdEx := len(m.SGIDs) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.SGIDs[iNdEx].Size() - i -= size - if _, err := m.SGIDs[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Settlement_Tx) 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 *Settlement_Tx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Settlement_Tx) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Receivers) > 0 { - for iNdEx := len(m.Receivers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Receivers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - { - size, err := m.Container.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.From) > 0 { - i -= len(m.From) - copy(dAtA[i:], m.From) - i = encodeVarintTypes(dAtA, i, uint64(len(m.From))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ContainerCreateTarget) 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 *ContainerCreateTarget) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ContainerCreateTarget) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *WithdrawTarget) 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 *WithdrawTarget) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WithdrawTarget) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Cheque) > 0 { - i -= len(m.Cheque) - copy(dAtA[i:], m.Cheque) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Cheque))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Account) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.ParentAddress) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.ActiveFunds != nil { - l = m.ActiveFunds.Size() - n += 1 + l + sovTypes(uint64(l)) - } - l = m.Lifetime.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.LockTarget != nil { - l = m.LockTarget.Size() - n += 1 + l + sovTypes(uint64(l)) - } - if len(m.LockAccounts) > 0 { - for _, e := range m.LockAccounts { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *LockTarget) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Target != nil { - n += m.Target.Size() - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *LockTarget_WithdrawTarget) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.WithdrawTarget != nil { - l = m.WithdrawTarget.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *LockTarget_ContainerCreateTarget) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ContainerCreateTarget != nil { - l = m.ContainerCreateTarget.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Balances) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Accounts) > 0 { - for _, e := range m.Accounts { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PayIO) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockID != 0 { - n += 1 + sovTypes(uint64(m.BlockID)) - } - if len(m.Transactions) > 0 { - for _, e := range m.Transactions { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Lifetime) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Unit != 0 { - n += 1 + sovTypes(uint64(m.Unit)) - } - if m.Value != 0 { - n += 1 + sovTypes(uint64(m.Value)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Tx) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovTypes(uint64(m.Type)) - } - l = len(m.From) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.To) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.PublicKeys) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Settlement) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != 0 { - n += 1 + sovTypes(uint64(m.Epoch)) - } - if len(m.Transactions) > 0 { - for _, e := range m.Transactions { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Settlement_Receiver) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.To) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Settlement_Container) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CID.Size() - n += 1 + l + sovTypes(uint64(l)) - if len(m.SGIDs) > 0 { - for _, e := range m.SGIDs { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Settlement_Tx) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.From) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = m.Container.Size() - n += 1 + l + sovTypes(uint64(l)) - if len(m.Receivers) > 0 { - for _, e := range m.Receivers { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ContainerCreateTarget) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CID.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *WithdrawTarget) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Cheque) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Account) 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 ErrIntOverflowTypes - } - 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: Account: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Account: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ParentAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ParentAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ActiveFunds", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ActiveFunds == nil { - m.ActiveFunds = &decimal.Decimal{} - } - if err := m.ActiveFunds.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lifetime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Lifetime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LockTarget", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LockTarget == nil { - m.LockTarget = &LockTarget{} - } - if err := m.LockTarget.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LockAccounts", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LockAccounts = append(m.LockAccounts, &Account{}) - if err := m.LockAccounts[len(m.LockAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LockTarget) 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 ErrIntOverflowTypes - } - 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: LockTarget: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LockTarget: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WithdrawTarget", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &WithdrawTarget{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Target = &LockTarget_WithdrawTarget{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContainerCreateTarget", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ContainerCreateTarget{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Target = &LockTarget_ContainerCreateTarget{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Balances) 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 ErrIntOverflowTypes - } - 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: Balances: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Balances: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Accounts = append(m.Accounts, Account{}) - if err := m.Accounts[len(m.Accounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PayIO) 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 ErrIntOverflowTypes - } - 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: PayIO: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PayIO: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockID", wireType) - } - m.BlockID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Transactions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Transactions = append(m.Transactions, Tx{}) - if err := m.Transactions[len(m.Transactions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Lifetime) 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 ErrIntOverflowTypes - } - 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: Lifetime: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Lifetime: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Unit", wireType) - } - m.Unit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Unit |= Lifetime_Unit(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - m.Value = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Value |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Tx) 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 ErrIntOverflowTypes - } - 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: Tx: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Tx: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Tx_Type(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.From = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.To = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Amount == nil { - m.Amount = &decimal.Decimal{} - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublicKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PublicKeys = append(m.PublicKeys[:0], dAtA[iNdEx:postIndex]...) - if m.PublicKeys == nil { - m.PublicKeys = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Settlement) 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 ErrIntOverflowTypes - } - 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: Settlement: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Settlement: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Transactions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Transactions = append(m.Transactions, &Settlement_Tx{}) - if err := m.Transactions[len(m.Transactions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Settlement_Receiver) 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 ErrIntOverflowTypes - } - 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: Receiver: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Receiver: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.To = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Amount == nil { - m.Amount = &decimal.Decimal{} - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Settlement_Container) 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 ErrIntOverflowTypes - } - 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: Container: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Container: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SGIDs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v SGID - m.SGIDs = append(m.SGIDs, v) - if err := m.SGIDs[len(m.SGIDs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Settlement_Tx) 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 ErrIntOverflowTypes - } - 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: Tx: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Tx: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.From = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Container", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Container.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Receivers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Receivers = append(m.Receivers, Settlement_Receiver{}) - if err := m.Receivers[len(m.Receivers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ContainerCreateTarget) 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 ErrIntOverflowTypes - } - 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: ContainerCreateTarget: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ContainerCreateTarget: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *WithdrawTarget) 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 ErrIntOverflowTypes - } - 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: WithdrawTarget: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: WithdrawTarget: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cheque", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cheque = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/accounting/types.proto b/accounting/types.proto deleted file mode 100644 index 02fb691..0000000 --- a/accounting/types.proto +++ /dev/null @@ -1,125 +0,0 @@ -syntax = "proto3"; -package accounting; -option go_package = "github.com/nspcc-dev/neofs-api-go/accounting"; -option csharp_namespace = "NeoFS.API.Accounting"; - -import "decimal/decimal.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -message Account { - // OwnerID is a wallet address - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // Address is identifier of accounting record - string Address = 2; - // ParentAddress is identifier of parent accounting record - string ParentAddress = 3; - // ActiveFunds is amount of active (non locked) funds for account - decimal.Decimal ActiveFunds = 4; - // Lifetime is time until account is valid (used for lock accounts) - Lifetime Lifetime = 5 [(gogoproto.nullable) = false]; - // LockTarget is the purpose of lock funds (it might be withdraw or payment for storage) - LockTarget LockTarget = 6; - // LockAccounts contains child accounts with locked funds - repeated Account LockAccounts = 7; -} - -// LockTarget must be one of two options -message LockTarget { - oneof Target { - // WithdrawTarget used when user requested withdraw - WithdrawTarget WithdrawTarget = 1; - // ContainerCreateTarget used when user requested creation of container - ContainerCreateTarget ContainerCreateTarget = 2; - } -} - -message Balances { - // Accounts contains multiple account snapshots - repeated Account Accounts = 1 [(gogoproto.nullable) = false]; -} - -message PayIO { - // BlockID contains id of the NEO block where withdraw or deposit - // call was invoked - uint64 BlockID = 1; - // Transactions contains all transactions that founded in block - // and used for PayIO - repeated Tx Transactions = 2 [(gogoproto.nullable) = false]; -} - -message Lifetime { - // Unit can be Unlimited, based on NeoFS epoch or Neo block - enum Unit { - Unlimited = 0; - NeoFSEpoch = 1; - NeoBlock = 2; - } - - // Unit describes how lifetime is measured in account - Unit unit = 1 [(gogoproto.customname) = "Unit"]; - // Value describes how long lifetime will be valid - int64 Value = 2; -} - -message Tx { - // Type can be withdrawal, payIO or inner - enum Type { - Unknown = 0; - Withdraw = 1; - PayIO = 2; - Inner = 3; - } - - // Type describes target of transaction - Type type = 1 [(gogoproto.customname) = "Type"]; - // From describes sender of funds - string From = 2; - // To describes receiver of funds - string To = 3; - // Amount describes amount of funds - decimal.Decimal Amount = 4; - // PublicKeys contains public key of sender - bytes PublicKeys = 5; -} - -message Settlement { - message Receiver { - // To is the address of funds recipient - string To = 1; - // Amount is the amount of funds that will be sent - decimal.Decimal Amount = 2; - } - - message Container { - // CID is container identifier - bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; - // SGIDs is a set of storage groups that successfully passed the audit - repeated bytes SGIDs = 2 [(gogoproto.customtype) = "SGID", (gogoproto.nullable) = false]; - } - - message Tx { - // From is the address of the sender of funds - string From = 1; - // Container that successfully had passed the audit - Container Container = 2 [(gogoproto.nullable) = false]; - // Receivers is a set of addresses of funds recipients - repeated Receiver Receivers = 3 [(gogoproto.nullable) = false]; - } - - // Epoch contains an epoch when settlement was accepted - uint64 Epoch = 1; - // Transactions is a set of transactions - repeated Tx Transactions = 2; -} - -message ContainerCreateTarget { - // CID is container identifier - bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; -} - -message WithdrawTarget { - // Cheque is a string representation of cheque id - string Cheque = 1; -} diff --git a/accounting/types_test.go b/accounting/types_test.go deleted file mode 100644 index a440028..0000000 --- a/accounting/types_test.go +++ /dev/null @@ -1,193 +0,0 @@ -package accounting - -import ( - "io/ioutil" - "testing" - - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/chain" - "github.com/nspcc-dev/neofs-api-go/decimal" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestCheque(t *testing.T) { - t.Run("new/valid", func(t *testing.T) { - id, err := NewChequeID() - require.NoError(t, err) - require.True(t, id.Valid()) - - d := make([]byte, chain.AddressLength+1) - - // expected size + 1 byte - str := base58.Encode(d) - require.False(t, ChequeID(str).Valid()) - - // expected size - 1 byte - str = base58.Encode(d[:len(d)-2]) - require.False(t, ChequeID(str).Valid()) - - // wrong encoding - d = d[:len(d)-1] // normal size - require.False(t, ChequeID(string(d)).Valid()) - }) - - t.Run("marshal/unmarshal", func(t *testing.T) { - b2 := new(Cheque) - - key1 := test.DecodeKey(0) - key2 := test.DecodeKey(1) - - id, err := NewChequeID() - require.NoError(t, err) - - owner, err := refs.NewOwnerID(&key1.PublicKey) - require.NoError(t, err) - - b1 := &Cheque{ - ID: id, - Owner: owner, - Height: 100, - Amount: decimal.NewGAS(100), - } - - require.NoError(t, b1.Sign(key1)) - require.NoError(t, b1.Sign(key2)) - - data, err := b1.MarshalBinary() - require.NoError(t, err) - - require.Len(t, data, b1.Size()) - require.NoError(t, b2.UnmarshalBinary(data)) - require.Equal(t, b1, b2) - - require.NoError(t, b1.Verify()) - require.NoError(t, b2.Verify()) - }) - - t.Run("example from SC", func(t *testing.T) { - pathToCheque := "fixtures/cheque_data" - expect, err := ioutil.ReadFile(pathToCheque) - require.NoError(t, err) - - var cheque Cheque - require.NoError(t, cheque.UnmarshalBinary(expect)) - - actual, err := cheque.MarshalBinary() - require.NoError(t, err) - - require.Equal(t, expect, actual) - - require.NoError(t, cheque.Verify()) - require.Equal(t, cheque.Height, uint64(7777)) - require.Equal(t, cheque.Amount, decimal.NewGAS(42)) - }) -} - -func TestBalanceRequest_SetOwnerID(t *testing.T) { - ownerID := OwnerID{1, 2, 3} - m := new(BalanceRequest) - - m.SetOwnerID(ownerID) - - require.Equal(t, ownerID, m.GetOwnerID()) -} - -func TestGetRequestGettersSetters(t *testing.T) { - t.Run("id", func(t *testing.T) { - id := ChequeID("test id") - m := new(GetRequest) - - m.SetID(id) - - require.Equal(t, id, m.GetID()) - }) - - t.Run("owner", func(t *testing.T) { - id := OwnerID{1, 2, 3} - m := new(GetRequest) - - m.SetOwnerID(id) - - require.Equal(t, id, m.GetOwnerID()) - }) -} - -func TestPutRequestGettersSetters(t *testing.T) { - t.Run("owner", func(t *testing.T) { - id := OwnerID{1, 2, 3} - m := new(PutRequest) - - m.SetOwnerID(id) - - require.Equal(t, id, m.GetOwnerID()) - }) - - t.Run("message ID", func(t *testing.T) { - id, err := refs.NewUUID() - require.NoError(t, err) - - m := new(PutRequest) - m.SetMessageID(id) - - require.Equal(t, id, m.GetMessageID()) - }) - - t.Run("amount", func(t *testing.T) { - amount := decimal.New(1) - m := new(PutRequest) - - m.SetAmount(amount) - - require.Equal(t, amount, m.GetAmount()) - }) - - t.Run("height", func(t *testing.T) { - h := uint64(3) - m := new(PutRequest) - - m.SetHeight(h) - - require.Equal(t, h, m.GetHeight()) - }) -} - -func TestListRequestGettersSetters(t *testing.T) { - ownerID := OwnerID{1, 2, 3} - m := new(ListRequest) - - m.SetOwnerID(ownerID) - - require.Equal(t, ownerID, m.GetOwnerID()) -} - -func TestDeleteRequestGettersSetters(t *testing.T) { - t.Run("id", func(t *testing.T) { - id := ChequeID("test id") - m := new(DeleteRequest) - - m.SetID(id) - - require.Equal(t, id, m.GetID()) - }) - - t.Run("owner", func(t *testing.T) { - id := OwnerID{1, 2, 3} - m := new(DeleteRequest) - - m.SetOwnerID(id) - - require.Equal(t, id, m.GetOwnerID()) - }) - - t.Run("message ID", func(t *testing.T) { - id, err := refs.NewUUID() - require.NoError(t, err) - - m := new(DeleteRequest) - m.SetMessageID(id) - - require.Equal(t, id, m.GetMessageID()) - }) -} diff --git a/accounting/withdraw.go b/accounting/withdraw.go deleted file mode 100644 index 1077395..0000000 --- a/accounting/withdraw.go +++ /dev/null @@ -1,35 +0,0 @@ -package accounting - -import ( - "encoding/binary" - - "github.com/nspcc-dev/neofs-api-go/refs" -) - -type ( - // MessageID type alias. - MessageID = refs.MessageID -) - -// PrepareData prepares bytes representation of PutRequest to satisfy SignedRequest interface. -func (m *PutRequest) PrepareData() ([]byte, error) { - var offset int - // MessageID-len + OwnerID-len + Amount + Height - buf := make([]byte, refs.UUIDSize+refs.OwnerIDSize+binary.MaxVarintLen64+binary.MaxVarintLen64) - offset += copy(buf[offset:], m.MessageID.Bytes()) - offset += copy(buf[offset:], m.OwnerID.Bytes()) - offset += binary.PutVarint(buf[offset:], m.Amount.Value) - binary.PutUvarint(buf[offset:], m.Height) - return buf, nil -} - -// PrepareData prepares bytes representation of DeleteRequest to satisfy SignedRequest interface. -func (m *DeleteRequest) PrepareData() ([]byte, error) { - var offset int - // ID-len + OwnerID-len + MessageID-len - buf := make([]byte, refs.UUIDSize+refs.OwnerIDSize+refs.UUIDSize) - offset += copy(buf[offset:], m.ID.Bytes()) - offset += copy(buf[offset:], m.OwnerID.Bytes()) - copy(buf[offset:], m.MessageID.Bytes()) - return buf, nil -} diff --git a/accounting/withdraw.pb.go b/accounting/withdraw.pb.go deleted file mode 100644 index e0825f5..0000000 --- a/accounting/withdraw.pb.go +++ /dev/null @@ -1,2819 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: accounting/withdraw.proto - -package accounting - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - decimal "github.com/nspcc-dev/neofs-api-go/decimal" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type Item struct { - // ID is a cheque identifier - ID ChequeID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=ChequeID" json:"ID"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Amount of funds - Amount *decimal.Decimal `protobuf:"bytes,3,opt,name=Amount,proto3" json:"Amount,omitempty"` - // Height is the neo blockchain height until the cheque is valid - Height uint64 `protobuf:"varint,4,opt,name=Height,proto3" json:"Height,omitempty"` - // Payload contains cheque representation in bytes - Payload []byte `protobuf:"bytes,5,opt,name=Payload,proto3" json:"Payload,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Item) Reset() { *m = Item{} } -func (m *Item) String() string { return proto.CompactTextString(m) } -func (*Item) ProtoMessage() {} -func (*Item) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{0} -} -func (m *Item) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Item) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Item) XXX_Merge(src proto.Message) { - xxx_messageInfo_Item.Merge(m, src) -} -func (m *Item) XXX_Size() int { - return m.Size() -} -func (m *Item) XXX_DiscardUnknown() { - xxx_messageInfo_Item.DiscardUnknown(m) -} - -var xxx_messageInfo_Item proto.InternalMessageInfo - -func (m *Item) GetAmount() *decimal.Decimal { - if m != nil { - return m.Amount - } - return nil -} - -func (m *Item) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *Item) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -type GetRequest struct { - // ID is cheque identifier - ID ChequeID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=ChequeID" json:"ID"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{1} -} -func (m *GetRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRequest.Merge(m, src) -} -func (m *GetRequest) XXX_Size() int { - return m.Size() -} -func (m *GetRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRequest proto.InternalMessageInfo - -type GetResponse struct { - // Withdraw is cheque with meta information - Withdraw *Item `protobuf:"bytes,1,opt,name=Withdraw,proto3" json:"Withdraw,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{2} -} -func (m *GetResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetResponse.Merge(m, src) -} -func (m *GetResponse) XXX_Size() int { - return m.Size() -} -func (m *GetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetResponse proto.InternalMessageInfo - -func (m *GetResponse) GetWithdraw() *Item { - if m != nil { - return m.Withdraw - } - return nil -} - -type PutRequest struct { - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Amount of funds - Amount *decimal.Decimal `protobuf:"bytes,2,opt,name=Amount,proto3" json:"Amount,omitempty"` - // Height is the neo blockchain height until the cheque is valid - Height uint64 `protobuf:"varint,3,opt,name=Height,proto3" json:"Height,omitempty"` - // MessageID is a nonce for uniq request (UUIDv4) - MessageID MessageID `protobuf:"bytes,4,opt,name=MessageID,proto3,customtype=MessageID" json:"MessageID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutRequest) Reset() { *m = PutRequest{} } -func (m *PutRequest) String() string { return proto.CompactTextString(m) } -func (*PutRequest) ProtoMessage() {} -func (*PutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{3} -} -func (m *PutRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutRequest.Merge(m, src) -} -func (m *PutRequest) XXX_Size() int { - return m.Size() -} -func (m *PutRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PutRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PutRequest proto.InternalMessageInfo - -func (m *PutRequest) GetAmount() *decimal.Decimal { - if m != nil { - return m.Amount - } - return nil -} - -func (m *PutRequest) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -type PutResponse struct { - // ID is cheque identifier - ID ChequeID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=ChequeID" json:"ID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutResponse) Reset() { *m = PutResponse{} } -func (m *PutResponse) String() string { return proto.CompactTextString(m) } -func (*PutResponse) ProtoMessage() {} -func (*PutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{4} -} -func (m *PutResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutResponse.Merge(m, src) -} -func (m *PutResponse) XXX_Size() int { - return m.Size() -} -func (m *PutResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PutResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PutResponse proto.InternalMessageInfo - -type ListRequest struct { - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{5} -} -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return m.Size() -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -type ListResponse struct { - // Items is a set of cheques with meta information - Items []*Item `protobuf:"bytes,1,rep,name=Items,proto3" json:"Items,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{6} -} -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return m.Size() -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -func (m *ListResponse) GetItems() []*Item { - if m != nil { - return m.Items - } - return nil -} - -type DeleteRequest struct { - // ID is cheque identifier - ID ChequeID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=ChequeID" json:"ID"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // MessageID is a nonce for uniq request (UUIDv4) - MessageID MessageID `protobuf:"bytes,3,opt,name=MessageID,proto3,customtype=MessageID" json:"MessageID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{7} -} -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return m.Size() -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -// DeleteResponse is empty -type DeleteResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b3a38a4dc2575267, []int{8} -} -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return m.Size() -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Item)(nil), "accounting.Item") - proto.RegisterType((*GetRequest)(nil), "accounting.GetRequest") - proto.RegisterType((*GetResponse)(nil), "accounting.GetResponse") - proto.RegisterType((*PutRequest)(nil), "accounting.PutRequest") - proto.RegisterType((*PutResponse)(nil), "accounting.PutResponse") - proto.RegisterType((*ListRequest)(nil), "accounting.ListRequest") - proto.RegisterType((*ListResponse)(nil), "accounting.ListResponse") - proto.RegisterType((*DeleteRequest)(nil), "accounting.DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "accounting.DeleteResponse") -} - -func init() { proto.RegisterFile("accounting/withdraw.proto", fileDescriptor_b3a38a4dc2575267) } - -var fileDescriptor_b3a38a4dc2575267 = []byte{ - // 620 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xc1, 0x6e, 0xd3, 0x4c, - 0x10, 0xee, 0xda, 0x69, 0xda, 0x7f, 0xd2, 0x1f, 0xca, 0xaa, 0x14, 0xd7, 0x87, 0x34, 0xf2, 0x01, - 0x05, 0xa9, 0xb1, 0xa5, 0x22, 0x55, 0x20, 0x0e, 0xa8, 0xc1, 0xa2, 0xb5, 0x44, 0x21, 0x32, 0x12, - 0x08, 0x6e, 0x8e, 0x33, 0x75, 0x2c, 0x35, 0xde, 0x60, 0xaf, 0x5b, 0xf5, 0x21, 0xb8, 0xf3, 0x0c, - 0xbd, 0x70, 0xe5, 0x11, 0x7a, 0xec, 0x11, 0x38, 0x54, 0x28, 0xbc, 0x03, 0x67, 0xe4, 0xf5, 0xba, - 0x76, 0xda, 0x4a, 0x54, 0x08, 0x54, 0x71, 0xca, 0xee, 0x7c, 0x33, 0xbb, 0x33, 0xdf, 0xf7, 0x6d, - 0x0c, 0x2b, 0x9e, 0xef, 0xb3, 0x34, 0xe2, 0x61, 0x14, 0x58, 0x07, 0x21, 0x1f, 0x0e, 0x62, 0xef, - 0xc0, 0x1c, 0xc7, 0x8c, 0x33, 0x0a, 0x25, 0xa4, 0xd3, 0x04, 0xe3, 0xfd, 0xd0, 0x47, 0x6b, 0x84, - 0xdc, 0xcb, 0x71, 0x7d, 0xa9, 0x88, 0xed, 0x63, 0x1c, 0xee, 0x1e, 0xca, 0xe8, 0xed, 0x01, 0xfa, - 0xe1, 0xc8, 0xdb, 0xb3, 0xe4, 0xaf, 0x0c, 0x77, 0x82, 0x90, 0x0f, 0xd3, 0xbe, 0xe9, 0xb3, 0x91, - 0x15, 0xb0, 0x80, 0x59, 0x22, 0xdc, 0x4f, 0x77, 0xc5, 0x4e, 0x6c, 0xc4, 0x2a, 0x4f, 0x37, 0x3e, - 0x12, 0xa8, 0x39, 0x1c, 0x47, 0xb4, 0x05, 0x8a, 0x63, 0x6b, 0xa4, 0x45, 0xda, 0x0b, 0xdd, 0xc5, - 0xe3, 0xd3, 0xd5, 0x99, 0xaf, 0xa7, 0xab, 0xf3, 0x4f, 0x86, 0xf8, 0x2e, 0x45, 0xc7, 0x76, 0x15, - 0xc7, 0xa6, 0xf7, 0x60, 0xee, 0xc5, 0x41, 0x84, 0xb1, 0x63, 0x6b, 0x8a, 0x48, 0xbb, 0x29, 0xd3, - 0x8a, 0xb0, 0x5b, 0x2c, 0x68, 0x1b, 0xea, 0x9b, 0xa3, 0x6c, 0x24, 0x4d, 0x6d, 0x91, 0x76, 0x63, - 0x7d, 0xd1, 0x2c, 0x9a, 0xb4, 0xf3, 0x5f, 0x57, 0xe2, 0x74, 0x19, 0xea, 0xdb, 0x18, 0x06, 0x43, - 0xae, 0xd5, 0x5a, 0xa4, 0x5d, 0x73, 0xe5, 0x8e, 0x6a, 0x30, 0xd7, 0xf3, 0x0e, 0xf7, 0x98, 0x37, - 0xd0, 0x66, 0xb3, 0xcb, 0xdc, 0x62, 0x6b, 0x7c, 0x21, 0x00, 0x5b, 0xc8, 0xdd, 0xac, 0xb3, 0x84, - 0xff, 0xd9, 0xbe, 0x1f, 0x40, 0x6d, 0x07, 0xb9, 0xa7, 0xf5, 0x45, 0xd7, 0xba, 0x29, 0x89, 0x37, - 0xe5, 0x65, 0x19, 0xb6, 0x8d, 0xde, 0x00, 0xe3, 0xee, 0x7c, 0x76, 0xc6, 0xc9, 0xe9, 0x2a, 0x71, - 0x45, 0x05, 0xb5, 0xa1, 0xfe, 0x4a, 0xa8, 0xa3, 0xf9, 0xa2, 0xd6, 0x38, 0x5f, 0x2b, 0xd0, 0xd0, - 0xf7, 0x78, 0xc8, 0xa2, 0x0b, 0x67, 0xc8, 0x5a, 0xe3, 0x11, 0x34, 0xc4, 0x68, 0xc9, 0x98, 0x45, - 0x09, 0xd2, 0x35, 0x98, 0x7f, 0x2d, 0xad, 0x22, 0x26, 0xcc, 0x88, 0x2c, 0xbd, 0x62, 0x66, 0xba, - 0xb9, 0x67, 0x19, 0xc6, 0x91, 0x02, 0xd0, 0x4b, 0xcf, 0x88, 0xa9, 0x8c, 0x4d, 0xae, 0x2c, 0x97, - 0x72, 0x65, 0xb9, 0xd4, 0x29, 0xb9, 0x2c, 0xf8, 0x6f, 0x07, 0x93, 0xc4, 0x0b, 0xd0, 0xb1, 0x85, - 0x92, 0x0b, 0xdd, 0x5b, 0xf2, 0xba, 0x12, 0x70, 0xcb, 0xe5, 0xb5, 0x33, 0x6d, 0x41, 0x43, 0x70, - 0x25, 0x99, 0xfe, 0xa5, 0x8b, 0x8c, 0x4f, 0x04, 0x1a, 0xcf, 0xc2, 0xe4, 0x77, 0xe8, 0xbd, 0xee, - 0x59, 0x37, 0x60, 0x21, 0xef, 0x5c, 0x0e, 0x7b, 0x17, 0x66, 0x33, 0xeb, 0x24, 0x1a, 0x69, 0xa9, - 0x97, 0x7a, 0x2a, 0x87, 0x8d, 0xf7, 0x0a, 0xfc, 0x6f, 0xe3, 0x1e, 0x72, 0xfc, 0x2b, 0x8f, 0x6d, - 0xca, 0x33, 0xea, 0x3f, 0xe0, 0x99, 0x45, 0xb8, 0x51, 0xd0, 0x91, 0x33, 0xb9, 0xfe, 0x83, 0x94, - 0x2f, 0x94, 0x6e, 0x80, 0xba, 0x85, 0x9c, 0x2e, 0x57, 0xe9, 0x2c, 0xff, 0xa8, 0xf4, 0x3b, 0x17, - 0xe2, 0x52, 0x8e, 0x0d, 0x50, 0x7b, 0xe9, 0xb9, 0xba, 0xf2, 0x1d, 0x4f, 0xd7, 0x55, 0x3d, 0xfb, - 0x10, 0x6a, 0x99, 0xac, 0x74, 0x2a, 0xa1, 0x62, 0x51, 0x5d, 0xbb, 0x08, 0xc8, 0xd2, 0xc7, 0x50, - 0xcf, 0x27, 0xa1, 0x2b, 0xd5, 0x9c, 0x29, 0xb1, 0x75, 0xfd, 0x32, 0x28, 0x3f, 0xa0, 0xfb, 0xe6, - 0x78, 0xd2, 0x24, 0x27, 0x93, 0x26, 0xf9, 0x3c, 0x69, 0x92, 0x6f, 0x93, 0x26, 0xf9, 0xf0, 0xbd, - 0x39, 0xf3, 0x76, 0xad, 0xf2, 0xed, 0x89, 0x92, 0xb1, 0xef, 0x77, 0x06, 0xb8, 0x6f, 0x45, 0xc8, - 0x76, 0x93, 0x8e, 0x37, 0x0e, 0x3b, 0x01, 0xb3, 0xca, 0x23, 0x8f, 0x94, 0xa5, 0xe7, 0xc8, 0x9e, - 0xbe, 0x34, 0x37, 0x7b, 0x8e, 0xb9, 0x79, 0x16, 0xee, 0xd7, 0xc5, 0x87, 0xe9, 0xfe, 0xcf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x87, 0x9f, 0x16, 0xf3, 0x31, 0x07, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// WithdrawClient is the client API for Withdraw service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type WithdrawClient interface { - // Get returns cheque if it was signed by inner ring nodes - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) - // Put ask inner ring nodes to sign a cheque for withdraw invoke - Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) - // List shows all user's checks - List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) - // Delete allows user to remove unused cheque - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) -} - -type withdrawClient struct { - cc *grpc.ClientConn -} - -func NewWithdrawClient(cc *grpc.ClientConn) WithdrawClient { - return &withdrawClient{cc} -} - -func (c *withdrawClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - out := new(GetResponse) - err := c.cc.Invoke(ctx, "/accounting.Withdraw/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *withdrawClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) { - out := new(PutResponse) - err := c.cc.Invoke(ctx, "/accounting.Withdraw/Put", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *withdrawClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { - out := new(ListResponse) - err := c.cc.Invoke(ctx, "/accounting.Withdraw/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *withdrawClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/accounting.Withdraw/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// WithdrawServer is the server API for Withdraw service. -type WithdrawServer interface { - // Get returns cheque if it was signed by inner ring nodes - Get(context.Context, *GetRequest) (*GetResponse, error) - // Put ask inner ring nodes to sign a cheque for withdraw invoke - Put(context.Context, *PutRequest) (*PutResponse, error) - // List shows all user's checks - List(context.Context, *ListRequest) (*ListResponse, error) - // Delete allows user to remove unused cheque - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) -} - -// UnimplementedWithdrawServer can be embedded to have forward compatible implementations. -type UnimplementedWithdrawServer struct { -} - -func (*UnimplementedWithdrawServer) Get(ctx context.Context, req *GetRequest) (*GetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedWithdrawServer) Put(ctx context.Context, req *PutRequest) (*PutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") -} -func (*UnimplementedWithdrawServer) List(ctx context.Context, req *ListRequest) (*ListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedWithdrawServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} - -func RegisterWithdrawServer(s *grpc.Server, srv WithdrawServer) { - s.RegisterService(&_Withdraw_serviceDesc, srv) -} - -func _Withdraw_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WithdrawServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounting.Withdraw/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WithdrawServer).Get(ctx, req.(*GetRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Withdraw_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WithdrawServer).Put(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounting.Withdraw/Put", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WithdrawServer).Put(ctx, req.(*PutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Withdraw_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WithdrawServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounting.Withdraw/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WithdrawServer).List(ctx, req.(*ListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Withdraw_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WithdrawServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/accounting.Withdraw/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WithdrawServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Withdraw_serviceDesc = grpc.ServiceDesc{ - ServiceName: "accounting.Withdraw", - HandlerType: (*WithdrawServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _Withdraw_Get_Handler, - }, - { - MethodName: "Put", - Handler: _Withdraw_Put_Handler, - }, - { - MethodName: "List", - Handler: _Withdraw_List_Handler, - }, - { - MethodName: "Delete", - Handler: _Withdraw_Delete_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "accounting/withdraw.proto", -} - -func (m *Item) 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 *Item) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Item) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintWithdraw(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0x2a - } - if m.Height != 0 { - i = encodeVarintWithdraw(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x20 - } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetRequest) 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 *GetRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetResponse) 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 *GetResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Withdraw != nil { - { - size, err := m.Withdraw.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PutRequest) 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 *PutRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.MessageID.Size() - i -= size - if _, err := m.MessageID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.Height != 0 { - i = encodeVarintWithdraw(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x18 - } - if m.Amount != nil { - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *PutResponse) 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 *PutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ListRequest) 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 *ListRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ListResponse) 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 *ListResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Items) > 0 { - for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DeleteRequest) 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 *DeleteRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.MessageID.Size() - i -= size - if _, err := m.MessageID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintWithdraw(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DeleteResponse) 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 *DeleteResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func encodeVarintWithdraw(dAtA []byte, offset int, v uint64) int { - offset -= sovWithdraw(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Item) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovWithdraw(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovWithdraw(uint64(m.Height)) - } - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovWithdraw(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Withdraw != nil { - l = m.Withdraw.Size() - n += 1 + l + sovWithdraw(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PutRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovWithdraw(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovWithdraw(uint64(m.Height)) - } - l = m.MessageID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ListRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ListResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Items) > 0 { - for _, e := range m.Items { - l = e.Size() - n += 1 + l + sovWithdraw(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.MessageID.Size() - n += 1 + l + sovWithdraw(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovWithdraw(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovWithdraw(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozWithdraw(x uint64) (n int) { - return sovWithdraw(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Item) 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 ErrIntOverflowWithdraw - } - 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: Item: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Item: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Amount == nil { - m.Amount = &decimal.Decimal{} - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRequest) 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 ErrIntOverflowWithdraw - } - 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: GetRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetResponse) 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 ErrIntOverflowWithdraw - } - 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: GetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Withdraw", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Withdraw == nil { - m.Withdraw = &Item{} - } - if err := m.Withdraw.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutRequest) 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 ErrIntOverflowWithdraw - } - 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: PutRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Amount == nil { - m.Amount = &decimal.Decimal{} - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MessageID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MessageID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutResponse) 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 ErrIntOverflowWithdraw - } - 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: PutResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ListRequest) 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 ErrIntOverflowWithdraw - } - 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: ListRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ListResponse) 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 ErrIntOverflowWithdraw - } - 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: ListResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Items = append(m.Items, &Item{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteRequest) 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 ErrIntOverflowWithdraw - } - 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: DeleteRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MessageID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MessageID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteResponse) 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 ErrIntOverflowWithdraw - } - 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: DeleteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipWithdraw(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthWithdraw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipWithdraw(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, ErrIntOverflowWithdraw - } - 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, ErrIntOverflowWithdraw - } - 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, ErrIntOverflowWithdraw - } - 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, ErrInvalidLengthWithdraw - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupWithdraw - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthWithdraw - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthWithdraw = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowWithdraw = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupWithdraw = fmt.Errorf("proto: unexpected end of group") -) diff --git a/accounting/withdraw.proto b/accounting/withdraw.proto deleted file mode 100644 index 080a100..0000000 --- a/accounting/withdraw.proto +++ /dev/null @@ -1,101 +0,0 @@ -syntax = "proto3"; -package accounting; -option go_package = "github.com/nspcc-dev/neofs-api-go/accounting"; -option csharp_namespace = "NeoFS.API.Accounting"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "decimal/decimal.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Withdraw is a service that provides withdraw assets operations from the NeoFS -service Withdraw { - // Get returns cheque if it was signed by inner ring nodes - rpc Get(GetRequest) returns (GetResponse); - // Put ask inner ring nodes to sign a cheque for withdraw invoke - rpc Put(PutRequest) returns (PutResponse); - // List shows all user's checks - rpc List(ListRequest) returns (ListResponse); - // Delete allows user to remove unused cheque - rpc Delete(DeleteRequest) returns (DeleteResponse); -} - -message Item { - // ID is a cheque identifier - bytes ID = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false]; - // OwnerID is a wallet address - bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // Amount of funds - decimal.Decimal Amount = 3; - // Height is the neo blockchain height until the cheque is valid - uint64 Height = 4; - // Payload contains cheque representation in bytes - bytes Payload = 5; -} - -message GetRequest { - // ID is cheque identifier - bytes ID = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false]; - // OwnerID is a wallet address - bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetResponse { - // Withdraw is cheque with meta information - Item Withdraw = 1; -} - -message PutRequest { - // OwnerID is a wallet address - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // Amount of funds - decimal.Decimal Amount = 2; - // Height is the neo blockchain height until the cheque is valid - uint64 Height = 3; - // MessageID is a nonce for uniq request (UUIDv4) - bytes MessageID = 4 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} -message PutResponse { - // ID is cheque identifier - bytes ID = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false]; -} - -message ListRequest { - // OwnerID is a wallet address - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message ListResponse { - // Items is a set of cheques with meta information - repeated Item Items = 1; -} - -message DeleteRequest { - // ID is cheque identifier - bytes ID = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false]; - // OwnerID is a wallet address - bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // MessageID is a nonce for uniq request (UUIDv4) - bytes MessageID = 3 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// DeleteResponse is empty -message DeleteResponse {} diff --git a/acl/extended/enum.go b/acl/extended/enum.go deleted file mode 100644 index e803476..0000000 --- a/acl/extended/enum.go +++ /dev/null @@ -1,126 +0,0 @@ -package eacl - -const ( - // MatchUnknown is a MatchType value used to mark value as undefined. - // Most of the tools consider MatchUnknown as incalculable. - // Using MatchUnknown in HeaderFilter is unsafe. - MatchUnknown MatchType = iota - - // StringEqual is a MatchType of string equality. - StringEqual - - // StringNotEqual is a MatchType of string inequality. - StringNotEqual -) - -const ( - // ActionUnknown is Action used to mark value as undefined. - // Most of the tools consider ActionUnknown as incalculable. - // Using ActionUnknown in Record is unsafe. - ActionUnknown Action = iota - - // ActionAllow is Action used to mark an applicability of ACL rule. - ActionAllow - - // ActionDeny is Action used to mark an inapplicability of ACL rule. - ActionDeny -) - -const ( - // GroupUnknown is a Group value used to mark value as undefined. - // Most of the tools consider GroupUnknown as incalculable. - // Using GroupUnknown in Target is unsafe. - GroupUnknown Group = iota - - // GroupUser is a Group value for User access group. - GroupUser - - // GroupSystem is a Group value for System access group. - GroupSystem - - // GroupOthers is a Group value for Others access group. - GroupOthers -) - -const ( - // HdrTypeUnknown is a HeaderType value used to mark value as undefined. - // Most of the tools consider HdrTypeUnknown as incalculable. - // Using HdrTypeUnknown in HeaderFilter is unsafe. - HdrTypeUnknown HeaderType = iota - - // HdrTypeRequest is a HeaderType for request header. - HdrTypeRequest - - // HdrTypeObjSys is a HeaderType for system headers of object. - HdrTypeObjSys - - // HdrTypeObjUsr is a HeaderType for user headers of object. - HdrTypeObjUsr -) - -const ( - // OpTypeUnknown is a OperationType value used to mark value as undefined. - // Most of the tools consider OpTypeUnknown as incalculable. - // Using OpTypeUnknown in Record is unsafe. - OpTypeUnknown OperationType = iota - - // OpTypeGet is an OperationType for object.Get RPC - OpTypeGet - - // OpTypePut is an OperationType for object.Put RPC - OpTypePut - - // OpTypeHead is an OperationType for object.Head RPC - OpTypeHead - - // OpTypeSearch is an OperationType for object.Search RPC - OpTypeSearch - - // OpTypeDelete is an OperationType for object.Delete RPC - OpTypeDelete - - // OpTypeRange is an OperationType for object.GetRange RPC - OpTypeRange - - // OpTypeRangeHash is an OperationType for object.GetRangeHash RPC - OpTypeRangeHash -) - -const ( - // HdrObjSysNameID is a name of ID field in system header of object. - HdrObjSysNameID = "ID" - - // HdrObjSysNameCID is a name of CID field in system header of object. - HdrObjSysNameCID = "CID" - - // HdrObjSysNameOwnerID is a name of OwnerID field in system header of object. - HdrObjSysNameOwnerID = "OWNER_ID" - - // HdrObjSysNameVersion is a name of Version field in system header of object. - HdrObjSysNameVersion = "VERSION" - - // HdrObjSysNamePayloadLength is a name of PayloadLength field in system header of object. - HdrObjSysNamePayloadLength = "PAYLOAD_LENGTH" - - // HdrObjSysNameCreatedUnix is a name of CreatedAt.UnitTime field in system header of object. - HdrObjSysNameCreatedUnix = "CREATED_UNIX" - - // HdrObjSysNameCreatedEpoch is a name of CreatedAt.Epoch field in system header of object. - HdrObjSysNameCreatedEpoch = "CREATED_EPOCH" - - // HdrObjSysLinkPrev is a name of previous link header in extended headers of object. - HdrObjSysLinkPrev = "LINK_PREV" - - // HdrObjSysLinkNext is a name of next link header in extended headers of object. - HdrObjSysLinkNext = "LINK_NEXT" - - // HdrObjSysLinkChild is a name of child link header in extended headers of object. - HdrObjSysLinkChild = "LINK_CHILD" - - // HdrObjSysLinkPar is a name of parent link header in extended headers of object. - HdrObjSysLinkPar = "LINK_PAR" - - // HdrObjSysLinkSG is a name of storage group link header in extended headers of object. - HdrObjSysLinkSG = "LINK_SG" -) - diff --git a/acl/extended/marshal.go b/acl/extended/marshal.go deleted file mode 100644 index d1fac07..0000000 --- a/acl/extended/marshal.go +++ /dev/null @@ -1,333 +0,0 @@ -package eacl - -import ( - "encoding/binary" - - "github.com/pkg/errors" -) - -const ( - sliceLenSize = 2 // uint16 for len() - actionSize = 4 // uint32 - opTypeSize = 4 // uint32 - hdrTypeSize = 4 // uint32 - matchTypeSize = 4 // uint32 - targetSize = 4 // uint32 -) - -// MarshalTable encodes Table into a -// binary form and returns the result. -// -// If table is nil, empty slice is returned. -func MarshalTable(table Table) []byte { - if table == nil { - return make([]byte, 0) - } - - // allocate buffer - buf := make([]byte, tableBinSize(table)) - - records := table.Records() - - // write record number - binary.BigEndian.PutUint16(buf, uint16(len(records))) - off := sliceLenSize - - // write all records - for _, record := range records { - // write action - binary.BigEndian.PutUint32(buf[off:], uint32(record.Action())) - off += actionSize - - // write operation type - binary.BigEndian.PutUint32(buf[off:], uint32(record.OperationType())) - off += actionSize - - filters := record.HeaderFilters() - - // write filter number - binary.BigEndian.PutUint16(buf[off:], uint16(len(filters))) - off += sliceLenSize - - // write all filters - for _, filter := range filters { - // write header type - binary.BigEndian.PutUint32(buf[off:], uint32(filter.HeaderType())) - off += hdrTypeSize - - // write match type - binary.BigEndian.PutUint32(buf[off:], uint32(filter.MatchType())) - off += matchTypeSize - - // write header name size - name := []byte(filter.Name()) - binary.BigEndian.PutUint16(buf[off:], uint16(len(name))) - off += sliceLenSize - - // write header name bytes - off += copy(buf[off:], name) - - // write header value size - val := []byte(filter.Value()) - binary.BigEndian.PutUint16(buf[off:], uint16(len(val))) - off += sliceLenSize - - // write header value bytes - off += copy(buf[off:], val) - } - - targets := record.TargetList() - - // write target number - binary.BigEndian.PutUint16(buf[off:], uint16(len(targets))) - off += sliceLenSize - - // write all targets - for _, target := range targets { - // write target group - binary.BigEndian.PutUint32(buf[off:], uint32(target.Group())) - off += targetSize - - keys := target.KeyList() - - // write key number - binary.BigEndian.PutUint16(buf[off:], uint16(len(keys))) - off += sliceLenSize - - // write keys - for i := range keys { - // write key size - binary.BigEndian.PutUint16(buf[off:], uint16(len(keys[i]))) - off += sliceLenSize - - // write key bytes - off += copy(buf[off:], keys[i]) - } - } - } - - return buf -} - -// returns the size of Table in a binary format. -func tableBinSize(table Table) (sz int) { - sz = sliceLenSize // number of records - - records := table.Records() - ln := len(records) - - sz += ln * actionSize // action type of each record - sz += ln * opTypeSize // operation type of each record - - for _, record := range records { - sz += sliceLenSize // number of filters - - filters := record.HeaderFilters() - ln := len(filters) - - sz += ln * hdrTypeSize // header type of each filter - sz += ln * matchTypeSize // match type of each filter - - for _, filter := range filters { - sz += sliceLenSize // header name size - sz += len(filter.Name()) // header name bytes - - sz += sliceLenSize // header value size - sz += len(filter.Value()) // header value bytes - } - - sz += sliceLenSize // number of targets - - targets := record.TargetList() - ln = len(targets) - - sz += ln * targetSize // target group of each target - - for _, target := range targets { - sz += sliceLenSize // number of keys - - for _, key := range target.KeyList() { - sz += sliceLenSize // key size - sz += len(key) // key bytes - } - } - } - - return -} - -// UnmarshalTable unmarshals Table from -// a binary representation. -// -// If data is empty, table w/o records is returned. -func UnmarshalTable(data []byte) (Table, error) { - table := WrapTable(nil) - - if len(data) == 0 { - return table, nil - } - - // decode record number - if len(data) < sliceLenSize { - return nil, errors.New("could not decode record number") - } - - recordNum := binary.BigEndian.Uint16(data) - records := make([]Record, 0, recordNum) - - off := sliceLenSize - - // decode all records one by one - for i := uint16(0); i < recordNum; i++ { - record := WrapRecord(nil) - - // decode action - if len(data[off:]) < actionSize { - return nil, errors.Errorf("could not decode action of record #%d", i) - } - - record.SetAction(Action(binary.BigEndian.Uint32(data[off:]))) - off += actionSize - - // decode operation type - if len(data[off:]) < opTypeSize { - return nil, errors.Errorf("could not decode operation type of record #%d", i) - } - - record.SetOperationType(OperationType(binary.BigEndian.Uint32(data[off:]))) - off += opTypeSize - - // decode filter number - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode filter number of record #%d", i) - } - - filterNum := binary.BigEndian.Uint16(data[off:]) - off += sliceLenSize - filters := make([]HeaderFilter, 0, filterNum) - - // decode filters one by one - for j := uint16(0); j < filterNum; j++ { - filter := WrapFilterInfo(nil) - - // decode header type - if len(data[off:]) < hdrTypeSize { - return nil, errors.Errorf("could not decode header type of filter #%d of record #%d", j, i) - } - - filter.SetHeaderType(HeaderType(binary.BigEndian.Uint32(data[off:])) ) - off += hdrTypeSize - - // decode match type - if len(data[off:]) < matchTypeSize { - return nil, errors.Errorf("could not decode match type of filter #%d of record #%d", j, i) - } - - filter.SetMatchType(MatchType(binary.BigEndian.Uint32(data[off:])) ) - off += matchTypeSize - - // decode header name size - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode header name size of filter #%d of record #%d", j, i) - } - - hdrNameSize := int(binary.BigEndian.Uint16(data[off:])) - off += sliceLenSize - - // decode header name - if len(data[off:]) < hdrNameSize { - return nil, errors.Errorf("could not decode header name of filter #%d of record #%d", j, i) - } - - filter.SetName(string(data[off : off+hdrNameSize])) - - off += hdrNameSize - - // decode header value size - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode header value size of filter #%d of record #%d", j, i) - } - - hdrValSize := int(binary.BigEndian.Uint16(data[off:])) - off += sliceLenSize - - // decode header value - if len(data[off:]) < hdrValSize { - return nil, errors.Errorf("could not decode header value of filter #%d of record #%d", j, i) - } - - filter.SetValue(string(data[off : off+hdrValSize])) - - off += hdrValSize - - filters = append(filters, filter) - } - - record.SetHeaderFilters(filters) - - // decode target number - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode target number of record #%d", i) - } - - targetNum := int(binary.BigEndian.Uint16(data[off:])) - off += sliceLenSize - - targets := make([]Target, 0, targetNum) - - // decode targets one by one - for j := 0; j < targetNum; j++ { - target := WrapTarget(nil) - - // decode target group - if len(data[off:]) < targetSize { - return nil, errors.Errorf("could not decode target group of target #%d of record #%d", j, i) - } - - target.SetGroup( Group(binary.BigEndian.Uint32(data[off:])), ) - off += targetSize - - // decode key number - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode key number of target #%d of record #%d", j, i) - } - - keyNum := int(binary.BigEndian.Uint16(data[off:])) - off += sliceLenSize - keys := make([][]byte, 0, keyNum) - - for k := 0; k < keyNum; k++ { - // decode key size - if len(data[off:]) < sliceLenSize { - return nil, errors.Errorf("could not decode size of key #%d target #%d of record #%d", k, j, i) - } - - keySz := int(binary.BigEndian.Uint16(data[off:])) - off += sliceLenSize - - // decode key - if len(data[off:]) < keySz { - return nil, errors.Errorf("could not decode key #%d target #%d of record #%d", k, j, i) - } - - key := make([]byte, keySz) - - off += copy(key, data[off:off+keySz]) - - keys = append(keys, key) - } - - target.SetKeyList(keys) - - targets = append(targets, target) - } - - record.SetTargetList(targets) - - records = append(records, record) - } - - table.SetRecords(records) - - return table, nil -} diff --git a/acl/extended/types.go b/acl/extended/types.go deleted file mode 100644 index 6b1b74b..0000000 --- a/acl/extended/types.go +++ /dev/null @@ -1,73 +0,0 @@ -package eacl - -// OperationType is an enumeration of operation types for extended ACL. -type OperationType uint32 - -// HeaderType is an enumeration of header types for extended ACL. -type HeaderType uint32 - -// MatchType is an enumeration of match types for extended ACL. -type MatchType uint32 - -// Action is an enumeration of extended ACL actions. -type Action uint32 - -// Group is an enumeration of access groups. -type Group uint32 - -// Header is an interface of string key-value pair, -type Header interface { - // Must return string identifier of header. - Name() string - - // Must return string value of header. - Value() string -} - -// TypedHeader is an interface of Header and HeaderType pair. -type TypedHeader interface { - Header - - // Must return type of filtered header. - HeaderType() HeaderType -} - -// HeaderFilter is an interface of grouped information about filtered header. -type HeaderFilter interface { - // Must return match type of filter. - MatchType() MatchType - - TypedHeader -} - -// Target is an interface of grouped information about extended ACL rule target. -type Target interface { - // Must return ACL target type. - Group() Group - - // Must return public key list of ACL targets. - KeyList() [][]byte -} - -// Record is an interface of record of extended ACL rule table. -type Record interface { - // Must return operation type of extended ACL rule. - OperationType() OperationType - - // Must return list of header filters of extended ACL rule. - HeaderFilters() []HeaderFilter - - // Must return target list of extended ACL rule. - TargetList() []Target - - // Must return action of extended ACL rule. - Action() Action -} - -// Table is an interface of extended ACL table. -type Table interface { - // Must return list of extended ACL rules. - Records() []Record -} - - diff --git a/acl/extended/wrappers.go b/acl/extended/wrappers.go deleted file mode 100644 index 2c8ff2e..0000000 --- a/acl/extended/wrappers.go +++ /dev/null @@ -1,528 +0,0 @@ -package eacl - -import ( - "github.com/nspcc-dev/neofs-api-go/acl" -) - -// FilterWrapper is a wrapper over acl.EACLRecord_FilterInfo pointer. -type FilterWrapper struct { - filter *acl.EACLRecord_FilterInfo -} - -// TargetWrapper is a wrapper over acl.EACLRecord_TargetInfo pointer. -type TargetWrapper struct { - target *acl.EACLRecord_TargetInfo -} - -// RecordWrapper is a wrapper over acl.EACLRecord pointer. -type RecordWrapper struct { - record *acl.EACLRecord -} - -// TableWrapper is a wrapper over acl.EACLTable pointer. -type TableWrapper struct { - table *acl.EACLTable -} - -// WrapFilterInfo wraps EACLRecord_FilterInfo pointer. -// -// If argument is nil, new EACLRecord_FilterInfo is initialized. -func WrapFilterInfo(v *acl.EACLRecord_FilterInfo) FilterWrapper { - if v == nil { - v = new(acl.EACLRecord_FilterInfo) - } - - return FilterWrapper{ - filter: v, - } -} - -// WrapTarget wraps EACLRecord_TargetInfo pointer. -// -// If argument is nil, new EACLRecord_TargetInfo is initialized. -func WrapTarget(v *acl.EACLRecord_TargetInfo) TargetWrapper { - if v == nil { - v = new(acl.EACLRecord_TargetInfo) - } - - return TargetWrapper{ - target: v, - } -} - -// WrapRecord wraps EACLRecord pointer. -// -// If argument is nil, new EACLRecord is initialized. -func WrapRecord(v *acl.EACLRecord) RecordWrapper { - if v == nil { - v = new(acl.EACLRecord) - } - - return RecordWrapper{ - record: v, - } -} - -// WrapTable wraps EACLTable pointer. -// -// If argument is nil, new EACLTable is initialized. -func WrapTable(v *acl.EACLTable) TableWrapper { - if v == nil { - v = new(acl.EACLTable) - } - - return TableWrapper{ - table: v, - } -} - -// MatchType returns the match type of the filter. -// -// If filter is not initialized, 0 returns. -// -// Returns 0 if MatchType is not one of: -// - EACLRecord_FilterInfo_StringEqual; -// - EACLRecord_FilterInfo_StringNotEqual. -func (s FilterWrapper) MatchType() (res MatchType) { - if s.filter != nil { - switch s.filter.GetMatchType() { - case acl.EACLRecord_FilterInfo_StringEqual: - res = StringEqual - case acl.EACLRecord_FilterInfo_StringNotEqual: - res = StringNotEqual - } - } - - return -} - -// SetMatchType sets the match type of the filter. -// -// If filter is not initialized, nothing changes. -// -// MatchType is set to EACLRecord_FilterInfo_MatchUnknown if argument is not one of: -// - StringEqual; -// - StringNotEqual. -func (s FilterWrapper) SetMatchType(v MatchType) { - if s.filter != nil { - switch v { - case StringEqual: - s.filter.SetMatchType(acl.EACLRecord_FilterInfo_StringEqual) - case StringNotEqual: - s.filter.SetMatchType(acl.EACLRecord_FilterInfo_StringNotEqual) - default: - s.filter.SetMatchType(acl.EACLRecord_FilterInfo_MatchUnknown) - } - } -} - -// Name returns the name of filtering header. -// -// If filter is not initialized, empty string returns. -func (s FilterWrapper) Name() string { - if s.filter == nil { - return "" - } - - return s.filter.GetHeaderName() -} - -// SetName sets the name of the filtering header. -// -// If filter is not initialized, nothing changes. -func (s FilterWrapper) SetName(v string) { - if s.filter != nil { - s.filter.SetHeaderName(v) - } -} - -// Value returns the value of filtering header. -// -// If filter is not initialized, empty string returns. -func (s FilterWrapper) Value() string { - if s.filter == nil { - return "" - } - - return s.filter.GetHeaderVal() -} - -// SetValue sets the value of filtering header. -// -// If filter is not initialized, nothing changes. -func (s FilterWrapper) SetValue(v string) { - if s.filter != nil { - s.filter.SetHeaderVal(v) - } -} - -// HeaderType returns the header type of the filter. -// -// If filter is not initialized, HdrTypeUnknown returns. -// -// Returns HdrTypeUnknown if Header is not one of: -// - EACLRecord_FilterInfo_Request; -// - EACLRecord_FilterInfo_ObjectSystem; -// - EACLRecord_FilterInfo_ObjectUser. -func (s FilterWrapper) HeaderType() (res HeaderType) { - res = HdrTypeUnknown - - if s.filter != nil { - switch s.filter.GetHeader() { - case acl.EACLRecord_FilterInfo_Request: - res = HdrTypeRequest - case acl.EACLRecord_FilterInfo_ObjectSystem: - res = HdrTypeObjSys - case acl.EACLRecord_FilterInfo_ObjectUser: - res = HdrTypeObjUsr - } - } - - return -} - -// SetHeaderType sets the header type of the filter. -// -// If filter is not initialized, nothing changes. -// -// Header is set to EACLRecord_FilterInfo_HeaderUnknown if argument is not one of: -// - HdrTypeRequest; -// - HdrTypeObjSys; -// - HdrTypeObjUsr. -func (s FilterWrapper) SetHeaderType(t HeaderType) { - if s.filter != nil { - switch t { - case HdrTypeRequest: - s.filter.SetHeader(acl.EACLRecord_FilterInfo_Request) - case HdrTypeObjSys: - s.filter.SetHeader(acl.EACLRecord_FilterInfo_ObjectSystem) - case HdrTypeObjUsr: - s.filter.SetHeader(acl.EACLRecord_FilterInfo_ObjectUser) - default: - s.filter.SetHeader(acl.EACLRecord_FilterInfo_HeaderUnknown) - } - } -} - -// Group returns the access group of the target. -// -// If target is not initialized, GroupUnknown returns. -// -// Returns GroupUnknown if Target is not one of: -// - Target_User; -// - GroupSystem; -// - GroupOthers. -func (s TargetWrapper) Group() (res Group) { - res = GroupUnknown - - if s.target != nil { - switch s.target.GetTarget() { - case acl.Target_User: - res = GroupUser - case acl.Target_System: - res = GroupSystem - case acl.Target_Others: - res = GroupOthers - } - } - - return -} - -// SetGroup sets the access group of the target. -// -// If target is not initialized, nothing changes. -// -// Target is set to Target_Unknown if argument is not one of: -// - GroupUser; -// - GroupSystem; -// - GroupOthers. -func (s TargetWrapper) SetGroup(g Group) { - if s.target != nil { - switch g { - case GroupUser: - s.target.SetTarget(acl.Target_User) - case GroupSystem: - s.target.SetTarget(acl.Target_System) - case GroupOthers: - s.target.SetTarget(acl.Target_Others) - default: - s.target.SetTarget(acl.Target_Unknown) - } - } -} - -// KeyList returns the key list of the target. -// -// If target is not initialized, nil returns. -func (s TargetWrapper) KeyList() [][]byte { - if s.target == nil { - return nil - } - - return s.target.GetKeyList() -} - -// SetKeyList sets the key list of the target. -// -// If target is not initialized, nothing changes. -func (s TargetWrapper) SetKeyList(v [][]byte) { - if s.target != nil { - s.target.SetKeyList(v) - } -} - -// OperationType returns the operation type of the record. -// -// If record is not initialized, OpTypeUnknown returns. -// -// Returns OpTypeUnknown if Operation is not one of: -// - EACLRecord_HEAD; -// - EACLRecord_PUT; -// - EACLRecord_SEARCH; -// - EACLRecord_GET; -// - EACLRecord_GETRANGE; -// - EACLRecord_GETRANGEHASH; -// - EACLRecord_DELETE. -func (s RecordWrapper) OperationType() (res OperationType) { - res = OpTypeUnknown - - if s.record != nil { - switch s.record.GetOperation() { - case acl.EACLRecord_HEAD: - res = OpTypeHead - case acl.EACLRecord_PUT: - res = OpTypePut - case acl.EACLRecord_SEARCH: - res = OpTypeSearch - case acl.EACLRecord_GET: - res = OpTypeGet - case acl.EACLRecord_GETRANGE: - res = OpTypeRange - case acl.EACLRecord_GETRANGEHASH: - res = OpTypeRangeHash - case acl.EACLRecord_DELETE: - res = OpTypeDelete - } - } - - return -} - -// SetOperationType sets the operation type of the record. -// -// If record is not initialized, nothing changes. -// -// Operation is set to EACLRecord_OPERATION_UNKNOWN if argument is not one of: -// - OpTypeHead; -// - OpTypePut; -// - OpTypeSearch; -// - OpTypeGet; -// - OpTypeRange; -// - OpTypeRangeHash; -// - OpTypeDelete. -func (s RecordWrapper) SetOperationType(v OperationType) { - if s.record != nil { - switch v { - case OpTypeHead: - s.record.SetOperation(acl.EACLRecord_HEAD) - case OpTypePut: - s.record.SetOperation(acl.EACLRecord_PUT) - case OpTypeSearch: - s.record.SetOperation(acl.EACLRecord_SEARCH) - case OpTypeGet: - s.record.SetOperation(acl.EACLRecord_GET) - case OpTypeRange: - s.record.SetOperation(acl.EACLRecord_GETRANGE) - case OpTypeRangeHash: - s.record.SetOperation(acl.EACLRecord_GETRANGEHASH) - case OpTypeDelete: - s.record.SetOperation(acl.EACLRecord_DELETE) - default: - s.record.SetOperation(acl.EACLRecord_OPERATION_UNKNOWN) - } - } -} - -// Action returns the action of the record. -// -// If record is not initialized, ActionUnknown returns. -// -// Returns ActionUnknown if Action is not one of: -// - EACLRecord_Deny; -// - EACLRecord_Allow. -func (s RecordWrapper) Action() (res Action) { - res = ActionUnknown - - if s.record != nil { - switch s.record.GetAction() { - case acl.EACLRecord_Deny: - res = ActionDeny - case acl.EACLRecord_Allow: - res = ActionAllow - } - } - - return -} - -// SetAction sets the action of the record. -// -// If record is not initialized, nothing changes. -// -// Action is set to EACLRecord_ActionUnknown if argument is not one of: -// - ActionDeny; -// - ActionAllow. -func (s RecordWrapper) SetAction(v Action) { - if s.record != nil { - switch v { - case ActionDeny: - s.record.SetAction(acl.EACLRecord_Deny) - case ActionAllow: - s.record.SetAction(acl.EACLRecord_Allow) - default: - s.record.SetAction(acl.EACLRecord_ActionUnknown) - } - } -} - -// HeaderFilters returns the header filter list of the record. -// -// If record is not initialized, nil returns. -func (s RecordWrapper) HeaderFilters() []HeaderFilter { - if s.record == nil { - return nil - } - - filters := s.record.GetFilters() - - res := make([]HeaderFilter, 0, len(filters)) - - for i := range filters { - res = append(res, WrapFilterInfo(filters[i])) - } - - return res -} - -// SetHeaderFilters sets the header filter list of the record. -// -// Ignores nil elements of argument. -// If record is not initialized, nothing changes. -func (s RecordWrapper) SetHeaderFilters(v []HeaderFilter) { - if s.record == nil { - return - } - - filters := make([]*acl.EACLRecord_FilterInfo, 0, len(v)) - - for i := range v { - if v[i] == nil { - continue - } - - w := WrapFilterInfo(nil) - w.SetMatchType(v[i].MatchType()) - w.SetHeaderType(v[i].HeaderType()) - w.SetName(v[i].Name()) - w.SetValue(v[i].Value()) - - filters = append(filters, w.filter) - } - - s.record.SetFilters(filters) -} - -// TargetList returns the target list of the record. -// -// If record is not initialized, nil returns. -func (s RecordWrapper) TargetList() []Target { - if s.record == nil { - return nil - } - - targets := s.record.GetTargets() - - res := make([]Target, 0, len(targets)) - - for i := range targets { - res = append(res, WrapTarget(targets[i])) - } - - return res -} - -// SetTargetList sets the target list of the record. -// -// Ignores nil elements of argument. -// If record is not initialized, nothing changes. -func (s RecordWrapper) SetTargetList(v []Target) { - if s.record == nil { - return - } - - targets := make([]*acl.EACLRecord_TargetInfo, 0, len(v)) - - for i := range v { - if v[i] == nil { - continue - } - - w := WrapTarget(nil) - w.SetGroup(v[i].Group()) - w.SetKeyList(v[i].KeyList()) - - targets = append(targets, w.target) - } - - s.record.SetTargets(targets) -} - -// Records returns the record list of the table. -// -// If table is not initialized, nil returns. -func (s TableWrapper) Records() []Record { - if s.table == nil { - return nil - } - - records := s.table.GetRecords() - - res := make([]Record, 0, len(records)) - - for i := range records { - res = append(res, WrapRecord(records[i])) - } - - return res -} - -// SetRecords sets the record list of the table. -// -// Ignores nil elements of argument. -// If table is not initialized, nothing changes. -func (s TableWrapper) SetRecords(v []Record) { - if s.table == nil { - return - } - - records := make([]*acl.EACLRecord, 0, len(v)) - - for i := range v { - if v[i] == nil { - continue - } - - w := WrapRecord(nil) - w.SetOperationType(v[i].OperationType()) - w.SetAction(v[i].Action()) - w.SetHeaderFilters(v[i].HeaderFilters()) - w.SetTargetList(v[i].TargetList()) - - records = append(records, w.record) - } - - s.table.SetRecords(records) -} - - diff --git a/acl/extended/wrappers_test.go b/acl/extended/wrappers_test.go deleted file mode 100644 index b139e59..0000000 --- a/acl/extended/wrappers_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package eacl - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestEACLFilterWrapper(t *testing.T) { - s := WrapFilterInfo(nil) - - mt := StringEqual - s.SetMatchType(mt) - require.Equal(t, mt, s.MatchType()) - - ht := HdrTypeObjUsr - s.SetHeaderType(ht) - require.Equal(t, ht, s.HeaderType()) - - n := "name" - s.SetName(n) - require.Equal(t, n, s.Name()) - - v := "value" - s.SetValue(v) - require.Equal(t, v, s.Value()) -} - -func TestEACLTargetWrapper(t *testing.T) { - s := WrapTarget(nil) - - group := Group(3) - s.SetGroup(group) - require.Equal(t, group, s.Group()) - - keys := [][]byte{ - {1, 2, 3}, - {4, 5, 6}, - } - s.SetKeyList(keys) - require.Equal(t, keys, s.KeyList()) -} - -func TestEACLRecordWrapper(t *testing.T) { - s := WrapRecord(nil) - - action := ActionAllow - s.SetAction(action) - require.Equal(t, action, s.Action()) - - opType := OperationType(5) - s.SetOperationType(opType) - require.Equal(t, opType, s.OperationType()) - - f1Name := "name1" - f1 := WrapFilterInfo(nil) - f1.SetName(f1Name) - - f2Name := "name2" - f2 := WrapFilterInfo(nil) - f2.SetName(f2Name) - - s.SetHeaderFilters([]HeaderFilter{f1, f2}) - - filters := s.HeaderFilters() - require.Len(t, filters, 2) - require.Equal(t, f1Name, filters[0].Name()) - require.Equal(t, f2Name, filters[1].Name()) - - group1 := Group(1) - t1 := WrapTarget(nil) - t1.SetGroup(group1) - - group2 := Group(2) - t2 := WrapTarget(nil) - t2.SetGroup(group2) - - s.SetTargetList([]Target{t1, t2}) - - targets := s.TargetList() - require.Len(t, targets, 2) - require.Equal(t, group1, targets[0].Group()) - require.Equal(t, group2, targets[1].Group()) -} - -func TestEACLTableWrapper(t *testing.T) { - s := WrapTable(nil) - - action1 := Action(1) - r1 := WrapRecord(nil) - r1.SetAction(action1) - - action2 := Action(2) - r2 := WrapRecord(nil) - r2.SetAction(action2) - - s.SetRecords([]Record{r1, r2}) - - records := s.Records() - require.Len(t, records, 2) - require.Equal(t, action1, records[0].Action()) - require.Equal(t, action2, records[1].Action()) - - s2, err := UnmarshalTable(MarshalTable(s)) - require.NoError(t, err) - - records1 := s.Records() - records2 := s2.Records() - require.Len(t, records1, len(records2)) - - for i := range records1 { - require.Equal(t, records1[i].Action(), records2[i].Action()) - require.Equal(t, records1[i].OperationType(), records2[i].OperationType()) - - targets1 := records1[i].TargetList() - targets2 := records2[i].TargetList() - require.Len(t, targets1, len(targets2)) - - for j := range targets1 { - require.Equal(t, targets1[j].Group(), targets2[j].Group()) - require.Equal(t, targets1[j].KeyList(), targets2[j].KeyList()) - } - - filters1 := records1[i].HeaderFilters() - filters2 := records2[i].HeaderFilters() - require.Len(t, filters1, len(filters2)) - - for j := range filters1 { - require.Equal(t, filters1[j].MatchType(), filters2[j].MatchType()) - require.Equal(t, filters1[j].HeaderType(), filters2[j].HeaderType()) - require.Equal(t, filters1[j].Name(), filters2[j].Name()) - require.Equal(t, filters1[j].Value(), filters2[j].Value()) - require.Equal(t, filters1[j].Value(), filters2[j].Value()) - } - } -} diff --git a/acl/types.go b/acl/types.go deleted file mode 100644 index 4aaf8fb..0000000 --- a/acl/types.go +++ /dev/null @@ -1,57 +0,0 @@ -package acl - - -// SetMatchType is MatchType field setter. -func (m *EACLRecord_FilterInfo) SetMatchType(v EACLRecord_FilterInfo_MatchType) { - m.MatchType = v -} - -// SetHeader is a Header field setter. -func (m *EACLRecord_FilterInfo) SetHeader(v EACLRecord_FilterInfo_Header) { - m.Header = v -} - -// SetHeaderName is a HeaderName field setter. -func (m *EACLRecord_FilterInfo) SetHeaderName(v string) { - m.HeaderName = v -} - -// SetHeaderVal is a HeaderVal field setter. -func (m *EACLRecord_FilterInfo) SetHeaderVal(v string) { - m.HeaderVal = v -} - -// SetTarget is a Target field setter. -func (m *EACLRecord_TargetInfo) SetTarget(v Target) { - m.Target = v -} - -// SetKeyList is a KeyList field setter. -func (m *EACLRecord_TargetInfo) SetKeyList(v [][]byte) { - m.KeyList = v -} - -// SetOperation is an Operation field setter. -func (m *EACLRecord) SetOperation(v EACLRecord_Operation) { - m.Operation = v -} - -// SetAction is an Action field setter. -func (m *EACLRecord) SetAction(v EACLRecord_Action) { - m.Action = v -} - -// SetFilters is a Filters field setter. -func (m *EACLRecord) SetFilters(v []*EACLRecord_FilterInfo) { - m.Filters = v -} - -// SetTargets is a Targets field setter. -func (m *EACLRecord) SetTargets(v []*EACLRecord_TargetInfo) { - m.Targets = v -} - -// SetRecords is a Records field setter. -func (m *EACLTable) SetRecords(v []*EACLRecord) { - m.Records = v -} diff --git a/acl/types.pb.go b/acl/types.pb.go deleted file mode 100644 index 24ecf28..0000000 --- a/acl/types.pb.go +++ /dev/null @@ -1,1408 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: acl/types.proto - -package acl - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Target of the access control rule in access control list. -type Target int32 - -const ( - // Unknown target, default value. - Target_Unknown Target = 0 - // User target rule is applied if sender is the owner of the container. - Target_User Target = 1 - // System target rule is applied if sender is the storage node within the - // container or inner ring node. - Target_System Target = 2 - // Others target rule is applied if sender is not user or system target. - Target_Others Target = 3 - // PubKey target rule is applied if sender has public key provided in - // extended ACL. - Target_PubKey Target = 4 -) - -var Target_name = map[int32]string{ - 0: "Unknown", - 1: "User", - 2: "System", - 3: "Others", - 4: "PubKey", -} - -var Target_value = map[string]int32{ - "Unknown": 0, - "User": 1, - "System": 2, - "Others": 3, - "PubKey": 4, -} - -func (x Target) String() string { - return proto.EnumName(Target_name, int32(x)) -} - -func (Target) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0} -} - -// Operation is an enumeration of operation types. -type EACLRecord_Operation int32 - -const ( - EACLRecord_OPERATION_UNKNOWN EACLRecord_Operation = 0 - EACLRecord_GET EACLRecord_Operation = 1 - EACLRecord_HEAD EACLRecord_Operation = 2 - EACLRecord_PUT EACLRecord_Operation = 3 - EACLRecord_DELETE EACLRecord_Operation = 4 - EACLRecord_SEARCH EACLRecord_Operation = 5 - EACLRecord_GETRANGE EACLRecord_Operation = 6 - EACLRecord_GETRANGEHASH EACLRecord_Operation = 7 -) - -var EACLRecord_Operation_name = map[int32]string{ - 0: "OPERATION_UNKNOWN", - 1: "GET", - 2: "HEAD", - 3: "PUT", - 4: "DELETE", - 5: "SEARCH", - 6: "GETRANGE", - 7: "GETRANGEHASH", -} - -var EACLRecord_Operation_value = map[string]int32{ - "OPERATION_UNKNOWN": 0, - "GET": 1, - "HEAD": 2, - "PUT": 3, - "DELETE": 4, - "SEARCH": 5, - "GETRANGE": 6, - "GETRANGEHASH": 7, -} - -func (x EACLRecord_Operation) String() string { - return proto.EnumName(EACLRecord_Operation_name, int32(x)) -} - -func (EACLRecord_Operation) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 0} -} - -// Action is an enumeration of EACL actions. -type EACLRecord_Action int32 - -const ( - EACLRecord_ActionUnknown EACLRecord_Action = 0 - EACLRecord_Allow EACLRecord_Action = 1 - EACLRecord_Deny EACLRecord_Action = 2 -) - -var EACLRecord_Action_name = map[int32]string{ - 0: "ActionUnknown", - 1: "Allow", - 2: "Deny", -} - -var EACLRecord_Action_value = map[string]int32{ - "ActionUnknown": 0, - "Allow": 1, - "Deny": 2, -} - -func (x EACLRecord_Action) String() string { - return proto.EnumName(EACLRecord_Action_name, int32(x)) -} - -func (EACLRecord_Action) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 1} -} - -// Header is an enumeration of filtering header types. -type EACLRecord_FilterInfo_Header int32 - -const ( - EACLRecord_FilterInfo_HeaderUnknown EACLRecord_FilterInfo_Header = 0 - EACLRecord_FilterInfo_Request EACLRecord_FilterInfo_Header = 1 - EACLRecord_FilterInfo_ObjectSystem EACLRecord_FilterInfo_Header = 2 - EACLRecord_FilterInfo_ObjectUser EACLRecord_FilterInfo_Header = 3 -) - -var EACLRecord_FilterInfo_Header_name = map[int32]string{ - 0: "HeaderUnknown", - 1: "Request", - 2: "ObjectSystem", - 3: "ObjectUser", -} - -var EACLRecord_FilterInfo_Header_value = map[string]int32{ - "HeaderUnknown": 0, - "Request": 1, - "ObjectSystem": 2, - "ObjectUser": 3, -} - -func (x EACLRecord_FilterInfo_Header) String() string { - return proto.EnumName(EACLRecord_FilterInfo_Header_name, int32(x)) -} - -func (EACLRecord_FilterInfo_Header) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 0, 0} -} - -// MatchType is an enumeration of match types. -type EACLRecord_FilterInfo_MatchType int32 - -const ( - EACLRecord_FilterInfo_MatchUnknown EACLRecord_FilterInfo_MatchType = 0 - EACLRecord_FilterInfo_StringEqual EACLRecord_FilterInfo_MatchType = 1 - EACLRecord_FilterInfo_StringNotEqual EACLRecord_FilterInfo_MatchType = 2 -) - -var EACLRecord_FilterInfo_MatchType_name = map[int32]string{ - 0: "MatchUnknown", - 1: "StringEqual", - 2: "StringNotEqual", -} - -var EACLRecord_FilterInfo_MatchType_value = map[string]int32{ - "MatchUnknown": 0, - "StringEqual": 1, - "StringNotEqual": 2, -} - -func (x EACLRecord_FilterInfo_MatchType) String() string { - return proto.EnumName(EACLRecord_FilterInfo_MatchType_name, int32(x)) -} - -func (EACLRecord_FilterInfo_MatchType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 0, 1} -} - -// EACLRecord groups information about extended ACL rule. -type EACLRecord struct { - // Operation carries type of operation. - Operation EACLRecord_Operation `protobuf:"varint,1,opt,name=operation,json=Operation,proto3,enum=acl.EACLRecord_Operation" json:"operation,omitempty"` - // Action carries ACL target action. - Action EACLRecord_Action `protobuf:"varint,2,opt,name=action,json=Action,proto3,enum=acl.EACLRecord_Action" json:"action,omitempty"` - // Filters carries set of filters. - Filters []*EACLRecord_FilterInfo `protobuf:"bytes,3,rep,name=Filters,proto3" json:"Filters,omitempty"` - // Targets carries information about extended ACL target list. - Targets []*EACLRecord_TargetInfo `protobuf:"bytes,4,rep,name=Targets,proto3" json:"Targets,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EACLRecord) Reset() { *m = EACLRecord{} } -func (m *EACLRecord) String() string { return proto.CompactTextString(m) } -func (*EACLRecord) ProtoMessage() {} -func (*EACLRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0} -} -func (m *EACLRecord) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *EACLRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_EACLRecord.Merge(m, src) -} -func (m *EACLRecord) XXX_Size() int { - return m.Size() -} -func (m *EACLRecord) XXX_DiscardUnknown() { - xxx_messageInfo_EACLRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_EACLRecord proto.InternalMessageInfo - -func (m *EACLRecord) GetOperation() EACLRecord_Operation { - if m != nil { - return m.Operation - } - return EACLRecord_OPERATION_UNKNOWN -} - -func (m *EACLRecord) GetAction() EACLRecord_Action { - if m != nil { - return m.Action - } - return EACLRecord_ActionUnknown -} - -func (m *EACLRecord) GetFilters() []*EACLRecord_FilterInfo { - if m != nil { - return m.Filters - } - return nil -} - -func (m *EACLRecord) GetTargets() []*EACLRecord_TargetInfo { - if m != nil { - return m.Targets - } - return nil -} - -// FilterInfo groups information about filter. -type EACLRecord_FilterInfo struct { - // Header carries type of header. - Header EACLRecord_FilterInfo_Header `protobuf:"varint,1,opt,name=header,json=HeaderType,proto3,enum=acl.EACLRecord_FilterInfo_Header" json:"header,omitempty"` - // MatchType carries type of match. - MatchType EACLRecord_FilterInfo_MatchType `protobuf:"varint,2,opt,name=matchType,json=MatchType,proto3,enum=acl.EACLRecord_FilterInfo_MatchType" json:"matchType,omitempty"` - // HeaderName carries name of filtering header. - HeaderName string `protobuf:"bytes,3,opt,name=HeaderName,json=Name,proto3" json:"HeaderName,omitempty"` - // HeaderVal carries value of filtering header. - HeaderVal string `protobuf:"bytes,4,opt,name=HeaderVal,json=Value,proto3" json:"HeaderVal,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EACLRecord_FilterInfo) Reset() { *m = EACLRecord_FilterInfo{} } -func (m *EACLRecord_FilterInfo) String() string { return proto.CompactTextString(m) } -func (*EACLRecord_FilterInfo) ProtoMessage() {} -func (*EACLRecord_FilterInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 0} -} -func (m *EACLRecord_FilterInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EACLRecord_FilterInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *EACLRecord_FilterInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_EACLRecord_FilterInfo.Merge(m, src) -} -func (m *EACLRecord_FilterInfo) XXX_Size() int { - return m.Size() -} -func (m *EACLRecord_FilterInfo) XXX_DiscardUnknown() { - xxx_messageInfo_EACLRecord_FilterInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_EACLRecord_FilterInfo proto.InternalMessageInfo - -func (m *EACLRecord_FilterInfo) GetHeader() EACLRecord_FilterInfo_Header { - if m != nil { - return m.Header - } - return EACLRecord_FilterInfo_HeaderUnknown -} - -func (m *EACLRecord_FilterInfo) GetMatchType() EACLRecord_FilterInfo_MatchType { - if m != nil { - return m.MatchType - } - return EACLRecord_FilterInfo_MatchUnknown -} - -func (m *EACLRecord_FilterInfo) GetHeaderName() string { - if m != nil { - return m.HeaderName - } - return "" -} - -func (m *EACLRecord_FilterInfo) GetHeaderVal() string { - if m != nil { - return m.HeaderVal - } - return "" -} - -// TargetInfo groups information about extended ACL target. -type EACLRecord_TargetInfo struct { - // Target carries target of ACL rule. - Target Target `protobuf:"varint,1,opt,name=Target,json=Role,proto3,enum=acl.Target" json:"Target,omitempty"` - // KeyList carries public keys of ACL target. - KeyList [][]byte `protobuf:"bytes,2,rep,name=KeyList,json=Keys,proto3" json:"KeyList,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EACLRecord_TargetInfo) Reset() { *m = EACLRecord_TargetInfo{} } -func (m *EACLRecord_TargetInfo) String() string { return proto.CompactTextString(m) } -func (*EACLRecord_TargetInfo) ProtoMessage() {} -func (*EACLRecord_TargetInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{0, 1} -} -func (m *EACLRecord_TargetInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EACLRecord_TargetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *EACLRecord_TargetInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_EACLRecord_TargetInfo.Merge(m, src) -} -func (m *EACLRecord_TargetInfo) XXX_Size() int { - return m.Size() -} -func (m *EACLRecord_TargetInfo) XXX_DiscardUnknown() { - xxx_messageInfo_EACLRecord_TargetInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_EACLRecord_TargetInfo proto.InternalMessageInfo - -func (m *EACLRecord_TargetInfo) GetTarget() Target { - if m != nil { - return m.Target - } - return Target_Unknown -} - -func (m *EACLRecord_TargetInfo) GetKeyList() [][]byte { - if m != nil { - return m.KeyList - } - return nil -} - -// EACLRecord carries the information about extended ACL rules. -type EACLTable struct { - // Records carries list of extended ACL rule records. - Records []*EACLRecord `protobuf:"bytes,1,rep,name=Records,proto3" json:"Records,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EACLTable) Reset() { *m = EACLTable{} } -func (m *EACLTable) String() string { return proto.CompactTextString(m) } -func (*EACLTable) ProtoMessage() {} -func (*EACLTable) Descriptor() ([]byte, []int) { - return fileDescriptor_9b63aff5f3a35e32, []int{1} -} -func (m *EACLTable) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EACLTable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *EACLTable) XXX_Merge(src proto.Message) { - xxx_messageInfo_EACLTable.Merge(m, src) -} -func (m *EACLTable) XXX_Size() int { - return m.Size() -} -func (m *EACLTable) XXX_DiscardUnknown() { - xxx_messageInfo_EACLTable.DiscardUnknown(m) -} - -var xxx_messageInfo_EACLTable proto.InternalMessageInfo - -func (m *EACLTable) GetRecords() []*EACLRecord { - if m != nil { - return m.Records - } - return nil -} - -func init() { - proto.RegisterEnum("acl.Target", Target_name, Target_value) - proto.RegisterEnum("acl.EACLRecord_Operation", EACLRecord_Operation_name, EACLRecord_Operation_value) - proto.RegisterEnum("acl.EACLRecord_Action", EACLRecord_Action_name, EACLRecord_Action_value) - proto.RegisterEnum("acl.EACLRecord_FilterInfo_Header", EACLRecord_FilterInfo_Header_name, EACLRecord_FilterInfo_Header_value) - proto.RegisterEnum("acl.EACLRecord_FilterInfo_MatchType", EACLRecord_FilterInfo_MatchType_name, EACLRecord_FilterInfo_MatchType_value) - proto.RegisterType((*EACLRecord)(nil), "acl.EACLRecord") - proto.RegisterType((*EACLRecord_FilterInfo)(nil), "acl.EACLRecord.FilterInfo") - proto.RegisterType((*EACLRecord_TargetInfo)(nil), "acl.EACLRecord.TargetInfo") - proto.RegisterType((*EACLTable)(nil), "acl.EACLTable") -} - -func init() { proto.RegisterFile("acl/types.proto", fileDescriptor_9b63aff5f3a35e32) } - -var fileDescriptor_9b63aff5f3a35e32 = []byte{ - // 676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x6e, 0xda, 0x58, - 0x14, 0x8e, 0x7f, 0x62, 0xc2, 0x01, 0x92, 0x9b, 0x2b, 0x65, 0xe4, 0x61, 0x41, 0x08, 0x9a, 0x91, - 0x98, 0x91, 0x30, 0xa3, 0x4c, 0xd5, 0x45, 0x77, 0x26, 0x31, 0x81, 0x92, 0x1a, 0x6a, 0x4c, 0x2a, - 0x75, 0x53, 0x5d, 0x9c, 0x1b, 0xa0, 0x35, 0xbe, 0xc4, 0x36, 0x89, 0x78, 0x93, 0x3e, 0x43, 0x9f, - 0xa4, 0xcb, 0x2e, 0xbb, 0x4a, 0x2b, 0xba, 0xef, 0x33, 0x54, 0xbe, 0x17, 0xc7, 0x51, 0xd4, 0x76, - 0xe5, 0xef, 0x3b, 0xbf, 0xf7, 0x7c, 0xe7, 0xc8, 0xb0, 0x47, 0x3c, 0xbf, 0x19, 0xaf, 0x16, 0x34, - 0x32, 0x16, 0x21, 0x8b, 0x19, 0x56, 0x88, 0xe7, 0x97, 0x1b, 0x93, 0x59, 0x3c, 0x5d, 0x8e, 0x0d, - 0x8f, 0xcd, 0x9b, 0x13, 0x36, 0x61, 0x4d, 0xee, 0x1b, 0x2f, 0xaf, 0x38, 0xe3, 0x84, 0x23, 0x91, - 0x53, 0xfb, 0xa2, 0x01, 0x58, 0xe6, 0xc9, 0xb9, 0x43, 0x3d, 0x16, 0x5e, 0xe2, 0x36, 0xe4, 0xd9, - 0x82, 0x86, 0x24, 0x9e, 0xb1, 0x40, 0x97, 0xaa, 0x52, 0x7d, 0xf7, 0xf8, 0x4f, 0x83, 0x78, 0xbe, - 0x91, 0xc5, 0x18, 0xfd, 0x34, 0xa0, 0x55, 0x5a, 0xdf, 0x1d, 0xe6, 0xef, 0xa9, 0x93, 0x41, 0xfc, - 0x0c, 0x34, 0xe2, 0xf1, 0x22, 0x32, 0x2f, 0xf2, 0xc7, 0xe3, 0x22, 0x26, 0xf7, 0xb6, 0x60, 0x7d, - 0x77, 0xa8, 0x09, 0xec, 0x6c, 0xbe, 0xf8, 0x09, 0xe4, 0xda, 0x33, 0x3f, 0xa6, 0x61, 0xa4, 0x2b, - 0x55, 0xa5, 0x5e, 0x38, 0x2e, 0x3f, 0x4e, 0x16, 0xee, 0x6e, 0x70, 0xc5, 0x9c, 0x34, 0x34, 0xc9, - 0x72, 0x49, 0x38, 0xa1, 0x71, 0xa4, 0xab, 0x3f, 0xcf, 0x12, 0x6e, 0x91, 0xb5, 0x09, 0x2d, 0x7f, - 0x97, 0x01, 0xb2, 0x6a, 0xb8, 0x0b, 0xda, 0x94, 0x92, 0x4b, 0x1a, 0x6e, 0x66, 0x3f, 0xfa, 0x75, - 0x67, 0xa3, 0xc3, 0x03, 0xc5, 0x04, 0x02, 0x3b, 0x20, 0xbe, 0xee, 0x6a, 0x41, 0xf1, 0x4b, 0xc8, - 0xcf, 0x49, 0xec, 0x4d, 0x13, 0xb2, 0x11, 0xe1, 0xaf, 0xdf, 0x54, 0x7b, 0x91, 0xc6, 0x0a, 0x51, - 0xef, 0xa9, 0x93, 0x41, 0xac, 0xc3, 0xa6, 0x81, 0x4d, 0xe6, 0x54, 0x57, 0xaa, 0x52, 0x3d, 0xef, - 0xa8, 0x09, 0xc6, 0x3a, 0xe4, 0x85, 0xe7, 0x82, 0xf8, 0xba, 0xca, 0x1d, 0xdb, 0x17, 0xc4, 0x5f, - 0xd2, 0xda, 0x73, 0xd8, 0x3c, 0x0e, 0xef, 0x43, 0x49, 0xa0, 0x51, 0xf0, 0x2e, 0x60, 0xb7, 0x01, - 0xda, 0xc2, 0x05, 0xc8, 0x39, 0xf4, 0x7a, 0x49, 0xa3, 0x18, 0x49, 0x18, 0x41, 0xb1, 0x3f, 0x7e, - 0x4b, 0xbd, 0x78, 0xb8, 0x8a, 0x62, 0x3a, 0x47, 0x32, 0xde, 0x05, 0x10, 0x96, 0x51, 0x44, 0x43, - 0xa4, 0xd4, 0x5a, 0xf0, 0xe0, 0x31, 0x08, 0x8a, 0x9c, 0x64, 0xd5, 0xf6, 0xa0, 0x30, 0x8c, 0xc3, - 0x59, 0x30, 0xb1, 0xae, 0x97, 0xc4, 0x47, 0x12, 0xc6, 0xb0, 0x2b, 0x0c, 0x36, 0x8b, 0x85, 0x4d, - 0x2e, 0xb7, 0x01, 0xb2, 0x3d, 0xe0, 0x23, 0xd0, 0x04, 0xdb, 0xe8, 0x5d, 0xe0, 0x0a, 0x09, 0x93, - 0xa3, 0x3a, 0xcc, 0xa7, 0xf8, 0x00, 0x72, 0x3d, 0xba, 0x3a, 0x9f, 0x45, 0xb1, 0x2e, 0x57, 0x95, - 0x7a, 0xd1, 0x51, 0x7b, 0x74, 0x15, 0xd5, 0x6e, 0xe0, 0xc1, 0xb5, 0x1d, 0xc0, 0x7e, 0x7f, 0x60, - 0x39, 0xa6, 0xdb, 0xed, 0xdb, 0x6f, 0x46, 0x76, 0xcf, 0xee, 0xbf, 0xb2, 0xd1, 0x16, 0xce, 0x81, - 0x72, 0x66, 0xb9, 0x48, 0xc2, 0x3b, 0xa0, 0x76, 0x2c, 0xf3, 0x14, 0xc9, 0x89, 0x69, 0x30, 0x72, - 0x91, 0x82, 0x01, 0xb4, 0x53, 0xeb, 0xdc, 0x72, 0x2d, 0xa4, 0x26, 0x78, 0x68, 0x99, 0xce, 0x49, - 0x07, 0x6d, 0xe3, 0x22, 0xec, 0x9c, 0x59, 0xae, 0x63, 0xda, 0x67, 0x16, 0xd2, 0x92, 0x21, 0x53, - 0xd6, 0x31, 0x87, 0x1d, 0x94, 0xab, 0xfd, 0x07, 0xe9, 0x99, 0xee, 0x43, 0x49, 0xa0, 0x4c, 0x81, - 0x3c, 0x6c, 0x9b, 0xbe, 0xcf, 0x6e, 0x45, 0xcb, 0x53, 0x1a, 0xac, 0x90, 0x5c, 0x7b, 0x0a, 0xf9, - 0x64, 0xe5, 0x2e, 0x19, 0xfb, 0x14, 0xff, 0x93, 0x28, 0x9e, 0xec, 0x3e, 0xd2, 0x25, 0x7e, 0xa5, - 0x7b, 0x8f, 0x6e, 0xc2, 0x49, 0xfd, 0xff, 0x9e, 0xa4, 0xda, 0x24, 0x6b, 0xca, 0x7a, 0xec, 0x80, - 0xca, 0xd7, 0x21, 0xf1, 0x67, 0xa7, 0xab, 0x02, 0xd0, 0xfa, 0xf1, 0x94, 0x86, 0x91, 0x18, 0x6d, - 0xb0, 0x1c, 0xf7, 0xe8, 0x0a, 0xa9, 0xad, 0xde, 0xc7, 0x75, 0x45, 0xfa, 0xb4, 0xae, 0x48, 0x9f, - 0xd7, 0x15, 0xe9, 0xeb, 0xba, 0x22, 0xbd, 0xff, 0x56, 0xd9, 0x7a, 0xfd, 0xf7, 0x83, 0x7f, 0x44, - 0x10, 0x2d, 0x3c, 0xaf, 0x71, 0x49, 0x6f, 0x9a, 0x01, 0x65, 0x57, 0x51, 0x83, 0x2c, 0x66, 0x8d, - 0x09, 0x6b, 0x12, 0xcf, 0xff, 0x20, 0x97, 0x6c, 0xca, 0xda, 0x43, 0xc3, 0x1c, 0x74, 0x0d, 0xd3, - 0xf3, 0xc7, 0x1a, 0xff, 0x65, 0xfc, 0xff, 0x23, 0x00, 0x00, 0xff, 0xff, 0x39, 0x7b, 0x27, 0xe6, - 0x79, 0x04, 0x00, 0x00, -} - -func (m *EACLRecord) 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 *EACLRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Targets) > 0 { - for iNdEx := len(m.Targets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Targets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.Filters) > 0 { - for iNdEx := len(m.Filters) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Filters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.Action != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Action)) - i-- - dAtA[i] = 0x10 - } - if m.Operation != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Operation)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EACLRecord_FilterInfo) 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 *EACLRecord_FilterInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EACLRecord_FilterInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.HeaderVal) > 0 { - i -= len(m.HeaderVal) - copy(dAtA[i:], m.HeaderVal) - i = encodeVarintTypes(dAtA, i, uint64(len(m.HeaderVal))) - i-- - dAtA[i] = 0x22 - } - if len(m.HeaderName) > 0 { - i -= len(m.HeaderName) - copy(dAtA[i:], m.HeaderName) - i = encodeVarintTypes(dAtA, i, uint64(len(m.HeaderName))) - i-- - dAtA[i] = 0x1a - } - if m.MatchType != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.MatchType)) - i-- - dAtA[i] = 0x10 - } - if m.Header != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Header)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EACLRecord_TargetInfo) 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 *EACLRecord_TargetInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EACLRecord_TargetInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.KeyList) > 0 { - for iNdEx := len(m.KeyList) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.KeyList[iNdEx]) - copy(dAtA[i:], m.KeyList[iNdEx]) - i = encodeVarintTypes(dAtA, i, uint64(len(m.KeyList[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if m.Target != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Target)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EACLTable) 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 *EACLTable) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EACLTable) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Records) > 0 { - for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *EACLRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Operation != 0 { - n += 1 + sovTypes(uint64(m.Operation)) - } - if m.Action != 0 { - n += 1 + sovTypes(uint64(m.Action)) - } - if len(m.Filters) > 0 { - for _, e := range m.Filters { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if len(m.Targets) > 0 { - for _, e := range m.Targets { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *EACLRecord_FilterInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Header != 0 { - n += 1 + sovTypes(uint64(m.Header)) - } - if m.MatchType != 0 { - n += 1 + sovTypes(uint64(m.MatchType)) - } - l = len(m.HeaderName) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.HeaderVal) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *EACLRecord_TargetInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Target != 0 { - n += 1 + sovTypes(uint64(m.Target)) - } - if len(m.KeyList) > 0 { - for _, b := range m.KeyList { - l = len(b) - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *EACLTable) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Records) > 0 { - for _, e := range m.Records { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *EACLRecord) 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 ErrIntOverflowTypes - } - 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: EACLRecord: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EACLRecord: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) - } - m.Operation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Operation |= EACLRecord_Operation(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) - } - m.Action = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Action |= EACLRecord_Action(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Filters = append(m.Filters, &EACLRecord_FilterInfo{}) - if err := m.Filters[len(m.Filters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Targets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Targets = append(m.Targets, &EACLRecord_TargetInfo{}) - if err := m.Targets[len(m.Targets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EACLRecord_FilterInfo) 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 ErrIntOverflowTypes - } - 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: FilterInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FilterInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - m.Header = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Header |= EACLRecord_FilterInfo_Header(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MatchType", wireType) - } - m.MatchType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MatchType |= EACLRecord_FilterInfo_MatchType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HeaderName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HeaderName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HeaderVal", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HeaderVal = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EACLRecord_TargetInfo) 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 ErrIntOverflowTypes - } - 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: TargetInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TargetInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) - } - m.Target = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Target |= Target(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyList", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.KeyList = append(m.KeyList, make([]byte, postIndex-iNdEx)) - copy(m.KeyList[len(m.KeyList)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EACLTable) 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 ErrIntOverflowTypes - } - 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: EACLTable: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EACLTable: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Records = append(m.Records, &EACLRecord{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/acl/types.proto b/acl/types.proto deleted file mode 100644 index 7f3efc9..0000000 --- a/acl/types.proto +++ /dev/null @@ -1,106 +0,0 @@ -syntax = "proto3"; -package acl; -option go_package = "github.com/nspcc-dev/neofs-api-go/acl"; -option csharp_namespace = "NeoFS.API.Acl"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; -option (gogoproto.stable_marshaler_all) = true; - -// Target of the access control rule in access control list. -enum Target { - // Unknown target, default value. - Unknown = 0; - - // User target rule is applied if sender is the owner of the container. - User = 1; - - // System target rule is applied if sender is the storage node within the - // container or inner ring node. - System = 2; - - // Others target rule is applied if sender is not user or system target. - Others = 3; - - // PubKey target rule is applied if sender has public key provided in - // extended ACL. - PubKey = 4; -} - -// EACLRecord groups information about extended ACL rule. -message EACLRecord { - // Operation is an enumeration of operation types. - enum Operation { - OPERATION_UNKNOWN = 0; - GET = 1; - HEAD = 2; - PUT = 3; - DELETE = 4; - SEARCH = 5; - GETRANGE = 6; - GETRANGEHASH = 7; - } - - // Operation carries type of operation. - Operation operation = 1 [(gogoproto.customname) = "Operation", json_name="Operation"]; - - // Action is an enumeration of EACL actions. - enum Action { - ActionUnknown = 0; - Allow = 1; - Deny = 2; - } - - // Action carries ACL target action. - Action action = 2 [(gogoproto.customname) = "Action", json_name="Action"]; - - // FilterInfo groups information about filter. - message FilterInfo { - // Header is an enumeration of filtering header types. - enum Header { - HeaderUnknown = 0; - Request = 1; - ObjectSystem = 2; - ObjectUser = 3; - } - - // Header carries type of header. - Header header = 1 [(gogoproto.customname) = "Header", json_name="HeaderType"]; - - // MatchType is an enumeration of match types. - enum MatchType { - MatchUnknown = 0; - StringEqual = 1; - StringNotEqual = 2; - } - - // MatchType carries type of match. - MatchType matchType = 2 [(gogoproto.customname) = "MatchType", json_name="MatchType"]; - - // HeaderName carries name of filtering header. - string HeaderName = 3 [json_name="Name"]; - - // HeaderVal carries value of filtering header. - string HeaderVal = 4 [json_name="Value"]; - } - - // Filters carries set of filters. - repeated FilterInfo Filters = 3 [json_name="Filters"]; - - // TargetInfo groups information about extended ACL target. - message TargetInfo { - // Target carries target of ACL rule. - acl.Target Target = 1 [json_name="Role"]; - - // KeyList carries public keys of ACL target. - repeated bytes KeyList = 2 [json_name="Keys"]; - } - - // Targets carries information about extended ACL target list. - repeated TargetInfo Targets = 4 [json_name="Targets"]; -} - -// EACLRecord carries the information about extended ACL rules. -message EACLTable { - // Records carries list of extended ACL rule records. - repeated EACLRecord Records = 1 [json_name="Records"]; -} diff --git a/bootstrap/service.go b/bootstrap/service.go deleted file mode 100644 index 929d9b3..0000000 --- a/bootstrap/service.go +++ /dev/null @@ -1,8 +0,0 @@ -package bootstrap - -import ( - "github.com/nspcc-dev/neofs-api-go/service" -) - -// NodeType type alias. -type NodeType = service.NodeRole diff --git a/bootstrap/service.pb.go b/bootstrap/service.pb.go deleted file mode 100644 index 50e6c67..0000000 --- a/bootstrap/service.pb.go +++ /dev/null @@ -1,628 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: bootstrap/service.proto - -package bootstrap - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Node state -type Request_State int32 - -const ( - // used by default - Request_Unknown Request_State = 0 - // used to inform that node online - Request_Online Request_State = 1 - // used to inform that node offline - Request_Offline Request_State = 2 -) - -var Request_State_name = map[int32]string{ - 0: "Unknown", - 1: "Online", - 2: "Offline", -} - -var Request_State_value = map[string]int32{ - "Unknown": 0, - "Online": 1, - "Offline": 2, -} - -func (x Request_State) String() string { - return proto.EnumName(Request_State_name, int32(x)) -} - -func (Request_State) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_21bce759c9d8eb63, []int{0, 0} -} - -type Request struct { - // Type is NodeType, can be InnerRingNode (type=1) or StorageNode (type=2) - Type NodeType `protobuf:"varint,1,opt,name=type,proto3,customtype=NodeType" json:"type"` - // Info contains information about node - Info NodeInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` - // State contains node status - State Request_State `protobuf:"varint,3,opt,name=state,proto3,enum=bootstrap.Request_State" json:"state,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Request) Reset() { *m = Request{} } -func (m *Request) String() string { return proto.CompactTextString(m) } -func (*Request) ProtoMessage() {} -func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_21bce759c9d8eb63, []int{0} -} -func (m *Request) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Request) XXX_Merge(src proto.Message) { - xxx_messageInfo_Request.Merge(m, src) -} -func (m *Request) XXX_Size() int { - return m.Size() -} -func (m *Request) XXX_DiscardUnknown() { - xxx_messageInfo_Request.DiscardUnknown(m) -} - -var xxx_messageInfo_Request proto.InternalMessageInfo - -func (m *Request) GetInfo() NodeInfo { - if m != nil { - return m.Info - } - return NodeInfo{} -} - -func (m *Request) GetState() Request_State { - if m != nil { - return m.State - } - return Request_Unknown -} - -func init() { - proto.RegisterEnum("bootstrap.Request_State", Request_State_name, Request_State_value) - proto.RegisterType((*Request)(nil), "bootstrap.Request") -} - -func init() { proto.RegisterFile("bootstrap/service.proto", fileDescriptor_21bce759c9d8eb63) } - -var fileDescriptor_21bce759c9d8eb63 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x51, 0x4d, 0x8b, 0xd3, 0x40, - 0x18, 0xee, 0xd4, 0xb4, 0xdd, 0x9d, 0x05, 0x59, 0x66, 0x57, 0x0c, 0x3d, 0xa4, 0xa5, 0xa7, 0x82, - 0x66, 0x02, 0xdd, 0x8b, 0x47, 0x0d, 0x22, 0xee, 0x61, 0x3f, 0x48, 0xfd, 0x00, 0x6f, 0x93, 0xf4, - 0x4d, 0x1d, 0x74, 0xe7, 0x1d, 0x33, 0xd3, 0x4a, 0xff, 0x89, 0xbf, 0xc1, 0xff, 0x21, 0xec, 0x71, - 0x8f, 0xe2, 0xa1, 0x48, 0xfc, 0x23, 0x32, 0xd3, 0xb4, 0x16, 0xf7, 0x94, 0xbc, 0xcf, 0xd7, 0xbc, - 0x1f, 0xf4, 0x71, 0x8e, 0x68, 0x8d, 0xad, 0x84, 0x4e, 0x0c, 0x54, 0x4b, 0x59, 0x00, 0xd7, 0x15, - 0x5a, 0x64, 0x87, 0x3b, 0xa2, 0xcf, 0x1a, 0x26, 0xb9, 0x01, 0x2b, 0x36, 0x74, 0xff, 0x74, 0x8b, - 0x2d, 0xa1, 0x92, 0xe5, 0xaa, 0x41, 0x1f, 0xfd, 0x4b, 0xb3, 0x2b, 0x0d, 0xa6, 0x81, 0xe3, 0xb9, - 0xb4, 0x1f, 0x17, 0x39, 0x2f, 0xf0, 0x26, 0x99, 0xe3, 0x1c, 0x13, 0x0f, 0xe7, 0x8b, 0xd2, 0x57, - 0xbe, 0xf0, 0x7f, 0x1b, 0xf9, 0xe8, 0x47, 0x9b, 0xf6, 0x32, 0xf8, 0xb2, 0x00, 0x63, 0xd9, 0x53, - 0x1a, 0xb8, 0xa4, 0x90, 0x0c, 0xc9, 0xb8, 0x93, 0x86, 0xb7, 0xeb, 0x41, 0xeb, 0xd7, 0x7a, 0x70, - 0x70, 0x89, 0x33, 0x78, 0xb3, 0xd2, 0x50, 0xaf, 0x07, 0x81, 0xfb, 0x66, 0x5e, 0xc5, 0x62, 0x1a, - 0x48, 0x55, 0x62, 0xd8, 0x1e, 0x92, 0xf1, 0xd1, 0xe4, 0x84, 0xef, 0xda, 0xe1, 0xce, 0x70, 0xae, - 0x4a, 0x4c, 0x03, 0x17, 0x91, 0x79, 0x19, 0xe3, 0xb4, 0x63, 0xac, 0xb0, 0x10, 0x3e, 0x18, 0x92, - 0xf1, 0xc3, 0x49, 0xb8, 0xa7, 0x6f, 0xde, 0xe7, 0x53, 0xc7, 0x67, 0x1b, 0x19, 0x7b, 0x46, 0x83, - 0x0b, 0xb0, 0x22, 0xcc, 0x7d, 0x7c, 0x9f, 0x6f, 0x37, 0xd6, 0x88, 0x1d, 0xf7, 0x1a, 0xc4, 0x0c, - 0xaa, 0xf4, 0xc0, 0xbd, 0x72, 0xb7, 0x1e, 0x90, 0xcc, 0x3b, 0xd8, 0x4b, 0xda, 0x7d, 0xe7, 0x17, - 0x15, 0x16, 0xde, 0x3b, 0xfa, 0xdf, 0xeb, 0x59, 0x59, 0x08, 0x2b, 0x51, 0xdd, 0xcb, 0x68, 0xbc, - 0xa3, 0x98, 0x76, 0x7c, 0x3f, 0xec, 0x88, 0xf6, 0xde, 0xaa, 0x4f, 0x0a, 0xbf, 0xaa, 0xe3, 0x16, - 0xa3, 0xb4, 0x7b, 0xa5, 0x3e, 0x4b, 0x05, 0xc7, 0xc4, 0x11, 0x57, 0x65, 0xe9, 0x8b, 0xf6, 0xe4, - 0x39, 0x3d, 0x4c, 0xb7, 0x03, 0xb1, 0x33, 0xda, 0xbb, 0xae, 0xb0, 0x00, 0x63, 0x18, 0xbb, 0x3f, - 0x67, 0xff, 0x74, 0x0f, 0x9b, 0xea, 0x0a, 0xc4, 0xec, 0x42, 0xe8, 0xf4, 0xfd, 0x6d, 0x1d, 0x91, - 0xbb, 0x3a, 0x22, 0x3f, 0xeb, 0x88, 0xfc, 0xae, 0x23, 0xf2, 0xed, 0x4f, 0xd4, 0xfa, 0xf0, 0x64, - 0xef, 0x9c, 0xca, 0xe8, 0xa2, 0x88, 0x67, 0xb0, 0x4c, 0x14, 0x60, 0x69, 0x62, 0xa1, 0x65, 0x3c, - 0xc7, 0x64, 0x17, 0xf6, 0xbd, 0x7d, 0x72, 0x09, 0xf8, 0x6a, 0xca, 0x5f, 0x5c, 0x9f, 0xf3, 0x5d, - 0x37, 0x79, 0xd7, 0x5f, 0xfa, 0xec, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x74, 0xc6, 0xb6, 0xb6, - 0x7f, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// BootstrapClient is the client API for Bootstrap service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type BootstrapClient interface { - // Process is method that allows to register node in the network and receive actual netmap - Process(ctx context.Context, in *Request, opts ...grpc.CallOption) (*SpreadMap, error) -} - -type bootstrapClient struct { - cc *grpc.ClientConn -} - -func NewBootstrapClient(cc *grpc.ClientConn) BootstrapClient { - return &bootstrapClient{cc} -} - -func (c *bootstrapClient) Process(ctx context.Context, in *Request, opts ...grpc.CallOption) (*SpreadMap, error) { - out := new(SpreadMap) - err := c.cc.Invoke(ctx, "/bootstrap.Bootstrap/Process", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// BootstrapServer is the server API for Bootstrap service. -type BootstrapServer interface { - // Process is method that allows to register node in the network and receive actual netmap - Process(context.Context, *Request) (*SpreadMap, error) -} - -// UnimplementedBootstrapServer can be embedded to have forward compatible implementations. -type UnimplementedBootstrapServer struct { -} - -func (*UnimplementedBootstrapServer) Process(ctx context.Context, req *Request) (*SpreadMap, error) { - return nil, status.Errorf(codes.Unimplemented, "method Process not implemented") -} - -func RegisterBootstrapServer(s *grpc.Server, srv BootstrapServer) { - s.RegisterService(&_Bootstrap_serviceDesc, srv) -} - -func _Bootstrap_Process_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BootstrapServer).Process(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/bootstrap.Bootstrap/Process", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BootstrapServer).Process(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -var _Bootstrap_serviceDesc = grpc.ServiceDesc{ - ServiceName: "bootstrap.Bootstrap", - HandlerType: (*BootstrapServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Process", - Handler: _Bootstrap_Process_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "bootstrap/service.proto", -} - -func (m *Request) 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 *Request) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.State != 0 { - i = encodeVarintService(dAtA, i, uint64(m.State)) - i-- - dAtA[i] = 0x18 - } - { - size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Type != 0 { - i = encodeVarintService(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Request) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovService(uint64(m.Type)) - } - l = m.Info.Size() - n += 1 + l + sovService(uint64(l)) - if m.State != 0 { - n += 1 + sovService(uint64(m.State)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Request) 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 ErrIntOverflowService - } - 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: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= NodeType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) - } - m.State = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.State |= Request_State(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/bootstrap/service.proto b/bootstrap/service.proto deleted file mode 100644 index 6918bef..0000000 --- a/bootstrap/service.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; -package bootstrap; -option go_package = "github.com/nspcc-dev/neofs-api-go/bootstrap"; -option csharp_namespace = "NeoFS.API.Bootstrap"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "bootstrap/types.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Bootstrap service allows neofs-node to connect to the network. Node should -// perform at least one bootstrap request in the epoch to stay in the network -// for the next epoch. -service Bootstrap { - // Process is method that allows to register node in the network and receive actual netmap - rpc Process(Request) returns (bootstrap.SpreadMap); -} - -message Request { - // Node state - enum State { - // used by default - Unknown = 0; - // used to inform that node online - Online = 1; - // used to inform that node offline - Offline = 2; - } - - // Type is NodeType, can be InnerRingNode (type=1) or StorageNode (type=2) - int32 type = 1 [(gogoproto.customname) = "Type" , (gogoproto.nullable) = false, (gogoproto.customtype) = "NodeType"]; - // Info contains information about node - bootstrap.NodeInfo info = 2 [(gogoproto.nullable) = false]; - // State contains node status - State state = 3; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} diff --git a/bootstrap/sign.go b/bootstrap/sign.go deleted file mode 100644 index 34f7fc2..0000000 --- a/bootstrap/sign.go +++ /dev/null @@ -1,46 +0,0 @@ -package bootstrap - -import ( - "io" - - "github.com/nspcc-dev/neofs-api-go/service" -) - -// SignedData returns payload bytes of the request. -func (m Request) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m Request) SignedDataSize() (sz int) { - sz += m.GetType().Size() - - sz += m.GetState().Size() - - info := m.GetInfo() - sz += info.Size() - - return -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m Request) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetType().Bytes()) - - off += copy(p[off:], m.GetState().Bytes()) - - info := m.GetInfo() - // FIXME: implement and use stable functions - n, err := info.MarshalTo(p[off:]) - off += n - - return off, err -} diff --git a/bootstrap/sign_test.go b/bootstrap/sign_test.go deleted file mode 100644 index 3812130..0000000 --- a/bootstrap/sign_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package bootstrap - -import ( - "testing" - - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestRequestSign(t *testing.T) { - sk := test.DecodeKey(0) - - type sigType interface { - service.RequestData - service.SignKeyPairAccumulator - service.SignKeyPairSource - SetToken(*service.Token) - } - - items := []struct { - constructor func() sigType - payloadCorrupt []func(sigType) - }{ - { // Request - constructor: func() sigType { - return new(Request) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*Request) - - req.SetType(req.GetType() + 1) - }, - func(s sigType) { - req := s.(*Request) - - req.SetState(req.GetState() + 1) - }, - func(s sigType) { - req := s.(*Request) - - info := req.GetInfo() - info.Address += "1" - - req.SetInfo(info) - }, - }, - }, - } - - for _, item := range items { - { // token corruptions - v := item.constructor() - - token := new(service.Token) - v.SetToken(token) - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - token.SetSessionKey(append(token.GetSessionKey(), 1)) - - require.Error(t, service.VerifyRequestData(v)) - } - - { // payload corruptions - for _, corruption := range item.payloadCorrupt { - v := item.constructor() - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - corruption(v) - - require.Error(t, service.VerifyRequestData(v)) - } - } - } -} diff --git a/bootstrap/types.go b/bootstrap/types.go deleted file mode 100644 index 7ad3ec2..0000000 --- a/bootstrap/types.go +++ /dev/null @@ -1,137 +0,0 @@ -package bootstrap - -import ( - "bytes" - "encoding/binary" - "encoding/hex" - "strconv" - "strings" - - "github.com/golang/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/object" -) - -type ( - // NodeStatus is a bitwise status field of the node. - NodeStatus uint64 -) - -const ( - storageFullMask = 0x1 - - optionCapacity = "/Capacity:" - optionPrice = "/Price:" -) - -var ( - _ proto.Message = (*NodeInfo)(nil) - _ proto.Message = (*SpreadMap)(nil) -) - -var requestEndianness = binary.BigEndian - -// Equals checks whether two NodeInfo has same address. -func (m NodeInfo) Equals(n1 NodeInfo) bool { - return m.Address == n1.Address && bytes.Equal(m.PubKey, n1.PubKey) -} - -// Full checks if node has enough space for storing users objects. -func (n NodeStatus) Full() bool { - return n&storageFullMask > 0 -} - -// SetFull changes state of node to indicate if node has enough space for storing users objects. -// If value is true - there's not enough space. -func (n *NodeStatus) SetFull(value bool) { - switch value { - case true: - *n |= NodeStatus(storageFullMask) - case false: - *n &= NodeStatus(^uint64(storageFullMask)) - } -} - -// Price returns price in 1e-8*GAS/Megabyte per month. -// User set price in GAS/Terabyte per month. -func (m NodeInfo) Price() uint64 { - for i := range m.Options { - if strings.HasPrefix(m.Options[i], optionPrice) { - n, err := strconv.ParseFloat(m.Options[i][len(optionPrice):], 64) - if err != nil { - return 0 - } - return uint64(n*1e8) / uint64(object.UnitsMB) // UnitsMB == megabytes in 1 terabyte - } - } - return 0 -} - -// Capacity returns node's capacity as reported by user. -func (m NodeInfo) Capacity() uint64 { - for i := range m.Options { - if strings.HasPrefix(m.Options[i], optionCapacity) { - n, err := strconv.ParseUint(m.Options[i][len(optionCapacity):], 10, 64) - if err != nil { - return 0 - } - return n - } - } - return 0 -} - -// String returns string representation of NodeInfo. -func (m NodeInfo) String() string { - return "(NodeInfo)<" + - "Address:" + m.Address + - ", " + - "PublicKey:" + hex.EncodeToString(m.PubKey) + - ", " + - "Options: [" + strings.Join(m.Options, ",") + "]>" -} - -// String returns string representation of SpreadMap. -func (m SpreadMap) String() string { - result := make([]string, 0, len(m.NetMap)) - for i := range m.NetMap { - result = append(result, m.NetMap[i].String()) - } - return "(SpreadMap)<" + - "Epoch: " + strconv.FormatUint(m.Epoch, 10) + - ", " + - "Netmap: [" + strings.Join(result, ",") + "]>" -} - -// GetType is a Type field getter. -func (m Request) GetType() NodeType { - return m.Type -} - -// SetType is a Type field setter. -func (m *Request) SetType(t NodeType) { - m.Type = t -} - -// SetState is a State field setter. -func (m *Request) SetState(state Request_State) { - m.State = state -} - -// SetInfo is an Info field getter. -func (m *Request) SetInfo(info NodeInfo) { - m.Info = info -} - -// Size returns the size necessary for a binary representation of the state. -func (x Request_State) Size() int { - return 4 -} - -// Bytes returns a binary representation of the state. -func (x Request_State) Bytes() []byte { - data := make([]byte, x.Size()) - - requestEndianness.PutUint32(data, uint32(x)) - - return data -} diff --git a/bootstrap/types.pb.go b/bootstrap/types.pb.go deleted file mode 100644 index fcd8848..0000000 --- a/bootstrap/types.pb.go +++ /dev/null @@ -1,705 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: bootstrap/types.proto - -package bootstrap - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -type SpreadMap struct { - // Epoch is current epoch for netmap - Epoch uint64 `protobuf:"varint,1,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - // NetMap is a set of NodeInfos - NetMap []NodeInfo `protobuf:"bytes,2,rep,name=NetMap,proto3" json:"NetMap"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SpreadMap) Reset() { *m = SpreadMap{} } -func (*SpreadMap) ProtoMessage() {} -func (*SpreadMap) Descriptor() ([]byte, []int) { - return fileDescriptor_423083266369adee, []int{0} -} -func (m *SpreadMap) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SpreadMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SpreadMap) XXX_Merge(src proto.Message) { - xxx_messageInfo_SpreadMap.Merge(m, src) -} -func (m *SpreadMap) XXX_Size() int { - return m.Size() -} -func (m *SpreadMap) XXX_DiscardUnknown() { - xxx_messageInfo_SpreadMap.DiscardUnknown(m) -} - -var xxx_messageInfo_SpreadMap proto.InternalMessageInfo - -func (m *SpreadMap) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *SpreadMap) GetNetMap() []NodeInfo { - if m != nil { - return m.NetMap - } - return nil -} - -type NodeInfo struct { - // Address is a node [multi-address](https://github.com/multiformats/multiaddr) - Address string `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` - // PubKey is a compressed public key representation in bytes - PubKey []byte `protobuf:"bytes,2,opt,name=PubKey,proto3" json:"pubkey,omitempty"` - // Options is set of node optional information, such as storage capacity, node location, price and etc - Options []string `protobuf:"bytes,3,rep,name=Options,proto3" json:"options,omitempty"` - // Status is bitmap status of the node - Status NodeStatus `protobuf:"varint,4,opt,name=Status,proto3,customtype=NodeStatus" json:"status"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NodeInfo) Reset() { *m = NodeInfo{} } -func (*NodeInfo) ProtoMessage() {} -func (*NodeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_423083266369adee, []int{1} -} -func (m *NodeInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *NodeInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodeInfo.Merge(m, src) -} -func (m *NodeInfo) XXX_Size() int { - return m.Size() -} -func (m *NodeInfo) XXX_DiscardUnknown() { - xxx_messageInfo_NodeInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_NodeInfo proto.InternalMessageInfo - -func (m *NodeInfo) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *NodeInfo) GetPubKey() []byte { - if m != nil { - return m.PubKey - } - return nil -} - -func (m *NodeInfo) GetOptions() []string { - if m != nil { - return m.Options - } - return nil -} - -func init() { - proto.RegisterType((*SpreadMap)(nil), "bootstrap.SpreadMap") - proto.RegisterType((*NodeInfo)(nil), "bootstrap.NodeInfo") -} - -func init() { proto.RegisterFile("bootstrap/types.proto", fileDescriptor_423083266369adee) } - -var fileDescriptor_423083266369adee = []byte{ - // 370 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xdf, 0x8a, 0x9b, 0x40, - 0x14, 0xc6, 0x9d, 0x24, 0x35, 0x75, 0xd2, 0x8b, 0xd6, 0x24, 0x20, 0xa5, 0xa8, 0x04, 0x0a, 0x42, - 0xa3, 0xd2, 0x3f, 0x2f, 0x10, 0xa1, 0x85, 0x50, 0x92, 0x06, 0xd3, 0xab, 0xde, 0x14, 0xff, 0x4c, - 0x8c, 0x2c, 0xf1, 0x0c, 0xce, 0xb8, 0xe0, 0xdd, 0x3e, 0xc6, 0x3e, 0xc3, 0x3e, 0xc8, 0x92, 0xcb, - 0xbd, 0x0c, 0x7b, 0x21, 0xbb, 0xee, 0x9d, 0x4f, 0xb1, 0x44, 0x63, 0xc8, 0xdd, 0xf9, 0xbe, 0xef, - 0x37, 0x33, 0x67, 0xce, 0xc1, 0x63, 0x1f, 0x80, 0x33, 0x9e, 0x7a, 0xd4, 0xe6, 0x39, 0x25, 0xcc, - 0xa2, 0x29, 0x70, 0x90, 0xa5, 0xb3, 0xfd, 0xd1, 0x8c, 0x62, 0xbe, 0xcd, 0x7c, 0x2b, 0x80, 0x9d, - 0x1d, 0x41, 0x04, 0x76, 0x4d, 0xf8, 0xd9, 0xa6, 0x56, 0xb5, 0xa8, 0xab, 0xe6, 0xe4, 0xe4, 0x2f, - 0x96, 0xd6, 0x34, 0x25, 0x5e, 0xb8, 0xf0, 0xa8, 0x3c, 0xc2, 0x6f, 0x7e, 0x52, 0x08, 0xb6, 0x0a, - 0xd2, 0x91, 0xd1, 0x73, 0x1b, 0x21, 0x7f, 0xc5, 0xe2, 0x92, 0xf0, 0x85, 0x47, 0x95, 0x8e, 0xde, - 0x35, 0x06, 0xdf, 0x86, 0xd6, 0xf9, 0x35, 0x6b, 0x09, 0x21, 0x99, 0x27, 0x1b, 0x70, 0x7a, 0xfb, - 0x42, 0x13, 0xdc, 0x13, 0x38, 0xb9, 0x47, 0xf8, 0x6d, 0x1b, 0xc9, 0x9f, 0x71, 0x7f, 0x16, 0x86, - 0x29, 0x61, 0xac, 0xbe, 0x57, 0x72, 0x06, 0x55, 0xa1, 0xf5, 0xbd, 0xc6, 0x72, 0xdb, 0x4c, 0x9e, - 0x62, 0x71, 0x95, 0xf9, 0xbf, 0x49, 0xae, 0x74, 0x74, 0x64, 0xbc, 0x73, 0x46, 0x55, 0xa1, 0xbd, - 0xa7, 0x99, 0x7f, 0x45, 0xf2, 0x29, 0xec, 0x62, 0x4e, 0x76, 0x94, 0xe7, 0xee, 0x89, 0x91, 0x6d, - 0xdc, 0xff, 0x43, 0x79, 0x0c, 0x09, 0x53, 0xba, 0x7a, 0xd7, 0x90, 0x9c, 0x71, 0x55, 0x68, 0x1f, - 0xa0, 0xb1, 0x2e, 0xf8, 0x96, 0x92, 0x7f, 0x60, 0x71, 0xcd, 0x3d, 0x9e, 0x31, 0xa5, 0x77, 0xfc, - 0x9c, 0xf3, 0xe9, 0xd8, 0xf0, 0x63, 0xa1, 0xe1, 0x63, 0x9f, 0x4d, 0x52, 0x15, 0x9a, 0xc8, 0xea, - 0xca, 0x3d, 0xb1, 0xce, 0xff, 0xc3, 0xb3, 0x2a, 0xdc, 0x94, 0xaa, 0xb0, 0x2f, 0x55, 0xf4, 0x50, - 0xaa, 0xe8, 0x50, 0xaa, 0xe8, 0xa9, 0x54, 0xd1, 0xed, 0x8b, 0x2a, 0xfc, 0xfb, 0x72, 0x31, 0xeb, - 0x84, 0xd1, 0x20, 0x30, 0x43, 0x72, 0x6d, 0x27, 0x04, 0x36, 0xcc, 0xf4, 0x68, 0x6c, 0x46, 0x60, - 0x9f, 0x47, 0x75, 0xd7, 0x19, 0x2e, 0x09, 0xfc, 0x5a, 0x5b, 0xb3, 0xd5, 0xdc, 0x72, 0x5a, 0xd7, - 0x17, 0xeb, 0x35, 0x7c, 0x7f, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xef, 0x9f, 0x22, 0x25, 0xd9, 0x01, - 0x00, 0x00, -} - -func (m *SpreadMap) 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 *SpreadMap) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SpreadMap) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.NetMap) > 0 { - for iNdEx := len(m.NetMap) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.NetMap[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.Epoch != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *NodeInfo) 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 *NodeInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Status != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x20 - } - if len(m.Options) > 0 { - for iNdEx := len(m.Options) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Options[iNdEx]) - copy(dAtA[i:], m.Options[iNdEx]) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Options[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.PubKey) > 0 { - i -= len(m.PubKey) - copy(dAtA[i:], m.PubKey) - i = encodeVarintTypes(dAtA, i, uint64(len(m.PubKey))) - i-- - dAtA[i] = 0x12 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *SpreadMap) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != 0 { - n += 1 + sovTypes(uint64(m.Epoch)) - } - if len(m.NetMap) > 0 { - for _, e := range m.NetMap { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *NodeInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.PubKey) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if len(m.Options) > 0 { - for _, s := range m.Options { - l = len(s) - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.Status != 0 { - n += 1 + sovTypes(uint64(m.Status)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *SpreadMap) 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 ErrIntOverflowTypes - } - 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: SpreadMap: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SpreadMap: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NetMap", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NetMap = append(m.NetMap, NodeInfo{}) - if err := m.NetMap[len(m.NetMap)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NodeInfo) 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 ErrIntOverflowTypes - } - 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: NodeInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NodeInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PubKey = append(m.PubKey[:0], dAtA[iNdEx:postIndex]...) - if m.PubKey == nil { - m.PubKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Options = append(m.Options, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= NodeStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/bootstrap/types.proto b/bootstrap/types.proto deleted file mode 100644 index 4ef0fff..0000000 --- a/bootstrap/types.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package bootstrap; -option go_package = "github.com/nspcc-dev/neofs-api-go/bootstrap"; -option csharp_namespace = "NeoFS.API.Bootstrap"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -option (gogoproto.stringer_all) = false; -option (gogoproto.goproto_stringer_all) = false; - -message SpreadMap { - // Epoch is current epoch for netmap - uint64 Epoch = 1; - // NetMap is a set of NodeInfos - repeated NodeInfo NetMap = 2 [(gogoproto.nullable) = false]; -} - -message NodeInfo { - // Address is a node [multi-address](https://github.com/multiformats/multiaddr) - string Address = 1 [(gogoproto.jsontag) = "address"]; - // PubKey is a compressed public key representation in bytes - bytes PubKey = 2 [(gogoproto.jsontag) = "pubkey,omitempty"]; - // Options is set of node optional information, such as storage capacity, node location, price and etc - repeated string Options = 3 [(gogoproto.jsontag) = "options,omitempty"]; - // Status is bitmap status of the node - uint64 Status = 4 [(gogoproto.jsontag) = "status", (gogoproto.nullable) = false, (gogoproto.customtype) = "NodeStatus"]; -} diff --git a/bootstrap/types_test.go b/bootstrap/types_test.go deleted file mode 100644 index 20b1b1a..0000000 --- a/bootstrap/types_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package bootstrap - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestRequestGettersSetters(t *testing.T) { - t.Run("type", func(t *testing.T) { - rt := NodeType(1) - m := new(Request) - - m.SetType(rt) - - require.Equal(t, rt, m.GetType()) - }) - - t.Run("state", func(t *testing.T) { - st := Request_State(1) - m := new(Request) - - m.SetState(st) - - require.Equal(t, st, m.GetState()) - }) - - t.Run("info", func(t *testing.T) { - info := NodeInfo{ - Address: "some address", - } - - m := new(Request) - - m.SetInfo(info) - - require.Equal(t, info, m.GetInfo()) - }) -} diff --git a/chain/address.go b/chain/address.go deleted file mode 100644 index 0a56b8e..0000000 --- a/chain/address.go +++ /dev/null @@ -1,30 +0,0 @@ -package chain - -import ( - "crypto/ecdsa" - - "github.com/nspcc-dev/neo-go/pkg/crypto/keys" -) - -// WalletAddress implements NEO address. -type WalletAddress [AddressLength]byte - -const ( - // AddressLength contains size of address, - // 1 byte of address version + 20 bytes of ScriptHash + 4 bytes of checksum. - AddressLength = 25 -) - -// KeyToAddress returns NEO address composed from public key. -func KeyToAddress(key *ecdsa.PublicKey) string { - if key == nil { - return "" - } - - neoPublicKey := keys.PublicKey{ - X: key.X, - Y: key.Y, - } - - return neoPublicKey.Address() -} diff --git a/chain/address_test.go b/chain/address_test.go deleted file mode 100644 index a998a11..0000000 --- a/chain/address_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package chain - -import ( - "encoding/hex" - "testing" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/stretchr/testify/require" -) - -type addressTestCase struct { - name string - publicKey string - wallet string -} - -func TestKeyToAddress(t *testing.T) { - tests := []addressTestCase{ - { - "nil key", - "", - "", - }, - { - "correct key", - "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", - "NgzuJWWGVEwFGsRrgzj8knswEYRJrTe7sm", - }, - } - - for i := range tests { - t.Run(tests[i].name, func(t *testing.T) { - data, err := hex.DecodeString(tests[i].publicKey) - require.NoError(t, err) - - key := crypto.UnmarshalPublicKey(data) - - require.Equal(t, tests[i].wallet, KeyToAddress(key)) - }) - } -} diff --git a/container/service.go b/container/service.go deleted file mode 100644 index 2f36dc1..0000000 --- a/container/service.go +++ /dev/null @@ -1,60 +0,0 @@ -package container - -import ( - "bytes" - "encoding/binary" - - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/pkg/errors" -) - -type ( - // CID type alias. - CID = refs.CID - // UUID type alias. - UUID = refs.UUID - // OwnerID type alias. - OwnerID = refs.OwnerID - // MessageID type alias. - MessageID = refs.MessageID -) - -const ( - // ErrNotFound is raised when container could not be found. - ErrNotFound = internal.Error("could not find container") -) - -// PrepareData prepares bytes representation of PutRequest to satisfy SignedRequest interface. -func (m *PutRequest) PrepareData() ([]byte, error) { - var ( - err error - buf = new(bytes.Buffer) - capBytes = make([]byte, 8) - aclBytes = make([]byte, 4) - ) - - binary.BigEndian.PutUint64(capBytes, m.Capacity) - binary.BigEndian.PutUint32(capBytes, m.BasicACL) - - if _, err = buf.Write(m.MessageID.Bytes()); err != nil { - return nil, errors.Wrap(err, "could not write message id") - } else if _, err = buf.Write(capBytes); err != nil { - return nil, errors.Wrap(err, "could not write capacity") - } else if _, err = buf.Write(m.OwnerID.Bytes()); err != nil { - return nil, errors.Wrap(err, "could not write pub") - } else if data, err := m.Rules.Marshal(); err != nil { - return nil, errors.Wrap(err, "could not marshal placement") - } else if _, err = buf.Write(data); err != nil { - return nil, errors.Wrap(err, "could not write placement") - } else if _, err = buf.Write(aclBytes); err != nil { - return nil, errors.Wrap(err, "could not write basic acl") - } - - return buf.Bytes(), nil -} - -// PrepareData prepares bytes representation of DeleteRequest to satisfy SignedRequest interface. -func (m *DeleteRequest) PrepareData() ([]byte, error) { - return m.CID.Bytes(), nil -} diff --git a/container/service.pb.go b/container/service.pb.go deleted file mode 100644 index f49f79f..0000000 --- a/container/service.pb.go +++ /dev/null @@ -1,3733 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: container/service.proto - -package container - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - service "github.com/nspcc-dev/neofs-api-go/service" - netmap "github.com/nspcc-dev/netmap" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type PutRequest struct { - // MessageID is a nonce for uniq container id calculation - MessageID MessageID `protobuf:"bytes,1,opt,name=MessageID,proto3,customtype=MessageID" json:"MessageID"` - // Capacity defines amount of data that can be stored in the container (doesn't used for now). - Capacity uint64 `protobuf:"varint,2,opt,name=Capacity,proto3" json:"Capacity,omitempty"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,3,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Rules define storage policy for the object inside the container. - Rules netmap.PlacementRule `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules"` - // BasicACL of the container. - BasicACL uint32 `protobuf:"varint,5,opt,name=BasicACL,proto3" json:"BasicACL,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutRequest) Reset() { *m = PutRequest{} } -func (m *PutRequest) String() string { return proto.CompactTextString(m) } -func (*PutRequest) ProtoMessage() {} -func (*PutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{0} -} -func (m *PutRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutRequest.Merge(m, src) -} -func (m *PutRequest) XXX_Size() int { - return m.Size() -} -func (m *PutRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PutRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PutRequest proto.InternalMessageInfo - -func (m *PutRequest) GetCapacity() uint64 { - if m != nil { - return m.Capacity - } - return 0 -} - -func (m *PutRequest) GetRules() netmap.PlacementRule { - if m != nil { - return m.Rules - } - return netmap.PlacementRule{} -} - -func (m *PutRequest) GetBasicACL() uint32 { - if m != nil { - return m.BasicACL - } - return 0 -} - -type PutResponse struct { - // CID (container id) is a SHA256 hash of the container structure - CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutResponse) Reset() { *m = PutResponse{} } -func (m *PutResponse) String() string { return proto.CompactTextString(m) } -func (*PutResponse) ProtoMessage() {} -func (*PutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{1} -} -func (m *PutResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutResponse.Merge(m, src) -} -func (m *PutResponse) XXX_Size() int { - return m.Size() -} -func (m *PutResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PutResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PutResponse proto.InternalMessageInfo - -type DeleteRequest struct { - // CID (container id) is a SHA256 hash of the container structure - CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{2} -} -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return m.Size() -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -// DeleteResponse is empty because delete operation is asynchronous and done -// via consensus in inner ring nodes -type DeleteResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{3} -} -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return m.Size() -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -type GetRequest struct { - // CID (container id) is a SHA256 hash of the container structure - CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{4} -} -func (m *GetRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRequest.Merge(m, src) -} -func (m *GetRequest) XXX_Size() int { - return m.Size() -} -func (m *GetRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRequest proto.InternalMessageInfo - -type GetResponse struct { - // Container is a structure that contains placement rules and owner id - Container *Container `protobuf:"bytes,1,opt,name=Container,proto3" json:"Container,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{5} -} -func (m *GetResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetResponse.Merge(m, src) -} -func (m *GetResponse) XXX_Size() int { - return m.Size() -} -func (m *GetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetResponse proto.InternalMessageInfo - -func (m *GetResponse) GetContainer() *Container { - if m != nil { - return m.Container - } - return nil -} - -type ListRequest struct { - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{6} -} -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return m.Size() -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -type ListResponse struct { - // CID (container id) is list of SHA256 hashes of the container structures - CID []CID `protobuf:"bytes,1,rep,name=CID,proto3,customtype=CID" json:"CID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{7} -} -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return m.Size() -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -type ExtendedACLKey struct { - // ID (container id) is a SHA256 hash of the container structure - ID CID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=CID" json:"ID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ExtendedACLKey) Reset() { *m = ExtendedACLKey{} } -func (m *ExtendedACLKey) String() string { return proto.CompactTextString(m) } -func (*ExtendedACLKey) ProtoMessage() {} -func (*ExtendedACLKey) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{8} -} -func (m *ExtendedACLKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExtendedACLKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ExtendedACLKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExtendedACLKey.Merge(m, src) -} -func (m *ExtendedACLKey) XXX_Size() int { - return m.Size() -} -func (m *ExtendedACLKey) XXX_DiscardUnknown() { - xxx_messageInfo_ExtendedACLKey.DiscardUnknown(m) -} - -var xxx_messageInfo_ExtendedACLKey proto.InternalMessageInfo - -type ExtendedACLValue struct { - // EACL carries binary representation of the table of extended ACL rules - EACL []byte `protobuf:"bytes,1,opt,name=EACL,proto3" json:"EACL,omitempty"` - // Signature carries EACL field signature - Signature []byte `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ExtendedACLValue) Reset() { *m = ExtendedACLValue{} } -func (m *ExtendedACLValue) String() string { return proto.CompactTextString(m) } -func (*ExtendedACLValue) ProtoMessage() {} -func (*ExtendedACLValue) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{9} -} -func (m *ExtendedACLValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExtendedACLValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ExtendedACLValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExtendedACLValue.Merge(m, src) -} -func (m *ExtendedACLValue) XXX_Size() int { - return m.Size() -} -func (m *ExtendedACLValue) XXX_DiscardUnknown() { - xxx_messageInfo_ExtendedACLValue.DiscardUnknown(m) -} - -var xxx_messageInfo_ExtendedACLValue proto.InternalMessageInfo - -func (m *ExtendedACLValue) GetEACL() []byte { - if m != nil { - return m.EACL - } - return nil -} - -func (m *ExtendedACLValue) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type SetExtendedACLRequest struct { - // Key carries key to extended ACL information - ExtendedACLKey `protobuf:"bytes,1,opt,name=Key,proto3,embedded=Key" json:"Key"` - // Value carries extended ACL information - ExtendedACLValue `protobuf:"bytes,2,opt,name=Value,proto3,embedded=Value" json:"Value"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetExtendedACLRequest) Reset() { *m = SetExtendedACLRequest{} } -func (m *SetExtendedACLRequest) String() string { return proto.CompactTextString(m) } -func (*SetExtendedACLRequest) ProtoMessage() {} -func (*SetExtendedACLRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{10} -} -func (m *SetExtendedACLRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SetExtendedACLRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SetExtendedACLRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetExtendedACLRequest.Merge(m, src) -} -func (m *SetExtendedACLRequest) XXX_Size() int { - return m.Size() -} -func (m *SetExtendedACLRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SetExtendedACLRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SetExtendedACLRequest proto.InternalMessageInfo - -type SetExtendedACLResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetExtendedACLResponse) Reset() { *m = SetExtendedACLResponse{} } -func (m *SetExtendedACLResponse) String() string { return proto.CompactTextString(m) } -func (*SetExtendedACLResponse) ProtoMessage() {} -func (*SetExtendedACLResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{11} -} -func (m *SetExtendedACLResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SetExtendedACLResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SetExtendedACLResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetExtendedACLResponse.Merge(m, src) -} -func (m *SetExtendedACLResponse) XXX_Size() int { - return m.Size() -} -func (m *SetExtendedACLResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SetExtendedACLResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SetExtendedACLResponse proto.InternalMessageInfo - -type GetExtendedACLRequest struct { - // Key carries key to extended ACL information - ExtendedACLKey `protobuf:"bytes,1,opt,name=Key,proto3,embedded=Key" json:"Key"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetExtendedACLRequest) Reset() { *m = GetExtendedACLRequest{} } -func (m *GetExtendedACLRequest) String() string { return proto.CompactTextString(m) } -func (*GetExtendedACLRequest) ProtoMessage() {} -func (*GetExtendedACLRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{12} -} -func (m *GetExtendedACLRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetExtendedACLRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetExtendedACLRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetExtendedACLRequest.Merge(m, src) -} -func (m *GetExtendedACLRequest) XXX_Size() int { - return m.Size() -} -func (m *GetExtendedACLRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetExtendedACLRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetExtendedACLRequest proto.InternalMessageInfo - -type GetExtendedACLResponse struct { - // ACL carries extended ACL information - ExtendedACLValue `protobuf:"bytes,1,opt,name=ACL,proto3,embedded=ACL" json:"ACL"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetExtendedACLResponse) Reset() { *m = GetExtendedACLResponse{} } -func (m *GetExtendedACLResponse) String() string { return proto.CompactTextString(m) } -func (*GetExtendedACLResponse) ProtoMessage() {} -func (*GetExtendedACLResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1fa9d7ab2e7ae06, []int{13} -} -func (m *GetExtendedACLResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetExtendedACLResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetExtendedACLResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetExtendedACLResponse.Merge(m, src) -} -func (m *GetExtendedACLResponse) XXX_Size() int { - return m.Size() -} -func (m *GetExtendedACLResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetExtendedACLResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetExtendedACLResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*PutRequest)(nil), "container.PutRequest") - proto.RegisterType((*PutResponse)(nil), "container.PutResponse") - proto.RegisterType((*DeleteRequest)(nil), "container.DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "container.DeleteResponse") - proto.RegisterType((*GetRequest)(nil), "container.GetRequest") - proto.RegisterType((*GetResponse)(nil), "container.GetResponse") - proto.RegisterType((*ListRequest)(nil), "container.ListRequest") - proto.RegisterType((*ListResponse)(nil), "container.ListResponse") - proto.RegisterType((*ExtendedACLKey)(nil), "container.ExtendedACLKey") - proto.RegisterType((*ExtendedACLValue)(nil), "container.ExtendedACLValue") - proto.RegisterType((*SetExtendedACLRequest)(nil), "container.SetExtendedACLRequest") - proto.RegisterType((*SetExtendedACLResponse)(nil), "container.SetExtendedACLResponse") - proto.RegisterType((*GetExtendedACLRequest)(nil), "container.GetExtendedACLRequest") - proto.RegisterType((*GetExtendedACLResponse)(nil), "container.GetExtendedACLResponse") -} - -func init() { proto.RegisterFile("container/service.proto", fileDescriptor_e1fa9d7ab2e7ae06) } - -var fileDescriptor_e1fa9d7ab2e7ae06 = []byte{ - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x35, 0x45, 0xf9, 0xa1, 0x2b, 0xdb, 0x75, 0xa7, 0x96, 0x4d, 0xd3, 0xad, 0xac, 0x72, 0xa5, - 0x3e, 0x44, 0xa2, 0xaa, 0x0b, 0x17, 0x28, 0xba, 0xd0, 0xc3, 0x55, 0x05, 0xdb, 0xad, 0x4a, 0xa1, - 0x0e, 0x90, 0x1d, 0x45, 0x5d, 0x2b, 0x04, 0x24, 0x52, 0x21, 0x87, 0x4e, 0xf4, 0x0d, 0xf9, 0x81, - 0x00, 0xf9, 0x83, 0x04, 0xc8, 0x3a, 0x9f, 0xe0, 0x55, 0x60, 0x20, 0x9b, 0x20, 0x0b, 0x23, 0x50, - 0x7e, 0x24, 0xe0, 0xf0, 0x29, 0x59, 0xb6, 0xb3, 0x08, 0x20, 0x64, 0x23, 0xcc, 0xdc, 0x7b, 0xcf, - 0x99, 0xfb, 0x16, 0x61, 0x5b, 0xb7, 0x4c, 0xaa, 0x19, 0x26, 0xda, 0x8a, 0x83, 0xf6, 0xb9, 0xa1, - 0xa3, 0x3c, 0xb4, 0x2d, 0x6a, 0x91, 0x4c, 0xa4, 0x10, 0x49, 0xa0, 0x51, 0x06, 0x48, 0x35, 0x5f, - 0x2d, 0x6e, 0x86, 0xb2, 0x73, 0xb4, 0x8d, 0xb3, 0x51, 0x20, 0xcd, 0xc5, 0x6c, 0x74, 0x34, 0x44, - 0x27, 0x10, 0xff, 0xd8, 0x33, 0xe8, 0x03, 0xb7, 0x23, 0xeb, 0xd6, 0x40, 0x31, 0x9d, 0xa1, 0xae, - 0x97, 0xba, 0x78, 0xae, 0x98, 0x48, 0x07, 0xda, 0x50, 0x71, 0xb0, 0x8f, 0x3a, 0xb5, 0xec, 0xc0, - 0xb6, 0x94, 0xb0, 0xed, 0x59, 0x3d, 0x4b, 0x61, 0xe2, 0x8e, 0x7b, 0xc6, 0x6e, 0xec, 0xc2, 0x4e, - 0xbe, 0xb9, 0xf4, 0x26, 0x05, 0xd0, 0x72, 0xa9, 0x8a, 0x0f, 0x5d, 0x74, 0x28, 0x51, 0x20, 0x73, - 0x82, 0x8e, 0xa3, 0xf5, 0xb0, 0x59, 0x17, 0xb8, 0x02, 0x57, 0x5c, 0xad, 0x7e, 0x7d, 0x71, 0xb5, - 0xb7, 0xf0, 0xee, 0x6a, 0x2f, 0x56, 0xa8, 0xf1, 0x91, 0x88, 0xb0, 0x52, 0xd3, 0x86, 0x9a, 0x6e, - 0xd0, 0x91, 0x90, 0x2a, 0x70, 0xc5, 0xb4, 0x1a, 0xdd, 0xc9, 0x0f, 0xb0, 0xfc, 0xef, 0x23, 0x13, - 0xed, 0x66, 0x5d, 0xe0, 0x19, 0xd5, 0x57, 0x01, 0x55, 0x28, 0x56, 0xc3, 0x03, 0xf9, 0x05, 0x16, - 0x6d, 0xb7, 0x8f, 0x8e, 0x90, 0x2e, 0x70, 0xc5, 0x6c, 0x39, 0x27, 0xfb, 0xc1, 0xc9, 0xad, 0xbe, - 0xa6, 0xe3, 0x00, 0x4d, 0xaa, 0xba, 0x7d, 0xac, 0xa6, 0x3d, 0xbc, 0xea, 0x5b, 0x7a, 0x2f, 0x57, - 0x35, 0xc7, 0xd0, 0x2b, 0xb5, 0x63, 0x61, 0xb1, 0xc0, 0x15, 0xd7, 0xd4, 0xe8, 0x4e, 0x7e, 0x87, - 0xf4, 0x09, 0x52, 0x4d, 0xe8, 0x30, 0x36, 0x51, 0x0e, 0x4b, 0x13, 0x84, 0xe9, 0xe9, 0xfe, 0x46, - 0xad, 0x8b, 0x76, 0x75, 0xc5, 0xa3, 0xbc, 0xbc, 0xda, 0xe3, 0x54, 0x86, 0x20, 0x75, 0x58, 0x3a, - 0x65, 0x15, 0x11, 0x74, 0x86, 0x95, 0xa6, 0xb1, 0x4c, 0x6b, 0xe8, 0x1a, 0x35, 0x2c, 0xf3, 0x1a, - 0x47, 0x80, 0x95, 0x7e, 0x86, 0x2c, 0x4b, 0xaa, 0x33, 0xb4, 0x4c, 0x07, 0xc9, 0x77, 0xc0, 0xd7, - 0xa2, 0x7c, 0x66, 0x83, 0x24, 0x78, 0x22, 0xd5, 0xfb, 0x91, 0x5e, 0x72, 0xb0, 0x56, 0xc7, 0x3e, - 0x52, 0x0c, 0xcb, 0x70, 0x3b, 0x60, 0xee, 0xe1, 0x6d, 0xc0, 0x7a, 0xe8, 0xaf, 0x1f, 0xa1, 0xf4, - 0x82, 0x03, 0x68, 0x20, 0xfd, 0x42, 0xfc, 0xaf, 0x40, 0x96, 0x39, 0x1b, 0x94, 0xa7, 0x0c, 0x99, - 0x5a, 0x38, 0x77, 0xcc, 0xe7, 0x6c, 0x79, 0x53, 0x8e, 0x26, 0x51, 0x8e, 0x74, 0x6a, 0x6c, 0x26, - 0xbd, 0xe2, 0x20, 0x7b, 0x6c, 0x38, 0x51, 0xc4, 0x89, 0x5e, 0xe7, 0xee, 0xe8, 0xf5, 0x79, 0x47, - 0x5f, 0x82, 0x55, 0xdf, 0xf3, 0xe9, 0xee, 0xe4, 0x67, 0x76, 0x67, 0x09, 0xd6, 0x0f, 0x1f, 0x53, - 0x34, 0xbb, 0xd8, 0xad, 0xd4, 0x8e, 0x8f, 0x70, 0x44, 0x76, 0x21, 0x35, 0xbb, 0xb8, 0xa9, 0x66, - 0x5d, 0xaa, 0xc3, 0x46, 0xc2, 0xfc, 0x54, 0xeb, 0xbb, 0x48, 0x08, 0xa4, 0x0f, 0xbd, 0x31, 0x65, - 0x10, 0x95, 0x9d, 0xc9, 0xb7, 0x90, 0x69, 0x1b, 0x3d, 0x53, 0xa3, 0xae, 0x8d, 0x6c, 0x73, 0xac, - 0xaa, 0xb1, 0x40, 0x7a, 0x92, 0x82, 0x5c, 0x1b, 0x69, 0x82, 0x29, 0x4c, 0xf4, 0x6f, 0xc0, 0x1f, - 0xe1, 0x28, 0x28, 0xd3, 0x4e, 0xa2, 0x4c, 0x93, 0x4e, 0x26, 0xe2, 0xf6, 0xec, 0xc9, 0x1f, 0xb0, - 0xc8, 0x7c, 0x61, 0x4f, 0x65, 0xcb, 0xbb, 0xb3, 0x81, 0xcc, 0x24, 0x01, 0xf5, 0x31, 0x73, 0xaf, - 0x98, 0x00, 0x5b, 0xd3, 0xc9, 0x08, 0xe6, 0xee, 0x35, 0x07, 0xb9, 0xc6, 0xe7, 0xcc, 0xd3, 0xbc, - 0x43, 0xfd, 0x0f, 0xb6, 0x1a, 0x33, 0x43, 0x25, 0x07, 0xc0, 0x87, 0x3d, 0xf4, 0xc9, 0xf5, 0xf3, - 0x10, 0xe5, 0x67, 0x3c, 0x2c, 0xb7, 0x7d, 0x57, 0xc8, 0x3e, 0xf0, 0x2d, 0x97, 0x92, 0x5c, 0x02, - 0x1e, 0xff, 0xfb, 0x89, 0x5b, 0xd3, 0xe2, 0xe0, 0xe9, 0x3f, 0x61, 0xc9, 0xdf, 0x77, 0x44, 0x48, - 0x58, 0x4c, 0xac, 0x6c, 0x71, 0x67, 0x86, 0x26, 0x80, 0xef, 0x03, 0xdf, 0xc0, 0xc9, 0x47, 0xe3, - 0x5d, 0x39, 0xf1, 0x68, 0x72, 0x2b, 0x1d, 0x40, 0xda, 0x1b, 0x53, 0x92, 0xd4, 0x27, 0x36, 0x8e, - 0xb8, 0x7d, 0x4d, 0x1e, 0x00, 0xff, 0x87, 0xf5, 0xc9, 0x6e, 0x21, 0x85, 0x84, 0xe9, 0xcc, 0xa9, - 0x12, 0xbf, 0xbf, 0xc5, 0x22, 0xa6, 0x6d, 0xdc, 0x4c, 0xdb, 0xb8, 0x93, 0x76, 0x76, 0x59, 0xab, - 0xf7, 0x2e, 0xc6, 0x79, 0xee, 0x72, 0x9c, 0xe7, 0xde, 0x8e, 0xf3, 0xdc, 0xfb, 0x71, 0x9e, 0x7b, - 0xfa, 0x21, 0xbf, 0x70, 0xff, 0xa7, 0x1b, 0xbe, 0x78, 0xac, 0x33, 0xa7, 0xa4, 0x0d, 0x8d, 0x52, - 0xcf, 0x52, 0x22, 0xe6, 0xe7, 0xa9, 0x6f, 0xfe, 0x41, 0xeb, 0xaf, 0xb6, 0x5c, 0x69, 0x35, 0xe3, - 0x65, 0xdd, 0x59, 0x62, 0x1f, 0x38, 0xbf, 0x7e, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x16, 0xc1, 0x2d, - 0xa9, 0xa2, 0x09, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ServiceClient interface { - // Put request proposes container to the inner ring nodes. They will - // accept new container if user has enough deposit. All containers - // are accepted by the consensus, therefore it is asynchronous process. - Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) - // Delete container removes it from the inner ring container storage. It - // also asynchronous process done by consensus. - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) - // Get container returns container instance - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) - // List returns all user's containers - List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) - // SetExtendedACL changes extended ACL rules of the container - SetExtendedACL(ctx context.Context, in *SetExtendedACLRequest, opts ...grpc.CallOption) (*SetExtendedACLResponse, error) - // GetExtendedACL returns extended ACL rules of the container - GetExtendedACL(ctx context.Context, in *GetExtendedACLRequest, opts ...grpc.CallOption) (*GetExtendedACLResponse, error) -} - -type serviceClient struct { - cc *grpc.ClientConn -} - -func NewServiceClient(cc *grpc.ClientConn) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) { - out := new(PutResponse) - err := c.cc.Invoke(ctx, "/container.Service/Put", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/container.Service/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - out := new(GetResponse) - err := c.cc.Invoke(ctx, "/container.Service/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { - out := new(ListResponse) - err := c.cc.Invoke(ctx, "/container.Service/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SetExtendedACL(ctx context.Context, in *SetExtendedACLRequest, opts ...grpc.CallOption) (*SetExtendedACLResponse, error) { - out := new(SetExtendedACLResponse) - err := c.cc.Invoke(ctx, "/container.Service/SetExtendedACL", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetExtendedACL(ctx context.Context, in *GetExtendedACLRequest, opts ...grpc.CallOption) (*GetExtendedACLResponse, error) { - out := new(GetExtendedACLResponse) - err := c.cc.Invoke(ctx, "/container.Service/GetExtendedACL", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -type ServiceServer interface { - // Put request proposes container to the inner ring nodes. They will - // accept new container if user has enough deposit. All containers - // are accepted by the consensus, therefore it is asynchronous process. - Put(context.Context, *PutRequest) (*PutResponse, error) - // Delete container removes it from the inner ring container storage. It - // also asynchronous process done by consensus. - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) - // Get container returns container instance - Get(context.Context, *GetRequest) (*GetResponse, error) - // List returns all user's containers - List(context.Context, *ListRequest) (*ListResponse, error) - // SetExtendedACL changes extended ACL rules of the container - SetExtendedACL(context.Context, *SetExtendedACLRequest) (*SetExtendedACLResponse, error) - // GetExtendedACL returns extended ACL rules of the container - GetExtendedACL(context.Context, *GetExtendedACLRequest) (*GetExtendedACLResponse, error) -} - -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { -} - -func (*UnimplementedServiceServer) Put(ctx context.Context, req *PutRequest) (*PutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") -} -func (*UnimplementedServiceServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedServiceServer) Get(ctx context.Context, req *GetRequest) (*GetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedServiceServer) List(ctx context.Context, req *ListRequest) (*ListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedServiceServer) SetExtendedACL(ctx context.Context, req *SetExtendedACLRequest) (*SetExtendedACLResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetExtendedACL not implemented") -} -func (*UnimplementedServiceServer) GetExtendedACL(ctx context.Context, req *GetExtendedACLRequest) (*GetExtendedACLResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetExtendedACL not implemented") -} - -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) -} - -func _Service_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Put(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/Put", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Put(ctx, req.(*PutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Get(ctx, req.(*GetRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).List(ctx, req.(*ListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_SetExtendedACL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetExtendedACLRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).SetExtendedACL(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/SetExtendedACL", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).SetExtendedACL(ctx, req.(*SetExtendedACLRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_GetExtendedACL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetExtendedACLRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).GetExtendedACL(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/container.Service/GetExtendedACL", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).GetExtendedACL(ctx, req.(*GetExtendedACLRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "container.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Put", - Handler: _Service_Put_Handler, - }, - { - MethodName: "Delete", - Handler: _Service_Delete_Handler, - }, - { - MethodName: "Get", - Handler: _Service_Get_Handler, - }, - { - MethodName: "List", - Handler: _Service_List_Handler, - }, - { - MethodName: "SetExtendedACL", - Handler: _Service_SetExtendedACL_Handler, - }, - { - MethodName: "GetExtendedACL", - Handler: _Service_GetExtendedACL_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "container/service.proto", -} - -func (m *PutRequest) 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 *PutRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.BasicACL != 0 { - i = encodeVarintService(dAtA, i, uint64(m.BasicACL)) - i-- - dAtA[i] = 0x28 - } - { - size, err := m.Rules.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.Capacity != 0 { - i = encodeVarintService(dAtA, i, uint64(m.Capacity)) - i-- - dAtA[i] = 0x10 - } - { - size := m.MessageID.Size() - i -= size - if _, err := m.MessageID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *PutResponse) 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 *PutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DeleteRequest) 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 *DeleteRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DeleteResponse) 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 *DeleteResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func (m *GetRequest) 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 *GetRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetResponse) 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 *GetResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Container != nil { - { - size, err := m.Container.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ListRequest) 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 *ListRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ListResponse) 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 *ListResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.CID) > 0 { - for iNdEx := len(m.CID) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.CID[iNdEx].Size() - i -= size - if _, err := m.CID[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExtendedACLKey) 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 *ExtendedACLKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExtendedACLKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExtendedACLValue) 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 *ExtendedACLValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExtendedACLValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintService(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.EACL) > 0 { - i -= len(m.EACL) - copy(dAtA[i:], m.EACL) - i = encodeVarintService(dAtA, i, uint64(len(m.EACL))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SetExtendedACLRequest) 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 *SetExtendedACLRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SetExtendedACLRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size, err := m.ExtendedACLValue.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.ExtendedACLKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *SetExtendedACLResponse) 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 *SetExtendedACLResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SetExtendedACLResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func (m *GetExtendedACLRequest) 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 *GetExtendedACLRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetExtendedACLRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size, err := m.ExtendedACLKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetExtendedACLResponse) 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 *GetExtendedACLResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetExtendedACLResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ExtendedACLValue.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PutRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.MessageID.Size() - n += 1 + l + sovService(uint64(l)) - if m.Capacity != 0 { - n += 1 + sovService(uint64(m.Capacity)) - } - l = m.OwnerID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.Rules.Size() - n += 1 + l + sovService(uint64(l)) - if m.BasicACL != 0 { - n += 1 + sovService(uint64(m.BasicACL)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CID.Size() - n += 1 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Container != nil { - l = m.Container.Size() - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ListRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ListResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.CID) > 0 { - for _, e := range m.CID { - l = e.Size() - n += 1 + l + sovService(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ExtendedACLKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ExtendedACLValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.EACL) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SetExtendedACLRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ExtendedACLKey.Size() - n += 1 + l + sovService(uint64(l)) - l = m.ExtendedACLValue.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SetExtendedACLResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetExtendedACLRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ExtendedACLKey.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetExtendedACLResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ExtendedACLValue.Size() - n += 1 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PutRequest) 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 ErrIntOverflowService - } - 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: PutRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MessageID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MessageID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Capacity", wireType) - } - m.Capacity = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Capacity |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Rules.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BasicACL", wireType) - } - m.BasicACL = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BasicACL |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutResponse) 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 ErrIntOverflowService - } - 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: PutResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteRequest) 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 ErrIntOverflowService - } - 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: DeleteRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteResponse) 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 ErrIntOverflowService - } - 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: DeleteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRequest) 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 ErrIntOverflowService - } - 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: GetRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetResponse) 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 ErrIntOverflowService - } - 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: GetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Container", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Container == nil { - m.Container = &Container{} - } - if err := m.Container.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ListRequest) 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 ErrIntOverflowService - } - 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: ListRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ListResponse) 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 ErrIntOverflowService - } - 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: ListResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ListResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v CID - m.CID = append(m.CID, v) - if err := m.CID[len(m.CID)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExtendedACLKey) 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 ErrIntOverflowService - } - 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: ExtendedACLKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExtendedACLKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExtendedACLValue) 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 ErrIntOverflowService - } - 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: ExtendedACLValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExtendedACLValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EACL", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EACL = append(m.EACL[:0], dAtA[iNdEx:postIndex]...) - if m.EACL == nil { - m.EACL = []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 ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - 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 := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SetExtendedACLRequest) 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 ErrIntOverflowService - } - 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: SetExtendedACLRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SetExtendedACLRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedACLKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExtendedACLKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedACLValue", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExtendedACLValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SetExtendedACLResponse) 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 ErrIntOverflowService - } - 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: SetExtendedACLResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SetExtendedACLResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetExtendedACLRequest) 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 ErrIntOverflowService - } - 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: GetExtendedACLRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetExtendedACLRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedACLKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExtendedACLKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetExtendedACLResponse) 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 ErrIntOverflowService - } - 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: GetExtendedACLResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetExtendedACLResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedACLValue", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExtendedACLValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/container/service.proto b/container/service.proto deleted file mode 100644 index b174052..0000000 --- a/container/service.proto +++ /dev/null @@ -1,146 +0,0 @@ -syntax = "proto3"; -package container; -option go_package = "github.com/nspcc-dev/neofs-api-go/container"; -option csharp_namespace = "NeoFS.API.Container"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "container/types.proto"; -import "github.com/nspcc-dev/netmap/selector.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Container service provides API for manipulating with the container. -service Service { - // Put request proposes container to the inner ring nodes. They will - // accept new container if user has enough deposit. All containers - // are accepted by the consensus, therefore it is asynchronous process. - rpc Put(PutRequest) returns (PutResponse); - - // Delete container removes it from the inner ring container storage. It - // also asynchronous process done by consensus. - rpc Delete(DeleteRequest) returns (DeleteResponse); - - // Get container returns container instance - rpc Get(GetRequest) returns (GetResponse); - - // List returns all user's containers - rpc List(ListRequest) returns (ListResponse); - - // SetExtendedACL changes extended ACL rules of the container - rpc SetExtendedACL(SetExtendedACLRequest) returns (SetExtendedACLResponse); - - // GetExtendedACL returns extended ACL rules of the container - rpc GetExtendedACL(GetExtendedACLRequest) returns (GetExtendedACLResponse); -} - -message PutRequest { - // MessageID is a nonce for uniq container id calculation - bytes MessageID = 1 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false]; - - // Capacity defines amount of data that can be stored in the container (doesn't used for now). - uint64 Capacity = 2; - - // OwnerID is a wallet address - bytes OwnerID = 3 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - - // Rules define storage policy for the object inside the container. - netmap.PlacementRule rules = 4 [(gogoproto.nullable) = false]; - - // BasicACL of the container. - uint32 BasicACL = 5; - - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message PutResponse { - // CID (container id) is a SHA256 hash of the container structure - bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; -} - -message DeleteRequest { - // CID (container id) is a SHA256 hash of the container structure - bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; - - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// DeleteResponse is empty because delete operation is asynchronous and done -// via consensus in inner ring nodes -message DeleteResponse { } - - -message GetRequest { - // CID (container id) is a SHA256 hash of the container structure - bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; - - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetResponse { - // Container is a structure that contains placement rules and owner id - container.Container Container = 1; -} - -message ListRequest { - // OwnerID is a wallet address - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message ListResponse { - // CID (container id) is list of SHA256 hashes of the container structures - repeated bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; -} - -message ExtendedACLKey { - // ID (container id) is a SHA256 hash of the container structure - bytes ID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; -} - -message ExtendedACLValue { - // EACL carries binary representation of the table of extended ACL rules - bytes EACL = 1; - // Signature carries EACL field signature - bytes Signature = 2; -} - -message SetExtendedACLRequest { - // Key carries key to extended ACL information - ExtendedACLKey Key = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // Value carries extended ACL information - ExtendedACLValue Value = 2 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message SetExtendedACLResponse {} - -message GetExtendedACLRequest { - // Key carries key to extended ACL information - ExtendedACLKey Key = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetExtendedACLResponse { - // ACL carries extended ACL information - ExtendedACLValue ACL = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} diff --git a/container/sign.go b/container/sign.go deleted file mode 100644 index f538f2d..0000000 --- a/container/sign.go +++ /dev/null @@ -1,194 +0,0 @@ -package container - -import ( - "encoding/binary" - "io" - - service "github.com/nspcc-dev/neofs-api-go/service" -) - -var requestEndianness = binary.BigEndian - -// SignedData returns payload bytes of the request. -func (m PutRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m PutRequest) SignedDataSize() (sz int) { - sz += m.GetMessageID().Size() - - sz += 8 - - sz += m.GetOwnerID().Size() - - rules := m.GetRules() - sz += rules.Size() - - sz += 4 - - return -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m PutRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetMessageID().Bytes()) - - requestEndianness.PutUint64(p[off:], m.GetCapacity()) - off += 8 - - off += copy(p[off:], m.GetOwnerID().Bytes()) - - rules := m.GetRules() - // FIXME: implement and use stable functions - n, err := rules.MarshalTo(p[off:]) - off += n - if err != nil { - return off, err - } - - requestEndianness.PutUint32(p[off:], m.GetBasicACL()) - off += 4 - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m DeleteRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m DeleteRequest) SignedDataSize() int { - return m.GetCID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m DeleteRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetCID().Bytes()) - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m GetRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m GetRequest) SignedDataSize() int { - return m.GetCID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetCID().Bytes()) - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m ListRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m ListRequest) SignedDataSize() int { - return m.GetOwnerID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m ListRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetOwnerID().Bytes()) - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m GetExtendedACLRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m GetExtendedACLRequest) SignedDataSize() int { - return m.GetID().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetExtendedACLRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetID().Bytes()) - - return off, nil -} - -// SignedData returns payload bytes of the request. -func (m SetExtendedACLRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m SetExtendedACLRequest) SignedDataSize() int { - return 0 + - m.GetID().Size() + - len(m.GetEACL()) + - len(m.GetSignature()) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m SetExtendedACLRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetID().Bytes()) - - off += copy(p[off:], m.GetEACL()) - - off += copy(p[off:], m.GetSignature()) - - return off, nil -} diff --git a/container/sign_test.go b/container/sign_test.go deleted file mode 100644 index d04a698..0000000 --- a/container/sign_test.go +++ /dev/null @@ -1,187 +0,0 @@ -package container - -import ( - "testing" - - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestRequestSign(t *testing.T) { - sk := test.DecodeKey(0) - - type sigType interface { - service.RequestData - service.SignKeyPairAccumulator - service.SignKeyPairSource - SetToken(*service.Token) - } - - items := []struct { - constructor func() sigType - payloadCorrupt []func(sigType) - }{ - { // PutRequest - constructor: func() sigType { - return new(PutRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*PutRequest) - - id := req.GetMessageID() - id[0]++ - - req.SetMessageID(id) - }, - func(s sigType) { - req := s.(*PutRequest) - - req.SetCapacity(req.GetCapacity() + 1) - }, - func(s sigType) { - req := s.(*PutRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - func(s sigType) { - req := s.(*PutRequest) - - rules := req.GetRules() - rules.ReplFactor++ - - req.SetRules(rules) - }, - func(s sigType) { - req := s.(*PutRequest) - - req.SetBasicACL(req.GetBasicACL() + 1) - }, - }, - }, - { // DeleteRequest - constructor: func() sigType { - return new(DeleteRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*DeleteRequest) - - cid := req.GetCID() - cid[0]++ - - req.SetCID(cid) - }, - }, - }, - { // GetRequest - constructor: func() sigType { - return new(GetRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*GetRequest) - - cid := req.GetCID() - cid[0]++ - - req.SetCID(cid) - }, - }, - }, - { // ListRequest - constructor: func() sigType { - return new(ListRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*ListRequest) - - owner := req.GetOwnerID() - owner[0]++ - - req.SetOwnerID(owner) - }, - }, - }, - { // GetExtendedACLRequest - constructor: func() sigType { - return new(GetExtendedACLRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*GetExtendedACLRequest) - - id := req.GetID() - id[0]++ - - req.SetID(id) - }, - }, - }, - { // SetExtendedACLRequest - constructor: func() sigType { - return new(SetExtendedACLRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*SetExtendedACLRequest) - - id := req.GetID() - id[0]++ - - req.SetID(id) - }, - func(s sigType) { - req := s.(*SetExtendedACLRequest) - - req.SetEACL( - append(req.GetEACL(), 1), - ) - }, - func(s sigType) { - req := s.(*SetExtendedACLRequest) - - req.SetSignature( - append(req.GetSignature(), 1), - ) - }, - }, - }, - } - - for _, item := range items { - { // token corruptions - v := item.constructor() - - token := new(service.Token) - v.SetToken(token) - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - token.SetSessionKey(append(token.GetSessionKey(), 1)) - - require.Error(t, service.VerifyRequestData(v)) - } - - { // payload corruptions - for _, corruption := range item.payloadCorrupt { - v := item.constructor() - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - corruption(v) - - require.Error(t, service.VerifyRequestData(v)) - } - } - } -} diff --git a/container/types.go b/container/types.go deleted file mode 100644 index be06b53..0000000 --- a/container/types.go +++ /dev/null @@ -1,188 +0,0 @@ -package container - -import ( - "bytes" - - "github.com/gogo/protobuf/proto" - "github.com/google/uuid" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/nspcc-dev/netmap" - "github.com/pkg/errors" -) - -var ( - _ internal.Custom = (*Container)(nil) - - emptySalt = (UUID{}).Bytes() - emptyOwner = (OwnerID{}).Bytes() -) - -// New creates new user container based on capacity, OwnerID, ACL and PlacementRules. -func New(cap uint64, owner OwnerID, acl uint32, rules netmap.PlacementRule) (*Container, error) { - if bytes.Equal(owner[:], emptyOwner) { - return nil, refs.ErrEmptyOwner - } else if cap == 0 { - return nil, refs.ErrEmptyCapacity - } - - salt, err := uuid.NewRandom() - if err != nil { - return nil, errors.Wrap(err, "could not create salt") - } - - return &Container{ - OwnerID: owner, - Salt: UUID(salt), - Capacity: cap, - Rules: rules, - BasicACL: acl, - }, nil -} - -// Bytes returns bytes representation of Container. -func (m *Container) Bytes() []byte { - data, err := m.Marshal() - if err != nil { - return nil - } - - return data -} - -// ID returns generated ContainerID based on Container (data). -func (m *Container) ID() (CID, error) { - if m.Empty() { - return CID{}, refs.ErrEmptyContainer - } - data, err := m.Marshal() - if err != nil { - return CID{}, err - } - - return refs.CIDForBytes(data), nil -} - -// Merge used by proto.Clone -func (m *Container) Merge(src proto.Message) { - if tmp, ok := src.(*Container); ok { - *m = *tmp - } -} - -// Empty checks that container is empty. -func (m *Container) Empty() bool { - return m.Capacity == 0 || bytes.Equal(m.Salt.Bytes(), emptySalt) || bytes.Equal(m.OwnerID.Bytes(), emptyOwner) -} - -// -- Test container definition -- // - -// NewTestContainer returns test container. -// WARNING: DON'T USE THIS OUTSIDE TESTS. -func NewTestContainer() (*Container, error) { - key := test.DecodeKey(0) - owner, err := refs.NewOwnerID(&key.PublicKey) - if err != nil { - return nil, err - } - return New(100, owner, 0xFFFFFFFF, netmap.PlacementRule{ - ReplFactor: 2, - SFGroups: []netmap.SFGroup{ - { - Selectors: []netmap.Select{ - {Key: "Country", Count: 1}, - {Key: netmap.NodesBucket, Count: 2}, - }, - Filters: []netmap.Filter{ - {Key: "Country", F: netmap.FilterIn("USA")}, - }, - }, - }, - }) -} - -// GetMessageID is a MessageID field getter. -func (m PutRequest) GetMessageID() MessageID { - return m.MessageID -} - -// SetMessageID is a MessageID field getter. -func (m *PutRequest) SetMessageID(id MessageID) { - m.MessageID = id -} - -// SetCapacity is a Capacity field setter. -func (m *PutRequest) SetCapacity(c uint64) { - m.Capacity = c -} - -// GetOwnerID is an OwnerID field getter. -func (m PutRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *PutRequest) SetOwnerID(owner OwnerID) { - m.OwnerID = owner -} - -// SetRules is a Rules field setter. -func (m *PutRequest) SetRules(rules netmap.PlacementRule) { - m.Rules = rules -} - -// SetBasicACL is a BasicACL field setter. -func (m *PutRequest) SetBasicACL(acl uint32) { - m.BasicACL = acl -} - -// GetCID is a CID field getter. -func (m DeleteRequest) GetCID() CID { - return m.CID -} - -// SetCID is a CID field setter. -func (m *DeleteRequest) SetCID(cid CID) { - m.CID = cid -} - -// GetCID is a CID field getter. -func (m GetRequest) GetCID() CID { - return m.CID -} - -// SetCID is a CID field setter. -func (m *GetRequest) SetCID(cid CID) { - m.CID = cid -} - -// GetOwnerID is an OwnerID field getter. -func (m ListRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *ListRequest) SetOwnerID(owner OwnerID) { - m.OwnerID = owner -} - -// GetID is an ID field getter. -func (m ExtendedACLKey) GetID() CID { - return m.ID -} - -// SetID is an ID field setter. -func (m *ExtendedACLKey) SetID(v CID) { - m.ID = v -} - -// SetEACL is an EACL field setter. -func (m *ExtendedACLValue) SetEACL(v []byte) { - m.EACL = v -} - -// SetSignature is a Signature field setter. -func (m *ExtendedACLValue) SetSignature(sig []byte) { - m.Signature = sig -} diff --git a/container/types.pb.go b/container/types.pb.go deleted file mode 100644 index 391656c..0000000 --- a/container/types.pb.go +++ /dev/null @@ -1,507 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: container/types.proto - -package container - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - netmap "github.com/nspcc-dev/netmap" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// The Container service definition. -type Container struct { - // OwnerID is a wallet address. - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Salt is a nonce for unique container id calculation. - Salt UUID `protobuf:"bytes,2,opt,name=Salt,proto3,customtype=UUID" json:"Salt"` - // Capacity defines amount of data that can be stored in the container (doesn't used for now). - Capacity uint64 `protobuf:"varint,3,opt,name=Capacity,proto3" json:"Capacity,omitempty"` - // Rules define storage policy for the object inside the container. - Rules netmap.PlacementRule `protobuf:"bytes,4,opt,name=Rules,proto3" json:"Rules"` - // BasicACL with access control rules for owner, system, others and - // permission bits for bearer token and extended ACL. - BasicACL uint32 `protobuf:"varint,5,opt,name=BasicACL,proto3" json:"BasicACL,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Container) Reset() { *m = Container{} } -func (m *Container) String() string { return proto.CompactTextString(m) } -func (*Container) ProtoMessage() {} -func (*Container) Descriptor() ([]byte, []int) { - return fileDescriptor_1432e52ab0b53e3e, []int{0} -} -func (m *Container) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Container) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Container) XXX_Merge(src proto.Message) { - xxx_messageInfo_Container.Merge(m, src) -} -func (m *Container) XXX_Size() int { - return m.Size() -} -func (m *Container) XXX_DiscardUnknown() { - xxx_messageInfo_Container.DiscardUnknown(m) -} - -var xxx_messageInfo_Container proto.InternalMessageInfo - -func (m *Container) GetCapacity() uint64 { - if m != nil { - return m.Capacity - } - return 0 -} - -func (m *Container) GetRules() netmap.PlacementRule { - if m != nil { - return m.Rules - } - return netmap.PlacementRule{} -} - -func (m *Container) GetBasicACL() uint32 { - if m != nil { - return m.BasicACL - } - return 0 -} - -func init() { - proto.RegisterType((*Container)(nil), "container.Container") -} - -func init() { proto.RegisterFile("container/types.proto", fileDescriptor_1432e52ab0b53e3e) } - -var fileDescriptor_1432e52ab0b53e3e = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0xce, 0xcf, 0x2b, - 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0xd2, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xe2, 0x84, 0x0b, 0x4b, 0x69, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, - 0xe7, 0xea, 0xe7, 0x15, 0x17, 0x24, 0x27, 0xeb, 0xa6, 0xa4, 0x96, 0xe9, 0xe7, 0xa5, 0x96, 0xe4, - 0x26, 0x16, 0xe8, 0x17, 0xa7, 0xe6, 0xa4, 0x26, 0x97, 0xe4, 0x17, 0x41, 0xb4, 0x49, 0xe9, 0x22, - 0xa9, 0x4d, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0x0b, 0x27, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, - 0x05, 0x51, 0xae, 0x74, 0x98, 0x91, 0x8b, 0xd3, 0x19, 0x66, 0x91, 0x90, 0x26, 0x17, 0xbb, 0x7f, - 0x79, 0x5e, 0x6a, 0x91, 0xa7, 0x8b, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x8f, 0x13, 0xff, 0x89, 0x7b, - 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0xc3, 0x84, 0x83, 0x60, 0x0c, 0x21, 0x05, 0x2e, 0x96, 0xe0, 0xc4, - 0x9c, 0x12, 0x09, 0x26, 0xb0, 0x3a, 0x1e, 0xa8, 0x3a, 0x96, 0xd0, 0x50, 0x4f, 0x97, 0x20, 0xb0, - 0x8c, 0x90, 0x14, 0x17, 0x87, 0x73, 0x62, 0x41, 0x62, 0x72, 0x66, 0x49, 0xa5, 0x04, 0xb3, 0x02, - 0xa3, 0x06, 0x4b, 0x10, 0x9c, 0x2f, 0x64, 0xc8, 0xc5, 0x1a, 0x54, 0x9a, 0x93, 0x5a, 0x2c, 0xc1, - 0xa2, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xaa, 0x07, 0xf1, 0x8c, 0x5e, 0x40, 0x4e, 0x62, 0x72, 0x6a, - 0x6e, 0x6a, 0x5e, 0x09, 0x48, 0xd6, 0x89, 0x05, 0x64, 0x6a, 0x10, 0x44, 0x25, 0xc8, 0x38, 0xa7, - 0xc4, 0xe2, 0xcc, 0x64, 0x47, 0x67, 0x1f, 0x09, 0x56, 0x05, 0x46, 0x0d, 0xde, 0x20, 0x38, 0xdf, - 0x29, 0xfc, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x6f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, - 0x48, 0x8e, 0x71, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x6d, 0x1c, 0xc1, 0x96, 0x9f, 0x56, 0xac, 0x9b, - 0x58, 0x90, 0xa9, 0x9b, 0x9e, 0xaf, 0x0f, 0x0f, 0xe3, 0x55, 0x4c, 0xc2, 0x7e, 0xa9, 0xf9, 0x6e, - 0xc1, 0x7a, 0x8e, 0x01, 0x9e, 0x7a, 0xf0, 0x00, 0x49, 0x62, 0x03, 0x87, 0x92, 0x31, 0x20, 0x00, - 0x00, 0xff, 0xff, 0xfc, 0x81, 0x55, 0xd6, 0xa4, 0x01, 0x00, 0x00, -} - -func (m *Container) 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 *Container) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Container) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.BasicACL != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.BasicACL)) - i-- - dAtA[i] = 0x28 - } - { - size, err := m.Rules.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.Capacity != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Capacity)) - i-- - dAtA[i] = 0x18 - } - { - size := m.Salt.Size() - i -= size - if _, err := m.Salt.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Container) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.Salt.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.Capacity != 0 { - n += 1 + sovTypes(uint64(m.Capacity)) - } - l = m.Rules.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.BasicACL != 0 { - n += 1 + sovTypes(uint64(m.BasicACL)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Container) 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 ErrIntOverflowTypes - } - 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: Container: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Container: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Salt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Capacity", wireType) - } - m.Capacity = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Capacity |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Rules.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BasicACL", wireType) - } - m.BasicACL = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BasicACL |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/container/types.proto b/container/types.proto deleted file mode 100644 index dc79bd3..0000000 --- a/container/types.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; -package container; -option go_package = "github.com/nspcc-dev/neofs-api-go/container"; -option csharp_namespace = "NeoFS.API.Container"; - -import "github.com/nspcc-dev/netmap/selector.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// The Container service definition. -message Container { - // OwnerID is a wallet address. - bytes OwnerID = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // Salt is a nonce for unique container id calculation. - bytes Salt = 2 [(gogoproto.customtype) = "UUID", (gogoproto.nullable) = false]; - // Capacity defines amount of data that can be stored in the container (doesn't used for now). - uint64 Capacity = 3; - // Rules define storage policy for the object inside the container. - netmap.PlacementRule Rules = 4 [(gogoproto.nullable) = false]; - // BasicACL with access control rules for owner, system, others and - // permission bits for bearer token and extended ACL. - uint32 BasicACL = 5; -} diff --git a/container/types_test.go b/container/types_test.go deleted file mode 100644 index 76bbe1c..0000000 --- a/container/types_test.go +++ /dev/null @@ -1,162 +0,0 @@ -package container - -import ( - "testing" - - "github.com/gogo/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/nspcc-dev/netmap" - "github.com/stretchr/testify/require" -) - -func TestCID(t *testing.T) { - t.Run("check that marshal/unmarshal works like expected", func(t *testing.T) { - var ( - c2 Container - cid2 CID - key = test.DecodeKey(0) - ) - - rules := netmap.PlacementRule{ - ReplFactor: 2, - SFGroups: []netmap.SFGroup{ - { - Selectors: []netmap.Select{ - {Key: "Country", Count: 1}, - {Key: netmap.NodesBucket, Count: 2}, - }, - Filters: []netmap.Filter{ - {Key: "Country", F: netmap.FilterIn("USA")}, - }, - }, - }, - } - - owner, err := refs.NewOwnerID(&key.PublicKey) - require.NoError(t, err) - - c1, err := New(10, owner, 0xDEADBEEF, rules) - require.NoError(t, err) - - data, err := proto.Marshal(c1) - require.NoError(t, err) - - require.NoError(t, c2.Unmarshal(data)) - require.Equal(t, c1, &c2) - - cid1, err := c1.ID() - require.NoError(t, err) - - data, err = proto.Marshal(&cid1) - require.NoError(t, err) - require.NoError(t, cid2.Unmarshal(data)) - - require.Equal(t, cid1, cid2) - }) -} - -func TestPutRequestGettersSetters(t *testing.T) { - t.Run("owner", func(t *testing.T) { - owner := OwnerID{1, 2, 3} - m := new(PutRequest) - - m.SetOwnerID(owner) - - require.Equal(t, owner, m.GetOwnerID()) - }) - - t.Run("capacity", func(t *testing.T) { - cp := uint64(3) - m := new(PutRequest) - - m.SetCapacity(cp) - - require.Equal(t, cp, m.GetCapacity()) - }) - - t.Run("message ID", func(t *testing.T) { - id, err := refs.NewUUID() - require.NoError(t, err) - - m := new(PutRequest) - - m.SetMessageID(id) - - require.Equal(t, id, m.GetMessageID()) - }) - - t.Run("rules", func(t *testing.T) { - rules := netmap.PlacementRule{ - ReplFactor: 1, - } - - m := new(PutRequest) - - m.SetRules(rules) - - require.Equal(t, rules, m.GetRules()) - }) - - t.Run("basic ACL", func(t *testing.T) { - bACL := uint32(5) - m := new(PutRequest) - - m.SetBasicACL(bACL) - - require.Equal(t, bACL, m.GetBasicACL()) - }) -} - -func TestDeleteRequestGettersSetters(t *testing.T) { - t.Run("cid", func(t *testing.T) { - cid := CID{1, 2, 3} - m := new(DeleteRequest) - - m.SetCID(cid) - - require.Equal(t, cid, m.GetCID()) - }) -} - -func TestGetRequestGettersSetters(t *testing.T) { - t.Run("cid", func(t *testing.T) { - cid := CID{1, 2, 3} - m := new(GetRequest) - - m.SetCID(cid) - - require.Equal(t, cid, m.GetCID()) - }) -} - -func TestListRequestGettersSetters(t *testing.T) { - t.Run("owner", func(t *testing.T) { - owner := OwnerID{1, 2, 3} - m := new(PutRequest) - - m.SetOwnerID(owner) - - require.Equal(t, owner, m.GetOwnerID()) - }) -} - -func TestExtendedACLKey(t *testing.T) { - s := new(ExtendedACLKey) - - id := CID{1, 2, 3} - s.SetID(id) - require.Equal(t, id, s.GetID()) -} - -func TestExtendedACLValue(t *testing.T) { - s := new(ExtendedACLValue) - - acl := []byte{1, 2, 3} - s.SetEACL(acl) - require.Equal(t, acl, s.GetEACL()) - - sig := []byte{4, 5, 6} - s.SetSignature(sig) - require.Equal(t, sig, s.GetSignature()) -} diff --git a/decimal/decimal.go b/decimal/decimal.go deleted file mode 100644 index 2ee0088..0000000 --- a/decimal/decimal.go +++ /dev/null @@ -1,110 +0,0 @@ -package decimal - -import ( - "math" - "strconv" - "strings" -) - -// GASPrecision contains precision for NEO Gas token. -const GASPrecision = 8 - -// Zero is empty Decimal value. -var Zero = &Decimal{} - -// New returns new Decimal (in satoshi). -func New(v int64) *Decimal { - return NewWithPrecision(v, GASPrecision) -} - -// NewGAS returns new Decimal * 1e8 (in GAS). -func NewGAS(v int64) *Decimal { - v *= int64(math.Pow10(GASPrecision)) - return NewWithPrecision(v, GASPrecision) -} - -// NewWithPrecision returns new Decimal with custom precision. -func NewWithPrecision(v int64, p uint32) *Decimal { - return &Decimal{Value: v, Precision: p} -} - -// ParseFloat return new Decimal parsed from float64 * 1e8 (in GAS). -func ParseFloat(v float64) *Decimal { - return new(Decimal).Parse(v, GASPrecision) -} - -// ParseFloatWithPrecision returns new Decimal parsed from float64 * 1^p. -func ParseFloatWithPrecision(v float64, p int) *Decimal { - return new(Decimal).Parse(v, p) -} - -// Copy returns copy of current Decimal. -func (m *Decimal) Copy() *Decimal { return &Decimal{Value: m.Value, Precision: m.Precision} } - -// Parse returns parsed Decimal from float64 * 1^p. -func (m *Decimal) Parse(v float64, p int) *Decimal { - m.Value = int64(v * math.Pow10(p)) - m.Precision = uint32(p) - return m -} - -// String returns string representation of Decimal. -func (m Decimal) String() string { - buf := new(strings.Builder) - val := m.Value - dec := int64(math.Pow10(int(m.Precision))) - if val < 0 { - buf.WriteRune('-') - val = -val - } - str := strconv.FormatInt(val/dec, 10) - buf.WriteString(str) - val %= dec - if val > 0 { - buf.WriteRune('.') - str = strconv.FormatInt(val, 10) - for i := len(str); i < int(m.Precision); i++ { - buf.WriteRune('0') - } - buf.WriteString(strings.TrimRight(str, "0")) - } - return buf.String() -} - -// Add returns d + m. -func (m Decimal) Add(d *Decimal) *Decimal { - precision := m.Precision - if precision < d.Precision { - precision = d.Precision - } - return &Decimal{ - Value: m.Value + d.Value, - Precision: precision, - } -} - -// Zero checks that Decimal is empty. -func (m Decimal) Zero() bool { return m.Value == 0 } - -// Equal checks that current Decimal is equal to passed Decimal. -func (m Decimal) Equal(v *Decimal) bool { return m.Value == v.Value && m.Precision == v.Precision } - -// GT checks that m > v. -func (m Decimal) GT(v *Decimal) bool { return m.Value > v.Value } - -// GTE checks that m >= v. -func (m Decimal) GTE(v *Decimal) bool { return m.Value >= v.Value } - -// LT checks that m < v. -func (m Decimal) LT(v *Decimal) bool { return m.Value < v.Value } - -// LTE checks that m <= v. -func (m Decimal) LTE(v *Decimal) bool { return m.Value <= v.Value } - -// Neg returns negative representation of current Decimal (m * -1). -func (m Decimal) Neg() *Decimal { - return &Decimal{ - Value: m.Value * -1, - Precision: m.Precision, - } -} diff --git a/decimal/decimal.pb.go b/decimal/decimal.pb.go deleted file mode 100644 index 9108e61..0000000 --- a/decimal/decimal.pb.go +++ /dev/null @@ -1,349 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: decimal/decimal.proto - -package decimal - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Decimal is a structure used for representation of assets amount -type Decimal struct { - // Value is value number - Value int64 `protobuf:"varint,1,opt,name=Value,proto3" json:"Value,omitempty"` - // Precision is precision number - Precision uint32 `protobuf:"varint,2,opt,name=Precision,proto3" json:"Precision,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Decimal) Reset() { *m = Decimal{} } -func (*Decimal) ProtoMessage() {} -func (*Decimal) Descriptor() ([]byte, []int) { - return fileDescriptor_e7e70e1773836c80, []int{0} -} -func (m *Decimal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Decimal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Decimal) XXX_Merge(src proto.Message) { - xxx_messageInfo_Decimal.Merge(m, src) -} -func (m *Decimal) XXX_Size() int { - return m.Size() -} -func (m *Decimal) XXX_DiscardUnknown() { - xxx_messageInfo_Decimal.DiscardUnknown(m) -} - -var xxx_messageInfo_Decimal proto.InternalMessageInfo - -func (m *Decimal) GetValue() int64 { - if m != nil { - return m.Value - } - return 0 -} - -func (m *Decimal) GetPrecision() uint32 { - if m != nil { - return m.Precision - } - return 0 -} - -func init() { - proto.RegisterType((*Decimal)(nil), "decimal.Decimal") -} - -func init() { proto.RegisterFile("decimal/decimal.proto", fileDescriptor_e7e70e1773836c80) } - -var fileDescriptor_e7e70e1773836c80 = []byte{ - // 201 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x49, 0x4d, 0xce, - 0xcc, 0x4d, 0xcc, 0xd1, 0x87, 0xd2, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0xae, - 0x94, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7a, 0x7e, 0x7a, - 0xbe, 0x3e, 0x58, 0x3e, 0xa9, 0x34, 0x0d, 0xcc, 0x03, 0x73, 0xc0, 0x2c, 0x88, 0x3e, 0x25, 0x67, - 0x2e, 0x76, 0x17, 0x88, 0x4e, 0x21, 0x11, 0x2e, 0xd6, 0xb0, 0xc4, 0x9c, 0xd2, 0x54, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0xe6, 0x20, 0x08, 0x47, 0x48, 0x86, 0x8b, 0x33, 0xa0, 0x28, 0x35, 0x39, 0xb3, - 0x38, 0x33, 0x3f, 0x4f, 0x82, 0x49, 0x81, 0x51, 0x83, 0x37, 0x08, 0x21, 0x60, 0xc5, 0x32, 0x63, - 0x81, 0x3c, 0x83, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, - 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x8c, 0xc7, 0x72, 0x0c, 0x51, 0x9a, 0x48, 0x2e, 0xc9, 0x2b, - 0x2e, 0x48, 0x4e, 0xd6, 0x4d, 0x49, 0x2d, 0xd3, 0xcf, 0x4b, 0xcd, 0x4f, 0x2b, 0xd6, 0x4d, 0x2c, - 0xc8, 0xd4, 0x4d, 0xcf, 0x87, 0xf9, 0x61, 0x15, 0x93, 0xa0, 0x5f, 0x6a, 0xbe, 0x5b, 0xb0, 0x9e, - 0x63, 0x80, 0xa7, 0x1e, 0xd4, 0x39, 0x49, 0x6c, 0x60, 0x07, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, - 0xff, 0xa5, 0x41, 0x4c, 0x9f, 0xf1, 0x00, 0x00, 0x00, -} - -func (m *Decimal) 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 *Decimal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Decimal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Precision != 0 { - i = encodeVarintDecimal(dAtA, i, uint64(m.Precision)) - i-- - dAtA[i] = 0x10 - } - if m.Value != 0 { - i = encodeVarintDecimal(dAtA, i, uint64(m.Value)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintDecimal(dAtA []byte, offset int, v uint64) int { - offset -= sovDecimal(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Decimal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != 0 { - n += 1 + sovDecimal(uint64(m.Value)) - } - if m.Precision != 0 { - n += 1 + sovDecimal(uint64(m.Precision)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovDecimal(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozDecimal(x uint64) (n int) { - return sovDecimal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Decimal) 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 ErrIntOverflowDecimal - } - 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: Decimal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Decimal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - m.Value = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDecimal - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Value |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Precision", wireType) - } - m.Precision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDecimal - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Precision |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipDecimal(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthDecimal - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthDecimal - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipDecimal(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, ErrIntOverflowDecimal - } - 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, ErrIntOverflowDecimal - } - 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, ErrIntOverflowDecimal - } - 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, ErrInvalidLengthDecimal - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupDecimal - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthDecimal - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthDecimal = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowDecimal = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupDecimal = fmt.Errorf("proto: unexpected end of group") -) diff --git a/decimal/decimal.proto b/decimal/decimal.proto deleted file mode 100644 index f3d5c00..0000000 --- a/decimal/decimal.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; -package decimal; -option go_package = "github.com/nspcc-dev/neofs-api-go/decimal"; -option csharp_namespace = "NeoFS.API.Decimal"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Decimal is a structure used for representation of assets amount -message Decimal { - option (gogoproto.goproto_stringer) = false; - - // Value is value number - int64 Value = 1; - // Precision is precision number - uint32 Precision = 2; -} diff --git a/decimal/decimal_test.go b/decimal/decimal_test.go deleted file mode 100644 index c5ffef7..0000000 --- a/decimal/decimal_test.go +++ /dev/null @@ -1,445 +0,0 @@ -package decimal - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestDecimal_Parse(t *testing.T) { - tests := []struct { - value float64 - name string - expect *Decimal - }{ - {name: "empty", expect: &Decimal{Precision: GASPrecision}}, - - { - value: 100, - name: "100 GAS", - expect: &Decimal{Value: 1e10, Precision: GASPrecision}, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.expect, ParseFloat(tt.value)) - }) - } -} - -func TestDecimal_ParseWithPrecision(t *testing.T) { - type args struct { - v float64 - p int - } - tests := []struct { - args args - name string - expect *Decimal - }{ - {name: "empty", expect: &Decimal{}}, - - { - name: "empty precision", - expect: &Decimal{Value: 0, Precision: 0}, - }, - - { - name: "100 GAS", - args: args{100, GASPrecision}, - expect: &Decimal{Value: 1e10, Precision: GASPrecision}, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.expect, - ParseFloatWithPrecision(tt.args.v, tt.args.p)) - }) - } -} - -func TestNew(t *testing.T) { - tests := []struct { - name string - val int64 - expect *Decimal - }{ - {name: "empty", expect: &Decimal{Value: 0, Precision: GASPrecision}}, - {name: "100 GAS", val: 1e10, expect: &Decimal{Value: 1e10, Precision: GASPrecision}}, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equalf(t, tt.expect, New(tt.val), tt.name) - }) - } -} - -func TestNewGAS(t *testing.T) { - tests := []struct { - name string - val int64 - expect *Decimal - }{ - {name: "empty", expect: &Decimal{Value: 0, Precision: GASPrecision}}, - {name: "100 GAS", val: 100, expect: &Decimal{Value: 1e10, Precision: GASPrecision}}, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equalf(t, tt.expect, NewGAS(tt.val), tt.name) - }) - } -} -func TestNewWithPrecision(t *testing.T) { - tests := []struct { - name string - val int64 - pre uint32 - expect *Decimal - }{ - {name: "empty", expect: &Decimal{}}, - {name: "100 GAS", val: 1e10, pre: GASPrecision, expect: &Decimal{Value: 1e10, Precision: GASPrecision}}, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equalf(t, tt.expect, NewWithPrecision(tt.val, tt.pre), tt.name) - }) - } -} - -func TestDecimal_Neg(t *testing.T) { - tests := []struct { - name string - val int64 - expect *Decimal - }{ - {name: "empty", expect: &Decimal{Value: 0, Precision: GASPrecision}}, - {name: "100 GAS", val: 1e10, expect: &Decimal{Value: -1e10, Precision: GASPrecision}}, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Equalf(t, tt.expect, New(tt.val).Neg(), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_String(t *testing.T) { - tests := []struct { - name string - expect string - value *Decimal - }{ - {name: "empty", expect: "0", value: &Decimal{}}, - {name: "100 GAS", expect: "100", value: &Decimal{Value: 1e10, Precision: GASPrecision}}, - {name: "-100 GAS", expect: "-100", value: &Decimal{Value: -1e10, Precision: GASPrecision}}, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.Equalf(t, tt.expect, tt.value.String(), tt.name) - }) - } -} - -const SomethingElsePrecision = 5 - -func TestDecimal_Add(t *testing.T) { - tests := []struct { - name string - expect *Decimal - values [2]*Decimal - }{ - {name: "empty", expect: &Decimal{}, values: [2]*Decimal{{}, {}}}, - { - name: "5 GAS + 2 GAS", - expect: &Decimal{Value: 7e8, Precision: GASPrecision}, - values: [2]*Decimal{ - {Value: 2e8, Precision: GASPrecision}, - {Value: 5e8, Precision: GASPrecision}, - }, - }, - { - name: "1e2 + 1e3", - expect: &Decimal{Value: 1.1e3, Precision: 3}, - values: [2]*Decimal{ - {Value: 1e2, Precision: 2}, - {Value: 1e3, Precision: 3}, - }, - }, - { - name: "5 GAS + 10 SomethingElse", - expect: &Decimal{Value: 5.01e8, Precision: GASPrecision}, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 1e6, Precision: SomethingElsePrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - { // A + B - one := tt.values[0] - two := tt.values[1] - require.Equalf(t, tt.expect, one.Add(two), tt.name) - t.Log(one.Add(two)) - } - - { // B + A - one := tt.values[0] - two := tt.values[1] - require.Equalf(t, tt.expect, two.Add(one), tt.name) - t.Log(two.Add(one)) - } - }, tt.name) - }) - } -} - -func TestDecimal_Copy(t *testing.T) { - tests := []struct { - name string - expect *Decimal - value *Decimal - }{ - {name: "zero", expect: Zero}, - { - name: "5 GAS", - expect: &Decimal{Value: 5e8, Precision: GASPrecision}, - }, - { - name: "100 GAS", - expect: &Decimal{Value: 1e10, Precision: GASPrecision}, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Equal(t, tt.expect, tt.expect.Copy()) - }, tt.name) - }) - } -} - -func TestDecimal_Zero(t *testing.T) { - tests := []struct { - name string - expect bool - value *Decimal - }{ - {name: "zero", expect: true, value: Zero}, - { - name: "5 GAS", - expect: false, - value: &Decimal{Value: 5e8, Precision: GASPrecision}, - }, - { - name: "100 GAS", - expect: false, - value: &Decimal{Value: 1e10, Precision: GASPrecision}, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == tt.value.Zero(), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_Equal(t *testing.T) { - tests := []struct { - name string - expect bool - values [2]*Decimal - }{ - {name: "zero == zero", expect: true, values: [2]*Decimal{Zero, Zero}}, - { - name: "5 GAS != 2 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 2e8, Precision: GASPrecision}, - }, - }, - { - name: "100 GAS == 100 GAS", - expect: true, - values: [2]*Decimal{ - {Value: 1e10, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == (tt.values[0].Equal(tt.values[1])), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_GT(t *testing.T) { - tests := []struct { - name string - expect bool - values [2]*Decimal - }{ - {name: "two zeros", expect: false, values: [2]*Decimal{Zero, Zero}}, - { - name: "5 GAS > 2 GAS", - expect: true, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 2e8, Precision: GASPrecision}, - }, - }, - { - name: "100 GAS !> 100 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 1e10, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == (tt.values[0].GT(tt.values[1])), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_GTE(t *testing.T) { - tests := []struct { - name string - expect bool - values [2]*Decimal - }{ - {name: "two zeros", expect: true, values: [2]*Decimal{Zero, Zero}}, - { - name: "5 GAS >= 2 GAS", - expect: true, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 2e8, Precision: GASPrecision}, - }, - }, - { - name: "1 GAS !>= 100 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 1e8, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == (tt.values[0].GTE(tt.values[1])), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_LT(t *testing.T) { - tests := []struct { - name string - expect bool - values [2]*Decimal - }{ - {name: "two zeros", expect: false, values: [2]*Decimal{Zero, Zero}}, - { - name: "5 GAS !< 2 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 2e8, Precision: GASPrecision}, - }, - }, - { - name: "1 GAS < 100 GAS", - expect: true, - values: [2]*Decimal{ - {Value: 1e8, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - { - name: "100 GAS !< 100 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 1e10, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == (tt.values[0].LT(tt.values[1])), tt.name) - }, tt.name) - }) - } -} - -func TestDecimal_LTE(t *testing.T) { - tests := []struct { - name string - expect bool - values [2]*Decimal - }{ - {name: "two zeros", expect: true, values: [2]*Decimal{Zero, Zero}}, - { - name: "5 GAS <= 2 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 5e8, Precision: GASPrecision}, - {Value: 2e8, Precision: GASPrecision}, - }, - }, - { - name: "1 GAS <= 100 GAS", - expect: true, - values: [2]*Decimal{ - {Value: 1e8, Precision: GASPrecision}, - {Value: 1e10, Precision: GASPrecision}, - }, - }, - { - name: "100 GAS !<= 1 GAS", - expect: false, - values: [2]*Decimal{ - {Value: 1e10, Precision: GASPrecision}, - {Value: 1e8, Precision: GASPrecision}, - }, - }, - } - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - require.NotPanicsf(t, func() { - require.Truef(t, tt.expect == (tt.values[0].LTE(tt.values[1])), tt.name) - }, tt.name) - }) - } -} diff --git a/hash/hash.go b/hash/hash.go deleted file mode 100644 index 4e2fb05..0000000 --- a/hash/hash.go +++ /dev/null @@ -1,106 +0,0 @@ -package hash - -import ( - "bytes" - - "github.com/gogo/protobuf/proto" - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/tzhash/tz" - "github.com/pkg/errors" -) - -// HomomorphicHashSize contains size of HH. -const HomomorphicHashSize = 64 - -// Hash is implementation of HomomorphicHash. -type Hash [HomomorphicHashSize]byte - -// ErrWrongDataSize raised when wrong size of bytes is passed to unmarshal HH. -const ErrWrongDataSize = internal.Error("wrong data size") - -var ( - _ internal.Custom = (*Hash)(nil) - - emptyHH [HomomorphicHashSize]byte -) - -// Size returns size of Hash (HomomorphicHashSize). -func (h Hash) Size() int { return HomomorphicHashSize } - -// Empty checks that Hash is empty. -func (h Hash) Empty() bool { return bytes.Equal(h.Bytes(), emptyHH[:]) } - -// Reset sets current Hash to empty value. -func (h *Hash) Reset() { *h = Hash{} } - -// ProtoMessage method to satisfy proto.Message interface. -func (h Hash) ProtoMessage() {} - -// Bytes represents Hash as bytes. -func (h Hash) Bytes() []byte { - buf := make([]byte, HomomorphicHashSize) - copy(buf, h[:]) - return h[:] -} - -// Marshal returns bytes representation of Hash. -func (h Hash) Marshal() ([]byte, error) { return h.Bytes(), nil } - -// MarshalTo tries to marshal Hash into passed bytes and returns count of copied bytes. -func (h *Hash) MarshalTo(data []byte) (int, error) { return copy(data, h.Bytes()), nil } - -// Unmarshal tries to parse bytes into valid Hash. -func (h *Hash) Unmarshal(data []byte) error { - if ln := len(data); ln != HomomorphicHashSize { - return errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", HomomorphicHashSize, ln) - } - - copy((*h)[:], data) - return nil -} - -// String returns string representation of Hash. -func (h Hash) String() string { return base58.Encode(h[:]) } - -// Equal checks that current Hash is equal to passed Hash. -func (h Hash) Equal(hash Hash) bool { return h == hash } - -// Verify validates if current hash generated from passed data. -func (h Hash) Verify(data []byte) bool { return h.Equal(Sum(data)) } - -// Validate checks if combined hashes are equal to current Hash. -func (h Hash) Validate(hashes []Hash) bool { - hashBytes := make([][]byte, 0, len(hashes)) - for i := range hashes { - hashBytes = append(hashBytes, hashes[i].Bytes()) - } - ok, err := tz.Validate(h.Bytes(), hashBytes) - return err == nil && ok -} - -// Merge used by proto.Clone -func (h *Hash) Merge(src proto.Message) { - if tmp, ok := src.(*Hash); ok { - *h = *tmp - } -} - -// Sum returns Tillich-Zémor checksum of data. -func Sum(data []byte) Hash { return tz.Sum(data) } - -// Concat combines hashes based on homomorphic property. -func Concat(hashes []Hash) (Hash, error) { - var ( - hash Hash - h = make([][]byte, 0, len(hashes)) - ) - for i := range hashes { - h = append(h, hashes[i].Bytes()) - } - cat, err := tz.Concat(h) - if err != nil { - return hash, err - } - return hash, hash.Unmarshal(cat) -} diff --git a/hash/hash_test.go b/hash/hash_test.go deleted file mode 100644 index b3ef703..0000000 --- a/hash/hash_test.go +++ /dev/null @@ -1,166 +0,0 @@ -package hash - -import ( - "bytes" - "crypto/rand" - "testing" - - "github.com/pkg/errors" - "github.com/stretchr/testify/require" -) - -func Test_Sum(t *testing.T) { - var ( - data = []byte("Hello world") - sum = Sum(data) - hash = []byte{0, 0, 0, 0, 1, 79, 16, 173, 134, 90, 176, 77, 114, 165, 253, 114, 0, 0, 0, 0, 0, 148, - 172, 222, 98, 248, 15, 99, 205, 129, 66, 91, 0, 0, 0, 0, 0, 138, 173, 39, 228, 231, 239, 123, - 170, 96, 186, 61, 0, 0, 0, 0, 0, 90, 69, 237, 131, 90, 161, 73, 38, 164, 185, 55} - ) - - require.Equal(t, hash, sum.Bytes()) -} - -func Test_Validate(t *testing.T) { - var ( - data = []byte("Hello world") - hash = Sum(data) - pieces = splitData(data, 2) - ln = len(pieces) - hashes = make([]Hash, 0, ln) - ) - - for i := 0; i < ln; i++ { - hashes = append(hashes, Sum(pieces[i])) - } - - require.True(t, hash.Validate(hashes)) -} - -func Test_Concat(t *testing.T) { - var ( - data = []byte("Hello world") - hash = Sum(data) - pieces = splitData(data, 2) - ln = len(pieces) - hashes = make([]Hash, 0, ln) - ) - - for i := 0; i < ln; i++ { - hashes = append(hashes, Sum(pieces[i])) - } - - res, err := Concat(hashes) - require.NoError(t, err) - require.Equal(t, hash, res) -} - -func Test_HashChunks(t *testing.T) { - var ( - chars = []byte("+") - size = 1400 - data = bytes.Repeat(chars, size) - hash = Sum(data) - count = 150 - ) - - hashes, err := dataHashes(data, count) - require.NoError(t, err) - require.Len(t, hashes, count) - - require.True(t, hash.Validate(hashes)) - - // 100 / 150 = 0 - hashes, err = dataHashes(data[:100], count) - require.Error(t, err) - require.Nil(t, hashes) -} - -func TestXOR(t *testing.T) { - var ( - dl = 10 - data = make([]byte, dl) - ) - - _, err := rand.Read(data) - require.NoError(t, err) - - t.Run("XOR with salt", func(t *testing.T) { - res := SaltXOR(data, nil) - require.Equal(t, res, data) - }) - - t.Run("XOR with empty salt", func(t *testing.T) { - xorWithSalt(t, data, 0) - }) - - t.Run("XOR with salt same data size", func(t *testing.T) { - xorWithSalt(t, data, dl) - }) - - t.Run("XOR with salt shorter than data aliquot", func(t *testing.T) { - xorWithSalt(t, data, dl/2) - }) - - t.Run("XOR with salt shorter than data aliquant", func(t *testing.T) { - xorWithSalt(t, data, dl/3/+1) - }) - - t.Run("XOR with salt longer than data aliquot", func(t *testing.T) { - xorWithSalt(t, data, dl*2) - }) - - t.Run("XOR with salt longer than data aliquant", func(t *testing.T) { - xorWithSalt(t, data, dl*2-1) - }) -} - -func xorWithSalt(t *testing.T, data []byte, saltSize int) { - var ( - direct, reverse []byte - salt = make([]byte, saltSize) - ) - - _, err := rand.Read(salt) - require.NoError(t, err) - - direct = SaltXOR(data, salt) - require.Len(t, direct, len(data)) - - reverse = SaltXOR(direct, salt) - require.Len(t, reverse, len(data)) - - require.Equal(t, reverse, data) -} - -func splitData(buf []byte, lim int) [][]byte { - var piece []byte - pieces := make([][]byte, 0, len(buf)/lim+1) - for len(buf) >= lim { - piece, buf = buf[:lim], buf[lim:] - pieces = append(pieces, piece) - } - if len(buf) > 0 { - pieces = append(pieces, buf) - } - return pieces -} - -func dataHashes(data []byte, count int) ([]Hash, error) { - var ( - ln = len(data) - mis = ln / count - off = (count - 1) * mis - hashes = make([]Hash, 0, count) - ) - if mis == 0 { - return nil, errors.Errorf("could not split %d bytes to %d pieces", ln, count) - } - - pieces := splitData(data[:off], mis) - pieces = append(pieces, data[off:]) - for i := 0; i < count; i++ { - hashes = append(hashes, Sum(pieces[i])) - } - return hashes, nil -} diff --git a/hash/hashesslice.go b/hash/hashesslice.go deleted file mode 100644 index 83bf4c5..0000000 --- a/hash/hashesslice.go +++ /dev/null @@ -1,20 +0,0 @@ -package hash - -import ( - "bytes" -) - -// HashesSlice is a collection that satisfies sort.Interface and can be -// sorted by the routines in sort package. -type HashesSlice []Hash - -// -- HashesSlice -- an inner type to sort Objects -// Len is the number of elements in the collection. -func (hs HashesSlice) Len() int { return len(hs) } - -// Less reports whether the element with -// index i should be sorted before the element with index j. -func (hs HashesSlice) Less(i, j int) bool { return bytes.Compare(hs[i].Bytes(), hs[j].Bytes()) == -1 } - -// Swap swaps the elements with indexes i and j. -func (hs HashesSlice) Swap(i, j int) { hs[i], hs[j] = hs[j], hs[i] } diff --git a/hash/salt.go b/hash/salt.go deleted file mode 100644 index 5b6eeb0..0000000 --- a/hash/salt.go +++ /dev/null @@ -1,17 +0,0 @@ -package hash - -// SaltXOR xors bits of data with salt -// repeating salt if necessary. -func SaltXOR(data, salt []byte) (result []byte) { - result = make([]byte, len(data)) - ls := len(salt) - if ls == 0 { - copy(result, data) - return - } - - for i := range result { - result[i] = data[i] ^ salt[i%ls] - } - return -} diff --git a/internal/error.go b/internal/error.go deleted file mode 100644 index 7df1603..0000000 --- a/internal/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package internal - -// Error is a custom error. -type Error string - -// Error is an implementation of error interface. -func (e Error) Error() string { return string(e) } diff --git a/internal/proto.go b/internal/proto.go deleted file mode 100644 index 9a924b5..0000000 --- a/internal/proto.go +++ /dev/null @@ -1,19 +0,0 @@ -package internal - -import "github.com/gogo/protobuf/proto" - -// Custom contains methods to satisfy proto.Message -// including custom methods to satisfy protobuf for -// non-proto defined types. -type Custom interface { - Size() int - Empty() bool - Bytes() []byte - Marshal() ([]byte, error) - MarshalTo(data []byte) (int, error) - Unmarshal(data []byte) error - proto.Message - - // Should contains for proto.Clone - proto.Merger -} diff --git a/object/doc.go b/object/doc.go deleted file mode 100644 index d81495b..0000000 --- a/object/doc.go +++ /dev/null @@ -1,143 +0,0 @@ -/* -Package object manages main storage structure in the system. All storage -operations are performed with the objects. During lifetime object might be -transformed into another object by cutting its payload or adding meta -information. All transformation may be reversed, therefore source object -will be able to restore. - -Object structure - -Object consists of Payload and Header. Payload is unlimited but storage nodes -may have a policy to store objects with a limited payload. In this case object -with large payload will be transformed into the chain of objects with small -payload. - -Headers are simple key-value fields that divided into two groups: system -headers and extended headers. System headers contain information about -protocol version, object id, payload length in bytes, owner id, container id -and object creation timestamp (both in epochs and unix time). All these fields -must be set up in the correct object. - - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | System Headers | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | Version : 1 | - | Payload Length : 21673465 | - | Object ID : 465208e2-ba4f-4f99-ad47-82a59f4192d4 | - | Owner ID : AShvoCbSZ7VfRiPkVb1tEcBLiJrcbts1tt | - | Container ID : FGobtRZA6sBZv2i9k4L7TiTtnuP6E788qa278xfj3Fxj | - | Created At : Epoch#10, 1573033162 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | Extended Headers | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | User Header : , | - | Verification Header : , | - | Homomorphic Hash : 0x23d35a56ae... | - | Payload Checksum : 0x1bd34abs75... | - | Integrity Header :
, | - | Transformation : Payload Split | - | Link-parent : cae08935-b4ba-499a-bf6c-98276c1e6c0b | - | Link-next : c3b40fbf-3798-4b61-a189-2992b5fb5070 | - | Payload Checksum : 0x1f387a5c36... | - | Integrity Header :
, | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | Payload | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - | 0xd1581963a342d231... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - -There are different kinds of extended headers. A correct object must contain -verification header, homomorphic hash header, payload checksum and -integrity header. The order of headers is matter. Let's look through all -these headers. - -Link header points to the connected objects. During object transformation, large -object might be transformed into the chain of smaller objects. One of these -objects drops payload and has several "Child" links. We call this object as -zero-object. Others will have "Parent" link to the zero-object, "Previous" -and "Next" links in the payload chain. - - [ Object ID:1 ] = > transformed - `- [ Zero-Object ID:1 ] - `- Link-child ID:2 - `- Link-child ID:3 - `- Link-child ID:4 - `- Payload [null] - `- [ Object ID:2 ] - `- Link-parent ID:1 - `- Link-next ID:3 - `- Payload [ 0x13ba... ] - `- [ Object ID:3 ] - `- Link-parent ID:1 - `- Link-previous ID:2 - `- Link-next ID:4 - `- Payload [ 0xcd34... ] - `- [ Object ID:4 ] - `- Link-parent ID:1 - `- Link-previous ID:3 - `- Payload [ 0xef86... ] - -Storage groups are also objects. They have "Storage Group" links to all -objects in the group. Links are set by nodes during transformations and, -in general, they should not be set by user manually. - -Redirect headers are not used yet, they will be implemented and described -later. - -User header is a key-value pair of string that can be defined by user. User -can use these headers as search attribute. You can store any meta information -about object there, e.g. object's nicename. - -Transformation header notifies that object was transformed by some pre-defined -way. This header sets up before object is transformed and all headers after -transformation must be located after transformation header. During reverse -transformation, all headers under transformation header will be cut out. - - +-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+ - | Payload checksum | | Payload checksum | | Payload checksum | - | Integrity header | => | Integrity header | + | Integrity header | - +-+-+-+-+-+-+-+-+-+- | Transformation | | Transformation | - | Large payload | | New Checksum | | New Checksum | - +-+-+-+-+-+-+-+-+-+- | New Integrity | | New Integrity | - +-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+ - | Small payload | | Small payload | - +-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+ - -For now, we use only one type of transformation: payload split transformation. -This header set up by node automatically. - -Tombstone header notifies that this object was deleted by user. Objects with -tombstone header do not have payload, but they still contain meta information -in the headers. This way we implement two-phase commit for object removal. -Storage nodes will eventually delete all tombstone objects. If you want to -delete object, you must create new object with the same object id, with -tombstone header, correct signatures and without payload. - -Verification header contains session information. To put the object in -the system user must create session. It is required because objects might -be transformed and therefore must be re-signed. To do that node creates -a pair of session public and private keys. Object owner delegates permission to -re-sign objects by signing session public key. This header contains session -public key and owner's signature of this key. You must specify this header -manually. - -Homomorphic hash header contains homomorphic hash of the source object. -Transformations do not affect this header. This header used by data audit and -set by node automatically. - -Payload checksum contains checksum of the actual object payload. All payload -transformation must set new payload checksum headers. This header set by node -automatically. - -Integrity header contains checksum of the header and signature of the -session key. This header must be last in the list of extended headers. -Checksum is calculated by marshaling all above headers, including system -headers. This header set by node automatically. - -Storage group header is presented in storage group objects. It contains -information for data audit: size of validated data, homomorphic has of this -data, storage group expiration time in epochs or unix time. - - -*/ -package object diff --git a/object/extensions.go b/object/extensions.go deleted file mode 100644 index be755c6..0000000 --- a/object/extensions.go +++ /dev/null @@ -1,64 +0,0 @@ -package object - -// todo: all extensions must be transferred to the separate util library - -import "github.com/nspcc-dev/neofs-api-go/storagegroup" - -// IsLinking checks if object has children links to another objects. -// We have to check payload size because zero-object must have zero -// payload and non-zero payload length field in system header. -func (m Object) IsLinking() bool { - for i := range m.Headers { - switch v := m.Headers[i].Value.(type) { - case *Header_Link: - if v.Link.GetType() == Link_Child { - return m.SystemHeader.PayloadLength > 0 && len(m.Payload) == 0 - } - } - } - return false -} - -// Links returns slice of ids of specified link type -func (m *Object) Links(t Link_Type) []ID { - var res []ID - for i := range m.Headers { - switch v := m.Headers[i].Value.(type) { - case *Header_Link: - if v.Link.GetType() == t { - res = append(res, v.Link.ID) - } - } - } - return res -} - -// Tombstone returns tombstone header if it is presented in extended headers. -func (m Object) Tombstone() *Tombstone { - _, h := m.LastHeader(HeaderType(TombstoneHdr)) - if h != nil { - return h.Value.(*Header_Tombstone).Tombstone - } - return nil -} - -// IsTombstone checks if object has tombstone header. -func (m Object) IsTombstone() bool { - n, _ := m.LastHeader(HeaderType(TombstoneHdr)) - return n != -1 -} - -// StorageGroup returns storage group structure if it is presented in extended headers. -func (m Object) StorageGroup() (*storagegroup.StorageGroup, error) { - _, sgHdr := m.LastHeader(HeaderType(StorageGroupHdr)) - if sgHdr == nil { - return nil, ErrHeaderNotFound - } - return sgHdr.Value.(*Header_StorageGroup).StorageGroup, nil -} - -// SetStorageGroup sets storage group header in the object. -// It will replace existing storage group header or add a new one. -func (m *Object) SetStorageGroup(group *storagegroup.StorageGroup) { - m.SetHeader(&Header{Value: &Header_StorageGroup{StorageGroup: group}}) -} diff --git a/object/service.go b/object/service.go deleted file mode 100644 index 0e38d70..0000000 --- a/object/service.go +++ /dev/null @@ -1,196 +0,0 @@ -package object - -import ( - "github.com/nspcc-dev/neofs-api-go/hash" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-api-go/session" -) - -type ( - // ID is a type alias of object id. - ID = refs.ObjectID - - // CID is a type alias of container id. - CID = refs.CID - - // SGID is a type alias of storage group id. - SGID = refs.SGID - - // OwnerID is a type alias of owner id. - OwnerID = refs.OwnerID - - // Hash is a type alias of Homomorphic hash. - Hash = hash.Hash - - // Token is a type alias of session token. - Token = session.Token - - // Request defines object rpc requests. - // All object operations must have TTL, Epoch, Type, Container ID and - // permission of usage previous network map. - Request interface { - service.SeizedRequestMetaContainer - - CID() CID - Type() RequestType - AllowPreviousNetMap() bool - } -) - -const ( - // starts enum for amount of bytes. - _ int64 = 1 << (10 * iota) - - // UnitsKB defines amount of bytes in one kilobyte. - UnitsKB - - // UnitsMB defines amount of bytes in one megabyte. - UnitsMB - - // UnitsGB defines amount of bytes in one gigabyte. - UnitsGB - - // UnitsTB defines amount of bytes in one terabyte. - UnitsTB -) - -const ( - // ErrNotFound is raised when object is not found in the system. - ErrNotFound = internal.Error("could not find object") - - // ErrHeaderExpected is raised when first message in protobuf stream does not contain user header. - ErrHeaderExpected = internal.Error("expected header as a first message in stream") - - // KeyStorageGroup is a key for a search object by storage group id. - KeyStorageGroup = "STORAGE_GROUP" - - // KeyNoChildren is a key for searching object that have no children links. - KeyNoChildren = "LEAF" - - // KeyParent is a key for searching object by id of parent object. - KeyParent = "PARENT" - - // KeyHasParent is a key for searching object that have parent link. - KeyHasParent = "HAS_PAR" - - // KeyTombstone is a key for searching object that have tombstone header. - KeyTombstone = "TOMBSTONE" - - // KeyChild is a key for searching object by id of child link. - KeyChild = "CHILD" - - // KeyPrev is a key for searching object by id of previous link. - KeyPrev = "PREV" - - // KeyNext is a key for searching object by id of next link. - KeyNext = "NEXT" - - // KeyID is a key for searching object by object id. - KeyID = "ID" - - // KeyCID is a key for searching object by container id. - KeyCID = "CID" - - // KeyOwnerID is a key for searching object by owner id. - KeyOwnerID = "OWNERID" - - // KeyRootObject is a key for searching object that are zero-object or do - // not have any children. - KeyRootObject = "ROOT_OBJECT" -) - -func checkIsNotFull(v interface{}) bool { - var obj *Object - - switch t := v.(type) { - case *GetResponse: - obj = t.GetObject() - case *PutRequest: - if h := t.GetHeader(); h != nil { - obj = h.Object - } - default: - panic("unknown type") - } - - return obj == nil || obj.SystemHeader.PayloadLength != uint64(len(obj.Payload)) && !obj.IsLinking() -} - -// NotFull checks if protobuf stream provided whole object for get operation. -func (m *GetResponse) NotFull() bool { return checkIsNotFull(m) } - -// NotFull checks if protobuf stream provided whole object for put operation. -func (m *PutRequest) NotFull() bool { return checkIsNotFull(m) } - -// CID returns container id value from object put request. -func (m *PutRequest) CID() (cid CID) { - if header := m.GetHeader(); header == nil { - return - } else if obj := header.GetObject(); obj == nil { - return - } else { - return obj.SystemHeader.CID - } -} - -// CID returns container id value from object get request. -func (m *GetRequest) CID() CID { return m.Address.CID } - -// CID returns container id value from object head request. -func (m *HeadRequest) CID() CID { return m.Address.CID } - -// CID returns container id value from object search request. -func (m *SearchRequest) CID() CID { return m.ContainerID } - -// CID returns container id value from object delete request. -func (m *DeleteRequest) CID() CID { return m.Address.CID } - -// CID returns container id value from object get range request. -func (m *GetRangeRequest) CID() CID { return m.Address.CID } - -// CID returns container id value from object get range hash request. -func (m *GetRangeHashRequest) CID() CID { return m.Address.CID } - -// AllowPreviousNetMap returns permission to use previous network map in object put request. -func (m *PutRequest) AllowPreviousNetMap() bool { return false } - -// AllowPreviousNetMap returns permission to use previous network map in object get request. -func (m *GetRequest) AllowPreviousNetMap() bool { return true } - -// AllowPreviousNetMap returns permission to use previous network map in object head request. -func (m *HeadRequest) AllowPreviousNetMap() bool { return true } - -// AllowPreviousNetMap returns permission to use previous network map in object search request. -func (m *SearchRequest) AllowPreviousNetMap() bool { return true } - -// AllowPreviousNetMap returns permission to use previous network map in object delete request. -func (m *DeleteRequest) AllowPreviousNetMap() bool { return false } - -// AllowPreviousNetMap returns permission to use previous network map in object get range request. -func (m *GetRangeRequest) AllowPreviousNetMap() bool { return false } - -// AllowPreviousNetMap returns permission to use previous network map in object get range hash request. -func (m *GetRangeHashRequest) AllowPreviousNetMap() bool { return false } - -// Type returns type of the object put request. -func (m *PutRequest) Type() RequestType { return RequestPut } - -// Type returns type of the object get request. -func (m *GetRequest) Type() RequestType { return RequestGet } - -// Type returns type of the object head request. -func (m *HeadRequest) Type() RequestType { return RequestHead } - -// Type returns type of the object search request. -func (m *SearchRequest) Type() RequestType { return RequestSearch } - -// Type returns type of the object delete request. -func (m *DeleteRequest) Type() RequestType { return RequestDelete } - -// Type returns type of the object get range request. -func (m *GetRangeRequest) Type() RequestType { return RequestRange } - -// Type returns type of the object get range hash request. -func (m *GetRangeHashRequest) Type() RequestType { return RequestRangeHash } diff --git a/object/service.pb.go b/object/service.pb.go deleted file mode 100644 index f882f5e..0000000 --- a/object/service.pb.go +++ /dev/null @@ -1,5050 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: object/service.proto - -package object - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - refs "github.com/nspcc-dev/neofs-api-go/refs" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type GetRequest struct { - // Address of object (container id + object id) - Address refs.Address `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{0} -} -func (m *GetRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRequest.Merge(m, src) -} -func (m *GetRequest) XXX_Size() int { - return m.Size() -} -func (m *GetRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRequest proto.InternalMessageInfo - -func (m *GetRequest) GetAddress() refs.Address { - if m != nil { - return m.Address - } - return refs.Address{} -} - -type GetResponse struct { - // Types that are valid to be assigned to R: - // *GetResponse_Object - // *GetResponse_Chunk - R isGetResponse_R `protobuf_oneof:"R"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{1} -} -func (m *GetResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetResponse.Merge(m, src) -} -func (m *GetResponse) XXX_Size() int { - return m.Size() -} -func (m *GetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetResponse proto.InternalMessageInfo - -type isGetResponse_R interface { - isGetResponse_R() - MarshalTo([]byte) (int, error) - Size() int -} - -type GetResponse_Object struct { - Object *Object `protobuf:"bytes,1,opt,name=object,proto3,oneof" json:"object,omitempty"` -} -type GetResponse_Chunk struct { - Chunk []byte `protobuf:"bytes,2,opt,name=Chunk,proto3,oneof" json:"Chunk,omitempty"` -} - -func (*GetResponse_Object) isGetResponse_R() {} -func (*GetResponse_Chunk) isGetResponse_R() {} - -func (m *GetResponse) GetR() isGetResponse_R { - if m != nil { - return m.R - } - return nil -} - -func (m *GetResponse) GetObject() *Object { - if x, ok := m.GetR().(*GetResponse_Object); ok { - return x.Object - } - return nil -} - -func (m *GetResponse) GetChunk() []byte { - if x, ok := m.GetR().(*GetResponse_Chunk); ok { - return x.Chunk - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*GetResponse) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*GetResponse_Object)(nil), - (*GetResponse_Chunk)(nil), - } -} - -type PutRequest struct { - // Types that are valid to be assigned to R: - // *PutRequest_Header - // *PutRequest_Chunk - R isPutRequest_R `protobuf_oneof:"R"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutRequest) Reset() { *m = PutRequest{} } -func (m *PutRequest) String() string { return proto.CompactTextString(m) } -func (*PutRequest) ProtoMessage() {} -func (*PutRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{2} -} -func (m *PutRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutRequest.Merge(m, src) -} -func (m *PutRequest) XXX_Size() int { - return m.Size() -} -func (m *PutRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PutRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PutRequest proto.InternalMessageInfo - -type isPutRequest_R interface { - isPutRequest_R() - MarshalTo([]byte) (int, error) - Size() int -} - -type PutRequest_Header struct { - Header *PutRequest_PutHeader `protobuf:"bytes,1,opt,name=Header,proto3,oneof" json:"Header,omitempty"` -} -type PutRequest_Chunk struct { - Chunk []byte `protobuf:"bytes,2,opt,name=Chunk,proto3,oneof" json:"Chunk,omitempty"` -} - -func (*PutRequest_Header) isPutRequest_R() {} -func (*PutRequest_Chunk) isPutRequest_R() {} - -func (m *PutRequest) GetR() isPutRequest_R { - if m != nil { - return m.R - } - return nil -} - -func (m *PutRequest) GetHeader() *PutRequest_PutHeader { - if x, ok := m.GetR().(*PutRequest_Header); ok { - return x.Header - } - return nil -} - -func (m *PutRequest) GetChunk() []byte { - if x, ok := m.GetR().(*PutRequest_Chunk); ok { - return x.Chunk - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*PutRequest) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*PutRequest_Header)(nil), - (*PutRequest_Chunk)(nil), - } -} - -type PutRequest_PutHeader struct { - // Object with at least container id and owner id fields - Object *Object `protobuf:"bytes,1,opt,name=Object,proto3" json:"Object,omitempty"` - // Number of the object copies to store within the RPC call (zero is processed according to the placement rules) - CopiesNumber uint32 `protobuf:"varint,2,opt,name=CopiesNumber,proto3" json:"CopiesNumber,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutRequest_PutHeader) Reset() { *m = PutRequest_PutHeader{} } -func (m *PutRequest_PutHeader) String() string { return proto.CompactTextString(m) } -func (*PutRequest_PutHeader) ProtoMessage() {} -func (*PutRequest_PutHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{2, 0} -} -func (m *PutRequest_PutHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutRequest_PutHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutRequest_PutHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutRequest_PutHeader.Merge(m, src) -} -func (m *PutRequest_PutHeader) XXX_Size() int { - return m.Size() -} -func (m *PutRequest_PutHeader) XXX_DiscardUnknown() { - xxx_messageInfo_PutRequest_PutHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_PutRequest_PutHeader proto.InternalMessageInfo - -func (m *PutRequest_PutHeader) GetObject() *Object { - if m != nil { - return m.Object - } - return nil -} - -func (m *PutRequest_PutHeader) GetCopiesNumber() uint32 { - if m != nil { - return m.CopiesNumber - } - return 0 -} - -type PutResponse struct { - // Address of object (container id + object id) - Address refs.Address `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PutResponse) Reset() { *m = PutResponse{} } -func (m *PutResponse) String() string { return proto.CompactTextString(m) } -func (*PutResponse) ProtoMessage() {} -func (*PutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{3} -} -func (m *PutResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PutResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PutResponse.Merge(m, src) -} -func (m *PutResponse) XXX_Size() int { - return m.Size() -} -func (m *PutResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PutResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PutResponse proto.InternalMessageInfo - -func (m *PutResponse) GetAddress() refs.Address { - if m != nil { - return m.Address - } - return refs.Address{} -} - -type DeleteRequest struct { - // Address of object (container id + object id) - Address refs.Address `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{4} -} -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return m.Size() -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -func (m *DeleteRequest) GetAddress() refs.Address { - if m != nil { - return m.Address - } - return refs.Address{} -} - -// DeleteResponse is empty because we cannot guarantee permanent object removal -// in distributed system. -type DeleteResponse struct { - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{5} -} -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return m.Size() -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -type HeadRequest struct { - // Address of object (container id + object id) - Address Address `protobuf:"bytes,1,opt,name=Address,proto3,customtype=Address" json:"Address"` - // FullHeaders can be set true for extended headers in the object - FullHeaders bool `protobuf:"varint,2,opt,name=FullHeaders,proto3" json:"FullHeaders,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HeadRequest) Reset() { *m = HeadRequest{} } -func (m *HeadRequest) String() string { return proto.CompactTextString(m) } -func (*HeadRequest) ProtoMessage() {} -func (*HeadRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{6} -} -func (m *HeadRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HeadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *HeadRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeadRequest.Merge(m, src) -} -func (m *HeadRequest) XXX_Size() int { - return m.Size() -} -func (m *HeadRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HeadRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HeadRequest proto.InternalMessageInfo - -func (m *HeadRequest) GetFullHeaders() bool { - if m != nil { - return m.FullHeaders - } - return false -} - -type HeadResponse struct { - // Object without payload - Object *Object `protobuf:"bytes,1,opt,name=Object,proto3" json:"Object,omitempty"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HeadResponse) Reset() { *m = HeadResponse{} } -func (m *HeadResponse) String() string { return proto.CompactTextString(m) } -func (*HeadResponse) ProtoMessage() {} -func (*HeadResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{7} -} -func (m *HeadResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HeadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *HeadResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeadResponse.Merge(m, src) -} -func (m *HeadResponse) XXX_Size() int { - return m.Size() -} -func (m *HeadResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HeadResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_HeadResponse proto.InternalMessageInfo - -func (m *HeadResponse) GetObject() *Object { - if m != nil { - return m.Object - } - return nil -} - -type SearchRequest struct { - // ContainerID for searching the object - ContainerID CID `protobuf:"bytes,1,opt,name=ContainerID,proto3,customtype=CID" json:"ContainerID"` - // Query in the binary serialized format - Query []byte `protobuf:"bytes,2,opt,name=Query,proto3" json:"Query,omitempty"` - // QueryVersion is a version of search query format - QueryVersion uint32 `protobuf:"varint,3,opt,name=QueryVersion,proto3" json:"QueryVersion,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SearchRequest) Reset() { *m = SearchRequest{} } -func (m *SearchRequest) String() string { return proto.CompactTextString(m) } -func (*SearchRequest) ProtoMessage() {} -func (*SearchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{8} -} -func (m *SearchRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SearchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SearchRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SearchRequest.Merge(m, src) -} -func (m *SearchRequest) XXX_Size() int { - return m.Size() -} -func (m *SearchRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SearchRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SearchRequest proto.InternalMessageInfo - -func (m *SearchRequest) GetQuery() []byte { - if m != nil { - return m.Query - } - return nil -} - -func (m *SearchRequest) GetQueryVersion() uint32 { - if m != nil { - return m.QueryVersion - } - return 0 -} - -type SearchResponse struct { - // Addresses of found objects - Addresses []refs.Address `protobuf:"bytes,1,rep,name=Addresses,proto3" json:"Addresses"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SearchResponse) Reset() { *m = SearchResponse{} } -func (m *SearchResponse) String() string { return proto.CompactTextString(m) } -func (*SearchResponse) ProtoMessage() {} -func (*SearchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{9} -} -func (m *SearchResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SearchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SearchResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SearchResponse.Merge(m, src) -} -func (m *SearchResponse) XXX_Size() int { - return m.Size() -} -func (m *SearchResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SearchResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SearchResponse proto.InternalMessageInfo - -func (m *SearchResponse) GetAddresses() []refs.Address { - if m != nil { - return m.Addresses - } - return nil -} - -type GetRangeRequest struct { - // Address of object (container id + object id) - Address refs.Address `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address"` - // Range of object's payload to return - Range Range `protobuf:"bytes,2,opt,name=Range,proto3" json:"Range"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRangeRequest) Reset() { *m = GetRangeRequest{} } -func (m *GetRangeRequest) String() string { return proto.CompactTextString(m) } -func (*GetRangeRequest) ProtoMessage() {} -func (*GetRangeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{10} -} -func (m *GetRangeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRangeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRangeRequest.Merge(m, src) -} -func (m *GetRangeRequest) XXX_Size() int { - return m.Size() -} -func (m *GetRangeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRangeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRangeRequest proto.InternalMessageInfo - -func (m *GetRangeRequest) GetAddress() refs.Address { - if m != nil { - return m.Address - } - return refs.Address{} -} - -func (m *GetRangeRequest) GetRange() Range { - if m != nil { - return m.Range - } - return Range{} -} - -type GetRangeResponse struct { - // Fragment of object's payload - Fragment []byte `protobuf:"bytes,1,opt,name=Fragment,proto3" json:"Fragment,omitempty"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRangeResponse) Reset() { *m = GetRangeResponse{} } -func (m *GetRangeResponse) String() string { return proto.CompactTextString(m) } -func (*GetRangeResponse) ProtoMessage() {} -func (*GetRangeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{11} -} -func (m *GetRangeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRangeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRangeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRangeResponse.Merge(m, src) -} -func (m *GetRangeResponse) XXX_Size() int { - return m.Size() -} -func (m *GetRangeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetRangeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRangeResponse proto.InternalMessageInfo - -func (m *GetRangeResponse) GetFragment() []byte { - if m != nil { - return m.Fragment - } - return nil -} - -type GetRangeHashRequest struct { - // Address of object (container id + object id) - Address refs.Address `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address"` - // Ranges of object's payload to calculate homomorphic hash - Ranges []Range `protobuf:"bytes,2,rep,name=Ranges,proto3" json:"Ranges"` - // Salt is used to XOR object's payload ranges before hashing, it can be nil - Salt []byte `protobuf:"bytes,3,opt,name=Salt,proto3" json:"Salt,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRangeHashRequest) Reset() { *m = GetRangeHashRequest{} } -func (m *GetRangeHashRequest) String() string { return proto.CompactTextString(m) } -func (*GetRangeHashRequest) ProtoMessage() {} -func (*GetRangeHashRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{12} -} -func (m *GetRangeHashRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRangeHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRangeHashRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRangeHashRequest.Merge(m, src) -} -func (m *GetRangeHashRequest) XXX_Size() int { - return m.Size() -} -func (m *GetRangeHashRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRangeHashRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRangeHashRequest proto.InternalMessageInfo - -func (m *GetRangeHashRequest) GetAddress() refs.Address { - if m != nil { - return m.Address - } - return refs.Address{} -} - -func (m *GetRangeHashRequest) GetRanges() []Range { - if m != nil { - return m.Ranges - } - return nil -} - -func (m *GetRangeHashRequest) GetSalt() []byte { - if m != nil { - return m.Salt - } - return nil -} - -type GetRangeHashResponse struct { - // Hashes is a homomorphic hashes of all ranges - Hashes []Hash `protobuf:"bytes,1,rep,name=Hashes,proto3,customtype=Hash" json:"Hashes"` - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader `protobuf:"bytes,99,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRangeHashResponse) Reset() { *m = GetRangeHashResponse{} } -func (m *GetRangeHashResponse) String() string { return proto.CompactTextString(m) } -func (*GetRangeHashResponse) ProtoMessage() {} -func (*GetRangeHashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dfcdf610ade6a9ce, []int{13} -} -func (m *GetRangeHashResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetRangeHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *GetRangeHashResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRangeHashResponse.Merge(m, src) -} -func (m *GetRangeHashResponse) XXX_Size() int { - return m.Size() -} -func (m *GetRangeHashResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetRangeHashResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRangeHashResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*GetRequest)(nil), "object.GetRequest") - proto.RegisterType((*GetResponse)(nil), "object.GetResponse") - proto.RegisterType((*PutRequest)(nil), "object.PutRequest") - proto.RegisterType((*PutRequest_PutHeader)(nil), "object.PutRequest.PutHeader") - proto.RegisterType((*PutResponse)(nil), "object.PutResponse") - proto.RegisterType((*DeleteRequest)(nil), "object.DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "object.DeleteResponse") - proto.RegisterType((*HeadRequest)(nil), "object.HeadRequest") - proto.RegisterType((*HeadResponse)(nil), "object.HeadResponse") - proto.RegisterType((*SearchRequest)(nil), "object.SearchRequest") - proto.RegisterType((*SearchResponse)(nil), "object.SearchResponse") - proto.RegisterType((*GetRangeRequest)(nil), "object.GetRangeRequest") - proto.RegisterType((*GetRangeResponse)(nil), "object.GetRangeResponse") - proto.RegisterType((*GetRangeHashRequest)(nil), "object.GetRangeHashRequest") - proto.RegisterType((*GetRangeHashResponse)(nil), "object.GetRangeHashResponse") -} - -func init() { proto.RegisterFile("object/service.proto", fileDescriptor_dfcdf610ade6a9ce) } - -var fileDescriptor_dfcdf610ade6a9ce = []byte{ - // 876 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4b, 0x6f, 0x22, 0x47, - 0x10, 0xa6, 0x01, 0x8f, 0x71, 0x31, 0xd8, 0x56, 0x9b, 0x38, 0x68, 0x6c, 0x61, 0x0b, 0x45, 0x11, - 0x51, 0xc4, 0xe0, 0x38, 0x52, 0xe2, 0x9c, 0x22, 0x03, 0xb2, 0x41, 0x51, 0xfc, 0x18, 0x24, 0x47, - 0xca, 0x6d, 0x18, 0x1a, 0x98, 0x04, 0x66, 0xf0, 0x3c, 0x6c, 0xf9, 0x92, 0x5b, 0xce, 0xb9, 0xe6, - 0xb8, 0xe7, 0xfd, 0x09, 0xbb, 0x7f, 0xc0, 0x47, 0x1f, 0x57, 0x7b, 0xb0, 0x56, 0xec, 0x69, 0xb5, - 0x7f, 0x60, 0x8f, 0xab, 0xe9, 0xee, 0x79, 0xd9, 0xcb, 0x3e, 0xe0, 0xc0, 0x69, 0xba, 0xbf, 0xfa, - 0xaa, 0xba, 0xea, 0xeb, 0xea, 0xee, 0x81, 0xbc, 0xd9, 0xf9, 0x8b, 0x68, 0x4e, 0xd5, 0x26, 0xd6, - 0x95, 0xae, 0x11, 0x79, 0x6c, 0x99, 0x8e, 0x89, 0x05, 0x86, 0x4a, 0xeb, 0x16, 0xe9, 0xd9, 0x55, - 0xe7, 0x66, 0x4c, 0x6c, 0x66, 0x91, 0x30, 0xe7, 0xc7, 0x30, 0xee, 0x5c, 0x1d, 0x11, 0x47, 0xe5, - 0x58, 0xde, 0xc7, 0xae, 0x88, 0xa5, 0xf7, 0x6e, 0x38, 0x5a, 0xe9, 0xeb, 0xce, 0xc0, 0xed, 0xc8, - 0x9a, 0x39, 0xaa, 0xf6, 0xcd, 0xbe, 0x59, 0xa5, 0x70, 0xc7, 0xed, 0xd1, 0x19, 0x9d, 0xd0, 0x11, - 0xa3, 0x97, 0x9e, 0x23, 0x80, 0x63, 0xe2, 0x28, 0xe4, 0xd2, 0x25, 0xb6, 0x83, 0x2b, 0xb0, 0x7c, - 0xd8, 0xed, 0x5a, 0xc4, 0xb6, 0x0b, 0x68, 0x17, 0x95, 0xb3, 0xfb, 0x39, 0xd9, 0xcb, 0x4f, 0xe6, - 0x60, 0x2d, 0x7d, 0x7b, 0xbf, 0x93, 0x50, 0x7c, 0x0e, 0x3e, 0x80, 0xf4, 0xef, 0xc4, 0x51, 0x0b, - 0x1d, 0xca, 0x95, 0x64, 0xbf, 0x44, 0x1e, 0xce, 0xb3, 0x35, 0x89, 0xda, 0x25, 0x56, 0x2d, 0xe3, - 0x39, 0xde, 0xdd, 0xef, 0x20, 0x85, 0x7a, 0xe0, 0x06, 0x08, 0x17, 0x34, 0xed, 0x82, 0x46, 0x7d, - 0x4b, 0x0f, 0x7d, 0xa9, 0x55, 0xd7, 0x54, 0x47, 0x37, 0x8d, 0x47, 0x31, 0xb8, 0x6f, 0xe9, 0x3f, - 0x04, 0x59, 0x9a, 0xbd, 0x3d, 0x36, 0x0d, 0x9b, 0xe0, 0x32, 0x70, 0x59, 0x79, 0xf6, 0xab, 0x32, - 0x9b, 0xca, 0xa7, 0xf4, 0xd3, 0x4c, 0x28, 0xdc, 0x8e, 0x37, 0x61, 0xa9, 0x3e, 0x70, 0x8d, 0xbf, - 0x0b, 0xc9, 0x5d, 0x54, 0x16, 0x9b, 0x09, 0x85, 0x4d, 0xf1, 0x2f, 0xbc, 0x22, 0x96, 0xd5, 0x56, - 0x24, 0x2b, 0xb6, 0xc4, 0xf4, 0x92, 0x6a, 0x29, 0x40, 0x4a, 0xe9, 0x59, 0x12, 0xe0, 0xcc, 0x0d, - 0xf4, 0xfc, 0x09, 0x04, 0xc6, 0xe6, 0x09, 0x6d, 0xfb, 0x09, 0x85, 0x1c, 0x6f, 0xc8, 0x38, 0x5e, - 0x7a, 0x6c, 0x34, 0x35, 0xbd, 0x05, 0x0b, 0x2e, 0xfd, 0x01, 0x2b, 0x41, 0xba, 0xf8, 0x5b, 0x10, - 0x4e, 0x3f, 0xa2, 0xb6, 0xc2, 0xad, 0xb8, 0x04, 0x62, 0xdd, 0x1c, 0xeb, 0xc4, 0x3e, 0x71, 0x47, - 0x1d, 0x62, 0xd1, 0x9a, 0x72, 0x4a, 0x0c, 0x63, 0xe2, 0x5d, 0x43, 0x96, 0xea, 0xc2, 0x77, 0xf3, - 0x0b, 0x9b, 0x71, 0xf6, 0xad, 0x2b, 0xbd, 0x41, 0x90, 0x6b, 0x90, 0x21, 0x71, 0xc8, 0x8c, 0x07, - 0xe1, 0x3b, 0x58, 0x3e, 0xbd, 0x36, 0x88, 0xd5, 0x6a, 0xb0, 0x1d, 0xab, 0xad, 0x79, 0xf6, 0x97, - 0xf7, 0x3b, 0x3e, 0xac, 0xf8, 0x83, 0x85, 0x9f, 0x99, 0xdf, 0x60, 0xd5, 0x2f, 0x95, 0xeb, 0x3c, - 0x9f, 0x70, 0x59, 0xcf, 0xe4, 0xcb, 0x76, 0xf0, 0x09, 0xd9, 0x02, 0x59, 0x38, 0x10, 0x2a, 0xb8, - 0x0b, 0xd9, 0x23, 0x77, 0x38, 0x64, 0xeb, 0xd8, 0x54, 0xc5, 0x8c, 0x12, 0x85, 0x16, 0x2e, 0xdc, - 0x25, 0x88, 0xac, 0x54, 0x2e, 0xdb, 0xe7, 0xb6, 0xff, 0x1c, 0xf2, 0xbe, 0x43, 0x90, 0x6b, 0x13, - 0xd5, 0xd2, 0x06, 0x61, 0x5f, 0x66, 0xeb, 0xa6, 0xe1, 0xa8, 0x3a, 0x6b, 0x36, 0x44, 0x9b, 0x2d, - 0xcb, 0x55, 0x4d, 0xd5, 0x5b, 0x0d, 0x25, 0x6a, 0xc7, 0x79, 0x58, 0x3a, 0x77, 0x89, 0x75, 0xc3, - 0xba, 0x52, 0x61, 0x13, 0xef, 0x40, 0xd2, 0xc1, 0x05, 0xb1, 0x6c, 0xdd, 0x34, 0x0a, 0x29, 0x76, - 0x20, 0xa3, 0xd8, 0xc2, 0xd5, 0xfe, 0x07, 0x56, 0xfd, 0xca, 0xb9, 0xde, 0x3f, 0xc0, 0x0a, 0x6f, - 0x16, 0xe2, 0x75, 0x57, 0x6a, 0xda, 0xa1, 0x0c, 0x59, 0xf3, 0x48, 0xff, 0x16, 0xc1, 0x9a, 0xf7, - 0xb4, 0xa8, 0x46, 0x7f, 0xf6, 0x4b, 0x61, 0x89, 0xba, 0x53, 0xf1, 0x3d, 0x32, 0xef, 0x0f, 0x0a, - 0x72, 0x32, 0x63, 0x2c, 0x5c, 0x6d, 0x1d, 0xd6, 0xc3, 0x62, 0xb9, 0xde, 0x12, 0x64, 0x8e, 0x2c, - 0xb5, 0x3f, 0x22, 0x06, 0xeb, 0x70, 0x51, 0x09, 0xe6, 0xf3, 0x08, 0xfb, 0x6f, 0x12, 0x36, 0xfc, - 0xb5, 0x9a, 0xaa, 0x3d, 0x98, 0x51, 0xdc, 0xef, 0x41, 0xa0, 0x21, 0xbc, 0xab, 0x22, 0x35, 0x4d, - 0x5d, 0x4e, 0xc1, 0x18, 0xd2, 0x6d, 0x75, 0xe8, 0xd0, 0x46, 0x17, 0x15, 0x3a, 0x5e, 0xb8, 0xe4, - 0xd7, 0x90, 0x8f, 0xcb, 0xc0, 0x65, 0xff, 0x06, 0x04, 0x6f, 0xce, 0x7b, 0x5c, 0xac, 0x89, 0xfc, - 0x70, 0xa7, 0x29, 0x8b, 0xdb, 0xe6, 0xd8, 0x80, 0xfd, 0x27, 0x29, 0x58, 0x6e, 0x33, 0x3a, 0xde, - 0x83, 0xd4, 0x31, 0x71, 0x30, 0xf6, 0xc5, 0x0b, 0x7f, 0x05, 0xa5, 0x8d, 0x18, 0xc6, 0xa2, 0xee, - 0x21, 0xcf, 0xe3, 0xcc, 0x8d, 0x78, 0x84, 0x3f, 0x32, 0xa1, 0x47, 0xe4, 0x11, 0x2f, 0x23, 0xfc, - 0x33, 0x08, 0xec, 0xc1, 0xc1, 0x5f, 0xf9, 0x84, 0xd8, 0x5b, 0x2b, 0x6d, 0x3e, 0x84, 0x83, 0x03, - 0x9f, 0xf6, 0x4a, 0xc0, 0x41, 0xdc, 0xc8, 0x4b, 0x23, 0xe5, 0xe3, 0x60, 0xf0, 0x94, 0x09, 0xec, - 0xd6, 0x08, 0xd7, 0x8a, 0xdd, 0x9f, 0xe1, 0x5a, 0xf1, 0xcb, 0x65, 0x0f, 0xe1, 0x5f, 0x21, 0xe3, - 0xef, 0x07, 0xfe, 0x3a, 0x5a, 0x7b, 0xe4, 0x06, 0x90, 0x0a, 0x8f, 0x0d, 0x41, 0x80, 0x16, 0x88, - 0xd1, 0x0d, 0xc5, 0x5b, 0x0f, 0xb9, 0x91, 0x6e, 0x97, 0xb6, 0x3f, 0x6c, 0x64, 0xc1, 0x6a, 0xe7, - 0xb7, 0x93, 0x22, 0xba, 0x9b, 0x14, 0xd1, 0x8b, 0x49, 0x11, 0xbd, 0x9a, 0x14, 0xd1, 0xff, 0xaf, - 0x8b, 0x89, 0x3f, 0xcb, 0x91, 0x5f, 0x7b, 0xc3, 0x1e, 0x6b, 0x5a, 0xa5, 0x4b, 0xae, 0xaa, 0x06, - 0x31, 0x7b, 0x76, 0x45, 0x1d, 0xeb, 0x95, 0xbe, 0x59, 0x65, 0x41, 0x9f, 0x26, 0xd7, 0x4f, 0x88, - 0x79, 0xd4, 0x96, 0x0f, 0xcf, 0x5a, 0xfc, 0x35, 0xea, 0x08, 0xf4, 0x7f, 0xff, 0xc7, 0xf7, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x71, 0xb8, 0x50, 0x3f, 0x8e, 0x0c, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ServiceClient interface { - // Get the object from container. Response uses gRPC stream. First response - // message carry object of requested address. Chunk messages are parts of - // the object's payload if it is needed. All messages except first carry - // chunks. Requested object can be restored by concatenation of object - // message payload and all chunks keeping receiving order. - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (Service_GetClient, error) - // Put the object into container. Request uses gRPC stream. First message - // SHOULD BE type of PutHeader. Container id and Owner id of object SHOULD - // BE set. Session token SHOULD BE obtained before put operation (see - // session package). Chunk messages considered by server as part of object - // payload. All messages except first SHOULD BE chunks. Chunk messages - // SHOULD BE sent in direct order of fragmentation. - Put(ctx context.Context, opts ...grpc.CallOption) (Service_PutClient, error) - // Delete the object from a container - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) - // Head returns the object without data payload. Object in the - // response has system header only. If full headers flag is set, extended - // headers are also present. - Head(ctx context.Context, in *HeadRequest, opts ...grpc.CallOption) (*HeadResponse, error) - // Search objects in container. Version of query language format SHOULD BE - // set to 1. Search query represented in serialized format (see query - // package). - Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (Service_SearchClient, error) - // GetRange of data payload. Range is a pair (offset, length). - // Requested range can be restored by concatenation of all chunks - // keeping receiving order. - GetRange(ctx context.Context, in *GetRangeRequest, opts ...grpc.CallOption) (Service_GetRangeClient, error) - // GetRangeHash returns homomorphic hash of object payload range after XOR - // operation. Ranges are set of pairs (offset, length). Hashes order in - // response corresponds to ranges order in request. Homomorphic hash is - // calculated for XORed data. - GetRangeHash(ctx context.Context, in *GetRangeHashRequest, opts ...grpc.CallOption) (*GetRangeHashResponse, error) -} - -type serviceClient struct { - cc *grpc.ClientConn -} - -func NewServiceClient(cc *grpc.ClientConn) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (Service_GetClient, error) { - stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[0], "/object.Service/Get", opts...) - if err != nil { - return nil, err - } - x := &serviceGetClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Service_GetClient interface { - Recv() (*GetResponse, error) - grpc.ClientStream -} - -type serviceGetClient struct { - grpc.ClientStream -} - -func (x *serviceGetClient) Recv() (*GetResponse, error) { - m := new(GetResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *serviceClient) Put(ctx context.Context, opts ...grpc.CallOption) (Service_PutClient, error) { - stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[1], "/object.Service/Put", opts...) - if err != nil { - return nil, err - } - x := &servicePutClient{stream} - return x, nil -} - -type Service_PutClient interface { - Send(*PutRequest) error - CloseAndRecv() (*PutResponse, error) - grpc.ClientStream -} - -type servicePutClient struct { - grpc.ClientStream -} - -func (x *servicePutClient) Send(m *PutRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *servicePutClient) CloseAndRecv() (*PutResponse, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(PutResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *serviceClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/object.Service/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Head(ctx context.Context, in *HeadRequest, opts ...grpc.CallOption) (*HeadResponse, error) { - out := new(HeadResponse) - err := c.cc.Invoke(ctx, "/object.Service/Head", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (Service_SearchClient, error) { - stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[2], "/object.Service/Search", opts...) - if err != nil { - return nil, err - } - x := &serviceSearchClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Service_SearchClient interface { - Recv() (*SearchResponse, error) - grpc.ClientStream -} - -type serviceSearchClient struct { - grpc.ClientStream -} - -func (x *serviceSearchClient) Recv() (*SearchResponse, error) { - m := new(SearchResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *serviceClient) GetRange(ctx context.Context, in *GetRangeRequest, opts ...grpc.CallOption) (Service_GetRangeClient, error) { - stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[3], "/object.Service/GetRange", opts...) - if err != nil { - return nil, err - } - x := &serviceGetRangeClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Service_GetRangeClient interface { - Recv() (*GetRangeResponse, error) - grpc.ClientStream -} - -type serviceGetRangeClient struct { - grpc.ClientStream -} - -func (x *serviceGetRangeClient) Recv() (*GetRangeResponse, error) { - m := new(GetRangeResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *serviceClient) GetRangeHash(ctx context.Context, in *GetRangeHashRequest, opts ...grpc.CallOption) (*GetRangeHashResponse, error) { - out := new(GetRangeHashResponse) - err := c.cc.Invoke(ctx, "/object.Service/GetRangeHash", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -type ServiceServer interface { - // Get the object from container. Response uses gRPC stream. First response - // message carry object of requested address. Chunk messages are parts of - // the object's payload if it is needed. All messages except first carry - // chunks. Requested object can be restored by concatenation of object - // message payload and all chunks keeping receiving order. - Get(*GetRequest, Service_GetServer) error - // Put the object into container. Request uses gRPC stream. First message - // SHOULD BE type of PutHeader. Container id and Owner id of object SHOULD - // BE set. Session token SHOULD BE obtained before put operation (see - // session package). Chunk messages considered by server as part of object - // payload. All messages except first SHOULD BE chunks. Chunk messages - // SHOULD BE sent in direct order of fragmentation. - Put(Service_PutServer) error - // Delete the object from a container - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) - // Head returns the object without data payload. Object in the - // response has system header only. If full headers flag is set, extended - // headers are also present. - Head(context.Context, *HeadRequest) (*HeadResponse, error) - // Search objects in container. Version of query language format SHOULD BE - // set to 1. Search query represented in serialized format (see query - // package). - Search(*SearchRequest, Service_SearchServer) error - // GetRange of data payload. Range is a pair (offset, length). - // Requested range can be restored by concatenation of all chunks - // keeping receiving order. - GetRange(*GetRangeRequest, Service_GetRangeServer) error - // GetRangeHash returns homomorphic hash of object payload range after XOR - // operation. Ranges are set of pairs (offset, length). Hashes order in - // response corresponds to ranges order in request. Homomorphic hash is - // calculated for XORed data. - GetRangeHash(context.Context, *GetRangeHashRequest) (*GetRangeHashResponse, error) -} - -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { -} - -func (*UnimplementedServiceServer) Get(req *GetRequest, srv Service_GetServer) error { - return status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedServiceServer) Put(srv Service_PutServer) error { - return status.Errorf(codes.Unimplemented, "method Put not implemented") -} -func (*UnimplementedServiceServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedServiceServer) Head(ctx context.Context, req *HeadRequest) (*HeadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Head not implemented") -} -func (*UnimplementedServiceServer) Search(req *SearchRequest, srv Service_SearchServer) error { - return status.Errorf(codes.Unimplemented, "method Search not implemented") -} -func (*UnimplementedServiceServer) GetRange(req *GetRangeRequest, srv Service_GetRangeServer) error { - return status.Errorf(codes.Unimplemented, "method GetRange not implemented") -} -func (*UnimplementedServiceServer) GetRangeHash(ctx context.Context, req *GetRangeHashRequest) (*GetRangeHashResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetRangeHash not implemented") -} - -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) -} - -func _Service_Get_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(GetRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ServiceServer).Get(m, &serviceGetServer{stream}) -} - -type Service_GetServer interface { - Send(*GetResponse) error - grpc.ServerStream -} - -type serviceGetServer struct { - grpc.ServerStream -} - -func (x *serviceGetServer) Send(m *GetResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _Service_Put_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServiceServer).Put(&servicePutServer{stream}) -} - -type Service_PutServer interface { - SendAndClose(*PutResponse) error - Recv() (*PutRequest, error) - grpc.ServerStream -} - -type servicePutServer struct { - grpc.ServerStream -} - -func (x *servicePutServer) SendAndClose(m *PutResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *servicePutServer) Recv() (*PutRequest, error) { - m := new(PutRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _Service_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/object.Service/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Head_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HeadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Head(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/object.Service/Head", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Head(ctx, req.(*HeadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Search_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(SearchRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ServiceServer).Search(m, &serviceSearchServer{stream}) -} - -type Service_SearchServer interface { - Send(*SearchResponse) error - grpc.ServerStream -} - -type serviceSearchServer struct { - grpc.ServerStream -} - -func (x *serviceSearchServer) Send(m *SearchResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _Service_GetRange_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(GetRangeRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ServiceServer).GetRange(m, &serviceGetRangeServer{stream}) -} - -type Service_GetRangeServer interface { - Send(*GetRangeResponse) error - grpc.ServerStream -} - -type serviceGetRangeServer struct { - grpc.ServerStream -} - -func (x *serviceGetRangeServer) Send(m *GetRangeResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _Service_GetRangeHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRangeHashRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).GetRangeHash(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/object.Service/GetRangeHash", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).GetRangeHash(ctx, req.(*GetRangeHashRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "object.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Delete", - Handler: _Service_Delete_Handler, - }, - { - MethodName: "Head", - Handler: _Service_Head_Handler, - }, - { - MethodName: "GetRangeHash", - Handler: _Service_GetRangeHash_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Get", - Handler: _Service_Get_Handler, - ServerStreams: true, - }, - { - StreamName: "Put", - Handler: _Service_Put_Handler, - ClientStreams: true, - }, - { - StreamName: "Search", - Handler: _Service_Search_Handler, - ServerStreams: true, - }, - { - StreamName: "GetRange", - Handler: _Service_GetRange_Handler, - ServerStreams: true, - }, - }, - Metadata: "object/service.proto", -} - -func (m *GetRequest) 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 *GetRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size, err := m.Address.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetResponse) 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 *GetResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - if m.R != nil { - { - size := m.R.Size() - i -= size - if _, err := m.R.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *GetResponse_Object) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetResponse_Object) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Object != nil { - { - size, err := m.Object.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *GetResponse_Chunk) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetResponse_Chunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Chunk != nil { - i -= len(m.Chunk) - copy(dAtA[i:], m.Chunk) - i = encodeVarintService(dAtA, i, uint64(len(m.Chunk))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *PutRequest) 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 *PutRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.R != nil { - { - size := m.R.Size() - i -= size - if _, err := m.R.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *PutRequest_Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest_Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Header != nil { - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *PutRequest_Chunk) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest_Chunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Chunk != nil { - i -= len(m.Chunk) - copy(dAtA[i:], m.Chunk) - i = encodeVarintService(dAtA, i, uint64(len(m.Chunk))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *PutRequest_PutHeader) 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 *PutRequest_PutHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutRequest_PutHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.CopiesNumber != 0 { - i = encodeVarintService(dAtA, i, uint64(m.CopiesNumber)) - i-- - dAtA[i] = 0x10 - } - if m.Object != nil { - { - size, err := m.Object.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PutResponse) 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 *PutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.Address.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DeleteRequest) 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 *DeleteRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Address.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DeleteResponse) 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 *DeleteResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - return len(dAtA) - i, nil -} - -func (m *HeadRequest) 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 *HeadRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeadRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.FullHeaders { - i-- - if m.FullHeaders { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - { - size := m.Address.Size() - i -= size - if _, err := m.Address.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *HeadResponse) 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 *HeadResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HeadResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - if m.Object != nil { - { - size, err := m.Object.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SearchRequest) 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 *SearchRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SearchRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.QueryVersion != 0 { - i = encodeVarintService(dAtA, i, uint64(m.QueryVersion)) - i-- - dAtA[i] = 0x18 - } - if len(m.Query) > 0 { - i -= len(m.Query) - copy(dAtA[i:], m.Query) - i = encodeVarintService(dAtA, i, uint64(len(m.Query))) - i-- - dAtA[i] = 0x12 - } - { - size := m.ContainerID.Size() - i -= size - if _, err := m.ContainerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *SearchResponse) 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 *SearchResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SearchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - if len(m.Addresses) > 0 { - for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Addresses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *GetRangeRequest) 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 *GetRangeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size, err := m.Range.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Address.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetRangeResponse) 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 *GetRangeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRangeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - if len(m.Fragment) > 0 { - i -= len(m.Fragment) - copy(dAtA[i:], m.Fragment) - i = encodeVarintService(dAtA, i, uint64(len(m.Fragment))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetRangeHashRequest) 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 *GetRangeHashRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRangeHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if len(m.Salt) > 0 { - i -= len(m.Salt) - copy(dAtA[i:], m.Salt) - i = encodeVarintService(dAtA, i, uint64(len(m.Salt))) - i-- - dAtA[i] = 0x1a - } - if len(m.Ranges) > 0 { - for iNdEx := len(m.Ranges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Ranges[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Address.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetRangeHashResponse) 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 *GetRangeHashResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetRangeHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.ResponseMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - if len(m.Hashes) > 0 { - for iNdEx := len(m.Hashes) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.Hashes[iNdEx].Size() - i -= size - if _, err := m.Hashes[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GetRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.R != nil { - n += m.R.Size() - } - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetResponse_Object) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Object != nil { - l = m.Object.Size() - n += 1 + l + sovService(uint64(l)) - } - return n -} -func (m *GetResponse_Chunk) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Chunk != nil { - l = len(m.Chunk) - n += 1 + l + sovService(uint64(l)) - } - return n -} -func (m *PutRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.R != nil { - n += m.R.Size() - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PutRequest_Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Header != nil { - l = m.Header.Size() - n += 1 + l + sovService(uint64(l)) - } - return n -} -func (m *PutRequest_Chunk) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Chunk != nil { - l = len(m.Chunk) - n += 1 + l + sovService(uint64(l)) - } - return n -} -func (m *PutRequest_PutHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Object != nil { - l = m.Object.Size() - n += 1 + l + sovService(uint64(l)) - } - if m.CopiesNumber != 0 { - n += 1 + sovService(uint64(m.CopiesNumber)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PutResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *HeadRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - if m.FullHeaders { - n += 2 - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *HeadResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Object != nil { - l = m.Object.Size() - n += 1 + l + sovService(uint64(l)) - } - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SearchRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ContainerID.Size() - n += 1 + l + sovService(uint64(l)) - l = len(m.Query) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.QueryVersion != 0 { - n += 1 + sovService(uint64(m.QueryVersion)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SearchResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Addresses) > 0 { - for _, e := range m.Addresses { - l = e.Size() - n += 1 + l + sovService(uint64(l)) - } - } - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRangeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - l = m.Range.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRangeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Fragment) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRangeHashRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Address.Size() - n += 1 + l + sovService(uint64(l)) - if len(m.Ranges) > 0 { - for _, e := range m.Ranges { - l = e.Size() - n += 1 + l + sovService(uint64(l)) - } - } - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *GetRangeHashResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Hashes) > 0 { - for _, e := range m.Hashes { - l = e.Size() - n += 1 + l + sovService(uint64(l)) - } - } - l = m.ResponseMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GetRequest) 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 ErrIntOverflowService - } - 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: GetRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetResponse) 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 ErrIntOverflowService - } - 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: GetResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Object{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.R = &GetResponse_Object{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.R = &GetResponse_Chunk{v} - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutRequest) 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 ErrIntOverflowService - } - 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: PutRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PutRequest_PutHeader{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.R = &PutRequest_Header{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.R = &PutRequest_Chunk{v} - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutRequest_PutHeader) 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 ErrIntOverflowService - } - 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: PutHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Object == nil { - m.Object = &Object{} - } - if err := m.Object.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CopiesNumber", wireType) - } - m.CopiesNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CopiesNumber |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PutResponse) 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 ErrIntOverflowService - } - 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: PutResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteRequest) 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 ErrIntOverflowService - } - 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: DeleteRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteResponse) 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 ErrIntOverflowService - } - 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: DeleteResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HeadRequest) 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 ErrIntOverflowService - } - 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: HeadRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HeadRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FullHeaders", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.FullHeaders = bool(v != 0) - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HeadResponse) 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 ErrIntOverflowService - } - 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: HeadResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HeadResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Object == nil { - m.Object = &Object{} - } - if err := m.Object.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SearchRequest) 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 ErrIntOverflowService - } - 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: SearchRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SearchRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ContainerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Query = append(m.Query[:0], dAtA[iNdEx:postIndex]...) - if m.Query == nil { - m.Query = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryVersion", wireType) - } - m.QueryVersion = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryVersion |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SearchResponse) 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 ErrIntOverflowService - } - 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: SearchResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SearchResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addresses = append(m.Addresses, refs.Address{}) - if err := m.Addresses[len(m.Addresses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRangeRequest) 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 ErrIntOverflowService - } - 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: GetRangeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRangeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Range", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Range.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRangeResponse) 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 ErrIntOverflowService - } - 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: GetRangeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRangeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fragment", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Fragment = append(m.Fragment[:0], dAtA[iNdEx:postIndex]...) - if m.Fragment == nil { - m.Fragment = []byte{} - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRangeHashRequest) 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 ErrIntOverflowService - } - 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: GetRangeHashRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRangeHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ranges", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ranges = append(m.Ranges, Range{}) - if err := m.Ranges[len(m.Ranges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) - if m.Salt == nil { - m.Salt = []byte{} - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetRangeHashResponse) 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 ErrIntOverflowService - } - 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: GetRangeHashResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetRangeHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hashes", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v Hash - m.Hashes = append(m.Hashes, v) - if err := m.Hashes[len(m.Hashes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResponseMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ResponseMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/object/service.proto b/object/service.proto deleted file mode 100644 index 91d0b99..0000000 --- a/object/service.proto +++ /dev/null @@ -1,197 +0,0 @@ -syntax = "proto3"; -package object; -option go_package = "github.com/nspcc-dev/neofs-api-go/object"; -option csharp_namespace = "NeoFS.API.Object"; - -import "refs/types.proto"; -import "object/types.proto"; -import "service/meta.proto"; -import "service/verify.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Object service provides API for manipulating with the object. -service Service { - - // Get the object from container. Response uses gRPC stream. First response - // message carry object of requested address. Chunk messages are parts of - // the object's payload if it is needed. All messages except first carry - // chunks. Requested object can be restored by concatenation of object - // message payload and all chunks keeping receiving order. - rpc Get(GetRequest) returns (stream GetResponse); - - // Put the object into container. Request uses gRPC stream. First message - // SHOULD BE type of PutHeader. Container id and Owner id of object SHOULD - // BE set. Session token SHOULD BE obtained before put operation (see - // session package). Chunk messages considered by server as part of object - // payload. All messages except first SHOULD BE chunks. Chunk messages - // SHOULD BE sent in direct order of fragmentation. - rpc Put(stream PutRequest) returns (PutResponse); - - // Delete the object from a container - rpc Delete(DeleteRequest) returns (DeleteResponse); - - // Head returns the object without data payload. Object in the - // response has system header only. If full headers flag is set, extended - // headers are also present. - rpc Head(HeadRequest) returns (HeadResponse); - - // Search objects in container. Version of query language format SHOULD BE - // set to 1. Search query represented in serialized format (see query - // package). - rpc Search(SearchRequest) returns (stream SearchResponse); - - // GetRange of data payload. Range is a pair (offset, length). - // Requested range can be restored by concatenation of all chunks - // keeping receiving order. - rpc GetRange(GetRangeRequest) returns (stream GetRangeResponse); - - // GetRangeHash returns homomorphic hash of object payload range after XOR - // operation. Ranges are set of pairs (offset, length). Hashes order in - // response corresponds to ranges order in request. Homomorphic hash is - // calculated for XORed data. - rpc GetRangeHash(GetRangeHashRequest) returns (GetRangeHashResponse); -} - -message GetRequest { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetResponse { - oneof R { - // Object header and some payload - Object object = 1; - // Chunk of remaining payload - bytes Chunk = 2; - } - - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message PutRequest { - message PutHeader { - // Object with at least container id and owner id fields - Object Object = 1; - // Number of the object copies to store within the RPC call (zero is processed according to the placement rules) - uint32 CopiesNumber = 2; - } - - oneof R { - // Header should be the first message in the stream - PutHeader Header = 1; - // Chunk should be a remaining message in stream should be chunks - bytes Chunk = 2; - } - - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message PutResponse { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false]; - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} -message DeleteRequest { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false]; - // OwnerID is a wallet address - bytes OwnerID = 2 [(gogoproto.nullable) = false, (gogoproto.customtype) = "OwnerID"]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// DeleteResponse is empty because we cannot guarantee permanent object removal -// in distributed system. -message DeleteResponse { - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message HeadRequest { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "Address"]; - // FullHeaders can be set true for extended headers in the object - bool FullHeaders = 2; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} -message HeadResponse { - // Object without payload - Object Object = 1; - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message SearchRequest { - // ContainerID for searching the object - bytes ContainerID = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "CID"]; - // Query in the binary serialized format - bytes Query = 2; - // QueryVersion is a version of search query format - uint32 QueryVersion = 3; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message SearchResponse { - // Addresses of found objects - repeated refs.Address Addresses = 1 [(gogoproto.nullable) = false]; - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetRangeRequest { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false]; - // Range of object's payload to return - Range Range = 2 [(gogoproto.nullable) = false]; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetRangeResponse { - // Fragment of object's payload - bytes Fragment = 1; - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetRangeHashRequest { - // Address of object (container id + object id) - refs.Address Address = 1 [(gogoproto.nullable) = false]; - // Ranges of object's payload to calculate homomorphic hash - repeated Range Ranges = 2 [(gogoproto.nullable) = false]; - // Salt is used to XOR object's payload ranges before hashing, it can be nil - bytes Salt = 3; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -message GetRangeHashResponse { - // Hashes is a homomorphic hashes of all ranges - repeated bytes Hashes = 1 [(gogoproto.customtype) = "Hash", (gogoproto.nullable) = false]; - // ResponseMetaHeader contains meta information based on request processing by server (should be embedded into message) - service.ResponseMetaHeader Meta = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - diff --git a/object/service_test.go b/object/service_test.go deleted file mode 100644 index 5b7a358..0000000 --- a/object/service_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package object - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestRequest(t *testing.T) { - cases := []Request{ - &PutRequest{}, - &GetRequest{}, - &HeadRequest{}, - &SearchRequest{}, - &DeleteRequest{}, - &GetRangeRequest{}, - &GetRangeHashRequest{}, - MakePutRequestHeader(nil), - MakePutRequestHeader(&Object{}), - } - - types := []RequestType{ - RequestPut, - RequestGet, - RequestHead, - RequestSearch, - RequestDelete, - RequestRange, - RequestRangeHash, - RequestPut, - RequestPut, - } - - for i := range cases { - v := cases[i] - - t.Run(fmt.Sprintf("%T_%d", v, i), func(t *testing.T) { - require.NotPanics(t, func() { v.CID() }) - require.Equal(t, types[i], v.Type()) - }) - } -} diff --git a/object/sg.go b/object/sg.go deleted file mode 100644 index a75b950..0000000 --- a/object/sg.go +++ /dev/null @@ -1,43 +0,0 @@ -package object - -import ( - "sort" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/storagegroup" -) - -// Here are defined getter functions for objects that contain storage group -// information. - -var _ storagegroup.Provider = (*Object)(nil) - -// Group returns slice of object ids that are part of a storage group. -func (m *Object) Group() []refs.ObjectID { - sgLinks := m.Links(Link_StorageGroup) - sort.Sort(storagegroup.IDList(sgLinks)) - return sgLinks -} - -// Zones returns validation zones of storage group. -func (m *Object) Zones() []storagegroup.ZoneInfo { - sgInfo, err := m.StorageGroup() - if err != nil { - return nil - } - return []storagegroup.ZoneInfo{ - { - Hash: sgInfo.ValidationHash, - Size: sgInfo.ValidationDataSize, - }, - } -} - -// IDInfo returns meta information about storage group. -func (m *Object) IDInfo() *storagegroup.IdentificationInfo { - return &storagegroup.IdentificationInfo{ - SGID: m.SystemHeader.ID, - CID: m.SystemHeader.CID, - OwnerID: m.SystemHeader.OwnerID, - } -} diff --git a/object/sg_test.go b/object/sg_test.go deleted file mode 100644 index 716e916..0000000 --- a/object/sg_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package object - -import ( - "math/rand" - "sort" - "testing" - - "github.com/nspcc-dev/neofs-api-go/hash" - "github.com/nspcc-dev/neofs-api-go/storagegroup" - "github.com/stretchr/testify/require" -) - -func TestObject_StorageGroup(t *testing.T) { - t.Run("group method", func(t *testing.T) { - var linkCount byte = 100 - - obj := &Object{Headers: make([]Header, 0, linkCount)} - require.Empty(t, obj.Group()) - - idList := make([]ID, linkCount) - for i := byte(0); i < linkCount; i++ { - idList[i] = ID{i} - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Link{Link: &Link{ - Type: Link_StorageGroup, - ID: idList[i], - }}, - }) - } - - rand.Shuffle(len(obj.Headers), func(i, j int) { obj.Headers[i], obj.Headers[j] = obj.Headers[j], obj.Headers[i] }) - sort.Sort(storagegroup.IDList(idList)) - require.Equal(t, idList, obj.Group()) - }) - t.Run("identification method", func(t *testing.T) { - oid, cid, owner := ID{1}, CID{2}, OwnerID{3} - obj := &Object{ - SystemHeader: SystemHeader{ - ID: oid, - OwnerID: owner, - CID: cid, - }, - } - - idInfo := obj.IDInfo() - require.Equal(t, oid, idInfo.SGID) - require.Equal(t, cid, idInfo.CID) - require.Equal(t, owner, idInfo.OwnerID) - }) - t.Run("zones method", func(t *testing.T) { - sgSize := uint64(100) - - d := make([]byte, sgSize) - _, err := rand.Read(d) - require.NoError(t, err) - sgHash := hash.Sum(d) - - obj := &Object{ - Headers: []Header{ - { - Value: &Header_StorageGroup{ - StorageGroup: &storagegroup.StorageGroup{ - ValidationDataSize: sgSize, - ValidationHash: sgHash, - }, - }, - }, - }, - } - - var ( - sumSize uint64 - zones = obj.Zones() - hashes = make([]Hash, len(zones)) - ) - - for i := range zones { - sumSize += zones[i].Size - hashes[i] = zones[i].Hash - } - - sumHash, err := hash.Concat(hashes) - require.NoError(t, err) - - require.Equal(t, sgSize, sumSize) - require.Equal(t, sgHash, sumHash) - }) -} diff --git a/object/sign.go b/object/sign.go deleted file mode 100644 index 3cdf94f..0000000 --- a/object/sign.go +++ /dev/null @@ -1,272 +0,0 @@ -package object - -import ( - "crypto/ecdsa" - "encoding/binary" - "io" - - "github.com/nspcc-dev/neofs-api-go/service" -) - -// SignedData returns payload bytes of the request. -// -// If payload is nil, ErrHeaderNotFound returns. -func (m PutRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m PutRequest) ReadSignedData(p []byte) (int, error) { - r := m.GetR() - if r == nil { - return 0, ErrHeaderNotFound - } - - return r.MarshalTo(p) -} - -// SignedDataSize returns the size of payload of the Put request. -// -// If payload is nil, -1 returns. -func (m PutRequest) SignedDataSize() int { - r := m.GetR() - if r == nil { - return -1 - } - - return r.Size() -} - -// SignedData returns payload bytes of the request. -func (m GetRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetRequest) ReadSignedData(p []byte) (int, error) { - addr := m.GetAddress() - - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], addr.CID.Bytes()) - - off += copy(p[off:], addr.ObjectID.Bytes()) - - return off, nil -} - -// SignedDataSize returns payload size of the request. -func (m GetRequest) SignedDataSize() int { - return addressSize(m.GetAddress()) -} - -// SignedData returns payload bytes of the request. -func (m HeadRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m HeadRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - if m.GetFullHeaders() { - p[0] = 1 - } else { - p[0] = 0 - } - - off := 1 - - off += copy(p[off:], m.Address.CID.Bytes()) - - off += copy(p[off:], m.Address.ObjectID.Bytes()) - - return off, nil -} - -// SignedDataSize returns payload size of the request. -func (m HeadRequest) SignedDataSize() int { - return addressSize(m.Address) + 1 -} - -// SignedData returns payload bytes of the request. -func (m DeleteRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m DeleteRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.OwnerID.Bytes()) - - off += copy(p[off:], addressBytes(m.Address)) - - return off, nil -} - -// SignedDataSize returns payload size of the request. -func (m DeleteRequest) SignedDataSize() int { - return m.OwnerID.Size() + addressSize(m.Address) -} - -// SignedData returns payload bytes of the request. -func (m GetRangeRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetRangeRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - n, err := (&m.Range).MarshalTo(p) - if err != nil { - return 0, err - } - - n += copy(p[n:], addressBytes(m.GetAddress())) - - return n, nil -} - -// SignedDataSize returns payload size of the request. -func (m GetRangeRequest) SignedDataSize() int { - return (&m.Range).Size() + addressSize(m.GetAddress()) -} - -// SignedData returns payload bytes of the request. -func (m GetRangeHashRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m GetRangeHashRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], addressBytes(m.GetAddress())) - - off += copy(p[off:], rangeSetBytes(m.GetRanges())) - - off += copy(p[off:], m.GetSalt()) - - return off, nil -} - -// SignedDataSize returns payload size of the request. -func (m GetRangeHashRequest) SignedDataSize() int { - var sz int - - sz += addressSize(m.GetAddress()) - - sz += rangeSetSize(m.GetRanges()) - - sz += len(m.GetSalt()) - - return sz -} - -// SignedData returns payload bytes of the request. -func (m SearchRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m SearchRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.CID().Bytes()) - - binary.BigEndian.PutUint32(p[off:], m.GetQueryVersion()) - off += 4 - - off += copy(p[off:], m.GetQuery()) - - return off, nil -} - -// SignedDataSize returns payload size of the request. -func (m SearchRequest) SignedDataSize() int { - var sz int - - sz += m.CID().Size() - - sz += 4 // uint32 Version - - sz += len(m.GetQuery()) - - return sz -} - -func rangeSetSize(rs []Range) int { - return 4 + len(rs)*16 // two uint64 fields -} - -func rangeSetBytes(rs []Range) []byte { - data := make([]byte, rangeSetSize(rs)) - - binary.BigEndian.PutUint32(data, uint32(len(rs))) - - off := 4 - - for i := range rs { - binary.BigEndian.PutUint64(data[off:], rs[i].Offset) - off += 8 - - binary.BigEndian.PutUint64(data[off:], rs[i].Length) - off += 8 - } - - return data -} - -func addressSize(addr Address) int { - return addr.CID.Size() + addr.ObjectID.Size() -} - -func addressBytes(addr Address) []byte { - return append(addr.CID.Bytes(), addr.ObjectID.Bytes()...) -} - -// SignedData returns the result of the ChecksumSignature field getter. -func (m IntegrityHeader) SignedData() ([]byte, error) { - return m.GetHeadersChecksum(), nil -} - -// AddSignKey calls the ChecksumSignature field setter with signature argument. -func (m *IntegrityHeader) AddSignKey(sign []byte, _ *ecdsa.PublicKey) { - m.SetSignature(sign) -} diff --git a/object/sign_test.go b/object/sign_test.go deleted file mode 100644 index dcfbd7e..0000000 --- a/object/sign_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package object - -import ( - "crypto/rand" - "testing" - - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestSignVerifyRequests(t *testing.T) { - sk := test.DecodeKey(0) - - type sigType interface { - service.RequestData - service.SignKeyPairAccumulator - service.SignKeyPairSource - SetToken(*Token) - } - - items := []struct { - constructor func() sigType - payloadCorrupt []func(sigType) - }{ - { // PutRequest.PutHeader - constructor: func() sigType { - return MakePutRequestHeader(new(Object)) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - obj := s.(*PutRequest).GetR().(*PutRequest_Header).Header.GetObject() - obj.SystemHeader.PayloadLength++ - }, - }, - }, - { // PutRequest.Chunk - constructor: func() sigType { - return MakePutRequestChunk(make([]byte, 10)) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - h := s.(*PutRequest).GetR().(*PutRequest_Chunk) - h.Chunk[0]++ - }, - }, - }, - { // GetRequest - constructor: func() sigType { - return new(GetRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*GetRequest).Address.CID[0]++ - }, - func(s sigType) { - s.(*GetRequest).Address.ObjectID[0]++ - }, - }, - }, - { // HeadRequest - constructor: func() sigType { - return new(HeadRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*HeadRequest).Address.CID[0]++ - }, - func(s sigType) { - s.(*HeadRequest).Address.ObjectID[0]++ - }, - func(s sigType) { - s.(*HeadRequest).FullHeaders = true - }, - }, - }, - { // DeleteRequest - constructor: func() sigType { - return new(DeleteRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*DeleteRequest).OwnerID[0]++ - }, - func(s sigType) { - s.(*DeleteRequest).Address.CID[0]++ - }, - func(s sigType) { - s.(*DeleteRequest).Address.ObjectID[0]++ - }, - }, - }, - { // GetRangeRequest - constructor: func() sigType { - return new(GetRangeRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*GetRangeRequest).Range.Length++ - }, - func(s sigType) { - s.(*GetRangeRequest).Range.Offset++ - }, - func(s sigType) { - s.(*GetRangeRequest).Address.CID[0]++ - }, - func(s sigType) { - s.(*GetRangeRequest).Address.ObjectID[0]++ - }, - }, - }, - { // GetRangeHashRequest - constructor: func() sigType { - return &GetRangeHashRequest{ - Ranges: []Range{{}}, - Salt: []byte{1, 2, 3}, - } - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*GetRangeHashRequest).Address.CID[0]++ - }, - func(s sigType) { - s.(*GetRangeHashRequest).Address.ObjectID[0]++ - }, - func(s sigType) { - s.(*GetRangeHashRequest).Salt[0]++ - }, - func(s sigType) { - s.(*GetRangeHashRequest).Ranges[0].Length++ - }, - func(s sigType) { - s.(*GetRangeHashRequest).Ranges[0].Offset++ - }, - func(s sigType) { - s.(*GetRangeHashRequest).Ranges = nil - }, - }, - }, - { // GetRangeHashRequest - constructor: func() sigType { - return &SearchRequest{ - Query: []byte{1, 2, 3}, - } - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - s.(*SearchRequest).ContainerID[0]++ - }, - func(s sigType) { - s.(*SearchRequest).Query[0]++ - }, - func(s sigType) { - s.(*SearchRequest).QueryVersion++ - }, - }, - }, - } - - for _, item := range items { - { // token corruptions - v := item.constructor() - - token := new(Token) - v.SetToken(token) - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - token.SetSessionKey(append(token.GetSessionKey(), 1)) - - require.Error(t, service.VerifyRequestData(v)) - } - - { // payload corruptions - for _, corruption := range item.payloadCorrupt { - v := item.constructor() - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - corruption(v) - - require.Error(t, service.VerifyRequestData(v)) - } - } - } -} - -func TestHeadRequest_ReadSignedData(t *testing.T) { - t.Run("full headers", func(t *testing.T) { - req := new(HeadRequest) - - // unset FullHeaders flag - req.SetFullHeaders(false) - - // allocate two different buffers for reading - buf1 := testData(t, req.SignedDataSize()) - buf2 := testData(t, req.SignedDataSize()) - - // read to both buffers - n1, err := req.ReadSignedData(buf1) - require.NoError(t, err) - - n2, err := req.ReadSignedData(buf2) - require.NoError(t, err) - - require.Equal(t, buf1[:n1], buf2[:n2]) - }) -} - -func testData(t *testing.T, sz int) []byte { - data := make([]byte, sz) - - _, err := rand.Read(data) - require.NoError(t, err) - - return data -} - -func TestIntegrityHeaderSignMethods(t *testing.T) { - // create new IntegrityHeader - s := new(IntegrityHeader) - - // set test headers checksum - s.SetHeadersChecksum([]byte{1, 2, 3}) - - data, err := s.SignedData() - require.NoError(t, err) - require.Equal(t, data, s.GetHeadersChecksum()) - - // add signature - sig := []byte{4, 5, 6} - s.AddSignKey(sig, nil) - - require.Equal(t, sig, s.GetSignature()) -} diff --git a/object/types.go b/object/types.go deleted file mode 100644 index 392e624..0000000 --- a/object/types.go +++ /dev/null @@ -1,422 +0,0 @@ -package object - -import ( - "bytes" - "context" - "fmt" - "io" - "reflect" - - "github.com/gogo/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/internal" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/pkg/errors" -) - -type ( - // Pred defines a predicate function that can check if passed header - // satisfies predicate condition. It is used to find headers of - // specific type. - Pred = func(*Header) bool - - // Address is a type alias of object Address. - Address = refs.Address - - // PositionReader defines object reader that returns slice of bytes - // for specified object and data range. - PositionReader interface { - PRead(ctx context.Context, addr refs.Address, rng Range) ([]byte, error) - } - - // RequestType of the object service requests. - RequestType int - - headerType int -) - -const ( - // ErrVerifyPayload is raised when payload checksum cannot be verified. - ErrVerifyPayload = internal.Error("can't verify payload") - - // ErrVerifyHeader is raised when object integrity cannot be verified. - ErrVerifyHeader = internal.Error("can't verify header") - - // ErrHeaderNotFound is raised when requested header not found. - ErrHeaderNotFound = internal.Error("header not found") - - // ErrVerifySignature is raised when signature cannot be verified. - ErrVerifySignature = internal.Error("can't verify signature") -) - -const ( - _ headerType = iota - // LinkHdr is a link header type. - LinkHdr - // RedirectHdr is a redirect header type. - RedirectHdr - // UserHdr is a user defined header type. - UserHdr - // TransformHdr is a transformation header type. - TransformHdr - // TombstoneHdr is a tombstone header type. - TombstoneHdr - // TokenHdr is a token header type. - TokenHdr - // HomoHashHdr is a homomorphic hash header type. - HomoHashHdr - // PayloadChecksumHdr is a payload checksum header type. - PayloadChecksumHdr - // IntegrityHdr is a integrity header type. - IntegrityHdr - // StorageGroupHdr is a storage group header type. - StorageGroupHdr - // PublicKeyHdr is a public key header type. - PublicKeyHdr -) - -const ( - _ RequestType = iota - // RequestPut is a type for object put request. - RequestPut - // RequestGet is a type for object get request. - RequestGet - // RequestHead is a type for object head request. - RequestHead - // RequestSearch is a type for object search request. - RequestSearch - // RequestRange is a type for object range request. - RequestRange - // RequestRangeHash is a type for object hash range request. - RequestRangeHash - // RequestDelete is a type for object delete request. - RequestDelete -) - -var ( - _ internal.Custom = (*Object)(nil) - - emptyObject = new(Object).Bytes() -) - -// String returns printable name of the request type. -func (s RequestType) String() string { - switch s { - case RequestPut: - return "PUT" - case RequestGet: - return "GET" - case RequestHead: - return "HEAD" - case RequestSearch: - return "SEARCH" - case RequestRange: - return "RANGE" - case RequestRangeHash: - return "RANGE_HASH" - case RequestDelete: - return "DELETE" - default: - return "UNKNOWN" - } -} - -// Bytes returns marshaled object in a binary format. -func (m Object) Bytes() []byte { data, _ := m.Marshal(); return data } - -// Empty checks if object does not contain any information. -func (m Object) Empty() bool { return bytes.Equal(m.Bytes(), emptyObject) } - -// LastHeader returns last header of the specified type. Type must be -// specified as a Pred function. -func (m Object) LastHeader(f Pred) (int, *Header) { - for i := len(m.Headers) - 1; i >= 0; i-- { - if f != nil && f(&m.Headers[i]) { - return i, &m.Headers[i] - } - } - return -1, nil -} - -// AddHeader adds passed header to the end of extended header list. -func (m *Object) AddHeader(h *Header) { - m.Headers = append(m.Headers, *h) -} - -// SetPayload sets payload field and payload length in the system header. -func (m *Object) SetPayload(payload []byte) { - m.Payload = payload - m.SystemHeader.PayloadLength = uint64(len(payload)) -} - -// SetHeader replaces existing extended header or adds new one to the end of -// extended header list. -func (m *Object) SetHeader(h *Header) { - // looking for the header of that type - for i := range m.Headers { - if m.Headers[i].typeOf(h.Value) { - // if we found one - set it with new value and return - m.Headers[i] = *h - return - } - } - // if we did not find one - add this header - m.AddHeader(h) -} - -// Merge used by proto.Clone -func (m *Object) Merge(src proto.Message) { - if tmp, ok := src.(*Object); ok { - tmp.CopyTo(m) - } -} - -func (m Header) typeOf(t isHeader_Value) (ok bool) { - switch t.(type) { - case *Header_Link: - _, ok = m.Value.(*Header_Link) - case *Header_Redirect: - _, ok = m.Value.(*Header_Redirect) - case *Header_UserHeader: - _, ok = m.Value.(*Header_UserHeader) - case *Header_Transform: - _, ok = m.Value.(*Header_Transform) - case *Header_Tombstone: - _, ok = m.Value.(*Header_Tombstone) - case *Header_Token: - _, ok = m.Value.(*Header_Token) - case *Header_HomoHash: - _, ok = m.Value.(*Header_HomoHash) - case *Header_PayloadChecksum: - _, ok = m.Value.(*Header_PayloadChecksum) - case *Header_Integrity: - _, ok = m.Value.(*Header_Integrity) - case *Header_StorageGroup: - _, ok = m.Value.(*Header_StorageGroup) - case *Header_PublicKey: - _, ok = m.Value.(*Header_PublicKey) - } - return -} - -// HeaderType returns predicate that check if extended header is a header -// of specified type. -func HeaderType(t headerType) Pred { - switch t { - case LinkHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Link); return ok } - case RedirectHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Redirect); return ok } - case UserHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_UserHeader); return ok } - case TransformHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Transform); return ok } - case TombstoneHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Tombstone); return ok } - case TokenHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Token); return ok } - case HomoHashHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_HomoHash); return ok } - case PayloadChecksumHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_PayloadChecksum); return ok } - case IntegrityHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_Integrity); return ok } - case StorageGroupHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_StorageGroup); return ok } - case PublicKeyHdr: - return func(h *Header) bool { _, ok := h.Value.(*Header_PublicKey); return ok } - default: - return nil - } -} - -// Copy creates full copy of the object. -func (m *Object) Copy() (obj *Object) { - obj = new(Object) - m.CopyTo(obj) - return -} - -// CopyTo creates fills passed object with the data from the current object. -// This function creates copies on every available data slice. -func (m *Object) CopyTo(o *Object) { - o.SystemHeader = m.SystemHeader - - if m.Headers != nil { - o.Headers = make([]Header, len(m.Headers)) - } - - if m.Payload != nil { - o.Payload = make([]byte, len(m.Payload)) - copy(o.Payload, m.Payload) - } - - for i := range m.Headers { - switch v := m.Headers[i].Value.(type) { - case *Header_Link: - link := *v.Link - o.Headers[i] = Header{ - Value: &Header_Link{ - Link: &link, - }, - } - case *Header_HomoHash: - hash := proto.Clone(&v.HomoHash).(*Hash) - o.Headers[i] = Header{ - Value: &Header_HomoHash{ - HomoHash: *hash, - }, - } - case *Header_Token: - token := *v.Token - o.Headers[i] = Header{ - Value: &Header_Token{ - Token: &token, - }, - } - default: - o.Headers[i] = *proto.Clone(&m.Headers[i]).(*Header) - } - } -} - -// Address returns object's address. -func (m Object) Address() *refs.Address { - return &refs.Address{ - ObjectID: m.SystemHeader.ID, - CID: m.SystemHeader.CID, - } -} - -func (m CreationPoint) String() string { - return fmt.Sprintf(`{UnixTime=%d Epoch=%d}`, m.UnixTime, m.Epoch) -} - -// Stringify converts object into string format. -func Stringify(dst io.Writer, obj *Object) error { - // put empty line - if _, err := fmt.Fprintln(dst); err != nil { - return err - } - - // put object line - if _, err := fmt.Fprintln(dst, "Object:"); err != nil { - return err - } - - // put system headers - if _, err := fmt.Fprintln(dst, "\tSystemHeader:"); err != nil { - return err - } - - sysHeaders := []string{"ID", "CID", "OwnerID", "Version", "PayloadLength", "CreatedAt"} - v := reflect.ValueOf(obj.SystemHeader) - for _, key := range sysHeaders { - if !v.FieldByName(key).IsValid() { - return errors.Errorf("invalid system header key: %q", key) - } - - val := v.FieldByName(key).Interface() - if _, err := fmt.Fprintf(dst, "\t\t- %s=%v\n", key, val); err != nil { - return err - } - } - - // put user headers - if _, err := fmt.Fprintln(dst, "\tUserHeaders:"); err != nil { - return err - } - - for _, header := range obj.Headers { - var ( - typ = reflect.ValueOf(header.Value) - key string - val interface{} - ) - - switch t := typ.Interface().(type) { - case *Header_Link: - key = "Link" - val = fmt.Sprintf(`{Type=%s ID=%s}`, t.Link.Type, t.Link.ID) - case *Header_Redirect: - key = "Redirect" - val = fmt.Sprintf(`{CID=%s OID=%s}`, t.Redirect.CID, t.Redirect.ObjectID) - case *Header_UserHeader: - key = "UserHeader" - val = fmt.Sprintf(`{Key=%s Val=%s}`, t.UserHeader.Key, t.UserHeader.Value) - case *Header_Transform: - key = "Transform" - val = t.Transform.Type.String() - case *Header_Tombstone: - key = "Tombstone" - val = "MARKED" - case *Header_Token: - key = "Token" - val = fmt.Sprintf("{"+ - "ID=%s OwnerID=%s Verb=%s Address=%s Created=%d ValidUntil=%d SessionKey=%02x Signature=%02x"+ - "}", - t.Token.GetID(), - t.Token.GetOwnerID(), - t.Token.GetVerb(), - t.Token.GetAddress(), - t.Token.CreationEpoch(), - t.Token.ExpirationEpoch(), - t.Token.GetSessionKey(), - t.Token.GetSignature()) - case *Header_HomoHash: - key = "HomoHash" - val = t.HomoHash - case *Header_PayloadChecksum: - key = "PayloadChecksum" - val = t.PayloadChecksum - case *Header_Integrity: - key = "Integrity" - val = fmt.Sprintf(`{Checksum=%02x Signature=%02x}`, - t.Integrity.HeadersChecksum, - t.Integrity.ChecksumSignature) - case *Header_StorageGroup: - key = "StorageGroup" - val = fmt.Sprintf(`{DataSize=%d Hash=%02x Lifetime={Unit=%s Value=%d}}`, - t.StorageGroup.ValidationDataSize, - t.StorageGroup.ValidationHash, - t.StorageGroup.Lifetime.Unit, - t.StorageGroup.Lifetime.Value) - case *Header_PublicKey: - key = "PublicKey" - val = t.PublicKey.Value - default: - key = "Unknown" - val = t - } - - if _, err := fmt.Fprintf(dst, "\t\t- Type=%s\n\t\t Value=%v\n", key, val); err != nil { - return err - } - } - - // put payload - if _, err := fmt.Fprintf(dst, "\tPayload: %#v\n", obj.Payload); err != nil { - return err - } - - return nil -} - -// SetFullHeaders is a FullHeaders field setter. -func (m *HeadRequest) SetFullHeaders(v bool) { - m.FullHeaders = v -} - -// GetSignature is a ChecksumSignature field getter. -func (m IntegrityHeader) GetSignature() []byte { - return m.ChecksumSignature -} - -// SetSignature is a ChecksumSignature field setter. -func (m *IntegrityHeader) SetSignature(v []byte) { - m.ChecksumSignature = v -} - -// SetHeadersChecksum is a HeadersChecksum field setter. -func (m *IntegrityHeader) SetHeadersChecksum(v []byte) { - m.HeadersChecksum = v -} diff --git a/object/types.pb.go b/object/types.pb.go deleted file mode 100644 index 97106c7..0000000 --- a/object/types.pb.go +++ /dev/null @@ -1,3568 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: object/types.proto - -package object - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - refs "github.com/nspcc-dev/neofs-api-go/refs" - service "github.com/nspcc-dev/neofs-api-go/service" - storagegroup "github.com/nspcc-dev/neofs-api-go/storagegroup" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type Link_Type int32 - -const ( - Link_Unknown Link_Type = 0 - // Parent object created during object transformation - Link_Parent Link_Type = 1 - // Previous object in the linked list created during object transformation - Link_Previous Link_Type = 2 - // Next object in the linked list created during object transformation - Link_Next Link_Type = 3 - // Child object created during object transformation - Link_Child Link_Type = 4 - // Object that included into this storage group - Link_StorageGroup Link_Type = 5 -) - -var Link_Type_name = map[int32]string{ - 0: "Unknown", - 1: "Parent", - 2: "Previous", - 3: "Next", - 4: "Child", - 5: "StorageGroup", -} - -var Link_Type_value = map[string]int32{ - "Unknown": 0, - "Parent": 1, - "Previous": 2, - "Next": 3, - "Child": 4, - "StorageGroup": 5, -} - -func (x Link_Type) String() string { - return proto.EnumName(Link_Type_name, int32(x)) -} - -func (Link_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{7, 0} -} - -type Transform_Type int32 - -const ( - Transform_Unknown Transform_Type = 0 - // Split sets when object created after payload split - Transform_Split Transform_Type = 1 - // Sign sets when object created after re-signing (doesn't used) - Transform_Sign Transform_Type = 2 - // Mould sets when object created after filling missing headers in the object - Transform_Mould Transform_Type = 3 -) - -var Transform_Type_name = map[int32]string{ - 0: "Unknown", - 1: "Split", - 2: "Sign", - 3: "Mould", -} - -var Transform_Type_value = map[string]int32{ - "Unknown": 0, - "Split": 1, - "Sign": 2, - "Mould": 3, -} - -func (x Transform_Type) String() string { - return proto.EnumName(Transform_Type_name, int32(x)) -} - -func (Transform_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{8, 0} -} - -type Range struct { - // Offset of the data range - Offset uint64 `protobuf:"varint,1,opt,name=Offset,proto3" json:"Offset,omitempty"` - // Length of the data range - Length uint64 `protobuf:"varint,2,opt,name=Length,proto3" json:"Length,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Range) Reset() { *m = Range{} } -func (m *Range) String() string { return proto.CompactTextString(m) } -func (*Range) ProtoMessage() {} -func (*Range) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{0} -} -func (m *Range) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Range) XXX_Merge(src proto.Message) { - xxx_messageInfo_Range.Merge(m, src) -} -func (m *Range) XXX_Size() int { - return m.Size() -} -func (m *Range) XXX_DiscardUnknown() { - xxx_messageInfo_Range.DiscardUnknown(m) -} - -var xxx_messageInfo_Range proto.InternalMessageInfo - -func (m *Range) GetOffset() uint64 { - if m != nil { - return m.Offset - } - return 0 -} - -func (m *Range) GetLength() uint64 { - if m != nil { - return m.Length - } - return 0 -} - -type UserHeader struct { - // Key of the user's header - Key string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"` - // Value of the user's header - Value string `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UserHeader) Reset() { *m = UserHeader{} } -func (m *UserHeader) String() string { return proto.CompactTextString(m) } -func (*UserHeader) ProtoMessage() {} -func (*UserHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{1} -} -func (m *UserHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UserHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *UserHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserHeader.Merge(m, src) -} -func (m *UserHeader) XXX_Size() int { - return m.Size() -} -func (m *UserHeader) XXX_DiscardUnknown() { - xxx_messageInfo_UserHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_UserHeader proto.InternalMessageInfo - -func (m *UserHeader) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *UserHeader) GetValue() string { - if m != nil { - return m.Value - } - return "" -} - -type Header struct { - // Types that are valid to be assigned to Value: - // *Header_Link - // *Header_Redirect - // *Header_UserHeader - // *Header_Transform - // *Header_Tombstone - // *Header_Token - // *Header_HomoHash - // *Header_PayloadChecksum - // *Header_Integrity - // *Header_StorageGroup - // *Header_PublicKey - Value isHeader_Value `protobuf_oneof:"Value"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Header) Reset() { *m = Header{} } -func (m *Header) String() string { return proto.CompactTextString(m) } -func (*Header) ProtoMessage() {} -func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{2} -} -func (m *Header) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header.Merge(m, src) -} -func (m *Header) XXX_Size() int { - return m.Size() -} -func (m *Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header.DiscardUnknown(m) -} - -var xxx_messageInfo_Header proto.InternalMessageInfo - -type isHeader_Value interface { - isHeader_Value() - MarshalTo([]byte) (int, error) - Size() int -} - -type Header_Link struct { - Link *Link `protobuf:"bytes,1,opt,name=Link,proto3,oneof" json:"Link,omitempty"` -} -type Header_Redirect struct { - Redirect *refs.Address `protobuf:"bytes,2,opt,name=Redirect,proto3,oneof" json:"Redirect,omitempty"` -} -type Header_UserHeader struct { - UserHeader *UserHeader `protobuf:"bytes,3,opt,name=UserHeader,proto3,oneof" json:"UserHeader,omitempty"` -} -type Header_Transform struct { - Transform *Transform `protobuf:"bytes,4,opt,name=Transform,proto3,oneof" json:"Transform,omitempty"` -} -type Header_Tombstone struct { - Tombstone *Tombstone `protobuf:"bytes,5,opt,name=Tombstone,proto3,oneof" json:"Tombstone,omitempty"` -} -type Header_Token struct { - Token *service.Token `protobuf:"bytes,6,opt,name=Token,proto3,oneof" json:"Token,omitempty"` -} -type Header_HomoHash struct { - HomoHash Hash `protobuf:"bytes,7,opt,name=HomoHash,proto3,oneof,customtype=Hash" json:"HomoHash,omitempty"` -} -type Header_PayloadChecksum struct { - PayloadChecksum []byte `protobuf:"bytes,8,opt,name=PayloadChecksum,proto3,oneof" json:"PayloadChecksum,omitempty"` -} -type Header_Integrity struct { - Integrity *IntegrityHeader `protobuf:"bytes,9,opt,name=Integrity,proto3,oneof" json:"Integrity,omitempty"` -} -type Header_StorageGroup struct { - StorageGroup *storagegroup.StorageGroup `protobuf:"bytes,10,opt,name=StorageGroup,proto3,oneof" json:"StorageGroup,omitempty"` -} -type Header_PublicKey struct { - PublicKey *PublicKey `protobuf:"bytes,11,opt,name=PublicKey,proto3,oneof" json:"PublicKey,omitempty"` -} - -func (*Header_Link) isHeader_Value() {} -func (*Header_Redirect) isHeader_Value() {} -func (*Header_UserHeader) isHeader_Value() {} -func (*Header_Transform) isHeader_Value() {} -func (*Header_Tombstone) isHeader_Value() {} -func (*Header_Token) isHeader_Value() {} -func (*Header_HomoHash) isHeader_Value() {} -func (*Header_PayloadChecksum) isHeader_Value() {} -func (*Header_Integrity) isHeader_Value() {} -func (*Header_StorageGroup) isHeader_Value() {} -func (*Header_PublicKey) isHeader_Value() {} - -func (m *Header) GetValue() isHeader_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *Header) GetLink() *Link { - if x, ok := m.GetValue().(*Header_Link); ok { - return x.Link - } - return nil -} - -func (m *Header) GetRedirect() *refs.Address { - if x, ok := m.GetValue().(*Header_Redirect); ok { - return x.Redirect - } - return nil -} - -func (m *Header) GetUserHeader() *UserHeader { - if x, ok := m.GetValue().(*Header_UserHeader); ok { - return x.UserHeader - } - return nil -} - -func (m *Header) GetTransform() *Transform { - if x, ok := m.GetValue().(*Header_Transform); ok { - return x.Transform - } - return nil -} - -func (m *Header) GetTombstone() *Tombstone { - if x, ok := m.GetValue().(*Header_Tombstone); ok { - return x.Tombstone - } - return nil -} - -func (m *Header) GetToken() *service.Token { - if x, ok := m.GetValue().(*Header_Token); ok { - return x.Token - } - return nil -} - -func (m *Header) GetPayloadChecksum() []byte { - if x, ok := m.GetValue().(*Header_PayloadChecksum); ok { - return x.PayloadChecksum - } - return nil -} - -func (m *Header) GetIntegrity() *IntegrityHeader { - if x, ok := m.GetValue().(*Header_Integrity); ok { - return x.Integrity - } - return nil -} - -func (m *Header) GetStorageGroup() *storagegroup.StorageGroup { - if x, ok := m.GetValue().(*Header_StorageGroup); ok { - return x.StorageGroup - } - return nil -} - -func (m *Header) GetPublicKey() *PublicKey { - if x, ok := m.GetValue().(*Header_PublicKey); ok { - return x.PublicKey - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Header) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Header_Link)(nil), - (*Header_Redirect)(nil), - (*Header_UserHeader)(nil), - (*Header_Transform)(nil), - (*Header_Tombstone)(nil), - (*Header_Token)(nil), - (*Header_HomoHash)(nil), - (*Header_PayloadChecksum)(nil), - (*Header_Integrity)(nil), - (*Header_StorageGroup)(nil), - (*Header_PublicKey)(nil), - } -} - -type Tombstone struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Tombstone) Reset() { *m = Tombstone{} } -func (m *Tombstone) String() string { return proto.CompactTextString(m) } -func (*Tombstone) ProtoMessage() {} -func (*Tombstone) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{3} -} -func (m *Tombstone) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Tombstone) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Tombstone) XXX_Merge(src proto.Message) { - xxx_messageInfo_Tombstone.Merge(m, src) -} -func (m *Tombstone) XXX_Size() int { - return m.Size() -} -func (m *Tombstone) XXX_DiscardUnknown() { - xxx_messageInfo_Tombstone.DiscardUnknown(m) -} - -var xxx_messageInfo_Tombstone proto.InternalMessageInfo - -type SystemHeader struct { - // Version of the object structure - Version uint64 `protobuf:"varint,1,opt,name=Version,proto3" json:"Version,omitempty"` - // PayloadLength is an object payload length - PayloadLength uint64 `protobuf:"varint,2,opt,name=PayloadLength,proto3" json:"PayloadLength,omitempty"` - // ID is an object identifier, is a valid UUIDv4 - ID ID `protobuf:"bytes,3,opt,name=ID,proto3,customtype=ID" json:"ID"` - // OwnerID is a wallet address - OwnerID OwnerID `protobuf:"bytes,4,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // CID is a SHA256 hash of the container structure (container identifier) - CID CID `protobuf:"bytes,5,opt,name=CID,proto3,customtype=CID" json:"CID"` - // CreatedAt is a timestamp of object creation - CreatedAt CreationPoint `protobuf:"bytes,6,opt,name=CreatedAt,proto3" json:"CreatedAt"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SystemHeader) Reset() { *m = SystemHeader{} } -func (m *SystemHeader) String() string { return proto.CompactTextString(m) } -func (*SystemHeader) ProtoMessage() {} -func (*SystemHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{4} -} -func (m *SystemHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SystemHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *SystemHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemHeader.Merge(m, src) -} -func (m *SystemHeader) XXX_Size() int { - return m.Size() -} -func (m *SystemHeader) XXX_DiscardUnknown() { - xxx_messageInfo_SystemHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_SystemHeader proto.InternalMessageInfo - -func (m *SystemHeader) GetVersion() uint64 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *SystemHeader) GetPayloadLength() uint64 { - if m != nil { - return m.PayloadLength - } - return 0 -} - -func (m *SystemHeader) GetCreatedAt() CreationPoint { - if m != nil { - return m.CreatedAt - } - return CreationPoint{} -} - -type CreationPoint struct { - // UnixTime is a date of creation in unixtime format - UnixTime int64 `protobuf:"varint,1,opt,name=UnixTime,proto3" json:"UnixTime,omitempty"` - // Epoch is a date of creation in NeoFS epochs - Epoch uint64 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreationPoint) Reset() { *m = CreationPoint{} } -func (*CreationPoint) ProtoMessage() {} -func (*CreationPoint) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{5} -} -func (m *CreationPoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CreationPoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *CreationPoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreationPoint.Merge(m, src) -} -func (m *CreationPoint) XXX_Size() int { - return m.Size() -} -func (m *CreationPoint) XXX_DiscardUnknown() { - xxx_messageInfo_CreationPoint.DiscardUnknown(m) -} - -var xxx_messageInfo_CreationPoint proto.InternalMessageInfo - -func (m *CreationPoint) GetUnixTime() int64 { - if m != nil { - return m.UnixTime - } - return 0 -} - -func (m *CreationPoint) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -type IntegrityHeader struct { - // HeadersChecksum is a checksum of all above headers in the object - HeadersChecksum []byte `protobuf:"bytes,1,opt,name=HeadersChecksum,proto3" json:"HeadersChecksum,omitempty"` - // ChecksumSignature is an user's signature of checksum to verify if it is correct - ChecksumSignature []byte `protobuf:"bytes,2,opt,name=ChecksumSignature,proto3" json:"ChecksumSignature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *IntegrityHeader) Reset() { *m = IntegrityHeader{} } -func (m *IntegrityHeader) String() string { return proto.CompactTextString(m) } -func (*IntegrityHeader) ProtoMessage() {} -func (*IntegrityHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{6} -} -func (m *IntegrityHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *IntegrityHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *IntegrityHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_IntegrityHeader.Merge(m, src) -} -func (m *IntegrityHeader) XXX_Size() int { - return m.Size() -} -func (m *IntegrityHeader) XXX_DiscardUnknown() { - xxx_messageInfo_IntegrityHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_IntegrityHeader proto.InternalMessageInfo - -func (m *IntegrityHeader) GetHeadersChecksum() []byte { - if m != nil { - return m.HeadersChecksum - } - return nil -} - -func (m *IntegrityHeader) GetChecksumSignature() []byte { - if m != nil { - return m.ChecksumSignature - } - return nil -} - -type Link struct { - // Type of link - Type Link_Type `protobuf:"varint,1,opt,name=type,proto3,enum=object.Link_Type" json:"type,omitempty"` - // ID is an object identifier, is a valid UUIDv4 - ID ID `protobuf:"bytes,2,opt,name=ID,proto3,customtype=ID" json:"ID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Link) Reset() { *m = Link{} } -func (m *Link) String() string { return proto.CompactTextString(m) } -func (*Link) ProtoMessage() {} -func (*Link) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{7} -} -func (m *Link) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Link) XXX_Merge(src proto.Message) { - xxx_messageInfo_Link.Merge(m, src) -} -func (m *Link) XXX_Size() int { - return m.Size() -} -func (m *Link) XXX_DiscardUnknown() { - xxx_messageInfo_Link.DiscardUnknown(m) -} - -var xxx_messageInfo_Link proto.InternalMessageInfo - -func (m *Link) GetType() Link_Type { - if m != nil { - return m.Type - } - return Link_Unknown -} - -type Transform struct { - // Type of object transformation - Type Transform_Type `protobuf:"varint,1,opt,name=type,proto3,enum=object.Transform_Type" json:"type,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Transform) Reset() { *m = Transform{} } -func (m *Transform) String() string { return proto.CompactTextString(m) } -func (*Transform) ProtoMessage() {} -func (*Transform) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{8} -} -func (m *Transform) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Transform) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Transform) XXX_Merge(src proto.Message) { - xxx_messageInfo_Transform.Merge(m, src) -} -func (m *Transform) XXX_Size() int { - return m.Size() -} -func (m *Transform) XXX_DiscardUnknown() { - xxx_messageInfo_Transform.DiscardUnknown(m) -} - -var xxx_messageInfo_Transform proto.InternalMessageInfo - -func (m *Transform) GetType() Transform_Type { - if m != nil { - return m.Type - } - return Transform_Unknown -} - -type Object struct { - // SystemHeader describes system header - SystemHeader SystemHeader `protobuf:"bytes,1,opt,name=SystemHeader,proto3" json:"SystemHeader"` - // Headers describes a set of an extended headers - Headers []Header `protobuf:"bytes,2,rep,name=Headers,proto3" json:"Headers"` - // Payload is an object's payload - Payload []byte `protobuf:"bytes,3,opt,name=Payload,proto3" json:"Payload,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Object) Reset() { *m = Object{} } -func (m *Object) String() string { return proto.CompactTextString(m) } -func (*Object) ProtoMessage() {} -func (*Object) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{9} -} -func (m *Object) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Object) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Object) XXX_Merge(src proto.Message) { - xxx_messageInfo_Object.Merge(m, src) -} -func (m *Object) XXX_Size() int { - return m.Size() -} -func (m *Object) XXX_DiscardUnknown() { - xxx_messageInfo_Object.DiscardUnknown(m) -} - -var xxx_messageInfo_Object proto.InternalMessageInfo - -func (m *Object) GetSystemHeader() SystemHeader { - if m != nil { - return m.SystemHeader - } - return SystemHeader{} -} - -func (m *Object) GetHeaders() []Header { - if m != nil { - return m.Headers - } - return nil -} - -func (m *Object) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -type PublicKey struct { - // Value contains marshaled ecdsa public key - Value []byte `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PublicKey) Reset() { *m = PublicKey{} } -func (m *PublicKey) String() string { return proto.CompactTextString(m) } -func (*PublicKey) ProtoMessage() {} -func (*PublicKey) Descriptor() ([]byte, []int) { - return fileDescriptor_02021a1d39b1aee0, []int{10} -} -func (m *PublicKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *PublicKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PublicKey.Merge(m, src) -} -func (m *PublicKey) XXX_Size() int { - return m.Size() -} -func (m *PublicKey) XXX_DiscardUnknown() { - xxx_messageInfo_PublicKey.DiscardUnknown(m) -} - -var xxx_messageInfo_PublicKey proto.InternalMessageInfo - -func (m *PublicKey) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func init() { - proto.RegisterEnum("object.Link_Type", Link_Type_name, Link_Type_value) - proto.RegisterEnum("object.Transform_Type", Transform_Type_name, Transform_Type_value) - proto.RegisterType((*Range)(nil), "object.Range") - proto.RegisterType((*UserHeader)(nil), "object.UserHeader") - proto.RegisterType((*Header)(nil), "object.Header") - proto.RegisterType((*Tombstone)(nil), "object.Tombstone") - proto.RegisterType((*SystemHeader)(nil), "object.SystemHeader") - proto.RegisterType((*CreationPoint)(nil), "object.CreationPoint") - proto.RegisterType((*IntegrityHeader)(nil), "object.IntegrityHeader") - proto.RegisterType((*Link)(nil), "object.Link") - proto.RegisterType((*Transform)(nil), "object.Transform") - proto.RegisterType((*Object)(nil), "object.Object") - proto.RegisterType((*PublicKey)(nil), "object.PublicKey") -} - -func init() { proto.RegisterFile("object/types.proto", fileDescriptor_02021a1d39b1aee0) } - -var fileDescriptor_02021a1d39b1aee0 = []byte{ - // 916 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x55, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xb7, 0x13, 0xe7, 0xdf, 0x8b, 0xb7, 0xeb, 0x8e, 0x96, 0x62, 0x45, 0x22, 0xbb, 0x58, 0x50, - 0x2d, 0x85, 0x75, 0x44, 0x8b, 0x54, 0xc1, 0x01, 0xb1, 0xd9, 0x40, 0x1d, 0x51, 0xba, 0x61, 0x92, - 0xed, 0x81, 0x9b, 0x93, 0x4c, 0x1c, 0xb3, 0xc9, 0x4c, 0x34, 0x33, 0xd9, 0x36, 0x5f, 0x83, 0x53, - 0x6f, 0x70, 0x44, 0x7c, 0x92, 0x1e, 0x39, 0xa2, 0x1e, 0x56, 0x68, 0xf9, 0x00, 0x7c, 0x85, 0x6a, - 0xc6, 0x76, 0x62, 0x6f, 0x7b, 0x89, 0xe6, 0xbd, 0xdf, 0xef, 0x37, 0x7e, 0xf3, 0xde, 0x6f, 0x26, - 0x80, 0xd8, 0xf8, 0x57, 0x32, 0x91, 0x1d, 0xb9, 0x59, 0x11, 0xe1, 0xaf, 0x38, 0x93, 0x0c, 0x55, - 0x93, 0x5c, 0xcb, 0xe1, 0x64, 0x26, 0xf2, 0x48, 0xeb, 0x40, 0x10, 0x7e, 0x15, 0x4f, 0x48, 0xe7, - 0x8a, 0xf0, 0x78, 0xb6, 0x49, 0xb3, 0xae, 0x90, 0x8c, 0x87, 0x11, 0x89, 0x38, 0x5b, 0xaf, 0x0a, - 0xfc, 0x93, 0x28, 0x96, 0xf3, 0xf5, 0xd8, 0x9f, 0xb0, 0x65, 0x27, 0x62, 0x11, 0xeb, 0xe8, 0xf4, - 0x78, 0x3d, 0xd3, 0x91, 0x0e, 0xf4, 0x2a, 0xa1, 0x7b, 0x8f, 0xa1, 0x82, 0x43, 0x1a, 0x11, 0x74, - 0x0f, 0xaa, 0xe7, 0xb3, 0x99, 0x20, 0xd2, 0x35, 0x8f, 0xcc, 0x63, 0x0b, 0xa7, 0x91, 0xca, 0x3f, - 0x25, 0x34, 0x92, 0x73, 0xb7, 0x94, 0xe4, 0x93, 0xc8, 0xfb, 0x0a, 0xe0, 0x42, 0x10, 0x1e, 0x90, - 0x70, 0x4a, 0x38, 0x72, 0xa0, 0xfc, 0x23, 0xd9, 0x68, 0x69, 0x03, 0xab, 0x25, 0x3a, 0x80, 0xca, - 0xf3, 0x70, 0xb1, 0x26, 0x5a, 0xd6, 0xc0, 0x49, 0xe0, 0xfd, 0x69, 0x41, 0x35, 0x95, 0x78, 0x60, - 0x3d, 0x8d, 0xe9, 0xa5, 0xd6, 0x34, 0x1f, 0xda, 0x7e, 0xd2, 0x01, 0x5f, 0xe5, 0x02, 0x03, 0x6b, - 0x0c, 0x7d, 0x0e, 0x75, 0x4c, 0xa6, 0x31, 0x27, 0x13, 0xa9, 0xf7, 0x69, 0x3e, 0xdc, 0xf3, 0x55, - 0x87, 0xfc, 0xd3, 0xe9, 0x94, 0x13, 0x21, 0x02, 0x03, 0x6f, 0x09, 0xa8, 0x50, 0x91, 0x5b, 0xd6, - 0x74, 0x94, 0x6d, 0xbb, 0x43, 0x02, 0x03, 0xe7, 0x2b, 0xff, 0x12, 0x1a, 0x23, 0x1e, 0x52, 0x31, - 0x63, 0x7c, 0xe9, 0x5a, 0x5a, 0x74, 0x37, 0x13, 0x6d, 0x81, 0xc0, 0xc0, 0x3b, 0x96, 0x96, 0xb0, - 0xe5, 0x58, 0x48, 0x46, 0x89, 0x5b, 0xb9, 0x25, 0xc9, 0x00, 0x2d, 0xc9, 0x02, 0x74, 0x1f, 0x2a, - 0x23, 0x76, 0x49, 0xa8, 0x5b, 0xd5, 0xf4, 0x3b, 0x7e, 0x3a, 0x55, 0x5f, 0x67, 0x03, 0x03, 0x27, - 0x30, 0xba, 0x0f, 0xf5, 0x80, 0x2d, 0x59, 0x10, 0x8a, 0xb9, 0x5b, 0x3b, 0x32, 0x8f, 0xed, 0x6e, - 0xfd, 0xcd, 0xf5, 0xa1, 0xa5, 0x62, 0x75, 0xd6, 0x0c, 0x43, 0x0f, 0x60, 0x7f, 0x10, 0x6e, 0x16, - 0x2c, 0x9c, 0x9e, 0xcd, 0xc9, 0xe4, 0x52, 0xac, 0x97, 0x6e, 0x5d, 0xd1, 0x03, 0x03, 0xdf, 0x06, - 0xd0, 0x63, 0x68, 0xf4, 0xa9, 0x24, 0x11, 0x8f, 0xe5, 0xc6, 0x6d, 0xe8, 0xef, 0x7f, 0x98, 0x95, - 0xbb, 0x05, 0xb6, 0xbd, 0xd9, 0x71, 0xd1, 0x77, 0x60, 0x0f, 0x13, 0x9b, 0x3d, 0x51, 0x36, 0x73, - 0x41, 0x6b, 0x5b, 0x7e, 0xde, 0x7b, 0x7e, 0x9e, 0x11, 0x18, 0xb8, 0xa0, 0x50, 0x9d, 0x1a, 0xac, - 0xc7, 0x8b, 0x78, 0xa2, 0xcc, 0xd1, 0x2c, 0x76, 0x6a, 0x0b, 0xa8, 0x8f, 0x6e, 0x83, 0x6e, 0x2d, - 0xf5, 0x8d, 0xd7, 0xcc, 0x75, 0xd9, 0xfb, 0xdf, 0x04, 0x7b, 0xb8, 0x11, 0x92, 0x2c, 0xd3, 0xb1, - 0xb9, 0x50, 0x7b, 0x4e, 0xb8, 0x88, 0x19, 0x4d, 0xfd, 0x9a, 0x85, 0xe8, 0x13, 0xd8, 0x4b, 0x3b, - 0x50, 0xf0, 0x6d, 0x31, 0x89, 0x5a, 0x50, 0xea, 0xf7, 0xb4, 0x49, 0xec, 0x2e, 0xbc, 0xbe, 0x3e, - 0x34, 0xde, 0x5c, 0x1f, 0x96, 0xfa, 0x3d, 0x5c, 0xea, 0xf7, 0xd0, 0x67, 0x50, 0x3b, 0x7f, 0x41, - 0x09, 0xef, 0xf7, 0xb4, 0x21, 0xec, 0xee, 0x7e, 0x4a, 0xc8, 0xd2, 0x38, 0x5b, 0xa0, 0x8f, 0xa0, - 0x7c, 0xd6, 0xef, 0x69, 0x13, 0xd8, 0xdd, 0x66, 0x4a, 0x53, 0x29, 0xac, 0x7e, 0xd0, 0xd7, 0xd0, - 0x38, 0xe3, 0x24, 0x94, 0x64, 0x7a, 0x2a, 0xd3, 0xd1, 0x7f, 0x90, 0x9d, 0x5f, 0x03, 0x31, 0xa3, - 0x03, 0x16, 0x53, 0xd9, 0xb5, 0x94, 0x16, 0xef, 0xd8, 0xde, 0x13, 0xd8, 0x2b, 0x30, 0x50, 0x0b, - 0xea, 0x17, 0x34, 0x7e, 0x39, 0x8a, 0x97, 0x44, 0x1f, 0xb9, 0x8c, 0xb7, 0xb1, 0xba, 0x6c, 0xdf, - 0xaf, 0xd8, 0x24, 0x3b, 0x6b, 0x12, 0x7c, 0x63, 0xbd, 0xfa, 0xe3, 0xd0, 0xf0, 0x62, 0xd8, 0xbf, - 0x35, 0x65, 0x74, 0x0c, 0xfb, 0xc9, 0x4a, 0x6c, 0xdd, 0xa3, 0x76, 0xb4, 0xf1, 0xed, 0x34, 0xfa, - 0x02, 0xee, 0x66, 0xeb, 0x61, 0x1c, 0xd1, 0x50, 0xae, 0x79, 0x72, 0xa3, 0x6d, 0xfc, 0x2e, 0xe0, - 0xfd, 0x6e, 0x26, 0x77, 0x1a, 0x7d, 0x0a, 0x96, 0x7a, 0x93, 0xf4, 0xae, 0x77, 0x76, 0x23, 0x57, - 0x98, 0x3f, 0xda, 0xac, 0x08, 0xd6, 0x70, 0x3a, 0x84, 0xd2, 0xfb, 0x86, 0xe0, 0x8d, 0xc0, 0x52, - 0x4c, 0xd4, 0x84, 0xda, 0x05, 0xbd, 0xa4, 0xec, 0x05, 0x75, 0x0c, 0x04, 0x50, 0x1d, 0x84, 0x9c, - 0x50, 0xe9, 0x98, 0xc8, 0x86, 0xfa, 0x80, 0x93, 0xab, 0x98, 0xad, 0x85, 0x53, 0x42, 0x75, 0xb0, - 0x9e, 0x91, 0x97, 0xd2, 0x29, 0xa3, 0x06, 0x54, 0xce, 0xe6, 0xf1, 0x62, 0xea, 0x58, 0xc8, 0x29, - 0x1a, 0xd8, 0xa9, 0x78, 0x8b, 0xdc, 0x6d, 0x47, 0x0f, 0x0a, 0x55, 0xde, 0x7b, 0xe7, 0xd6, 0xe7, - 0x4a, 0xf5, 0x1e, 0xbd, 0xaf, 0x9c, 0x06, 0x54, 0x86, 0xab, 0x45, 0xac, 0xaa, 0xa9, 0x83, 0xa5, - 0xfa, 0xe0, 0x94, 0x54, 0xf2, 0x27, 0xb6, 0x5e, 0x4c, 0x9d, 0xb2, 0xf7, 0x9b, 0x09, 0xd5, 0x73, - 0xbd, 0x29, 0xfa, 0xb6, 0xe8, 0xdf, 0xf4, 0xd5, 0x3b, 0xc8, 0xbe, 0x99, 0xc7, 0x52, 0x2f, 0x14, - 0xfd, 0xee, 0x43, 0x2d, 0x9d, 0x8d, 0x5b, 0x3a, 0x2a, 0xeb, 0x27, 0x24, 0x95, 0x16, 0x44, 0x19, - 0x49, 0xdd, 0x8f, 0xd4, 0xf0, 0x89, 0xc9, 0x71, 0x16, 0x7a, 0x1f, 0xe7, 0xee, 0xe4, 0xee, 0x95, - 0x4e, 0xe6, 0x9f, 0x04, 0xdd, 0x9f, 0x5f, 0xdf, 0xb4, 0xcd, 0xbf, 0x6f, 0xda, 0xe6, 0x3f, 0x37, - 0x6d, 0xf3, 0xdf, 0x9b, 0xb6, 0xf9, 0xea, 0xbf, 0xb6, 0xf1, 0xcb, 0x71, 0xee, 0x9f, 0x85, 0x8a, - 0xd5, 0x64, 0x72, 0x32, 0x25, 0x57, 0x1d, 0x4a, 0xd8, 0x4c, 0x9c, 0x84, 0xab, 0xf8, 0x24, 0x62, - 0x9d, 0xa4, 0xa4, 0xbf, 0x4a, 0xce, 0x33, 0xc2, 0x7e, 0x18, 0xfa, 0xa7, 0x83, 0xbe, 0x9f, 0x9c, - 0x7f, 0x5c, 0xd5, 0x7f, 0x37, 0x8f, 0xde, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xcb, 0xd2, 0xde, - 0xfd, 0x06, 0x00, 0x00, -} - -func (m *Range) 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 *Range) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Range) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Length != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Length)) - i-- - dAtA[i] = 0x10 - } - if m.Offset != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Offset)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *UserHeader) 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 *UserHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UserHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Header_Link) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Link) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Link != nil { - { - size, err := m.Link.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *Header_Redirect) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Redirect) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Redirect != nil { - { - size, err := m.Redirect.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *Header_UserHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_UserHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.UserHeader != nil { - { - size, err := m.UserHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *Header_Transform) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Transform) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Transform != nil { - { - size, err := m.Transform.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *Header_Tombstone) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Tombstone) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Tombstone != nil { - { - size, err := m.Tombstone.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func (m *Header_Token) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Token) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Token != nil { - { - size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} -func (m *Header_HomoHash) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_HomoHash) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - { - size := m.HomoHash.Size() - i -= size - if _, err := m.HomoHash.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - return len(dAtA) - i, nil -} -func (m *Header_PayloadChecksum) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_PayloadChecksum) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PayloadChecksum != nil { - i -= len(m.PayloadChecksum) - copy(dAtA[i:], m.PayloadChecksum) - i = encodeVarintTypes(dAtA, i, uint64(len(m.PayloadChecksum))) - i-- - dAtA[i] = 0x42 - } - return len(dAtA) - i, nil -} -func (m *Header_Integrity) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Integrity) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Integrity != nil { - { - size, err := m.Integrity.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - return len(dAtA) - i, nil -} -func (m *Header_StorageGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_StorageGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.StorageGroup != nil { - { - size, err := m.StorageGroup.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - return len(dAtA) - i, nil -} -func (m *Header_PublicKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PublicKey != nil { - { - size, err := m.PublicKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - return len(dAtA) - i, nil -} -func (m *Tombstone) 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 *Tombstone) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Tombstone) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func (m *SystemHeader) 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 *SystemHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SystemHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.CreatedAt.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.PayloadLength != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.PayloadLength)) - i-- - dAtA[i] = 0x10 - } - if m.Version != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *CreationPoint) 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 *CreationPoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CreationPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Epoch != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x10 - } - if m.UnixTime != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.UnixTime)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *IntegrityHeader) 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 *IntegrityHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *IntegrityHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ChecksumSignature) > 0 { - i -= len(m.ChecksumSignature) - copy(dAtA[i:], m.ChecksumSignature) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ChecksumSignature))) - i-- - dAtA[i] = 0x12 - } - if len(m.HeadersChecksum) > 0 { - i -= len(m.HeadersChecksum) - copy(dAtA[i:], m.HeadersChecksum) - i = encodeVarintTypes(dAtA, i, uint64(len(m.HeadersChecksum))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Link) 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 *Link) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Link) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Type != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Transform) 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 *Transform) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Transform) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Type != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Object) 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 *Object) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Object) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0x1a - } - if len(m.Headers) > 0 { - for iNdEx := len(m.Headers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Headers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.SystemHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *PublicKey) 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 *PublicKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Range) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Offset != 0 { - n += 1 + sovTypes(uint64(m.Offset)) - } - if m.Length != 0 { - n += 1 + sovTypes(uint64(m.Length)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *UserHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != nil { - n += m.Value.Size() - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Header_Link) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Link != nil { - l = m.Link.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_Redirect) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Redirect != nil { - l = m.Redirect.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_UserHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UserHeader != nil { - l = m.UserHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_Transform) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Transform != nil { - l = m.Transform.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_Tombstone) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Tombstone != nil { - l = m.Tombstone.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_Token) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Token != nil { - l = m.Token.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_HomoHash) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.HomoHash.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} -func (m *Header_PayloadChecksum) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PayloadChecksum != nil { - l = len(m.PayloadChecksum) - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_Integrity) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Integrity != nil { - l = m.Integrity.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_StorageGroup) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StorageGroup != nil { - l = m.StorageGroup.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Header_PublicKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PublicKey != nil { - l = m.PublicKey.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *Tombstone) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SystemHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Version != 0 { - n += 1 + sovTypes(uint64(m.Version)) - } - if m.PayloadLength != 0 { - n += 1 + sovTypes(uint64(m.PayloadLength)) - } - l = m.ID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.CID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.CreatedAt.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *CreationPoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UnixTime != 0 { - n += 1 + sovTypes(uint64(m.UnixTime)) - } - if m.Epoch != 0 { - n += 1 + sovTypes(uint64(m.Epoch)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *IntegrityHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.HeadersChecksum) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.ChecksumSignature) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Link) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovTypes(uint64(m.Type)) - } - l = m.ID.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Transform) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovTypes(uint64(m.Type)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Object) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.SystemHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - if len(m.Headers) > 0 { - for _, e := range m.Headers { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PublicKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Value) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Range) 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 ErrIntOverflowTypes - } - 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: Range: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Range: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - m.Offset = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Offset |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Length", wireType) - } - m.Length = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Length |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UserHeader) 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 ErrIntOverflowTypes - } - 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: UserHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UserHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Header) 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 ErrIntOverflowTypes - } - 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: Header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Link", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Link{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Link{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Redirect", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &refs.Address{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Redirect{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &UserHeader{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_UserHeader{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Transform", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Transform{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Transform{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tombstone", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Tombstone{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Tombstone{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &service.Token{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Token{v} - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HomoHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var vv Hash - v := &vv - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_HomoHash{*v} - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PayloadChecksum", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Value = &Header_PayloadChecksum{v} - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Integrity", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &IntegrityHeader{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_Integrity{v} - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StorageGroup", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &storagegroup.StorageGroup{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_StorageGroup{v} - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PublicKey{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Header_PublicKey{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Tombstone) 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 ErrIntOverflowTypes - } - 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: Tombstone: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Tombstone: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SystemHeader) 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 ErrIntOverflowTypes - } - 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: SystemHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SystemHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PayloadLength", wireType) - } - m.PayloadLength = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PayloadLength |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CreatedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CreationPoint) 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 ErrIntOverflowTypes - } - 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: CreationPoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CreationPoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnixTime", wireType) - } - m.UnixTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnixTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *IntegrityHeader) 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 ErrIntOverflowTypes - } - 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: IntegrityHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IntegrityHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HeadersChecksum", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HeadersChecksum = append(m.HeadersChecksum[:0], dAtA[iNdEx:postIndex]...) - if m.HeadersChecksum == nil { - m.HeadersChecksum = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChecksumSignature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChecksumSignature = append(m.ChecksumSignature[:0], dAtA[iNdEx:postIndex]...) - if m.ChecksumSignature == nil { - m.ChecksumSignature = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Link) 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 ErrIntOverflowTypes - } - 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: Link: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Link: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Link_Type(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Transform) 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 ErrIntOverflowTypes - } - 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: Transform: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Transform: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Transform_Type(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Object) 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 ErrIntOverflowTypes - } - 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: Object: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Object: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SystemHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SystemHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Headers = append(m.Headers, Header{}) - if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PublicKey) 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 ErrIntOverflowTypes - } - 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: PublicKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PublicKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/object/types.proto b/object/types.proto deleted file mode 100644 index 46e1549..0000000 --- a/object/types.proto +++ /dev/null @@ -1,134 +0,0 @@ -syntax = "proto3"; -package object; -option go_package = "github.com/nspcc-dev/neofs-api-go/object"; -option csharp_namespace = "NeoFS.API.Object"; - -import "refs/types.proto"; -import "service/verify.proto"; -import "storagegroup/types.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -message Range { - // Offset of the data range - uint64 Offset = 1; - // Length of the data range - uint64 Length = 2; -} - -message UserHeader { - // Key of the user's header - string Key = 1; - // Value of the user's header - string Value = 2; -} - -message Header { - oneof Value { - // Link to other objects - Link Link = 1; - // Redirect not used yet - refs.Address Redirect = 2; - // UserHeader is a set of KV headers defined by user - UserHeader UserHeader = 3; - // Transform defines transform operation (e.g. payload split) - Transform Transform = 4; - // Tombstone header that set up in deleted objects - Tombstone Tombstone = 5; - // Token header contains token of the session within which the object was created - service.Token Token = 6; - // HomoHash is a homomorphic hash of original object payload - bytes HomoHash = 7 [(gogoproto.customtype) = "Hash"]; - // PayloadChecksum of actual object's payload - bytes PayloadChecksum = 8; - // Integrity header with checksum of all above headers in the object - IntegrityHeader Integrity = 9; - // StorageGroup contains meta information for the data audit - storagegroup.StorageGroup StorageGroup = 10; - // PublicKey of owner of the object. Key is used for verification and can be based on NeoID or x509 cert. - PublicKey PublicKey = 11; - } -} - -message Tombstone {} - -message SystemHeader { - // Version of the object structure - uint64 Version = 1; - // PayloadLength is an object payload length - uint64 PayloadLength = 2; - - // ID is an object identifier, is a valid UUIDv4 - bytes ID = 3 [(gogoproto.customtype) = "ID", (gogoproto.nullable) = false]; - // OwnerID is a wallet address - bytes OwnerID = 4 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - // CID is a SHA256 hash of the container structure (container identifier) - bytes CID = 5 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; - // CreatedAt is a timestamp of object creation - CreationPoint CreatedAt = 6 [(gogoproto.nullable) = false]; -} - -message CreationPoint { - option (gogoproto.goproto_stringer) = false; - - // UnixTime is a date of creation in unixtime format - int64 UnixTime = 1; - // Epoch is a date of creation in NeoFS epochs - uint64 Epoch = 2; -} - -message IntegrityHeader { - // HeadersChecksum is a checksum of all above headers in the object - bytes HeadersChecksum = 1; - // ChecksumSignature is an user's signature of checksum to verify if it is correct - bytes ChecksumSignature = 2; -} - -message Link { - enum Type { - Unknown = 0; - // Parent object created during object transformation - Parent = 1; - // Previous object in the linked list created during object transformation - Previous = 2; - // Next object in the linked list created during object transformation - Next = 3; - // Child object created during object transformation - Child = 4; - // Object that included into this storage group - StorageGroup = 5; - } - // Type of link - Type type = 1; - // ID is an object identifier, is a valid UUIDv4 - bytes ID = 2 [(gogoproto.customtype) = "ID", (gogoproto.nullable) = false]; -} - -message Transform { - enum Type { - Unknown = 0; - // Split sets when object created after payload split - Split = 1; - // Sign sets when object created after re-signing (doesn't used) - Sign = 2; - // Mould sets when object created after filling missing headers in the object - Mould = 3; - } - // Type of object transformation - Type type = 1; -} - -message Object { - // SystemHeader describes system header - SystemHeader SystemHeader = 1 [(gogoproto.nullable) = false]; - // Headers describes a set of an extended headers - repeated Header Headers = 2 [(gogoproto.nullable) = false]; - // Payload is an object's payload - bytes Payload = 3; -} - -message PublicKey { - // Value contains marshaled ecdsa public key - bytes Value = 1; -} diff --git a/object/types_test.go b/object/types_test.go deleted file mode 100644 index 4a2ca92..0000000 --- a/object/types_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package object - -import ( - "bytes" - "testing" - - "github.com/gogo/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-api-go/storagegroup" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestStringify(t *testing.T) { - res := ` -Object: - SystemHeader: - - ID=7e0b9c6c-aabc-4985-949e-2680e577b48b - - CID=11111111111111111111111111111111 - - OwnerID=NQHKh7fKGieCPrPuiEkY58ucRFwWMyU1Mc - - Version=1 - - PayloadLength=1 - - CreatedAt={UnixTime=1 Epoch=1} - UserHeaders: - - Type=Link - Value={Type=Child ID=7e0b9c6c-aabc-4985-949e-2680e577b48b} - - Type=Redirect - Value={CID=11111111111111111111111111111111 OID=7e0b9c6c-aabc-4985-949e-2680e577b48b} - - Type=UserHeader - Value={Key=test_key Val=test_value} - - Type=Transform - Value=Split - - Type=Tombstone - Value=MARKED - - Type=Token - Value={ID=7e0b9c6c-aabc-4985-949e-2680e577b48b OwnerID=NQHKh7fKGieCPrPuiEkY58ucRFwWMyU1Mc Verb=Search Address=11111111111111111111111111111111/7e0b9c6c-aabc-4985-949e-2680e577b48b Created=1 ValidUntil=2 SessionKey=010203040506 Signature=010203040506} - - Type=HomoHash - Value=1111111111111111111111111111111111111111111111111111111111111111 - - Type=PayloadChecksum - Value=[1 2 3 4 5 6] - - Type=Integrity - Value={Checksum=010203040506 Signature=010203040506} - - Type=StorageGroup - Value={DataSize=5 Hash=31313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 Lifetime={Unit=UnixTime Value=555}} - - Type=PublicKey - Value=[1 2 3 4 5 6] - Payload: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7} -` - - key := test.DecodeKey(0) - - uid, err := refs.NewOwnerID(&key.PublicKey) - require.NoError(t, err) - - var oid refs.UUID - - require.NoError(t, oid.Parse("7e0b9c6c-aabc-4985-949e-2680e577b48b")) - - obj := &Object{ - SystemHeader: SystemHeader{ - Version: 1, - PayloadLength: 1, - ID: oid, - OwnerID: uid, - CID: CID{}, - CreatedAt: CreationPoint{ - UnixTime: 1, - Epoch: 1, - }, - }, - Payload: []byte{1, 2, 3, 4, 5, 6, 7}, - } - - // *Header_Link - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Link{ - Link: &Link{ID: oid, Type: Link_Child}, - }, - }) - - // *Header_Redirect - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Redirect{ - Redirect: &Address{ObjectID: oid, CID: CID{}}, - }, - }) - - // *Header_UserHeader - obj.Headers = append(obj.Headers, Header{ - Value: &Header_UserHeader{ - UserHeader: &UserHeader{ - Key: "test_key", - Value: "test_value", - }, - }, - }) - - // *Header_Transform - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Transform{ - Transform: &Transform{ - Type: Transform_Split, - }, - }, - }) - - // *Header_Tombstone - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Tombstone{ - Tombstone: &Tombstone{}, - }, - }) - - token := new(Token) - token.SetID(oid) - token.SetOwnerID(uid) - token.SetVerb(service.Token_Info_Search) - token.SetAddress(Address{ObjectID: oid, CID: refs.CID{}}) - token.SetCreationEpoch(1) - token.SetExpirationEpoch(2) - token.SetSessionKey([]byte{1, 2, 3, 4, 5, 6}) - token.SetSignature([]byte{1, 2, 3, 4, 5, 6}) - - // *Header_Token - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Token{ - Token: token, - }, - }) - - // *Header_HomoHash - obj.Headers = append(obj.Headers, Header{ - Value: &Header_HomoHash{ - HomoHash: Hash{}, - }, - }) - - // *Header_PayloadChecksum - obj.Headers = append(obj.Headers, Header{ - Value: &Header_PayloadChecksum{ - PayloadChecksum: []byte{1, 2, 3, 4, 5, 6}, - }, - }) - - // *Header_Integrity - obj.Headers = append(obj.Headers, Header{ - Value: &Header_Integrity{ - Integrity: &IntegrityHeader{ - HeadersChecksum: []byte{1, 2, 3, 4, 5, 6}, - ChecksumSignature: []byte{1, 2, 3, 4, 5, 6}, - }, - }, - }) - - // *Header_StorageGroup - obj.Headers = append(obj.Headers, Header{ - Value: &Header_StorageGroup{ - StorageGroup: &storagegroup.StorageGroup{ - ValidationDataSize: 5, - ValidationHash: storagegroup.Hash{}, - Lifetime: &storagegroup.StorageGroup_Lifetime{ - Unit: storagegroup.StorageGroup_Lifetime_UnixTime, - Value: 555, - }, - }, - }, - }) - - // *Header_PublicKey - obj.Headers = append(obj.Headers, Header{ - Value: &Header_PublicKey{ - PublicKey: &PublicKey{Value: []byte{1, 2, 3, 4, 5, 6}}, - }, - }) - - buf := new(bytes.Buffer) - - require.NoError(t, Stringify(buf, obj)) - require.Equal(t, res, buf.String()) -} - -func TestObject_Copy(t *testing.T) { - t.Run("token header", func(t *testing.T) { - token := new(Token) - token.SetID(service.TokenID{1, 2, 3}) - - obj := new(Object) - - obj.AddHeader(&Header{ - Value: &Header_Token{ - Token: token, - }, - }) - - { // Copying - cp := obj.Copy() - - _, h := cp.LastHeader(HeaderType(TokenHdr)) - require.NotNil(t, h) - require.Equal(t, token, h.GetValue().(*Header_Token).Token) - } - - { // Cloning - cl := proto.Clone(obj).(*Object) - require.Equal(t, obj, cl) - - _, h := cl.LastHeader(HeaderType(TokenHdr)) - h.GetToken().SetID(service.TokenID{3, 2, 1}) - - require.NotEqual(t, token, h.GetToken()) - } - }) -} - -func TestIntegrityHeaderGettersSetters(t *testing.T) { - t.Run("headers checksum", func(t *testing.T) { - data := []byte{1, 2, 3} - - v := new(IntegrityHeader) - - v.SetHeadersChecksum(data) - require.Equal(t, data, v.GetHeadersChecksum()) - }) - - t.Run("headers checksum", func(t *testing.T) { - data := []byte{1, 2, 3} - - v := new(IntegrityHeader) - - v.SetSignature(data) - require.Equal(t, data, v.GetSignature()) - }) -} diff --git a/object/utils.go b/object/utils.go deleted file mode 100644 index 33423aa..0000000 --- a/object/utils.go +++ /dev/null @@ -1,100 +0,0 @@ -package object - -import ( - "io" - "strconv" - - "github.com/pkg/errors" -) - -// FilenameHeader is a user header key for names of files, stored by third -// party apps. We recommend to use this header to be compatible with neofs -// http gate, neofs minio gate and neofs-dropper application. -const FilenameHeader = "filename" - -// ByteSize used to format bytes -type ByteSize uint64 - -// String represents ByteSize in string format -func (b ByteSize) String() string { - var ( - dec int64 - unit string - num = int64(b) - ) - - switch { - case num > UnitsTB: - unit = "TB" - dec = UnitsTB - case num > UnitsGB: - unit = "GB" - dec = UnitsGB - case num > UnitsMB: - unit = "MB" - dec = UnitsMB - case num > UnitsKB: - unit = "KB" - dec = UnitsKB - default: - dec = 1 - } - - return strconv.FormatFloat(float64(num)/float64(dec), 'g', 6, 64) + unit -} - -// MakePutRequestHeader combines object and session token value -// into header of object put request. -func MakePutRequestHeader(obj *Object) *PutRequest { - return &PutRequest{ - R: &PutRequest_Header{Header: &PutRequest_PutHeader{ - Object: obj, - }}, - } -} - -// MakePutRequestChunk splits data into chunks that will be transferred -// in the protobuf stream. -func MakePutRequestChunk(chunk []byte) *PutRequest { - return &PutRequest{R: &PutRequest_Chunk{Chunk: chunk}} -} - -func errMaxSizeExceeded(size uint64) error { - return errors.Errorf("object payload size exceed: %s", ByteSize(size).String()) -} - -// ReceiveGetResponse receives object by chunks from the protobuf stream -// and combine it into single get response structure. -func ReceiveGetResponse(c Service_GetClient, maxSize uint64) (*GetResponse, error) { - res, err := c.Recv() - if err == io.EOF { - return res, err - } else if err != nil { - return nil, err - } - - obj := res.GetObject() - if obj == nil { - return nil, ErrHeaderExpected - } - - if obj.SystemHeader.PayloadLength > maxSize { - return nil, errMaxSizeExceeded(maxSize) - } - - if res.NotFull() { - payload := make([]byte, obj.SystemHeader.PayloadLength) - offset := copy(payload, obj.Payload) - - var r *GetResponse - for r, err = c.Recv(); err == nil; r, err = c.Recv() { - offset += copy(payload[offset:], r.GetChunk()) - } - if err != io.EOF { - return nil, err - } - obj.Payload = payload - } - - return res, nil -} diff --git a/object/utils_test.go b/object/utils_test.go deleted file mode 100644 index d4d7fe2..0000000 --- a/object/utils_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package object - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestByteSize_String(t *testing.T) { - cases := []struct { - name string - expect string - actual ByteSize - }{ - { - name: "0 bytes", - expect: "0", - actual: ByteSize(0), - }, - { - name: "101 bytes", - expect: "101", - actual: ByteSize(101), - }, - { - name: "112.84KB", - expect: "112.84KB", - actual: ByteSize(115548), - }, - { - name: "80.44MB", - expect: "80.44MB", - actual: ByteSize(84347453), - }, - { - name: "905.144GB", - expect: "905.144GB", - actual: ByteSize(971891061884), - }, - { - name: "1.857TB", - expect: "1.857TB", - actual: ByteSize(2041793092780), - }, - } - - for i := range cases { - tt := cases[i] - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.expect, tt.actual.String()) - }) - } -} diff --git a/object/verification.go b/object/verification.go deleted file mode 100644 index 0bcbc7c..0000000 --- a/object/verification.go +++ /dev/null @@ -1,149 +0,0 @@ -package object - -import ( - "bytes" - "crypto/ecdsa" - "crypto/sha256" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/pkg/errors" -) - -func (m Object) headersData(check bool) ([]byte, error) { - var bytebuf = new(bytes.Buffer) - - // fixme: we must marshal fields one by one without protobuf marshaling - // protobuf marshaling does not guarantee the same result - - if sysheader, err := m.SystemHeader.Marshal(); err != nil { - return nil, err - } else if _, err := bytebuf.Write(sysheader); err != nil { - return nil, err - } - - n, _ := m.LastHeader(HeaderType(IntegrityHdr)) - for i := range m.Headers { - if check && i == n { - // ignore last integrity header in order to check headers data - continue - } - - if header, err := m.Headers[i].Marshal(); err != nil { - return nil, err - } else if _, err := bytebuf.Write(header); err != nil { - return nil, err - } - } - return bytebuf.Bytes(), nil -} - -func (m Object) headersChecksum(check bool) ([]byte, error) { - data, err := m.headersData(check) - if err != nil { - return nil, err - } - checksum := sha256.Sum256(data) - return checksum[:], nil -} - -// PayloadChecksum calculates sha256 checksum of object payload. -func (m Object) PayloadChecksum() []byte { - checksum := sha256.Sum256(m.Payload) - return checksum[:] -} - -func (m Object) verifySignature(key []byte, ih *IntegrityHeader) error { - pk := crypto.UnmarshalPublicKey(key) - if crypto.Verify(pk, ih.HeadersChecksum, ih.ChecksumSignature) == nil { - return nil - } - return ErrVerifySignature -} - -// Verify performs local integrity check by finding verification header and -// integrity header. If header integrity is passed, function verifies -// checksum of the object payload. -// todo: move this verification logic into separate library -func (m Object) Verify() error { - var ( - err error - checksum []byte - pubkey []byte - ) - ind, ih := m.LastHeader(HeaderType(IntegrityHdr)) - if ih == nil || ind != len(m.Headers)-1 { - return ErrHeaderNotFound - } - integrity := ih.Value.(*Header_Integrity).Integrity - - // Prepare structures - _, vh := m.LastHeader(HeaderType(TokenHdr)) - if vh == nil { - _, pkh := m.LastHeader(HeaderType(PublicKeyHdr)) - if pkh == nil { - return ErrHeaderNotFound - } - pubkey = pkh.Value.(*Header_PublicKey).PublicKey.Value - } else { - pubkey = vh.Value.(*Header_Token).Token.GetSessionKey() - } - - // Verify signature - err = m.verifySignature(pubkey, integrity) - if err != nil { - return errors.Wrapf(err, "public key: %x", pubkey) - } - - // Verify checksum of header - checksum, err = m.headersChecksum(true) - if err != nil { - return err - } - if !bytes.Equal(integrity.HeadersChecksum, checksum) { - return ErrVerifyHeader - } - - // Verify checksum of payload - if m.SystemHeader.PayloadLength > 0 && !m.IsLinking() { - checksum = m.PayloadChecksum() - - _, ph := m.LastHeader(HeaderType(PayloadChecksumHdr)) - if ph == nil { - return ErrHeaderNotFound - } - if !bytes.Equal(ph.Value.(*Header_PayloadChecksum).PayloadChecksum, checksum) { - return ErrVerifyPayload - } - } - return nil -} - -// CreateIntegrityHeader returns signed integrity header for the object -func CreateIntegrityHeader(obj *Object, key *ecdsa.PrivateKey) (*Header, error) { - headerChecksum, err := obj.headersChecksum(false) - if err != nil { - return nil, err - } - headerChecksumSignature, err := crypto.Sign(key, headerChecksum) - if err != nil { - return nil, err - } - - return &Header{Value: &Header_Integrity{ - Integrity: &IntegrityHeader{ - HeadersChecksum: headerChecksum, - ChecksumSignature: headerChecksumSignature, - }, - }}, nil -} - -// Sign creates new integrity header and adds it to the end of the list of -// extended headers. -func (m *Object) Sign(key *ecdsa.PrivateKey) error { - ih, err := CreateIntegrityHeader(m, key) - if err != nil { - return err - } - m.AddHeader(ih) - return nil -} diff --git a/object/verification_test.go b/object/verification_test.go deleted file mode 100644 index 95a6d32..0000000 --- a/object/verification_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package object - -import ( - "testing" - - "github.com/google/uuid" - "github.com/nspcc-dev/neofs-api-go/container" - "github.com/nspcc-dev/neofs-api-go/refs" - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestObject_Verify(t *testing.T) { - key := test.DecodeKey(0) - sessionkey := test.DecodeKey(1) - - payload := make([]byte, 1024*1024) - - cnr, err := container.NewTestContainer() - require.NoError(t, err) - - cid, err := cnr.ID() - require.NoError(t, err) - - id, err := uuid.NewRandom() - uid := refs.UUID(id) - require.NoError(t, err) - - obj := &Object{ - SystemHeader: SystemHeader{ - ID: uid, - CID: cid, - OwnerID: refs.OwnerID([refs.OwnerIDSize]byte{}), - }, - Headers: []Header{ - { - Value: &Header_UserHeader{ - UserHeader: &UserHeader{ - Key: "Profession", - Value: "Developer", - }, - }, - }, - { - Value: &Header_UserHeader{ - UserHeader: &UserHeader{ - Key: "Language", - Value: "GO", - }, - }, - }, - }, - } - obj.SetPayload(payload) - obj.SetHeader(&Header{Value: &Header_PayloadChecksum{[]byte("incorrect checksum")}}) - - t.Run("error no integrity header and pubkey", func(t *testing.T) { - err = obj.Verify() - require.EqualError(t, err, ErrHeaderNotFound.Error()) - }) - - badHeaderChecksum := []byte("incorrect checksum") - signature, err := crypto.Sign(sessionkey, badHeaderChecksum) - require.NoError(t, err) - ih := &IntegrityHeader{ - HeadersChecksum: badHeaderChecksum, - ChecksumSignature: signature, - } - obj.SetHeader(&Header{Value: &Header_Integrity{ih}}) - - t.Run("error no validation header", func(t *testing.T) { - err = obj.Verify() - require.EqualError(t, err, ErrHeaderNotFound.Error()) - }) - - dataPK := crypto.MarshalPublicKey(&sessionkey.PublicKey) - signature, err = crypto.Sign(key, dataPK) - tok := new(Token) - tok.SetSignature(signature) - tok.SetSessionKey(dataPK) - obj.AddHeader(&Header{Value: &Header_Token{Token: tok}}) - - // validation header is not last - t.Run("error validation header is not last", func(t *testing.T) { - err = obj.Verify() - require.EqualError(t, err, ErrHeaderNotFound.Error()) - }) - - obj.Headers = obj.Headers[:len(obj.Headers)-2] - obj.AddHeader(&Header{Value: &Header_Token{Token: tok}}) - obj.SetHeader(&Header{Value: &Header_Integrity{ih}}) - - t.Run("error invalid header checksum", func(t *testing.T) { - err = obj.Verify() - require.EqualError(t, err, ErrVerifyHeader.Error()) - }) - - obj.Headers = obj.Headers[:len(obj.Headers)-1] - genIH, err := CreateIntegrityHeader(obj, sessionkey) - require.NoError(t, err) - obj.SetHeader(genIH) - - t.Run("error invalid payload checksum", func(t *testing.T) { - err = obj.Verify() - require.EqualError(t, err, ErrVerifyPayload.Error()) - }) - - obj.SetHeader(&Header{Value: &Header_PayloadChecksum{obj.PayloadChecksum()}}) - - obj.Headers = obj.Headers[:len(obj.Headers)-1] - genIH, err = CreateIntegrityHeader(obj, sessionkey) - require.NoError(t, err) - obj.SetHeader(genIH) - - t.Run("correct with tok", func(t *testing.T) { - err = obj.Verify() - require.NoError(t, err) - }) - - pkh := Header{Value: &Header_PublicKey{&PublicKey{ - Value: crypto.MarshalPublicKey(&key.PublicKey), - }}} - // replace tok with pkh - obj.Headers[len(obj.Headers)-2] = pkh - // re-sign object - obj.Sign(sessionkey) - - t.Run("incorrect with bad public key", func(t *testing.T) { - err = obj.Verify() - require.Error(t, err) - }) - - obj.SetHeader(&Header{Value: &Header_PublicKey{&PublicKey{ - Value: dataPK, - }}}) - obj.Sign(sessionkey) - - t.Run("correct with good public key", func(t *testing.T) { - err = obj.Verify() - require.NoError(t, err) - }) - -} diff --git a/query/types.go b/query/types.go deleted file mode 100644 index 15a54f6..0000000 --- a/query/types.go +++ /dev/null @@ -1,43 +0,0 @@ -package query - -import ( - "strings" - - "github.com/gogo/protobuf/proto" -) - -var ( - _ proto.Message = (*Query)(nil) - _ proto.Message = (*Filter)(nil) -) - -// String returns string representation of Filter. -func (m Filter) String() string { - b := new(strings.Builder) - b.WriteString("") - return b.String() -} - -// String returns string representation of Query. -func (m Query) String() string { - b := new(strings.Builder) - b.WriteString(" 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x1a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if m.Type != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Query) 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 *Query) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Query) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Filters) > 0 { - for iNdEx := len(m.Filters) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Filters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Filter) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovTypes(uint64(m.Type)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Query) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Filters) > 0 { - for _, e := range m.Filters { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Filter) 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 ErrIntOverflowTypes - } - 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: Filter: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Filter: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Filter_Type(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - 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 ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Query) 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 ErrIntOverflowTypes - } - 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: Query: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Query: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Filters = append(m.Filters, Filter{}) - if err := m.Filters[len(m.Filters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/query/types.proto b/query/types.proto deleted file mode 100644 index ebc0d64..0000000 --- a/query/types.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; -package query; -option go_package = "github.com/nspcc-dev/neofs-api-go/query"; -option csharp_namespace = "NeoFS.API.Query"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -message Filter { - option (gogoproto.goproto_stringer) = false; - - enum Type { - // Exact sets when value of filter should be equal to the header value - Exact = 0; - // Regex sets when value of filter should match the header value by the regular expression - Regex = 1; - } - - // Type of filter - Type type = 1 [(gogoproto.customname) = "Type"]; - // Name of field that should be filtered - string Name = 2; - // Value that should be used for filter - string Value = 3; -} - -message Query { - option (gogoproto.goproto_stringer) = false; - - // Filters is set of filters, should not be empty - repeated Filter Filters = 1 [(gogoproto.nullable) = false]; -} diff --git a/refs/address.go b/refs/address.go deleted file mode 100644 index ad5f420..0000000 --- a/refs/address.go +++ /dev/null @@ -1,80 +0,0 @@ -package refs - -import ( - "crypto/sha256" - "strings" - - "github.com/gogo/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/internal" -) - -const ( - joinSeparator = "/" - - // ErrWrongAddress is raised when wrong address is passed to Address.Parse ParseAddress. - ErrWrongAddress = internal.Error("wrong address") - - // ErrEmptyAddress is raised when empty address is passed to Address.Parse ParseAddress. - ErrEmptyAddress = internal.Error("empty address") -) - -// ParseAddress parses address from string representation into new Address. -func ParseAddress(str string) (*Address, error) { - var addr Address - return &addr, addr.Parse(str) -} - -// Parse parses address from string representation into current Address. -func (m *Address) Parse(addr string) error { - if m == nil { - return ErrEmptyAddress - } - - items := strings.Split(addr, joinSeparator) - if len(items) != 2 { - return ErrWrongAddress - } - - if err := m.CID.Parse(items[0]); err != nil { - return err - } else if err := m.ObjectID.Parse(items[1]); err != nil { - return err - } - - return nil -} - -// String returns string representation of Address. -func (m Address) String() string { - return strings.Join([]string{m.CID.String(), m.ObjectID.String()}, joinSeparator) -} - -// IsFull checks that ContainerID and ObjectID is not empty. -func (m Address) IsFull() bool { - return !m.CID.Empty() && !m.ObjectID.Empty() -} - -// Equal checks that current Address is equal to passed Address. -func (m Address) Equal(a2 *Address) bool { - return m.CID.Equal(a2.CID) && m.ObjectID.Equal(a2.ObjectID) -} - -// Hash returns []byte that used as a key for storage bucket. -func (m Address) Hash() ([]byte, error) { - if !m.IsFull() { - return nil, ErrEmptyAddress - } - h := sha256.Sum256(append(m.ObjectID.Bytes(), m.CID.Bytes()...)) - return h[:], nil -} - -// Merge used by proto.Clone -func (m *Address) Merge(src proto.Message) { - if addr, ok := src.(*Address); ok { - cid := proto.Clone(&addr.CID).(*CID) - oid := proto.Clone(&addr.ObjectID).(*ObjectID) - - m.CID = *cid - m.ObjectID = *oid - } -} diff --git a/refs/cid.go b/refs/cid.go deleted file mode 100644 index 83450a9..0000000 --- a/refs/cid.go +++ /dev/null @@ -1,104 +0,0 @@ -package refs - -import ( - "bytes" - "crypto/sha256" - - "github.com/gogo/protobuf/proto" - "github.com/mr-tron/base58" - "github.com/pkg/errors" -) - -// CIDForBytes creates CID for passed bytes. -func CIDForBytes(data []byte) CID { return sha256.Sum256(data) } - -// CIDFromBytes parses CID from passed bytes. -func CIDFromBytes(data []byte) (cid CID, err error) { - if ln := len(data); ln != CIDSize { - return CID{}, errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", CIDSize, ln) - } - - copy(cid[:], data) - return -} - -// CIDFromString parses CID from string representation of CID. -func CIDFromString(c string) (CID, error) { - var cid CID - decoded, err := base58.Decode(c) - if err != nil { - return cid, err - } - return CIDFromBytes(decoded) -} - -// Size returns size of CID (CIDSize). -func (c CID) Size() int { return CIDSize } - -// Parse tries to parse CID from string representation. -func (c *CID) Parse(cid string) error { - var err error - if *c, err = CIDFromString(cid); err != nil { - return err - } - return nil -} - -// Empty checks that current CID is empty. -func (c CID) Empty() bool { return bytes.Equal(c.Bytes(), emptyCID) } - -// Equal checks that current CID is equal to passed CID. -func (c CID) Equal(cid CID) bool { return bytes.Equal(c.Bytes(), cid.Bytes()) } - -// Marshal returns CID bytes representation. -func (c CID) Marshal() ([]byte, error) { return c.Bytes(), nil } - -// MarshalBinary returns CID bytes representation. -func (c CID) MarshalBinary() ([]byte, error) { return c.Bytes(), nil } - -// MarshalTo marshal CID to bytes representation into passed bytes. -func (c *CID) MarshalTo(data []byte) (int, error) { return copy(data, c.Bytes()), nil } - -// ProtoMessage method to satisfy proto.Message interface. -func (c CID) ProtoMessage() {} - -// String returns string representation of CID. -func (c CID) String() string { return base58.Encode(c[:]) } - -// Reset resets current CID to zero value. -func (c *CID) Reset() { *c = CID{} } - -// Bytes returns CID bytes representation. -func (c CID) Bytes() []byte { - buf := make([]byte, CIDSize) - copy(buf, c[:]) - return buf -} - -// UnmarshalBinary tries to parse bytes representation of CID. -func (c *CID) UnmarshalBinary(data []byte) error { return c.Unmarshal(data) } - -// Unmarshal tries to parse bytes representation of CID. -func (c *CID) Unmarshal(data []byte) error { - if ln := len(data); ln != CIDSize { - return errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", CIDSize, ln) - } - - copy((*c)[:], data) - return nil -} - -// Verify validates that current CID is generated for passed bytes data. -func (c CID) Verify(data []byte) error { - if id := CIDForBytes(data); !bytes.Equal(c[:], id[:]) { - return errors.New("wrong hash for data") - } - return nil -} - -// Merge used by proto.Clone -func (c *CID) Merge(src proto.Message) { - if cid, ok := src.(*CID); ok { - *c = *cid - } -} diff --git a/refs/owner.go b/refs/owner.go deleted file mode 100644 index 0e599e9..0000000 --- a/refs/owner.go +++ /dev/null @@ -1,77 +0,0 @@ -package refs - -import ( - "bytes" - "crypto/ecdsa" - - "github.com/gogo/protobuf/proto" - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/chain" - "github.com/pkg/errors" -) - -// NewOwnerID returns generated OwnerID from passed public key. -func NewOwnerID(key *ecdsa.PublicKey) (owner OwnerID, err error) { - if key == nil { - return - } - - var d []byte - - d, err = base58.Decode(chain.KeyToAddress(key)) - if err != nil { - return - } - - copy(owner[:], d) - - return -} - -// Size returns OwnerID size in bytes (OwnerIDSize). -func (OwnerID) Size() int { return OwnerIDSize } - -// Empty checks that current OwnerID is empty value. -func (o OwnerID) Empty() bool { return bytes.Equal(o.Bytes(), emptyOwner) } - -// Equal checks that current OwnerID is equal to passed OwnerID. -func (o OwnerID) Equal(id OwnerID) bool { return bytes.Equal(o.Bytes(), id.Bytes()) } - -// Reset sets current OwnerID to empty value. -func (o *OwnerID) Reset() { *o = OwnerID{} } - -// ProtoMessage method to satisfy proto.Message interface. -func (OwnerID) ProtoMessage() {} - -// Marshal returns OwnerID bytes representation. -func (o OwnerID) Marshal() ([]byte, error) { return o.Bytes(), nil } - -// MarshalTo copies OwnerID bytes representation into passed slice of bytes. -func (o OwnerID) MarshalTo(data []byte) (int, error) { return copy(data, o.Bytes()), nil } - -// String returns string representation of OwnerID. -func (o OwnerID) String() string { return base58.Encode(o[:]) } - -// Bytes returns OwnerID bytes representation. -func (o OwnerID) Bytes() []byte { - buf := make([]byte, OwnerIDSize) - copy(buf, o[:]) - return buf -} - -// Unmarshal tries to parse OwnerID bytes representation into current OwnerID. -func (o *OwnerID) Unmarshal(data []byte) error { - if ln := len(data); ln != OwnerIDSize { - return errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", OwnerIDSize, ln) - } - - copy((*o)[:], data) - return nil -} - -// Merge used by proto.Clone -func (o *OwnerID) Merge(src proto.Message) { - if uid, ok := src.(*OwnerID); ok { - *o = *uid - } -} diff --git a/refs/sgid.go b/refs/sgid.go deleted file mode 100644 index d6fcf2d..0000000 --- a/refs/sgid.go +++ /dev/null @@ -1,14 +0,0 @@ -package refs - -import ( - "github.com/pkg/errors" -) - -// SGIDFromBytes parse bytes representation of SGID into new SGID value. -func SGIDFromBytes(data []byte) (sgid SGID, err error) { - if ln := len(data); ln != SGIDSize { - return SGID{}, errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", SGIDSize, ln) - } - copy(sgid[:], data) - return -} diff --git a/refs/types.go b/refs/types.go deleted file mode 100644 index 417eec3..0000000 --- a/refs/types.go +++ /dev/null @@ -1,123 +0,0 @@ -// This package contains basic structures implemented in Go, such as -// -// CID - container id -// OwnerID - owner id -// ObjectID - object id -// SGID - storage group id -// Address - contains object id and container id -// UUID - a 128 bit (16 byte) Universal Unique Identifier as defined in RFC 4122 - -package refs - -import ( - "crypto/sha256" - - "github.com/google/uuid" - "github.com/nspcc-dev/neofs-api-go/chain" - "github.com/nspcc-dev/neofs-api-go/internal" -) - -type ( - // CID is implementation of ContainerID. - CID [CIDSize]byte - - // UUID wrapper over github.com/google/uuid.UUID. - UUID uuid.UUID - - // SGID is type alias of UUID. - SGID = UUID - - // ObjectID is type alias of UUID. - ObjectID = UUID - - // MessageID is type alias of UUID. - MessageID = UUID - - // OwnerID is wrapper over neofs-proto/chain.WalletAddress. - OwnerID chain.WalletAddress -) - -// OwnerIDSource is an interface of the container of an OwnerID value with read access. -type OwnerIDSource interface { - GetOwnerID() OwnerID -} - -// OwnerIDContainer is an interface of the container of an OwnerID value. -type OwnerIDContainer interface { - OwnerIDSource - SetOwnerID(OwnerID) -} - -// AddressContainer is an interface of the container of object address value. -type AddressContainer interface { - GetAddress() Address - SetAddress(Address) -} - -const ( - // UUIDSize contains size of UUID. - UUIDSize = 16 - - // SGIDSize contains size of SGID. - SGIDSize = UUIDSize - - // CIDSize contains size of CID. - CIDSize = sha256.Size - - // OwnerIDSize contains size of OwnerID. - OwnerIDSize = chain.AddressLength - - // ErrWrongDataSize is raised when passed bytes into Unmarshal have wrong size. - ErrWrongDataSize = internal.Error("wrong data size") - - // ErrEmptyOwner is raised when empty OwnerID is passed into container.New. - ErrEmptyOwner = internal.Error("owner cant be empty") - - // ErrEmptyCapacity is raised when empty Capacity is passed container.New. - ErrEmptyCapacity = internal.Error("capacity cant be empty") - - // ErrEmptyContainer is raised when it CID method is called for an empty container. - ErrEmptyContainer = internal.Error("cannot return ID for empty container") -) - -var ( - emptyCID = (CID{}).Bytes() - emptyUUID = (UUID{}).Bytes() - emptyOwner = (OwnerID{}).Bytes() - - _ internal.Custom = (*CID)(nil) - _ internal.Custom = (*SGID)(nil) - _ internal.Custom = (*UUID)(nil) - _ internal.Custom = (*OwnerID)(nil) - _ internal.Custom = (*ObjectID)(nil) - _ internal.Custom = (*MessageID)(nil) - - // NewSGID method alias. - NewSGID = NewUUID - - // NewObjectID method alias. - NewObjectID = NewUUID - - // NewMessageID method alias. - NewMessageID = NewUUID -) - -// NewUUID returns a Random (Version 4) UUID. -// -// The strength of the UUIDs is based on the strength of the crypto/rand -// package. -// -// A note about uniqueness derived from the UUID Wikipedia entry: -// -// Randomly generated UUIDs have 122 random bits. One's annual risk of being -// hit by a meteorite is estimated to be one chance in 17 billion, that -// means the probability is about 0.00000000006 (6 × 10−11), -// equivalent to the odds of creating a few tens of trillions of UUIDs in a -// year and having one duplicate. -func NewUUID() (UUID, error) { - id, err := uuid.NewRandom() - if err != nil { - return UUID{}, err - } - return UUID(id), nil -} diff --git a/refs/types.pb.go b/refs/types.pb.go deleted file mode 100644 index 1b483cd..0000000 --- a/refs/types.pb.go +++ /dev/null @@ -1,372 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: refs/types.proto - -package refs - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Address of object (container id + object id) -type Address struct { - // ObjectID is an object identifier, valid UUIDv4 represented in bytes - ObjectID ObjectID `protobuf:"bytes,1,opt,name=ObjectID,proto3,customtype=ObjectID" json:"ObjectID"` - // CID is container identifier - CID CID `protobuf:"bytes,2,opt,name=CID,proto3,customtype=CID" json:"CID"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Address) Reset() { *m = Address{} } -func (*Address) ProtoMessage() {} -func (*Address) Descriptor() ([]byte, []int) { - return fileDescriptor_063a64a96d952d31, []int{0} -} -func (m *Address) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Address) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Address) XXX_Merge(src proto.Message) { - xxx_messageInfo_Address.Merge(m, src) -} -func (m *Address) XXX_Size() int { - return m.Size() -} -func (m *Address) XXX_DiscardUnknown() { - xxx_messageInfo_Address.DiscardUnknown(m) -} - -var xxx_messageInfo_Address proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Address)(nil), "refs.Address") -} - -func init() { proto.RegisterFile("refs/types.proto", fileDescriptor_063a64a96d952d31) } - -var fileDescriptor_063a64a96d952d31 = []byte{ - // 221 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x4a, 0x4d, 0x2b, - 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x01, 0x89, - 0x48, 0xe9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa7, 0xe7, 0xa7, - 0xe7, 0xeb, 0x83, 0x25, 0x93, 0x4a, 0xd3, 0xc0, 0x3c, 0x30, 0x07, 0xcc, 0x82, 0x68, 0x52, 0x0a, - 0xe3, 0x62, 0x77, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x16, 0xd2, 0xe1, 0xe2, 0xf0, 0x4f, 0xca, - 0x4a, 0x4d, 0x2e, 0xf1, 0x74, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x71, 0x12, 0x38, 0x71, 0x4f, - 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0xb8, 0x78, 0x10, 0x9c, 0x25, 0x24, 0xcb, 0xc5, 0xec, 0xec, 0xe9, - 0x22, 0xc1, 0x04, 0x56, 0xc8, 0x0d, 0x55, 0x08, 0x12, 0x0a, 0x02, 0x11, 0x4e, 0xa1, 0x37, 0x1e, - 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x1b, - 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x0d, 0xc9, 0x91, - 0x79, 0xc5, 0x05, 0xc9, 0xc9, 0xba, 0x29, 0xa9, 0x65, 0xfa, 0x79, 0xa9, 0xf9, 0x69, 0xc5, 0xba, - 0x89, 0x05, 0x99, 0xba, 0xe9, 0xf9, 0xfa, 0x20, 0xcf, 0xac, 0x62, 0xe2, 0xf3, 0x4b, 0xcd, 0x77, - 0x0b, 0xd6, 0x73, 0x0c, 0xf0, 0xd4, 0x0b, 0x4a, 0x4d, 0x2b, 0x4e, 0x62, 0x03, 0xbb, 0xda, 0x18, - 0x10, 0x00, 0x00, 0xff, 0xff, 0xae, 0x9a, 0x6d, 0x68, 0xfe, 0x00, 0x00, 0x00, -} - -func (m *Address) 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 *Address) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Address) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size := m.CID.Size() - i -= size - if _, err := m.CID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.ObjectID.Size() - i -= size - if _, err := m.ObjectID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Address) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ObjectID.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.CID.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Address) 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 ErrIntOverflowTypes - } - 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: Address: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Address: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ObjectID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ObjectID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/refs/types.proto b/refs/types.proto deleted file mode 100644 index 6b001c0..0000000 --- a/refs/types.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -package refs; -option go_package = "github.com/nspcc-dev/neofs-api-go/refs"; -option csharp_namespace = "NeoFS.API.Refs"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -option (gogoproto.stringer_all) = false; -option (gogoproto.goproto_stringer_all) = false; - -// Address of object (container id + object id) -message Address { - // ObjectID is an object identifier, valid UUIDv4 represented in bytes - bytes ObjectID = 1[(gogoproto.customtype) = "ObjectID", (gogoproto.nullable) = false]; - // CID is container identifier - bytes CID = 2[(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; -} diff --git a/refs/types_test.go b/refs/types_test.go deleted file mode 100644 index 948a48b..0000000 --- a/refs/types_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package refs - -import ( - "strings" - "testing" - - "github.com/gogo/protobuf/proto" - "github.com/google/uuid" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestSGID(t *testing.T) { - t.Run("check that marshal/unmarshal works like expected", func(t *testing.T) { - var sgid1, sgid2 UUID - - sgid1, err := NewSGID() - require.NoError(t, err) - - data, err := proto.Marshal(&sgid1) - require.NoError(t, err) - - require.NoError(t, sgid2.Unmarshal(data)) - require.Equal(t, sgid1, sgid2) - }) - - t.Run("check that proto.Clone works like expected", func(t *testing.T) { - var ( - sgid1 UUID - sgid2 *UUID - ) - - sgid1, err := NewSGID() - require.NoError(t, err) - - sgid2 = proto.Clone(&sgid1).(*SGID) - require.Equal(t, sgid1, *sgid2) - }) -} - -func TestUUID(t *testing.T) { - t.Run("parse should work like expected", func(t *testing.T) { - var u UUID - - id, err := uuid.NewRandom() - require.NoError(t, err) - - require.NoError(t, u.Parse(id.String())) - require.Equal(t, id.String(), u.String()) - }) - - t.Run("check that marshal/unmarshal works like expected", func(t *testing.T) { - var u1, u2 UUID - - u1 = UUID{0x8f, 0xe4, 0xeb, 0xa0, 0xb8, 0xfb, 0x49, 0x3b, 0xbb, 0x1d, 0x1d, 0x13, 0x6e, 0x69, 0xfc, 0xf7} - - data, err := proto.Marshal(&u1) - require.NoError(t, err) - - require.NoError(t, u2.Unmarshal(data)) - require.Equal(t, u1, u2) - }) - - t.Run("check that marshal/unmarshal works like expected even for msg id", func(t *testing.T) { - var u2 MessageID - - u1, err := NewMessageID() - require.NoError(t, err) - - data, err := proto.Marshal(&u1) - require.NoError(t, err) - - require.NoError(t, u2.Unmarshal(data)) - require.Equal(t, u1, u2) - }) -} - -func TestOwnerID(t *testing.T) { - t.Run("check that marshal/unmarshal works like expected", func(t *testing.T) { - var u1, u2 OwnerID - - owner, err := NewOwnerID(nil) - require.NoError(t, err) - require.True(t, owner.Empty()) - - key := test.DecodeKey(0) - - u1, err = NewOwnerID(&key.PublicKey) - require.NoError(t, err) - data, err := proto.Marshal(&u1) - require.NoError(t, err) - - require.NoError(t, u2.Unmarshal(data)) - require.Equal(t, u1, u2) - }) - - t.Run("check that proto.Clone works like expected", func(t *testing.T) { - var u2 *OwnerID - - key := test.DecodeKey(0) - - u1, err := NewOwnerID(&key.PublicKey) - require.NoError(t, err) - - u2 = proto.Clone(&u1).(*OwnerID) - require.Equal(t, u1, *u2) - }) -} - -func TestAddress(t *testing.T) { - cid := CIDForBytes([]byte("test")) - - id, err := NewObjectID() - require.NoError(t, err) - - expect := strings.Join([]string{ - cid.String(), - id.String(), - }, joinSeparator) - - require.NotPanics(t, func() { - actual := (Address{ - ObjectID: id, - CID: cid, - }).String() - - require.Equal(t, expect, actual) - }) - - var temp Address - require.NoError(t, temp.Parse(expect)) - require.Equal(t, expect, temp.String()) - - actual, err := ParseAddress(expect) - require.NoError(t, err) - require.Equal(t, expect, actual.String()) - - addr := proto.Clone(actual).(*Address) - require.Equal(t, actual, addr) - require.Equal(t, expect, addr.String()) -} diff --git a/refs/uuid.go b/refs/uuid.go deleted file mode 100644 index 5a49b92..0000000 --- a/refs/uuid.go +++ /dev/null @@ -1,84 +0,0 @@ -package refs - -import ( - "bytes" - "encoding/hex" - - "github.com/gogo/protobuf/proto" - "github.com/google/uuid" - "github.com/pkg/errors" -) - -func encodeHex(dst []byte, uuid UUID) { - hex.Encode(dst, uuid[:4]) - dst[8] = '-' - hex.Encode(dst[9:13], uuid[4:6]) - dst[13] = '-' - hex.Encode(dst[14:18], uuid[6:8]) - dst[18] = '-' - hex.Encode(dst[19:23], uuid[8:10]) - dst[23] = '-' - hex.Encode(dst[24:], uuid[10:]) -} - -// Size returns size in bytes of UUID (UUIDSize). -func (UUID) Size() int { return UUIDSize } - -// Empty checks that current UUID is empty value. -func (u UUID) Empty() bool { return bytes.Equal(u.Bytes(), emptyUUID) } - -// Reset sets current UUID to empty value. -func (u *UUID) Reset() { *u = [UUIDSize]byte{} } - -// ProtoMessage method to satisfy proto.Message. -func (UUID) ProtoMessage() {} - -// Marshal returns UUID bytes representation. -func (u UUID) Marshal() ([]byte, error) { return u.Bytes(), nil } - -// MarshalTo returns UUID bytes representation. -func (u UUID) MarshalTo(data []byte) (int, error) { return copy(data, u[:]), nil } - -// Bytes returns UUID bytes representation. -func (u UUID) Bytes() []byte { - buf := make([]byte, UUIDSize) - copy(buf, u[:]) - return buf -} - -// Equal checks that current UUID is equal to passed UUID. -func (u UUID) Equal(u2 UUID) bool { return bytes.Equal(u.Bytes(), u2.Bytes()) } - -func (u UUID) String() string { - var buf [36]byte - encodeHex(buf[:], u) - return string(buf[:]) -} - -// Unmarshal tries to parse UUID bytes representation. -func (u *UUID) Unmarshal(data []byte) error { - if ln := len(data); ln != UUIDSize { - return errors.Wrapf(ErrWrongDataSize, "expect=%d, actual=%d", UUIDSize, ln) - } - - copy((*u)[:], data) - return nil -} - -// Parse tries to parse UUID string representation. -func (u *UUID) Parse(id string) error { - tmp, err := uuid.Parse(id) - if err != nil { - return errors.Wrapf(err, "could not parse `%s`", id) - } - - copy((*u)[:], tmp[:]) - return nil -} - -// Merge used by proto.Clone -func (u *UUID) Merge(src proto.Message) { - if tmp, ok := src.(*UUID); ok { - *u = *tmp - } -} diff --git a/service/alias.go b/service/alias.go deleted file mode 100644 index 9a40702..0000000 --- a/service/alias.go +++ /dev/null @@ -1,20 +0,0 @@ -package service - -import ( - "github.com/nspcc-dev/neofs-api-go/refs" -) - -// TokenID is a type alias of UUID ref. -type TokenID = refs.UUID - -// OwnerID is a type alias of OwnerID ref. -type OwnerID = refs.OwnerID - -// Address is a type alias of Address ref. -type Address = refs.Address - -// AddressContainer is a type alias of refs.AddressContainer. -type AddressContainer = refs.AddressContainer - -// OwnerIDContainer is a type alias of refs.OwnerIDContainer. -type OwnerIDContainer = refs.OwnerIDContainer diff --git a/service/bearer.go b/service/bearer.go deleted file mode 100644 index 327f74f..0000000 --- a/service/bearer.go +++ /dev/null @@ -1,140 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - "io" - - "github.com/nspcc-dev/neofs-api-go/refs" - crypto "github.com/nspcc-dev/neofs-crypto" -) - -type signedBearerToken struct { - BearerToken -} - -type bearerMsgWrapper struct { - *BearerTokenMsg -} - -const fixedBearerTokenDataSize = 0 + - refs.OwnerIDSize + - 8 - -// NewSignedBearerToken wraps passed BearerToken in a component suitable for signing. -// -// Result can be used in AddSignatureWithKey function. -func NewSignedBearerToken(token BearerToken) DataWithSignKeyAccumulator { - return &signedBearerToken{ - BearerToken: token, - } -} - -// NewVerifiedBearerToken wraps passed SessionToken in a component suitable for signature verification. -// -// Result can be used in VerifySignatureWithKey function. -func NewVerifiedBearerToken(token BearerToken) DataWithSignature { - return &signedBearerToken{ - BearerToken: token, - } -} - -// AddSignKey calls a Signature field setter and an OwnerKey field setter with corresponding arguments. -func (s signedBearerToken) AddSignKey(sig []byte, key *ecdsa.PublicKey) { - if s.BearerToken != nil { - s.SetSignature(sig) - - s.SetOwnerKey( - crypto.MarshalPublicKey(key), - ) - } -} - -// SignedData returns token information in a binary representation. -func (s signedBearerToken) SignedData() ([]byte, error) { - return SignedDataFromReader(s) -} - -// SignedDataSize returns the length of signed token information slice. -func (s signedBearerToken) SignedDataSize() int { - return bearerTokenInfoSize(s.BearerToken) -} - -// ReadSignedData copies a binary representation of the token information to passed buffer. -// -// If buffer length is less than required, io.ErrUnexpectedEOF returns. -func (s signedBearerToken) ReadSignedData(p []byte) (int, error) { - sz := s.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - copyBearerTokenSignedData(p, s.BearerToken) - - return sz, nil -} - -func bearerTokenInfoSize(v ACLRulesSource) int { - if v == nil { - return 0 - } - return fixedBearerTokenDataSize + len(v.GetACLRules()) -} - -// Fills passed buffer with signing token information bytes. -// Does not check buffer length, it is understood that enough space is allocated in it. -// -// If passed BearerTokenInfo, buffer remains unchanged. -func copyBearerTokenSignedData(buf []byte, token BearerTokenInfo) { - if token == nil { - return - } - - var off int - - off += copy(buf[off:], token.GetACLRules()) - - off += copy(buf[off:], token.GetOwnerID().Bytes()) - - tokenEndianness.PutUint64(buf[off:], token.ExpirationEpoch()) - off += 8 -} - -// SetACLRules is an ACLRules field setter. -func (m *BearerTokenMsg_Info) SetACLRules(v []byte) { - m.ACLRules = v -} - -// SetValidUntil is a ValidUntil field setter. -func (m *BearerTokenMsg_Info) SetValidUntil(v uint64) { - m.ValidUntil = v -} - -// GetOwnerID if an OwnerID field getter. -func (m BearerTokenMsg_Info) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *BearerTokenMsg_Info) SetOwnerID(v OwnerID) { - m.OwnerID = v -} - -// ExpirationEpoch returns the result of ValidUntil field getter. -func (m BearerTokenMsg_Info) ExpirationEpoch() uint64 { - return m.GetValidUntil() -} - -// SetExpirationEpoch passes argument to ValidUntil field setter. -func (m *BearerTokenMsg_Info) SetExpirationEpoch(v uint64) { - m.SetValidUntil(v) -} - -// SetOwnerKey is an OwnerKey field setter. -func (m *BearerTokenMsg) SetOwnerKey(v []byte) { - m.OwnerKey = v -} - -// SetSignature is a Signature field setter. -func (m *BearerTokenMsg) SetSignature(v []byte) { - m.Signature = v -} diff --git a/service/bearer_test.go b/service/bearer_test.go deleted file mode 100644 index d6985cb..0000000 --- a/service/bearer_test.go +++ /dev/null @@ -1,199 +0,0 @@ -package service - -import ( - "crypto/rand" - "testing" - - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -type testBearerToken struct { - aclRules []byte - expEpoch uint64 - owner OwnerID - key []byte - sig []byte -} - -func (s testBearerToken) GetACLRules() []byte { - return s.aclRules -} - -func (s *testBearerToken) SetACLRules(v []byte) { - s.aclRules = v -} - -func (s testBearerToken) ExpirationEpoch() uint64 { - return s.expEpoch -} - -func (s *testBearerToken) SetExpirationEpoch(v uint64) { - s.expEpoch = v -} - -func (s testBearerToken) GetOwnerID() OwnerID { - return s.owner -} - -func (s *testBearerToken) SetOwnerID(v OwnerID) { - s.owner = v -} - -func (s testBearerToken) GetOwnerKey() []byte { - return s.key -} - -func (s *testBearerToken) SetOwnerKey(v []byte) { - s.key = v -} - -func (s testBearerToken) GetSignature() []byte { - return s.sig -} - -func (s *testBearerToken) SetSignature(v []byte) { - s.sig = v -} - -func TestBearerTokenMsgGettersSetters(t *testing.T) { - var tok BearerToken = new(testBearerToken) - - { // ACLRules - rules := []byte{1, 2, 3} - - tok.SetACLRules(rules) - - require.Equal(t, rules, tok.GetACLRules()) - } - - { // OwnerID - ownerID := OwnerID{} - _, err := rand.Read(ownerID[:]) - require.NoError(t, err) - - tok.SetOwnerID(ownerID) - - require.Equal(t, ownerID, tok.GetOwnerID()) - } - - { // ValidUntil - e := uint64(5) - - tok.SetExpirationEpoch(e) - - require.Equal(t, e, tok.ExpirationEpoch()) - } - - { // OwnerKey - key := make([]byte, 10) - _, err := rand.Read(key) - require.NoError(t, err) - - tok.SetOwnerKey(key) - - require.Equal(t, key, tok.GetOwnerKey()) - } - - { // Signature - sig := make([]byte, 10) - _, err := rand.Read(sig) - require.NoError(t, err) - - tok.SetSignature(sig) - - require.Equal(t, sig, tok.GetSignature()) - } -} - -func TestSignVerifyBearerToken(t *testing.T) { - var token BearerToken = new(testBearerToken) - - // create private key for signing - sk := test.DecodeKey(0) - pk := &sk.PublicKey - - rules := []byte{1, 2, 3} - token.SetACLRules(rules) - - ownerID := OwnerID{} - _, err := rand.Read(ownerID[:]) - require.NoError(t, err) - token.SetOwnerID(ownerID) - - fEpoch := uint64(2) - token.SetExpirationEpoch(fEpoch) - - signedToken := NewSignedBearerToken(token) - verifiedToken := NewVerifiedBearerToken(token) - - // sign and verify token - require.NoError(t, AddSignatureWithKey(sk, signedToken)) - require.NoError(t, VerifySignatureWithKey(pk, verifiedToken)) - - items := []struct { - corrupt func() - restore func() - }{ - { // ACLRules - corrupt: func() { - token.SetACLRules(append(rules, 1)) - }, - restore: func() { - token.SetACLRules(rules) - }, - }, - { // Owner ID - corrupt: func() { - ownerID[0]++ - token.SetOwnerID(ownerID) - }, - restore: func() { - ownerID[0]-- - token.SetOwnerID(ownerID) - }, - }, - { // Expiration epoch - corrupt: func() { - token.SetExpirationEpoch(fEpoch + 1) - }, - restore: func() { - token.SetExpirationEpoch(fEpoch) - }, - }, - } - - for _, v := range items { - v.corrupt() - require.Error(t, VerifySignatureWithKey(pk, verifiedToken)) - v.restore() - require.NoError(t, VerifySignatureWithKey(pk, verifiedToken)) - } -} - -func TestBearerTokenMsg_Setters(t *testing.T) { - s := new(BearerTokenMsg) - - aclRules := []byte{1, 2, 3} - s.SetACLRules(aclRules) - require.Equal(t, aclRules, s.GetACLRules()) - - validUntil := uint64(6) - s.SetValidUntil(validUntil) - require.Equal(t, validUntil, s.GetValidUntil()) - - s.SetExpirationEpoch(validUntil + 1) - require.Equal(t, validUntil+1, s.ExpirationEpoch()) - - ownerID := OwnerID{1, 2, 3} - s.SetOwnerID(ownerID) - require.Equal(t, ownerID, s.GetOwnerID()) - - ownerKey := []byte{4, 5, 6} - s.SetOwnerKey(ownerKey) - require.Equal(t, ownerKey, s.GetOwnerKey()) - - sig := []byte{7, 8, 9} - s.SetSignature(sig) - require.Equal(t, sig, s.GetSignature()) -} diff --git a/service/epoch.go b/service/epoch.go deleted file mode 100644 index 7a7a556..0000000 --- a/service/epoch.go +++ /dev/null @@ -1,11 +0,0 @@ -package service - -// SetEpoch is an Epoch field setter. -func (m *ResponseMetaHeader) SetEpoch(v uint64) { - m.Epoch = v -} - -// SetEpoch is an Epoch field setter. -func (m *RequestMetaHeader) SetEpoch(v uint64) { - m.Epoch = v -} diff --git a/service/epoch_test.go b/service/epoch_test.go deleted file mode 100644 index 47316c0..0000000 --- a/service/epoch_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package service - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestGetSetEpoch(t *testing.T) { - v := uint64(5) - - items := []EpochContainer{ - new(ResponseMetaHeader), - new(RequestMetaHeader), - } - - for _, item := range items { - item.SetEpoch(v) - require.Equal(t, v, item.GetEpoch()) - } -} diff --git a/service/errors.go b/service/errors.go deleted file mode 100644 index e1c4900..0000000 --- a/service/errors.go +++ /dev/null @@ -1,53 +0,0 @@ -package service - -import "github.com/nspcc-dev/neofs-api-go/internal" - -// ErrNilToken is returned by functions that expect -// a non-nil token argument, but received nil. -const ErrNilToken = internal.Error("token is nil") - -// ErrInvalidTTL means that the TTL value does not -// satisfy a specific criterion. -const ErrInvalidTTL = internal.Error("invalid TTL value") - -// ErrInvalidPublicKeyBytes means that the public key could not be unmarshaled. -const ErrInvalidPublicKeyBytes = internal.Error("cannot load public key") - -// ErrCannotFindOwner is raised when signatures empty in GetOwner. -const ErrCannotFindOwner = internal.Error("cannot find owner public key") - -// ErrWrongOwner is raised when passed OwnerID -// not equal to present PublicKey -const ErrWrongOwner = internal.Error("wrong owner") - -// ErrNilSignedDataSource returned by functions that expect a non-nil -// SignedDataSource, but received nil. -const ErrNilSignedDataSource = internal.Error("signed data source is nil") - -// ErrNilSignatureKeySource is returned by functions that expect a non-nil -// SignatureKeySource, but received nil. -const ErrNilSignatureKeySource = internal.Error("empty key-signature source") - -// ErrEmptyDataWithSignature is returned by functions that expect -// a non-nil DataWithSignature, but received nil. -const ErrEmptyDataWithSignature = internal.Error("empty data with signature") - -// ErrNegativeLength is returned by functions that received -// negative length for slice allocation. -const ErrNegativeLength = internal.Error("negative slice length") - -// ErrNilRequestSignedData is returned by functions that expect -// a non-nil RequestSignedData, but received nil. -const ErrNilRequestSignedData = internal.Error("request signed data is nil") - -// ErrNilRequestVerifyData is returned by functions that expect -// a non-nil RequestVerifyData, but received nil. -const ErrNilRequestVerifyData = internal.Error("request verification data is nil") - -// ErrNilSignedDataReader is returned by functions that expect -// a non-nil SignedDataReader, but received nil. -const ErrNilSignedDataReader = internal.Error("signed data reader is nil") - -// ErrNilSignKeyPairAccumulator is returned by functions that expect -// a non-nil SignKeyPairAccumulator, but received nil. -const ErrNilSignKeyPairAccumulator = internal.Error("signature-key pair accumulator is nil") diff --git a/service/meta.go b/service/meta.go deleted file mode 100644 index 557d076..0000000 --- a/service/meta.go +++ /dev/null @@ -1,131 +0,0 @@ -package service - -import ( - "io" -) - -type extHdrWrapper struct { - msg *RequestExtendedHeader_KV -} - -type extHdrSrcWrapper struct { - extHdrSrc ExtendedHeadersSource -} - -// CutMeta returns current value and sets RequestMetaHeader to empty value. -func (m *RequestMetaHeader) CutMeta() RequestMetaHeader { - cp := *m - m.Reset() - return cp -} - -// RestoreMeta sets current RequestMetaHeader to passed value. -func (m *RequestMetaHeader) RestoreMeta(v RequestMetaHeader) { - *m = v -} - -// ExtendedHeadersSignedData wraps passed ExtendedHeadersSource and returns SignedDataSource. -func ExtendedHeadersSignedData(headers ExtendedHeadersSource) SignedDataSource { - return &extHdrSrcWrapper{ - extHdrSrc: headers, - } -} - -// SignedData returns extended headers in a binary representation. -func (s extHdrSrcWrapper) SignedData() ([]byte, error) { - return SignedDataFromReader(s) -} - -// SignedDataSize returns the length of extended headers slice. -func (s extHdrSrcWrapper) SignedDataSize() (res int) { - if s.extHdrSrc != nil { - for _, h := range s.extHdrSrc.ExtendedHeaders() { - if h != nil { - res += len(h.Key()) + len(h.Value()) - } - } - } - - return -} - -// ReadSignedData copies a binary representation of the extended headers to passed buffer. -// -// If buffer length is less than required, io.ErrUnexpectedEOF returns. -func (s extHdrSrcWrapper) ReadSignedData(p []byte) (int, error) { - sz := s.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - if s.extHdrSrc != nil { - off := 0 - for _, h := range s.extHdrSrc.ExtendedHeaders() { - if h == nil { - continue - } - - off += copy(p[off:], []byte(h.Key())) - - off += copy(p[off:], []byte(h.Value())) - } - } - - return sz, nil -} - -// SetK is a K field setter. -func (m *RequestExtendedHeader_KV) SetK(v string) { - m.K = v -} - -// SetV is a V field setter. -func (m *RequestExtendedHeader_KV) SetV(v string) { - m.V = v -} - -// SetHeaders is a Headers field setter. -func (m *RequestExtendedHeader) SetHeaders(v []RequestExtendedHeader_KV) { - m.Headers = v -} - -func wrapExtendedHeaderKV(msg *RequestExtendedHeader_KV) extHdrWrapper { - return extHdrWrapper{ - msg: msg, - } -} - -// Key returns the result of K field getter. -// -// If message is nil, empty string returns. -func (m extHdrWrapper) Key() string { - if m.msg != nil { - return m.msg.GetK() - } - - return "" -} - -// Value returns the result of V field getter. -// -// If message is nil, empty string returns. -func (m extHdrWrapper) Value() string { - if m.msg != nil { - return m.msg.GetV() - } - - return "" -} - -// ExtendedHeaders composes ExtendedHeader list from the Headers field getter result. -func (m RequestExtendedHeader) ExtendedHeaders() []ExtendedHeader { - hs := m.GetHeaders() - - res := make([]ExtendedHeader, 0, len(hs)) - - for i := range hs { - res = append(res, wrapExtendedHeaderKV(&hs[i])) - } - - return res -} diff --git a/service/meta.pb.go b/service/meta.pb.go deleted file mode 100644 index 0d63077..0000000 --- a/service/meta.pb.go +++ /dev/null @@ -1,1118 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: service/meta.proto - -package service - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -// RequestMetaHeader contains information about request meta headers -// (should be embedded into message) -type RequestMetaHeader struct { - // TTL must be larger than zero, it decreased in every NeoFS Node - TTL uint32 `protobuf:"varint,1,opt,name=TTL,proto3" json:"TTL,omitempty"` - // Epoch for user can be empty, because node sets epoch to the actual value - Epoch uint64 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - // Version defines protocol version - // TODO: not used for now, should be implemented in future - Version uint32 `protobuf:"varint,3,opt,name=Version,proto3" json:"Version,omitempty"` - // Raw determines whether the request is raw or not - Raw bool `protobuf:"varint,4,opt,name=Raw,proto3" json:"Raw,omitempty"` - // ExtendedHeader carries extended headers of the request - RequestExtendedHeader `protobuf:"bytes,5,opt,name=ExtendedHeader,proto3,embedded=ExtendedHeader" json:"ExtendedHeader"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestMetaHeader) Reset() { *m = RequestMetaHeader{} } -func (m *RequestMetaHeader) String() string { return proto.CompactTextString(m) } -func (*RequestMetaHeader) ProtoMessage() {} -func (*RequestMetaHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_a638867e7b43457c, []int{0} -} -func (m *RequestMetaHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestMetaHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *RequestMetaHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestMetaHeader.Merge(m, src) -} -func (m *RequestMetaHeader) XXX_Size() int { - return m.Size() -} -func (m *RequestMetaHeader) XXX_DiscardUnknown() { - xxx_messageInfo_RequestMetaHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestMetaHeader proto.InternalMessageInfo - -func (m *RequestMetaHeader) GetTTL() uint32 { - if m != nil { - return m.TTL - } - return 0 -} - -func (m *RequestMetaHeader) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *RequestMetaHeader) GetVersion() uint32 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *RequestMetaHeader) GetRaw() bool { - if m != nil { - return m.Raw - } - return false -} - -// ResponseMetaHeader contains meta information based on request processing by server -// (should be embedded into message) -type ResponseMetaHeader struct { - // Current NeoFS epoch on server - Epoch uint64 `protobuf:"varint,1,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - // Version defines protocol version - // TODO: not used for now, should be implemented in future - Version uint32 `protobuf:"varint,2,opt,name=Version,proto3" json:"Version,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ResponseMetaHeader) Reset() { *m = ResponseMetaHeader{} } -func (m *ResponseMetaHeader) String() string { return proto.CompactTextString(m) } -func (*ResponseMetaHeader) ProtoMessage() {} -func (*ResponseMetaHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_a638867e7b43457c, []int{1} -} -func (m *ResponseMetaHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResponseMetaHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ResponseMetaHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResponseMetaHeader.Merge(m, src) -} -func (m *ResponseMetaHeader) XXX_Size() int { - return m.Size() -} -func (m *ResponseMetaHeader) XXX_DiscardUnknown() { - xxx_messageInfo_ResponseMetaHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_ResponseMetaHeader proto.InternalMessageInfo - -func (m *ResponseMetaHeader) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *ResponseMetaHeader) GetVersion() uint32 { - if m != nil { - return m.Version - } - return 0 -} - -// RequestExtendedHeader contains extended headers of request -type RequestExtendedHeader struct { - // Headers carries list of key-value headers - Headers []RequestExtendedHeader_KV `protobuf:"bytes,1,rep,name=Headers,proto3" json:"Headers"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestExtendedHeader) Reset() { *m = RequestExtendedHeader{} } -func (m *RequestExtendedHeader) String() string { return proto.CompactTextString(m) } -func (*RequestExtendedHeader) ProtoMessage() {} -func (*RequestExtendedHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_a638867e7b43457c, []int{2} -} -func (m *RequestExtendedHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestExtendedHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *RequestExtendedHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestExtendedHeader.Merge(m, src) -} -func (m *RequestExtendedHeader) XXX_Size() int { - return m.Size() -} -func (m *RequestExtendedHeader) XXX_DiscardUnknown() { - xxx_messageInfo_RequestExtendedHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestExtendedHeader proto.InternalMessageInfo - -func (m *RequestExtendedHeader) GetHeaders() []RequestExtendedHeader_KV { - if m != nil { - return m.Headers - } - return nil -} - -// KV contains string key-value pair -type RequestExtendedHeader_KV struct { - // K carries extended header key - K string `protobuf:"bytes,1,opt,name=K,proto3" json:"K,omitempty"` - // V carries extended header value - V string `protobuf:"bytes,2,opt,name=V,proto3" json:"V,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestExtendedHeader_KV) Reset() { *m = RequestExtendedHeader_KV{} } -func (m *RequestExtendedHeader_KV) String() string { return proto.CompactTextString(m) } -func (*RequestExtendedHeader_KV) ProtoMessage() {} -func (*RequestExtendedHeader_KV) Descriptor() ([]byte, []int) { - return fileDescriptor_a638867e7b43457c, []int{2, 0} -} -func (m *RequestExtendedHeader_KV) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestExtendedHeader_KV) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *RequestExtendedHeader_KV) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestExtendedHeader_KV.Merge(m, src) -} -func (m *RequestExtendedHeader_KV) XXX_Size() int { - return m.Size() -} -func (m *RequestExtendedHeader_KV) XXX_DiscardUnknown() { - xxx_messageInfo_RequestExtendedHeader_KV.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestExtendedHeader_KV proto.InternalMessageInfo - -func (m *RequestExtendedHeader_KV) GetK() string { - if m != nil { - return m.K - } - return "" -} - -func (m *RequestExtendedHeader_KV) GetV() string { - if m != nil { - return m.V - } - return "" -} - -func init() { - proto.RegisterType((*RequestMetaHeader)(nil), "service.RequestMetaHeader") - proto.RegisterType((*ResponseMetaHeader)(nil), "service.ResponseMetaHeader") - proto.RegisterType((*RequestExtendedHeader)(nil), "service.RequestExtendedHeader") - proto.RegisterType((*RequestExtendedHeader_KV)(nil), "service.RequestExtendedHeader.KV") -} - -func init() { proto.RegisterFile("service/meta.proto", fileDescriptor_a638867e7b43457c) } - -var fileDescriptor_a638867e7b43457c = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xb1, 0x8e, 0xda, 0x40, - 0x10, 0x86, 0x19, 0x03, 0x01, 0x96, 0x24, 0x0a, 0xab, 0x44, 0xb2, 0x28, 0x8c, 0x43, 0xe5, 0x14, - 0xb6, 0x25, 0xf2, 0x04, 0xa0, 0x10, 0x25, 0x72, 0x12, 0xa1, 0x05, 0xb9, 0x48, 0x67, 0xec, 0xc1, - 0xb8, 0xc0, 0xeb, 0x78, 0x0d, 0x49, 0x91, 0x07, 0xc9, 0x33, 0xe4, 0x0d, 0xee, 0x0d, 0x28, 0x29, - 0xaf, 0x42, 0x27, 0xdf, 0x8b, 0x9c, 0xbc, 0x36, 0x27, 0x38, 0xdd, 0x5d, 0xf7, 0x7f, 0xb3, 0x33, - 0x3b, 0x9f, 0x34, 0x84, 0x0a, 0x4c, 0x77, 0x91, 0x8f, 0xf6, 0x06, 0x33, 0xcf, 0x4a, 0x52, 0x9e, - 0x71, 0xda, 0xaa, 0x6a, 0x7d, 0x33, 0x8c, 0xb2, 0xf5, 0x76, 0x69, 0xf9, 0x7c, 0x63, 0x87, 0x3c, - 0xe4, 0xb6, 0x7c, 0x5f, 0x6e, 0x57, 0x92, 0x24, 0xc8, 0x54, 0xce, 0x0d, 0xaf, 0x80, 0xf4, 0x18, - 0xfe, 0xda, 0xa2, 0xc8, 0xbe, 0x63, 0xe6, 0x7d, 0x41, 0x2f, 0xc0, 0x94, 0xbe, 0x21, 0xf5, 0xc5, - 0xe2, 0x9b, 0x0a, 0x3a, 0x18, 0xaf, 0x58, 0x11, 0xe9, 0x5b, 0xd2, 0x9c, 0x26, 0xdc, 0x5f, 0xab, - 0x8a, 0x0e, 0x46, 0x83, 0x95, 0x40, 0x55, 0xd2, 0x72, 0x31, 0x15, 0x11, 0x8f, 0xd5, 0xba, 0xec, - 0x3d, 0x61, 0xf1, 0x03, 0xf3, 0x7e, 0xab, 0x0d, 0x1d, 0x8c, 0x36, 0x2b, 0x22, 0x9d, 0x91, 0xd7, - 0xd3, 0x3f, 0x19, 0xc6, 0x01, 0x06, 0xe5, 0x16, 0xb5, 0xa9, 0x83, 0xd1, 0x1d, 0x69, 0x56, 0xa5, - 0x6e, 0x55, 0x1e, 0x97, 0x5d, 0x93, 0xf6, 0xfe, 0x38, 0xa8, 0x1d, 0x8e, 0x03, 0x60, 0x0f, 0xe6, - 0x87, 0x9f, 0x08, 0x65, 0x28, 0x12, 0x1e, 0x0b, 0x3c, 0x73, 0xbf, 0x37, 0x85, 0x27, 0x4c, 0x95, - 0x0b, 0xd3, 0xe1, 0x5f, 0xf2, 0xee, 0xd1, 0xc5, 0x74, 0x4c, 0x5a, 0x65, 0x12, 0x2a, 0xe8, 0x75, - 0xa3, 0x3b, 0x7a, 0xff, 0xbc, 0xa9, 0xe5, 0xb8, 0x93, 0x46, 0x21, 0xcb, 0x4e, 0x73, 0x7d, 0x9d, - 0x28, 0x8e, 0x4b, 0x5f, 0x12, 0x70, 0xa4, 0x4d, 0x87, 0x81, 0x53, 0x90, 0x2b, 0x1d, 0x3a, 0x0c, - 0xdc, 0xc9, 0x7c, 0x9f, 0x6b, 0x70, 0xc8, 0x35, 0xb8, 0xce, 0x35, 0xb8, 0xc9, 0x35, 0xf8, 0x77, - 0xab, 0xd5, 0x7e, 0x7e, 0x38, 0x3b, 0x62, 0x2c, 0x12, 0xdf, 0x37, 0x03, 0xdc, 0xd9, 0x31, 0xf2, - 0x95, 0x30, 0xbd, 0x24, 0x32, 0x43, 0x6e, 0x57, 0x2a, 0xff, 0x95, 0xde, 0x0f, 0xe4, 0x9f, 0xe7, - 0xd6, 0x78, 0xf6, 0xd5, 0x9a, 0x97, 0xb5, 0xe5, 0x0b, 0x79, 0xdb, 0x8f, 0x77, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xf3, 0xf7, 0x0a, 0xb8, 0x29, 0x02, 0x00, 0x00, -} - -func (m *RequestMetaHeader) 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 *RequestMetaHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestMetaHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestExtendedHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMeta(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.Raw { - i-- - if m.Raw { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if m.Version != 0 { - i = encodeVarintMeta(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x18 - } - if m.Epoch != 0 { - i = encodeVarintMeta(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x10 - } - if m.TTL != 0 { - i = encodeVarintMeta(dAtA, i, uint64(m.TTL)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ResponseMetaHeader) 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 *ResponseMetaHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResponseMetaHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Version != 0 { - i = encodeVarintMeta(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x10 - } - if m.Epoch != 0 { - i = encodeVarintMeta(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *RequestExtendedHeader) 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 *RequestExtendedHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestExtendedHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Headers) > 0 { - for iNdEx := len(m.Headers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Headers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMeta(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *RequestExtendedHeader_KV) 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 *RequestExtendedHeader_KV) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestExtendedHeader_KV) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.V) > 0 { - i -= len(m.V) - copy(dAtA[i:], m.V) - i = encodeVarintMeta(dAtA, i, uint64(len(m.V))) - i-- - dAtA[i] = 0x12 - } - if len(m.K) > 0 { - i -= len(m.K) - copy(dAtA[i:], m.K) - i = encodeVarintMeta(dAtA, i, uint64(len(m.K))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintMeta(dAtA []byte, offset int, v uint64) int { - offset -= sovMeta(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *RequestMetaHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TTL != 0 { - n += 1 + sovMeta(uint64(m.TTL)) - } - if m.Epoch != 0 { - n += 1 + sovMeta(uint64(m.Epoch)) - } - if m.Version != 0 { - n += 1 + sovMeta(uint64(m.Version)) - } - if m.Raw { - n += 2 - } - l = m.RequestExtendedHeader.Size() - n += 1 + l + sovMeta(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ResponseMetaHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != 0 { - n += 1 + sovMeta(uint64(m.Epoch)) - } - if m.Version != 0 { - n += 1 + sovMeta(uint64(m.Version)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RequestExtendedHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Headers) > 0 { - for _, e := range m.Headers { - l = e.Size() - n += 1 + l + sovMeta(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RequestExtendedHeader_KV) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.K) - if l > 0 { - n += 1 + l + sovMeta(uint64(l)) - } - l = len(m.V) - if l > 0 { - n += 1 + l + sovMeta(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovMeta(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMeta(x uint64) (n int) { - return sovMeta(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RequestMetaHeader) 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 ErrIntOverflowMeta - } - 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: RequestMetaHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RequestMetaHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType) - } - m.TTL = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TTL |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Raw", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Raw = bool(v != 0) - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestExtendedHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMeta - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMeta - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestExtendedHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMeta(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResponseMetaHeader) 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 ErrIntOverflowMeta - } - 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: ResponseMetaHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResponseMetaHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMeta(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RequestExtendedHeader) 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 ErrIntOverflowMeta - } - 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: RequestExtendedHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RequestExtendedHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMeta - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMeta - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Headers = append(m.Headers, RequestExtendedHeader_KV{}) - if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMeta(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RequestExtendedHeader_KV) 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 ErrIntOverflowMeta - } - 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: KV: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KV: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field K", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - 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 ErrInvalidLengthMeta - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMeta - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.K = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field V", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMeta - } - 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 ErrInvalidLengthMeta - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMeta - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.V = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMeta(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMeta - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMeta(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, ErrIntOverflowMeta - } - 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, ErrIntOverflowMeta - } - 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, ErrIntOverflowMeta - } - 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, ErrInvalidLengthMeta - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMeta - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMeta - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMeta = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMeta = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMeta = fmt.Errorf("proto: unexpected end of group") -) diff --git a/service/meta.proto b/service/meta.proto deleted file mode 100644 index 8171980..0000000 --- a/service/meta.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto3"; -package service; -option go_package = "github.com/nspcc-dev/neofs-api-go/service"; -option csharp_namespace = "NeoFS.API.Service"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// RequestMetaHeader contains information about request meta headers -// (should be embedded into message) -message RequestMetaHeader { - // TTL must be larger than zero, it decreased in every NeoFS Node - uint32 TTL = 1; - // Epoch for user can be empty, because node sets epoch to the actual value - uint64 Epoch = 2; - // Version defines protocol version - // TODO: not used for now, should be implemented in future - uint32 Version = 3; - // Raw determines whether the request is raw or not - bool Raw = 4; - // ExtendedHeader carries extended headers of the request - RequestExtendedHeader ExtendedHeader = 5 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// ResponseMetaHeader contains meta information based on request processing by server -// (should be embedded into message) -message ResponseMetaHeader { - // Current NeoFS epoch on server - uint64 Epoch = 1; - // Version defines protocol version - // TODO: not used for now, should be implemented in future - uint32 Version = 2; -} - -// RequestExtendedHeader contains extended headers of request -message RequestExtendedHeader { - // KV contains string key-value pair - message KV { - // K carries extended header key - string K = 1; - - // V carries extended header value - string V = 2; - } - - // Headers carries list of key-value headers - repeated KV Headers = 1 [(gogoproto.nullable) = false]; -} diff --git a/service/meta_test.go b/service/meta_test.go deleted file mode 100644 index 9e9c012..0000000 --- a/service/meta_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package service - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestCutRestoreMeta(t *testing.T) { - items := []func() SeizedMetaHeaderContainer{ - func() SeizedMetaHeaderContainer { - m := new(RequestMetaHeader) - m.SetEpoch(1) - return m - }, - } - - for _, item := range items { - v1 := item() - m1 := v1.CutMeta() - v1.RestoreMeta(m1) - - require.Equal(t, item(), v1) - } -} - -func TestRequestExtendedHeader_KV_Setters(t *testing.T) { - s := new(RequestExtendedHeader_KV) - - key := "key" - s.SetK(key) - require.Equal(t, key, s.GetK()) - - val := "val" - s.SetV(val) - require.Equal(t, val, s.GetV()) -} - -func TestRequestExtendedHeader_SetHeaders(t *testing.T) { - s := new(RequestExtendedHeader) - - hdr := RequestExtendedHeader_KV{} - hdr.SetK("key") - hdr.SetV("val") - - hdrs := []RequestExtendedHeader_KV{ - hdr, - } - - s.SetHeaders(hdrs) - - require.Equal(t, hdrs, s.GetHeaders()) -} - -func TestExtHdrWrapper(t *testing.T) { - s := wrapExtendedHeaderKV(nil) - require.Empty(t, s.Key()) - require.Empty(t, s.Value()) - - msg := new(RequestExtendedHeader_KV) - s = wrapExtendedHeaderKV(msg) - - key := "key" - msg.SetK(key) - require.Equal(t, key, s.Key()) - - val := "val" - msg.SetV(val) - require.Equal(t, val, s.Value()) -} - -func TestRequestExtendedHeader_ExtendedHeaders(t *testing.T) { - var ( - k1, v1 = "key1", "value1" - k2, v2 = "key2", "value2" - h1 = new(RequestExtendedHeader_KV) - h2 = new(RequestExtendedHeader_KV) - ) - - h1.SetK(k1) - h1.SetV(v1) - - h2.SetK(k2) - h2.SetV(v2) - - s := new(RequestExtendedHeader) - s.SetHeaders([]RequestExtendedHeader_KV{ - *h1, *h2, - }) - - xHdrs := s.ExtendedHeaders() - require.Len(t, xHdrs, 2) - - require.Equal(t, k1, xHdrs[0].Key()) - require.Equal(t, v1, xHdrs[0].Value()) - - require.Equal(t, k2, xHdrs[1].Key()) - require.Equal(t, v2, xHdrs[1].Value()) -} diff --git a/service/raw.go b/service/raw.go deleted file mode 100644 index 0bb4b27..0000000 --- a/service/raw.go +++ /dev/null @@ -1,6 +0,0 @@ -package service - -// SetRaw is a Raw field setter. -func (m *RequestMetaHeader) SetRaw(raw bool) { - m.Raw = raw -} diff --git a/service/raw_test.go b/service/raw_test.go deleted file mode 100644 index ad595ed..0000000 --- a/service/raw_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package service - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestGetSetRaw(t *testing.T) { - items := []RawContainer{ - new(RequestMetaHeader), - } - - for _, item := range items { - // init with false - item.SetRaw(false) - - item.SetRaw(true) - require.True(t, item.GetRaw()) - - item.SetRaw(false) - require.False(t, item.GetRaw()) - } -} diff --git a/service/role.go b/service/role.go deleted file mode 100644 index 64a0074..0000000 --- a/service/role.go +++ /dev/null @@ -1,37 +0,0 @@ -package service - -import "encoding/binary" - -const ( - _ NodeRole = iota - // InnerRingNode that work like IR node. - InnerRingNode - // StorageNode that work like a storage node. - StorageNode -) - -// String is method, that represent NodeRole as string. -func (nt NodeRole) String() string { - switch nt { - case InnerRingNode: - return "InnerRingNode" - case StorageNode: - return "StorageNode" - default: - return "Unknown" - } -} - -// Size returns the size necessary for a binary representation of the NodeRole. -func (nt NodeRole) Size() int { - return 4 -} - -// Bytes returns a binary representation of the NodeRole. -func (nt NodeRole) Bytes() []byte { - data := make([]byte, nt.Size()) - - binary.BigEndian.PutUint32(data, uint32(nt)) - - return data -} diff --git a/service/role_test.go b/service/role_test.go deleted file mode 100644 index 01dbee2..0000000 --- a/service/role_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package service - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestNodeRole_String(t *testing.T) { - tests := []struct { - nt NodeRole - want string - }{ - {want: "Unknown"}, - {nt: StorageNode, want: "StorageNode"}, - {nt: InnerRingNode, want: "InnerRingNode"}, - } - for _, tt := range tests { - t.Run(tt.want, func(t *testing.T) { - require.Equal(t, tt.want, tt.nt.String()) - }) - } -} diff --git a/service/sign.go b/service/sign.go deleted file mode 100644 index 796a4cd..0000000 --- a/service/sign.go +++ /dev/null @@ -1,404 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - "io" - "sync" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/pkg/errors" -) - -type keySign struct { - key *ecdsa.PublicKey - sign []byte -} - -type signSourceGroup struct { - SignKeyPairSource - SignKeyPairAccumulator - - sources []SignedDataSource -} - -type signReadersGroup struct { - SignKeyPairSource - SignKeyPairAccumulator - - readers []SignedDataReader -} - -var bytesPool = sync.Pool{ - New: func() interface{} { - return make([]byte, 5<<20) - }, -} - -// GetSignature is a sign field getter. -func (s keySign) GetSignature() []byte { - return s.sign -} - -// GetPublicKey is a key field getter, -func (s keySign) GetPublicKey() *ecdsa.PublicKey { - return s.key -} - -// Unites passed key with signature and returns SignKeyPair interface. -func newSignatureKeyPair(key *ecdsa.PublicKey, sign []byte) SignKeyPair { - return &keySign{ - key: key, - sign: sign, - } -} - -// Returns data from DataSignatureAccumulator for signature creation/verification. -// -// If passed DataSignatureAccumulator provides a SignedDataReader interface, data for signature is obtained -// using this interface for optimization. In this case, it is understood that reading into the slice D -// that the method DataForSignature returns does not change D. -// -// If returned length of data is negative, ErrNegativeLength returns. -func dataForSignature(src SignedDataSource) ([]byte, error) { - if src == nil { - return nil, ErrNilSignedDataSource - } - - r, ok := src.(SignedDataReader) - if !ok { - return src.SignedData() - } - - buf := bytesPool.Get().([]byte) - - if size := r.SignedDataSize(); size < 0 { - return nil, ErrNegativeLength - } else if size <= cap(buf) { - buf = buf[:size] - } else { - buf = make([]byte, size) - } - - n, err := r.ReadSignedData(buf) - if err != nil { - return nil, err - } - - return buf[:n], nil - -} - -// DataSignature returns the signature of data obtained using the private key. -// -// If passed data container is nil, ErrNilSignedDataSource returns. -// If passed private key is nil, crypto.ErrEmptyPrivateKey returns. -// If the data container or the signature function returns an error, it is returned directly. -func DataSignature(key *ecdsa.PrivateKey, src SignedDataSource) ([]byte, error) { - if key == nil { - return nil, crypto.ErrEmptyPrivateKey - } - - data, err := dataForSignature(src) - if err != nil { - return nil, err - } - defer bytesPool.Put(data) - - return crypto.Sign(key, data) -} - -// AddSignatureWithKey calculates the data signature and adds it to accumulator with public key. -// -// Any change of data provoke signature breakdown. -// -// Returns signing errors only. -func AddSignatureWithKey(key *ecdsa.PrivateKey, v DataWithSignKeyAccumulator) error { - sign, err := DataSignature(key, v) - if err != nil { - return err - } - - v.AddSignKey(sign, &key.PublicKey) - - return nil -} - -// Checks passed key-signature pairs for data from the passed container. -// -// If passed key-signatures pair set is empty, nil returns immediately. -func verifySignatures(src SignedDataSource, items ...SignKeyPair) error { - if len(items) <= 0 { - return nil - } - - data, err := dataForSignature(src) - if err != nil { - return err - } - defer bytesPool.Put(data) - - for i := range items { - if i > 0 { - // add previous key bytes to the signed message - - signKeyDataSrc := SignKeyPairsSignedData(items[i-1]) - - signKeyData, err := signKeyDataSrc.SignedData() - if err != nil { - return errors.Wrapf(err, "could not get signed data of key-signature #%d", i) - } - - data = append(data, signKeyData...) - } - - if err := crypto.Verify( - items[i].GetPublicKey(), - data, - items[i].GetSignature(), - ); err != nil { - return err - } - } - - return nil -} - -// VerifySignatures checks passed key-signature pairs for data from the passed container. -// -// If passed data source is nil, ErrNilSignedDataSource returns. -// If check data is not ready, corresponding error returns. -// If at least one of the pairs is invalid, an error returns. -func VerifySignatures(src SignedDataSource, items ...SignKeyPair) error { - return verifySignatures(src, items...) -} - -// VerifyAccumulatedSignatures checks if accumulated key-signature pairs are valid. -// -// Behaves like VerifySignatures. -// If passed key-signature source is empty, ErrNilSignatureKeySource returns. -func VerifyAccumulatedSignatures(src DataWithSignKeySource) error { - if src == nil { - return ErrNilSignatureKeySource - } - - return verifySignatures(src, src.GetSignKeyPairs()...) -} - -// VerifySignatureWithKey checks data signature from the passed container with passed key. -// -// If passed data with signature is nil, ErrEmptyDataWithSignature returns. -// If passed key is nil, crypto.ErrEmptyPublicKey returns. -// A non-nil error returns if and only if the signature does not pass verification. -func VerifySignatureWithKey(key *ecdsa.PublicKey, src DataWithSignature) error { - if src == nil { - return ErrEmptyDataWithSignature - } else if key == nil { - return crypto.ErrEmptyPublicKey - } - - return verifySignatures( - src, - newSignatureKeyPair( - key, - src.GetSignature(), - ), - ) -} - -// SignRequestData calculates request data signature and adds it to accumulator. -// -// Any change of request data provoke signature breakdown. -// -// If passed private key is nil, crypto.ErrEmptyPrivateKey returns. -// If passed RequestSignedData is nil, ErrNilRequestSignedData returns. -func SignRequestData(key *ecdsa.PrivateKey, src RequestSignedData) error { - if src == nil { - return ErrNilRequestSignedData - } - - sigSrc, err := GroupSignedPayloads( - src, - src, - NewSignedSessionToken( - src.GetSessionToken(), - ), - NewSignedBearerToken( - src.GetBearerToken(), - ), - ExtendedHeadersSignedData(src), - SignKeyPairsSignedData(src.GetSignKeyPairs()...), - ) - if err != nil { - return err - } - - return AddSignatureWithKey(key, sigSrc) -} - -// VerifyRequestData checks if accumulated key-signature pairs of data with token are valid. -// -// If passed RequestVerifyData is nil, ErrNilRequestVerifyData returns. -func VerifyRequestData(src RequestVerifyData) error { - if src == nil { - return ErrNilRequestVerifyData - } - - verSrc, err := GroupVerifyPayloads( - src, - src, - NewVerifiedSessionToken( - src.GetSessionToken(), - ), - NewVerifiedBearerToken( - src.GetBearerToken(), - ), - ExtendedHeadersSignedData(src), - ) - if err != nil { - return err - } - - return VerifyAccumulatedSignatures(verSrc) -} - -// SignedData returns payload bytes concatenation from all sources keeping order. -func (s signSourceGroup) SignedData() ([]byte, error) { - chunks := make([][]byte, 0, len(s.sources)) - sz := 0 - - for i := range s.sources { - data, err := s.sources[i].SignedData() - if err != nil { - return nil, errors.Wrapf(err, "could not get signed payload of element #%d", i) - } - - chunks = append(chunks, data) - - sz += len(data) - } - - res := make([]byte, sz) - off := 0 - - for i := range chunks { - off += copy(res[off:], chunks[i]) - } - - return res, nil -} - -// SignedData returns payload bytes concatenation from all readers. -func (s signReadersGroup) SignedData() ([]byte, error) { - return SignedDataFromReader(s) -} - -// SignedDataSize returns the sum of sizes of all readers. -func (s signReadersGroup) SignedDataSize() (sz int) { - for i := range s.readers { - sz += s.readers[i].SignedDataSize() - } - - return -} - -// ReadSignedData reads data from all readers to passed buffer keeping order. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (s signReadersGroup) ReadSignedData(p []byte) (int, error) { - sz := s.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - off := 0 - - for i := range s.readers { - n, err := s.readers[i].ReadSignedData(p[off:]) - off += n - if err != nil { - return off, errors.Wrapf(err, "could not read signed payload of element #%d", i) - } - } - - return off, nil -} - -// GroupSignedPayloads groups SignKeyPairAccumulator and SignedDataSource list to DataWithSignKeyAccumulator. -// -// If passed SignKeyPairAccumulator is nil, ErrNilSignKeyPairAccumulator returns. -// -// Signed payload of the result is a concatenation of payloads of list elements keeping order. -// Nil elements in list are ignored. -// -// If all elements implement SignedDataReader, result implements it too. -func GroupSignedPayloads(acc SignKeyPairAccumulator, sources ...SignedDataSource) (DataWithSignKeyAccumulator, error) { - if acc == nil { - return nil, ErrNilSignKeyPairAccumulator - } - - return groupPayloads(acc, nil, sources...), nil -} - -// GroupVerifyPayloads groups SignKeyPairSource and SignedDataSource list to DataWithSignKeySource. -// -// If passed SignKeyPairSource is nil, ErrNilSignatureKeySource returns. -// -// Signed payload of the result is a concatenation of payloads of list elements keeping order. -// Nil elements in list are ignored. -// -// If all elements implement SignedDataReader, result implements it too. -func GroupVerifyPayloads(src SignKeyPairSource, sources ...SignedDataSource) (DataWithSignKeySource, error) { - if src == nil { - return nil, ErrNilSignatureKeySource - } - - return groupPayloads(nil, src, sources...), nil -} - -func groupPayloads(acc SignKeyPairAccumulator, src SignKeyPairSource, sources ...SignedDataSource) interface { - SignedDataSource - SignKeyPairSource - SignKeyPairAccumulator -} { - var allReaders bool - - for i := range sources { - if sources[i] == nil { - continue - } else if _, allReaders = sources[i].(SignedDataReader); !allReaders { - break - } - } - - if !allReaders { - res := &signSourceGroup{ - SignKeyPairSource: src, - SignKeyPairAccumulator: acc, - - sources: make([]SignedDataSource, 0, len(sources)), - } - - for i := range sources { - if sources[i] != nil { - res.sources = append(res.sources, sources[i]) - } - } - - return res - } - - res := &signReadersGroup{ - SignKeyPairSource: src, - SignKeyPairAccumulator: acc, - - readers: make([]SignedDataReader, 0, len(sources)), - } - - for i := range sources { - if sources[i] != nil { - res.readers = append(res.readers, sources[i].(SignedDataReader)) - } - } - - return res -} diff --git a/service/sign_test.go b/service/sign_test.go deleted file mode 100644 index 3c54e8c..0000000 --- a/service/sign_test.go +++ /dev/null @@ -1,400 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - "crypto/rand" - "errors" - "io" - "testing" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -type testSignedDataSrc struct { - err error - data []byte - token SessionToken - - bearer BearerToken - - extHdrs []ExtendedHeader - - signKeys []SignKeyPair -} - -type testSignedDataReader struct { - *testSignedDataSrc -} - -func (s testSignedDataSrc) GetSignature() []byte { - if len(s.signKeys) > 0 { - return s.signKeys[0].GetSignature() - } - - return nil -} - -func (s testSignedDataSrc) GetSignKeyPairs() []SignKeyPair { - return s.signKeys -} - -func (s testSignedDataSrc) SignedData() ([]byte, error) { - return s.data, s.err -} - -func (s *testSignedDataSrc) AddSignKey(sig []byte, key *ecdsa.PublicKey) { - s.signKeys = append(s.signKeys, - newSignatureKeyPair(key, sig), - ) -} - -func testData(t *testing.T, sz int) []byte { - d := make([]byte, sz) - _, err := rand.Read(d) - require.NoError(t, err) - return d -} - -func (s testSignedDataSrc) GetSessionToken() SessionToken { - return s.token -} - -func (s testSignedDataSrc) GetBearerToken() BearerToken { - return s.bearer -} - -func (s testSignedDataSrc) ExtendedHeaders() []ExtendedHeader { - return s.extHdrs -} - -func (s testSignedDataReader) SignedDataSize() int { - return len(s.data) -} - -func (s testSignedDataReader) ReadSignedData(buf []byte) (int, error) { - if s.err != nil { - return 0, s.err - } - - var err error - if len(buf) < len(s.data) { - err = io.ErrUnexpectedEOF - } - return copy(buf, s.data), err -} - -func TestDataSignature(t *testing.T) { - var err error - - // nil private key - _, err = DataSignature(nil, nil) - require.EqualError(t, err, crypto.ErrEmptyPrivateKey.Error()) - - // create test private key - sk := test.DecodeKey(0) - - // nil private key - _, err = DataSignature(sk, nil) - require.EqualError(t, err, ErrNilSignedDataSource.Error()) - - t.Run("common signed data source", func(t *testing.T) { - // create test data source - src := &testSignedDataSrc{ - data: testData(t, 10), - } - - // create custom error for data source - src.err = errors.New("test error for data source") - - _, err = DataSignature(sk, src) - require.EqualError(t, err, src.err.Error()) - - // reset error to nil - src.err = nil - - // calculate data signature - sig, err := DataSignature(sk, src) - require.NoError(t, err) - - // ascertain that the signature passes verification - require.NoError(t, crypto.Verify(&sk.PublicKey, src.data, sig)) - }) - - t.Run("signed data reader", func(t *testing.T) { - // create test signed data reader - src := &testSignedDataSrc{ - data: testData(t, 10), - } - - // create custom error for signed data reader - src.err = errors.New("test error for signed data reader") - - sig, err := DataSignature(sk, src) - require.EqualError(t, err, src.err.Error()) - - // reset error to nil - src.err = nil - - // calculate data signature - sig, err = DataSignature(sk, src) - require.NoError(t, err) - - // ascertain that the signature passes verification - require.NoError(t, crypto.Verify(&sk.PublicKey, src.data, sig)) - }) -} - -func TestAddSignatureWithKey(t *testing.T) { - require.NoError(t, - AddSignatureWithKey( - test.DecodeKey(0), - &testSignedDataSrc{ - data: testData(t, 10), - }, - ), - ) -} - -func TestVerifySignatures(t *testing.T) { - // empty signatures - require.NoError(t, VerifySignatures(nil)) - - // create test signature source - src := &testSignedDataSrc{ - data: testData(t, 10), - } - - // create private key for test - sk := test.DecodeKey(0) - - // calculate a signature of the data - sig, err := crypto.Sign(sk, src.data) - require.NoError(t, err) - - // ascertain that verification is passed - require.NoError(t, - VerifySignatures( - src, - newSignatureKeyPair(&sk.PublicKey, sig), - ), - ) - - // break the signature - sig[0]++ - - require.Error(t, - VerifySignatures( - src, - newSignatureKeyPair(&sk.PublicKey, sig), - ), - ) - - // restore the signature - sig[0]-- - - // empty data source - require.EqualError(t, - VerifySignatures(nil, nil), - ErrNilSignedDataSource.Error(), - ) - -} - -func TestVerifyAccumulatedSignatures(t *testing.T) { - // nil signature source - require.EqualError(t, - VerifyAccumulatedSignatures(nil), - ErrNilSignatureKeySource.Error(), - ) - - // create test private key - sk := test.DecodeKey(0) - - signKey := new(RequestVerificationHeader_Signature) - signKey.Peer = crypto.MarshalPublicKey(&sk.PublicKey) - - // create signature source - src := &testSignedDataSrc{ - data: testData(t, 10), - - signKeys: []SignKeyPair{signKey}, - } - - var err error - - // calculate a signature - signKey.Sign, err = crypto.Sign(sk, src.data) - require.NoError(t, err) - - // ascertain that verification is passed - require.NoError(t, VerifyAccumulatedSignatures(src)) - - // break the signature - signKey.Sign[0]++ - - // ascertain that verification is failed - require.Error(t, VerifyAccumulatedSignatures(src)) -} - -func TestVerifySignatureWithKey(t *testing.T) { - // nil signature source - require.EqualError(t, - VerifySignatureWithKey(nil, nil), - ErrEmptyDataWithSignature.Error(), - ) - - signKey := new(RequestVerificationHeader_Signature) - - // create test signature source - src := &testSignedDataSrc{ - data: testData(t, 10), - - signKeys: []SignKeyPair{signKey}, - } - - // nil public key - require.EqualError(t, - VerifySignatureWithKey(nil, src), - crypto.ErrEmptyPublicKey.Error(), - ) - - // create test private key - sk := test.DecodeKey(0) - - var err error - - // calculate a signature - signKey.Sign, err = crypto.Sign(sk, src.data) - require.NoError(t, err) - - // ascertain that verification is passed - require.NoError(t, VerifySignatureWithKey(&sk.PublicKey, src)) - - // break the signature - signKey.Sign[0]++ - - // ascertain that verification is failed - require.Error(t, VerifySignatureWithKey(&sk.PublicKey, src)) -} - -func TestSignVerifyRequestData(t *testing.T) { - // sign with empty RequestSignedData - require.EqualError(t, - SignRequestData(nil, nil), - ErrNilRequestSignedData.Error(), - ) - - // verify with empty RequestVerifyData - require.EqualError(t, - VerifyRequestData(nil), - ErrNilRequestVerifyData.Error(), - ) - - // create test session token - var ( - token = new(Token) - initVerb = Token_Info_Verb(1) - - bearer = new(BearerTokenMsg) - bearerEpoch = uint64(8) - - extHdrKey = "key" - extHdr = new(RequestExtendedHeader_KV) - ) - - token.SetVerb(initVerb) - - bearer.SetExpirationEpoch(bearerEpoch) - - extHdr.SetK(extHdrKey) - - // create test data with token - src := &testSignedDataSrc{ - data: testData(t, 10), - token: token, - - bearer: bearer, - - extHdrs: []ExtendedHeader{ - wrapExtendedHeaderKV(extHdr), - }, - } - - // create test private key - sk := test.DecodeKey(0) - - // sign with private key - require.NoError(t, SignRequestData(sk, src)) - - // ascertain that verification is passed - require.NoError(t, VerifyRequestData(src)) - - // break the data - src.data[0]++ - - // ascertain that verification is failed - require.Error(t, VerifyRequestData(src)) - - // restore the data - src.data[0]-- - - // break the token - token.SetVerb(initVerb + 1) - - // ascertain that verification is failed - require.Error(t, VerifyRequestData(src)) - - // restore the token - token.SetVerb(initVerb) - - // ascertain that verification is passed - require.NoError(t, VerifyRequestData(src)) - - // break the Bearer token - bearer.SetExpirationEpoch(bearerEpoch + 1) - - // ascertain that verification is failed - require.Error(t, VerifyRequestData(src)) - - // restore the Bearer token - bearer.SetExpirationEpoch(bearerEpoch) - - // ascertain that verification is passed - require.NoError(t, VerifyRequestData(src)) - - // break the extended header - extHdr.SetK(extHdrKey + "1") - - // ascertain that verification is failed - require.Error(t, VerifyRequestData(src)) - - // restore the extended header - extHdr.SetK(extHdrKey) - - // ascertain that verification is passed - require.NoError(t, VerifyRequestData(src)) - - // wrap to data reader - rdr := &testSignedDataReader{ - testSignedDataSrc: src, - } - - // sign with private key - require.NoError(t, SignRequestData(sk, rdr)) - - // ascertain that verification is passed - require.NoError(t, VerifyRequestData(rdr)) - - if len(rdr.GetSignKeyPairs()) < 2 { - // add one more signature - require.NoError(t, SignRequestData(test.DecodeKey(1), rdr)) - } - - // change key-signature order - rdr.signKeys[0], rdr.signKeys[1] = rdr.signKeys[1], rdr.signKeys[0] - - // ascertain that verification is failed - require.Error(t, VerifyRequestData(src)) -} diff --git a/service/token.go b/service/token.go deleted file mode 100644 index 638539f..0000000 --- a/service/token.go +++ /dev/null @@ -1,265 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - "encoding/binary" - "io" - - "github.com/nspcc-dev/neofs-api-go/refs" - crypto "github.com/nspcc-dev/neofs-crypto" -) - -type signAccumWithToken struct { - SignedDataSource - SignKeyPairAccumulator - SignKeyPairSource - - token SessionToken -} - -type signDataReaderWithToken struct { - SignedDataSource - SignKeyPairAccumulator - SignKeyPairSource - - rdr SignedDataReader - - token SessionToken -} - -type signedSessionToken struct { - SessionToken -} - -const verbSize = 4 - -const fixedTokenDataSize = 0 + - refs.UUIDSize + - refs.OwnerIDSize + - verbSize + - refs.UUIDSize + - refs.CIDSize + - 8 + - 8 - -var tokenEndianness = binary.BigEndian - -// GetID is an ID field getter. -func (m Token_Info) GetID() TokenID { - return m.ID -} - -// SetID is an ID field setter. -func (m *Token_Info) SetID(id TokenID) { - m.ID = id -} - -// GetOwnerID is an OwnerID field getter. -func (m Token_Info) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *Token_Info) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// SetVerb is a Verb field setter. -func (m *Token_Info) SetVerb(verb Token_Info_Verb) { - m.Verb = verb -} - -// GetAddress is an Address field getter. -func (m Token_Info) GetAddress() Address { - return m.Address -} - -// SetAddress is an Address field setter. -func (m *Token_Info) SetAddress(addr Address) { - m.Address = addr -} - -// CreationEpoch is a Created field getter. -func (m TokenLifetime) CreationEpoch() uint64 { - return m.Created -} - -// SetCreationEpoch is a Created field setter. -func (m *TokenLifetime) SetCreationEpoch(e uint64) { - m.Created = e -} - -// ExpirationEpoch is a ValidUntil field getter. -func (m TokenLifetime) ExpirationEpoch() uint64 { - return m.ValidUntil -} - -// SetExpirationEpoch is a ValidUntil field setter. -func (m *TokenLifetime) SetExpirationEpoch(e uint64) { - m.ValidUntil = e -} - -// SetSessionKey is a SessionKey field setter. -func (m *Token_Info) SetSessionKey(key []byte) { - m.SessionKey = key -} - -// SetOwnerKey is an OwnerKey field setter. -func (m *Token_Info) SetOwnerKey(key []byte) { - m.OwnerKey = key -} - -// SetSignature is a Signature field setter. -func (m *Token) SetSignature(sig []byte) { - m.Signature = sig -} - -// Size returns the size of a binary representation of the verb. -func (x Token_Info_Verb) Size() int { - return verbSize -} - -// Bytes returns a binary representation of the verb. -func (x Token_Info_Verb) Bytes() []byte { - data := make([]byte, verbSize) - tokenEndianness.PutUint32(data, uint32(x)) - return data -} - -// AddSignKey calls a Signature field setter and an OwnerKey field setter with corresponding arguments. -func (s signedSessionToken) AddSignKey(sig []byte, key *ecdsa.PublicKey) { - if s.SessionToken != nil { - s.SessionToken.SetSignature(sig) - - s.SessionToken.SetOwnerKey( - crypto.MarshalPublicKey(key), - ) - } -} - -// SignedData returns token information in a binary representation. -func (s signedSessionToken) SignedData() ([]byte, error) { - return SignedDataFromReader(s) -} - -// SignedDataSize returns the length of signed token information slice. -func (s signedSessionToken) SignedDataSize() int { - return tokenInfoSize(s.SessionToken) -} - -// ReadSignedData copies a binary representation of the token information to passed buffer. -// -// If buffer length is less than required, io.ErrUnexpectedEOF returns. -func (s signedSessionToken) ReadSignedData(p []byte) (int, error) { - sz := s.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - copyTokenSignedData(p, s.SessionToken) - - return sz, nil -} - -// NewSignedSessionToken wraps passed SessionToken in a component suitable for signing. -// -// Result can be used in AddSignatureWithKey function. -func NewSignedSessionToken(token SessionToken) DataWithSignKeyAccumulator { - return &signedSessionToken{ - SessionToken: token, - } -} - -// NewVerifiedSessionToken wraps passed SessionToken in a component suitable for signature verification. -// -// Result can be used in VerifySignatureWithKey function. -func NewVerifiedSessionToken(token SessionToken) DataWithSignature { - return &signedSessionToken{ - SessionToken: token, - } -} - -func tokenInfoSize(v SessionKeySource) int { - if v == nil { - return 0 - } - return fixedTokenDataSize + len(v.GetSessionKey()) -} - -// Fills passed buffer with signing token information bytes. -// Does not check buffer length, it is understood that enough space is allocated in it. -// -// If passed SessionTokenInfo, buffer remains unchanged. -func copyTokenSignedData(buf []byte, token SessionTokenInfo) { - if token == nil { - return - } - - var off int - - off += copy(buf[off:], token.GetID().Bytes()) - - off += copy(buf[off:], token.GetOwnerID().Bytes()) - - off += copy(buf[off:], token.GetVerb().Bytes()) - - addr := token.GetAddress() - off += copy(buf[off:], addr.CID.Bytes()) - off += copy(buf[off:], addr.ObjectID.Bytes()) - - tokenEndianness.PutUint64(buf[off:], token.CreationEpoch()) - off += 8 - - tokenEndianness.PutUint64(buf[off:], token.ExpirationEpoch()) - off += 8 - - copy(buf[off:], token.GetSessionKey()) -} - -// SignedData concatenates signed data with session token information. Returns concatenation result. -// -// Token bytes are added if and only if token is not nil. -func (s signAccumWithToken) SignedData() ([]byte, error) { - data, err := s.SignedDataSource.SignedData() - if err != nil { - return nil, err - } - - tokenData := make([]byte, tokenInfoSize(s.token)) - - copyTokenSignedData(tokenData, s.token) - - return append(data, tokenData...), nil -} - -func (s signDataReaderWithToken) SignedDataSize() int { - sz := s.rdr.SignedDataSize() - if sz < 0 { - return -1 - } - - sz += tokenInfoSize(s.token) - - return sz -} - -func (s signDataReaderWithToken) ReadSignedData(p []byte) (int, error) { - dataSize := s.rdr.SignedDataSize() - if dataSize < 0 { - return 0, ErrNegativeLength - } - - sumSize := dataSize + tokenInfoSize(s.token) - - if len(p) < sumSize { - return 0, io.ErrUnexpectedEOF - } - - if n, err := s.rdr.ReadSignedData(p); err != nil { - return n, err - } - - copyTokenSignedData(p[dataSize:], s.token) - - return sumSize, nil -} diff --git a/service/token_test.go b/service/token_test.go deleted file mode 100644 index 4fb430a..0000000 --- a/service/token_test.go +++ /dev/null @@ -1,248 +0,0 @@ -package service - -import ( - "crypto/rand" - "testing" - - "github.com/nspcc-dev/neofs-api-go/refs" - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestTokenGettersSetters(t *testing.T) { - var tok SessionToken = new(Token) - - { // ID - id, err := refs.NewUUID() - require.NoError(t, err) - - tok.SetID(id) - - require.Equal(t, id, tok.GetID()) - } - - { // OwnerID - ownerID := OwnerID{} - _, err := rand.Read(ownerID[:]) - require.NoError(t, err) - - tok.SetOwnerID(ownerID) - - require.Equal(t, ownerID, tok.GetOwnerID()) - } - - { // Verb - verb := Token_Info_Verb(3) - - tok.SetVerb(verb) - - require.Equal(t, verb, tok.GetVerb()) - } - - { // Address - addr := Address{} - _, err := rand.Read(addr.CID[:]) - require.NoError(t, err) - _, err = rand.Read(addr.ObjectID[:]) - require.NoError(t, err) - - tok.SetAddress(addr) - - require.Equal(t, addr, tok.GetAddress()) - } - - { // Created - e := uint64(5) - - tok.SetCreationEpoch(e) - - require.Equal(t, e, tok.CreationEpoch()) - } - - { // ValidUntil - e := uint64(5) - - tok.SetExpirationEpoch(e) - - require.Equal(t, e, tok.ExpirationEpoch()) - } - - { // SessionKey - key := make([]byte, 10) - _, err := rand.Read(key) - require.NoError(t, err) - - tok.SetSessionKey(key) - - require.Equal(t, key, tok.GetSessionKey()) - } - - { // Signature - sig := make([]byte, 10) - _, err := rand.Read(sig) - require.NoError(t, err) - - tok.SetSignature(sig) - - require.Equal(t, sig, tok.GetSignature()) - } -} - -func TestSignToken(t *testing.T) { - var token SessionToken = new(Token) - - // create private key for signing - sk := test.DecodeKey(0) - pk := &sk.PublicKey - - id := TokenID{} - _, err := rand.Read(id[:]) - require.NoError(t, err) - token.SetID(id) - - ownerID := OwnerID{} - _, err = rand.Read(ownerID[:]) - require.NoError(t, err) - token.SetOwnerID(ownerID) - - verb := Token_Info_Verb(1) - token.SetVerb(verb) - - addr := Address{} - _, err = rand.Read(addr.ObjectID[:]) - require.NoError(t, err) - _, err = rand.Read(addr.CID[:]) - require.NoError(t, err) - token.SetAddress(addr) - - cEpoch := uint64(1) - token.SetCreationEpoch(cEpoch) - - fEpoch := uint64(2) - token.SetExpirationEpoch(fEpoch) - - sessionKey := make([]byte, 10) - _, err = rand.Read(sessionKey[:]) - require.NoError(t, err) - token.SetSessionKey(sessionKey) - - signedToken := NewSignedSessionToken(token) - verifiedToken := NewVerifiedSessionToken(token) - - // sign and verify token - require.NoError(t, AddSignatureWithKey(sk, signedToken)) - require.NoError(t, VerifySignatureWithKey(pk, verifiedToken)) - - items := []struct { - corrupt func() - restore func() - }{ - { // ID - corrupt: func() { - id[0]++ - token.SetID(id) - }, - restore: func() { - id[0]-- - token.SetID(id) - }, - }, - { // Owner ID - corrupt: func() { - ownerID[0]++ - token.SetOwnerID(ownerID) - }, - restore: func() { - ownerID[0]-- - token.SetOwnerID(ownerID) - }, - }, - { // Verb - corrupt: func() { - token.SetVerb(verb + 1) - }, - restore: func() { - token.SetVerb(verb) - }, - }, - { // ObjectID - corrupt: func() { - addr.ObjectID[0]++ - token.SetAddress(addr) - }, - restore: func() { - addr.ObjectID[0]-- - token.SetAddress(addr) - }, - }, - { // CID - corrupt: func() { - addr.CID[0]++ - token.SetAddress(addr) - }, - restore: func() { - addr.CID[0]-- - token.SetAddress(addr) - }, - }, - { // Creation epoch - corrupt: func() { - token.SetCreationEpoch(cEpoch + 1) - }, - restore: func() { - token.SetCreationEpoch(cEpoch) - }, - }, - { // Expiration epoch - corrupt: func() { - token.SetExpirationEpoch(fEpoch + 1) - }, - restore: func() { - token.SetExpirationEpoch(fEpoch) - }, - }, - { // Session key - corrupt: func() { - sessionKey[0]++ - token.SetSessionKey(sessionKey) - }, - restore: func() { - sessionKey[0]-- - token.SetSessionKey(sessionKey) - }, - }, - } - - for _, v := range items { - v.corrupt() - require.Error(t, VerifySignatureWithKey(pk, verifiedToken)) - v.restore() - require.NoError(t, VerifySignatureWithKey(pk, verifiedToken)) - } -} - -func TestSignedSessionToken_AddSignKey(t *testing.T) { - // nil SessionToken - s := new(signedSessionToken) - - require.NotPanics(t, func() { - s.AddSignKey(nil, nil) - }) - - // create test public key and signature - pk := &test.DecodeKey(0).PublicKey - sig := []byte{1, 2, 3} - - s.SessionToken = new(Token) - - // add key-signature pair to SessionToken - s.AddSignKey(sig, pk) - - require.Equal(t, sig, s.GetSignature()) - - require.Equal(t, - crypto.MarshalPublicKey(pk), - s.GetOwnerKey(), - ) -} diff --git a/service/ttl.go b/service/ttl.go deleted file mode 100644 index 28a5092..0000000 --- a/service/ttl.go +++ /dev/null @@ -1,63 +0,0 @@ -package service - -import ( - "github.com/pkg/errors" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// TTL constants. -const ( - // ZeroTTL is an upper bound of invalid TTL values. - ZeroTTL = iota - - // NonForwardingTTL is a TTL value that does not imply a request forwarding. - NonForwardingTTL - - // SingleForwardingTTL is a TTL value that imply potential forwarding with NonForwardingTTL. - SingleForwardingTTL -) - -// SetTTL is a TTL field setter. -func (m *RequestMetaHeader) SetTTL(v uint32) { - m.TTL = v -} - -// IRNonForwarding condition that allows NonForwardingTTL only for IR. -func IRNonForwarding(role NodeRole) TTLCondition { - return func(ttl uint32) error { - if ttl == NonForwardingTTL && role != InnerRingNode { - return ErrInvalidTTL - } - - return nil - } -} - -// ProcessRequestTTL validates and updates requests with TTL. -func ProcessRequestTTL(req TTLContainer, cond ...TTLCondition) error { - ttl := req.GetTTL() - - if ttl == ZeroTTL { - return status.New(codes.InvalidArgument, ErrInvalidTTL.Error()).Err() - } - - for i := range cond { - if cond[i] == nil { - continue - } - - // check specific condition: - if err := cond[i](ttl); err != nil { - if st, ok := status.FromError(errors.Cause(err)); ok { - return st.Err() - } - - return status.New(codes.InvalidArgument, err.Error()).Err() - } - } - - req.SetTTL(ttl - 1) - - return nil -} diff --git a/service/ttl_test.go b/service/ttl_test.go deleted file mode 100644 index 1c982f5..0000000 --- a/service/ttl_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package service - -import ( - "testing" - - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type mockedRequest struct { - msg string - name string - code codes.Code - handler TTLCondition - RequestMetaHeader -} - -func TestMetaRequest(t *testing.T) { - tests := []mockedRequest{ - { - name: "direct to ir node", - handler: IRNonForwarding(InnerRingNode), - RequestMetaHeader: RequestMetaHeader{TTL: NonForwardingTTL}, - }, - { - code: codes.InvalidArgument, - msg: ErrInvalidTTL.Error(), - name: "direct to storage node", - handler: IRNonForwarding(StorageNode), - RequestMetaHeader: RequestMetaHeader{TTL: NonForwardingTTL}, - }, - { - msg: ErrInvalidTTL.Error(), - code: codes.InvalidArgument, - name: "zero ttl", - handler: IRNonForwarding(StorageNode), - RequestMetaHeader: RequestMetaHeader{TTL: ZeroTTL}, - }, - { - name: "default to ir node", - handler: IRNonForwarding(InnerRingNode), - RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, - }, - { - name: "default to storage node", - handler: IRNonForwarding(StorageNode), - RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, - }, - { - msg: "not found", - code: codes.NotFound, - name: "custom status error", - RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, - handler: func(_ uint32) error { return status.Error(codes.NotFound, "not found") }, - }, - { - msg: "not found", - code: codes.NotFound, - name: "custom wrapped status error", - RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, - handler: func(_ uint32) error { - err := status.Error(codes.NotFound, "not found") - err = errors.Wrap(err, "some error context") - err = errors.Wrap(err, "another error context") - return err - }, - }, - } - - for i := range tests { - tt := tests[i] - t.Run(tt.name, func(t *testing.T) { - before := tt.GetTTL() - err := ProcessRequestTTL(&tt, tt.handler) - if tt.msg != "" { - require.Errorf(t, err, tt.msg) - - state, ok := status.FromError(err) - require.True(t, ok) - require.Equal(t, tt.code, state.Code()) - require.Equal(t, tt.msg, state.Message()) - } else { - require.NoError(t, err) - require.NotEqualf(t, before, tt.GetTTL(), "ttl should be changed: %d vs %d", before, tt.GetTTL()) - } - }) - } -} - -func TestRequestMetaHeader_SetTTL(t *testing.T) { - m := new(RequestMetaHeader) - ttl := uint32(3) - - m.SetTTL(ttl) - - require.Equal(t, ttl, m.GetTTL()) -} diff --git a/service/types.go b/service/types.go deleted file mode 100644 index 785a30a..0000000 --- a/service/types.go +++ /dev/null @@ -1,317 +0,0 @@ -package service - -import ( - "crypto/ecdsa" -) - -// NodeRole to identify in Bootstrap service. -type NodeRole int32 - -// TTLCondition is a function type that used to verify that TTL values match a specific criterion. -// Nil error indicates compliance with the criterion. -type TTLCondition func(uint32) error - -// RawSource is an interface of the container of a boolean Raw value with read access. -type RawSource interface { - GetRaw() bool -} - -// RawContainer is an interface of the container of a boolean Raw value. -type RawContainer interface { - RawSource - SetRaw(bool) -} - -// VersionSource is an interface of the container of a numerical Version value with read access. -type VersionSource interface { - GetVersion() uint32 -} - -// VersionContainer is an interface of the container of a numerical Version value. -type VersionContainer interface { - VersionSource - SetVersion(uint32) -} - -// EpochSource is an interface of the container of a NeoFS epoch number with read access. -type EpochSource interface { - GetEpoch() uint64 -} - -// EpochContainer is an interface of the container of a NeoFS epoch number. -type EpochContainer interface { - EpochSource - SetEpoch(uint64) -} - -// TTLSource is an interface of the container of a numerical TTL value with read access. -type TTLSource interface { - GetTTL() uint32 -} - -// TTLContainer is an interface of the container of a numerical TTL value. -type TTLContainer interface { - TTLSource - SetTTL(uint32) -} - -// SeizedMetaHeaderContainer is an interface of container of RequestMetaHeader that can be cut and restored. -type SeizedMetaHeaderContainer interface { - CutMeta() RequestMetaHeader - RestoreMeta(RequestMetaHeader) -} - -// RequestMetaContainer is an interface of a fixed set of request meta value containers. -// Contains: -// - TTL value; -// - NeoFS epoch number; -// - Protocol version; -// - Raw toggle option. -type RequestMetaContainer interface { - TTLContainer - EpochContainer - VersionContainer - RawContainer -} - -// SeizedRequestMetaContainer is a RequestMetaContainer with seized meta. -type SeizedRequestMetaContainer interface { - RequestMetaContainer - SeizedMetaHeaderContainer -} - -// VerbSource is an interface of the container of a token verb value with read access. -type VerbSource interface { - GetVerb() Token_Info_Verb -} - -// VerbContainer is an interface of the container of a token verb value. -type VerbContainer interface { - VerbSource - SetVerb(Token_Info_Verb) -} - -// TokenIDSource is an interface of the container of a token ID value with read access. -type TokenIDSource interface { - GetID() TokenID -} - -// TokenIDContainer is an interface of the container of a token ID value. -type TokenIDContainer interface { - TokenIDSource - SetID(TokenID) -} - -// CreationEpochSource is an interface of the container of a creation epoch number with read access. -type CreationEpochSource interface { - CreationEpoch() uint64 -} - -// CreationEpochContainer is an interface of the container of a creation epoch number. -type CreationEpochContainer interface { - CreationEpochSource - SetCreationEpoch(uint64) -} - -// ExpirationEpochSource is an interface of the container of an expiration epoch number with read access. -type ExpirationEpochSource interface { - ExpirationEpoch() uint64 -} - -// ExpirationEpochContainer is an interface of the container of an expiration epoch number. -type ExpirationEpochContainer interface { - ExpirationEpochSource - SetExpirationEpoch(uint64) -} - -// LifetimeSource is an interface of the container of creation-expiration epoch pair with read access. -type LifetimeSource interface { - CreationEpochSource - ExpirationEpochSource -} - -// LifetimeContainer is an interface of the container of creation-expiration epoch pair. -type LifetimeContainer interface { - CreationEpochContainer - ExpirationEpochContainer -} - -// SessionKeySource is an interface of the container of session key bytes with read access. -type SessionKeySource interface { - GetSessionKey() []byte -} - -// SessionKeyContainer is an interface of the container of public session key bytes. -type SessionKeyContainer interface { - SessionKeySource - SetSessionKey([]byte) -} - -// SignatureSource is an interface of the container of signature bytes with read access. -type SignatureSource interface { - GetSignature() []byte -} - -// SignatureContainer is an interface of the container of signature bytes. -type SignatureContainer interface { - SignatureSource - SetSignature([]byte) -} - -// OwnerKeySource is an interface of the container of owner key bytes with read access. -type OwnerKeySource interface { - GetOwnerKey() []byte -} - -// OwnerKeyContainer is an interface of the container of owner key bytes. -type OwnerKeyContainer interface { - OwnerKeySource - SetOwnerKey([]byte) -} - -// SessionTokenSource is an interface of the container of a SessionToken with read access. -type SessionTokenSource interface { - GetSessionToken() SessionToken -} - -// SessionTokenInfo is an interface of a fixed set of token information value containers. -// Contains: -// - ID of the token; -// - ID of the token's owner; -// - verb of the session; -// - address of the session object; -// - token lifetime; -// - public session key bytes; -// - owner's public key bytes. -type SessionTokenInfo interface { - TokenIDContainer - OwnerIDContainer - VerbContainer - AddressContainer - LifetimeContainer - SessionKeyContainer - OwnerKeyContainer -} - -// SessionToken is an interface of token information and signature pair. -type SessionToken interface { - SessionTokenInfo - SignatureContainer -} - -// SignedDataSource is an interface of the container of a data for signing. -type SignedDataSource interface { - // Must return the required for signature byte slice. - // A non-nil error indicates that the data is not ready for signature. - SignedData() ([]byte, error) -} - -// SignedDataReader is an interface of signed data reader. -type SignedDataReader interface { - // Must return the minimum length of the slice for full reading. - // Must return a negative value if the length cannot be calculated. - SignedDataSize() int - - // Must behave like Read method of io.Reader and differ only in the reading of the signed data. - ReadSignedData([]byte) (int, error) -} - -// SignKeyPairAccumulator is an interface of a set of key-signature pairs with append access. -type SignKeyPairAccumulator interface { - AddSignKey([]byte, *ecdsa.PublicKey) -} - -// SignKeyPairSource is an interface of a set of key-signature pairs with read access. -type SignKeyPairSource interface { - GetSignKeyPairs() []SignKeyPair -} - -// SignKeyPair is an interface of key-signature pair with read access. -type SignKeyPair interface { - SignatureSource - GetPublicKey() *ecdsa.PublicKey -} - -// DataWithSignature is an interface of data-signature pair with read access. -type DataWithSignature interface { - SignedDataSource - SignatureSource -} - -// DataWithSignKeyAccumulator is an interface of data and key-signature accumulator pair. -type DataWithSignKeyAccumulator interface { - SignedDataSource - SignKeyPairAccumulator -} - -// DataWithSignKeySource is an interface of data and key-signature source pair. -type DataWithSignKeySource interface { - SignedDataSource - SignKeyPairSource -} - -// RequestData is an interface of the request information with read access. -type RequestData interface { - SignedDataSource - SessionTokenSource - BearerTokenSource - ExtendedHeadersSource -} - -// RequestSignedData is an interface of request information with signature write access. -type RequestSignedData interface { - RequestData - SignKeyPairAccumulator - SignKeyPairSource -} - -// RequestVerifyData is an interface of request information with signature read access. -type RequestVerifyData interface { - RequestData - SignKeyPairSource -} - -// ACLRulesSource is an interface of the container of binary extended ACL rules with read access. -type ACLRulesSource interface { - GetACLRules() []byte -} - -// ACLRulesContainer is an interface of the container of binary extended ACL rules. -type ACLRulesContainer interface { - ACLRulesSource - SetACLRules([]byte) -} - -// BearerTokenInfo is an interface of a fixed set of Bearer token information value containers. -// Contains: -// - binary extended ACL rules; -// - expiration epoch number; -// - ID of the token's owner. -type BearerTokenInfo interface { - ACLRulesContainer - ExpirationEpochContainer - OwnerIDContainer -} - -// BearerToken is an interface of Bearer token information and key-signature pair. -type BearerToken interface { - BearerTokenInfo - OwnerKeyContainer - SignatureContainer -} - -// BearerTokenSource is an interface of the container of a BearerToken with read access. -type BearerTokenSource interface { - GetBearerToken() BearerToken -} - -// ExtendedHeader is an interface of string key-value pair with read access. -type ExtendedHeader interface { - Key() string - Value() string -} - -// ExtendedHeadersSource is an interface of ExtendedHeader list with read access. -type ExtendedHeadersSource interface { - ExtendedHeaders() []ExtendedHeader -} diff --git a/service/utils.go b/service/utils.go deleted file mode 100644 index 17b23bb..0000000 --- a/service/utils.go +++ /dev/null @@ -1,18 +0,0 @@ -package service - -// SignedDataFromReader allocates buffer and reads bytes from passed reader to it. -// -// If passed SignedDataReader is nil, ErrNilSignedDataReader returns. -func SignedDataFromReader(r SignedDataReader) ([]byte, error) { - if r == nil { - return nil, ErrNilSignedDataReader - } - - data := make([]byte, r.SignedDataSize()) - - if _, err := r.ReadSignedData(data); err != nil { - return nil, err - } - - return data, nil -} diff --git a/service/utils_test.go b/service/utils_test.go deleted file mode 100644 index 60a2352..0000000 --- a/service/utils_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package service - -import ( - "testing" - - "github.com/pkg/errors" - "github.com/stretchr/testify/require" -) - -func TestSignedDataFromReader(t *testing.T) { - // nil SignedDataReader - _, err := SignedDataFromReader(nil) - require.EqualError(t, err, ErrNilSignedDataReader.Error()) - - rdr := &testSignedDataReader{ - testSignedDataSrc: new(testSignedDataSrc), - } - - // make reader to return an error - rdr.err = errors.New("test error") - - _, err = SignedDataFromReader(rdr) - require.EqualError(t, err, rdr.err.Error()) - - // remove the error - rdr.err = nil - - // fill the data - rdr.data = testData(t, 10) - - res, err := SignedDataFromReader(rdr) - require.NoError(t, err) - require.Equal(t, rdr.data, res) -} diff --git a/service/verify.go b/service/verify.go deleted file mode 100644 index 2aca7cb..0000000 --- a/service/verify.go +++ /dev/null @@ -1,174 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - "io" - - "github.com/gogo/protobuf/proto" - "github.com/nspcc-dev/neofs-api-go/internal" - crypto "github.com/nspcc-dev/neofs-crypto" -) - -type signKeyPairsWrapper struct { - items []SignKeyPair -} - -// GetSessionToken returns SessionToken interface of Token field. -// -// If token field value is nil, nil returns. -func (m RequestVerificationHeader) GetSessionToken() SessionToken { - if t := m.GetToken(); t != nil { - return t - } - - return nil -} - -// AddSignKey adds new element to Signatures field. -// -// Sets Sign field to passed sign. Set Peer field to marshaled passed key. -func (m *RequestVerificationHeader) AddSignKey(sign []byte, key *ecdsa.PublicKey) { - m.SetSignatures( - append( - m.GetSignatures(), - &RequestVerificationHeader_Signature{ - Sign: sign, - Peer: crypto.MarshalPublicKey(key), - }, - ), - ) -} - -// GetSignKeyPairs returns the elements of Signatures field as SignKeyPair slice. -func (m RequestVerificationHeader) GetSignKeyPairs() []SignKeyPair { - var ( - signs = m.GetSignatures() - res = make([]SignKeyPair, len(signs)) - ) - - for i := range signs { - res[i] = signs[i] - } - - return res -} - -// GetSignature returns the result of a Sign field getter. -func (m RequestVerificationHeader_Signature) GetSignature() []byte { - return m.GetSign() -} - -// GetPublicKey unmarshals and returns the result of a Peer field getter. -func (m RequestVerificationHeader_Signature) GetPublicKey() *ecdsa.PublicKey { - return crypto.UnmarshalPublicKey(m.GetPeer()) -} - -// SetSignatures replaces signatures stored in RequestVerificationHeader. -func (m *RequestVerificationHeader) SetSignatures(signatures []*RequestVerificationHeader_Signature) { - m.Signatures = signatures -} - -// SetToken is a Token field setter. -func (m *RequestVerificationHeader) SetToken(token *Token) { - m.Token = token -} - -// SetBearer is a Bearer field setter. -func (m *RequestVerificationHeader) SetBearer(v *BearerTokenMsg) { - m.Bearer = v -} - -// testCustomField for test usage only. -type testCustomField [8]uint32 - -var _ internal.Custom = (*testCustomField)(nil) - -// Reset skip, it's for test usage only. -func (t testCustomField) Reset() {} - -// ProtoMessage skip, it's for test usage only. -func (t testCustomField) ProtoMessage() {} - -// Size skip, it's for test usage only. -func (t testCustomField) Size() int { return 32 } - -// String skip, it's for test usage only. -func (t testCustomField) String() string { return "" } - -// Bytes skip, it's for test usage only. -func (t testCustomField) Bytes() []byte { return nil } - -// Unmarshal skip, it's for test usage only. -func (t testCustomField) Unmarshal(data []byte) error { return nil } - -// Empty skip, it's for test usage only. -func (t testCustomField) Empty() bool { return false } - -// UnmarshalTo skip, it's for test usage only. -func (t testCustomField) MarshalTo(data []byte) (int, error) { return 0, nil } - -// Marshal skip, it's for test usage only. -func (t testCustomField) Marshal() ([]byte, error) { return nil, nil } - -// Merge used by proto.Clone -func (t *testCustomField) Merge(src proto.Message) { - if tmp, ok := src.(*testCustomField); ok { - *t = *tmp - } -} - -// GetBearerToken wraps Bearer field and return BearerToken interface. -// -// If Bearer field value is nil, nil returns. -func (m RequestVerificationHeader) GetBearerToken() BearerToken { - if t := m.GetBearer(); t != nil { - return t - } - - return nil -} - -// SignKeyPairsSignedData wraps passed SignKeyPair slice and returns SignedDataSource interface. -func SignKeyPairsSignedData(v ...SignKeyPair) SignedDataSource { - return &signKeyPairsWrapper{ - items: v, - } -} - -// SignedData returns signed SignKeyPair slice in a binary representation. -func (s signKeyPairsWrapper) SignedData() ([]byte, error) { - return SignedDataFromReader(s) -} - -// SignedDataSize returns the length of signed SignKeyPair slice. -func (s signKeyPairsWrapper) SignedDataSize() (sz int) { - for i := range s.items { - // add key length - sz += len( - crypto.MarshalPublicKey(s.items[i].GetPublicKey()), - ) - } - - return -} - -// ReadSignedData copies a binary representation of the signed SignKeyPair slice to passed buffer. -// -// If buffer length is less than required, io.ErrUnexpectedEOF returns. -func (s signKeyPairsWrapper) ReadSignedData(p []byte) (int, error) { - sz := s.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - off := 0 - - for i := range s.items { - // copy public key bytes - off += copy(p[off:], crypto.MarshalPublicKey( - s.items[i].GetPublicKey(), - )) - } - - return off, nil -} diff --git a/service/verify.pb.go b/service/verify.pb.go deleted file mode 100644 index 02f3f39..0000000 --- a/service/verify.pb.go +++ /dev/null @@ -1,2225 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: service/verify.proto - -package service - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - _ "github.com/nspcc-dev/neofs-api-go/refs" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// Verb is an enumeration of session request types -type Token_Info_Verb int32 - -const ( - // Put refers to object.Put RPC call - Token_Info_Put Token_Info_Verb = 0 - // Get refers to object.Get RPC call - Token_Info_Get Token_Info_Verb = 1 - // Head refers to object.Head RPC call - Token_Info_Head Token_Info_Verb = 2 - // Search refers to object.Search RPC call - Token_Info_Search Token_Info_Verb = 3 - // Delete refers to object.Delete RPC call - Token_Info_Delete Token_Info_Verb = 4 - // Range refers to object.GetRange RPC call - Token_Info_Range Token_Info_Verb = 5 - // RangeHash refers to object.GetRangeHash RPC call - Token_Info_RangeHash Token_Info_Verb = 6 -) - -var Token_Info_Verb_name = map[int32]string{ - 0: "Put", - 1: "Get", - 2: "Head", - 3: "Search", - 4: "Delete", - 5: "Range", - 6: "RangeHash", -} - -var Token_Info_Verb_value = map[string]int32{ - "Put": 0, - "Get": 1, - "Head": 2, - "Search": 3, - "Delete": 4, - "Range": 5, - "RangeHash": 6, -} - -func (x Token_Info_Verb) String() string { - return proto.EnumName(Token_Info_Verb_name, int32(x)) -} - -func (Token_Info_Verb) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{1, 0, 0} -} - -// RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request -// (should be embedded into message). -type RequestVerificationHeader struct { - // Signatures is a set of signatures of every passed NeoFS Node - Signatures []*RequestVerificationHeader_Signature `protobuf:"bytes,1,rep,name=Signatures,proto3" json:"Signatures,omitempty"` - // Token is a token of the session within which the request is sent - Token *Token `protobuf:"bytes,2,opt,name=Token,proto3" json:"Token,omitempty"` - // Bearer is a Bearer token of the request - Bearer *BearerTokenMsg `protobuf:"bytes,3,opt,name=Bearer,proto3" json:"Bearer,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestVerificationHeader) Reset() { *m = RequestVerificationHeader{} } -func (m *RequestVerificationHeader) String() string { return proto.CompactTextString(m) } -func (*RequestVerificationHeader) ProtoMessage() {} -func (*RequestVerificationHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{0} -} -func (m *RequestVerificationHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestVerificationHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *RequestVerificationHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestVerificationHeader.Merge(m, src) -} -func (m *RequestVerificationHeader) XXX_Size() int { - return m.Size() -} -func (m *RequestVerificationHeader) XXX_DiscardUnknown() { - xxx_messageInfo_RequestVerificationHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestVerificationHeader proto.InternalMessageInfo - -func (m *RequestVerificationHeader) GetSignatures() []*RequestVerificationHeader_Signature { - if m != nil { - return m.Signatures - } - return nil -} - -func (m *RequestVerificationHeader) GetToken() *Token { - if m != nil { - return m.Token - } - return nil -} - -func (m *RequestVerificationHeader) GetBearer() *BearerTokenMsg { - if m != nil { - return m.Bearer - } - return nil -} - -type RequestVerificationHeader_Signature struct { - // Sign is signature of the request or session key. - Sign []byte `protobuf:"bytes,1,opt,name=Sign,proto3" json:"Sign,omitempty"` - // Peer is compressed public key used for signature. - Peer []byte `protobuf:"bytes,2,opt,name=Peer,proto3" json:"Peer,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestVerificationHeader_Signature) Reset() { *m = RequestVerificationHeader_Signature{} } -func (m *RequestVerificationHeader_Signature) String() string { return proto.CompactTextString(m) } -func (*RequestVerificationHeader_Signature) ProtoMessage() {} -func (*RequestVerificationHeader_Signature) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{0, 0} -} -func (m *RequestVerificationHeader_Signature) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestVerificationHeader_Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *RequestVerificationHeader_Signature) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestVerificationHeader_Signature.Merge(m, src) -} -func (m *RequestVerificationHeader_Signature) XXX_Size() int { - return m.Size() -} -func (m *RequestVerificationHeader_Signature) XXX_DiscardUnknown() { - xxx_messageInfo_RequestVerificationHeader_Signature.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestVerificationHeader_Signature proto.InternalMessageInfo - -func (m *RequestVerificationHeader_Signature) GetSign() []byte { - if m != nil { - return m.Sign - } - return nil -} - -func (m *RequestVerificationHeader_Signature) GetPeer() []byte { - if m != nil { - return m.Peer - } - return nil -} - -// User token granting rights for object manipulation -type Token struct { - // TokenInfo is a grouped information about token - Token_Info `protobuf:"bytes,1,opt,name=TokenInfo,proto3,embedded=TokenInfo" json:"TokenInfo"` - // Signature is a signature of session token information - Signature []byte `protobuf:"bytes,8,opt,name=Signature,proto3" json:"Signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Token) Reset() { *m = Token{} } -func (m *Token) String() string { return proto.CompactTextString(m) } -func (*Token) ProtoMessage() {} -func (*Token) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{1} -} -func (m *Token) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Token) XXX_Merge(src proto.Message) { - xxx_messageInfo_Token.Merge(m, src) -} -func (m *Token) XXX_Size() int { - return m.Size() -} -func (m *Token) XXX_DiscardUnknown() { - xxx_messageInfo_Token.DiscardUnknown(m) -} - -var xxx_messageInfo_Token proto.InternalMessageInfo - -func (m *Token) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type Token_Info struct { - // ID is a token identifier. valid UUIDv4 represented in bytes - ID TokenID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=TokenID" json:"ID"` - // OwnerID is an owner of manipulation object - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Verb is a type of request for which the token is issued - Verb Token_Info_Verb `protobuf:"varint,3,opt,name=verb,proto3,enum=service.Token_Info_Verb" json:"verb,omitempty"` - // Address is an object address for which token is issued - Address Address `protobuf:"bytes,4,opt,name=Address,proto3,customtype=Address" json:"Address"` - // Lifetime is a lifetime of the session - TokenLifetime `protobuf:"bytes,5,opt,name=Lifetime,proto3,embedded=Lifetime" json:"Lifetime"` - // SessionKey is a public key of session key - SessionKey []byte `protobuf:"bytes,6,opt,name=SessionKey,proto3" json:"SessionKey,omitempty"` - // OwnerKey is a public key of the token owner - OwnerKey []byte `protobuf:"bytes,7,opt,name=OwnerKey,proto3" json:"OwnerKey,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Token_Info) Reset() { *m = Token_Info{} } -func (m *Token_Info) String() string { return proto.CompactTextString(m) } -func (*Token_Info) ProtoMessage() {} -func (*Token_Info) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{1, 0} -} -func (m *Token_Info) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Token_Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *Token_Info) XXX_Merge(src proto.Message) { - xxx_messageInfo_Token_Info.Merge(m, src) -} -func (m *Token_Info) XXX_Size() int { - return m.Size() -} -func (m *Token_Info) XXX_DiscardUnknown() { - xxx_messageInfo_Token_Info.DiscardUnknown(m) -} - -var xxx_messageInfo_Token_Info proto.InternalMessageInfo - -func (m *Token_Info) GetVerb() Token_Info_Verb { - if m != nil { - return m.Verb - } - return Token_Info_Put -} - -func (m *Token_Info) GetSessionKey() []byte { - if m != nil { - return m.SessionKey - } - return nil -} - -func (m *Token_Info) GetOwnerKey() []byte { - if m != nil { - return m.OwnerKey - } - return nil -} - -// TokenLifetime carries a group of lifetime parameters of the token -type TokenLifetime struct { - // Created carries an initial epoch of token lifetime - Created uint64 `protobuf:"varint,1,opt,name=Created,proto3" json:"Created,omitempty"` - // ValidUntil carries a last epoch of token lifetime - ValidUntil uint64 `protobuf:"varint,2,opt,name=ValidUntil,proto3" json:"ValidUntil,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TokenLifetime) Reset() { *m = TokenLifetime{} } -func (m *TokenLifetime) String() string { return proto.CompactTextString(m) } -func (*TokenLifetime) ProtoMessage() {} -func (*TokenLifetime) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{2} -} -func (m *TokenLifetime) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TokenLifetime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *TokenLifetime) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenLifetime.Merge(m, src) -} -func (m *TokenLifetime) XXX_Size() int { - return m.Size() -} -func (m *TokenLifetime) XXX_DiscardUnknown() { - xxx_messageInfo_TokenLifetime.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenLifetime proto.InternalMessageInfo - -func (m *TokenLifetime) GetCreated() uint64 { - if m != nil { - return m.Created - } - return 0 -} - -func (m *TokenLifetime) GetValidUntil() uint64 { - if m != nil { - return m.ValidUntil - } - return 0 -} - -// BearerTokenMsg carries information about request ACL rules with limited lifetime -type BearerTokenMsg struct { - // TokenInfo is a grouped information about token - BearerTokenMsg_Info `protobuf:"bytes,1,opt,name=TokenInfo,proto3,embedded=TokenInfo" json:"TokenInfo"` - // OwnerKey is a public key of the token owner - OwnerKey []byte `protobuf:"bytes,2,opt,name=OwnerKey,proto3" json:"OwnerKey,omitempty"` - // Signature is a signature of token information - Signature []byte `protobuf:"bytes,3,opt,name=Signature,proto3" json:"Signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BearerTokenMsg) Reset() { *m = BearerTokenMsg{} } -func (m *BearerTokenMsg) String() string { return proto.CompactTextString(m) } -func (*BearerTokenMsg) ProtoMessage() {} -func (*BearerTokenMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{3} -} -func (m *BearerTokenMsg) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BearerTokenMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *BearerTokenMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_BearerTokenMsg.Merge(m, src) -} -func (m *BearerTokenMsg) XXX_Size() int { - return m.Size() -} -func (m *BearerTokenMsg) XXX_DiscardUnknown() { - xxx_messageInfo_BearerTokenMsg.DiscardUnknown(m) -} - -var xxx_messageInfo_BearerTokenMsg proto.InternalMessageInfo - -func (m *BearerTokenMsg) GetOwnerKey() []byte { - if m != nil { - return m.OwnerKey - } - return nil -} - -func (m *BearerTokenMsg) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type BearerTokenMsg_Info struct { - // ACLRules carries a binary representation of the table of extended ACL rules - ACLRules []byte `protobuf:"bytes,1,opt,name=ACLRules,proto3" json:"ACLRules,omitempty"` - // OwnerID is an owner of token - OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // ValidUntil carries a last epoch of token lifetime - ValidUntil uint64 `protobuf:"varint,3,opt,name=ValidUntil,proto3" json:"ValidUntil,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BearerTokenMsg_Info) Reset() { *m = BearerTokenMsg_Info{} } -func (m *BearerTokenMsg_Info) String() string { return proto.CompactTextString(m) } -func (*BearerTokenMsg_Info) ProtoMessage() {} -func (*BearerTokenMsg_Info) Descriptor() ([]byte, []int) { - return fileDescriptor_4bdd5bc50ec96238, []int{3, 0} -} -func (m *BearerTokenMsg_Info) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BearerTokenMsg_Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *BearerTokenMsg_Info) XXX_Merge(src proto.Message) { - xxx_messageInfo_BearerTokenMsg_Info.Merge(m, src) -} -func (m *BearerTokenMsg_Info) XXX_Size() int { - return m.Size() -} -func (m *BearerTokenMsg_Info) XXX_DiscardUnknown() { - xxx_messageInfo_BearerTokenMsg_Info.DiscardUnknown(m) -} - -var xxx_messageInfo_BearerTokenMsg_Info proto.InternalMessageInfo - -func (m *BearerTokenMsg_Info) GetACLRules() []byte { - if m != nil { - return m.ACLRules - } - return nil -} - -func (m *BearerTokenMsg_Info) GetValidUntil() uint64 { - if m != nil { - return m.ValidUntil - } - return 0 -} - -func init() { - proto.RegisterEnum("service.Token_Info_Verb", Token_Info_Verb_name, Token_Info_Verb_value) - proto.RegisterType((*RequestVerificationHeader)(nil), "service.RequestVerificationHeader") - proto.RegisterType((*RequestVerificationHeader_Signature)(nil), "service.RequestVerificationHeader.Signature") - proto.RegisterType((*Token)(nil), "service.Token") - proto.RegisterType((*Token_Info)(nil), "service.Token.Info") - proto.RegisterType((*TokenLifetime)(nil), "service.TokenLifetime") - proto.RegisterType((*BearerTokenMsg)(nil), "service.BearerTokenMsg") - proto.RegisterType((*BearerTokenMsg_Info)(nil), "service.BearerTokenMsg.Info") -} - -func init() { proto.RegisterFile("service/verify.proto", fileDescriptor_4bdd5bc50ec96238) } - -var fileDescriptor_4bdd5bc50ec96238 = []byte{ - // 658 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x5a, - 0x10, 0xae, 0x63, 0x27, 0x76, 0xa6, 0x3f, 0xd7, 0xf7, 0xdc, 0xab, 0x7b, 0x4d, 0x54, 0x25, 0x55, - 0xc4, 0xa2, 0x95, 0x88, 0x2d, 0xa5, 0x12, 0x42, 0x82, 0x4d, 0xd3, 0x08, 0x1a, 0x51, 0xa0, 0x3a, - 0x29, 0x5d, 0xb0, 0x73, 0x92, 0x89, 0x6b, 0x91, 0xda, 0xe1, 0x1c, 0x27, 0xa8, 0xef, 0xc1, 0x82, - 0x67, 0xe0, 0x49, 0xba, 0xec, 0x12, 0xb1, 0x88, 0x50, 0x78, 0x06, 0x16, 0xac, 0x40, 0x1e, 0x3b, - 0x89, 0x5d, 0x28, 0x12, 0xbb, 0x6f, 0xbe, 0xf9, 0xe6, 0xe7, 0x4c, 0xbe, 0x18, 0xfe, 0x95, 0x28, - 0xa6, 0x7e, 0x1f, 0x9d, 0x29, 0x0a, 0x7f, 0x78, 0x69, 0x8f, 0x45, 0x18, 0x85, 0x4c, 0x4f, 0xd9, - 0x8a, 0x29, 0x70, 0x28, 0x9d, 0xe8, 0x72, 0x8c, 0x32, 0x49, 0x55, 0x1a, 0x9e, 0x1f, 0x9d, 0x4f, - 0x7a, 0x76, 0x3f, 0xbc, 0x70, 0xbc, 0xd0, 0x0b, 0x1d, 0xa2, 0x7b, 0x93, 0x21, 0x45, 0x14, 0x10, - 0x4a, 0xe4, 0xf5, 0xaf, 0x0a, 0xdc, 0xe1, 0xf8, 0x66, 0x82, 0x32, 0x3a, 0x8b, 0x27, 0xf8, 0x7d, - 0x37, 0xf2, 0xc3, 0xe0, 0x08, 0xdd, 0x01, 0x0a, 0x76, 0x0c, 0xd0, 0xf5, 0xbd, 0xc0, 0x8d, 0x26, - 0x02, 0xa5, 0xa5, 0xec, 0xa8, 0xbb, 0xeb, 0xcd, 0x7b, 0x76, 0x3a, 0xdc, 0xbe, 0xb5, 0xce, 0x5e, - 0x16, 0xf1, 0x4c, 0x3d, 0xbb, 0x0b, 0xc5, 0xd3, 0xf0, 0x35, 0x06, 0x56, 0x61, 0x47, 0xd9, 0x5d, - 0x6f, 0x6e, 0x2d, 0x1b, 0x11, 0xcb, 0x93, 0x24, 0x73, 0xa0, 0xd4, 0x42, 0x57, 0xa0, 0xb0, 0x54, - 0x92, 0xfd, 0xbf, 0x94, 0x25, 0x34, 0xa9, 0x9e, 0x49, 0x8f, 0xa7, 0xb2, 0xca, 0x3e, 0x94, 0x97, - 0x43, 0x18, 0x03, 0x2d, 0x0e, 0x2c, 0x65, 0x47, 0xd9, 0xdd, 0xe0, 0x84, 0x63, 0xee, 0x04, 0x51, - 0xd0, 0xd8, 0x0d, 0x4e, 0xb8, 0xfe, 0x4d, 0x4d, 0x97, 0x61, 0x0f, 0xa1, 0x4c, 0xa0, 0x13, 0x0c, - 0x43, 0x2a, 0x5b, 0x6f, 0xfe, 0x93, 0xdf, 0xcc, 0x8e, 0x53, 0x2d, 0xe3, 0x6a, 0x56, 0x5b, 0xbb, - 0x9e, 0xd5, 0x14, 0xbe, 0xd2, 0xb3, 0xed, 0xcc, 0x6c, 0xcb, 0xa0, 0xfe, 0x2b, 0xa2, 0xf2, 0x4e, - 0x05, 0x8d, 0x64, 0x35, 0x28, 0x74, 0xda, 0xc9, 0x4e, 0xad, 0xbf, 0xe2, 0x3e, 0x9f, 0x66, 0x35, - 0x3d, 0xe9, 0xd2, 0xe6, 0x85, 0x4e, 0x9b, 0xed, 0x81, 0xfe, 0xe2, 0x6d, 0x80, 0xa2, 0xd3, 0x4e, - 0xb6, 0x5c, 0xa9, 0x52, 0x9a, 0x2f, 0x00, 0xbb, 0x0f, 0xda, 0x14, 0x45, 0x8f, 0xae, 0xb3, 0xd5, - 0xb4, 0x7e, 0xb1, 0xaa, 0x7d, 0x86, 0xa2, 0xd7, 0x32, 0xe6, 0xb3, 0x9a, 0x16, 0x23, 0x4e, 0x7a, - 0xf6, 0x00, 0xf4, 0x83, 0xc1, 0x40, 0xa0, 0x94, 0x96, 0x46, 0xaf, 0xdc, 0xb4, 0x63, 0xf3, 0xd8, - 0x29, 0xb9, 0x9a, 0x98, 0x12, 0x7c, 0x01, 0xd8, 0x23, 0x30, 0x8e, 0xfd, 0x21, 0x46, 0xfe, 0x05, - 0x5a, 0x45, 0x2a, 0xfd, 0x2f, 0x3f, 0x75, 0x91, 0xcd, 0xdc, 0x68, 0x59, 0xc1, 0xaa, 0x00, 0x5d, - 0x94, 0xd2, 0x0f, 0x83, 0xa7, 0x78, 0x69, 0x95, 0xe8, 0x46, 0x19, 0x86, 0x55, 0xc0, 0xa0, 0xa7, - 0xc5, 0x59, 0x9d, 0xb2, 0xcb, 0xb8, 0x7e, 0x0a, 0xf4, 0x02, 0xa6, 0x83, 0x7a, 0x32, 0x89, 0xcc, - 0xb5, 0x18, 0x3c, 0xc1, 0xc8, 0x54, 0x98, 0x01, 0x5a, 0xec, 0x35, 0xb3, 0xc0, 0x00, 0x4a, 0x5d, - 0x74, 0x45, 0xff, 0xdc, 0x54, 0x63, 0xdc, 0xc6, 0x11, 0x46, 0x68, 0x6a, 0xac, 0x0c, 0x45, 0xee, - 0x06, 0x1e, 0x9a, 0x45, 0xb6, 0x09, 0x65, 0x82, 0x47, 0xae, 0x3c, 0x37, 0x4b, 0xf5, 0x0e, 0x6c, - 0xe6, 0xd6, 0x66, 0x16, 0xe8, 0x87, 0x02, 0xdd, 0x08, 0x07, 0xf4, 0x1b, 0x69, 0x7c, 0x11, 0xc6, - 0xcb, 0x9f, 0xb9, 0x23, 0x7f, 0xf0, 0x32, 0x88, 0xfc, 0x11, 0xfd, 0x34, 0x1a, 0xcf, 0x30, 0xf5, - 0xef, 0x0a, 0x6c, 0xe5, 0x6d, 0xc9, 0xda, 0x3f, 0xfb, 0x69, 0xfb, 0x16, 0x0b, 0xff, 0xc6, 0x58, - 0xd9, 0xab, 0x14, 0xf2, 0x57, 0xc9, 0x9b, 0x4e, 0xbd, 0x69, 0xba, 0x8b, 0xd4, 0x73, 0x15, 0x30, - 0x0e, 0x0e, 0x8f, 0xf9, 0x64, 0x44, 0xff, 0x5c, 0xea, 0xb0, 0x88, 0xff, 0xc4, 0x6e, 0xf9, 0x0b, - 0xa8, 0x37, 0x2f, 0xd0, 0xea, 0x5e, 0xcd, 0xab, 0xca, 0xf5, 0xbc, 0xaa, 0x7c, 0x9c, 0x57, 0x95, - 0xcf, 0xf3, 0xaa, 0xf2, 0xfe, 0x4b, 0x75, 0xed, 0xd5, 0x5e, 0xe6, 0x2b, 0x14, 0xc8, 0x71, 0xbf, - 0xdf, 0x18, 0xe0, 0xd4, 0x09, 0x30, 0x1c, 0xca, 0x86, 0x3b, 0xf6, 0x1b, 0x5e, 0xe8, 0xa4, 0x27, - 0xf9, 0x50, 0xf8, 0xfb, 0x39, 0x86, 0x8f, 0xbb, 0xf6, 0xc1, 0x49, 0xc7, 0xee, 0x26, 0x5c, 0xaf, - 0x44, 0x1f, 0xa7, 0xfd, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x49, 0xb9, 0x3e, 0xfe, 0x04, - 0x00, 0x00, -} - -func (m *RequestVerificationHeader) 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 *RequestVerificationHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestVerificationHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Bearer != nil { - { - size, err := m.Bearer.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Token != nil { - { - size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Signatures) > 0 { - for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Signatures[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *RequestVerificationHeader_Signature) 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 *RequestVerificationHeader_Signature) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestVerificationHeader_Signature) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Peer) > 0 { - i -= len(m.Peer) - copy(dAtA[i:], m.Peer) - i = encodeVarintVerify(dAtA, i, uint64(len(m.Peer))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sign) > 0 { - i -= len(m.Sign) - copy(dAtA[i:], m.Sign) - i = encodeVarintVerify(dAtA, i, uint64(len(m.Sign))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Token) 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 *Token) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Token) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintVerify(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x42 - } - { - size, err := m.Token_Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Token_Info) 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 *Token_Info) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Token_Info) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.OwnerKey) > 0 { - i -= len(m.OwnerKey) - copy(dAtA[i:], m.OwnerKey) - i = encodeVarintVerify(dAtA, i, uint64(len(m.OwnerKey))) - i-- - dAtA[i] = 0x3a - } - if len(m.SessionKey) > 0 { - i -= len(m.SessionKey) - copy(dAtA[i:], m.SessionKey) - i = encodeVarintVerify(dAtA, i, uint64(len(m.SessionKey))) - i-- - dAtA[i] = 0x32 - } - { - size, err := m.TokenLifetime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.Address.Size() - i -= size - if _, err := m.Address.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.Verb != 0 { - i = encodeVarintVerify(dAtA, i, uint64(m.Verb)) - i-- - dAtA[i] = 0x18 - } - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *TokenLifetime) 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 *TokenLifetime) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TokenLifetime) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ValidUntil != 0 { - i = encodeVarintVerify(dAtA, i, uint64(m.ValidUntil)) - i-- - dAtA[i] = 0x10 - } - if m.Created != 0 { - i = encodeVarintVerify(dAtA, i, uint64(m.Created)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *BearerTokenMsg) 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 *BearerTokenMsg) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BearerTokenMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintVerify(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x1a - } - if len(m.OwnerKey) > 0 { - i -= len(m.OwnerKey) - copy(dAtA[i:], m.OwnerKey) - i = encodeVarintVerify(dAtA, i, uint64(len(m.OwnerKey))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.BearerTokenMsg_Info.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *BearerTokenMsg_Info) 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 *BearerTokenMsg_Info) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BearerTokenMsg_Info) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ValidUntil != 0 { - i = encodeVarintVerify(dAtA, i, uint64(m.ValidUntil)) - i-- - dAtA[i] = 0x18 - } - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintVerify(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ACLRules) > 0 { - i -= len(m.ACLRules) - copy(dAtA[i:], m.ACLRules) - i = encodeVarintVerify(dAtA, i, uint64(len(m.ACLRules))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintVerify(dAtA []byte, offset int, v uint64) int { - offset -= sovVerify(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *RequestVerificationHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Signatures) > 0 { - for _, e := range m.Signatures { - l = e.Size() - n += 1 + l + sovVerify(uint64(l)) - } - } - if m.Token != nil { - l = m.Token.Size() - n += 1 + l + sovVerify(uint64(l)) - } - if m.Bearer != nil { - l = m.Bearer.Size() - n += 1 + l + sovVerify(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RequestVerificationHeader_Signature) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sign) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - l = len(m.Peer) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Token) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Token_Info.Size() - n += 1 + l + sovVerify(uint64(l)) - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Token_Info) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovVerify(uint64(l)) - l = m.OwnerID.Size() - n += 1 + l + sovVerify(uint64(l)) - if m.Verb != 0 { - n += 1 + sovVerify(uint64(m.Verb)) - } - l = m.Address.Size() - n += 1 + l + sovVerify(uint64(l)) - l = m.TokenLifetime.Size() - n += 1 + l + sovVerify(uint64(l)) - l = len(m.SessionKey) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - l = len(m.OwnerKey) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *TokenLifetime) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Created != 0 { - n += 1 + sovVerify(uint64(m.Created)) - } - if m.ValidUntil != 0 { - n += 1 + sovVerify(uint64(m.ValidUntil)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BearerTokenMsg) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.BearerTokenMsg_Info.Size() - n += 1 + l + sovVerify(uint64(l)) - l = len(m.OwnerKey) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BearerTokenMsg_Info) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ACLRules) - if l > 0 { - n += 1 + l + sovVerify(uint64(l)) - } - l = m.OwnerID.Size() - n += 1 + l + sovVerify(uint64(l)) - if m.ValidUntil != 0 { - n += 1 + sovVerify(uint64(m.ValidUntil)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovVerify(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozVerify(x uint64) (n int) { - return sovVerify(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RequestVerificationHeader) 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 ErrIntOverflowVerify - } - 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: RequestVerificationHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RequestVerificationHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signatures", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signatures = append(m.Signatures, &RequestVerificationHeader_Signature{}) - if err := m.Signatures[len(m.Signatures)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Token == nil { - m.Token = &Token{} - } - if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bearer", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Bearer == nil { - m.Bearer = &BearerTokenMsg{} - } - if err := m.Bearer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RequestVerificationHeader_Signature) 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 ErrIntOverflowVerify - } - 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: Signature: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Signature: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sign", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sign = append(m.Sign[:0], dAtA[iNdEx:postIndex]...) - if m.Sign == nil { - m.Sign = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Peer", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Peer = append(m.Peer[:0], dAtA[iNdEx:postIndex]...) - if m.Peer == nil { - m.Peer = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Token) 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 ErrIntOverflowVerify - } - 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: Token: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Token: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token_Info", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Token_Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - 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 ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - 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 := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Token_Info) 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 ErrIntOverflowVerify - } - 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: Info: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Info: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Verb", wireType) - } - m.Verb = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Verb |= Token_Info_Verb(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Address.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenLifetime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TokenLifetime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SessionKey = append(m.SessionKey[:0], dAtA[iNdEx:postIndex]...) - if m.SessionKey == nil { - m.SessionKey = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OwnerKey = append(m.OwnerKey[:0], dAtA[iNdEx:postIndex]...) - if m.OwnerKey == nil { - m.OwnerKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TokenLifetime) 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 ErrIntOverflowVerify - } - 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: TokenLifetime: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TokenLifetime: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) - } - m.Created = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Created |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - 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 ErrIntOverflowVerify - } - 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 := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BearerTokenMsg) 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 ErrIntOverflowVerify - } - 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: BearerTokenMsg: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BearerTokenMsg: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BearerTokenMsg_Info", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.BearerTokenMsg_Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OwnerKey = append(m.OwnerKey[:0], dAtA[iNdEx:postIndex]...) - if m.OwnerKey == nil { - m.OwnerKey = []byte{} - } - iNdEx = postIndex - case 3: - 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 ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - 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 := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BearerTokenMsg_Info) 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 ErrIntOverflowVerify - } - 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: Info: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Info: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ACLRules", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ACLRules = append(m.ACLRules[:0], dAtA[iNdEx:postIndex]...) - if m.ACLRules == nil { - m.ACLRules = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerify - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerify - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerify - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - 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 ErrIntOverflowVerify - } - 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 := skipVerify(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerify - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipVerify(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, ErrIntOverflowVerify - } - 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, ErrIntOverflowVerify - } - 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, ErrIntOverflowVerify - } - 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, ErrInvalidLengthVerify - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupVerify - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthVerify - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthVerify = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowVerify = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupVerify = fmt.Errorf("proto: unexpected end of group") -) diff --git a/service/verify.proto b/service/verify.proto deleted file mode 100644 index a7e694f..0000000 --- a/service/verify.proto +++ /dev/null @@ -1,119 +0,0 @@ -syntax = "proto3"; -package service; -option go_package = "github.com/nspcc-dev/neofs-api-go/service"; -option csharp_namespace = "NeoFS.API.Service"; - -import "refs/types.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request -// (should be embedded into message). -message RequestVerificationHeader { - message Signature { - // Sign is signature of the request or session key. - bytes Sign = 1; - // Peer is compressed public key used for signature. - bytes Peer = 2; - } - - // Signatures is a set of signatures of every passed NeoFS Node - repeated Signature Signatures = 1; - - // Token is a token of the session within which the request is sent - Token Token = 2; - - // Bearer is a Bearer token of the request - BearerTokenMsg Bearer = 3; -} - -// User token granting rights for object manipulation -message Token { - message Info { - // ID is a token identifier. valid UUIDv4 represented in bytes - bytes ID = 1 [(gogoproto.customtype) = "TokenID", (gogoproto.nullable) = false]; - - // OwnerID is an owner of manipulation object - bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - - // Verb is an enumeration of session request types - enum Verb { - // Put refers to object.Put RPC call - Put = 0; - // Get refers to object.Get RPC call - Get = 1; - // Head refers to object.Head RPC call - Head = 2; - // Search refers to object.Search RPC call - Search = 3; - // Delete refers to object.Delete RPC call - Delete = 4; - // Range refers to object.GetRange RPC call - Range = 5; - // RangeHash refers to object.GetRangeHash RPC call - RangeHash = 6; - } - - // Verb is a type of request for which the token is issued - Verb verb = 3 [(gogoproto.customname) = "Verb"]; - - // Address is an object address for which token is issued - refs.Address Address = 4 [(gogoproto.nullable) = false, (gogoproto.customtype) = "Address"]; - - // Lifetime is a lifetime of the session - TokenLifetime Lifetime = 5 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - - // SessionKey is a public key of session key - bytes SessionKey = 6; - - // OwnerKey is a public key of the token owner - bytes OwnerKey = 7; - } - - // TokenInfo is a grouped information about token - Info TokenInfo = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - - // Signature is a signature of session token information - bytes Signature = 8; -} - -// TokenLifetime carries a group of lifetime parameters of the token -message TokenLifetime { - // Created carries an initial epoch of token lifetime - uint64 Created = 1; - - // ValidUntil carries a last epoch of token lifetime - uint64 ValidUntil = 2; -} - -// TODO: for variable token types and version redefine message -// Example: -// message Token { -// TokenType TokenType = 1; -// uint32 Version = 2; -// bytes Data = 3; -// } - -// BearerTokenMsg carries information about request ACL rules with limited lifetime -message BearerTokenMsg { - message Info { - // ACLRules carries a binary representation of the table of extended ACL rules - bytes ACLRules = 1; - - // OwnerID is an owner of token - bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; - - // ValidUntil carries a last epoch of token lifetime - uint64 ValidUntil = 3; - } - - // TokenInfo is a grouped information about token - Info TokenInfo = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - - // OwnerKey is a public key of the token owner - bytes OwnerKey = 2; - - // Signature is a signature of token information - bytes Signature = 3; -} diff --git a/service/verify_test.go b/service/verify_test.go deleted file mode 100644 index 5ab8753..0000000 --- a/service/verify_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package service - -import ( - "encoding/binary" - "io" - "math" - "testing" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func (m TestRequest) SignedData() ([]byte, error) { - return SignedDataFromReader(m) -} - -func (m TestRequest) SignedDataSize() (sz int) { - sz += 4 - - sz += len(m.StringField) - - sz += len(m.BytesField) - - sz += m.CustomField.Size() - - return -} - -func (m TestRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - binary.BigEndian.PutUint32(p[off:], uint32(m.IntField)) - off += 4 - - off += copy(p[off:], []byte(m.StringField)) - - off += copy(p[off:], m.BytesField) - - n, err := m.CustomField.MarshalTo(p[off:]) - off += n - - return off, err -} - -func BenchmarkSignDataWithSessionToken(b *testing.B) { - key := test.DecodeKey(0) - - customField := testCustomField{1, 2, 3, 4, 5, 6, 7, 8} - - token := new(Token) - - req := &TestRequest{ - IntField: math.MaxInt32, - StringField: "TestRequestStringField", - BytesField: make([]byte, 1<<22), - CustomField: &customField, - } - - req.SetTTL(math.MaxInt32 - 8) - req.SetEpoch(math.MaxInt64 - 12) - req.SetToken(token) - - b.ResetTimer() - b.ReportAllocs() - - for i := 0; i < b.N; i++ { - require.NoError(b, SignRequestData(key, req)) - } -} - -func BenchmarkVerifyAccumulatedSignaturesWithToken(b *testing.B) { - customField := testCustomField{1, 2, 3, 4, 5, 6, 7, 8} - - token := new(Token) - - req := &TestRequest{ - IntField: math.MaxInt32, - StringField: "TestRequestStringField", - BytesField: make([]byte, 1<<22), - CustomField: &customField, - } - - req.SetTTL(math.MaxInt32 - 8) - req.SetEpoch(math.MaxInt64 - 12) - req.SetToken(token) - - for i := 0; i < 10; i++ { - key := test.DecodeKey(i) - require.NoError(b, SignRequestData(key, req)) - } - - b.ResetTimer() - b.ReportAllocs() - - for i := 0; i < b.N; i++ { - require.NoError(b, VerifyRequestData(req)) - } -} - -func TestRequestVerificationHeader_SetToken(t *testing.T) { - id, err := refs.NewUUID() - require.NoError(t, err) - - token := new(Token) - token.SetID(id) - - h := new(RequestVerificationHeader) - - h.SetToken(token) - - require.Equal(t, token, h.GetToken()) -} - -func TestRequestVerificationHeader_SetBearer(t *testing.T) { - aclRules := []byte{1, 2, 3} - - token := new(BearerTokenMsg) - token.SetACLRules(aclRules) - - h := new(RequestVerificationHeader) - - h.SetBearer(token) - - require.Equal(t, token, h.GetBearer()) -} - -func TestRequestVerificationHeader_GetBearerToken(t *testing.T) { - s := new(RequestVerificationHeader) - - require.Nil(t, s.GetBearerToken()) - - bearer := new(BearerTokenMsg) - s.SetBearer(bearer) - require.Equal(t, bearer, s.GetBearerToken()) -} diff --git a/service/verify_test.pb.go b/service/verify_test.pb.go deleted file mode 100644 index 6bc8748..0000000 --- a/service/verify_test.pb.go +++ /dev/null @@ -1,572 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: service/verify_test.proto - -package service - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -type TestRequest struct { - IntField int32 `protobuf:"varint,1,opt,name=IntField,proto3" json:"IntField,omitempty"` - StringField string `protobuf:"bytes,2,opt,name=StringField,proto3" json:"StringField,omitempty"` - BytesField []byte `protobuf:"bytes,3,opt,name=BytesField,proto3" json:"BytesField,omitempty"` - CustomField *testCustomField `protobuf:"bytes,4,opt,name=CustomField,proto3,customtype=testCustomField" json:"CustomField,omitempty"` - RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - RequestVerificationHeader `protobuf:"bytes,99,opt,name=Header,proto3,embedded=Header" json:"Header"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TestRequest) Reset() { *m = TestRequest{} } -func (m *TestRequest) String() string { return proto.CompactTextString(m) } -func (*TestRequest) ProtoMessage() {} -func (*TestRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1effa83201a30d75, []int{0} -} -func (m *TestRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *TestRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestRequest.Merge(m, src) -} -func (m *TestRequest) XXX_Size() int { - return m.Size() -} -func (m *TestRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TestRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_TestRequest proto.InternalMessageInfo - -func (m *TestRequest) GetIntField() int32 { - if m != nil { - return m.IntField - } - return 0 -} - -func (m *TestRequest) GetStringField() string { - if m != nil { - return m.StringField - } - return "" -} - -func (m *TestRequest) GetBytesField() []byte { - if m != nil { - return m.BytesField - } - return nil -} - -func init() { - proto.RegisterType((*TestRequest)(nil), "service.TestRequest") -} - -func init() { proto.RegisterFile("service/verify_test.proto", fileDescriptor_1effa83201a30d75) } - -var fileDescriptor_1effa83201a30d75 = []byte{ - // 328 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xb1, 0x4e, 0xf3, 0x30, - 0x14, 0x85, 0xeb, 0xfe, 0xfd, 0x4b, 0x71, 0x90, 0x90, 0x0c, 0x43, 0xc9, 0x90, 0x46, 0x9d, 0xc2, - 0x90, 0x44, 0x02, 0x21, 0xb1, 0x21, 0x05, 0x84, 0x60, 0x60, 0x09, 0x88, 0x81, 0x05, 0x25, 0xe9, - 0x6d, 0xb0, 0x44, 0xe3, 0x12, 0xdf, 0x54, 0xea, 0x9b, 0x30, 0xf3, 0x34, 0x1d, 0x3b, 0x22, 0x86, - 0x08, 0x85, 0x17, 0x41, 0x71, 0x0c, 0x0a, 0xb0, 0xf9, 0x9e, 0xf3, 0x1d, 0xdb, 0xf7, 0xd0, 0x3d, - 0x09, 0xf9, 0x82, 0x27, 0xe0, 0x2f, 0x20, 0xe7, 0xd3, 0xe5, 0x3d, 0x82, 0x44, 0x6f, 0x9e, 0x0b, - 0x14, 0x6c, 0x43, 0x5b, 0x26, 0xfb, 0x62, 0x66, 0x80, 0x51, 0x63, 0x9a, 0xbb, 0x3f, 0x73, 0x5a, - 0x75, 0x53, 0x8e, 0x0f, 0x45, 0xec, 0x25, 0x62, 0xe6, 0xa7, 0x22, 0x15, 0xbe, 0x92, 0xe3, 0x62, - 0xaa, 0x26, 0x35, 0xa8, 0x53, 0x83, 0x8f, 0x5f, 0xba, 0xd4, 0xb8, 0x01, 0x89, 0x21, 0x3c, 0x15, - 0x20, 0x91, 0x99, 0x74, 0x70, 0x99, 0xe1, 0x39, 0x87, 0xc7, 0xc9, 0x90, 0xd8, 0xc4, 0xf9, 0x1f, - 0x7e, 0xcf, 0xcc, 0xa6, 0xc6, 0x35, 0xe6, 0x3c, 0x4b, 0x1b, 0xbb, 0x6b, 0x13, 0x67, 0x33, 0x6c, - 0x4b, 0xcc, 0xa2, 0x34, 0x58, 0x22, 0xc8, 0x06, 0xf8, 0x67, 0x13, 0x67, 0x2b, 0x6c, 0x29, 0xec, - 0x88, 0x1a, 0xa7, 0x85, 0x44, 0x31, 0x6b, 0x80, 0x5e, 0x0d, 0x04, 0x3b, 0x6f, 0xe5, 0x68, 0xbb, - 0x5e, 0xba, 0x65, 0x85, 0x6d, 0x8e, 0x1d, 0xd3, 0xde, 0x15, 0x60, 0x34, 0x8c, 0x6d, 0xe2, 0x18, - 0x07, 0xa6, 0xa7, 0x17, 0xf7, 0xf4, 0xa7, 0x6b, 0xef, 0x02, 0xa2, 0x09, 0xe4, 0xc1, 0x60, 0x55, - 0x8e, 0x3a, 0xeb, 0x72, 0x44, 0x42, 0x95, 0x60, 0x67, 0xb4, 0xdf, 0x38, 0xc3, 0x44, 0x65, 0xc7, - 0xbf, 0xb3, 0xb7, 0x75, 0x77, 0x3c, 0x89, 0x90, 0x8b, 0xec, 0xcf, 0x1d, 0x3a, 0x1b, 0x9c, 0xac, - 0x2a, 0x8b, 0xac, 0x2b, 0x8b, 0xbc, 0x56, 0x16, 0x79, 0xaf, 0x2c, 0xf2, 0xfc, 0x61, 0x75, 0xee, - 0xf6, 0x5b, 0x4d, 0x67, 0x72, 0x9e, 0x24, 0xee, 0x04, 0x16, 0x7e, 0x06, 0x62, 0x2a, 0xdd, 0x68, - 0xce, 0xdd, 0x54, 0xf8, 0xfa, 0xb1, 0xb8, 0xaf, 0xca, 0x3e, 0xfc, 0x0c, 0x00, 0x00, 0xff, 0xff, - 0xcb, 0xae, 0x78, 0xc0, 0xeb, 0x01, 0x00, 0x00, -} - -func (m *TestRequest) 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 *TestRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TestRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerifyTest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintVerifyTest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.CustomField != nil { - { - size := m.CustomField.Size() - i -= size - if _, err := m.CustomField.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintVerifyTest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.BytesField) > 0 { - i -= len(m.BytesField) - copy(dAtA[i:], m.BytesField) - i = encodeVarintVerifyTest(dAtA, i, uint64(len(m.BytesField))) - i-- - dAtA[i] = 0x1a - } - if len(m.StringField) > 0 { - i -= len(m.StringField) - copy(dAtA[i:], m.StringField) - i = encodeVarintVerifyTest(dAtA, i, uint64(len(m.StringField))) - i-- - dAtA[i] = 0x12 - } - if m.IntField != 0 { - i = encodeVarintVerifyTest(dAtA, i, uint64(m.IntField)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintVerifyTest(dAtA []byte, offset int, v uint64) int { - offset -= sovVerifyTest(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *TestRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IntField != 0 { - n += 1 + sovVerifyTest(uint64(m.IntField)) - } - l = len(m.StringField) - if l > 0 { - n += 1 + l + sovVerifyTest(uint64(l)) - } - l = len(m.BytesField) - if l > 0 { - n += 1 + l + sovVerifyTest(uint64(l)) - } - if m.CustomField != nil { - l = m.CustomField.Size() - n += 1 + l + sovVerifyTest(uint64(l)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovVerifyTest(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovVerifyTest(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovVerifyTest(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozVerifyTest(x uint64) (n int) { - return sovVerifyTest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *TestRequest) 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 ErrIntOverflowVerifyTest - } - 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: TestRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TestRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IntField", wireType) - } - m.IntField = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.IntField |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StringField", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - 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 ErrInvalidLengthVerifyTest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthVerifyTest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StringField = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BytesField", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerifyTest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerifyTest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BytesField = append(m.BytesField[:0], dAtA[iNdEx:postIndex]...) - if m.BytesField == nil { - m.BytesField = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CustomField", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthVerifyTest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthVerifyTest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v testCustomField - m.CustomField = &v - if err := m.CustomField.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerifyTest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerifyTest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowVerifyTest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthVerifyTest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthVerifyTest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipVerifyTest(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthVerifyTest - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthVerifyTest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipVerifyTest(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, ErrIntOverflowVerifyTest - } - 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, ErrIntOverflowVerifyTest - } - 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, ErrIntOverflowVerifyTest - } - 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, ErrInvalidLengthVerifyTest - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupVerifyTest - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthVerifyTest - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthVerifyTest = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowVerifyTest = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupVerifyTest = fmt.Errorf("proto: unexpected end of group") -) diff --git a/service/verify_test.proto b/service/verify_test.proto deleted file mode 100644 index 901d6fd..0000000 --- a/service/verify_test.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; -package service; -option go_package = "github.com/nspcc-dev/neofs-api-go/service"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -message TestRequest { - int32 IntField = 1; - string StringField = 2; - bytes BytesField = 3; - bytes CustomField = 4 [(gogoproto.customtype) = "testCustomField"]; - RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - RequestVerificationHeader Header = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} diff --git a/service/version.go b/service/version.go deleted file mode 100644 index 6f4839c..0000000 --- a/service/version.go +++ /dev/null @@ -1,11 +0,0 @@ -package service - -// SetVersion is a Version field setter. -func (m *ResponseMetaHeader) SetVersion(v uint32) { - m.Version = v -} - -// SetVersion is a Version field setter. -func (m *RequestMetaHeader) SetVersion(v uint32) { - m.Version = v -} diff --git a/service/version_test.go b/service/version_test.go deleted file mode 100644 index d102d30..0000000 --- a/service/version_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package service - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestGetSetVersion(t *testing.T) { - v := uint32(7) - - items := []VersionContainer{ - new(ResponseMetaHeader), - new(RequestMetaHeader), - } - - for _, item := range items { - item.SetVersion(v) - require.Equal(t, v, item.GetVersion()) - } -} diff --git a/session/alias.go b/session/alias.go deleted file mode 100644 index aa49d55..0000000 --- a/session/alias.go +++ /dev/null @@ -1,15 +0,0 @@ -package session - -import ( - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/service" -) - -// OwnerID is a type alias of OwnerID ref. -type OwnerID = refs.OwnerID - -// TokenID is a type alias of TokenID ref. -type TokenID = service.TokenID - -// Token is a type alias of Token. -type Token = service.Token diff --git a/session/create.go b/session/create.go deleted file mode 100644 index 412d1fd..0000000 --- a/session/create.go +++ /dev/null @@ -1,62 +0,0 @@ -package session - -import ( - "context" - "crypto/ecdsa" - - "github.com/nspcc-dev/neofs-api-go/service" - crypto "github.com/nspcc-dev/neofs-crypto" - "google.golang.org/grpc" -) - -type gRPCCreator struct { - conn *grpc.ClientConn - - key *ecdsa.PrivateKey - - clientFunc func(*grpc.ClientConn) SessionClient -} - -// NewGRPCCreator unites virtual gRPC client with private ket and returns Creator interface. -// -// If passed ClientConn is nil, ErrNilGPRCClientConn returns. -// If passed private key is nil, crypto.ErrEmptyPrivateKey returns. -func NewGRPCCreator(conn *grpc.ClientConn, key *ecdsa.PrivateKey) (Creator, error) { - if conn == nil { - return nil, ErrNilGPRCClientConn - } else if key == nil { - return nil, crypto.ErrEmptyPrivateKey - } - - return &gRPCCreator{ - conn: conn, - - key: key, - - clientFunc: NewSessionClient, - }, nil -} - -// Create constructs message, signs it with private key and sends it to a gRPC client. -// -// If passed CreateParamsSource is nil, ErrNilCreateParamsSource returns. -// If message could not be signed, an error returns. -func (s gRPCCreator) Create(ctx context.Context, p CreateParamsSource) (CreateResult, error) { - if p == nil { - return nil, ErrNilCreateParamsSource - } - - // create and fill a message - req := new(CreateRequest) - req.SetOwnerID(p.GetOwnerID()) - req.SetCreationEpoch(p.CreationEpoch()) - req.SetExpirationEpoch(p.ExpirationEpoch()) - - // sign with private key - if err := service.SignRequestData(s.key, req); err != nil { - return nil, err - } - - // make gRPC call - return s.clientFunc(s.conn).Create(ctx, req) -} diff --git a/session/create_test.go b/session/create_test.go deleted file mode 100644 index 943c5da..0000000 --- a/session/create_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package session - -import ( - "context" - "crypto/ecdsa" - "testing" - - "github.com/nspcc-dev/neofs-api-go/service" - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" -) - -type testSessionClient struct { - fn func(*CreateRequest) - resp *CreateResponse - err error -} - -func (s testSessionClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - if s.fn != nil { - s.fn(in) - } - - return s.resp, s.err -} - -func TestNewGRPCCreator(t *testing.T) { - var ( - err error - conn = new(grpc.ClientConn) - sk = new(ecdsa.PrivateKey) - ) - - // nil client connection - _, err = NewGRPCCreator(nil, sk) - require.EqualError(t, err, ErrNilGPRCClientConn.Error()) - - // nil private key - _, err = NewGRPCCreator(conn, nil) - require.EqualError(t, err, crypto.ErrEmptyPrivateKey.Error()) - - // valid params - res, err := NewGRPCCreator(conn, sk) - require.NoError(t, err) - - v := res.(*gRPCCreator) - require.Equal(t, conn, v.conn) - require.Equal(t, sk, v.key) - require.NotNil(t, v.clientFunc) -} - -func TestGRPCCreator_Create(t *testing.T) { - ctx := context.TODO() - s := new(gRPCCreator) - - // nil CreateParamsSource - _, err := s.Create(ctx, nil) - require.EqualError(t, err, ErrNilCreateParamsSource.Error()) - - var ( - ownerID = OwnerID{1, 2, 3} - created = uint64(2) - expired = uint64(4) - ) - - p := NewParams() - p.SetOwnerID(ownerID) - p.SetCreationEpoch(created) - p.SetExpirationEpoch(expired) - - // nil private key - _, err = s.Create(ctx, p) - require.Error(t, err) - - // create test private key - s.key = test.DecodeKey(0) - - // create test client - c := &testSessionClient{ - fn: func(req *CreateRequest) { - require.Equal(t, ownerID, req.GetOwnerID()) - require.Equal(t, created, req.CreationEpoch()) - require.Equal(t, expired, req.ExpirationEpoch()) - require.NoError(t, service.VerifyRequestData(req)) - }, - resp: &CreateResponse{ - ID: TokenID{1, 2, 3}, - SessionKey: []byte{1, 2, 3}, - }, - err: errors.New("test error"), - } - - s.clientFunc = func(*grpc.ClientConn) SessionClient { - return c - } - - res, err := s.Create(ctx, p) - require.EqualError(t, err, c.err.Error()) - require.Equal(t, c.resp, res) -} diff --git a/session/errors.go b/session/errors.go deleted file mode 100644 index d35bed4..0000000 --- a/session/errors.go +++ /dev/null @@ -1,19 +0,0 @@ -package session - -import "github.com/nspcc-dev/neofs-api-go/internal" - -// ErrNilCreateParamsSource is returned by functions that expect a non-nil -// CreateParamsSource, but received nil. -const ErrNilCreateParamsSource = internal.Error("create params source is nil") - -// ErrNilGPRCClientConn is returned by functions that expect a non-nil -// grpc.ClientConn, but received nil. -const ErrNilGPRCClientConn = internal.Error("gRPC client connection is nil") - -// ErrPrivateTokenNotFound is returned when addressed private token was -// not found in storage. -const ErrPrivateTokenNotFound = internal.Error("private token not found") - -// ErrNilPrivateToken is returned by functions that expect a non-nil -// PrivateToken, but received nil. -const ErrNilPrivateToken = internal.Error("private token is nil") diff --git a/session/private.go b/session/private.go deleted file mode 100644 index bb9242f..0000000 --- a/session/private.go +++ /dev/null @@ -1,67 +0,0 @@ -package session - -import ( - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - - crypto "github.com/nspcc-dev/neofs-crypto" -) - -type pToken struct { - // private session token - sessionKey *ecdsa.PrivateKey - // last epoch of the lifetime - validUntil uint64 -} - -// NewPrivateToken creates PrivateToken instance that expires after passed epoch. -// -// Returns non-nil error on key generation error. -func NewPrivateToken(validUntil uint64) (PrivateToken, error) { - sk, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, err - } - - return &pToken{ - sessionKey: sk, - validUntil: validUntil, - }, nil -} - -// PublicSessionToken returns a binary representation of session public key. -// -// If passed PrivateToken is nil, ErrNilPrivateToken returns. -// If passed PrivateToken carries nil private key, crypto.ErrEmptyPrivateKey returns. -func PublicSessionToken(pToken PrivateToken) ([]byte, error) { - if pToken == nil { - return nil, ErrNilPrivateToken - } - - sk := pToken.PrivateKey() - if sk == nil { - return nil, crypto.ErrEmptyPrivateKey - } - - return crypto.MarshalPublicKey(&sk.PublicKey), nil -} - -// PrivateKey is a session private key getter. -func (t *pToken) PrivateKey() *ecdsa.PrivateKey { - return t.sessionKey -} - -func (t *pToken) Expired(epoch uint64) bool { - return t.validUntil < epoch -} - -// SetOwnerID is an owner ID field setter. -func (s *PrivateTokenKey) SetOwnerID(id OwnerID) { - s.owner = id -} - -// SetTokenID is a token ID field setter. -func (s *PrivateTokenKey) SetTokenID(id TokenID) { - s.token = id -} diff --git a/session/private_test.go b/session/private_test.go deleted file mode 100644 index c6f8125..0000000 --- a/session/private_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package session - -import ( - "testing" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/stretchr/testify/require" -) - -func TestPToken_PrivateKey(t *testing.T) { - // create new private token - pToken, err := NewPrivateToken(0) - require.NoError(t, err) - require.NotNil(t, pToken.PrivateKey()) -} - -func TestPToken_Expired(t *testing.T) { - e := uint64(10) - - var token PrivateToken = &pToken{ - validUntil: e, - } - - // must not be expired in the epoch before last - require.False(t, token.Expired(e-1)) - - // must not be expired in the last epoch - require.False(t, token.Expired(e)) - - // must be expired in the epoch after last - require.True(t, token.Expired(e+1)) -} - -func TestPrivateTokenKey_SetOwnerID(t *testing.T) { - ownerID := OwnerID{1, 2, 3} - - s := new(PrivateTokenKey) - - s.SetOwnerID(ownerID) - - require.Equal(t, ownerID, s.owner) -} - -func TestPrivateTokenKey_SetTokenID(t *testing.T) { - tokenID := TokenID{1, 2, 3} - - s := new(PrivateTokenKey) - - s.SetTokenID(tokenID) - - require.Equal(t, tokenID, s.token) -} - -func TestPublicSessionToken(t *testing.T) { - var err error - - // nil PrivateToken - _, err = PublicSessionToken(nil) - require.EqualError(t, err, ErrNilPrivateToken.Error()) - - // empty private key - var pToken PrivateToken = new(pToken) - _, err = PublicSessionToken(pToken) - require.EqualError(t, err, crypto.ErrEmptyPrivateKey.Error()) - - // correct PrivateToken - pToken, err = NewPrivateToken(0) - require.NoError(t, err) - - key := pToken.PrivateKey() - require.NotNil(t, key) - - res, err := PublicSessionToken(pToken) - require.NoError(t, err) - require.Equal(t, res, crypto.MarshalPublicKey(&key.PublicKey)) -} diff --git a/session/request.go b/session/request.go deleted file mode 100644 index 73c05e5..0000000 --- a/session/request.go +++ /dev/null @@ -1,62 +0,0 @@ -package session - -import ( - "encoding/binary" - "io" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/service" -) - -const signedRequestDataSize = 0 + - refs.OwnerIDSize + - 8 + - 8 - -var requestEndianness = binary.BigEndian - -// NewParams creates a new CreateRequest message and returns CreateParamsContainer interface. -func NewParams() CreateParamsContainer { - return new(CreateRequest) -} - -// GetOwnerID is an OwnerID field getter. -func (m CreateRequest) GetOwnerID() OwnerID { - return m.OwnerID -} - -// SetOwnerID is an OwnerID field setter. -func (m *CreateRequest) SetOwnerID(id OwnerID) { - m.OwnerID = id -} - -// SignedData returns payload bytes of the request. -func (m CreateRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m CreateRequest) SignedDataSize() int { - return signedRequestDataSize -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the buffer size is insufficient, io.ErrUnexpectedEOF returns. -func (m CreateRequest) ReadSignedData(p []byte) (int, error) { - sz := m.SignedDataSize() - if len(p) < sz { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetOwnerID().Bytes()) - - requestEndianness.PutUint64(p[off:], m.CreationEpoch()) - off += 8 - - requestEndianness.PutUint64(p[off:], m.ExpirationEpoch()) - - return sz, nil -} diff --git a/session/request_test.go b/session/request_test.go deleted file mode 100644 index 094ca66..0000000 --- a/session/request_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package session - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestCreateRequestGettersSetters(t *testing.T) { - t.Run("owner ID", func(t *testing.T) { - id := OwnerID{1, 2, 3} - m := new(CreateRequest) - - m.SetOwnerID(id) - - require.Equal(t, id, m.GetOwnerID()) - }) - - t.Run("lifetime", func(t *testing.T) { - e1, e2 := uint64(3), uint64(4) - m := new(CreateRequest) - - m.SetCreationEpoch(e1) - m.SetExpirationEpoch(e2) - - require.Equal(t, e1, m.CreationEpoch()) - require.Equal(t, e2, m.ExpirationEpoch()) - }) -} - -func TestCreateRequest_SignedData(t *testing.T) { - var ( - id = OwnerID{1, 2, 3} - e1 = uint64(1) - e2 = uint64(2) - ) - - // create new message - m := new(CreateRequest) - - // fill the fields - m.SetOwnerID(id) - m.SetCreationEpoch(e1) - m.SetExpirationEpoch(e2) - - // calculate initial signed data - d, err := m.SignedData() - require.NoError(t, err) - - items := []struct { - change func() - reset func() - }{ - { // OwnerID - change: func() { - id2 := id - id2[0]++ - m.SetOwnerID(id2) - }, - reset: func() { - m.SetOwnerID(id) - }, - }, - { // CreationEpoch - change: func() { - m.SetCreationEpoch(e1 + 1) - }, - reset: func() { - m.SetCreationEpoch(e1) - }, - }, - { // ExpirationEpoch - change: func() { - m.SetExpirationEpoch(e2 + 1) - }, - reset: func() { - m.SetExpirationEpoch(e2) - }, - }, - } - - for _, item := range items { - item.change() - - d2, err := m.SignedData() - require.NoError(t, err) - - require.NotEqual(t, d, d2) - - item.reset() - } -} diff --git a/session/response.go b/session/response.go deleted file mode 100644 index 3426d7c..0000000 --- a/session/response.go +++ /dev/null @@ -1,16 +0,0 @@ -package session - -// GetID is an ID field getter. -func (m CreateResponse) GetID() TokenID { - return m.ID -} - -// SetID is an ID field setter. -func (m *CreateResponse) SetID(id TokenID) { - m.ID = id -} - -// SetSessionKey is a SessionKey field setter. -func (m *CreateResponse) SetSessionKey(key []byte) { - m.SessionKey = key -} diff --git a/session/response_test.go b/session/response_test.go deleted file mode 100644 index 0e1de0b..0000000 --- a/session/response_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package session - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestCreateResponseGettersSetters(t *testing.T) { - t.Run("id", func(t *testing.T) { - id := TokenID{1, 2, 3} - m := new(CreateResponse) - - m.SetID(id) - - require.Equal(t, id, m.GetID()) - }) - - t.Run("session key", func(t *testing.T) { - key := []byte{1, 2, 3} - m := new(CreateResponse) - - m.SetSessionKey(key) - - require.Equal(t, key, m.GetSessionKey()) - }) -} diff --git a/session/service.pb.go b/session/service.pb.go deleted file mode 100644 index e68c0fd..0000000 --- a/session/service.pb.go +++ /dev/null @@ -1,800 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: session/service.proto - -package session - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -// CreateRequest carries an information necessary for opening a session -type CreateRequest struct { - // OwnerID carries an identifier of a session initiator - OwnerID OwnerID `protobuf:"bytes,1,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` - // Lifetime carries a lifetime of the session - service.TokenLifetime `protobuf:"bytes,2,opt,name=Lifetime,proto3,embedded=Lifetime" json:"Lifetime"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRequest) Reset() { *m = CreateRequest{} } -func (m *CreateRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRequest) ProtoMessage() {} -func (*CreateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b329bee0fd1148e0, []int{0} -} -func (m *CreateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *CreateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRequest.Merge(m, src) -} -func (m *CreateRequest) XXX_Size() int { - return m.Size() -} -func (m *CreateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRequest proto.InternalMessageInfo - -// CreateResponse carries an information about the opened session -type CreateResponse struct { - // ID carries an identifier of session token - ID TokenID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=TokenID" json:"ID"` - // SessionKey carries a session public key - SessionKey []byte `protobuf:"bytes,2,opt,name=SessionKey,proto3" json:"SessionKey,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateResponse) Reset() { *m = CreateResponse{} } -func (m *CreateResponse) String() string { return proto.CompactTextString(m) } -func (*CreateResponse) ProtoMessage() {} -func (*CreateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b329bee0fd1148e0, []int{1} -} -func (m *CreateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *CreateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateResponse.Merge(m, src) -} -func (m *CreateResponse) XXX_Size() int { - return m.Size() -} -func (m *CreateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateResponse proto.InternalMessageInfo - -func (m *CreateResponse) GetSessionKey() []byte { - if m != nil { - return m.SessionKey - } - return nil -} - -func init() { - proto.RegisterType((*CreateRequest)(nil), "session.CreateRequest") - proto.RegisterType((*CreateResponse)(nil), "session.CreateResponse") -} - -func init() { proto.RegisterFile("session/service.proto", fileDescriptor_b329bee0fd1148e0) } - -var fileDescriptor_b329bee0fd1148e0 = []byte{ - // 386 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xcf, 0x6e, 0xda, 0x40, - 0x10, 0xc6, 0x59, 0xab, 0x02, 0xb4, 0xa5, 0xad, 0xba, 0xea, 0x1f, 0xcb, 0x07, 0x1b, 0x71, 0x82, - 0x83, 0x6d, 0x89, 0x5e, 0x5a, 0xa9, 0x97, 0x52, 0xab, 0xaa, 0xd5, 0xe6, 0x9f, 0x89, 0x72, 0xc8, - 0xcd, 0x36, 0x63, 0x67, 0x15, 0xe1, 0x75, 0xbc, 0x0b, 0x11, 0x6f, 0x92, 0x67, 0xc8, 0x93, 0x70, - 0xe4, 0x18, 0xe5, 0x80, 0x22, 0xe7, 0x25, 0x72, 0x8c, 0x58, 0xaf, 0x11, 0x09, 0xb7, 0x9d, 0xdf, - 0xec, 0xf7, 0x69, 0xbe, 0x19, 0xfc, 0x99, 0x03, 0xe7, 0x94, 0x65, 0x2e, 0x87, 0x62, 0x4e, 0x63, - 0x70, 0xf2, 0x82, 0x09, 0x46, 0x5a, 0x0a, 0x1b, 0x44, 0x71, 0x77, 0x0a, 0x22, 0xac, 0x9a, 0xc6, - 0xa7, 0x9a, 0xcd, 0xa1, 0xa0, 0xc9, 0x42, 0x51, 0x3b, 0xa5, 0xe2, 0x62, 0x16, 0x39, 0x31, 0x9b, - 0xba, 0x29, 0x4b, 0x99, 0x2b, 0x71, 0x34, 0x4b, 0x64, 0x25, 0x0b, 0xf9, 0xaa, 0xbe, 0xf7, 0x9e, - 0x10, 0x7e, 0xf7, 0xbb, 0x80, 0x50, 0x40, 0x00, 0x57, 0x33, 0xe0, 0x82, 0x0c, 0x70, 0xeb, 0xe8, - 0x3a, 0x83, 0xc2, 0xf7, 0x74, 0xd4, 0x45, 0xfd, 0xce, 0xe8, 0xc3, 0x72, 0x6d, 0x35, 0xee, 0xd7, - 0x56, 0x8d, 0x83, 0xfa, 0x41, 0x7e, 0xe2, 0xf6, 0x7f, 0x9a, 0x80, 0xa0, 0x53, 0xd0, 0xb5, 0x2e, - 0xea, 0xbf, 0x1d, 0x7e, 0x71, 0xea, 0x00, 0xa7, 0xec, 0x12, 0xb2, 0xba, 0x3b, 0x6a, 0x6f, 0x3c, - 0x56, 0x6b, 0x0b, 0x05, 0x5b, 0x05, 0xf9, 0x8e, 0xdf, 0x1c, 0x80, 0x08, 0xf5, 0x48, 0x2a, 0x8d, - 0xad, 0x52, 0x0d, 0xb2, 0xe9, 0xfd, 0x85, 0x70, 0x02, 0xc5, 0x8e, 0x5a, 0x2a, 0x88, 0x87, 0x9b, - 0x67, 0x32, 0xb3, 0x1e, 0x4b, 0x6d, 0xef, 0xb5, 0x56, 0x76, 0x69, 0x1c, 0x0a, 0xca, 0xb2, 0x3d, - 0x0f, 0xa5, 0xed, 0x9d, 0xe0, 0xf7, 0x75, 0x72, 0x9e, 0xb3, 0x8c, 0x03, 0xb1, 0xb0, 0xb6, 0x9f, - 0x5a, 0x06, 0xf1, 0xbd, 0x40, 0xf3, 0x3d, 0x62, 0x62, 0x3c, 0xae, 0x2e, 0xf2, 0x0f, 0x16, 0x32, - 0x72, 0x27, 0xd8, 0x21, 0x43, 0x0f, 0xb7, 0x54, 0x45, 0x7e, 0xe0, 0x66, 0xe5, 0x4e, 0x36, 0x3b, - 0x91, 0xcc, 0x79, 0xb1, 0x68, 0xe3, 0xeb, 0x1e, 0xaf, 0xc6, 0x18, 0x8d, 0x97, 0xa5, 0x89, 0x56, - 0xa5, 0x89, 0xee, 0x4a, 0x13, 0x3d, 0x94, 0x26, 0xba, 0x79, 0x34, 0x1b, 0xe7, 0x83, 0x9d, 0xc3, - 0x66, 0x3c, 0x8f, 0x63, 0x7b, 0x02, 0x73, 0x37, 0x03, 0x96, 0x70, 0x3b, 0xcc, 0xa9, 0x9d, 0x32, - 0x57, 0xf9, 0xdd, 0x6a, 0x1f, 0x0f, 0x81, 0xfd, 0x19, 0x3b, 0xbf, 0x8e, 0x7d, 0x47, 0xcd, 0x13, - 0x35, 0xe5, 0xbd, 0xbf, 0x3d, 0x07, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x66, 0xc9, 0x19, 0x6a, 0x02, - 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// SessionClient is the client API for Session service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type SessionClient interface { - // Create opens new session between the client and the server - Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) -} - -type sessionClient struct { - cc *grpc.ClientConn -} - -func NewSessionClient(cc *grpc.ClientConn) SessionClient { - return &sessionClient{cc} -} - -func (c *sessionClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - out := new(CreateResponse) - err := c.cc.Invoke(ctx, "/session.Session/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// SessionServer is the server API for Session service. -type SessionServer interface { - // Create opens new session between the client and the server - Create(context.Context, *CreateRequest) (*CreateResponse, error) -} - -// UnimplementedSessionServer can be embedded to have forward compatible implementations. -type UnimplementedSessionServer struct { -} - -func (*UnimplementedSessionServer) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} - -func RegisterSessionServer(s *grpc.Server, srv SessionServer) { - s.RegisterService(&_Session_serviceDesc, srv) -} - -func _Session_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SessionServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/session.Session/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SessionServer).Create(ctx, req.(*CreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Session_serviceDesc = grpc.ServiceDesc{ - ServiceName: "session.Session", - HandlerType: (*SessionServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Session_Create_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "session/service.proto", -} - -func (m *CreateRequest) 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 *CreateRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CreateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - { - size, err := m.TokenLifetime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.OwnerID.Size() - i -= size - if _, err := m.OwnerID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *CreateResponse) 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 *CreateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.SessionKey) > 0 { - i -= len(m.SessionKey) - copy(dAtA[i:], m.SessionKey) - i = encodeVarintService(dAtA, i, uint64(len(m.SessionKey))) - i-- - dAtA[i] = 0x12 - } - { - size := m.ID.Size() - i -= size - if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *CreateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.OwnerID.Size() - n += 1 + l + sovService(uint64(l)) - l = m.TokenLifetime.Size() - n += 1 + l + sovService(uint64(l)) - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *CreateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ID.Size() - n += 1 + l + sovService(uint64(l)) - l = len(m.SessionKey) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *CreateRequest) 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 ErrIntOverflowService - } - 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: CreateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CreateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OwnerID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenLifetime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TokenLifetime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CreateResponse) 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 ErrIntOverflowService - } - 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: CreateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CreateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SessionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SessionKey = append(m.SessionKey[:0], dAtA[iNdEx:postIndex]...) - if m.SessionKey == nil { - m.SessionKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/session/service.proto b/session/service.proto deleted file mode 100644 index b7eb0df..0000000 --- a/session/service.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; -package session; -option go_package = "github.com/nspcc-dev/neofs-api-go/session"; -option csharp_namespace = "NeoFS.API.Session"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - - -service Session { - // Create opens new session between the client and the server - rpc Create (CreateRequest) returns (CreateResponse); -} - -// CreateRequest carries an information necessary for opening a session -message CreateRequest { - // OwnerID carries an identifier of a session initiator - bytes OwnerID = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "OwnerID"]; - - // Lifetime carries a lifetime of the session - service.TokenLifetime Lifetime = 2 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// CreateResponse carries an information about the opened session -message CreateResponse { - // ID carries an identifier of session token - bytes ID = 1 [(gogoproto.customtype) = "TokenID", (gogoproto.nullable) = false]; - - // SessionKey carries a session public key - bytes SessionKey = 2; -} diff --git a/session/store.go b/session/store.go deleted file mode 100644 index fa33b7e..0000000 --- a/session/store.go +++ /dev/null @@ -1,64 +0,0 @@ -package session - -import ( - "sync" -) - -type mapTokenStore struct { - *sync.RWMutex - - tokens map[PrivateTokenKey]PrivateToken -} - -// NewMapTokenStore creates new PrivateTokenStore instance. -// -// The elements of the instance are stored in the map. -func NewMapTokenStore() PrivateTokenStore { - return &mapTokenStore{ - RWMutex: new(sync.RWMutex), - tokens: make(map[PrivateTokenKey]PrivateToken), - } -} - -// Store adds passed token to the map. -// -// Resulting error is always nil. -func (s *mapTokenStore) Store(key PrivateTokenKey, token PrivateToken) error { - s.Lock() - s.tokens[key] = token - s.Unlock() - - return nil -} - -// Fetch returns the map element corresponding to the given key. -// -// Returns ErrPrivateTokenNotFound is there is no element in map. -func (s *mapTokenStore) Fetch(key PrivateTokenKey) (PrivateToken, error) { - s.RLock() - defer s.RUnlock() - - t, ok := s.tokens[key] - if !ok { - return nil, ErrPrivateTokenNotFound - } - - return t, nil -} - -// RemoveExpired removes all the map elements that are expired in the passed epoch. -// -// Resulting error is always nil. -func (s *mapTokenStore) RemoveExpired(epoch uint64) error { - s.Lock() - - for key, token := range s.tokens { - if token.Expired(epoch) { - delete(s.tokens, key) - } - } - - s.Unlock() - - return nil -} diff --git a/session/store_test.go b/session/store_test.go deleted file mode 100644 index 74e0023..0000000 --- a/session/store_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package session - -import ( - "testing" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/stretchr/testify/require" -) - -func TestMapTokenStore(t *testing.T) { - // create new private token - pToken, err := NewPrivateToken(0) - require.NoError(t, err) - - // create map token store - s := NewMapTokenStore() - - // create test TokenID - tid, err := refs.NewUUID() - require.NoError(t, err) - - // create test OwnerID - ownerID := OwnerID{1, 2, 3} - - key := PrivateTokenKey{} - key.SetOwnerID(ownerID) - key.SetTokenID(tid) - - // ascertain that there is no record for the key - _, err = s.Fetch(key) - require.EqualError(t, err, ErrPrivateTokenNotFound.Error()) - - // save private token record - require.NoError(t, s.Store(key, pToken)) - - // fetch private token by the key - res, err := s.Fetch(key) - require.NoError(t, err) - - // ascertain that returned token equals to initial - require.Equal(t, pToken, res) -} - -func TestMapTokenStore_RemoveExpired(t *testing.T) { - // create some epoch number - e1 := uint64(1) - - // create private token that expires after e1 - tok1, err := NewPrivateToken(e1) - require.NoError(t, err) - - // create some greater than e1 epoch number - e2 := e1 + 1 - - // create private token that expires after e2 - tok2, err := NewPrivateToken(e2) - require.NoError(t, err) - - // create token store instance - s := NewMapTokenStore() - - // create test PrivateTokenKey - key := PrivateTokenKey{} - key.SetOwnerID(OwnerID{1, 2, 3}) - - // create IDs for tokens - id1, err := refs.NewUUID() - require.NoError(t, err) - id2, err := refs.NewUUID() - require.NoError(t, err) - - assertPresence := func(ids ...TokenID) { - for i := range ids { - key.SetTokenID(ids[i]) - _, err = s.Fetch(key) - require.NoError(t, err) - } - } - - assertAbsence := func(ids ...TokenID) { - for i := range ids { - key.SetTokenID(ids[i]) - _, err = s.Fetch(key) - require.EqualError(t, err, ErrPrivateTokenNotFound.Error()) - } - } - - // store both tokens - key.SetTokenID(id1) - require.NoError(t, s.Store(key, tok1)) - key.SetTokenID(id2) - require.NoError(t, s.Store(key, tok2)) - - // ascertain that both tokens are available - assertPresence(id1, id2) - - // perform cleaning for epoch in which both tokens are not expired - require.NoError(t, s.RemoveExpired(e1)) - - // ascertain that both tokens are still available - assertPresence(id1, id2) - - // perform cleaning for epoch greater than e1 and not greater than e2 - require.NoError(t, s.RemoveExpired(e1+1)) - - // ascertain that tok1 was removed - assertAbsence(id1) - - // ascertain that tok2 was not removed - assertPresence(id2) -} diff --git a/session/types.go b/session/types.go deleted file mode 100644 index 95a0065..0000000 --- a/session/types.go +++ /dev/null @@ -1,80 +0,0 @@ -package session - -import ( - "context" - "crypto/ecdsa" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-api-go/service" -) - -// PrivateToken is an interface of session private part. -type PrivateToken interface { - // PrivateKey must return session private key. - PrivateKey() *ecdsa.PrivateKey - - // Expired must return true if and only if private token is expired in the given epoch number. - Expired(uint64) bool -} - -// PrivateTokenKey is a structure of private token storage key. -type PrivateTokenKey struct { - owner OwnerID - token TokenID -} - -// PrivateTokenSource is an interface of private token storage with read access. -type PrivateTokenSource interface { - // Fetch must return the storage record corresponding to the passed key. - // - // Resulting error must be ErrPrivateTokenNotFound if there is no corresponding record. - Fetch(PrivateTokenKey) (PrivateToken, error) -} - -// EpochLifetimeStore is an interface of the storage of elements that lifetime is limited by NeoFS epoch. -type EpochLifetimeStore interface { - // RemoveExpired must remove all elements that are expired in the given epoch. - RemoveExpired(uint64) error -} - -// PrivateTokenStore is an interface of the storage of private tokens addressable by TokenID. -type PrivateTokenStore interface { - PrivateTokenSource - EpochLifetimeStore - - // Store must save passed private token in the storage under the given key. - // - // Resulting error must be nil if private token was stored successfully. - Store(PrivateTokenKey, PrivateToken) error -} - -// KeyStore is an interface of the storage of public keys addressable by OwnerID, -type KeyStore interface { - // Get must return the storage record corresponding to the passed key. - // - // Resulting error must be ErrKeyNotFound if there is no corresponding record. - Get(context.Context, OwnerID) ([]*ecdsa.PublicKey, error) -} - -// CreateParamsSource is an interface of the container of session parameters with read access. -type CreateParamsSource interface { - refs.OwnerIDSource - service.LifetimeSource -} - -// CreateParamsContainer is an interface of the container of session parameters. -type CreateParamsContainer interface { - refs.OwnerIDContainer - service.LifetimeContainer -} - -// CreateResult is an interface of the container of an opened session info with read access. -type CreateResult interface { - service.TokenIDSource - service.SessionKeySource -} - -// Creator is an interface of the tool for a session opening. -type Creator interface { - Create(context.Context, CreateParamsSource) (CreateResult, error) -} diff --git a/state/service.go b/state/service.go deleted file mode 100644 index 577046c..0000000 --- a/state/service.go +++ /dev/null @@ -1,88 +0,0 @@ -package state - -import ( - "bytes" - "encoding/json" - "expvar" - "fmt" - - "github.com/golang/protobuf/proto" - "github.com/prometheus/client_golang/prometheus" - dto "github.com/prometheus/client_model/go" - "github.com/spf13/viper" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// MetricFamily is type alias for proto.Message generated -// from github.com/prometheus/client_model/metrics.proto. -type MetricFamily = dto.MetricFamily - -// EncodeMetrics encodes metrics from gatherer into MetricsResponse message, -// if something went wrong returns gRPC Status error (can be returned from service). -func EncodeMetrics(g prometheus.Gatherer) (*MetricsResponse, error) { - metrics, err := g.Gather() - if err != nil { - return nil, status.New(codes.Internal, err.Error()).Err() - } - - results := make([][]byte, 0, len(metrics)) - for _, mf := range metrics { - item, err := proto.Marshal(mf) - if err != nil { - return nil, status.New(codes.Internal, err.Error()).Err() - } - - results = append(results, item) - } - - return &MetricsResponse{Metrics: results}, nil -} - -// DecodeMetrics decodes metrics from MetricsResponse to []MetricFamily, -// if something went wrong returns error. -func DecodeMetrics(r *MetricsResponse) ([]*MetricFamily, error) { - metrics := make([]*dto.MetricFamily, 0, len(r.Metrics)) - for i := range r.Metrics { - mf := new(MetricFamily) - if err := proto.Unmarshal(r.Metrics[i], mf); err != nil { - return nil, err - } - metrics = append(metrics, mf) - } - - return metrics, nil -} - -// EncodeConfig encodes viper settings into DumpConfig message, -// if something went wrong returns gRPC Status error (can be returned from service). -func EncodeConfig(v *viper.Viper) (*DumpResponse, error) { - data, err := json.Marshal(v.AllSettings()) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &DumpResponse{Config: data}, nil -} - -// EncodeVariables encodes debug variables into DumpVarsResponse message. -// Variables encoded into JSON and stored as slice of bytes. -func EncodeVariables() *DumpVarsResponse { - buf := new(bytes.Buffer) - buf.WriteString("{\n") - first := true - - expvar.Do(func(kv expvar.KeyValue) { - if !first { - buf.WriteString(",\n") - } - - first = false - - _, _ = fmt.Fprintf(buf, "%q: %s", kv.Key, kv.Value) - }) - - buf.WriteString("\n}\n") - - return &DumpVarsResponse{Variables: buf.Bytes()} -} diff --git a/state/service.pb.go b/state/service.pb.go deleted file mode 100644 index 187949b..0000000 --- a/state/service.pb.go +++ /dev/null @@ -1,2811 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: state/service.proto - -package state - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/protobuf/proto" - bootstrap "github.com/nspcc-dev/neofs-api-go/bootstrap" - service "github.com/nspcc-dev/neofs-api-go/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - 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.ProtoPackageIsVersion3 // please upgrade the proto package - -type ChangeStateRequest_State int32 - -const ( - // Unknown is default value. Does nothing. - ChangeStateRequest_Unknown ChangeStateRequest_State = 0 - // Online used when need to set node to the online state. - ChangeStateRequest_Online ChangeStateRequest_State = 1 - // Offline used when need to set node to the offline state. - ChangeStateRequest_Offline ChangeStateRequest_State = 2 -) - -var ChangeStateRequest_State_name = map[int32]string{ - 0: "Unknown", - 1: "Online", - 2: "Offline", -} - -var ChangeStateRequest_State_value = map[string]int32{ - "Unknown": 0, - "Online": 1, - "Offline": 2, -} - -func (x ChangeStateRequest_State) String() string { - return proto.EnumName(ChangeStateRequest_State_name, int32(x)) -} - -func (ChangeStateRequest_State) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{9, 0} -} - -// NetmapRequest message to request current node netmap -type NetmapRequest struct { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NetmapRequest) Reset() { *m = NetmapRequest{} } -func (m *NetmapRequest) String() string { return proto.CompactTextString(m) } -func (*NetmapRequest) ProtoMessage() {} -func (*NetmapRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{0} -} -func (m *NetmapRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NetmapRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *NetmapRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_NetmapRequest.Merge(m, src) -} -func (m *NetmapRequest) XXX_Size() int { - return m.Size() -} -func (m *NetmapRequest) XXX_DiscardUnknown() { - xxx_messageInfo_NetmapRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_NetmapRequest proto.InternalMessageInfo - -// MetricsRequest message to request node metrics -type MetricsRequest struct { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MetricsRequest) Reset() { *m = MetricsRequest{} } -func (m *MetricsRequest) String() string { return proto.CompactTextString(m) } -func (*MetricsRequest) ProtoMessage() {} -func (*MetricsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{1} -} -func (m *MetricsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MetricsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *MetricsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricsRequest.Merge(m, src) -} -func (m *MetricsRequest) XXX_Size() int { - return m.Size() -} -func (m *MetricsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MetricsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_MetricsRequest proto.InternalMessageInfo - -// MetricsResponse contains [][]byte, -// every []byte is marshaled MetricFamily proto message -// from github.com/prometheus/client_model/metrics.proto -type MetricsResponse struct { - Metrics [][]byte `protobuf:"bytes,1,rep,name=Metrics,proto3" json:"Metrics,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MetricsResponse) Reset() { *m = MetricsResponse{} } -func (m *MetricsResponse) String() string { return proto.CompactTextString(m) } -func (*MetricsResponse) ProtoMessage() {} -func (*MetricsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{2} -} -func (m *MetricsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MetricsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *MetricsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricsResponse.Merge(m, src) -} -func (m *MetricsResponse) XXX_Size() int { - return m.Size() -} -func (m *MetricsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MetricsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MetricsResponse proto.InternalMessageInfo - -func (m *MetricsResponse) GetMetrics() [][]byte { - if m != nil { - return m.Metrics - } - return nil -} - -// HealthRequest message to check current state -type HealthRequest struct { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HealthRequest) Reset() { *m = HealthRequest{} } -func (m *HealthRequest) String() string { return proto.CompactTextString(m) } -func (*HealthRequest) ProtoMessage() {} -func (*HealthRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{3} -} -func (m *HealthRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HealthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *HealthRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HealthRequest.Merge(m, src) -} -func (m *HealthRequest) XXX_Size() int { - return m.Size() -} -func (m *HealthRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HealthRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HealthRequest proto.InternalMessageInfo - -// HealthResponse message with current state -type HealthResponse struct { - // Healthy is true when node alive and healthy - Healthy bool `protobuf:"varint,1,opt,name=Healthy,proto3" json:"Healthy,omitempty"` - // Status contains detailed information about health status - Status string `protobuf:"bytes,2,opt,name=Status,proto3" json:"Status,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HealthResponse) Reset() { *m = HealthResponse{} } -func (m *HealthResponse) String() string { return proto.CompactTextString(m) } -func (*HealthResponse) ProtoMessage() {} -func (*HealthResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{4} -} -func (m *HealthResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HealthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *HealthResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HealthResponse.Merge(m, src) -} -func (m *HealthResponse) XXX_Size() int { - return m.Size() -} -func (m *HealthResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HealthResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_HealthResponse proto.InternalMessageInfo - -func (m *HealthResponse) GetHealthy() bool { - if m != nil { - return m.Healthy - } - return false -} - -func (m *HealthResponse) GetStatus() string { - if m != nil { - return m.Status - } - return "" -} - -// DumpRequest message to fetch current server config. -type DumpRequest struct { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DumpRequest) Reset() { *m = DumpRequest{} } -func (m *DumpRequest) String() string { return proto.CompactTextString(m) } -func (*DumpRequest) ProtoMessage() {} -func (*DumpRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{5} -} -func (m *DumpRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DumpRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DumpRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DumpRequest.Merge(m, src) -} -func (m *DumpRequest) XXX_Size() int { - return m.Size() -} -func (m *DumpRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DumpRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DumpRequest proto.InternalMessageInfo - -// DumpResponse message contains current server config. -// Config stored in JSON encoded into slice of bytes. -type DumpResponse struct { - Config []byte `protobuf:"bytes,1,opt,name=Config,proto3" json:"Config,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DumpResponse) Reset() { *m = DumpResponse{} } -func (m *DumpResponse) String() string { return proto.CompactTextString(m) } -func (*DumpResponse) ProtoMessage() {} -func (*DumpResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{6} -} -func (m *DumpResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DumpResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DumpResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DumpResponse.Merge(m, src) -} -func (m *DumpResponse) XXX_Size() int { - return m.Size() -} -func (m *DumpResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DumpResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DumpResponse proto.InternalMessageInfo - -func (m *DumpResponse) GetConfig() []byte { - if m != nil { - return m.Config - } - return nil -} - -// DumpVarsRequest message to fetch current server debug variables. -type DumpVarsRequest struct { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DumpVarsRequest) Reset() { *m = DumpVarsRequest{} } -func (m *DumpVarsRequest) String() string { return proto.CompactTextString(m) } -func (*DumpVarsRequest) ProtoMessage() {} -func (*DumpVarsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{7} -} -func (m *DumpVarsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DumpVarsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DumpVarsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DumpVarsRequest.Merge(m, src) -} -func (m *DumpVarsRequest) XXX_Size() int { - return m.Size() -} -func (m *DumpVarsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DumpVarsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DumpVarsRequest proto.InternalMessageInfo - -// DumpVarsResponse message contains current server debug variables. -// Variables stored in JSON encoded into slice of bytes. -type DumpVarsResponse struct { - Variables []byte `protobuf:"bytes,1,opt,name=Variables,proto3" json:"Variables,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DumpVarsResponse) Reset() { *m = DumpVarsResponse{} } -func (m *DumpVarsResponse) String() string { return proto.CompactTextString(m) } -func (*DumpVarsResponse) ProtoMessage() {} -func (*DumpVarsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{8} -} -func (m *DumpVarsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DumpVarsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *DumpVarsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DumpVarsResponse.Merge(m, src) -} -func (m *DumpVarsResponse) XXX_Size() int { - return m.Size() -} -func (m *DumpVarsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DumpVarsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DumpVarsResponse proto.InternalMessageInfo - -func (m *DumpVarsResponse) GetVariables() []byte { - if m != nil { - return m.Variables - } - return nil -} - -// ChangeStateRequest contains a new state of node. -type ChangeStateRequest struct { - // State is a new state of node. - State ChangeStateRequest_State `protobuf:"varint,1,opt,name=state,proto3,enum=state.ChangeStateRequest_State" json:"state,omitempty"` - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ChangeStateRequest) Reset() { *m = ChangeStateRequest{} } -func (m *ChangeStateRequest) String() string { return proto.CompactTextString(m) } -func (*ChangeStateRequest) ProtoMessage() {} -func (*ChangeStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{9} -} -func (m *ChangeStateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ChangeStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ChangeStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChangeStateRequest.Merge(m, src) -} -func (m *ChangeStateRequest) XXX_Size() int { - return m.Size() -} -func (m *ChangeStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ChangeStateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ChangeStateRequest proto.InternalMessageInfo - -func (m *ChangeStateRequest) GetState() ChangeStateRequest_State { - if m != nil { - return m.State - } - return ChangeStateRequest_Unknown -} - -// ChangeStateResponse is an empty response, that returns when RPC invoked without errors. -type ChangeStateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ChangeStateResponse) Reset() { *m = ChangeStateResponse{} } -func (m *ChangeStateResponse) String() string { return proto.CompactTextString(m) } -func (*ChangeStateResponse) ProtoMessage() {} -func (*ChangeStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_695592f6f2fc97b7, []int{10} -} -func (m *ChangeStateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ChangeStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *ChangeStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChangeStateResponse.Merge(m, src) -} -func (m *ChangeStateResponse) XXX_Size() int { - return m.Size() -} -func (m *ChangeStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ChangeStateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ChangeStateResponse proto.InternalMessageInfo - -func init() { - proto.RegisterEnum("state.ChangeStateRequest_State", ChangeStateRequest_State_name, ChangeStateRequest_State_value) - proto.RegisterType((*NetmapRequest)(nil), "state.NetmapRequest") - proto.RegisterType((*MetricsRequest)(nil), "state.MetricsRequest") - proto.RegisterType((*MetricsResponse)(nil), "state.MetricsResponse") - proto.RegisterType((*HealthRequest)(nil), "state.HealthRequest") - proto.RegisterType((*HealthResponse)(nil), "state.HealthResponse") - proto.RegisterType((*DumpRequest)(nil), "state.DumpRequest") - proto.RegisterType((*DumpResponse)(nil), "state.DumpResponse") - proto.RegisterType((*DumpVarsRequest)(nil), "state.DumpVarsRequest") - proto.RegisterType((*DumpVarsResponse)(nil), "state.DumpVarsResponse") - proto.RegisterType((*ChangeStateRequest)(nil), "state.ChangeStateRequest") - proto.RegisterType((*ChangeStateResponse)(nil), "state.ChangeStateResponse") -} - -func init() { proto.RegisterFile("state/service.proto", fileDescriptor_695592f6f2fc97b7) } - -var fileDescriptor_695592f6f2fc97b7 = []byte{ - // 619 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xc1, 0x6e, 0xd3, 0x4c, - 0x10, 0xee, 0xe6, 0xff, 0xeb, 0xb6, 0x93, 0xd2, 0x56, 0xdb, 0x26, 0x18, 0x0b, 0xa5, 0x91, 0x0f, - 0x10, 0x09, 0xc5, 0x46, 0x85, 0x4a, 0x15, 0x9c, 0x68, 0x2b, 0x54, 0x0e, 0x6d, 0x91, 0x2b, 0x7a, - 0xe0, 0xb6, 0x76, 0xc7, 0x8e, 0xd5, 0xc6, 0x6b, 0xbc, 0x9b, 0xa2, 0x3e, 0x04, 0x02, 0x6e, 0x3c, - 0x03, 0x4f, 0xd2, 0x63, 0x8f, 0x9c, 0x2a, 0x14, 0xee, 0x3c, 0x00, 0x27, 0x94, 0xdd, 0x75, 0x9a, - 0x34, 0x70, 0x26, 0xb7, 0x7c, 0xdf, 0xcc, 0xb7, 0xf9, 0x66, 0x77, 0x66, 0x0c, 0xab, 0x42, 0x32, - 0x89, 0xbe, 0xc0, 0xe2, 0x3c, 0x8d, 0xd0, 0xcb, 0x0b, 0x2e, 0x39, 0x9d, 0x55, 0xa4, 0x43, 0x0d, - 0xeb, 0x77, 0x51, 0x32, 0x1d, 0x72, 0xd6, 0x4a, 0xee, 0x1c, 0x8b, 0x34, 0xbe, 0x30, 0x6c, 0x2d, - 0xe4, 0x5c, 0x0a, 0x59, 0xb0, 0xdc, 0x97, 0x17, 0x39, 0x0a, 0x43, 0xb7, 0x93, 0x54, 0x76, 0x7a, - 0xa1, 0x17, 0xf1, 0xae, 0x9f, 0xf0, 0x84, 0xfb, 0x8a, 0x0e, 0x7b, 0xb1, 0x42, 0x0a, 0xa8, 0x5f, - 0x3a, 0xdd, 0xfd, 0x48, 0xe0, 0xce, 0x01, 0xca, 0x2e, 0xcb, 0x03, 0x7c, 0xd7, 0x43, 0x21, 0xe9, - 0x16, 0xfc, 0xbf, 0x8f, 0x92, 0xd9, 0x61, 0x93, 0xb4, 0xaa, 0x1b, 0x8e, 0x57, 0xda, 0x34, 0xf1, - 0x41, 0x6c, 0x0f, 0xd9, 0x09, 0x16, 0xdb, 0xf3, 0x97, 0xd7, 0xeb, 0x33, 0x57, 0xd7, 0xeb, 0x24, - 0x50, 0x0a, 0xba, 0x0b, 0xd6, 0xb1, 0x72, 0x68, 0x47, 0x4a, 0xeb, 0xde, 0xd6, 0xaa, 0x68, 0x1a, - 0x31, 0x99, 0xf2, 0x6c, 0xe2, 0x0c, 0xa3, 0x75, 0x3f, 0x11, 0x58, 0xda, 0x47, 0x59, 0xa4, 0x91, - 0x98, 0x16, 0x4b, 0x8f, 0x60, 0x79, 0xe8, 0x48, 0xe4, 0x3c, 0x13, 0x48, 0x6d, 0x98, 0x33, 0x94, - 0x4d, 0x9a, 0xff, 0xb5, 0x16, 0x83, 0x12, 0xaa, 0x1b, 0xdd, 0x43, 0x76, 0x26, 0x3b, 0xd3, 0x62, - 0x7f, 0x1b, 0x96, 0x4a, 0x43, 0x37, 0xee, 0x35, 0x73, 0x61, 0x93, 0x26, 0x69, 0xcd, 0x07, 0x25, - 0xa4, 0x75, 0xb0, 0x8e, 0x24, 0x93, 0x3d, 0x61, 0x57, 0x9a, 0xa4, 0xb5, 0x10, 0x18, 0xe4, 0x7e, - 0x20, 0x50, 0xdd, 0xed, 0x75, 0xa7, 0xa6, 0x4b, 0x1e, 0xc0, 0xa2, 0xb6, 0x63, 0x2a, 0xaa, 0x83, - 0xb5, 0xc3, 0xb3, 0x38, 0x4d, 0x54, 0x41, 0x8b, 0x81, 0x41, 0xee, 0x67, 0x02, 0xcb, 0x83, 0xc4, - 0x63, 0x56, 0x4c, 0x4d, 0x3b, 0x3d, 0x86, 0x95, 0x1b, 0x4b, 0xc6, 0xff, 0x7d, 0x58, 0x38, 0x66, - 0x45, 0xca, 0xc2, 0x33, 0x14, 0xa6, 0x84, 0x1b, 0xc2, 0xfd, 0x45, 0x80, 0xee, 0x74, 0x58, 0x96, - 0xe0, 0xe0, 0x39, 0xb0, 0x2c, 0x64, 0x13, 0xf4, 0xd6, 0x50, 0x82, 0xa5, 0x8d, 0x75, 0x4f, 0x21, - 0x6f, 0x32, 0xd3, 0xd3, 0x40, 0x67, 0xff, 0xf3, 0xfa, 0xdb, 0x30, 0xab, 0xfc, 0xd0, 0x2a, 0xcc, - 0xbd, 0xc9, 0x4e, 0x33, 0xfe, 0x3e, 0x5b, 0x99, 0xa1, 0x00, 0xd6, 0x61, 0x76, 0x96, 0x66, 0xb8, - 0x42, 0x06, 0x81, 0xc3, 0x38, 0x56, 0xa0, 0xe2, 0xd6, 0x60, 0x75, 0xac, 0x22, 0x7d, 0x63, 0x1b, - 0x3f, 0x2b, 0x65, 0xab, 0xd2, 0xa7, 0x60, 0xe9, 0x1d, 0x46, 0xd7, 0xcc, 0x15, 0x8c, 0xad, 0x34, - 0x67, 0xcd, 0x1b, 0xee, 0x4a, 0xef, 0x28, 0x2f, 0x90, 0x9d, 0xec, 0xb3, 0x9c, 0x6e, 0x0d, 0x47, - 0x98, 0xd6, 0x8c, 0x6c, 0x7c, 0xef, 0x38, 0xf5, 0xdb, 0xb4, 0x79, 0xac, 0x67, 0x50, 0xd5, 0xf3, - 0xb2, 0xd3, 0xc1, 0xe8, 0x74, 0xf8, 0xa7, 0x63, 0x53, 0xef, 0xd4, 0x6e, 0xb1, 0x46, 0xbb, 0x09, - 0x30, 0x78, 0x7c, 0xdd, 0x9e, 0x94, 0x9a, 0xa4, 0x91, 0xd1, 0x72, 0x56, 0xc7, 0x38, 0x23, 0x7b, - 0x0e, 0xf3, 0x65, 0xcf, 0xd0, 0xfa, 0x48, 0xc2, 0x48, 0x5f, 0x3b, 0x77, 0x27, 0x78, 0x23, 0xde, - 0x85, 0xea, 0xc8, 0x0d, 0xd2, 0x7b, 0x7f, 0xed, 0x13, 0xc7, 0xf9, 0x53, 0x48, 0x9f, 0xb2, 0x7d, - 0x78, 0xd9, 0x6f, 0x90, 0xab, 0x7e, 0x83, 0x7c, 0xeb, 0x37, 0xc8, 0xf7, 0x7e, 0x83, 0x7c, 0xf9, - 0xd1, 0x98, 0x79, 0xfb, 0x70, 0xe4, 0x7b, 0x93, 0x89, 0x3c, 0x8a, 0xda, 0x27, 0x78, 0xee, 0x67, - 0xc8, 0x63, 0xd1, 0x66, 0x79, 0xda, 0x4e, 0xb8, 0xaf, 0x8e, 0xfc, 0x5a, 0x59, 0x3e, 0x40, 0xfe, - 0xf2, 0xc8, 0x7b, 0xf1, 0xfa, 0x95, 0x6e, 0xc7, 0xd0, 0x52, 0x9f, 0xa0, 0x27, 0xbf, 0x03, 0x00, - 0x00, 0xff, 0xff, 0x8c, 0xdd, 0xa7, 0x55, 0x10, 0x07, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// StatusClient is the client API for Status service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type StatusClient interface { - // Netmap request allows to receive current [bootstrap.SpreadMap](bootstrap.md#bootstrap.SpreadMap) - Netmap(ctx context.Context, in *NetmapRequest, opts ...grpc.CallOption) (*bootstrap.SpreadMap, error) - // Metrics request allows to receive metrics in prometheus format - Metrics(ctx context.Context, in *MetricsRequest, opts ...grpc.CallOption) (*MetricsResponse, error) - // HealthCheck request allows to check health status of the node. - // If node unhealthy field Status would contains detailed info. - HealthCheck(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error) - // DumpConfig request allows dumping settings for the current node. - // To permit access, used server config options. - // The request should be signed. - DumpConfig(ctx context.Context, in *DumpRequest, opts ...grpc.CallOption) (*DumpResponse, error) - // DumpVars returns debug variables for the current node. - // To permit access, used server config options. - // The request should be signed. - DumpVars(ctx context.Context, in *DumpVarsRequest, opts ...grpc.CallOption) (*DumpVarsResponse, error) - // ChangeState allows to change current node state of node. - // To permit access, used server config options. - // The request should be signed. - ChangeState(ctx context.Context, in *ChangeStateRequest, opts ...grpc.CallOption) (*ChangeStateResponse, error) -} - -type statusClient struct { - cc *grpc.ClientConn -} - -func NewStatusClient(cc *grpc.ClientConn) StatusClient { - return &statusClient{cc} -} - -func (c *statusClient) Netmap(ctx context.Context, in *NetmapRequest, opts ...grpc.CallOption) (*bootstrap.SpreadMap, error) { - out := new(bootstrap.SpreadMap) - err := c.cc.Invoke(ctx, "/state.Status/Netmap", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *statusClient) Metrics(ctx context.Context, in *MetricsRequest, opts ...grpc.CallOption) (*MetricsResponse, error) { - out := new(MetricsResponse) - err := c.cc.Invoke(ctx, "/state.Status/Metrics", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *statusClient) HealthCheck(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error) { - out := new(HealthResponse) - err := c.cc.Invoke(ctx, "/state.Status/HealthCheck", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *statusClient) DumpConfig(ctx context.Context, in *DumpRequest, opts ...grpc.CallOption) (*DumpResponse, error) { - out := new(DumpResponse) - err := c.cc.Invoke(ctx, "/state.Status/DumpConfig", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *statusClient) DumpVars(ctx context.Context, in *DumpVarsRequest, opts ...grpc.CallOption) (*DumpVarsResponse, error) { - out := new(DumpVarsResponse) - err := c.cc.Invoke(ctx, "/state.Status/DumpVars", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *statusClient) ChangeState(ctx context.Context, in *ChangeStateRequest, opts ...grpc.CallOption) (*ChangeStateResponse, error) { - out := new(ChangeStateResponse) - err := c.cc.Invoke(ctx, "/state.Status/ChangeState", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// StatusServer is the server API for Status service. -type StatusServer interface { - // Netmap request allows to receive current [bootstrap.SpreadMap](bootstrap.md#bootstrap.SpreadMap) - Netmap(context.Context, *NetmapRequest) (*bootstrap.SpreadMap, error) - // Metrics request allows to receive metrics in prometheus format - Metrics(context.Context, *MetricsRequest) (*MetricsResponse, error) - // HealthCheck request allows to check health status of the node. - // If node unhealthy field Status would contains detailed info. - HealthCheck(context.Context, *HealthRequest) (*HealthResponse, error) - // DumpConfig request allows dumping settings for the current node. - // To permit access, used server config options. - // The request should be signed. - DumpConfig(context.Context, *DumpRequest) (*DumpResponse, error) - // DumpVars returns debug variables for the current node. - // To permit access, used server config options. - // The request should be signed. - DumpVars(context.Context, *DumpVarsRequest) (*DumpVarsResponse, error) - // ChangeState allows to change current node state of node. - // To permit access, used server config options. - // The request should be signed. - ChangeState(context.Context, *ChangeStateRequest) (*ChangeStateResponse, error) -} - -// UnimplementedStatusServer can be embedded to have forward compatible implementations. -type UnimplementedStatusServer struct { -} - -func (*UnimplementedStatusServer) Netmap(ctx context.Context, req *NetmapRequest) (*bootstrap.SpreadMap, error) { - return nil, status.Errorf(codes.Unimplemented, "method Netmap not implemented") -} -func (*UnimplementedStatusServer) Metrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Metrics not implemented") -} -func (*UnimplementedStatusServer) HealthCheck(ctx context.Context, req *HealthRequest) (*HealthResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") -} -func (*UnimplementedStatusServer) DumpConfig(ctx context.Context, req *DumpRequest) (*DumpResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DumpConfig not implemented") -} -func (*UnimplementedStatusServer) DumpVars(ctx context.Context, req *DumpVarsRequest) (*DumpVarsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DumpVars not implemented") -} -func (*UnimplementedStatusServer) ChangeState(ctx context.Context, req *ChangeStateRequest) (*ChangeStateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChangeState not implemented") -} - -func RegisterStatusServer(s *grpc.Server, srv StatusServer) { - s.RegisterService(&_Status_serviceDesc, srv) -} - -func _Status_Netmap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NetmapRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).Netmap(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/Netmap", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).Netmap(ctx, req.(*NetmapRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Status_Metrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MetricsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).Metrics(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/Metrics", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).Metrics(ctx, req.(*MetricsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Status_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HealthRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).HealthCheck(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/HealthCheck", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).HealthCheck(ctx, req.(*HealthRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Status_DumpConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DumpRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).DumpConfig(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/DumpConfig", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).DumpConfig(ctx, req.(*DumpRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Status_DumpVars_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DumpVarsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).DumpVars(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/DumpVars", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).DumpVars(ctx, req.(*DumpVarsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Status_ChangeState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ChangeStateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StatusServer).ChangeState(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/state.Status/ChangeState", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StatusServer).ChangeState(ctx, req.(*ChangeStateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Status_serviceDesc = grpc.ServiceDesc{ - ServiceName: "state.Status", - HandlerType: (*StatusServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Netmap", - Handler: _Status_Netmap_Handler, - }, - { - MethodName: "Metrics", - Handler: _Status_Metrics_Handler, - }, - { - MethodName: "HealthCheck", - Handler: _Status_HealthCheck_Handler, - }, - { - MethodName: "DumpConfig", - Handler: _Status_DumpConfig_Handler, - }, - { - MethodName: "DumpVars", - Handler: _Status_DumpVars_Handler, - }, - { - MethodName: "ChangeState", - Handler: _Status_ChangeState_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "state/service.proto", -} - -func (m *NetmapRequest) 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 *NetmapRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NetmapRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - return len(dAtA) - i, nil -} - -func (m *MetricsRequest) 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 *MetricsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MetricsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - return len(dAtA) - i, nil -} - -func (m *MetricsResponse) 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 *MetricsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MetricsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Metrics) > 0 { - for iNdEx := len(m.Metrics) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Metrics[iNdEx]) - copy(dAtA[i:], m.Metrics[iNdEx]) - i = encodeVarintService(dAtA, i, uint64(len(m.Metrics[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *HealthRequest) 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 *HealthRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HealthRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - return len(dAtA) - i, nil -} - -func (m *HealthResponse) 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 *HealthResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HealthResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Status) > 0 { - i -= len(m.Status) - copy(dAtA[i:], m.Status) - i = encodeVarintService(dAtA, i, uint64(len(m.Status))) - i-- - dAtA[i] = 0x12 - } - if m.Healthy { - i-- - if m.Healthy { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *DumpRequest) 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 *DumpRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DumpRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - return len(dAtA) - i, nil -} - -func (m *DumpResponse) 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 *DumpResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DumpResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Config) > 0 { - i -= len(m.Config) - copy(dAtA[i:], m.Config) - i = encodeVarintService(dAtA, i, uint64(len(m.Config))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DumpVarsRequest) 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 *DumpVarsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DumpVarsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - return len(dAtA) - i, nil -} - -func (m *DumpVarsResponse) 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 *DumpVarsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DumpVarsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Variables) > 0 { - i -= len(m.Variables) - copy(dAtA[i:], m.Variables) - i = encodeVarintService(dAtA, i, uint64(len(m.Variables))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ChangeStateRequest) 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 *ChangeStateRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ChangeStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - { - size, err := m.RequestVerificationHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x9a - { - size, err := m.RequestMetaHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0x92 - if m.State != 0 { - i = encodeVarintService(dAtA, i, uint64(m.State)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ChangeStateResponse) 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 *ChangeStateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ChangeStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func encodeVarintService(dAtA []byte, offset int, v uint64) int { - offset -= sovService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *NetmapRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *MetricsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *MetricsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Metrics) > 0 { - for _, b := range m.Metrics { - l = len(b) - n += 1 + l + sovService(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *HealthRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *HealthResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Healthy { - n += 2 - } - l = len(m.Status) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DumpRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DumpResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Config) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DumpVarsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DumpVarsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Variables) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ChangeStateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.State != 0 { - n += 1 + sovService(uint64(m.State)) - } - l = m.RequestMetaHeader.Size() - n += 2 + l + sovService(uint64(l)) - l = m.RequestVerificationHeader.Size() - n += 2 + l + sovService(uint64(l)) - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ChangeStateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozService(x uint64) (n int) { - return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *NetmapRequest) 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 ErrIntOverflowService - } - 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: NetmapRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NetmapRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsRequest) 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 ErrIntOverflowService - } - 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: MetricsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsResponse) 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 ErrIntOverflowService - } - 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: MetricsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metrics = append(m.Metrics, make([]byte, postIndex-iNdEx)) - copy(m.Metrics[len(m.Metrics)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HealthRequest) 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 ErrIntOverflowService - } - 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: HealthRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HealthRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HealthResponse) 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 ErrIntOverflowService - } - 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: HealthResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HealthResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Healthy", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Healthy = bool(v != 0) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - 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 ErrInvalidLengthService - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Status = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DumpRequest) 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 ErrIntOverflowService - } - 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: DumpRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DumpRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DumpResponse) 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 ErrIntOverflowService - } - 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: DumpResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DumpResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Config = append(m.Config[:0], dAtA[iNdEx:postIndex]...) - if m.Config == nil { - m.Config = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DumpVarsRequest) 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 ErrIntOverflowService - } - 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: DumpVarsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DumpVarsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DumpVarsResponse) 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 ErrIntOverflowService - } - 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: DumpVarsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DumpVarsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Variables", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Variables = append(m.Variables[:0], dAtA[iNdEx:postIndex]...) - if m.Variables == nil { - m.Variables = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ChangeStateRequest) 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 ErrIntOverflowService - } - 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: ChangeStateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ChangeStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) - } - m.State = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.State |= ChangeStateRequest_State(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 98: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestMetaHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 99: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestVerificationHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RequestVerificationHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ChangeStateResponse) 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 ErrIntOverflowService - } - 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: ChangeStateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ChangeStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipService(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipService(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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrIntOverflowService - } - 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, ErrInvalidLengthService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/state/service.proto b/state/service.proto deleted file mode 100644 index 410a000..0000000 --- a/state/service.proto +++ /dev/null @@ -1,124 +0,0 @@ -syntax = "proto3"; -package state; -option go_package = "github.com/nspcc-dev/neofs-api-go/state"; -option csharp_namespace = "NeoFS.API.State"; - -import "service/meta.proto"; -import "service/verify.proto"; -import "bootstrap/types.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -// Status service provides node's healthcheck and status info. -// TODO: decide how to describe auth and were contains permissions. -service Status { - // Netmap request allows to receive current [bootstrap.SpreadMap](bootstrap.md#bootstrap.SpreadMap) - rpc Netmap(NetmapRequest) returns (bootstrap.SpreadMap); - // Metrics request allows to receive metrics in prometheus format - rpc Metrics(MetricsRequest) returns (MetricsResponse); - // HealthCheck request allows to check health status of the node. - // If node unhealthy field Status would contains detailed info. - rpc HealthCheck(HealthRequest) returns (HealthResponse); - // DumpConfig request allows dumping settings for the current node. - // To permit access, used server config options. - // The request should be signed. - rpc DumpConfig(DumpRequest) returns (DumpResponse); - // DumpVars returns debug variables for the current node. - // To permit access, used server config options. - // The request should be signed. - rpc DumpVars(DumpVarsRequest) returns (DumpVarsResponse); - // ChangeState allows to change current node state of node. - // To permit access, used server config options. - // The request should be signed. - rpc ChangeState(ChangeStateRequest) returns (ChangeStateResponse); -} - -// NetmapRequest message to request current node netmap -message NetmapRequest { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// MetricsRequest message to request node metrics -message MetricsRequest { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// MetricsResponse contains [][]byte, -// every []byte is marshaled MetricFamily proto message -// from github.com/prometheus/client_model/metrics.proto -message MetricsResponse { - repeated bytes Metrics = 1; -} - -// HealthRequest message to check current state -message HealthRequest { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// HealthResponse message with current state -message HealthResponse { - // Healthy is true when node alive and healthy - bool Healthy = 1; - // Status contains detailed information about health status - string Status = 2; -} - -// DumpRequest message to fetch current server config. -message DumpRequest { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// DumpResponse message contains current server config. -// Config stored in JSON encoded into slice of bytes. -message DumpResponse { - bytes Config = 1; -} - -// DumpVarsRequest message to fetch current server debug variables. -message DumpVarsRequest { - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// DumpVarsResponse message contains current server debug variables. -// Variables stored in JSON encoded into slice of bytes. -message DumpVarsResponse { - bytes Variables = 1; -} - -// ChangeStateRequest contains a new state of node. -message ChangeStateRequest { - enum State { - // Unknown is default value. Does nothing. - Unknown = 0; - // Online used when need to set node to the online state. - Online = 1; - // Offline used when need to set node to the offline state. - Offline = 2; - } - - // State is a new state of node. - State state = 1; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) - service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) - service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; -} - -// ChangeStateResponse is an empty response, that returns when RPC invoked without errors. -message ChangeStateResponse {} \ No newline at end of file diff --git a/state/service_test.go b/state/service_test.go deleted file mode 100644 index d545cb0..0000000 --- a/state/service_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package state - -import ( - "bytes" - "encoding/json" - "expvar" - "testing" - - "github.com/prometheus/client_golang/prometheus" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" -) - -type testCollector struct { - testA *prometheus.Desc - testB *prometheus.Desc -} - -func (c *testCollector) Describe(ch chan<- *prometheus.Desc) { - ch <- c.testA - ch <- c.testB -} - -func (c *testCollector) Collect(ch chan<- prometheus.Metric) { - ch <- prometheus.MustNewConstMetric(c.testA, prometheus.GaugeValue, 1, "label_1") - ch <- prometheus.MustNewConstMetric(c.testB, prometheus.GaugeValue, 2, "label_2") -} - -func TestEncodeVariables(t *testing.T) { - dump := make(map[string]interface{}) - - expvar.NewString("test1").Set("test1") - expvar.NewString("test2").Set("test2") - - res := EncodeVariables() - - require.NoError(t, json.Unmarshal(res.Variables, &dump)) - require.NotEmpty(t, dump) - - // dump should contains keys `test1` and `test2` - require.Contains(t, dump, "test1") - require.Equal(t, "test1", dump["test1"]) - - require.Contains(t, dump, "test2") - require.Equal(t, "test2", dump["test2"]) -} - -func TestEncodeConfig(t *testing.T) { - v := viper.New() - v.Set("test1", "test1") - v.Set("test2", "test2") - - res, err := EncodeConfig(v) - require.NoError(t, err) - - dump := make(map[string]interface{}) - require.NoError(t, json.Unmarshal(res.Config, &dump)) - - require.NotEmpty(t, dump) - - require.Contains(t, dump, "test1") - require.Equal(t, dump["test1"], "test1") - - require.Contains(t, dump, "test2") - require.Equal(t, dump["test2"], "test2") -} - -func TestEncodeAndDecodeMetrics(t *testing.T) { - registry := prometheus.NewRegistry() - - collector := &testCollector{ - testA: prometheus.NewDesc("test1", "test1", []string{"test1"}, prometheus.Labels{"label_1": "test1"}), - testB: prometheus.NewDesc("test2", "test2", []string{"test2"}, prometheus.Labels{"label_2": "test2"}), - } - - require.NoError(t, registry.Register(collector)) - - gather, err := registry.Gather() - require.NoError(t, err) - - res, err := EncodeMetrics(registry) - require.NoError(t, err) - - metrics, err := DecodeMetrics(res) - require.NoError(t, err) - - require.Len(t, metrics, len(gather)) - - { // Check that JSON encoded metrics are equal: - expect := new(bytes.Buffer) - actual := new(bytes.Buffer) - - require.NoError(t, json.NewEncoder(expect).Encode(gather)) - require.NoError(t, json.NewEncoder(actual).Encode(metrics)) - - require.Equal(t, expect.Bytes(), actual.Bytes()) - } - - { // Deep comparison of metrics: - for i := range metrics { - require.Equal(t, gather[i].Help, metrics[i].Help) - require.Equal(t, gather[i].Name, metrics[i].Name) - require.Equal(t, gather[i].Type, metrics[i].Type) - - require.Len(t, metrics[i].Metric, len(gather[i].Metric)) - - for j := range metrics[i].Metric { - require.Equal(t, gather[i].Metric[j].Gauge, metrics[i].Metric[j].Gauge) - require.Len(t, metrics[i].Metric[j].Label, len(gather[i].Metric[j].Label)) - - for k := range metrics[i].Metric[j].Label { - require.Equal(t, gather[i].Metric[j].Label[k].Name, metrics[i].Metric[j].Label[k].Name) - require.Equal(t, gather[i].Metric[j].Label[k].Value, metrics[i].Metric[j].Label[k].Value) - } - } - } - } -} diff --git a/state/sign.go b/state/sign.go deleted file mode 100644 index 88f038c..0000000 --- a/state/sign.go +++ /dev/null @@ -1,67 +0,0 @@ -package state - -import ( - "io" - - "github.com/nspcc-dev/neofs-api-go/service" -) - -// SignedData returns payload bytes of the request. -// -// Always returns an empty slice. -func (m NetmapRequest) SignedData() ([]byte, error) { - return make([]byte, 0), nil -} - -// SignedData returns payload bytes of the request. -// -// Always returns an empty slice. -func (m MetricsRequest) SignedData() ([]byte, error) { - return make([]byte, 0), nil -} - -// SignedData returns payload bytes of the request. -// -// Always returns an empty slice. -func (m HealthRequest) SignedData() ([]byte, error) { - return make([]byte, 0), nil -} - -// SignedData returns payload bytes of the request. -// -// Always returns an empty slice. -func (m DumpRequest) SignedData() ([]byte, error) { - return make([]byte, 0), nil -} - -// SignedData returns payload bytes of the request. -// -// Always returns an empty slice. -func (m DumpVarsRequest) SignedData() ([]byte, error) { - return make([]byte, 0), nil -} - -// SignedData returns payload bytes of the request. -func (m ChangeStateRequest) SignedData() ([]byte, error) { - return service.SignedDataFromReader(m) -} - -// SignedDataSize returns payload size of the request. -func (m ChangeStateRequest) SignedDataSize() int { - return m.GetState().Size() -} - -// ReadSignedData copies payload bytes to passed buffer. -// -// If the Request size is insufficient, io.ErrUnexpectedEOF returns. -func (m ChangeStateRequest) ReadSignedData(p []byte) (int, error) { - if len(p) < m.SignedDataSize() { - return 0, io.ErrUnexpectedEOF - } - - var off int - - off += copy(p[off:], m.GetState().Bytes()) - - return off, nil -} diff --git a/state/sign_test.go b/state/sign_test.go deleted file mode 100644 index 05af654..0000000 --- a/state/sign_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package state - -import ( - "testing" - - "github.com/nspcc-dev/neofs-api-go/service" - "github.com/nspcc-dev/neofs-crypto/test" - "github.com/stretchr/testify/require" -) - -func TestRequestSign(t *testing.T) { - sk := test.DecodeKey(0) - - type sigType interface { - service.RequestData - service.SignKeyPairAccumulator - service.SignKeyPairSource - SetToken(*service.Token) - } - - items := []struct { - constructor func() sigType - payloadCorrupt []func(sigType) - }{ - { // NetmapRequest - constructor: func() sigType { - return new(NetmapRequest) - }, - }, - { // MetricsRequest - constructor: func() sigType { - return new(MetricsRequest) - }, - }, - { // HealthRequest - constructor: func() sigType { - return new(HealthRequest) - }, - }, - { // DumpRequest - constructor: func() sigType { - return new(DumpRequest) - }, - }, - { // DumpVarsRequest - constructor: func() sigType { - return new(DumpVarsRequest) - }, - }, - { - constructor: func() sigType { - return new(ChangeStateRequest) - }, - payloadCorrupt: []func(sigType){ - func(s sigType) { - req := s.(*ChangeStateRequest) - - req.SetState(req.GetState() + 1) - }, - }, - }, - } - - for _, item := range items { - { // token corruptions - v := item.constructor() - - token := new(service.Token) - v.SetToken(token) - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - token.SetSessionKey(append(token.GetSessionKey(), 1)) - - require.Error(t, service.VerifyRequestData(v)) - } - - { // payload corruptions - for _, corruption := range item.payloadCorrupt { - v := item.constructor() - - require.NoError(t, service.SignRequestData(sk, v)) - - require.NoError(t, service.VerifyRequestData(v)) - - corruption(v) - - require.Error(t, service.VerifyRequestData(v)) - } - } - } -} diff --git a/state/types.go b/state/types.go deleted file mode 100644 index 6b572db..0000000 --- a/state/types.go +++ /dev/null @@ -1,24 +0,0 @@ -package state - -import ( - "encoding/binary" -) - -// SetState is a State field setter. -func (m *ChangeStateRequest) SetState(st ChangeStateRequest_State) { - m.State = st -} - -// Size returns the size of the state binary representation. -func (ChangeStateRequest_State) Size() int { - return 4 -} - -// Bytes returns the state binary representation. -func (x ChangeStateRequest_State) Bytes() []byte { - data := make([]byte, x.Size()) - - binary.BigEndian.PutUint32(data, uint32(x)) - - return data -} diff --git a/state/types_test.go b/state/types_test.go deleted file mode 100644 index 5d5f5de..0000000 --- a/state/types_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package state - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestChangeStateRequestGettersSetters(t *testing.T) { - t.Run("state", func(t *testing.T) { - st := ChangeStateRequest_State(1) - m := new(ChangeStateRequest) - - m.SetState(st) - - require.Equal(t, st, m.GetState()) - }) -} diff --git a/storagegroup/storage.go b/storagegroup/storage.go deleted file mode 100644 index 7438b2b..0000000 --- a/storagegroup/storage.go +++ /dev/null @@ -1,39 +0,0 @@ -package storagegroup - -import ( - "context" - - "github.com/nspcc-dev/neofs-api-go/refs" -) - -type ( - // Store is a interface for storing users storage group - Store interface { - Lister - Receiver - Receptacle - } - - // Lister defines list function that returns all storage groups - // created for the passed container - Lister interface { - List(ctx context.Context, cid refs.CID) ([]refs.SGID, error) - } - - // Receiver defines get function that returns asked storage group - Receiver interface { - Get(ctx context.Context, cid refs.CID, sgid refs.SGID) (Provider, error) - } - - // Receptacle defines put function that places storage group in the - // store. - Receptacle interface { - Put(ctx context.Context, sg Provider) error - } - - // InfoReceiver defines GetSGInfo function that returns storage group - // that contains passed object ids. - InfoReceiver interface { - GetSGInfo(ctx context.Context, cid refs.CID, group []refs.ObjectID) (*StorageGroup, error) - } -) diff --git a/storagegroup/types.go b/storagegroup/types.go deleted file mode 100644 index d16382b..0000000 --- a/storagegroup/types.go +++ /dev/null @@ -1,97 +0,0 @@ -package storagegroup - -import ( - "bytes" - "strconv" - "strings" - - "github.com/gogo/protobuf/proto" - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/hash" - "github.com/nspcc-dev/neofs-api-go/refs" -) - -type ( - // Hash is alias of hash.Hash for proto definition. - Hash = hash.Hash - - // Provider is an interface that defines storage group instance. - // There was different storage group implementation. Right now it - // is implemented as extended header in the object. - Provider interface { - // Group returns list of object ids of the storage group. - // This list **should be** sorted. - Group() []refs.ObjectID - - IDInfo() *IdentificationInfo - Zones() []ZoneInfo - } - - // ZoneInfo provides validation information of storage group. - ZoneInfo struct { - hash.Hash - Size uint64 - } - - // IdentificationInfo provides meta information about storage group. - IdentificationInfo struct { - CID refs.CID - SGID refs.SGID - OwnerID refs.OwnerID - } - - // IDList is a slice of object ids, that can be sorted. - IDList []refs.ObjectID -) - -var _ proto.Message = (*StorageGroup)(nil) - -// String returns string representation of StorageGroup. -func (m *StorageGroup) String() string { - b := new(strings.Builder) - b.WriteString("') - return b.String() -} - -// Empty checks if storage group has some data for validation. -func (m StorageGroup) Empty() bool { - return m.ValidationDataSize == 0 && m.ValidationHash.Equal(hash.Hash{}) -} - -// Len returns amount of object ids in IDList. -func (s IDList) Len() int { return len(s) } - -// Less returns byte comparision between IDList[i] and IDList[j]. -func (s IDList) Less(i, j int) bool { return bytes.Compare(s[i].Bytes(), s[j].Bytes()) == -1 } - -// Swap swaps element with i and j index in IDList. -func (s IDList) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// CalculateSize combines length of all zones in storage group. -func CalculateSize(sg Provider) (size uint64) { - zoneList := sg.Zones() - for i := range zoneList { - size += zoneList[i].Size - } - return -} - -// CalculateHash returns homomorphic sum of hashes -// fromm all zones in storage group. -func CalculateHash(sg Provider) (hash.Hash, error) { - var ( - zones = sg.Zones() - hashes = make([]hash.Hash, len(zones)) - ) - for i := range zones { - hashes[i] = zones[i].Hash - } - return hash.Concat(hashes) -} diff --git a/storagegroup/types.pb.go b/storagegroup/types.pb.go deleted file mode 100644 index fa4b248..0000000 --- a/storagegroup/types.pb.go +++ /dev/null @@ -1,664 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: storagegroup/types.proto - -package storagegroup - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/golang/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.ProtoPackageIsVersion3 // please upgrade the proto package - -type StorageGroup_Lifetime_Unit int32 - -const ( - // Unlimited set if storage group always valid - StorageGroup_Lifetime_Unlimited StorageGroup_Lifetime_Unit = 0 - // NeoFSEpoch set if storage group is valid until lifetime NeoFS epoch - StorageGroup_Lifetime_NeoFSEpoch StorageGroup_Lifetime_Unit = 1 - // UnixTime set if storage group is valid until lifetime unix timestamp - StorageGroup_Lifetime_UnixTime StorageGroup_Lifetime_Unit = 2 -) - -var StorageGroup_Lifetime_Unit_name = map[int32]string{ - 0: "Unlimited", - 1: "NeoFSEpoch", - 2: "UnixTime", -} - -var StorageGroup_Lifetime_Unit_value = map[string]int32{ - "Unlimited": 0, - "NeoFSEpoch": 1, - "UnixTime": 2, -} - -func (x StorageGroup_Lifetime_Unit) String() string { - return proto.EnumName(StorageGroup_Lifetime_Unit_name, int32(x)) -} - -func (StorageGroup_Lifetime_Unit) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_cfa54edc899249a8, []int{0, 0, 0} -} - -type StorageGroup struct { - // ValidationDataSize is size of the all object's payloads included into storage group - ValidationDataSize uint64 `protobuf:"varint,1,opt,name=ValidationDataSize,proto3" json:"ValidationDataSize,omitempty"` - // ValidationHash is homomorphic hash of all object's payloads included into storage group - ValidationHash Hash `protobuf:"bytes,2,opt,name=ValidationHash,proto3,customtype=Hash" json:"ValidationHash"` - // Lifetime is time until storage group is valid - Lifetime *StorageGroup_Lifetime `protobuf:"bytes,3,opt,name=lifetime,proto3" json:"lifetime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StorageGroup) Reset() { *m = StorageGroup{} } -func (*StorageGroup) ProtoMessage() {} -func (*StorageGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_cfa54edc899249a8, []int{0} -} -func (m *StorageGroup) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StorageGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *StorageGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_StorageGroup.Merge(m, src) -} -func (m *StorageGroup) XXX_Size() int { - return m.Size() -} -func (m *StorageGroup) XXX_DiscardUnknown() { - xxx_messageInfo_StorageGroup.DiscardUnknown(m) -} - -var xxx_messageInfo_StorageGroup proto.InternalMessageInfo - -func (m *StorageGroup) GetValidationDataSize() uint64 { - if m != nil { - return m.ValidationDataSize - } - return 0 -} - -func (m *StorageGroup) GetLifetime() *StorageGroup_Lifetime { - if m != nil { - return m.Lifetime - } - return nil -} - -type StorageGroup_Lifetime struct { - // Unit is lifetime type - Unit StorageGroup_Lifetime_Unit `protobuf:"varint,1,opt,name=unit,proto3,enum=storagegroup.StorageGroup_Lifetime_Unit" json:"unit,omitempty"` - // Value for lifetime - Value int64 `protobuf:"varint,2,opt,name=Value,proto3" json:"Value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StorageGroup_Lifetime) Reset() { *m = StorageGroup_Lifetime{} } -func (m *StorageGroup_Lifetime) String() string { return proto.CompactTextString(m) } -func (*StorageGroup_Lifetime) ProtoMessage() {} -func (*StorageGroup_Lifetime) Descriptor() ([]byte, []int) { - return fileDescriptor_cfa54edc899249a8, []int{0, 0} -} -func (m *StorageGroup_Lifetime) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StorageGroup_Lifetime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil -} -func (m *StorageGroup_Lifetime) XXX_Merge(src proto.Message) { - xxx_messageInfo_StorageGroup_Lifetime.Merge(m, src) -} -func (m *StorageGroup_Lifetime) XXX_Size() int { - return m.Size() -} -func (m *StorageGroup_Lifetime) XXX_DiscardUnknown() { - xxx_messageInfo_StorageGroup_Lifetime.DiscardUnknown(m) -} - -var xxx_messageInfo_StorageGroup_Lifetime proto.InternalMessageInfo - -func (m *StorageGroup_Lifetime) GetUnit() StorageGroup_Lifetime_Unit { - if m != nil { - return m.Unit - } - return StorageGroup_Lifetime_Unlimited -} - -func (m *StorageGroup_Lifetime) GetValue() int64 { - if m != nil { - return m.Value - } - return 0 -} - -func init() { - proto.RegisterEnum("storagegroup.StorageGroup_Lifetime_Unit", StorageGroup_Lifetime_Unit_name, StorageGroup_Lifetime_Unit_value) - proto.RegisterType((*StorageGroup)(nil), "storagegroup.StorageGroup") - proto.RegisterType((*StorageGroup_Lifetime)(nil), "storagegroup.StorageGroup.Lifetime") -} - -func init() { proto.RegisterFile("storagegroup/types.proto", fileDescriptor_cfa54edc899249a8) } - -var fileDescriptor_cfa54edc899249a8 = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x31, 0x6b, 0xdb, 0x40, - 0x14, 0xd6, 0xc9, 0x6a, 0x51, 0xaf, 0xaa, 0x31, 0x47, 0x29, 0xc2, 0x83, 0x64, 0xdc, 0x45, 0x8b, - 0x4e, 0x60, 0x77, 0xea, 0x56, 0xd1, 0xba, 0x2d, 0x24, 0x21, 0xc8, 0xb1, 0x87, 0x40, 0x86, 0xb3, - 0x7c, 0x96, 0x0f, 0x24, 0x9d, 0xb0, 0x4e, 0x21, 0xc9, 0x2f, 0xf1, 0x12, 0xc8, 0x9c, 0x5f, 0xe2, - 0x31, 0x63, 0xc8, 0x20, 0x82, 0x32, 0xe5, 0x5f, 0x04, 0x9f, 0x13, 0x47, 0x09, 0x19, 0xb2, 0xbd, - 0xef, 0x7b, 0xdf, 0xf7, 0xde, 0xfb, 0x78, 0xd0, 0xcc, 0x05, 0x5f, 0x90, 0x88, 0x46, 0x0b, 0x5e, - 0x64, 0x9e, 0x38, 0xcd, 0x68, 0x8e, 0xb3, 0x05, 0x17, 0x1c, 0x19, 0xf5, 0x4e, 0xdb, 0x8d, 0x98, - 0x98, 0x17, 0x13, 0x1c, 0xf2, 0xc4, 0x8b, 0x78, 0xc4, 0x3d, 0x29, 0x9a, 0x14, 0x33, 0x89, 0x24, - 0x90, 0xd5, 0xc6, 0xdc, 0xbd, 0x57, 0xa1, 0x31, 0xdc, 0xf8, 0xff, 0xae, 0xfd, 0x08, 0x43, 0x34, - 0x26, 0x31, 0x9b, 0x12, 0xc1, 0x78, 0xfa, 0x9b, 0x08, 0x32, 0x64, 0x67, 0xd4, 0x04, 0x1d, 0xe0, - 0x68, 0xc1, 0x1b, 0x1d, 0xf4, 0x03, 0x36, 0x9f, 0xd9, 0x7f, 0x24, 0x9f, 0x9b, 0x6a, 0x07, 0x38, - 0x86, 0x6f, 0xac, 0x4a, 0x5b, 0xb9, 0x29, 0x6d, 0x6d, 0xcd, 0x05, 0xaf, 0x34, 0x68, 0x17, 0xea, - 0x31, 0x9b, 0x51, 0xc1, 0x12, 0x6a, 0x36, 0x3a, 0xc0, 0xf9, 0xdc, 0xfb, 0x8e, 0xeb, 0x31, 0x70, - 0xfd, 0x26, 0xbc, 0xf3, 0x28, 0xf5, 0x8d, 0xaa, 0xb4, 0xf5, 0x27, 0x14, 0x6c, 0x47, 0xb4, 0xcf, - 0x01, 0xdc, 0xd2, 0x68, 0x00, 0xb5, 0x22, 0x65, 0x42, 0xde, 0xdc, 0xec, 0x39, 0xef, 0x98, 0x8b, - 0x47, 0x29, 0x13, 0xbe, 0x5e, 0x95, 0xb6, 0xb6, 0xae, 0x02, 0xe9, 0x47, 0x5f, 0xe1, 0x87, 0x31, - 0x89, 0x0b, 0x2a, 0x03, 0x35, 0x82, 0x0d, 0xe8, 0xf6, 0xa1, 0xd4, 0xa0, 0x2f, 0xf0, 0xd3, 0x28, - 0x8d, 0x59, 0xc2, 0x04, 0x9d, 0xb6, 0x14, 0xd4, 0x84, 0x70, 0x8f, 0xf2, 0xc1, 0xf0, 0x4f, 0xc6, - 0xc3, 0x79, 0x0b, 0x20, 0x03, 0xea, 0xa3, 0x94, 0x9d, 0x1c, 0xb0, 0x84, 0xb6, 0xd4, 0x9f, 0xda, - 0xf2, 0xc2, 0x56, 0xfc, 0xa3, 0x55, 0x65, 0x81, 0xab, 0xca, 0x02, 0xd7, 0x95, 0x05, 0x6e, 0x2b, - 0x0b, 0x2c, 0xef, 0x2c, 0xe5, 0x10, 0xd7, 0x1e, 0x96, 0xe6, 0x59, 0x18, 0xba, 0x53, 0x7a, 0xec, - 0xa5, 0x94, 0xcf, 0x72, 0x97, 0x64, 0xcc, 0x8d, 0xb8, 0x57, 0x4f, 0x70, 0xa9, 0x7e, 0x93, 0x8b, - 0xf0, 0xaf, 0xfd, 0xff, 0x2f, 0xd2, 0x4c, 0x3e, 0xca, 0x8f, 0xf6, 0x1f, 0x02, 0x00, 0x00, 0xff, - 0xff, 0xf8, 0x32, 0x27, 0x9d, 0x2a, 0x02, 0x00, 0x00, -} - -func (m *StorageGroup) 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 *StorageGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StorageGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Lifetime != nil { - { - size, err := m.Lifetime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - { - size := m.ValidationHash.Size() - i -= size - if _, err := m.ValidationHash.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.ValidationDataSize != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.ValidationDataSize)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *StorageGroup_Lifetime) 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 *StorageGroup_Lifetime) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StorageGroup_Lifetime) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Value != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Value)) - i-- - dAtA[i] = 0x10 - } - if m.Unit != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Unit)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { - offset -= sovTypes(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StorageGroup) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ValidationDataSize != 0 { - n += 1 + sovTypes(uint64(m.ValidationDataSize)) - } - l = m.ValidationHash.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.Lifetime != nil { - l = m.Lifetime.Size() - n += 1 + l + sovTypes(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *StorageGroup_Lifetime) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Unit != 0 { - n += 1 + sovTypes(uint64(m.Unit)) - } - if m.Value != 0 { - n += 1 + sovTypes(uint64(m.Value)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StorageGroup) 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 ErrIntOverflowTypes - } - 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: StorageGroup: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StorageGroup: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidationDataSize", wireType) - } - m.ValidationDataSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ValidationDataSize |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidationHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ValidationHash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lifetime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Lifetime == nil { - m.Lifetime = &StorageGroup_Lifetime{} - } - if err := m.Lifetime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StorageGroup_Lifetime) 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 ErrIntOverflowTypes - } - 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: Lifetime: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Lifetime: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Unit", wireType) - } - m.Unit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Unit |= StorageGroup_Lifetime_Unit(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - m.Value = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Value |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTypes(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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrIntOverflowTypes - } - 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, ErrInvalidLengthTypes - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTypes - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTypes - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") -) diff --git a/storagegroup/types.proto b/storagegroup/types.proto deleted file mode 100644 index fde33aa..0000000 --- a/storagegroup/types.proto +++ /dev/null @@ -1,36 +0,0 @@ -syntax = "proto3"; -package storagegroup; -option go_package = "github.com/nspcc-dev/neofs-api-go/storagegroup"; -option csharp_namespace = "NeoFS.API.StorageGroup"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option (gogoproto.stable_marshaler_all) = true; - -message StorageGroup { - option (gogoproto.goproto_stringer) = false; - - // ValidationDataSize is size of the all object's payloads included into storage group - uint64 ValidationDataSize = 1; - // ValidationHash is homomorphic hash of all object's payloads included into storage group - bytes ValidationHash = 2 [(gogoproto.customtype) = "Hash", (gogoproto.nullable) = false]; - - message Lifetime { - enum Unit { - // Unlimited set if storage group always valid - Unlimited = 0; - // NeoFSEpoch set if storage group is valid until lifetime NeoFS epoch - NeoFSEpoch = 1; - // UnixTime set if storage group is valid until lifetime unix timestamp - UnixTime = 2; - } - - // Unit is lifetime type - Unit unit = 1 [(gogoproto.customname) = "Unit"]; - // Value for lifetime - int64 Value = 2; - } - - // Lifetime is time until storage group is valid - Lifetime lifetime = 3 [(gogoproto.customname) = "Lifetime"]; -}