From 8e3b545526abe9a7626e8674f7c6bbe4a92eb26d Mon Sep 17 00:00:00 2001 From: zhoufanjin Date: Thu, 9 Jan 2025 14:54:38 +0800 Subject: [PATCH] refactor: using slices.Contains to simplify the code Signed-off-by: zhoufanjin --- cmd/stellar-rpc/internal/methods/get_events.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/stellar-rpc/internal/methods/get_events.go b/cmd/stellar-rpc/internal/methods/get_events.go index 8408ef95..3978d492 100644 --- a/cmd/stellar-rpc/internal/methods/get_events.go +++ b/cmd/stellar-rpc/internal/methods/get_events.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "math" + "slices" "strings" "time" @@ -221,12 +222,7 @@ func (e *EventFilter) matchesContractIDs(event xdr.ContractEvent) bool { return false } needle := strkey.MustEncode(strkey.VersionByteContract, (*event.ContractId)[:]) - for _, id := range e.ContractIDs { - if id == needle { - return true - } - } - return false + return slices.Contains(e.ContractIDs, needle) } func (e *EventFilter) matchesTopics(event xdr.ContractEvent) bool {