From 3f78beacb3dd9859903ec29014d8144cff9106c7 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Mon, 28 Aug 2023 17:18:53 +0800 Subject: [PATCH] chore: switch the order of create sp event and update price event --- x/sp/keeper/msg_server.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/x/sp/keeper/msg_server.go b/x/sp/keeper/msg_server.go index d41fed6b5..3ed841ffd 100644 --- a/x/sp/keeper/msg_server.go +++ b/x/sp/keeper/msg_server.go @@ -144,16 +144,6 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr k.SetStorageProviderByGcAddr(ctx, &sp) k.SetStorageProviderByBlsKey(ctx, &sp) - // set initial sp storage price - spStoragePrice := types.SpStoragePrice{ - SpId: sp.Id, - UpdateTimeSec: ctx.BlockTime().Unix(), - ReadPrice: msg.ReadPrice, - StorePrice: msg.StorePrice, - FreeReadQuota: msg.FreeReadQuota, - } - k.SetSpStoragePrice(ctx, spStoragePrice) - if err = ctx.EventManager().EmitTypedEvents(&types.EventCreateStorageProvider{ SpId: sp.Id, SpAddress: spAcc.String(), @@ -170,6 +160,17 @@ func (k msgServer) CreateStorageProvider(goCtx context.Context, msg *types.MsgCr }); err != nil { return nil, err } + + // set initial sp storage price + spStoragePrice := types.SpStoragePrice{ + SpId: sp.Id, + UpdateTimeSec: ctx.BlockTime().Unix(), + ReadPrice: msg.ReadPrice, + StorePrice: msg.StorePrice, + FreeReadQuota: msg.FreeReadQuota, + } + k.SetSpStoragePrice(ctx, spStoragePrice) + return &types.MsgCreateStorageProviderResponse{}, nil }