mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 19:00:46 +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"
|
BlockSigners = "0x0000000000000000000000000000000000000089"
|
||||||
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
|
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
|
||||||
RandomizeSMC = "0x0000000000000000000000000000000000000090"
|
RandomizeSMC = "0x0000000000000000000000000000000000000090"
|
||||||
FoudationAddr = "0x0000000000000000000000000000000000000068"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -247,24 +246,18 @@ func (a UnprefixedAddress) MarshalText() ([]byte, error) {
|
||||||
|
|
||||||
// Extract validators from byte array.
|
// Extract validators from byte array.
|
||||||
func RemoveItemFromArray(array []Address, items []Address) []Address {
|
func RemoveItemFromArray(array []Address, items []Address) []Address {
|
||||||
if items == nil {
|
if len(items) == 0 {
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
i := 0;
|
|
||||||
for i < len(array) {
|
for _, item := range items {
|
||||||
value := array[i]
|
for i := len(array) - 1; i >= 0; i-- {
|
||||||
remove := false
|
if array[i] == item {
|
||||||
for _, item := range items {
|
|
||||||
if value == item {
|
|
||||||
array = append(array[:i], array[i+1:]...)
|
array = append(array[:i], array[i+1:]...)
|
||||||
remove = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !remove {
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue