mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Fixed check penalty signers working when it return chain.
This commit is contained in:
parent
cd2faaace9
commit
e639f0f46e
1 changed files with 19 additions and 10 deletions
|
|
@ -274,6 +274,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
prevHeader := chain.GetHeaderByNumber(prevEpoc)
|
prevHeader := chain.GetHeaderByNumber(prevEpoc)
|
||||||
penSigners := c.GetMasternodes(chain, prevHeader)
|
penSigners := c.GetMasternodes(chain, prevHeader)
|
||||||
|
goodSigners := make(map[common.Address]*big.Int)
|
||||||
if len(penSigners) > 0 {
|
if len(penSigners) > 0 {
|
||||||
// Loop for each block to check missing sign.
|
// Loop for each block to check missing sign.
|
||||||
for i := prevEpoc; i < blockNumberEpoc; i++ {
|
for i := prevEpoc; i < blockNumberEpoc; i++ {
|
||||||
|
|
@ -282,25 +283,33 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
bhash := bheader.Hash()
|
bhash := bheader.Hash()
|
||||||
block := chain.GetBlock(bhash, i)
|
block := chain.GetBlock(bhash, i)
|
||||||
if len(penSigners) > 0 {
|
if len(penSigners) > 0 {
|
||||||
signedMasternodes, err := contracts.GetSignersFromContract(canonicalState, block)
|
signer, err := c.RecoverSigner(block.Header())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(signedMasternodes) > 0 {
|
for _, addr := range penSigners {
|
||||||
// Check signer signed?
|
if signer == addr {
|
||||||
for _, signed := range signedMasternodes {
|
// Remove it from dupSigners.
|
||||||
for j, addr := range penSigners {
|
goodSigners[signer] = goodSigners[signer].Add(goodSigners[signer], big.NewInt(1))
|
||||||
if signed == addr {
|
|
||||||
// Remove it from dupSigners.
|
|
||||||
penSigners = append(penSigners[:j], penSigners[j+1:]...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(goodSigners) > 0 {
|
||||||
|
for signer, totalSign := range goodSigners {
|
||||||
|
if totalSign.Cmp(big.NewInt(4)) >= 0 {
|
||||||
|
for j, addr := range penSigners {
|
||||||
|
if signer == addr {
|
||||||
|
// Remove it from dupSigners.
|
||||||
|
penSigners = append(penSigners[:j], penSigners[j+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Debug("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start)))
|
log.Debug("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue