diff --git a/Makefile b/Makefile index 860eb9d..b8828d7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: build test deps build-dev SHELL=/usr/bin/env bash export GOPRIVATE=github.com/anyproto -export PATH:=deps:$(PATH) +export PATH:=$(CURDIR)/deps:$(PATH) export CGO_ENABLED:=1 BUILD_GOOS:=$(shell go env GOOS) BUILD_GOARCH:=$(shell go env GOARCH) @@ -25,8 +25,27 @@ test: deps: go mod download + go build -o deps google.golang.org/protobuf/cmd/protoc-gen-go + go build -o deps github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto go build -o deps github.com/ahmetb/govvv - go build -o deps github.com/gogo/protobuf/protoc-gen-gogofaster + go build -o deps go.uber.org/mock/mockgen + +mocks: + echo 'Generating mocks...' + go generate ./... + +PROTOC=protoc +PROTOC_GEN_GO=deps/protoc-gen-go +PROTOC_GEN_VTPROTO=deps/protoc-gen-go-vtproto + +define generate_proto + @echo "Generating Protobuf for directory: $(1)" + $(PROTOC) \ + --go_out=. --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \ + --go-vtproto_out=. --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_VTPROTO)" \ + --go-vtproto_opt=features=marshal+unmarshal+size \ + --proto_path=$(1) $(wildcard $(1)/*.proto) +endef proto: - protoc --gogofaster_out=:. index/indexproto/protos/*.proto + $(call generate_proto,index/indexproto/protos) diff --git a/deletelog/deletelog.go b/deletelog/deletelog.go index aeb27a2..09ea8c0 100644 --- a/deletelog/deletelog.go +++ b/deletelog/deletelog.go @@ -15,6 +15,7 @@ import ( "github.com/redis/go-redis/v9" "go.uber.org/zap" + "github.com/anyproto/any-sync-filenode/filenode" "github.com/anyproto/any-sync-filenode/index" "github.com/anyproto/any-sync-filenode/redisprovider" ) @@ -37,6 +38,7 @@ type deleteLog struct { redsync *redsync.Redsync ticker periodicsync.PeriodicSync index index.Index + filenode filenode.Service disableTicker bool } @@ -45,6 +47,7 @@ func (d *deleteLog) Init(a *app.App) (err error) { d.coordinatorClient = a.MustComponent(coordinatorclient.CName).(coordinatorclient.CoordinatorClient) d.redsync = redsync.New(goredis.NewPool(d.redis)) d.index = a.MustComponent(index.CName).(index.Index) + d.filenode = a.MustComponent(filenode.CName).(filenode.Service) return } @@ -79,24 +82,20 @@ func (d *deleteLog) checkLog(ctx context.Context) (err error) { return } var handledCount, deletedCount int - var ok bool for _, rec := range recs { - if rec.Status == coordinatorproto.DeletionLogRecordStatus_Remove && rec.FileGroup != "" { - key := index.Key{ - GroupId: rec.FileGroup, - SpaceId: rec.SpaceId, - } - ok, err = d.index.SpaceDelete(ctx, key) - if err != nil && !errors.Is(err, redis.Nil) && !errors.Is(err, index.ErrSpaceIsDeleted) { - return - } - handledCount++ - if _, err = d.index.MarkSpaceAsDeleted(ctx, key); err != nil { - return - } - if ok { - deletedCount++ - } + var ok bool + switch rec.Status { + case coordinatorproto.DeletionLogRecordStatus_Remove: + ok, err = d.handleDeletion(ctx, rec) + case coordinatorproto.DeletionLogRecordStatus_OwnershipChange: + err = d.handleOwnershipTransfer(ctx, rec) + } + if err != nil { + return + } + handledCount++ + if ok { + deletedCount++ } if err = d.redis.Set(ctx, lastKey, rec.Id, 0).Err(); err != nil { return @@ -111,6 +110,28 @@ func (d *deleteLog) checkLog(ctx context.Context) (err error) { return } +func (d *deleteLog) handleDeletion(ctx context.Context, rec *coordinatorproto.DeletionLogRecord) (ok bool, err error) { + if rec.FileGroup == "" { + return + } + key := index.Key{ + GroupId: rec.FileGroup, + SpaceId: rec.SpaceId, + } + ok, err = d.index.SpaceDelete(ctx, key) + if err != nil && !errors.Is(err, redis.Nil) && !errors.Is(err, index.ErrSpaceIsDeleted) { + return + } + if _, err = d.index.MarkSpaceAsDeleted(ctx, key); err != nil { + return + } + return ok, nil +} + +func (d *deleteLog) handleOwnershipTransfer(ctx context.Context, rec *coordinatorproto.DeletionLogRecord) (err error) { + return d.filenode.OwnershipTransfer(ctx, rec.SpaceId, rec.FileGroup, rec.AclRecordId) +} + func (d *deleteLog) Close(ctx context.Context) (err error) { if d.ticker != nil { d.ticker.Close() diff --git a/deletelog/deletelog_test.go b/deletelog/deletelog_test.go index 2092b39..92ec333 100644 --- a/deletelog/deletelog_test.go +++ b/deletelog/deletelog_test.go @@ -13,6 +13,8 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + "github.com/anyproto/any-sync-filenode/filenode" + "github.com/anyproto/any-sync-filenode/filenode/mock_filenode" "github.com/anyproto/any-sync-filenode/index" "github.com/anyproto/any-sync-filenode/index/mock_index" "github.com/anyproto/any-sync-filenode/redisprovider/testredisprovider" @@ -59,6 +61,26 @@ func TestDeleteLog_checkLog(t *testing.T) { assert.Equal(t, "2", lastId) }) + t.Run("ownership change", func(t *testing.T) { + fx := newFixture(t) + defer fx.finish(t) + now := time.Now().Unix() + fx.coord.EXPECT().DeletionLog(ctx, "", recordsLimit).Return([]*coordinatorproto.DeletionLogRecord{ + { + Id: "1", + SpaceId: "s1", + Status: coordinatorproto.DeletionLogRecordStatus_OwnershipChange, + Timestamp: now, + FileGroup: "f1", + AclRecordId: "acl1", + }, + }, nil) + fx.filenode.EXPECT().OwnershipTransfer(ctx, "s1", "f1", "acl1").Return(nil) + require.NoError(t, fx.checkLog(ctx)) + lastId, err := fx.redis.Get(ctx, lastKey).Result() + require.NoError(t, err) + assert.Equal(t, "1", lastId) + }) } func newFixture(t *testing.T) *fixture { @@ -68,6 +90,7 @@ func newFixture(t *testing.T) *fixture { a: new(app.App), coord: mock_coordinatorclient.NewMockCoordinatorClient(ctrl), index: mock_index.NewMockIndex(ctrl), + filenode: mock_filenode.NewMockService(ctrl), deleteLog: New().(*deleteLog), } fx.disableTicker = true @@ -77,18 +100,25 @@ func newFixture(t *testing.T) *fixture { fx.index.EXPECT().Init(gomock.Any()).AnyTimes() fx.index.EXPECT().Run(gomock.Any()).AnyTimes() fx.index.EXPECT().Close(gomock.Any()).AnyTimes() + fx.filenode.EXPECT().Name().Return(filenode.CName).AnyTimes() + fx.filenode.EXPECT().Init(gomock.Any()).AnyTimes() - fx.a.Register(testredisprovider.NewTestRedisProviderNum(7)).Register(fx.coord).Register(fx.index).Register(fx.deleteLog) + fx.a.Register(testredisprovider.NewTestRedisProviderNum(7)). + Register(fx.coord). + Register(fx.index). + Register(fx.filenode). + Register(fx.deleteLog) require.NoError(t, fx.a.Start(ctx)) return fx } type fixture struct { - ctrl *gomock.Controller - a *app.App - coord *mock_coordinatorclient.MockCoordinatorClient - index *mock_index.MockIndex + ctrl *gomock.Controller + a *app.App + coord *mock_coordinatorclient.MockCoordinatorClient + index *mock_index.MockIndex + filenode *mock_filenode.MockService *deleteLog } diff --git a/etc/any-sync-filenode.yml b/etc/any-sync-filenode.yml index 59a5373..2d8fe36 100755 --- a/etc/any-sync-filenode.yml +++ b/etc/any-sync-filenode.yml @@ -69,4 +69,4 @@ network: networkStorePath: . networkUpdateIntervalSec: 600 defaultLimit: 1073741824 -persistTtl: 300 +persistTtl: 1800 diff --git a/filenode/filenode.go b/filenode/filenode.go index 706bf4d..d69aa46 100644 --- a/filenode/filenode.go +++ b/filenode/filenode.go @@ -17,6 +17,7 @@ import ( "github.com/anyproto/any-sync/net/peer" "github.com/anyproto/any-sync/net/rpc/server" "github.com/anyproto/any-sync/nodeconf" + "github.com/anyproto/any-sync/util/crypto" blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" "go.uber.org/zap" @@ -37,7 +38,9 @@ func New() Service { return new(fileNode) } +//go:generate mockgen -destination mock_filenode/mock_filenode.go github.com/anyproto/any-sync-filenode/filenode Service type Service interface { + OwnershipTransfer(ctx context.Context, spaceId, oldIdentity string, aclRecordId string) (err error) app.Component } @@ -180,13 +183,24 @@ func (fn *fileNode) StoreKey(ctx context.Context, spaceId string, checkLimit boo return storageKey, fileprotoerr.ErrForbidden } - ownerPubKey, err := fn.acl.OwnerPubKey(ctx, spaceId) - if err != nil { - log.WarnCtx(ctx, "acl ownerPubKey error", zap.Error(err)) - return storageKey, fileprotoerr.ErrForbidden - } + var ( + ownerPubKey crypto.PubKey + ownerRecordIndex int + isOneToOne bool + ) - err = fn.acl.ReadState(ctx, spaceId, func(aclState *list.AclState) error { + err = fn.acl.ReadList(ctx, spaceId, func(aclList list.AclList) error { + aclState := aclList.AclState() + var ownerRecordId string + if ownerPubKey, ownerRecordId, err = aclState.OwnerPubKeyWithRecordId(); err != nil { + log.WarnCtx(ctx, "acl ownerPubKey error", zap.Error(err)) + return fileprotoerr.ErrForbidden + } + ownerRecordIndex = aclList.GetRecordIndex(ownerRecordId) + if ownerRecordIndex < 0 { + log.ErrorCtx(ctx, "acl ownerRecordIndex not found", zap.String("spaceId", spaceId), zap.String("recordId", ownerRecordId), zap.Error(err)) + return fileprotoerr.ErrUnexpected + } if aclState.IsOneToOne() { if aclState.Permissions(identity).NoPermissions() { return fileprotoerr.ErrForbidden @@ -207,6 +221,7 @@ func (fn *fileNode) StoreKey(ctx context.Context, spaceId string, checkLimit boo GroupId: identity.Account(), SpaceId: newSpaceId, } + isOneToOne = true } else { storageKey = index.Key{ GroupId: ownerPubKey.Account(), @@ -231,10 +246,19 @@ func (fn *fileNode) StoreKey(ctx context.Context, spaceId string, checkLimit boo } } - if e := fn.index.Migrate(ctx, storageKey); e != nil { - log.WarnCtx(ctx, "space migrate error", zap.String("spaceId", spaceId), zap.Error(e)) + if !isOneToOne { + if e := fn.index.Migrate(ctx, storageKey); e != nil { + log.WarnCtx(ctx, "space migrate error", zap.String("spaceId", spaceId), zap.Error(e)) + } + var oldIdentity string + if ownerRecordIndex == 0 { + oldIdentity = storageKey.GroupId + } + if err = fn.index.CheckAndMoveOwnership(ctx, storageKey, oldIdentity, ownerRecordIndex); err != nil { + log.ErrorCtx(ctx, "check ownership error", zap.String("spaceId", spaceId), zap.Error(err)) + return storageKey, fileprotoerr.ErrUnexpected + } } - if checkLimit { if err = fn.index.CheckLimits(ctx, storageKey); err != nil { if errors.Is(err, index.ErrLimitExceed) { @@ -417,3 +441,35 @@ func (fn *fileNode) FilesGet(ctx context.Context, spaceId string) (fileIds []str } return fn.index.FilesList(ctx, storeKey) } + +func (fn *fileNode) OwnershipTransfer(ctx context.Context, spaceId, oldIdentity, aclRecordId string) (err error) { + var ( + ownerPubKey crypto.PubKey + ownerRecordIndex int + ) + defer func() { + log.InfoCtx(ctx, "ownership transfer", zap.String("spaceId", spaceId), zap.String("recordId", aclRecordId), zap.Error(err)) + }() + err = fn.acl.ReadList(ctx, spaceId, func(aclList list.AclList) error { + if !aclList.HasHead(aclRecordId) { + log.WarnCtx(ctx, "ownership transfer error: acl record not found", zap.String("spaceId", spaceId), zap.String("recordId", aclRecordId)) + return fileprotoerr.ErrAclRecordNotFound + } + aclState := aclList.AclState() + var ownerRecordId string + if ownerPubKey, ownerRecordId, err = aclState.OwnerPubKeyWithRecordId(); err != nil { + log.WarnCtx(ctx, "acl ownerPubKey error", zap.Error(err)) + return fileprotoerr.ErrForbidden + } + ownerRecordIndex = aclList.GetRecordIndex(ownerRecordId) + if ownerRecordIndex < 0 { + log.ErrorCtx(ctx, "acl ownerRecordIndex not found", zap.String("spaceId", spaceId), zap.String("recordId", ownerRecordId), zap.Error(err)) + return fileprotoerr.ErrUnexpected + } + return nil + }) + if err != nil { + return + } + return fn.index.CheckAndMoveOwnership(ctx, index.Key{GroupId: ownerPubKey.Account(), SpaceId: spaceId}, oldIdentity, ownerRecordIndex) +} diff --git a/filenode/filenode_test.go b/filenode/filenode_test.go index 0f423be..76ae305 100644 --- a/filenode/filenode_test.go +++ b/filenode/filenode_test.go @@ -36,20 +36,24 @@ func TestFileNode_Add(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() - fileId = testutil.NewRandCid().String() - b = testutil.NewRandBlock(1024) + _, storeKey = newRandKey() + fileId = testutil.NewRandCid().String() + b = testutil.NewRandBlock(1024) ) - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(aclList list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().CheckLimits(ctx, storeKey) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().BlocksLock(ctx, []blocks.Block{b}).Return(func() {}, nil) fx.index.EXPECT().BlocksGetNonExistent(ctx, []blocks.Block{b}).Return([]blocks.Block{b}, nil) fx.store.EXPECT().Add(ctx, []blocks.Block{b}) @@ -72,19 +76,23 @@ func TestFileNode_Add(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() - fileId = testutil.NewRandCid().String() - b = testutil.NewRandBlock(1024) + _, storeKey = newRandKey() + fileId = testutil.NewRandCid().String() + b = testutil.NewRandBlock(1024) ) - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().CheckLimits(ctx, storeKey).Return(index.ErrLimitExceed) resp, err := fx.handler.BlockPush(ctx, &fileproto.BlockPushRequest{ @@ -191,20 +199,25 @@ func TestFileNode_Get(t *testing.T) { func TestFileNode_Check(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) - var ctx, storeKey = newRandKey() + var _, storeKey = newRandKey() var bs = testutil.NewRandBlocks(3) cids := make([][]byte, len(bs)) for _, b := range bs { cids = append(cids, b.Cid().Bytes()) } - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().CidExistsInSpace(ctx, storeKey, testutil.BlocksToKeys(bs)).Return(testutil.BlocksToKeys(bs[:1]), nil) fx.index.EXPECT().CidExists(ctx, bs[1].Cid()).Return(true, nil) fx.index.EXPECT().CidExists(ctx, bs[2].Cid()).Return(false, nil) @@ -223,27 +236,31 @@ func TestFileNode_BlocksBind(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() - fileId = testutil.NewRandCid().String() - bs = testutil.NewRandBlocks(3) - cidsB = make([][]byte, len(bs)) - cids = make([]cid.Cid, len(bs)) - cidEntries = &index.CidEntries{} + _, storeKey = newRandKey() + fileId = testutil.NewRandCid().String() + bs = testutil.NewRandBlocks(3) + cidsB = make([][]byte, len(bs)) + cids = make([]cid.Cid, len(bs)) + cidEntries = &index.CidEntries{} ) for i, b := range bs { cids[i] = b.Cid() cidsB[i] = b.Cid().Bytes() } - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().CheckLimits(ctx, storeKey) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().CidEntries(ctx, cids).Return(cidEntries, nil) fx.index.EXPECT().FileBind(ctx, storeKey, fileId, cidEntries) @@ -262,18 +279,23 @@ func TestFileNode_FileInfo(t *testing.T) { defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() - fileId1 = testutil.NewRandCid().String() - fileId2 = testutil.NewRandCid().String() + _, storeKey = newRandKey() + fileId1 = testutil.NewRandCid().String() + fileId2 = testutil.NewRandCid().String() ) - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().FileInfo(ctx, storeKey, fileId1, fileId2).Return([]index.FileInfo{{1, 1}, {2, 2}}, nil) resp, err := fx.handler.FilesInfo(ctx, &fileproto.FilesInfoRequest{ @@ -340,16 +362,21 @@ func TestFileNode_SpaceInfo(t *testing.T) { defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() + _, storeKey = newRandKey() ) - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().GroupInfo(ctx, storeKey.GroupId).Return(index.GroupInfo{ BytesUsage: 100, @@ -380,18 +407,21 @@ func TestFileNode_SpaceInfo(t *testing.T) { defer fx.Finish(t) var ( - ctx, storeKey = newRandKey() + _, storeKey = newRandKey() ) storeKey.SpaceId = fmt.Sprintf("%s#1", storeKey.SpaceId) + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().GroupInfo(ctx, storeKey.GroupId).Return(index.GroupInfo{ BytesUsage: 100, @@ -423,21 +453,21 @@ func TestFileNode_StoreKey(t *testing.T) { defer fx.Finish(t) spaceId := "spaceId" - aclState := defaultAclState(t, spaceId) - idRaw, _ := aclState.Identity().Marshall() + aclList := defaultAclList(t, spaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() ctx := peer.CtxWithIdentity(context.Background(), idRaw) expectedStoreKey := index.Key{ - GroupId: aclState.Identity().Account(), + GroupId: aclList.AclState().Identity().Account(), SpaceId: "spaceId", } fx.index.EXPECT().Migrate(ctx, expectedStoreKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, expectedStoreKey, expectedStoreKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().CheckLimits(ctx, expectedStoreKey) - fx.aclService.EXPECT().OwnerPubKey(ctx, "spaceId").Return(aclState.OwnerPubKey()) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - return fn(aclState) + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) actualStoreKey, err := fx.StoreKey(ctx, "spaceId", true) @@ -456,29 +486,27 @@ func TestFileNode_StoreKey(t *testing.T) { // checks permissions using Storage() fn, and acl test suit executor can't parse // such commands with stringified binaries instead of names spaceId := "spaceId" - aclState := oneToOneAclState(t, spaceId) - idRaw, _ := aclState.Identity().Marshall() + aclList := oneToOneAclList(t, spaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() ctx := peer.CtxWithIdentity(context.Background(), idRaw) // make suffix via oneToOneSpaceId to avoid test flakiness: // acltestsuite uses random to generate accounts. // oneToOneSpaceId is tested separately. - statePubKeys, err := oneToOneParticipantPubKeys(aclState.CurrentAccounts()) + statePubKeys, err := oneToOneParticipantPubKeys(aclList.AclState().CurrentAccounts()) require.NoError(t, err) - expectedSuffix, err := oneToOneSpaceId(aclState.Identity().Storage(), statePubKeys, spaceId) + expectedSuffix, err := oneToOneSpaceId(aclList.AclState().Identity().Storage(), statePubKeys, spaceId) require.NoError(t, err) expectedStoreKey := index.Key{ - GroupId: aclState.Identity().Account(), + GroupId: aclList.AclState().Identity().Account(), SpaceId: expectedSuffix, } - fx.index.EXPECT().Migrate(ctx, expectedStoreKey) fx.index.EXPECT().CheckLimits(ctx, expectedStoreKey) - fx.aclService.EXPECT().OwnerPubKey(ctx, "spaceId").Return(aclState.OwnerPubKey()) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - return fn(aclState) + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) actualStoreKey, err := fx.StoreKey(ctx, "spaceId", true) @@ -492,13 +520,12 @@ func TestFileNode_StoreKey(t *testing.T) { defer fx.Finish(t) spaceId := "spaceId" - aclState := oneToOneAclState(t, spaceId) + aclList := oneToOneAclList(t, spaceId) ctx, _ := newRandKey() - fx.aclService.EXPECT().OwnerPubKey(ctx, "spaceId").Return(aclState.OwnerPubKey()) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - return fn(aclState) + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) _, err := fx.StoreKey(ctx, "spaceId", true) @@ -537,20 +564,25 @@ func TestFileNode_SpaceLimitSet(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) - ctx, storeKey := newRandKey() - fx.aclService.EXPECT().OwnerPubKey(ctx, storeKey.SpaceId).Return(mustPubKey(ctx), nil) - fx.aclService.EXPECT().ReadState(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, spaceId string, fn func(*list.AclState) error) error { - state := defaultAclState(t, spaceId) - return fn(state) + _, storeKey := newRandKey() + + aclList := defaultAclList(t, storeKey.SpaceId) + idRaw, _ := aclList.AclState().Identity().Marshall() + storeKey.GroupId = aclList.AclState().Identity().Account() + ctx := peer.CtxWithIdentity(context.Background(), idRaw) + + fx.aclService.EXPECT().ReadList(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, spaceId string, fn func(list.AclList) error) error { + return fn(aclList) }) fx.index.EXPECT().Migrate(ctx, storeKey) + fx.index.EXPECT().CheckAndMoveOwnership(ctx, storeKey, storeKey.GroupId, gomock.Any()).Return(nil) fx.index.EXPECT().SetSpaceLimit(ctx, storeKey, uint64(12345)) require.NoError(t, fx.SpaceLimitSet(ctx, storeKey.SpaceId, 12345)) } -func newAclState(t *testing.T, spaceId string, initCmd string) *list.AclState { +func newAclList(t *testing.T, spaceId string, initCmd string) list.AclList { a := list.NewAclExecutor(spaceId) cmds := []string{ initCmd, @@ -559,14 +591,14 @@ func newAclState(t *testing.T, spaceId string, initCmd string) *list.AclState { err := a.Execute(cmd) require.NoError(t, err) } - return a.ActualAccounts()["a"].Acl.AclState() + return a.ActualAccounts()["a"].Acl } -func oneToOneAclState(t *testing.T, spaceId string) *list.AclState { - return newAclState(t, spaceId, "a;b.init-onetoone::a;b") +func oneToOneAclList(t *testing.T, spaceId string) list.AclList { + return newAclList(t, spaceId, "a;b.init-onetoone::a;b") } -func defaultAclState(t *testing.T, spaceId string) *list.AclState { - return newAclState(t, spaceId, "a.init::a") +func defaultAclList(t *testing.T, spaceId string) list.AclList { + return newAclList(t, spaceId, "a.init::a") } func newFixture(t *testing.T) *fixture { diff --git a/filenode/mock_filenode/mock_filenode.go b/filenode/mock_filenode/mock_filenode.go new file mode 100644 index 0000000..2b87d52 --- /dev/null +++ b/filenode/mock_filenode/mock_filenode.go @@ -0,0 +1,84 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/anyproto/any-sync-filenode/filenode (interfaces: Service) +// +// Generated by this command: +// +// mockgen -destination mock_filenode/mock_filenode.go github.com/anyproto/any-sync-filenode/filenode Service +// + +// Package mock_filenode is a generated GoMock package. +package mock_filenode + +import ( + context "context" + reflect "reflect" + + app "github.com/anyproto/any-sync/app" + gomock "go.uber.org/mock/gomock" +) + +// MockService is a mock of Service interface. +type MockService struct { + ctrl *gomock.Controller + recorder *MockServiceMockRecorder + isgomock struct{} +} + +// MockServiceMockRecorder is the mock recorder for MockService. +type MockServiceMockRecorder struct { + mock *MockService +} + +// NewMockService creates a new mock instance. +func NewMockService(ctrl *gomock.Controller) *MockService { + mock := &MockService{ctrl: ctrl} + mock.recorder = &MockServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockService) EXPECT() *MockServiceMockRecorder { + return m.recorder +} + +// Init mocks base method. +func (m *MockService) Init(a *app.App) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Init", a) + ret0, _ := ret[0].(error) + return ret0 +} + +// Init indicates an expected call of Init. +func (mr *MockServiceMockRecorder) Init(a any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockService)(nil).Init), a) +} + +// Name mocks base method. +func (m *MockService) Name() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Name") + ret0, _ := ret[0].(string) + return ret0 +} + +// Name indicates an expected call of Name. +func (mr *MockServiceMockRecorder) Name() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockService)(nil).Name)) +} + +// OwnershipTransfer mocks base method. +func (m *MockService) OwnershipTransfer(ctx context.Context, spaceId, oldIdentity, aclRecordId string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OwnershipTransfer", ctx, spaceId, oldIdentity, aclRecordId) + ret0, _ := ret[0].(error) + return ret0 +} + +// OwnershipTransfer indicates an expected call of OwnershipTransfer. +func (mr *MockServiceMockRecorder) OwnershipTransfer(ctx, spaceId, oldIdentity, aclRecordId any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OwnershipTransfer", reflect.TypeOf((*MockService)(nil).OwnershipTransfer), ctx, spaceId, oldIdentity, aclRecordId) +} diff --git a/filenode/onetooneutils_test.go b/filenode/onetooneutils_test.go index 250dfce..ec3c4f7 100644 --- a/filenode/onetooneutils_test.go +++ b/filenode/onetooneutils_test.go @@ -175,8 +175,8 @@ func Test_oneToOneParticipantPubKeys(t *testing.T) { fx := newFixture(t) defer fx.Finish(t) spaceId := "spaceId" - aclState := oneToOneAclState(t, spaceId) - accounts := aclState.CurrentAccounts() + aclList := oneToOneAclList(t, spaceId) + accounts := aclList.AclState().CurrentAccounts() t.Run("basic test", func(t *testing.T) { writersPubKeys, err := oneToOneParticipantPubKeys(accounts) @@ -184,7 +184,7 @@ func Test_oneToOneParticipantPubKeys(t *testing.T) { require.NoError(t, err) assert.False(t, bytes.Equal(writersPubKeys[0], writersPubKeys[1])) - ownerPubKey, _ := aclState.OwnerPubKey() + ownerPubKey, _ := aclList.AclState().OwnerPubKey() ownerBytes := ownerPubKey.Storage() assert.False(t, bytes.Equal(writersPubKeys[0], ownerBytes)) assert.False(t, bytes.Equal(writersPubKeys[1], ownerBytes)) diff --git a/go.mod b/go.mod index b77dee5..17d7008 100644 --- a/go.mod +++ b/go.mod @@ -8,26 +8,27 @@ require ( github.com/OneOfOne/xxhash v1.2.8 github.com/ahmetb/govvv v0.3.0 github.com/anyproto/any-store v0.4.3 - github.com/anyproto/any-sync v0.11.4 + github.com/anyproto/any-sync v0.11.7 github.com/aws/aws-sdk-go v1.55.8 github.com/cespare/xxhash/v2 v2.3.0 github.com/go-redsync/redsync/v4 v4.14.0 - github.com/gogo/protobuf v1.3.2 github.com/golang/snappy v1.0.0 github.com/ipfs/go-block-format v0.2.3 github.com/ipfs/go-cid v0.6.0 + github.com/planetscale/vtprotobuf v0.6.0 github.com/redis/go-redis/v9 v9.17.0 github.com/stretchr/testify v1.11.1 go.uber.org/mock v0.6.0 go.uber.org/zap v1.27.1 - golang.org/x/sync v0.18.0 + golang.org/x/sync v0.19.0 + google.golang.org/protobuf v1.36.11 gopkg.in/yaml.v3 v3.0.1 ) require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/anyproto/go-chash v0.1.0 // indirect - github.com/anyproto/go-slip10 v1.0.1-0.20250818123350-f910c27dd080 // indirect + github.com/anyproto/go-slip10 v1.0.1 // indirect github.com/anyproto/go-slip21 v1.0.0 // indirect github.com/anyproto/go-sqlite v1.4.2-any // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -51,7 +52,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.45.0 // indirect + github.com/libp2p/go-libp2p v0.46.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mr-tron/base58 v1.2.0 // indirect @@ -65,13 +66,12 @@ require ( github.com/multiformats/go-varint v0.1.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/planetscale/vtprotobuf v0.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.23.2 // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.66.1 // indirect github.com/prometheus/procfs v0.17.0 // indirect - github.com/quic-go/quic-go v0.56.0 // indirect + github.com/quic-go/quic-go v0.58.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect @@ -80,12 +80,11 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect - golang.org/x/crypto v0.44.0 // indirect + golang.org/x/crypto v0.46.0 // indirect golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect - golang.org/x/net v0.47.0 // indirect - golang.org/x/sys v0.38.0 // indirect + golang.org/x/net v0.48.0 // indirect + golang.org/x/sys v0.39.0 // indirect golang.org/x/time v0.14.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect lukechampine.com/blake3 v1.4.1 // indirect modernc.org/libc v1.66.8 // indirect modernc.org/mathutil v1.7.1 // indirect diff --git a/go.sum b/go.sum index 2920fc5..edadde7 100644 --- a/go.sum +++ b/go.sum @@ -8,12 +8,12 @@ github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0= github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s= github.com/anyproto/any-store v0.4.3 h1:8H5TXPhlgGnUIOVNtLXFE2Dy2tYvLQCQuEYPSymMyhY= github.com/anyproto/any-store v0.4.3/go.mod h1:P9CnoL9Q06eh051DwtcvCiiWCwdXO7AbEILcnD6yrss= -github.com/anyproto/any-sync v0.11.4 h1:aq466wLCSI7hXSuckqzC9GXnU/pBuMm4GHLZYQetCjk= -github.com/anyproto/any-sync v0.11.4/go.mod h1:KogFi29ev5K1nwwP8cgCphpZdIXRTfj6nZl/6k8RLEM= +github.com/anyproto/any-sync v0.11.7 h1:pfaalr2U7/pRDNLf0EVAKocR5W0BiBFZWYaVZbLJwG0= +github.com/anyproto/any-sync v0.11.7/go.mod h1:lhjZHy+93ns16hriKmnErWS8F7IjCjb19FrROpOBoJI= github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY= github.com/anyproto/go-chash v0.1.0/go.mod h1:0UjNQi3PDazP0fINpFYu6VKhuna+W/V+1vpXHAfNgLY= -github.com/anyproto/go-slip10 v1.0.1-0.20250818123350-f910c27dd080 h1:bbHmaibcUbctrXG6LT6136H0oDlBUDoDANX2qBpqhkU= -github.com/anyproto/go-slip10 v1.0.1-0.20250818123350-f910c27dd080/go.mod h1:BCmIlM1KB8wX6K4/8pOvxPl9oVKfEvZ5vsmO5rkK6vg= +github.com/anyproto/go-slip10 v1.0.1 h1:Pa/OpYoOE668fip4ygAd4T07chLBx4XoBa5fwnGq0/M= +github.com/anyproto/go-slip10 v1.0.1/go.mod h1:BCmIlM1KB8wX6K4/8pOvxPl9oVKfEvZ5vsmO5rkK6vg= github.com/anyproto/go-slip21 v1.0.0 h1:CI7lUqTIwmPOEGVAj4jyNLoICvueh++0U2HoAi3m2ZY= github.com/anyproto/go-slip21 v1.0.0/go.mod h1:gbIJt7HAdr5DuT4f2pFTKCBSUWYsm/fysHBNqgsuxT0= github.com/anyproto/go-sqlite v1.4.2-any h1:ZTIcq/u2mYYJ6rJB4I3Ds5QH/7IlONebMiG14FyZcD4= @@ -71,8 +71,6 @@ github.com/go-redsync/redsync/v4 v4.14.0 h1:zyxzFJsmQHIPBl8iBT7KFKohWsjsghgGLiP8 github.com/go-redsync/redsync/v4 v4.14.0/go.mod h1:twMlVd19upZ/juvJyJGlQOSQxor1oeHtjs62l4pRFzo= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -104,8 +102,6 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= @@ -119,8 +115,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-libp2p v0.45.0 h1:Pdhr2HsFXaYjtfiNcBP4CcRUONvbMFdH3puM9vV4Tiw= -github.com/libp2p/go-libp2p v0.45.0/go.mod h1:NovCojezAt4dnDd4fH048K7PKEqH0UFYYqJRjIIu8zc= +github.com/libp2p/go-libp2p v0.46.0 h1:0T2yvIKpZ3DVYCuPOFxPD1layhRU486pj9rSlGWYnDM= +github.com/libp2p/go-libp2p v0.46.0/go.mod h1:TbIDnpDjBLa7isdgYpbxozIVPBTmM/7qKOJP4SFySrQ= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= github.com/libp2p/go-yamux/v5 v5.0.1 h1:f0WoX/bEF2E8SbE4c/k1Mo+/9z0O4oC/hWEA+nfYRSg= @@ -166,8 +162,8 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0= github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw= -github.com/quic-go/quic-go v0.56.0 h1:q/TW+OLismmXAehgFLczhCDTYB3bFmua4D9lsNBWxvY= -github.com/quic-go/quic-go v0.56.0/go.mod h1:9gx5KsFQtw2oZ6GZTyh+7YEvOxWCL9WZAepnHxgAo6c= +github.com/quic-go/quic-go v0.58.0 h1:ggY2pvZaVdB9EyojxL1p+5mptkuHyX5MOSv4dgWF4Ug= +github.com/quic-go/quic-go v0.58.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU= github.com/redis/go-redis/v9 v9.17.0 h1:K6E+ZlYN95KSMmZeEQPbU/c++wfmEvfFB17yEAq/VhM= github.com/redis/go-redis/v9 v9.17.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= github.com/redis/rueidis v1.0.64 h1:XqgbueDuNV3qFdVdQwAHJl1uNt90zUuAJuzqjH4cw6Y= @@ -190,8 +186,6 @@ github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2n github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= @@ -210,57 +204,38 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= -golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY= golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= -golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= -golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= +golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/index/bind.go b/index/bind.go index a69786c..91fea6a 100644 --- a/index/bind.go +++ b/index/bind.go @@ -35,7 +35,7 @@ func (ri *redisIndex) fileBind(ctx context.Context, key Key, fileId string, cids if !fileInfo.Exists(c.Cid.String()) { newFileCidIdx = append(newFileCidIdx, i) fileInfo.Cids = append(fileInfo.Cids, c.Cid.String()) - fileInfo.Size_ += c.Size_ + fileInfo.Size += c.Size } } @@ -74,7 +74,7 @@ func (ri *redisIndex) fileBind(ctx context.Context, key Key, fileId string, cids } if !ex { entry.group.CidCount++ - entry.group.Size_ += cids.entries[idx].Size_ + entry.group.Size += cids.entries[idx].Size } } ex, err := cidExistSpaceCmds[i].Result() @@ -83,7 +83,7 @@ func (ri *redisIndex) fileBind(ctx context.Context, key Key, fileId string, cids } if !ex { entry.space.CidCount++ - entry.space.Size_ += cids.entries[idx].Size_ + entry.space.Size += cids.entries[idx].Size affectedCidIdx = append(affectedCidIdx, idx) } } @@ -118,3 +118,12 @@ func (ri *redisIndex) fileBind(ctx context.Context, key Key, fileId string, cids } return } + +func (ri *redisIndex) fileBindCidStrings(ctx context.Context, key Key, fileId string, cidStrings []string, entry groupSpaceEntry) (err error) { + cidEntries, err := ri.CidEntriesByString(ctx, cidStrings) + if err != nil { + return + } + defer cidEntries.Release() + return ri.fileBind(ctx, key, fileId, cidEntries, entry) +} diff --git a/index/check.go b/index/check.go index 14bb7cd..382f962 100644 --- a/index/check.go +++ b/index/check.go @@ -70,7 +70,7 @@ func (ri *redisIndex) Check(ctx context.Context, key Key, doFix bool) (checkResu checkResults = append(checkResults, results...) for k, ref := range check.actualRefs { sumRefs[k] += ref - sumSize += check.cidEntries[k].Size_ + sumSize += check.cidEntries[k].Size } } @@ -121,7 +121,7 @@ func (ri *redisIndex) fix(ctx context.Context, key Key, checkResults []CheckResu func (ri *redisIndex) fixSpaceEntry(ctx context.Context, key Key, check CheckResult) (err error) { se := check.SpaceEntry se.UpdateTime = time.Now().Unix() - data, err := se.Marshal() + data, err := se.MarshalVT() if err != nil { return } @@ -155,7 +155,7 @@ func (ri *redisIndex) fixGroupCid(ctx context.Context, key Key, check CheckResul func (ri *redisIndex) fixCid(ctx context.Context, v CheckResult) (err error) { ce := v.CidEntry ce.UpdateTime = time.Now().Unix() - data, err := ce.Marshal() + data, err := ce.MarshalVT() if err != nil { return err } @@ -178,7 +178,7 @@ func (ri *redisIndex) loadSpaceContent(ctx context.Context, key Key, se *spaceEn sc.cids[k[2:]], _ = strconv.ParseUint(v, 10, 64) } else if strings.HasPrefix(k, "f:") { fileEntryProto := &indexproto.FileEntry{} - if err = fileEntryProto.Unmarshal([]byte(v)); err != nil { + if err = fileEntryProto.UnmarshalVT([]byte(v)); err != nil { return } sc.files[k[2:]] = fileEntryProto @@ -233,15 +233,15 @@ func (sc *spaceContent) Check(ctx context.Context, ri *redisIndex) (checkResults for fileId, file := range sc.files { var fileSize uint64 for _, fCid := range file.Cids { - fileSize += sc.cidEntries[fCid].Size_ + fileSize += sc.cidEntries[fCid].Size } - if file.Size_ != fileSize { + if file.Size != fileSize { fix := CheckResult{ Key: "f:" + fileId, - Description: fmt.Sprintf("file size mismatch: %d -> %d", file.Size_, fileSize), + Description: fmt.Sprintf("file size mismatch: %d -> %d", file.Size, fileSize), SpaceId: sc.entry.Id, } - file.Size_ = fileSize + file.Size = fileSize fix.FileEntry = file checkResults = append(checkResults, fix) } @@ -269,21 +269,21 @@ func (sc *spaceContent) Check(ctx context.Context, ri *redisIndex) (checkResults } checkResults = append(checkResults, fix) } - sumSize += cEntry.Size_ + sumSize += cEntry.Size } // check space entry - if sc.entry.Size_ != sumSize || sc.entry.FileCount != uint32(len(sc.files)) || sc.entry.CidCount != uint64(len(sc.actualRefs)) { + if sc.entry.Size != sumSize || sc.entry.FileCount != uint32(len(sc.files)) || sc.entry.CidCount != uint64(len(sc.actualRefs)) { fix := CheckResult{ Key: "info", Description: fmt.Sprintf("space entry; size: %d -> %d; cidsCount: %d -> %d; filesCount: %d -> %d", - sc.entry.Size_, sumSize, + sc.entry.Size, sumSize, sc.entry.CidCount, len(sc.actualRefs), sc.entry.FileCount, len(sc.files), ), SpaceId: sc.entry.Id, } - sc.entry.Size_ = sumSize + sc.entry.Size = sumSize sc.entry.FileCount = uint32(len(sc.files)) sc.entry.CidCount = uint64(len(sc.actualRefs)) fix.SpaceEntry = sc.entry.SpaceEntry @@ -350,13 +350,13 @@ func (gc *groupContent) Check(cidRefs map[string]uint64, sumSize uint64) (checkR checkResults = append(checkResults, fix) } } - if gc.entry.Size_ != sumSize { + if gc.entry.Size != sumSize { fix := CheckResult{ Key: "info", GroupEntry: gc.entry.GroupEntry, - Description: fmt.Sprintf("group size mismatch: %d -> %d", gc.entry.Size_, sumSize), + Description: fmt.Sprintf("group size mismatch: %d -> %d", gc.entry.Size, sumSize), } - fix.GroupEntry.Size_ = sumSize + fix.GroupEntry.Size = sumSize fix.GroupEntry.CidCount = uint64(len(cidRefs)) checkResults = append(checkResults, fix) } diff --git a/index/check_test.go b/index/check_test.go index 5bee398..a627bc2 100644 --- a/index/check_test.go +++ b/index/check_test.go @@ -37,14 +37,14 @@ func TestRedisIndex_Check(t *testing.T) { t.Run("fix space+group size", func(t *testing.T) { se, err := fx.getSpaceEntry(ctx, key) require.NoError(t, err) - se.Size_ += 100 - seData, _ := se.Marshal() + se.Size += 100 + seData, _ := se.MarshalVT() require.NoError(t, fx.cl.HSet(ctx, SpaceKey(key), infoKey, seData).Err()) ge, err := fx.getGroupEntry(ctx, key) require.NoError(t, err) - ge.Size_ += 100 - geData, _ := ge.Marshal() + ge.Size += 100 + geData, _ := ge.MarshalVT() require.NoError(t, fx.cl.HSet(ctx, GroupKey(key), infoKey, geData).Err()) fixRes, err := fx.Check(ctx, key, true) diff --git a/index/cidentry.go b/index/cidentry.go index 77c9e31..fb24d7d 100644 --- a/index/cidentry.go +++ b/index/cidentry.go @@ -39,7 +39,7 @@ type cidEntry struct { func (ce *cidEntry) Save(ctx context.Context, cl redis.Cmdable) error { ce.UpdateTime = time.Now().Unix() - data, err := ce.Marshal() + data, err := ce.MarshalVT() if err != nil { return err } diff --git a/index/cids.go b/index/cids.go index a6ba9ab..a17b2bc 100644 --- a/index/cids.go +++ b/index/cids.go @@ -176,7 +176,7 @@ func (ri *redisIndex) getCidEntry(ctx context.Context, c cid.Cid) (entry *cidEnt return } protoEntry := &indexproto.CidEntry{} - err = protoEntry.Unmarshal([]byte(cidData)) + err = protoEntry.UnmarshalVT([]byte(cidData)) if err != nil { return } @@ -195,7 +195,7 @@ func (ri *redisIndex) createCidEntry(ctx context.Context, b blocks.Block) (entry entry = &cidEntry{ Cid: b.Cid(), CidEntry: &indexproto.CidEntry{ - Size_: uint64(len(b.RawData())), + Size: uint64(len(b.RawData())), CreateTime: now, UpdateTime: now, }, @@ -216,7 +216,7 @@ func (ri *redisIndex) initCidEntry(ctx context.Context, entry *cidEntry) (err er return } _, err = ri.cl.Pipelined(ctx, func(pipe redis.Pipeliner) error { - if e := pipe.IncrBy(ctx, cidSizeSumKey, int64(entry.Size_)).Err(); e != nil { + if e := pipe.IncrBy(ctx, cidSizeSumKey, int64(entry.Size)).Err(); e != nil { return e } if e := pipe.Incr(ctx, cidCount).Err(); e != nil { diff --git a/index/cids_test.go b/index/cids_test.go index 0d23626..e1945c2 100644 --- a/index/cids_test.go +++ b/index/cids_test.go @@ -25,7 +25,7 @@ func TestRedisIndex_BlocksAdd(t *testing.T) { require.Len(t, result.entries, len(bs)) for _, e := range result.entries { - assert.NotEmpty(t, e.Size_) + assert.NotEmpty(t, e.Size) assert.NotEmpty(t, e.CreateTime) assert.NotEmpty(t, e.UpdateTime) assert.NotEmpty(t, e.Version) @@ -69,7 +69,7 @@ func TestRedisIndex_CidEntries(t *testing.T) { entry := &cidEntry{ Cid: b.Cid(), CidEntry: &indexproto.CidEntry{ - Size_: uint64(len(b.RawData())), + Size: uint64(len(b.RawData())), CreateTime: 1, UpdateTime: 2, }, @@ -84,7 +84,7 @@ func TestRedisIndex_CidEntries(t *testing.T) { require.NoError(t, err) require.Len(t, result.entries, len(bs)) for _, e := range result.entries { - assert.NotEmpty(t, e.Size_) + assert.NotEmpty(t, e.Size) assert.NotEmpty(t, e.CreateTime) assert.NotEmpty(t, e.UpdateTime) assert.NotEmpty(t, e.Version) diff --git a/index/entry.go b/index/entry.go index 01dd52e..fc8edfc 100644 --- a/index/entry.go +++ b/index/entry.go @@ -21,7 +21,7 @@ func (f *fileEntry) Exists(c string) (ok bool) { func (f *fileEntry) Save(ctx context.Context, k Key, fileId string, cl redis.Pipeliner) { f.UpdateTime = time.Now().Unix() - data, err := f.Marshal() + data, err := f.MarshalVT() if err != nil { return } @@ -41,7 +41,7 @@ func (ri *redisIndex) getFileEntry(ctx context.Context, k Key, fileId string) (e }, true, nil } fileEntryProto := &indexproto.FileEntry{} - if err = fileEntryProto.Unmarshal([]byte(result)); err != nil { + if err = fileEntryProto.UnmarshalVT([]byte(result)); err != nil { return } return &fileEntry{FileEntry: fileEntryProto}, false, nil @@ -54,7 +54,7 @@ type spaceEntry struct { func (f *spaceEntry) Save(ctx context.Context, k Key, cl redis.Pipeliner) { f.UpdateTime = time.Now().Unix() - data, err := f.Marshal() + data, err := f.MarshalVT() if err != nil { return } @@ -78,7 +78,7 @@ func (ri *redisIndex) getSpaceEntry(ctx context.Context, key Key) (entry *spaceE }, nil } spaceEntryProto := &indexproto.SpaceEntry{} - if err = spaceEntryProto.Unmarshal([]byte(result)); err != nil { + if err = spaceEntryProto.UnmarshalVT([]byte(result)); err != nil { return } return &spaceEntry{SpaceEntry: spaceEntryProto, Id: key.SpaceId}, nil @@ -90,7 +90,7 @@ type groupEntry struct { func (f *groupEntry) Save(ctx context.Context, cl redis.Cmdable) { f.UpdateTime = time.Now().Unix() - data, err := f.Marshal() + data, err := f.MarshalVT() if err != nil { return } @@ -115,14 +115,14 @@ func (ri *redisIndex) getGroupEntry(ctx context.Context, key Key) (entry *groupE GroupId: key.GroupId, CreateTime: now, UpdateTime: now, - Size_: 0, + Size: 0, Limit: ri.defaultLimit, AccountLimit: ri.defaultLimit, }, }, nil } groupEntryProto := &indexproto.GroupEntry{} - if err = groupEntryProto.Unmarshal([]byte(result)); err != nil { + if err = groupEntryProto.UnmarshalVT([]byte(result)); err != nil { return } groupEntryProto.GroupId = key.GroupId diff --git a/index/index.go b/index/index.go index ef13eaa..8fadbe5 100644 --- a/index/index.go +++ b/index/index.go @@ -72,6 +72,9 @@ type Index interface { SpaceDelete(ctx context.Context, key Key) (ok bool, err error) MarkSpaceAsDeleted(ctx context.Context, key Key) (ok bool, err error) + + CheckAndMoveOwnership(ctx context.Context, key Key, oldIdentity string, aclRecordIndex int) error + app.ComponentRunnable } @@ -183,7 +186,7 @@ func (ri *redisIndex) FileInfo(ctx context.Context, key Key, fileIds ...string) return nil, err } fileInfos[i] = FileInfo{ - BytesUsage: fEntry.Size_, + BytesUsage: fEntry.Size, CidsCount: uint64(len(fEntry.Cids)), } } @@ -274,7 +277,7 @@ func (ri *redisIndex) GroupInfo(ctx context.Context, groupId string) (info Group return } return GroupInfo{ - BytesUsage: sEntry.Size_, + BytesUsage: sEntry.Size, CidsCount: sEntry.CidCount, AccountLimit: sEntry.AccountLimit, Limit: sEntry.Limit, @@ -293,7 +296,7 @@ func (ri *redisIndex) SpaceInfo(ctx context.Context, key Key) (info SpaceInfo, e return } return SpaceInfo{ - BytesUsage: sEntry.Size_, + BytesUsage: sEntry.Size, CidsCount: sEntry.CidCount, Limit: sEntry.Limit, FileCount: sEntry.FileCount, @@ -333,4 +336,8 @@ func DelKey(k Key) string { return "del:" + k.SpaceId + ".{" + hash + "}" } +func OwnerKey(spaceId string) string { + return "o:" + spaceId +} + const infoKey = "info" diff --git a/index/indexproto/index.pb.go b/index/indexproto/index.pb.go index d5e0890..6f715c0 100644 --- a/index/indexproto/index.pb.go +++ b/index/indexproto/index.pb.go @@ -1,1722 +1,564 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: index/indexproto/protos/index.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v3.21.12 +// source: index.proto package indexproto import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type CidEntry struct { - Size_ uint64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` - CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` - UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` - Refs int32 `protobuf:"varint,4,opt,name=refs,proto3" json:"refs,omitempty"` - Version uint32 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Size uint64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` + CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` + UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` + Refs int32 `protobuf:"varint,4,opt,name=refs,proto3" json:"refs,omitempty"` + Version uint32 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *CidEntry) Reset() { *m = CidEntry{} } -func (m *CidEntry) String() string { return proto.CompactTextString(m) } -func (*CidEntry) ProtoMessage() {} -func (*CidEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_f1f29953df8d243b, []int{0} +func (x *CidEntry) Reset() { + *x = CidEntry{} + mi := &file_index_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *CidEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (x *CidEntry) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *CidEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CidEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err + +func (*CidEntry) ProtoMessage() {} + +func (x *CidEntry) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -func (m *CidEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_CidEntry.Merge(m, src) -} -func (m *CidEntry) XXX_Size() int { - return m.Size() -} -func (m *CidEntry) XXX_DiscardUnknown() { - xxx_messageInfo_CidEntry.DiscardUnknown(m) + return mi.MessageOf(x) } -var xxx_messageInfo_CidEntry proto.InternalMessageInfo +// Deprecated: Use CidEntry.ProtoReflect.Descriptor instead. +func (*CidEntry) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{0} +} -func (m *CidEntry) GetSize_() uint64 { - if m != nil { - return m.Size_ +func (x *CidEntry) GetSize() uint64 { + if x != nil { + return x.Size } return 0 } -func (m *CidEntry) GetCreateTime() int64 { - if m != nil { - return m.CreateTime +func (x *CidEntry) GetCreateTime() int64 { + if x != nil { + return x.CreateTime } return 0 } -func (m *CidEntry) GetUpdateTime() int64 { - if m != nil { - return m.UpdateTime +func (x *CidEntry) GetUpdateTime() int64 { + if x != nil { + return x.UpdateTime } return 0 } -func (m *CidEntry) GetRefs() int32 { - if m != nil { - return m.Refs +func (x *CidEntry) GetRefs() int32 { + if x != nil { + return x.Refs } return 0 } -func (m *CidEntry) GetVersion() uint32 { - if m != nil { - return m.Version +func (x *CidEntry) GetVersion() uint32 { + if x != nil { + return x.Version } return 0 } type CidList struct { - Cids [][]byte `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Cids [][]byte `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *CidList) Reset() { *m = CidList{} } -func (m *CidList) String() string { return proto.CompactTextString(m) } -func (*CidList) ProtoMessage() {} -func (*CidList) Descriptor() ([]byte, []int) { - return fileDescriptor_f1f29953df8d243b, []int{1} +func (x *CidList) Reset() { + *x = CidList{} + mi := &file_index_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *CidList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (x *CidList) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *CidList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CidList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err + +func (*CidList) ProtoMessage() {} + +func (x *CidList) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -func (m *CidList) XXX_Merge(src proto.Message) { - xxx_messageInfo_CidList.Merge(m, src) -} -func (m *CidList) XXX_Size() int { - return m.Size() -} -func (m *CidList) XXX_DiscardUnknown() { - xxx_messageInfo_CidList.DiscardUnknown(m) + return mi.MessageOf(x) } -var xxx_messageInfo_CidList proto.InternalMessageInfo +// Deprecated: Use CidList.ProtoReflect.Descriptor instead. +func (*CidList) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{1} +} -func (m *CidList) GetCids() [][]byte { - if m != nil { - return m.Cids +func (x *CidList) GetCids() [][]byte { + if x != nil { + return x.Cids } return nil } type GroupEntry struct { - GroupId string `protobuf:"bytes,1,opt,name=groupId,proto3" json:"groupId,omitempty"` - CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` - UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` - Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` - CidCount uint64 `protobuf:"varint,5,opt,name=cidCount,proto3" json:"cidCount,omitempty"` - SpaceIds []string `protobuf:"bytes,6,rep,name=spaceIds,proto3" json:"spaceIds,omitempty"` - Limit uint64 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"` - AccountLimit uint64 `protobuf:"varint,8,opt,name=accountLimit,proto3" json:"accountLimit,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + GroupId string `protobuf:"bytes,1,opt,name=groupId,proto3" json:"groupId,omitempty"` + CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` + UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` + Size uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + CidCount uint64 `protobuf:"varint,5,opt,name=cidCount,proto3" json:"cidCount,omitempty"` + SpaceIds []string `protobuf:"bytes,6,rep,name=spaceIds,proto3" json:"spaceIds,omitempty"` + Limit uint64 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"` + AccountLimit uint64 `protobuf:"varint,8,opt,name=accountLimit,proto3" json:"accountLimit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *GroupEntry) Reset() { *m = GroupEntry{} } -func (m *GroupEntry) String() string { return proto.CompactTextString(m) } -func (*GroupEntry) ProtoMessage() {} -func (*GroupEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_f1f29953df8d243b, []int{2} +func (x *GroupEntry) Reset() { + *x = GroupEntry{} + mi := &file_index_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *GroupEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (x *GroupEntry) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GroupEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GroupEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err + +func (*GroupEntry) ProtoMessage() {} + +func (x *GroupEntry) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -func (m *GroupEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_GroupEntry.Merge(m, src) -} -func (m *GroupEntry) XXX_Size() int { - return m.Size() -} -func (m *GroupEntry) XXX_DiscardUnknown() { - xxx_messageInfo_GroupEntry.DiscardUnknown(m) + return mi.MessageOf(x) } -var xxx_messageInfo_GroupEntry proto.InternalMessageInfo +// Deprecated: Use GroupEntry.ProtoReflect.Descriptor instead. +func (*GroupEntry) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{2} +} -func (m *GroupEntry) GetGroupId() string { - if m != nil { - return m.GroupId +func (x *GroupEntry) GetGroupId() string { + if x != nil { + return x.GroupId } return "" } -func (m *GroupEntry) GetCreateTime() int64 { - if m != nil { - return m.CreateTime +func (x *GroupEntry) GetCreateTime() int64 { + if x != nil { + return x.CreateTime } return 0 } -func (m *GroupEntry) GetUpdateTime() int64 { - if m != nil { - return m.UpdateTime +func (x *GroupEntry) GetUpdateTime() int64 { + if x != nil { + return x.UpdateTime } return 0 } -func (m *GroupEntry) GetSize_() uint64 { - if m != nil { - return m.Size_ +func (x *GroupEntry) GetSize() uint64 { + if x != nil { + return x.Size } return 0 } -func (m *GroupEntry) GetCidCount() uint64 { - if m != nil { - return m.CidCount +func (x *GroupEntry) GetCidCount() uint64 { + if x != nil { + return x.CidCount } return 0 } -func (m *GroupEntry) GetSpaceIds() []string { - if m != nil { - return m.SpaceIds +func (x *GroupEntry) GetSpaceIds() []string { + if x != nil { + return x.SpaceIds } return nil } -func (m *GroupEntry) GetLimit() uint64 { - if m != nil { - return m.Limit +func (x *GroupEntry) GetLimit() uint64 { + if x != nil { + return x.Limit } return 0 } -func (m *GroupEntry) GetAccountLimit() uint64 { - if m != nil { - return m.AccountLimit +func (x *GroupEntry) GetAccountLimit() uint64 { + if x != nil { + return x.AccountLimit } return 0 } type SpaceEntry struct { - GroupId string `protobuf:"bytes,1,opt,name=groupId,proto3" json:"groupId,omitempty"` - CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` - UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` - Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` - FileCount uint32 `protobuf:"varint,5,opt,name=fileCount,proto3" json:"fileCount,omitempty"` - CidCount uint64 `protobuf:"varint,6,opt,name=cidCount,proto3" json:"cidCount,omitempty"` - Limit uint64 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + GroupId string `protobuf:"bytes,1,opt,name=groupId,proto3" json:"groupId,omitempty"` + CreateTime int64 `protobuf:"varint,2,opt,name=createTime,proto3" json:"createTime,omitempty"` + UpdateTime int64 `protobuf:"varint,3,opt,name=updateTime,proto3" json:"updateTime,omitempty"` + Size uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + FileCount uint32 `protobuf:"varint,5,opt,name=fileCount,proto3" json:"fileCount,omitempty"` + CidCount uint64 `protobuf:"varint,6,opt,name=cidCount,proto3" json:"cidCount,omitempty"` + Limit uint64 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *SpaceEntry) Reset() { *m = SpaceEntry{} } -func (m *SpaceEntry) String() string { return proto.CompactTextString(m) } -func (*SpaceEntry) ProtoMessage() {} -func (*SpaceEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_f1f29953df8d243b, []int{3} -} -func (m *SpaceEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (x *SpaceEntry) Reset() { + *x = SpaceEntry{} + mi := &file_index_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *SpaceEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SpaceEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SpaceEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_SpaceEntry.Merge(m, src) -} -func (m *SpaceEntry) XXX_Size() int { - return m.Size() -} -func (m *SpaceEntry) XXX_DiscardUnknown() { - xxx_messageInfo_SpaceEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_SpaceEntry proto.InternalMessageInfo -func (m *SpaceEntry) GetGroupId() string { - if m != nil { - return m.GroupId - } - return "" +func (x *SpaceEntry) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *SpaceEntry) GetCreateTime() int64 { - if m != nil { - return m.CreateTime - } - return 0 -} +func (*SpaceEntry) ProtoMessage() {} -func (m *SpaceEntry) GetUpdateTime() int64 { - if m != nil { - return m.UpdateTime +func (x *SpaceEntry) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) } -func (m *SpaceEntry) GetSize_() uint64 { - if m != nil { - return m.Size_ - } - return 0 +// Deprecated: Use SpaceEntry.ProtoReflect.Descriptor instead. +func (*SpaceEntry) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{3} } -func (m *SpaceEntry) GetFileCount() uint32 { - if m != nil { - return m.FileCount +func (x *SpaceEntry) GetGroupId() string { + if x != nil { + return x.GroupId } - return 0 + return "" } -func (m *SpaceEntry) GetCidCount() uint64 { - if m != nil { - return m.CidCount +func (x *SpaceEntry) GetCreateTime() int64 { + if x != nil { + return x.CreateTime } return 0 } -func (m *SpaceEntry) GetLimit() uint64 { - if m != nil { - return m.Limit +func (x *SpaceEntry) GetUpdateTime() int64 { + if x != nil { + return x.UpdateTime } return 0 } -type FileEntry struct { - Cids []string `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` - Size_ uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` - CreateTime int64 `protobuf:"varint,3,opt,name=createTime,proto3" json:"createTime,omitempty"` - UpdateTime int64 `protobuf:"varint,4,opt,name=updateTime,proto3" json:"updateTime,omitempty"` -} - -func (m *FileEntry) Reset() { *m = FileEntry{} } -func (m *FileEntry) String() string { return proto.CompactTextString(m) } -func (*FileEntry) ProtoMessage() {} -func (*FileEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_f1f29953df8d243b, []int{4} -} -func (m *FileEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FileEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FileEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *FileEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_FileEntry.Merge(m, src) -} -func (m *FileEntry) XXX_Size() int { - return m.Size() -} -func (m *FileEntry) XXX_DiscardUnknown() { - xxx_messageInfo_FileEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_FileEntry proto.InternalMessageInfo - -func (m *FileEntry) GetCids() []string { - if m != nil { - return m.Cids - } - return nil -} - -func (m *FileEntry) GetSize_() uint64 { - if m != nil { - return m.Size_ +func (x *SpaceEntry) GetSize() uint64 { + if x != nil { + return x.Size } return 0 } -func (m *FileEntry) GetCreateTime() int64 { - if m != nil { - return m.CreateTime +func (x *SpaceEntry) GetFileCount() uint32 { + if x != nil { + return x.FileCount } return 0 } -func (m *FileEntry) GetUpdateTime() int64 { - if m != nil { - return m.UpdateTime +func (x *SpaceEntry) GetCidCount() uint64 { + if x != nil { + return x.CidCount } return 0 } -func init() { - proto.RegisterType((*CidEntry)(nil), "fileIndexProto.CidEntry") - proto.RegisterType((*CidList)(nil), "fileIndexProto.CidList") - proto.RegisterType((*GroupEntry)(nil), "fileIndexProto.GroupEntry") - proto.RegisterType((*SpaceEntry)(nil), "fileIndexProto.SpaceEntry") - proto.RegisterType((*FileEntry)(nil), "fileIndexProto.FileEntry") -} - -func init() { - proto.RegisterFile("index/indexproto/protos/index.proto", fileDescriptor_f1f29953df8d243b) -} - -var fileDescriptor_f1f29953df8d243b = []byte{ - // 372 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x53, 0xcd, 0x4a, 0xf3, 0x40, - 0x14, 0xed, 0x34, 0x69, 0xd3, 0x5c, 0xda, 0x8f, 0x8f, 0xc1, 0xc5, 0x20, 0x3a, 0x84, 0xb8, 0x09, - 0x2e, 0xec, 0xc2, 0x37, 0xb0, 0xa8, 0x14, 0xba, 0x90, 0xd1, 0x95, 0xbb, 0x9a, 0x99, 0xca, 0x40, - 0x9b, 0x84, 0x4c, 0x2a, 0xea, 0x33, 0xb8, 0xf0, 0xb1, 0xc4, 0x55, 0x97, 0x2e, 0xa5, 0xdd, 0xfa, - 0x10, 0x32, 0x37, 0x34, 0xfd, 0x41, 0x71, 0x23, 0xb8, 0x99, 0xdc, 0x73, 0x0e, 0x77, 0x38, 0xe7, - 0xce, 0x0d, 0x1c, 0xe8, 0x44, 0xaa, 0xfb, 0x2e, 0x9e, 0x59, 0x9e, 0x16, 0x69, 0x17, 0x4f, 0x53, - 0x32, 0x47, 0x08, 0xe8, 0xbf, 0x91, 0x1e, 0xab, 0xbe, 0x25, 0x2e, 0x2c, 0x0e, 0x9f, 0x08, 0xb4, - 0x7a, 0x5a, 0x9e, 0x26, 0x45, 0xfe, 0x40, 0x29, 0xb8, 0x46, 0x3f, 0x2a, 0x46, 0x02, 0x12, 0xb9, - 0x02, 0x6b, 0xca, 0x01, 0xe2, 0x5c, 0x0d, 0x0b, 0x75, 0xa5, 0x27, 0x8a, 0xd5, 0x03, 0x12, 0x39, - 0x62, 0x8d, 0xb1, 0xfa, 0x34, 0x93, 0x4b, 0xdd, 0x29, 0xf5, 0x15, 0x63, 0xef, 0xcc, 0xd5, 0xc8, - 0x30, 0x37, 0x20, 0x51, 0x43, 0x60, 0x4d, 0x19, 0x78, 0x77, 0x2a, 0x37, 0x3a, 0x4d, 0x58, 0x23, - 0x20, 0x51, 0x47, 0x2c, 0x61, 0xb8, 0x0f, 0x5e, 0x4f, 0xcb, 0x81, 0x36, 0x85, 0x6d, 0x8c, 0xb5, - 0x34, 0x8c, 0x04, 0x4e, 0xd4, 0x16, 0x58, 0x87, 0x1f, 0x04, 0xe0, 0x3c, 0x4f, 0xa7, 0x59, 0xe9, - 0x97, 0x81, 0x77, 0x6b, 0x51, 0x5f, 0xa2, 0x65, 0x5f, 0x2c, 0xe1, 0x6f, 0xb8, 0xc6, 0x49, 0xb8, - 0x6b, 0x93, 0xd8, 0x85, 0x56, 0xac, 0x65, 0x2f, 0x9d, 0x26, 0x05, 0xda, 0x76, 0x45, 0x85, 0xad, - 0x66, 0xb2, 0x61, 0xac, 0xfa, 0xd2, 0xb0, 0x66, 0xe0, 0x44, 0xbe, 0xa8, 0x30, 0xdd, 0x81, 0xc6, - 0x58, 0x4f, 0x74, 0xc1, 0x3c, 0x6c, 0x2a, 0x01, 0x0d, 0xa1, 0x3d, 0x8c, 0x63, 0xdb, 0x3c, 0x40, - 0xb1, 0x85, 0xe2, 0x06, 0x17, 0xbe, 0x12, 0x80, 0x4b, 0x7b, 0xcd, 0x5f, 0xc4, 0xdd, 0x03, 0xdf, - 0xee, 0xca, 0x2a, 0x6f, 0x47, 0xac, 0x88, 0x8d, 0x61, 0x34, 0xb7, 0x86, 0xf1, 0x65, 0xe0, 0xd0, - 0x80, 0x7f, 0xa6, 0xc7, 0xaa, 0xda, 0xb4, 0xea, 0x71, 0xfd, 0xf2, 0x71, 0x2b, 0x13, 0xf5, 0x6f, - 0xb7, 0xcf, 0xf9, 0x21, 0x98, 0xbb, 0x1d, 0xec, 0xe4, 0xf0, 0x65, 0xce, 0xc9, 0x6c, 0xce, 0xc9, - 0xfb, 0x9c, 0x93, 0xe7, 0x05, 0xaf, 0xcd, 0x16, 0xbc, 0xf6, 0xb6, 0xe0, 0xb5, 0xeb, 0xff, 0xdb, - 0x7f, 0xcb, 0x4d, 0x13, 0x3f, 0xc7, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x64, 0x5b, 0xf6, 0x08, - 0x48, 0x03, 0x00, 0x00, -} - -func (m *CidEntry) 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 *CidEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CidEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Version != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x28 - } - if m.Refs != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Refs)) - i-- - dAtA[i] = 0x20 - } - if m.UpdateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.UpdateTime)) - i-- - dAtA[i] = 0x18 - } - if m.CreateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CreateTime)) - i-- - dAtA[i] = 0x10 +func (x *SpaceEntry) GetLimit() uint64 { + if x != nil { + return x.Limit } - if m.Size_ != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + return 0 } -func (m *CidList) 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 +type FileEntry struct { + state protoimpl.MessageState `protogen:"open.v1"` + Cids []string `protobuf:"bytes,1,rep,name=cids,proto3" json:"cids,omitempty"` + Size uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` + CreateTime int64 `protobuf:"varint,3,opt,name=createTime,proto3" json:"createTime,omitempty"` + UpdateTime int64 `protobuf:"varint,4,opt,name=updateTime,proto3" json:"updateTime,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *CidList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *FileEntry) Reset() { + *x = FileEntry{} + mi := &file_index_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *CidList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Cids) > 0 { - for iNdEx := len(m.Cids) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Cids[iNdEx]) - copy(dAtA[i:], m.Cids[iNdEx]) - i = encodeVarintIndex(dAtA, i, uint64(len(m.Cids[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil +func (x *FileEntry) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *GroupEntry) 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 *GroupEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +func (*FileEntry) ProtoMessage() {} -func (m *GroupEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AccountLimit != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.AccountLimit)) - i-- - dAtA[i] = 0x40 - } - if m.Limit != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Limit)) - i-- - dAtA[i] = 0x38 - } - if len(m.SpaceIds) > 0 { - for iNdEx := len(m.SpaceIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SpaceIds[iNdEx]) - copy(dAtA[i:], m.SpaceIds[iNdEx]) - i = encodeVarintIndex(dAtA, i, uint64(len(m.SpaceIds[iNdEx]))) - i-- - dAtA[i] = 0x32 +func (x *FileEntry) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } + return ms } - if m.CidCount != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CidCount)) - i-- - dAtA[i] = 0x28 - } - if m.Size_ != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x20 - } - if m.UpdateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.UpdateTime)) - i-- - dAtA[i] = 0x18 - } - if m.CreateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CreateTime)) - i-- - dAtA[i] = 0x10 - } - if len(m.GroupId) > 0 { - i -= len(m.GroupId) - copy(dAtA[i:], m.GroupId) - i = encodeVarintIndex(dAtA, i, uint64(len(m.GroupId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + return mi.MessageOf(x) } -func (m *SpaceEntry) 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 *SpaceEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// Deprecated: Use FileEntry.ProtoReflect.Descriptor instead. +func (*FileEntry) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{4} } -func (m *SpaceEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Limit != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Limit)) - i-- - dAtA[i] = 0x38 - } - if m.CidCount != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CidCount)) - i-- - dAtA[i] = 0x30 - } - if m.FileCount != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.FileCount)) - i-- - dAtA[i] = 0x28 - } - if m.Size_ != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x20 - } - if m.UpdateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.UpdateTime)) - i-- - dAtA[i] = 0x18 +func (x *FileEntry) GetCids() []string { + if x != nil { + return x.Cids } - if m.CreateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CreateTime)) - i-- - dAtA[i] = 0x10 - } - if len(m.GroupId) > 0 { - i -= len(m.GroupId) - copy(dAtA[i:], m.GroupId) - i = encodeVarintIndex(dAtA, i, uint64(len(m.GroupId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + return nil } -func (m *FileEntry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (x *FileEntry) GetSize() uint64 { + if x != nil { + return x.Size } - return dAtA[:n], nil -} - -func (m *FileEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return 0 } -func (m *FileEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.UpdateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.UpdateTime)) - i-- - dAtA[i] = 0x20 +func (x *FileEntry) GetCreateTime() int64 { + if x != nil { + return x.CreateTime } - if m.CreateTime != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.CreateTime)) - i-- - dAtA[i] = 0x18 - } - if m.Size_ != 0 { - i = encodeVarintIndex(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x10 - } - if len(m.Cids) > 0 { - for iNdEx := len(m.Cids) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Cids[iNdEx]) - copy(dAtA[i:], m.Cids[iNdEx]) - i = encodeVarintIndex(dAtA, i, uint64(len(m.Cids[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil + return 0 } -func encodeVarintIndex(dAtA []byte, offset int, v uint64) int { - offset -= sovIndex(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *CidEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Size_ != 0 { - n += 1 + sovIndex(uint64(m.Size_)) - } - if m.CreateTime != 0 { - n += 1 + sovIndex(uint64(m.CreateTime)) - } - if m.UpdateTime != 0 { - n += 1 + sovIndex(uint64(m.UpdateTime)) - } - if m.Refs != 0 { - n += 1 + sovIndex(uint64(m.Refs)) - } - if m.Version != 0 { - n += 1 + sovIndex(uint64(m.Version)) +func (x *FileEntry) GetUpdateTime() int64 { + if x != nil { + return x.UpdateTime } - return n + return 0 } -func (m *CidList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Cids) > 0 { - for _, b := range m.Cids { - l = len(b) - n += 1 + l + sovIndex(uint64(l)) - } - } - return n +type OwnershipRecord struct { + state protoimpl.MessageState `protogen:"open.v1"` + OwnerId string `protobuf:"bytes,1,opt,name=ownerId,proto3" json:"ownerId,omitempty"` + AclRecordIndex int64 `protobuf:"varint,2,opt,name=aclRecordIndex,proto3" json:"aclRecordIndex,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *GroupEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.GroupId) - if l > 0 { - n += 1 + l + sovIndex(uint64(l)) - } - if m.CreateTime != 0 { - n += 1 + sovIndex(uint64(m.CreateTime)) - } - if m.UpdateTime != 0 { - n += 1 + sovIndex(uint64(m.UpdateTime)) - } - if m.Size_ != 0 { - n += 1 + sovIndex(uint64(m.Size_)) - } - if m.CidCount != 0 { - n += 1 + sovIndex(uint64(m.CidCount)) - } - if len(m.SpaceIds) > 0 { - for _, s := range m.SpaceIds { - l = len(s) - n += 1 + l + sovIndex(uint64(l)) - } - } - if m.Limit != 0 { - n += 1 + sovIndex(uint64(m.Limit)) - } - if m.AccountLimit != 0 { - n += 1 + sovIndex(uint64(m.AccountLimit)) - } - return n +func (x *OwnershipRecord) Reset() { + *x = OwnershipRecord{} + mi := &file_index_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *SpaceEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.GroupId) - if l > 0 { - n += 1 + l + sovIndex(uint64(l)) - } - if m.CreateTime != 0 { - n += 1 + sovIndex(uint64(m.CreateTime)) - } - if m.UpdateTime != 0 { - n += 1 + sovIndex(uint64(m.UpdateTime)) - } - if m.Size_ != 0 { - n += 1 + sovIndex(uint64(m.Size_)) - } - if m.FileCount != 0 { - n += 1 + sovIndex(uint64(m.FileCount)) - } - if m.CidCount != 0 { - n += 1 + sovIndex(uint64(m.CidCount)) - } - if m.Limit != 0 { - n += 1 + sovIndex(uint64(m.Limit)) - } - return n +func (x *OwnershipRecord) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *FileEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Cids) > 0 { - for _, s := range m.Cids { - l = len(s) - n += 1 + l + sovIndex(uint64(l)) - } - } - if m.Size_ != 0 { - n += 1 + sovIndex(uint64(m.Size_)) - } - if m.CreateTime != 0 { - n += 1 + sovIndex(uint64(m.CreateTime)) - } - if m.UpdateTime != 0 { - n += 1 + sovIndex(uint64(m.UpdateTime)) - } - return n -} +func (*OwnershipRecord) ProtoMessage() {} -func sovIndex(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozIndex(x uint64) (n int) { - return sovIndex(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *CidEntry) 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 ErrIntOverflowIndex - } - 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: CidEntry: wiretype end group for non-group") +func (x *OwnershipRecord) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - if fieldNum <= 0 { - return fmt.Errorf("proto: CidEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) - } - m.CreateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) - } - m.UpdateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Refs", wireType) - } - m.Refs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Refs |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - 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 ErrIntOverflowIndex - } - 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 := skipIndex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIndex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF + return ms } - return nil + return mi.MessageOf(x) } -func (m *CidList) 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 ErrIntOverflowIndex - } - 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: CidList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CidList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cids", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthIndex - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthIndex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cids = append(m.Cids, make([]byte, postIndex-iNdEx)) - copy(m.Cids[len(m.Cids)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipIndex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIndex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil +// Deprecated: Use OwnershipRecord.ProtoReflect.Descriptor instead. +func (*OwnershipRecord) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{5} } -func (m *GroupEntry) 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 ErrIntOverflowIndex - } - 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: GroupEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GroupEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - 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 ErrInvalidLengthIndex - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIndex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.GroupId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) - } - m.CreateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) - } - m.UpdateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CidCount", wireType) - } - m.CidCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CidCount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpaceIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - 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 ErrInvalidLengthIndex - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIndex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SpaceIds = append(m.SpaceIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountLimit", wireType) - } - m.AccountLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AccountLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIndex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIndex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *OwnershipRecord) GetOwnerId() string { + if x != nil { + return x.OwnerId } - return nil + return "" } -func (m *SpaceEntry) 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 ErrIntOverflowIndex - } - 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: SpaceEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SpaceEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - 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 ErrInvalidLengthIndex - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIndex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.GroupId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) - } - m.CreateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) - } - m.UpdateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FileCount", wireType) - } - m.FileCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FileCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CidCount", wireType) - } - m.CidCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CidCount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIndex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIndex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *OwnershipRecord) GetAclRecordIndex() int64 { + if x != nil { + return x.AclRecordIndex } - return nil + return 0 } -func (m *FileEntry) 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 ErrIntOverflowIndex - } - 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: FileEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FileEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cids", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - 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 ErrInvalidLengthIndex - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIndex - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cids = append(m.Cids, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) - } - m.CreateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) - } - m.UpdateTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIndex - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdateTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIndex(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIndex - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipIndex(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, ErrIntOverflowIndex - } - 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, ErrIntOverflowIndex - } - 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, ErrIntOverflowIndex - } - 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, ErrInvalidLengthIndex - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupIndex - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthIndex - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} +var File_index_proto protoreflect.FileDescriptor + +const file_index_proto_rawDesc = "" + + "\n" + + "\vindex.proto\x12\x0efileIndexProto\"\x8c\x01\n" + + "\bCidEntry\x12\x12\n" + + "\x04size\x18\x01 \x01(\x04R\x04size\x12\x1e\n" + + "\n" + + "createTime\x18\x02 \x01(\x03R\n" + + "createTime\x12\x1e\n" + + "\n" + + "updateTime\x18\x03 \x01(\x03R\n" + + "updateTime\x12\x12\n" + + "\x04refs\x18\x04 \x01(\x05R\x04refs\x12\x18\n" + + "\aversion\x18\x05 \x01(\rR\aversion\"\x1d\n" + + "\aCidList\x12\x12\n" + + "\x04cids\x18\x01 \x03(\fR\x04cids\"\xec\x01\n" + + "\n" + + "GroupEntry\x12\x18\n" + + "\agroupId\x18\x01 \x01(\tR\agroupId\x12\x1e\n" + + "\n" + + "createTime\x18\x02 \x01(\x03R\n" + + "createTime\x12\x1e\n" + + "\n" + + "updateTime\x18\x03 \x01(\x03R\n" + + "updateTime\x12\x12\n" + + "\x04size\x18\x04 \x01(\x04R\x04size\x12\x1a\n" + + "\bcidCount\x18\x05 \x01(\x04R\bcidCount\x12\x1a\n" + + "\bspaceIds\x18\x06 \x03(\tR\bspaceIds\x12\x14\n" + + "\x05limit\x18\a \x01(\x04R\x05limit\x12\"\n" + + "\faccountLimit\x18\b \x01(\x04R\faccountLimit\"\xca\x01\n" + + "\n" + + "SpaceEntry\x12\x18\n" + + "\agroupId\x18\x01 \x01(\tR\agroupId\x12\x1e\n" + + "\n" + + "createTime\x18\x02 \x01(\x03R\n" + + "createTime\x12\x1e\n" + + "\n" + + "updateTime\x18\x03 \x01(\x03R\n" + + "updateTime\x12\x12\n" + + "\x04size\x18\x04 \x01(\x04R\x04size\x12\x1c\n" + + "\tfileCount\x18\x05 \x01(\rR\tfileCount\x12\x1a\n" + + "\bcidCount\x18\x06 \x01(\x04R\bcidCount\x12\x14\n" + + "\x05limit\x18\a \x01(\x04R\x05limit\"s\n" + + "\tFileEntry\x12\x12\n" + + "\x04cids\x18\x01 \x03(\tR\x04cids\x12\x12\n" + + "\x04size\x18\x02 \x01(\x04R\x04size\x12\x1e\n" + + "\n" + + "createTime\x18\x03 \x01(\x03R\n" + + "createTime\x12\x1e\n" + + "\n" + + "updateTime\x18\x04 \x01(\x03R\n" + + "updateTime\"S\n" + + "\x0fOwnershipRecord\x12\x18\n" + + "\aownerId\x18\x01 \x01(\tR\aownerId\x12&\n" + + "\x0eaclRecordIndex\x18\x02 \x01(\x03R\x0eaclRecordIndexB\x12Z\x10index/indexprotob\x06proto3" var ( - ErrInvalidLengthIndex = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowIndex = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupIndex = fmt.Errorf("proto: unexpected end of group") + file_index_proto_rawDescOnce sync.Once + file_index_proto_rawDescData []byte ) + +func file_index_proto_rawDescGZIP() []byte { + file_index_proto_rawDescOnce.Do(func() { + file_index_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_index_proto_rawDesc), len(file_index_proto_rawDesc))) + }) + return file_index_proto_rawDescData +} + +var file_index_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_index_proto_goTypes = []any{ + (*CidEntry)(nil), // 0: fileIndexProto.CidEntry + (*CidList)(nil), // 1: fileIndexProto.CidList + (*GroupEntry)(nil), // 2: fileIndexProto.GroupEntry + (*SpaceEntry)(nil), // 3: fileIndexProto.SpaceEntry + (*FileEntry)(nil), // 4: fileIndexProto.FileEntry + (*OwnershipRecord)(nil), // 5: fileIndexProto.OwnershipRecord +} +var file_index_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_index_proto_init() } +func file_index_proto_init() { + if File_index_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_index_proto_rawDesc), len(file_index_proto_rawDesc)), + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_index_proto_goTypes, + DependencyIndexes: file_index_proto_depIdxs, + MessageInfos: file_index_proto_msgTypes, + }.Build() + File_index_proto = out.File + file_index_proto_goTypes = nil + file_index_proto_depIdxs = nil +} diff --git a/index/indexproto/index_vtproto.pb.go b/index/indexproto/index_vtproto.pb.go new file mode 100644 index 0000000..4418e6b --- /dev/null +++ b/index/indexproto/index_vtproto.pb.go @@ -0,0 +1,1421 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: index.proto + +package indexproto + +import ( + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *CidEntry) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CidEntry) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CidEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Version != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x28 + } + if m.Refs != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Refs)) + i-- + dAtA[i] = 0x20 + } + if m.UpdateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.UpdateTime)) + i-- + dAtA[i] = 0x18 + } + if m.CreateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CreateTime)) + i-- + dAtA[i] = 0x10 + } + if m.Size != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Size)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CidList) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CidList) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CidList) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Cids) > 0 { + for iNdEx := len(m.Cids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Cids[iNdEx]) + copy(dAtA[i:], m.Cids[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Cids[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *GroupEntry) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GroupEntry) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *GroupEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.AccountLimit != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.AccountLimit)) + i-- + dAtA[i] = 0x40 + } + if m.Limit != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x38 + } + if len(m.SpaceIds) > 0 { + for iNdEx := len(m.SpaceIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SpaceIds[iNdEx]) + copy(dAtA[i:], m.SpaceIds[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SpaceIds[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if m.CidCount != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CidCount)) + i-- + dAtA[i] = 0x28 + } + if m.Size != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Size)) + i-- + dAtA[i] = 0x20 + } + if m.UpdateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.UpdateTime)) + i-- + dAtA[i] = 0x18 + } + if m.CreateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CreateTime)) + i-- + dAtA[i] = 0x10 + } + if len(m.GroupId) > 0 { + i -= len(m.GroupId) + copy(dAtA[i:], m.GroupId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.GroupId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SpaceEntry) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceEntry) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SpaceEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Limit != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x38 + } + if m.CidCount != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CidCount)) + i-- + dAtA[i] = 0x30 + } + if m.FileCount != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.FileCount)) + i-- + dAtA[i] = 0x28 + } + if m.Size != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Size)) + i-- + dAtA[i] = 0x20 + } + if m.UpdateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.UpdateTime)) + i-- + dAtA[i] = 0x18 + } + if m.CreateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CreateTime)) + i-- + dAtA[i] = 0x10 + } + if len(m.GroupId) > 0 { + i -= len(m.GroupId) + copy(dAtA[i:], m.GroupId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.GroupId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FileEntry) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FileEntry) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FileEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.UpdateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.UpdateTime)) + i-- + dAtA[i] = 0x20 + } + if m.CreateTime != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CreateTime)) + i-- + dAtA[i] = 0x18 + } + if m.Size != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Size)) + i-- + dAtA[i] = 0x10 + } + if len(m.Cids) > 0 { + for iNdEx := len(m.Cids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Cids[iNdEx]) + copy(dAtA[i:], m.Cids[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Cids[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OwnershipRecord) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OwnershipRecord) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *OwnershipRecord) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.AclRecordIndex != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.AclRecordIndex)) + i-- + dAtA[i] = 0x10 + } + if len(m.OwnerId) > 0 { + i -= len(m.OwnerId) + copy(dAtA[i:], m.OwnerId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.OwnerId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CidEntry) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Size != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Size)) + } + if m.CreateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CreateTime)) + } + if m.UpdateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.UpdateTime)) + } + if m.Refs != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Refs)) + } + if m.Version != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Version)) + } + n += len(m.unknownFields) + return n +} + +func (m *CidList) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Cids) > 0 { + for _, b := range m.Cids { + l = len(b) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *GroupEntry) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GroupId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CreateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CreateTime)) + } + if m.UpdateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.UpdateTime)) + } + if m.Size != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Size)) + } + if m.CidCount != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CidCount)) + } + if len(m.SpaceIds) > 0 { + for _, s := range m.SpaceIds { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Limit != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Limit)) + } + if m.AccountLimit != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.AccountLimit)) + } + n += len(m.unknownFields) + return n +} + +func (m *SpaceEntry) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GroupId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CreateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CreateTime)) + } + if m.UpdateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.UpdateTime)) + } + if m.Size != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Size)) + } + if m.FileCount != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.FileCount)) + } + if m.CidCount != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CidCount)) + } + if m.Limit != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Limit)) + } + n += len(m.unknownFields) + return n +} + +func (m *FileEntry) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Cids) > 0 { + for _, s := range m.Cids { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Size != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Size)) + } + if m.CreateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CreateTime)) + } + if m.UpdateTime != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.UpdateTime)) + } + n += len(m.unknownFields) + return n +} + +func (m *OwnershipRecord) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OwnerId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.AclRecordIndex != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.AclRecordIndex)) + } + n += len(m.unknownFields) + return n +} + +func (m *CidEntry) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: CidEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CidEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) + } + m.Size = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) + } + m.CreateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) + } + m.UpdateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Refs", wireType) + } + m.Refs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Refs |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + 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 protohelpers.ErrIntOverflow + } + 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 := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CidList) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: CidList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CidList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cids", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cids = append(m.Cids, make([]byte, postIndex-iNdEx)) + copy(m.Cids[len(m.Cids)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GroupEntry) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: GroupEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GroupEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) + } + m.CreateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) + } + m.UpdateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) + } + m.Size = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CidCount", wireType) + } + m.CidCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CidCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceIds = append(m.SpaceIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountLimit", wireType) + } + m.AccountLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SpaceEntry) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: SpaceEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) + } + m.CreateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) + } + m.UpdateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) + } + m.Size = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FileCount", wireType) + } + m.FileCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FileCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CidCount", wireType) + } + m.CidCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CidCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FileEntry) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: FileEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FileEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cids", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cids = append(m.Cids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) + } + m.Size = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateTime", wireType) + } + m.CreateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) + } + m.UpdateTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OwnershipRecord) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: OwnershipRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OwnershipRecord: 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 stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AclRecordIndex", wireType) + } + m.AclRecordIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AclRecordIndex |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/index/indexproto/protos/index.proto b/index/indexproto/protos/index.proto index b4477e0..a1bcf1b 100644 --- a/index/indexproto/protos/index.proto +++ b/index/indexproto/protos/index.proto @@ -41,4 +41,9 @@ message FileEntry { uint64 size = 2; int64 createTime = 3; int64 updateTime = 4; -} \ No newline at end of file +} + +message OwnershipRecord { + string ownerId = 1; + int64 aclRecordIndex = 2; +} diff --git a/index/limit.go b/index/limit.go index 9d564f2..2e6cad4 100644 --- a/index/limit.go +++ b/index/limit.go @@ -23,14 +23,14 @@ func (ri *redisIndex) CheckLimits(ctx context.Context, key Key) (err error) { // isolated space if entry.space.Limit != 0 { - if entry.space.Size_ >= entry.space.Limit { + if entry.space.Size >= entry.space.Limit { return ErrLimitExceed } return } // group limit - if entry.group.Size_ >= entry.group.Limit { + if entry.group.Size >= entry.group.Limit { return ErrLimitExceed } return @@ -149,12 +149,12 @@ func (op *spaceLimitOp) SetSpaceLimit(ctx context.Context, key Key, limit uint64 newGLimit := int64(op.groupEntry.Limit) - diff // check the group limit - if newGLimit < int64(op.groupEntry.Size_) { + if newGLimit < int64(op.groupEntry.Size) { return fileprotoerr.ErrNotEnoughSpace } // check the space limit - if entry.space.Size_ > limit { + if entry.space.Size > limit { return fileprotoerr.ErrNotEnoughSpace } op.groupEntry.Limit = uint64(newGLimit) @@ -232,7 +232,7 @@ func (op *spaceLimitOp) isolateSpace(ctx context.Context, entry groupSpaceEntry) if _, err = op.cl.TxPipelined(ctx, func(pipe redis.Pipeliner) error { for _, idx := range toDeleteIdx { pipe.HDel(ctx, gk, CidKey(cids[idx])) - op.groupEntry.Size_ -= cidEntries.entries[idx].Size_ + op.groupEntry.Size -= cidEntries.entries[idx].Size op.groupEntry.CidCount-- } return nil @@ -288,7 +288,7 @@ func (op *spaceLimitOp) uniteSpace(ctx context.Context, entry groupSpaceEntry) ( // make a list of cids without refs and increase the size for i, res := range groupDecrResults { if res.Val() == 1 { - op.groupEntry.Size_ += cidEntries.entries[i].Size_ + op.groupEntry.Size += cidEntries.entries[i].Size op.groupEntry.CidCount++ } } diff --git a/index/migrate.go b/index/migrate.go index 9a04c95..1df3cc4 100644 --- a/index/migrate.go +++ b/index/migrate.go @@ -92,7 +92,7 @@ func (ri *redisIndex) migrateFile(ctx context.Context, key Key, migrateKey, file return } oldList := &indexproto.CidList{} - if err = oldList.Unmarshal(encodedData); err != nil { + if err = oldList.UnmarshalVT(encodedData); err != nil { return } diff --git a/index/mock_index/mock_index.go b/index/mock_index/mock_index.go index d702187..127d3de 100644 --- a/index/mock_index/mock_index.go +++ b/index/mock_index/mock_index.go @@ -24,6 +24,7 @@ import ( type MockIndex struct { ctrl *gomock.Controller recorder *MockIndexMockRecorder + isgomock struct{} } // MockIndexMockRecorder is the mock recorder for MockIndex. @@ -44,201 +45,215 @@ func (m *MockIndex) EXPECT() *MockIndexMockRecorder { } // BlocksAdd mocks base method. -func (m *MockIndex) BlocksAdd(arg0 context.Context, arg1 []blocks.Block) error { +func (m *MockIndex) BlocksAdd(ctx context.Context, bs []blocks.Block) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BlocksAdd", arg0, arg1) + ret := m.ctrl.Call(m, "BlocksAdd", ctx, bs) ret0, _ := ret[0].(error) return ret0 } // BlocksAdd indicates an expected call of BlocksAdd. -func (mr *MockIndexMockRecorder) BlocksAdd(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) BlocksAdd(ctx, bs any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksAdd", reflect.TypeOf((*MockIndex)(nil).BlocksAdd), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksAdd", reflect.TypeOf((*MockIndex)(nil).BlocksAdd), ctx, bs) } // BlocksGetNonExistent mocks base method. -func (m *MockIndex) BlocksGetNonExistent(arg0 context.Context, arg1 []blocks.Block) ([]blocks.Block, error) { +func (m *MockIndex) BlocksGetNonExistent(ctx context.Context, bs []blocks.Block) ([]blocks.Block, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BlocksGetNonExistent", arg0, arg1) + ret := m.ctrl.Call(m, "BlocksGetNonExistent", ctx, bs) ret0, _ := ret[0].([]blocks.Block) ret1, _ := ret[1].(error) return ret0, ret1 } // BlocksGetNonExistent indicates an expected call of BlocksGetNonExistent. -func (mr *MockIndexMockRecorder) BlocksGetNonExistent(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) BlocksGetNonExistent(ctx, bs any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksGetNonExistent", reflect.TypeOf((*MockIndex)(nil).BlocksGetNonExistent), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksGetNonExistent", reflect.TypeOf((*MockIndex)(nil).BlocksGetNonExistent), ctx, bs) } // BlocksLock mocks base method. -func (m *MockIndex) BlocksLock(arg0 context.Context, arg1 []blocks.Block) (func(), error) { +func (m *MockIndex) BlocksLock(ctx context.Context, bs []blocks.Block) (func(), error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BlocksLock", arg0, arg1) + ret := m.ctrl.Call(m, "BlocksLock", ctx, bs) ret0, _ := ret[0].(func()) ret1, _ := ret[1].(error) return ret0, ret1 } // BlocksLock indicates an expected call of BlocksLock. -func (mr *MockIndexMockRecorder) BlocksLock(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) BlocksLock(ctx, bs any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksLock", reflect.TypeOf((*MockIndex)(nil).BlocksLock), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlocksLock", reflect.TypeOf((*MockIndex)(nil).BlocksLock), ctx, bs) } // Check mocks base method. -func (m *MockIndex) Check(arg0 context.Context, arg1 index.Key, arg2 bool) ([]index.CheckResult, error) { +func (m *MockIndex) Check(ctx context.Context, key index.Key, doFix bool) ([]index.CheckResult, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Check", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "Check", ctx, key, doFix) ret0, _ := ret[0].([]index.CheckResult) ret1, _ := ret[1].(error) return ret0, ret1 } // Check indicates an expected call of Check. -func (mr *MockIndexMockRecorder) Check(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Check(ctx, key, doFix any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Check", reflect.TypeOf((*MockIndex)(nil).Check), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Check", reflect.TypeOf((*MockIndex)(nil).Check), ctx, key, doFix) +} + +// CheckAndMoveOwnership mocks base method. +func (m *MockIndex) CheckAndMoveOwnership(ctx context.Context, key index.Key, oldIdentity string, aclRecordIndex int) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CheckAndMoveOwnership", ctx, key, oldIdentity, aclRecordIndex) + ret0, _ := ret[0].(error) + return ret0 +} + +// CheckAndMoveOwnership indicates an expected call of CheckAndMoveOwnership. +func (mr *MockIndexMockRecorder) CheckAndMoveOwnership(ctx, key, oldIdentity, aclRecordIndex any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckAndMoveOwnership", reflect.TypeOf((*MockIndex)(nil).CheckAndMoveOwnership), ctx, key, oldIdentity, aclRecordIndex) } // CheckDeletedSpaces mocks base method. -func (m *MockIndex) CheckDeletedSpaces(arg0 context.Context, arg1 index.Key, arg2 func([]string) ([]string, error), arg3 bool) ([]string, error) { +func (m *MockIndex) CheckDeletedSpaces(ctx context.Context, key index.Key, resolve func([]string) ([]string, error), doFix bool) ([]string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CheckDeletedSpaces", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "CheckDeletedSpaces", ctx, key, resolve, doFix) ret0, _ := ret[0].([]string) ret1, _ := ret[1].(error) return ret0, ret1 } // CheckDeletedSpaces indicates an expected call of CheckDeletedSpaces. -func (mr *MockIndexMockRecorder) CheckDeletedSpaces(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CheckDeletedSpaces(ctx, key, resolve, doFix any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDeletedSpaces", reflect.TypeOf((*MockIndex)(nil).CheckDeletedSpaces), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDeletedSpaces", reflect.TypeOf((*MockIndex)(nil).CheckDeletedSpaces), ctx, key, resolve, doFix) } // CheckKey mocks base method. -func (m *MockIndex) CheckKey(arg0 context.Context, arg1 string) (bool, error) { +func (m *MockIndex) CheckKey(ctx context.Context, key string) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CheckKey", arg0, arg1) + ret := m.ctrl.Call(m, "CheckKey", ctx, key) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // CheckKey indicates an expected call of CheckKey. -func (mr *MockIndexMockRecorder) CheckKey(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CheckKey(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckKey", reflect.TypeOf((*MockIndex)(nil).CheckKey), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckKey", reflect.TypeOf((*MockIndex)(nil).CheckKey), ctx, key) } // CheckLimits mocks base method. -func (m *MockIndex) CheckLimits(arg0 context.Context, arg1 index.Key) error { +func (m *MockIndex) CheckLimits(ctx context.Context, key index.Key) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CheckLimits", arg0, arg1) + ret := m.ctrl.Call(m, "CheckLimits", ctx, key) ret0, _ := ret[0].(error) return ret0 } // CheckLimits indicates an expected call of CheckLimits. -func (mr *MockIndexMockRecorder) CheckLimits(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CheckLimits(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckLimits", reflect.TypeOf((*MockIndex)(nil).CheckLimits), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckLimits", reflect.TypeOf((*MockIndex)(nil).CheckLimits), ctx, key) } // CidEntries mocks base method. -func (m *MockIndex) CidEntries(arg0 context.Context, arg1 []cid.Cid) (*index.CidEntries, error) { +func (m *MockIndex) CidEntries(ctx context.Context, cids []cid.Cid) (*index.CidEntries, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CidEntries", arg0, arg1) + ret := m.ctrl.Call(m, "CidEntries", ctx, cids) ret0, _ := ret[0].(*index.CidEntries) ret1, _ := ret[1].(error) return ret0, ret1 } // CidEntries indicates an expected call of CidEntries. -func (mr *MockIndexMockRecorder) CidEntries(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CidEntries(ctx, cids any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidEntries", reflect.TypeOf((*MockIndex)(nil).CidEntries), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidEntries", reflect.TypeOf((*MockIndex)(nil).CidEntries), ctx, cids) } // CidEntriesByBlocks mocks base method. -func (m *MockIndex) CidEntriesByBlocks(arg0 context.Context, arg1 []blocks.Block) (*index.CidEntries, error) { +func (m *MockIndex) CidEntriesByBlocks(ctx context.Context, bs []blocks.Block) (*index.CidEntries, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CidEntriesByBlocks", arg0, arg1) + ret := m.ctrl.Call(m, "CidEntriesByBlocks", ctx, bs) ret0, _ := ret[0].(*index.CidEntries) ret1, _ := ret[1].(error) return ret0, ret1 } // CidEntriesByBlocks indicates an expected call of CidEntriesByBlocks. -func (mr *MockIndexMockRecorder) CidEntriesByBlocks(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CidEntriesByBlocks(ctx, bs any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidEntriesByBlocks", reflect.TypeOf((*MockIndex)(nil).CidEntriesByBlocks), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidEntriesByBlocks", reflect.TypeOf((*MockIndex)(nil).CidEntriesByBlocks), ctx, bs) } // CidExists mocks base method. -func (m *MockIndex) CidExists(arg0 context.Context, arg1 cid.Cid) (bool, error) { +func (m *MockIndex) CidExists(ctx context.Context, c cid.Cid) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CidExists", arg0, arg1) + ret := m.ctrl.Call(m, "CidExists", ctx, c) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // CidExists indicates an expected call of CidExists. -func (mr *MockIndexMockRecorder) CidExists(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CidExists(ctx, c any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidExists", reflect.TypeOf((*MockIndex)(nil).CidExists), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidExists", reflect.TypeOf((*MockIndex)(nil).CidExists), ctx, c) } // CidExistsInSpace mocks base method. -func (m *MockIndex) CidExistsInSpace(arg0 context.Context, arg1 index.Key, arg2 []cid.Cid) ([]cid.Cid, error) { +func (m *MockIndex) CidExistsInSpace(ctx context.Context, key index.Key, cids []cid.Cid) ([]cid.Cid, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CidExistsInSpace", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "CidExistsInSpace", ctx, key, cids) ret0, _ := ret[0].([]cid.Cid) ret1, _ := ret[1].(error) return ret0, ret1 } // CidExistsInSpace indicates an expected call of CidExistsInSpace. -func (mr *MockIndexMockRecorder) CidExistsInSpace(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIndexMockRecorder) CidExistsInSpace(ctx, key, cids any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidExistsInSpace", reflect.TypeOf((*MockIndex)(nil).CidExistsInSpace), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CidExistsInSpace", reflect.TypeOf((*MockIndex)(nil).CidExistsInSpace), ctx, key, cids) } // Close mocks base method. -func (m *MockIndex) Close(arg0 context.Context) error { +func (m *MockIndex) Close(ctx context.Context) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close", arg0) + ret := m.ctrl.Call(m, "Close", ctx) ret0, _ := ret[0].(error) return ret0 } // Close indicates an expected call of Close. -func (mr *MockIndexMockRecorder) Close(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Close(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockIndex)(nil).Close), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockIndex)(nil).Close), ctx) } // FileBind mocks base method. -func (m *MockIndex) FileBind(arg0 context.Context, arg1 index.Key, arg2 string, arg3 *index.CidEntries) error { +func (m *MockIndex) FileBind(ctx context.Context, key index.Key, fileId string, cidEntries *index.CidEntries) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FileBind", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "FileBind", ctx, key, fileId, cidEntries) ret0, _ := ret[0].(error) return ret0 } // FileBind indicates an expected call of FileBind. -func (mr *MockIndexMockRecorder) FileBind(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockIndexMockRecorder) FileBind(ctx, key, fileId, cidEntries any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileBind", reflect.TypeOf((*MockIndex)(nil).FileBind), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileBind", reflect.TypeOf((*MockIndex)(nil).FileBind), ctx, key, fileId, cidEntries) } // FileInfo mocks base method. -func (m *MockIndex) FileInfo(arg0 context.Context, arg1 index.Key, arg2 ...string) ([]index.FileInfo, error) { +func (m *MockIndex) FileInfo(ctx context.Context, key index.Key, fileIds ...string) ([]index.FileInfo, error) { m.ctrl.T.Helper() - varargs := []any{arg0, arg1} - for _, a := range arg2 { + varargs := []any{ctx, key} + for _, a := range fileIds { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "FileInfo", varargs...) @@ -248,17 +263,17 @@ func (m *MockIndex) FileInfo(arg0 context.Context, arg1 index.Key, arg2 ...strin } // FileInfo indicates an expected call of FileInfo. -func (mr *MockIndexMockRecorder) FileInfo(arg0, arg1 any, arg2 ...any) *gomock.Call { +func (mr *MockIndexMockRecorder) FileInfo(ctx, key any, fileIds ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1}, arg2...) + varargs := append([]any{ctx, key}, fileIds...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileInfo", reflect.TypeOf((*MockIndex)(nil).FileInfo), varargs...) } // FileUnbind mocks base method. -func (m *MockIndex) FileUnbind(arg0 context.Context, arg1 index.Key, arg2 ...string) error { +func (m *MockIndex) FileUnbind(ctx context.Context, kye index.Key, fileIds ...string) error { m.ctrl.T.Helper() - varargs := []any{arg0, arg1} - for _, a := range arg2 { + varargs := []any{ctx, kye} + for _, a := range fileIds { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "FileUnbind", varargs...) @@ -267,83 +282,83 @@ func (m *MockIndex) FileUnbind(arg0 context.Context, arg1 index.Key, arg2 ...str } // FileUnbind indicates an expected call of FileUnbind. -func (mr *MockIndexMockRecorder) FileUnbind(arg0, arg1 any, arg2 ...any) *gomock.Call { +func (mr *MockIndexMockRecorder) FileUnbind(ctx, kye any, fileIds ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1}, arg2...) + varargs := append([]any{ctx, kye}, fileIds...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileUnbind", reflect.TypeOf((*MockIndex)(nil).FileUnbind), varargs...) } // FilesList mocks base method. -func (m *MockIndex) FilesList(arg0 context.Context, arg1 index.Key) ([]string, error) { +func (m *MockIndex) FilesList(ctx context.Context, key index.Key) ([]string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FilesList", arg0, arg1) + ret := m.ctrl.Call(m, "FilesList", ctx, key) ret0, _ := ret[0].([]string) ret1, _ := ret[1].(error) return ret0, ret1 } // FilesList indicates an expected call of FilesList. -func (mr *MockIndexMockRecorder) FilesList(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) FilesList(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilesList", reflect.TypeOf((*MockIndex)(nil).FilesList), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FilesList", reflect.TypeOf((*MockIndex)(nil).FilesList), ctx, key) } // GroupInfo mocks base method. -func (m *MockIndex) GroupInfo(arg0 context.Context, arg1 string) (index.GroupInfo, error) { +func (m *MockIndex) GroupInfo(ctx context.Context, groupId string) (index.GroupInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GroupInfo", arg0, arg1) + ret := m.ctrl.Call(m, "GroupInfo", ctx, groupId) ret0, _ := ret[0].(index.GroupInfo) ret1, _ := ret[1].(error) return ret0, ret1 } // GroupInfo indicates an expected call of GroupInfo. -func (mr *MockIndexMockRecorder) GroupInfo(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) GroupInfo(ctx, groupId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GroupInfo", reflect.TypeOf((*MockIndex)(nil).GroupInfo), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GroupInfo", reflect.TypeOf((*MockIndex)(nil).GroupInfo), ctx, groupId) } // Init mocks base method. -func (m *MockIndex) Init(arg0 *app.App) error { +func (m *MockIndex) Init(a *app.App) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Init", arg0) + ret := m.ctrl.Call(m, "Init", a) ret0, _ := ret[0].(error) return ret0 } // Init indicates an expected call of Init. -func (mr *MockIndexMockRecorder) Init(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Init(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockIndex)(nil).Init), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockIndex)(nil).Init), a) } // MarkSpaceAsDeleted mocks base method. -func (m *MockIndex) MarkSpaceAsDeleted(arg0 context.Context, arg1 index.Key) (bool, error) { +func (m *MockIndex) MarkSpaceAsDeleted(ctx context.Context, key index.Key) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MarkSpaceAsDeleted", arg0, arg1) + ret := m.ctrl.Call(m, "MarkSpaceAsDeleted", ctx, key) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // MarkSpaceAsDeleted indicates an expected call of MarkSpaceAsDeleted. -func (mr *MockIndexMockRecorder) MarkSpaceAsDeleted(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) MarkSpaceAsDeleted(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkSpaceAsDeleted", reflect.TypeOf((*MockIndex)(nil).MarkSpaceAsDeleted), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkSpaceAsDeleted", reflect.TypeOf((*MockIndex)(nil).MarkSpaceAsDeleted), ctx, key) } // Migrate mocks base method. -func (m *MockIndex) Migrate(arg0 context.Context, arg1 index.Key) error { +func (m *MockIndex) Migrate(ctx context.Context, key index.Key) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Migrate", arg0, arg1) + ret := m.ctrl.Call(m, "Migrate", ctx, key) ret0, _ := ret[0].(error) return ret0 } // Migrate indicates an expected call of Migrate. -func (mr *MockIndexMockRecorder) Migrate(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Migrate(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockIndex)(nil).Migrate), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockIndex)(nil).Migrate), ctx, key) } // Name mocks base method. @@ -361,104 +376,104 @@ func (mr *MockIndexMockRecorder) Name() *gomock.Call { } // OnBlockUploaded mocks base method. -func (m *MockIndex) OnBlockUploaded(arg0 context.Context, arg1 ...blocks.Block) { +func (m *MockIndex) OnBlockUploaded(ctx context.Context, bs ...blocks.Block) { m.ctrl.T.Helper() - varargs := []any{arg0} - for _, a := range arg1 { + varargs := []any{ctx} + for _, a := range bs { varargs = append(varargs, a) } m.ctrl.Call(m, "OnBlockUploaded", varargs...) } // OnBlockUploaded indicates an expected call of OnBlockUploaded. -func (mr *MockIndexMockRecorder) OnBlockUploaded(arg0 any, arg1 ...any) *gomock.Call { +func (mr *MockIndexMockRecorder) OnBlockUploaded(ctx any, bs ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0}, arg1...) + varargs := append([]any{ctx}, bs...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnBlockUploaded", reflect.TypeOf((*MockIndex)(nil).OnBlockUploaded), varargs...) } // Run mocks base method. -func (m *MockIndex) Run(arg0 context.Context) error { +func (m *MockIndex) Run(ctx context.Context) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Run", arg0) + ret := m.ctrl.Call(m, "Run", ctx) ret0, _ := ret[0].(error) return ret0 } // Run indicates an expected call of Run. -func (mr *MockIndexMockRecorder) Run(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Run(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockIndex)(nil).Run), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockIndex)(nil).Run), ctx) } // SetGroupLimit mocks base method. -func (m *MockIndex) SetGroupLimit(arg0 context.Context, arg1 string, arg2 uint64) error { +func (m *MockIndex) SetGroupLimit(ctx context.Context, groupId string, limit uint64) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetGroupLimit", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SetGroupLimit", ctx, groupId, limit) ret0, _ := ret[0].(error) return ret0 } // SetGroupLimit indicates an expected call of SetGroupLimit. -func (mr *MockIndexMockRecorder) SetGroupLimit(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIndexMockRecorder) SetGroupLimit(ctx, groupId, limit any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetGroupLimit", reflect.TypeOf((*MockIndex)(nil).SetGroupLimit), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetGroupLimit", reflect.TypeOf((*MockIndex)(nil).SetGroupLimit), ctx, groupId, limit) } // SetSpaceLimit mocks base method. -func (m *MockIndex) SetSpaceLimit(arg0 context.Context, arg1 index.Key, arg2 uint64) error { +func (m *MockIndex) SetSpaceLimit(ctx context.Context, key index.Key, limit uint64) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetSpaceLimit", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SetSpaceLimit", ctx, key, limit) ret0, _ := ret[0].(error) return ret0 } // SetSpaceLimit indicates an expected call of SetSpaceLimit. -func (mr *MockIndexMockRecorder) SetSpaceLimit(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIndexMockRecorder) SetSpaceLimit(ctx, key, limit any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSpaceLimit", reflect.TypeOf((*MockIndex)(nil).SetSpaceLimit), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSpaceLimit", reflect.TypeOf((*MockIndex)(nil).SetSpaceLimit), ctx, key, limit) } // SpaceDelete mocks base method. -func (m *MockIndex) SpaceDelete(arg0 context.Context, arg1 index.Key) (bool, error) { +func (m *MockIndex) SpaceDelete(ctx context.Context, key index.Key) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpaceDelete", arg0, arg1) + ret := m.ctrl.Call(m, "SpaceDelete", ctx, key) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // SpaceDelete indicates an expected call of SpaceDelete. -func (mr *MockIndexMockRecorder) SpaceDelete(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) SpaceDelete(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceDelete", reflect.TypeOf((*MockIndex)(nil).SpaceDelete), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceDelete", reflect.TypeOf((*MockIndex)(nil).SpaceDelete), ctx, key) } // SpaceInfo mocks base method. -func (m *MockIndex) SpaceInfo(arg0 context.Context, arg1 index.Key) (index.SpaceInfo, error) { +func (m *MockIndex) SpaceInfo(ctx context.Context, key index.Key) (index.SpaceInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpaceInfo", arg0, arg1) + ret := m.ctrl.Call(m, "SpaceInfo", ctx, key) ret0, _ := ret[0].(index.SpaceInfo) ret1, _ := ret[1].(error) return ret0, ret1 } // SpaceInfo indicates an expected call of SpaceInfo. -func (mr *MockIndexMockRecorder) SpaceInfo(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) SpaceInfo(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceInfo", reflect.TypeOf((*MockIndex)(nil).SpaceInfo), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceInfo", reflect.TypeOf((*MockIndex)(nil).SpaceInfo), ctx, key) } // WaitCidExists mocks base method. -func (m *MockIndex) WaitCidExists(arg0 context.Context, arg1 cid.Cid) error { +func (m *MockIndex) WaitCidExists(ctx context.Context, c cid.Cid) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WaitCidExists", arg0, arg1) + ret := m.ctrl.Call(m, "WaitCidExists", ctx, c) ret0, _ := ret[0].(error) return ret0 } // WaitCidExists indicates an expected call of WaitCidExists. -func (mr *MockIndexMockRecorder) WaitCidExists(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) WaitCidExists(ctx, c any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitCidExists", reflect.TypeOf((*MockIndex)(nil).WaitCidExists), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitCidExists", reflect.TypeOf((*MockIndex)(nil).WaitCidExists), ctx, c) } diff --git a/index/move.go b/index/move.go new file mode 100644 index 0000000..a40bf88 --- /dev/null +++ b/index/move.go @@ -0,0 +1,195 @@ +package index + +import ( + "context" + "errors" + "fmt" + "slices" + "strings" + + "github.com/redis/go-redis/v9" + "go.uber.org/zap" + + "github.com/anyproto/any-sync-filenode/index/indexproto" +) + +func (ri *redisIndex) CheckAndMoveOwnership(ctx context.Context, key Key, oldIdentity string, aclRecordIndex int) (err error) { + oKey := OwnerKey(key.SpaceId) + _, release, err := ri.AcquireKey(ctx, oKey) + if err != nil { + return + } + defer release() + + var ( + ownerData = &indexproto.OwnershipRecord{ + OwnerId: oldIdentity, + } + notExists bool + ) + result, err := ri.cl.Get(ctx, oKey).Result() + if err != nil { + if errors.Is(err, redis.Nil) { + notExists = true + err = nil + } else { + return + } + } + + if !notExists { + if err = ownerData.UnmarshalVT([]byte(result)); err != nil { + return + } + } else if oldIdentity == "" { + return fmt.Errorf("previous owner not found") + } + + var needUpdate bool + if ownerData.OwnerId != key.GroupId && ownerData.AclRecordIndex <= int64(aclRecordIndex) { + if err = ri.Move(ctx, key, Key{SpaceId: key.SpaceId, GroupId: ownerData.OwnerId}); err != nil { + return + } + ownerData.OwnerId = key.GroupId + needUpdate = true + } + + if ownerData.AclRecordIndex < int64(aclRecordIndex) { + ownerData.AclRecordIndex = int64(aclRecordIndex) + needUpdate = true + } + + if !needUpdate { + return + } + + data, err := ownerData.MarshalVT() + if err != nil { + return err + } + return ri.cl.Set(ctx, oKey, data, 0).Err() +} + +func (ri *redisIndex) Move(ctx context.Context, dest, src Key) (err error) { + log.InfoCtx(ctx, "move space", zap.String("spaceId", dest.SpaceId), zap.String("src", src.GroupId), zap.String("dest", dest.GroupId)) + if dest.SpaceId != src.SpaceId { + return fmt.Errorf("spaceId should be the same for both keys") + } + srcEntry, scrRelease, err := ri.AcquireSpace(ctx, src) + if err != nil { + return + } + defer scrRelease() + + _, destGRelease, err := ri.AcquireKey(ctx, GroupKey(dest)) + if err != nil { + return + } + defer destGRelease() + + destGroup, err := ri.getGroupEntry(ctx, dest) + if err != nil { + return + } + + // in case of hash collision, we don't need to lock the space key twice + sSK := SpaceKey(src) + dSK := SpaceKey(dest) + if sSK != dSK { + _, destSRelease, err := ri.AcquireKey(ctx, SpaceKey(dest)) + if err != nil { + return err + } + defer destSRelease() + } + + // collect all the space cids + keys, err := ri.cl.HKeys(ctx, sSK).Result() + if err != nil { + return + } + var cids []string + for _, k := range keys { + if strings.HasPrefix(k, "c:") { + cids = append(cids, k[2:]) + } + } + + // load entries + cidEntries, err := ri.CidEntriesByString(ctx, cids) + if err != nil { + return + } + defer cidEntries.Release() + + // increment cid refs in the dest group + dGK := GroupKey(dest) + cmdGroupExists := make([]*redis.IntCmd, len(cidEntries.entries)) + _, err = ri.cl.Pipelined(ctx, func(pipe redis.Pipeliner) error { + for i, cidE := range cidEntries.entries { + cmdGroupExists[i] = pipe.HIncrBy(ctx, dGK, CidKey(cidE.Cid), 1) + } + return nil + }) + if err != nil { + return + } + + // calculate the dest group sums + for i, cmd := range cmdGroupExists { + res, _ := cmd.Result() + if res == 1 { + destGroup.CidCount++ + destGroup.Size += cidEntries.entries[i].Size + } + } + + // remove cids from the src group + sGK := GroupKey(src) + var srcCmdGroupDecr = make([]*redis.IntCmd, len(cidEntries.entries)) + _, err = ri.cl.Pipelined(ctx, func(pipe redis.Pipeliner) error { + for i, cidE := range cidEntries.entries { + srcCmdGroupDecr[i] = pipe.HIncrBy(ctx, sGK, CidKey(cidE.Cid), -1) + } + return nil + }) + if err != nil { + return + } + + // remove unneeded cids / update sums / save the src group entry + _, err = ri.cl.Pipelined(ctx, func(pipe redis.Pipeliner) error { + for i, cmd := range srcCmdGroupDecr { + res, _ := cmd.Result() + if res == 0 { + srcEntry.group.CidCount-- + srcEntry.group.Size -= cidEntries.entries[i].Size + pipe.HDel(ctx, sGK, CidKey(cidEntries.entries[i].Cid)) + } + } + srcEntry.space.GroupId = dest.GroupId + srcEntry.space.Save(ctx, src, pipe) + srcEntry.group.SpaceIds = slices.DeleteFunc(srcEntry.group.SpaceIds, func(spaceId string) bool { + return spaceId == src.SpaceId + }) + srcEntry.group.Save(ctx, pipe) + return nil + }) + if err != nil { + return + } + + _, err = ri.cl.Pipelined(ctx, func(pipe redis.Pipeliner) error { + srcEntry.space.Save(ctx, dest, pipe) + destGroup.AddSpaceId(src.SpaceId) + destGroup.Save(ctx, pipe) + return nil + }) + + if sSK != dSK { + if err = ri.cl.Del(ctx, sSK).Err(); err != nil { + return + } + } + return +} diff --git a/index/move_test.go b/index/move_test.go new file mode 100644 index 0000000..21ead9f --- /dev/null +++ b/index/move_test.go @@ -0,0 +1,103 @@ +package index + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/anyproto/any-sync-filenode/testutil" +) + +func TestRedisIndex_CheckOwnership(t *testing.T) { + t.Run("same owner", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish(t) + err := fx.CheckAndMoveOwnership(ctx, Key{"o1", "s1"}, "s1", 0) + require.NoError(t, err) + err = fx.CheckAndMoveOwnership(ctx, Key{"o1", "s1"}, "", 0) + require.NoError(t, err) + err = fx.CheckAndMoveOwnership(ctx, Key{"o1", "s1"}, "", 22) + require.NoError(t, err) + }) + t.Run("change owner", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish(t) + err := fx.CheckAndMoveOwnership(ctx, Key{"alice", "s1"}, "sn", 0) + require.NoError(t, err) + err = fx.CheckAndMoveOwnership(ctx, Key{GroupId: "bob", SpaceId: "s1"}, "sn", 1) + require.NoError(t, err) + }) + t.Run("old index", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish(t) + err := fx.CheckAndMoveOwnership(ctx, Key{"alice", "s1"}, "sn", 11) + require.NoError(t, err) + err = fx.CheckAndMoveOwnership(ctx, Key{"bob", "s1"}, "sn", 9) + require.NoError(t, err) + }) + t.Run("no prev owner", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish(t) + err := fx.CheckAndMoveOwnership(ctx, Key{"alice", "s1"}, "", 12) + assert.Error(t, err) + }) +} + +func TestRedisIndex_Move(t *testing.T) { + var test = func(aliceKey, bobKey Key) { + fx := newFixture(t) + defer fx.Finish(t) + + aliceBS := testutil.NewRandBlocks(3) + require.NoError(t, fx.BlocksAdd(ctx, aliceBS)) + aliceCids, err := fx.CidEntriesByBlocks(ctx, aliceBS) + require.NoError(t, err) + require.NoError(t, fx.FileBind(ctx, aliceKey, "f1", aliceCids)) + aliceCids.Release() + + bobBS := testutil.NewRandBlocks(3) + require.NoError(t, fx.BlocksAdd(ctx, bobBS)) + bobCids, err := fx.CidEntriesByBlocks(ctx, bobBS) + require.NoError(t, err) + require.NoError(t, fx.FileBind(ctx, bobKey, "f1", bobCids)) + bobCids.Release() + + aliceGroupBefore, err := fx.GroupInfo(ctx, aliceKey.GroupId) + require.NoError(t, err) + bobGroupBefore, err := fx.GroupInfo(ctx, bobKey.GroupId) + require.NoError(t, err) + spaceBefore, err := fx.SpaceInfo(ctx, bobKey) + require.NoError(t, err) + + require.NoError(t, fx.Move(ctx, Key{aliceKey.GroupId, bobKey.SpaceId}, bobKey)) + + aliceGroupAfter, err := fx.GroupInfo(ctx, aliceKey.GroupId) + require.NoError(t, err) + bobGroupAfter, err := fx.GroupInfo(ctx, bobKey.GroupId) + require.NoError(t, err) + spaceAfter, err := fx.SpaceInfo(ctx, Key{aliceKey.GroupId, bobKey.SpaceId}) + require.NoError(t, err) + + assert.Equal(t, int(aliceGroupBefore.BytesUsage+spaceBefore.BytesUsage), int(aliceGroupAfter.BytesUsage)) + assert.Greater(t, int(bobGroupBefore.BytesUsage), 0) + assert.NotEqual(t, bobGroupBefore.BytesUsage, bobGroupAfter.BytesUsage) + assert.Equal(t, int(bobGroupAfter.BytesUsage), 0) + assert.Equal(t, int(bobGroupAfter.CidsCount), 0) + assert.Len(t, bobGroupAfter.SpaceIds, 0) + assert.Len(t, aliceGroupAfter.SpaceIds, 2) + assert.Equal(t, int(spaceAfter.BytesUsage), int(spaceBefore.BytesUsage)) + } + + t.Run("move", func(t *testing.T) { + var srcKey = Key{"g1", "s1"} + var dstKey = Key{"g2", "s2"} + test(srcKey, dstKey) + }) + t.Run("move same hash", func(t *testing.T) { + // these groups has an identical xxhash + var srcKey = Key{"3325572473", "s1"} + var dstKey = Key{"8117876798", "s2"} + test(srcKey, dstKey) + }) +} diff --git a/index/unbind.go b/index/unbind.go index b73e766..f4d2ee6 100644 --- a/index/unbind.go +++ b/index/unbind.go @@ -85,10 +85,10 @@ func (ri *redisIndex) fileUnbind(ctx context.Context, key Key, entry groupSpaceE } if res == "1" { groupRemoveKeys = append(groupRemoveKeys, ck) - if entry.group.Size_-c.Size_ > entry.group.Size_ { - log.WarnCtx(ctx, "group: unable to decrement size", zap.Uint64("before", entry.group.Size_), zap.Uint64("size", c.Size_), zap.String("spaceId", key.SpaceId)) + if entry.group.Size-c.Size > entry.group.Size { + log.WarnCtx(ctx, "group: unable to decrement size", zap.Uint64("before", entry.group.Size), zap.Uint64("size", c.Size), zap.String("spaceId", key.SpaceId)) } else { - entry.group.Size_ -= c.Size_ + entry.group.Size -= c.Size } if entry.group.CidCount != 0 { entry.group.CidCount-- @@ -105,10 +105,10 @@ func (ri *redisIndex) fileUnbind(ctx context.Context, key Key, entry groupSpaceE } if res == "1" { spaceRemoveKeys = append(spaceRemoveKeys, ck) - if entry.space.Size_-c.Size_ > entry.space.Size_ { - log.WarnCtx(ctx, "space: unable to decrement size", zap.Uint64("before", entry.space.Size_), zap.Uint64("size", c.Size_), zap.String("spaceId", key.SpaceId)) + if entry.space.Size-c.Size > entry.space.Size { + log.WarnCtx(ctx, "space: unable to decrement size", zap.Uint64("before", entry.space.Size), zap.Uint64("size", c.Size), zap.String("spaceId", key.SpaceId)) } else { - entry.space.Size_ -= c.Size_ + entry.space.Size -= c.Size } if entry.space.CidCount != 0 { entry.space.CidCount-- diff --git a/store/mock_store/mock_store.go b/store/mock_store/mock_store.go index 6aa3454..d0616c6 100644 --- a/store/mock_store/mock_store.go +++ b/store/mock_store/mock_store.go @@ -23,6 +23,7 @@ import ( type MockStore struct { ctrl *gomock.Controller recorder *MockStoreMockRecorder + isgomock struct{} } // MockStoreMockRecorder is the mock recorder for MockStore. @@ -43,131 +44,131 @@ func (m *MockStore) EXPECT() *MockStoreMockRecorder { } // Add mocks base method. -func (m *MockStore) Add(arg0 context.Context, arg1 []blocks.Block) error { +func (m *MockStore) Add(ctx context.Context, b []blocks.Block) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Add", arg0, arg1) + ret := m.ctrl.Call(m, "Add", ctx, b) ret0, _ := ret[0].(error) return ret0 } // Add indicates an expected call of Add. -func (mr *MockStoreMockRecorder) Add(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) Add(ctx, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockStore)(nil).Add), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockStore)(nil).Add), ctx, b) } // Delete mocks base method. -func (m *MockStore) Delete(arg0 context.Context, arg1 cid.Cid) error { +func (m *MockStore) Delete(ctx context.Context, c cid.Cid) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret := m.ctrl.Call(m, "Delete", ctx, c) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockStoreMockRecorder) Delete(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) Delete(ctx, c any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockStore)(nil).Delete), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockStore)(nil).Delete), ctx, c) } // DeleteMany mocks base method. -func (m *MockStore) DeleteMany(arg0 context.Context, arg1 []cid.Cid) error { +func (m *MockStore) DeleteMany(ctx context.Context, toDelete []cid.Cid) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteMany", arg0, arg1) + ret := m.ctrl.Call(m, "DeleteMany", ctx, toDelete) ret0, _ := ret[0].(error) return ret0 } // DeleteMany indicates an expected call of DeleteMany. -func (mr *MockStoreMockRecorder) DeleteMany(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) DeleteMany(ctx, toDelete any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMany", reflect.TypeOf((*MockStore)(nil).DeleteMany), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMany", reflect.TypeOf((*MockStore)(nil).DeleteMany), ctx, toDelete) } // Get mocks base method. -func (m *MockStore) Get(arg0 context.Context, arg1 cid.Cid) (blocks.Block, error) { +func (m *MockStore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", arg0, arg1) + ret := m.ctrl.Call(m, "Get", ctx, k) ret0, _ := ret[0].(blocks.Block) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockStoreMockRecorder) Get(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) Get(ctx, k any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockStore)(nil).Get), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockStore)(nil).Get), ctx, k) } // GetMany mocks base method. -func (m *MockStore) GetMany(arg0 context.Context, arg1 []cid.Cid) <-chan blocks.Block { +func (m *MockStore) GetMany(ctx context.Context, ks []cid.Cid) <-chan blocks.Block { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetMany", arg0, arg1) + ret := m.ctrl.Call(m, "GetMany", ctx, ks) ret0, _ := ret[0].(<-chan blocks.Block) return ret0 } // GetMany indicates an expected call of GetMany. -func (mr *MockStoreMockRecorder) GetMany(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) GetMany(ctx, ks any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMany", reflect.TypeOf((*MockStore)(nil).GetMany), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMany", reflect.TypeOf((*MockStore)(nil).GetMany), ctx, ks) } // IndexDelete mocks base method. -func (m *MockStore) IndexDelete(arg0 context.Context, arg1 string) error { +func (m *MockStore) IndexDelete(ctx context.Context, key string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IndexDelete", arg0, arg1) + ret := m.ctrl.Call(m, "IndexDelete", ctx, key) ret0, _ := ret[0].(error) return ret0 } // IndexDelete indicates an expected call of IndexDelete. -func (mr *MockStoreMockRecorder) IndexDelete(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) IndexDelete(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexDelete", reflect.TypeOf((*MockStore)(nil).IndexDelete), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexDelete", reflect.TypeOf((*MockStore)(nil).IndexDelete), ctx, key) } // IndexGet mocks base method. -func (m *MockStore) IndexGet(arg0 context.Context, arg1 string) ([]byte, error) { +func (m *MockStore) IndexGet(ctx context.Context, key string) ([]byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IndexGet", arg0, arg1) + ret := m.ctrl.Call(m, "IndexGet", ctx, key) ret0, _ := ret[0].([]byte) ret1, _ := ret[1].(error) return ret0, ret1 } // IndexGet indicates an expected call of IndexGet. -func (mr *MockStoreMockRecorder) IndexGet(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreMockRecorder) IndexGet(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexGet", reflect.TypeOf((*MockStore)(nil).IndexGet), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexGet", reflect.TypeOf((*MockStore)(nil).IndexGet), ctx, key) } // IndexPut mocks base method. -func (m *MockStore) IndexPut(arg0 context.Context, arg1 string, arg2 []byte) error { +func (m *MockStore) IndexPut(ctx context.Context, key string, value []byte) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IndexPut", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "IndexPut", ctx, key, value) ret0, _ := ret[0].(error) return ret0 } // IndexPut indicates an expected call of IndexPut. -func (mr *MockStoreMockRecorder) IndexPut(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreMockRecorder) IndexPut(ctx, key, value any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexPut", reflect.TypeOf((*MockStore)(nil).IndexPut), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexPut", reflect.TypeOf((*MockStore)(nil).IndexPut), ctx, key, value) } // Init mocks base method. -func (m *MockStore) Init(arg0 *app.App) error { +func (m *MockStore) Init(a *app.App) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Init", arg0) + ret := m.ctrl.Call(m, "Init", a) ret0, _ := ret[0].(error) return ret0 } // Init indicates an expected call of Init. -func (mr *MockStoreMockRecorder) Init(arg0 any) *gomock.Call { +func (mr *MockStoreMockRecorder) Init(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockStore)(nil).Init), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockStore)(nil).Init), a) } // Name mocks base method.