From 28ea145121bcfbefcafd3b0a6796223d2ba9a7b7 Mon Sep 17 00:00:00 2001 From: deepdring Date: Thu, 14 Aug 2025 22:33:52 +0800 Subject: [PATCH] eth: use slices.Contains Signed-off-by: deepdring --- eth/catalyst/api.go | 8 ++------ eth/tracers/native/4byte.go | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 038328d9ba..403ed307b0 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -20,6 +20,7 @@ package catalyst import ( "errors" "fmt" + "slices" "strconv" "sync" "sync/atomic" @@ -906,12 +907,7 @@ func (api *ConsensusAPI) config() *params.ChainConfig { // is one of the forks provided. func (api *ConsensusAPI) checkFork(timestamp uint64, forks ...forks.Fork) bool { latest := api.config().LatestFork(timestamp) - for _, fork := range forks { - if latest == fork { - return true - } - } - return false + return slices.Contains(forks, latest) } // ExchangeCapabilities returns the current methods provided by this node. diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go index cec45a1e7a..165cd5c954 100644 --- a/eth/tracers/native/4byte.go +++ b/eth/tracers/native/4byte.go @@ -19,6 +19,7 @@ package native import ( "encoding/json" "math/big" + "slices" "strconv" "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 func (t *fourByteTracer) isPrecompiled(addr common.Address) bool { - for _, p := range t.activePrecompiles { - if p == addr { - return true - } - } - return false + return slices.Contains(t.activePrecompiles, addr) } // store saves the given identifier and datasize.