Skip to content

Commit

Permalink
fix(dpos): reocrd last dpos rewards by history
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Jan 1, 2025
1 parent 9954c12 commit f300d17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions core/transaction/dposv2claimrewardtransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"bytes"
"errors"
"fmt"

"github.com/elastos/Elastos.ELA/common"
common2 "github.com/elastos/Elastos.ELA/core/types/common"

"github.com/elastos/Elastos.ELA/blockchain"
Expand Down
14 changes: 7 additions & 7 deletions dpos/state/arbitrators.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,13 @@ func (a *Arbiters) accumulateReward(block *types.Block, confirm *payload.Confirm
rewards = a.LastDPoSRewards[recordedSponsor]
}

swapReardMapContent(&a.LastDPoSRewards, &possibleRewards)
originRewardsMap := copyDPoSRewardMap(a.LastDPoSRewards)
a.History.Append(block.Height, func() {
a.LastDPoSRewards = possibleRewards
}, func() {
a.LastDPoSRewards = originRewardsMap
})

} else {
if confirm != nil {
// get sponsor from cache first
Expand Down Expand Up @@ -880,12 +886,6 @@ func (a *Arbiters) accumulateReward(block *types.Block, confirm *payload.Confirm
}
}

func swapReardMapContent(map1, map2 *map[string]map[string]common.Fixed64) {
temp := *map1
*map1 = *map2
*map2 = temp
}

func (a *Arbiters) clearingDPOSReward(block *types.Block, historyHeight uint32,
smoothClearing bool) (err error) {
if block.Height < a.ChainParams.PublicDPOSHeight ||
Expand Down

0 comments on commit f300d17

Please sign in to comment.