mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
sort candidates in function GetCandidateStatus
This commit is contained in:
parent
8ed9a754b2
commit
745e097040
1 changed files with 8 additions and 0 deletions
|
|
@ -754,6 +754,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
return result, err
|
||||
}
|
||||
candidatesAddresses := state.GetCandidates(statedb)
|
||||
candidates = make([]utils.Masternode, 0, len(candidatesAddresses))
|
||||
for _, address := range candidatesAddresses {
|
||||
v := state.GetCandidateCap(statedb, address)
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
|
|
@ -764,6 +765,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
result[fieldSuccess] = false
|
||||
return result, err
|
||||
}
|
||||
|
||||
var maxMasternodes int
|
||||
if s.b.ChainConfig().IsTIPIncreaseMasternodes(block.Number()) {
|
||||
maxMasternodes = common.MaxMasternodesV2
|
||||
|
|
@ -807,6 +809,12 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
}
|
||||
}
|
||||
|
||||
if len(candidates) > maxMasternodes {
|
||||
sort.Slice(candidates, func(i, j int) bool {
|
||||
return candidates[i].Stake.Cmp(candidates[j].Stake) > 0
|
||||
})
|
||||
}
|
||||
|
||||
// Third, Get penalties list
|
||||
penalties = append(penalties, header.Penalties...)
|
||||
// check last 5 epochs to find penalize masternodes
|
||||
|
|
|
|||
Loading…
Reference in a new issue