Skip to content

Commit

Permalink
add some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
iceming123 committed Jan 10, 2023
1 parent dc1d1ad commit 3ca36e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions consensus/minerva/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -1183,6 +1185,7 @@ func accumulateRewardsFast3(stateDB *state.StateDB, fast, origin *big.Int) (*typ
}
}
rewardsInfos := &types.ChainReward{
Height: fast.Uint64(),
CommitteeBase: infos,
Foundation: developer,
}
Expand Down
33 changes: 23 additions & 10 deletions core/types/impawnUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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"`
Expand Down

0 comments on commit 3ca36e9

Please sign in to comment.