diff --git a/venus-shared/types/tipset.go b/venus-shared/types/tipset.go index 460ac7c3b7..ec2ac76237 100644 --- a/venus-shared/types/tipset.go +++ b/venus-shared/types/tipset.go @@ -106,12 +106,7 @@ func (ts *TipSet) Defined() bool { } func (ts *TipSet) Contains(oc cid.Cid) bool { - for _, c := range ts.cids { - if c == oc { - return true - } - } - return false + return slices.Contains(ts.cids, oc) } func (ts *TipSet) Equals(ots *TipSet) bool { diff --git a/venus-shared/types/tipset_key.go b/venus-shared/types/tipset_key.go index 9168999306..5c65492e79 100644 --- a/venus-shared/types/tipset_key.go +++ b/venus-shared/types/tipset_key.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "slices" "strings" "github.com/filecoin-project/go-state-types/abi" @@ -128,12 +129,7 @@ func (tsk TipSetKey) ContainsAll(other TipSetKey) bool { // Has checks whether the set contains `id`. func (tsk TipSetKey) Has(id cid.Cid) bool { // Find index of the first CID not less than id. - for _, cid := range tsk.Cids() { - if cid == id { - return true - } - } - return false + return slices.Contains(tsk.Cids(), id) } // Equals checks whether the set contains exactly the same CIDs as another.