diff --git a/consensus/minerva/consensus.go b/consensus/minerva/consensus.go index 97a372c0..a4dd1422 100644 --- a/consensus/minerva/consensus.go +++ b/consensus/minerva/consensus.go @@ -880,12 +880,14 @@ func (m *Minerva) Finalize(chain consensus.ChainReader, header *types.Header, st epoch := types.GetEpochFromHeight(fastNumber.Uint64()) if fastNumber.Uint64() == epoch.EndHeight && fastNumber.Cmp(chain.Config().TIP13.FastNumber) >= 0 { + log.Info("*************accumulateRewardsFast3*******************") tip13Epoch := types.GetEpochFromHeight(chain.Config().TIP13.FastNumber.Uint64()) infos, err = accumulateRewardsFast3(state, new(big.Int).Set(header.Number), big.NewInt(int64(tip13Epoch.EpochID))) if err != nil { log.Error("Finalize Error", "accumulateRewardsFast3", err.Error()) return nil, nil, err } + infos.SimplePrint() } } else if !chain.Config().IsTIP13(header.Number) && header.SnailHash != (common.Hash{}) && header.SnailNumber.Sign() != 0 { sBlockHeader := m.sbc.GetHeaderByNumber(header.SnailNumber.Uint64()) @@ -1183,6 +1185,7 @@ func accumulateRewardsFast3(stateDB *state.StateDB, fast, origin *big.Int) (*typ } } rewardsInfos := &types.ChainReward{ + Height: fast.Uint64(), CommitteeBase: infos, Foundation: developer, } diff --git a/core/types/impawnUtil.go b/core/types/impawnUtil.go index 0f5d2cd4..4a7d4fef 100644 --- a/core/types/impawnUtil.go +++ b/core/types/impawnUtil.go @@ -101,11 +101,12 @@ type RewardInfo struct { Amount *big.Int `json:"Amount"` Staking *big.Int `json:"Staking"` } + func (e *RewardInfo) clone() *RewardInfo { return &RewardInfo{ - Address: e.Address, - Amount: new(big.Int).Set(e.Amount), - Staking: new(big.Int).Set(e.Staking), + Address: e.Address, + Amount: new(big.Int).Set(e.Amount), + Staking: new(big.Int).Set(e.Staking), } } func (e *RewardInfo) String() string { @@ -142,10 +143,11 @@ func mergeRewardInfos(items1, itmes2 []*RewardInfo) []*RewardInfo { type SARewardInfos struct { Items []*RewardInfo `json:"Items"` } + func (s *SARewardInfos) clone() *SARewardInfos { var res SARewardInfos - for _,v := range s.Items { - res.Items = append(res.Items,v.clone()) + for _, v := range s.Items { + res.Items = append(res.Items, v.clone()) } return &res } @@ -178,19 +180,30 @@ type ChainReward struct { FruitBase []*RewardInfo `json:"fruitminer"` CommitteeBase []*SARewardInfos `json:"committeeReward"` } + func CloneChainReward(reward *ChainReward) *ChainReward { var res ChainReward - res.Height,res.St = reward.Height,reward.St + res.Height, res.St = reward.Height, reward.St res.Foundation = reward.Foundation.clone() res.CoinBase = reward.CoinBase.clone() - for _,v := range reward.FruitBase { - res.FruitBase = append(res.FruitBase,v.clone()) + for _, v := range reward.FruitBase { + res.FruitBase = append(res.FruitBase, v.clone()) } - for _,v := range reward.CommitteeBase { - res.CommitteeBase = append(res.CommitteeBase,v.clone()) + for _, v := range reward.CommitteeBase { + res.CommitteeBase = append(res.CommitteeBase, v.clone()) } return &res } +func (c *ChainReward) SimplePrint() { + fmt.Println("--------------------------------------") + fmt.Println("height", c.Height) + fmt.Println("Foundation", c.Foundation.String()) + for i, v := range c.CommitteeBase { + fmt.Println("CommitteeBase", i) + fmt.Println(v.String()) + } + fmt.Println("--------------------------------------") +} type BalanceInfo struct { Address common.Address `json:"address"`