From b36d134fa6ed1c28e82ecb69085e755a86de85a8 Mon Sep 17 00:00:00 2001 From: WangLiStratos Date: Thu, 26 Jan 2023 23:09:54 -0500 Subject: [PATCH] updatestake to restore sp's ppstore --- x/register/keeper/msg_server.go | 3 ++- x/register/keeper/resource_node.go | 16 ++++++++-------- x/register/types/events.go | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/x/register/keeper/msg_server.go b/x/register/keeper/msg_server.go index 8d6ea4bc..ce281a77 100644 --- a/x/register/keeper/msg_server.go +++ b/x/register/keeper/msg_server.go @@ -321,7 +321,7 @@ func (k msgServer) HandleMsgUpdateResourceNodeStake(goCtx context.Context, msg * return &types.MsgUpdateResourceNodeStakeResponse{}, errors.New("invalid stake delta") } - ozoneLimitChange, completionTime, err := k.UpdateResourceNodeStake(ctx, networkAddr, ownerAddress, *msg.StakeDelta, msg.IncrStake) + ozoneLimitChange, completionTime, node, err := k.UpdateResourceNodeStake(ctx, networkAddr, ownerAddress, *msg.StakeDelta, msg.IncrStake) if err != nil { return nil, sdkerrors.Wrap(types.ErrUpdateResourceNodeStake, err.Error()) } @@ -333,6 +333,7 @@ func (k msgServer) HandleMsgUpdateResourceNodeStake(goCtx context.Context, msg * sdk.NewAttribute(types.AttributeKeyNetworkAddress, msg.NetworkAddress), sdk.NewAttribute(types.AttributeKeyIncrStakeBool, strconv.FormatBool(msg.IncrStake)), sdk.NewAttribute(types.AttributeKeyStakeDelta, msg.StakeDelta.String()), + sdk.NewAttribute(types.AttributeKeyCurrentStake, sdk.NewCoin(k.BondDenom(ctx), node.Tokens).String()), sdk.NewAttribute(types.AttributeKeyOZoneLimitChanges, ozoneLimitChange.String()), sdk.NewAttribute(types.AttributeKeyUnbondingMatureTime, completionTime.Format(time.RFC3339)), ), diff --git a/x/register/keeper/resource_node.go b/x/register/keeper/resource_node.go index 91731066..f3c3eeec 100644 --- a/x/register/keeper/resource_node.go +++ b/x/register/keeper/resource_node.go @@ -317,36 +317,36 @@ func (k Keeper) UpdateResourceNode(ctx sdk.Context, description types.Descriptio } func (k Keeper) UpdateResourceNodeStake(ctx sdk.Context, networkAddr stratos.SdsAddress, ownerAddr sdk.AccAddress, - stakeDelta sdk.Coin, incrStake bool) (ozoneLimitChange sdk.Int, unbondingMatureTime time.Time, err error) { + stakeDelta sdk.Coin, incrStake bool) (ozoneLimitChange sdk.Int, unbondingMatureTime time.Time, resourcenode types.ResourceNode, err error) { blockTime := ctx.BlockHeader().Time node, found := k.GetResourceNode(ctx, networkAddr) if !found { - return sdk.ZeroInt(), blockTime, types.ErrNoResourceNodeFound + return sdk.ZeroInt(), blockTime, node, types.ErrNoResourceNodeFound } ownerAddrNode, _ := sdk.AccAddressFromBech32(node.GetOwnerAddress()) if !bytes.Equal(ownerAddrNode, ownerAddr) { - return sdk.ZeroInt(), blockTime, types.ErrInvalidOwnerAddr + return sdk.ZeroInt(), blockTime, node, types.ErrInvalidOwnerAddr } if incrStake { ozoneLimitChange, err := k.AddResourceNodeStake(ctx, node, stakeDelta) if err != nil { - return sdk.ZeroInt(), blockTime, err + return sdk.ZeroInt(), blockTime, node, err } - return ozoneLimitChange, blockTime, nil + return ozoneLimitChange, blockTime, node, nil } else { // if !incrStake if node.GetStatus() == stakingtypes.Unbonding { - return sdk.ZeroInt(), blockTime, types.ErrUnbondingNode + return sdk.ZeroInt(), blockTime, node, types.ErrUnbondingNode } ozoneLimitChange, completionTime, err := k.UnbondResourceNode(ctx, node, stakeDelta.Amount) if err != nil { - return sdk.ZeroInt(), blockTime, err + return sdk.ZeroInt(), blockTime, node, err } - return ozoneLimitChange, completionTime, nil + return ozoneLimitChange, completionTime, node, nil } } diff --git a/x/register/types/events.go b/x/register/types/events.go index 5cdc7957..89b1dca5 100644 --- a/x/register/types/events.go +++ b/x/register/types/events.go @@ -30,6 +30,7 @@ const ( AttributeKeyOZoneLimitChanges = "ozone_limit_changes" AttributeKeyInitialStake = "initial_stake" + AttributeKeyCurrentStake = "current_stake" AttributeKeyStakeDelta = "stake_delta" AttributeKeyStakeToRemove = "stake_to_remove" AttributeKeyIncrStakeBool = "incr_stake"