Skip to content

Commit

Permalink
update: add tag for reward recon
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Sep 21, 2022
1 parent 92d412e commit c90b968
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions x/stake/keeper/distribute_sidechain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down
5 changes: 4 additions & 1 deletion x/stake/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const (
EventTypeUnbond = "unbond"
EventTypeRedelegate = "redelegate"

EventTypeCrossStake = "crossStake"
EventTypeCrossStake = "cross_stake"
EventTypeTotalDistribution = "total_distribution"

AttributeKeyValidator = "validator"
AttributeKeyCommissionRate = "commission_rate"
Expand All @@ -20,4 +21,6 @@ const (
AttributeKeyCompletionTime = "completion_time"

AttributeKeySideChainId = "side_chain_id"

AttributeKeyRewardSum = "reward_sum"
)

0 comments on commit c90b968

Please sign in to comment.