eth: use slices.Contains

Signed-off-by: deepdring <deepdrink@icloud.com>
This commit is contained in:
deepdring 2025-08-14 22:33:52 +08:00
parent 2dbb580f51
commit 28ea145121
2 changed files with 4 additions and 12 deletions

View file

@ -20,6 +20,7 @@ package catalyst
import ( import (
"errors" "errors"
"fmt" "fmt"
"slices"
"strconv" "strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -906,12 +907,7 @@ func (api *ConsensusAPI) config() *params.ChainConfig {
// is one of the forks provided. // is one of the forks provided.
func (api *ConsensusAPI) checkFork(timestamp uint64, forks ...forks.Fork) bool { func (api *ConsensusAPI) checkFork(timestamp uint64, forks ...forks.Fork) bool {
latest := api.config().LatestFork(timestamp) latest := api.config().LatestFork(timestamp)
for _, fork := range forks { return slices.Contains(forks, latest)
if latest == fork {
return true
}
}
return false
} }
// ExchangeCapabilities returns the current methods provided by this node. // ExchangeCapabilities returns the current methods provided by this node.

View file

@ -19,6 +19,7 @@ package native
import ( import (
"encoding/json" "encoding/json"
"math/big" "math/big"
"slices"
"strconv" "strconv"
"sync/atomic" "sync/atomic"
@ -75,12 +76,7 @@ func newFourByteTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p
// isPrecompiled returns whether the addr is a precompile. Logic borrowed from newJsTracer in eth/tracers/js/tracer.go // isPrecompiled returns whether the addr is a precompile. Logic borrowed from newJsTracer in eth/tracers/js/tracer.go
func (t *fourByteTracer) isPrecompiled(addr common.Address) bool { func (t *fourByteTracer) isPrecompiled(addr common.Address) bool {
for _, p := range t.activePrecompiles { return slices.Contains(t.activePrecompiles, addr)
if p == addr {
return true
}
}
return false
} }
// store saves the given identifier and datasize. // store saves the given identifier and datasize.