From fd6dba5d8367ce757115295c102a05ec4ec2f919 Mon Sep 17 00:00:00 2001 From: jishudashen Date: Sat, 19 Jul 2025 15:42:46 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code Signed-off-by: jishudashen --- pkg/health/ethereum/execution_rpc.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/health/ethereum/execution_rpc.go b/pkg/health/ethereum/execution_rpc.go index 10d863a..a36a6ba 100644 --- a/pkg/health/ethereum/execution_rpc.go +++ b/pkg/health/ethereum/execution_rpc.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/kurtosis-tech/stacktrace" log "github.com/sirupsen/logrus" + "slices" "time" ) @@ -116,13 +117,7 @@ func (c *ExecClientRPC) GetLatestBlockBy(ctx context.Context, blockType string) "unknown block", //reth } - noFinalBlockFound := false - for _, msg := range notFinalizingErrors { - if err.Error() == msg { - noFinalBlockFound = true - break - } - } + noFinalBlockFound := slices.Contains(notFinalizingErrors, err.Error()) if noFinalBlockFound { choice = &ClientForkChoice{