Skip to content

Commit

Permalink
add event
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Mar 22, 2024
1 parent f28b240 commit 0bea34d
Show file tree
Hide file tree
Showing 3 changed files with 412 additions and 128 deletions.
13 changes: 13 additions & 0 deletions proto/greenfield/storage/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,16 @@ message EventBucketFlowRateLimitStatus {
// is_limited define the status of the bucket flow rate limit
bool is_limited = 2;
}

message EventToggleSPAsDelegatedAgent {
// bucket_name define the name of the bucket
string bucket_name = 1;
// bucket_id is the unique u256 for bucket. Not global, only unique in buckets.
string bucket_id = 2 [
(cosmos_proto.scalar) = "cosmos.Uint",
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// sp_as_delegated_agent_disabled indicates that whether bucket owner disable SP as the upload agent.
bool sp_as_delegated_agent_disabled = 3;
}
8 changes: 7 additions & 1 deletion x/storage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func (k msgServer) ToggleSPAsDelegatedAgent(goCtx context.Context, msg *storaget
}
bucketInfo.SpAsDelegatedAgentDisabled = !bucketInfo.SpAsDelegatedAgentDisabled
k.SetBucketInfo(ctx, bucketInfo)
if err := ctx.EventManager().EmitTypedEvents(&types.EventToggleSPAsDelegatedAgent{
BucketName: bucketInfo.BucketName,
BucketId: bucketInfo.Id,
SpAsDelegatedAgentDisabled: bucketInfo.SpAsDelegatedAgentDisabled,
}); err != nil {
return nil, err
}
return &types.MsgToggleSPAsDelegatedAgentResponse{}, nil

}

func (k msgServer) CreateObject(goCtx context.Context, msg *types.MsgCreateObject) (*types.MsgCreateObjectResponse, error) {
Expand Down
Loading

0 comments on commit 0bea34d

Please sign in to comment.