Skip to content

Commit

Permalink
refactor: using slices.Contains to simplify the code
Browse files Browse the repository at this point in the history
Signed-off-by: zhoufanjin <[email protected]>
  • Loading branch information
zhoufanjin committed Jan 16, 2025
1 parent 69d7895 commit 8e3b545
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cmd/stellar-rpc/internal/methods/get_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"math"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8e3b545

Please sign in to comment.