Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions venus-shared/types/tipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions venus-shared/types/tipset_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"slices"
"strings"

"github.com/filecoin-project/go-state-types/abi"
Expand Down Expand Up @@ -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.
Expand Down