Skip to content

Commit

Permalink
fix: add cancel mb event for discontinue and delete (#391)
Browse files Browse the repository at this point in the history
* add cancel migrate bucket events for delete and discontinue bucket

* fix lint

* Update msg_server_test.go

* Update msg_server_test.go

* fix lint
  • Loading branch information
fynnss authored Aug 3, 2023
1 parent 3f580f7 commit 5312550
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,26 @@ func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketI
if err != nil {
return err
}
err = ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{
if err = ctx.EventManager().EmitTypedEvents(&types.EventDeleteBucket{
Operator: operator.String(),
Owner: bucketInfo.Owner,
BucketName: bucketInfo.BucketName,
BucketId: bucketInfo.Id,
GlobalVirtualGroupFamilyId: bucketInfo.GlobalVirtualGroupFamilyId,
})
return err
}); err != nil {
return err
}

if bucketInfo.BucketStatus == types.BUCKET_STATUS_MIGRATING {
if err = ctx.EventManager().EmitTypedEvents(&types.EventCancelMigrationBucket{
Operator: operator.String(),
BucketName: bucketInfo.BucketName,
BucketId: bucketInfo.Id,
}); err != nil {
return err
}
}
return nil
}

func (k Keeper) GetPrimarySPForBucket(ctx sdk.Context, bucketInfo *types.BucketInfo) (*sptypes.StorageProvider, error) {
Expand Down Expand Up @@ -463,6 +475,16 @@ func (k Keeper) DiscontinueBucket(ctx sdk.Context, operator sdk.AccAddress, buck
k.appendDiscontinueBucketIds(ctx, deleteAt, []sdkmath.Uint{bucketInfo.Id})
k.SetDiscontinueBucketCount(ctx, operator, count+1)

if bucketInfo.BucketStatus == types.BUCKET_STATUS_MIGRATING {
if err := ctx.EventManager().EmitTypedEvents(&types.EventCancelMigrationBucket{
Operator: operator.String(),
BucketName: bucketInfo.BucketName,
BucketId: bucketInfo.Id,
}); err != nil {
return err
}
}

if err := ctx.EventManager().EmitTypedEvents(&types.EventDiscontinueBucket{
BucketId: bucketInfo.Id,
BucketName: bucketInfo.BucketName,
Expand Down

0 comments on commit 5312550

Please sign in to comment.