Skip to content

Commit

Permalink
chore: switch the order of create sp event and update price event
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Aug 28, 2023
1 parent 690ffe9 commit 3f78bea
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions x/sp/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
}

Expand Down

0 comments on commit 3f78bea

Please sign in to comment.