mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
filter zero address in function GetCandidates
This commit is contained in:
parent
4a59bdf15a
commit
e2359d9b8c
3 changed files with 11 additions and 16 deletions
|
|
@ -93,16 +93,17 @@ func GetCandidates(statedb *StateDB) []common.Address {
|
|||
slot := slotValidatorMapping["candidates"]
|
||||
slotHash := common.BigToHash(new(big.Int).SetUint64(slot))
|
||||
arrLength := statedb.GetState(common.HexToAddress(common.MasternodeVotingSMC), slotHash)
|
||||
keys := []common.Hash{}
|
||||
for i := uint64(0); i < arrLength.Big().Uint64(); i++ {
|
||||
count := arrLength.Big().Uint64()
|
||||
rets := make([]common.Address, 0, count)
|
||||
|
||||
for i := uint64(0); i < count; i++ {
|
||||
key := GetLocDynamicArrAtElement(slotHash, i, 1)
|
||||
keys = append(keys, key)
|
||||
}
|
||||
rets := []common.Address{}
|
||||
for _, key := range keys {
|
||||
ret := statedb.GetState(common.HexToAddress(common.MasternodeVotingSMC), key)
|
||||
rets = append(rets, common.HexToAddress(ret.Hex()))
|
||||
if !ret.IsZero() {
|
||||
rets = append(rets, common.HexToAddress(ret.Hex()))
|
||||
}
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -238,9 +238,7 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if address.String() != "xdc0000000000000000000000000000000000000000" {
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
// sort candidates by stake descending
|
||||
sort.Slice(candidates, func(i, j int) bool {
|
||||
|
|
|
|||
|
|
@ -756,9 +756,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
|||
candidatesAddresses := state.GetCandidates(statedb)
|
||||
for _, address := range candidatesAddresses {
|
||||
v := state.GetCandidateCap(statedb, address)
|
||||
if address.String() != "xdc0000000000000000000000000000000000000000" {
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
}
|
||||
if err != nil || len(candidates) == 0 {
|
||||
|
|
@ -882,9 +880,7 @@ func (s *PublicBlockChainAPI) GetCandidates(ctx context.Context, epoch rpc.Epoch
|
|||
candidatesAddresses := state.GetCandidates(statedb)
|
||||
for _, address := range candidatesAddresses {
|
||||
v := state.GetCandidateCap(statedb, address)
|
||||
if address.String() != "xdc0000000000000000000000000000000000000000" {
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
candidates = append(candidates, utils.Masternode{Address: address, Stake: v})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue