mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +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
|
} 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 {
|
if number.Uint64() > comebackHeight {
|
||||||
// penParolees record those who stayed enough epoch of LimitPenaltyEpoch
|
// penParolees record those who stayed enough epoch of LimitPenaltyEpoch
|
||||||
penParoleeMap := map[common.Address]int{}
|
penParoleeMap := map[common.Address]int{}
|
||||||
// lastPenalty record the last epoch penalties
|
// lastPenalty record the last epoch penalties
|
||||||
lastPenalty := []common.Address{}
|
lastPenalty := []common.Address{}
|
||||||
for i := 0; i <= currentConfig.LimitPenaltyEpoch; i++ {
|
for i := 0; i < limitPenaltyEpoch; i++ {
|
||||||
pens := adaptor.EngineV2.GetPreviousPenaltyByHash(chain, currentHash, i)
|
pens := adaptor.EngineV2.GetPreviousPenaltyByHash(chain, currentHash, i)
|
||||||
for _, p := range pens {
|
for _, p := range pens {
|
||||||
penParoleeMap[p]++
|
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
|
// check addr in lastPenalty, and if they does not meet condition, add them to penalty
|
||||||
for _, p := range lastPenalty {
|
for _, p := range lastPenalty {
|
||||||
if penParoleeMap[p] == currentConfig.LimitPenaltyEpoch+1 {
|
if penParoleeMap[p] == limitPenaltyEpoch {
|
||||||
// check if this node signs enough
|
// check if this node signs enough
|
||||||
if txSignerMap[p] >= currentConfig.MinimumSigningTx {
|
if txSignerMap[p] >= currentConfig.MinimumSigningTx {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ var (
|
||||||
MasternodeReward: 500, // double as Reward
|
MasternodeReward: 500, // double as Reward
|
||||||
ProtectorReward: 400,
|
ProtectorReward: 400,
|
||||||
ObserverReward: 300.125,
|
ObserverReward: 300.125,
|
||||||
LimitPenaltyEpoch: 1,
|
LimitPenaltyEpoch: 2,
|
||||||
MinimumSigningTx: 2,
|
MinimumSigningTx: 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue