mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
return more slashed nodes in GetCandidates
This commit is contained in:
parent
6e7d7f5002
commit
8ed9a754b2
1 changed files with 11 additions and 12 deletions
|
|
@ -965,20 +965,19 @@ func (s *PublicBlockChainAPI) GetCandidates(ctx context.Context, epoch rpc.Epoch
|
|||
}
|
||||
penaltyList = common.ExtractAddressFromBytes(penalties)
|
||||
|
||||
var topCandidates []utils.Masternode
|
||||
if len(candidates) > maxMasternodes {
|
||||
topCandidates = candidates[:maxMasternodes]
|
||||
} else {
|
||||
topCandidates = candidates
|
||||
}
|
||||
// check penalties from checkpoint headers and modify status of a node to SLASHED if it's in top 150 candidates
|
||||
// if it's SLASHED but it's out of top 150, the status should be still PROPOSED
|
||||
for _, pen := range penaltyList {
|
||||
for _, candidate := range topCandidates {
|
||||
if candidate.Address == pen && candidatesStatusMap[pen.String()] != nil {
|
||||
// check penalties from checkpoint headers and modify status of a node to SLASHED if it's in top maxMasternodes candidates.
|
||||
// if it's SLASHED but it's out of top maxMasternodes, the status should be still PROPOSED.
|
||||
total := len(masternodes)
|
||||
for _, candidate := range candidates {
|
||||
for _, pen := range penaltyList {
|
||||
if candidate.Address == pen {
|
||||
candidatesStatusMap[pen.String()][fieldStatus] = statusSlashed
|
||||
total++
|
||||
if total >= maxMasternodes {
|
||||
result[fieldCandidates] = candidatesStatusMap
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
penalties = append(penalties, block.Penalties()...)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue