diff --git a/x/stake/keeper/distribute_sidechain.go b/x/stake/keeper/distribute_sidechain.go index a58333e65..0b90e2f44 100644 --- a/x/stake/keeper/distribute_sidechain.go +++ b/x/stake/keeper/distribute_sidechain.go @@ -134,6 +134,7 @@ func (k Keeper) DistributeInBreathBlock(ctx sdk.Context, sideChainId string) sdk var toPublish []types.DistributionData // data to be published in breathe blocks var toSaveRewards []types.Reward // rewards to be saved var toSaveValDistAddrs []types.StoredValDistAddr // mapping between validator and distribution address, to be saved + var rewardSum int64 bondDenom := k.BondDenom(ctx) for _, validator := range validators { @@ -195,6 +196,7 @@ func (k Keeper) DistributeInBreathBlock(ctx sdk.Context, sideChainId string) sdk if k.AddrPool != nil { k.AddrPool.AddAddrs(changedAddrs[:]) } + rewardSum += totalReward } if ctx.IsDeliverTx() && k.PbsbServer != nil { @@ -230,6 +232,13 @@ func (k Keeper) DistributeInBreathBlock(ctx sdk.Context, sideChainId string) sdk k.setRewardValDistAddrs(ctx, toSaveValDistAddrs) } + if rewardSum > 0 { + events = events.AppendEvent(sdk.Event{ + Type: types.EventTypeTotalDistribution, + Attributes: sdk.NewTags(types.AttributeKeyRewardSum, []byte(strconv.FormatInt(rewardSum, 10))), + }) + } + // publish data if needed if ctx.IsDeliverTx() && len(toPublish) > 0 && k.PbsbServer != nil { event := types.SideDistributionEvent{ diff --git a/x/stake/types/events.go b/x/stake/types/events.go index 9c15365c8..2b264a4ad 100644 --- a/x/stake/types/events.go +++ b/x/stake/types/events.go @@ -9,7 +9,8 @@ const ( EventTypeUnbond = "unbond" EventTypeRedelegate = "redelegate" - EventTypeCrossStake = "crossStake" + EventTypeCrossStake = "cross_stake" + EventTypeTotalDistribution = "total_distribution" AttributeKeyValidator = "validator" AttributeKeyCommissionRate = "commission_rate" @@ -20,4 +21,6 @@ const ( AttributeKeyCompletionTime = "completion_time" AttributeKeySideChainId = "side_chain_id" + + AttributeKeyRewardSum = "reward_sum" )