@@ -107,7 +107,7 @@ func (sc *stakingCommittee) DelegatesByHeight(height uint64) (state.CandidateLis
107
107
// convert to epoch start height
108
108
epochHeight := sc .getEpochHeight (sc .getEpochNum (height ))
109
109
if sc .hu .IsPre (config .Cook , epochHeight ) {
110
- return cand , nil
110
+ return sc . filterDelegates ( cand ) , nil
111
111
}
112
112
// native staking starts from Cook
113
113
if sc .nativeStaking == nil {
@@ -116,7 +116,7 @@ func (sc *stakingCommittee) DelegatesByHeight(height uint64) (state.CandidateLis
116
116
nativeVotes , ts , err := sc .nativeStaking .Votes ()
117
117
if err == ErrNoData {
118
118
// no native staking data
119
- return cand , nil
119
+ return sc . filterDelegates ( cand ) , nil
120
120
}
121
121
if err != nil {
122
122
return nil , errors .Wrap (err , "failed to get native chain candidates" )
@@ -134,6 +134,17 @@ func (sc *stakingCommittee) SetNativeStakingContract(contract string) {
134
134
sc .nativeStaking .SetContract (contract )
135
135
}
136
136
137
+ // return candidates whose votes are above threshold
138
+ func (sc * stakingCommittee ) filterDelegates (candidates state.CandidateList ) state.CandidateList {
139
+ var cand state.CandidateList
140
+ for _ , c := range candidates {
141
+ if c .Votes .Cmp (sc .scoreThreshold ) >= 0 {
142
+ cand = append (cand , c )
143
+ }
144
+ }
145
+ return cand
146
+ }
147
+
137
148
func (sc * stakingCommittee ) mergeDelegates (list state.CandidateList , votes * VoteTally , ts time.Time ) state.CandidateList {
138
149
// as of now, native staking does not have register contract, only voting/staking contract
139
150
// it is assumed that all votes done on native staking target for delegates registered on Ethereum
0 commit comments