mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-23 15:14:32 +00:00
refactor RemoveItemFromArray
This commit is contained in:
parent
4211d56ad0
commit
592259eb73
1 changed files with 6 additions and 13 deletions
|
|
@ -33,7 +33,6 @@ const (
|
|||
BlockSigners = "0x0000000000000000000000000000000000000089"
|
||||
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
|
||||
RandomizeSMC = "0x0000000000000000000000000000000000000090"
|
||||
FoudationAddr = "0x0000000000000000000000000000000000000068"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -247,24 +246,18 @@ func (a UnprefixedAddress) MarshalText() ([]byte, error) {
|
|||
|
||||
// Extract validators from byte array.
|
||||
func RemoveItemFromArray(array []Address, items []Address) []Address {
|
||||
if items == nil {
|
||||
if len(items) == 0 {
|
||||
return array
|
||||
}
|
||||
i := 0;
|
||||
for i < len(array) {
|
||||
value := array[i]
|
||||
remove := false
|
||||
for _, item := range items {
|
||||
if value == item {
|
||||
|
||||
for _, item := range items {
|
||||
for i := len(array) - 1; i >= 0; i-- {
|
||||
if array[i] == item {
|
||||
array = append(array[:i], array[i+1:]...)
|
||||
remove = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !remove {
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue