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()
|
||||
prevHeader := chain.GetHeaderByNumber(prevEpoc)
|
||||
penSigners := c.GetMasternodes(chain, prevHeader)
|
||||
goodSigners := make(map[common.Address]*big.Int)
|
||||
if len(penSigners) > 0 {
|
||||
// Loop for each block to check missing sign.
|
||||
for i := prevEpoc; i < blockNumberEpoc; i++ {
|
||||
|
|
@ -282,24 +283,32 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
bhash := bheader.Hash()
|
||||
block := chain.GetBlock(bhash, i)
|
||||
if len(penSigners) > 0 {
|
||||
signedMasternodes, err := contracts.GetSignersFromContract(canonicalState, block)
|
||||
signer, err := c.RecoverSigner(block.Header())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(signedMasternodes) > 0 {
|
||||
// Check signer signed?
|
||||
for _, signed := range signedMasternodes {
|
||||
for _, addr := range penSigners {
|
||||
if signer == addr {
|
||||
// Remove it from dupSigners.
|
||||
goodSigners[signer] = goodSigners[signer].Add(goodSigners[signer], big.NewInt(1))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(goodSigners) > 0 {
|
||||
for signer, totalSign := range goodSigners {
|
||||
if totalSign.Cmp(big.NewInt(4)) >= 0 {
|
||||
for j, addr := range penSigners {
|
||||
if signed == addr {
|
||||
if signer == addr {
|
||||
// Remove it from dupSigners.
|
||||
penSigners = append(penSigners[:j], penSigners[j+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue