Skip to content

Commit

Permalink
refactor options
Browse files Browse the repository at this point in the history
  • Loading branch information
fynn-0xc committed Feb 27, 2023
1 parent faa3a90 commit c31eea0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 60 deletions.
60 changes: 0 additions & 60 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}

type CreateBucketOptions struct {
IsPublic bool
SourceType types.SourceType
ReadQuota types.ReadQuota
PaymentAddress string
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}

type DeleteBucketOptions struct {
SourceType types.SourceType
}

type UpdateBucketOptions struct {
SourceType types.SourceType
ReadQuota types.ReadQuota
PaymentAddress string
}

func (k Keeper) CreateBucket(
ctx sdk.Context, ownerAcc sdk.AccAddress, bucketName string,
primarySpAddress string, opts CreateBucketOptions) (math.Uint, error) {
Expand Down Expand Up @@ -273,17 +254,6 @@ func (k Keeper) GetBucketInfoById(ctx sdk.Context, bucketId math.Uint) (bucketIn
return bucketInfo, true
}

type CreateObjectOptions struct {
IsPublic bool
ContentType string
SourceType types.SourceType
RedundancyType types.RedundancyType
Checksums [][]byte
SecondarySpAddresses []string
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}

func (k Keeper) CreateObject(
ctx sdk.Context, ownerAcc sdk.AccAddress, bucketName, objectName string,
payloadSize uint64, opts CreateObjectOptions) (math.Uint, error) {
Expand Down Expand Up @@ -485,10 +455,6 @@ func (k Keeper) SealObject(
return nil
}

type CancelCreateObjectOptions struct {
SourceType types.SourceType
}

func (k Keeper) CancelCreateObject(
ctx sdk.Context, ownAcc sdk.AccAddress,
bucketName, objectName string, opts CancelCreateObjectOptions) error {
Expand Down Expand Up @@ -538,10 +504,6 @@ func (k Keeper) CancelCreateObject(
return nil
}

type DeleteObjectOptions struct {
SourceType types.SourceType
}

func (k Keeper) DeleteObject(
ctx sdk.Context, operator sdk.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error {
store := ctx.KVStore(k.storeKey)
Expand Down Expand Up @@ -593,13 +555,6 @@ func (k Keeper) DeleteObject(
return nil
}

type CopyObjectOptions struct {
SourceType types.SourceType
IsPublic bool
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}

func (k Keeper) CopyObject(
ctx sdk.Context, operator sdk.AccAddress, srcBucketName, srcObjectName, dstBucketName, dstObjectName string,
opts CopyObjectOptions) (math.Uint, error) {
Expand Down Expand Up @@ -729,11 +684,6 @@ func (k Keeper) RejectSealObject(ctx sdk.Context, operator sdk.AccAddress, bucke
return nil
}

type CreateGroupOptions struct {
Members []string
SourceType types.SourceType
}

func (k Keeper) CreateGroup(
ctx sdk.Context, owner sdk.AccAddress,
groupName string, opts CreateGroupOptions) (math.Uint, error) {
Expand Down Expand Up @@ -827,10 +777,6 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, ownerAddr sdk.AccAddress, groupName
return nil
}

type LeaveGroupOptions struct {
types.SourceType
}

func (k Keeper) LeaveGroup(
ctx sdk.Context, member sdk.AccAddress, owner sdk.AccAddress,
groupName string, opts LeaveGroupOptions) error {
Expand All @@ -857,12 +803,6 @@ func (k Keeper) LeaveGroup(
return nil
}

type UpdateGroupMemberOptions struct {
SourceType types.SourceType
MembersToAdd []string
MembersToDelete []string
}

func (k Keeper) UpdateGroupMember(ctx sdk.Context, owner sdk.AccAddress, groupName string, opts UpdateGroupMemberOptions) error {
store := ctx.KVStore(k.storeKey)
groupInfo, found := k.GetGroupInfo(ctx, owner, groupName)
Expand Down
61 changes: 61 additions & 0 deletions x/storage/keeper/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package keeper

import "github.com/bnb-chain/greenfield/x/storage/types"

type CreateBucketOptions struct {
IsPublic bool
types.SourceType
ReadQuota types.ReadQuota
PaymentAddress string
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}

type DeleteBucketOptions struct {
types.SourceType
}

type UpdateBucketOptions struct {
types.SourceType
types.ReadQuota
PaymentAddress string
}

type CreateObjectOptions struct {
IsPublic bool
ContentType string
types.SourceType
types.RedundancyType
Checksums [][]byte
SecondarySpAddresses []string
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}

type CancelCreateObjectOptions struct {
types.SourceType
}

type DeleteObjectOptions struct {
types.SourceType
}

type CopyObjectOptions struct {
types.SourceType
IsPublic bool
PrimarySpApproval *types.Approval
ApprovalMsgBytes []byte
}
type CreateGroupOptions struct {
Members []string
types.SourceType
}
type LeaveGroupOptions struct {
types.SourceType
}

type UpdateGroupMemberOptions struct {
types.SourceType
MembersToAdd []string
MembersToDelete []string
}

0 comments on commit c31eea0

Please sign in to comment.