Skip to content

Commit c336856

Browse files
committed
refactor: using slices.Contains to simplify the code
Signed-off-by: zhoufanjin <[email protected]>
1 parent 49af443 commit c336856

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

protocol/get_events.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"strings"
8+
"strings"
89

910
"github.com/stellar/go/strkey"
1011
"github.com/stellar/go/xdr"
@@ -212,12 +213,7 @@ func (e *EventFilter) matchesContractIDs(event xdr.ContractEvent) bool {
212213
return false
213214
}
214215
needle := strkey.MustEncode(strkey.VersionByteContract, (*event.ContractId)[:])
215-
for _, id := range e.ContractIDs {
216-
if id == needle {
217-
return true
218-
}
219-
}
220-
return false
216+
return slices.Contains(e.ContractIDs, needle)
221217
}
222218

223219
func (e *EventFilter) matchesTopics(event xdr.ContractEvent) bool {

0 commit comments

Comments
 (0)