From 22efd3099de3b0d793538b46bb355fc6b0ddc63b Mon Sep 17 00:00:00 2001 From: yinwenyu6 Date: Sun, 17 Aug 2025 14:36:30 +0800 Subject: [PATCH] refactor: use slices.Contains to simplify code Signed-off-by: yinwenyu6 --- yoda/handler.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/yoda/handler.go b/yoda/handler.go index 8cfe67d0a..8f83ba11b 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,13 +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 - } - } + hasMe := slices.Contains(req.RequestedValidators, c.validator.String()) if !hasMe { l.Debug(":next_track_button: Skip request not related to this validator") return