mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
style: change limitPenaltyEpoch in config to real meaning, avoid +1 (#1538)
This commit is contained in:
parent
5a6d25ec08
commit
968fb0124b
2 changed files with 9 additions and 4 deletions
|
|
@ -182,13 +182,18 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
}
|
||||
}
|
||||
} else { // after penalty upgrade
|
||||
comebackHeight := (uint64(currentConfig.LimitPenaltyEpoch)+1)*chain.Config().XDPoS.Epoch + chain.Config().XDPoS.V2.SwitchBlock.Uint64()
|
||||
limitPenaltyEpoch := 1
|
||||
if currentConfig.LimitPenaltyEpoch > 0 {
|
||||
// if non-zero parameter, use it
|
||||
limitPenaltyEpoch = currentConfig.LimitPenaltyEpoch
|
||||
}
|
||||
comebackHeight := uint64(limitPenaltyEpoch)*chain.Config().XDPoS.Epoch + chain.Config().XDPoS.V2.SwitchBlock.Uint64()
|
||||
if number.Uint64() > comebackHeight {
|
||||
// penParolees record those who stayed enough epoch of LimitPenaltyEpoch
|
||||
penParoleeMap := map[common.Address]int{}
|
||||
// lastPenalty record the last epoch penalties
|
||||
lastPenalty := []common.Address{}
|
||||
for i := 0; i <= currentConfig.LimitPenaltyEpoch; i++ {
|
||||
for i := 0; i < limitPenaltyEpoch; i++ {
|
||||
pens := adaptor.EngineV2.GetPreviousPenaltyByHash(chain, currentHash, i)
|
||||
for _, p := range pens {
|
||||
penParoleeMap[p]++
|
||||
|
|
@ -230,7 +235,7 @@ func AttachConsensusV2Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
}
|
||||
// check addr in lastPenalty, and if they does not meet condition, add them to penalty
|
||||
for _, p := range lastPenalty {
|
||||
if penParoleeMap[p] == currentConfig.LimitPenaltyEpoch+1 {
|
||||
if penParoleeMap[p] == limitPenaltyEpoch {
|
||||
// check if this node signs enough
|
||||
if txSignerMap[p] >= currentConfig.MinimumSigningTx {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ var (
|
|||
MasternodeReward: 500, // double as Reward
|
||||
ProtectorReward: 400,
|
||||
ObserverReward: 300.125,
|
||||
LimitPenaltyEpoch: 1,
|
||||
LimitPenaltyEpoch: 2,
|
||||
MinimumSigningTx: 2,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue