From e49a2cf31ff2f8976f942bd0a6ab8451e2088361 Mon Sep 17 00:00:00 2001 From: keeghcet Date: Mon, 8 Sep 2025 17:00:02 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code Signed-off-by: keeghcet --- yoda/handler.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/yoda/handler.go b/yoda/handler.go index 8cfe67d0a..9834fc76b 100644 --- a/yoda/handler.go +++ b/yoda/handler.go @@ -2,6 +2,7 @@ package yoda import ( "encoding/hex" + "slices" "strconv" abci "github.com/cometbft/cometbft/abci/types" @@ -62,14 +63,7 @@ func handleRequest(c *Context, l *Logger, id types.RequestID) { return } - hasMe := false - for _, val := range req.RequestedValidators { - if val == c.validator.String() { - hasMe = true - break - } - } - if !hasMe { + if !slices.Contains(req.RequestedValidators, c.validator.String()) { l.Debug(":next_track_button: Skip request not related to this validator") return }