Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Feb 20, 2024
1 parent d9ae3f0 commit 8fe3000
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
13 changes: 10 additions & 3 deletions swagger/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3675,7 +3675,10 @@ paths:
properties:
operator:
type: string
title: operator define the account address of object updater
description: >-
operator defines the account address of the operator,
either the object owner or the updater with granted
permission.
id:
type: string
title: id defines the object id
Expand Down Expand Up @@ -35703,7 +35706,9 @@ definitions:
properties:
operator:
type: string
title: operator define the account address of object updater
description: >-
operator defines the account address of the operator, either the
object owner or the updater with granted permission.
id:
type: string
title: id defines the object id
Expand Down Expand Up @@ -36886,7 +36891,9 @@ definitions:
properties:
operator:
type: string
title: operator define the account address of object updater
description: >-
operator defines the account address of the operator, either the
object owner or the updater with granted permission.
id:
type: string
title: id defines the object id
Expand Down
24 changes: 4 additions & 20 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,9 @@ func (k Keeper) GetShadowObjectInfo(ctx sdk.Context, bucketName, objectName stri
return nil, false
}

return k.GetShadowObjectInfoById(ctx, k.objectSeq.DecodeSequence(bz))
var objectInfo types.ShadowObjectInfo
k.cdc.MustUnmarshal(bz, &objectInfo)
return &objectInfo, true
}

func (k Keeper) MustGetShadowObjectInfo(ctx sdk.Context, bucketName, objectName string) *types.ShadowObjectInfo {
Expand All @@ -749,19 +751,6 @@ func (k Keeper) MustGetShadowObjectInfo(ctx sdk.Context, bucketName, objectName
return shadowObjectInfo
}

func (k Keeper) GetShadowObjectInfoById(ctx sdk.Context, objectId sdkmath.Uint) (*types.ShadowObjectInfo, bool) {
store := ctx.KVStore(k.storeKey)

bz := store.Get(types.GetShadowObjectByIDKey(objectId))
if bz == nil {
return nil, false
}

var objectInfo types.ShadowObjectInfo
k.cdc.MustUnmarshal(bz, &objectInfo)
return &objectInfo, true
}

type SealObjectOptions struct {
GlobalVirtualGroupId uint32
SecondarySpBlsSignatures []byte
Expand Down Expand Up @@ -819,7 +808,6 @@ func (k Keeper) SealObject(
objectInfo.IsUpdating = false

store.Delete(types.GetShadowObjectKey(bucketInfo.BucketName, objectName))
store.Delete(types.GetShadowObjectByIDKey(shadowObjectInfo.Id))
} else if objectInfo.ObjectStatus != types.OBJECT_STATUS_CREATED {
return types.ErrObjectAlreadySealed
}
Expand Down Expand Up @@ -980,7 +968,6 @@ func (k Keeper) DeleteObject(
return err
}
}
_ = k.MustGetPrimarySPForBucket(ctx, bucketInfo)
internalBucketInfo := k.MustGetInternalBucketInfo(ctx, bucketInfo.Id)

err := k.UnChargeObjectStoreFee(ctx, bucketInfo, internalBucketInfo, objectInfo)
Expand Down Expand Up @@ -2498,9 +2485,7 @@ func (k Keeper) UpdateObjectContent(
UpdatedAt: ctx.BlockTime().Unix(),
Version: nextVersion,
}
store.Set(types.GetShadowObjectKey(bucketName, objectName), k.objectSeq.EncodeSequence(objectInfo.Id))
store.Set(types.GetShadowObjectByIDKey(shadowObjectInfo.Id), k.cdc.MustMarshal(shadowObjectInfo))

store.Set(types.GetShadowObjectKey(bucketName, objectName), k.cdc.MustMarshal(shadowObjectInfo))
err = k.LockShadowObjectStoreFee(ctx, bucketInfo, shadowObjectInfo, objectName)
if err != nil {
return err
Expand Down Expand Up @@ -2533,7 +2518,6 @@ func (k Keeper) UnlockShadowObjectFeeAndDeleteShadowObjectInfo(ctx sdk.Context,
}
store := ctx.KVStore(k.storeKey)
store.Delete(types.GetShadowObjectKey(bucketInfo.BucketName, objectName))
store.Delete(types.GetShadowObjectByIDKey(shadowObjectInfo.Id))
return
}

Expand Down
8 changes: 0 additions & 8 deletions x/storage/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ var (
ObjectByIDPrefix = []byte{0x22}
GroupByIDPrefix = []byte{0x23}

ShadowObjectByIDPrefix = []byte{0x24}

BucketSequencePrefix = []byte{0x31}
ObjectSequencePrefix = []byte{0x32}
GroupSequencePrefix = []byte{0x33}
Expand Down Expand Up @@ -112,12 +110,6 @@ func GetObjectByIDKey(objectId math.Uint) []byte {
return append(ObjectByIDPrefix, seq.EncodeSequence(objectId)...)
}

// GetShadowObjectByIDKey return the shadowObjectId store key
func GetShadowObjectByIDKey(objectId math.Uint) []byte {
var seq sequence.Sequence[math.Uint]
return append(ShadowObjectByIDPrefix, seq.EncodeSequence(objectId)...)
}

// GetGroupByIDKey return the groupId store key
func GetGroupByIDKey(groupId math.Uint) []byte {
var seq sequence.Sequence[math.Uint]
Expand Down
4 changes: 2 additions & 2 deletions x/storage/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/storage/types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8fe3000

Please sign in to comment.