Skip to content

Commit

Permalink
add hosts and v2 contracts to search
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Jan 17, 2025
1 parent 3f0a126 commit a736c8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions explorer/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,5 +445,19 @@ func (e *Explorer) Search(id types.Hash256) (SearchType, error) {
return SearchTypeContract, nil
}

v2Contracts, err := e.V2Contracts([]types.FileContractID{types.FileContractID(id)})
if err != nil {
return SearchTypeInvalid, err
} else if len(v2Contracts) > 0 {
return SearchTypeV2Contract, nil
}

hosts, err := e.Hosts([]types.PublicKey{types.PublicKey(id)})
if err != nil {
return SearchTypeInvalid, err
} else if len(hosts) > 0 {
return SearchTypeHost, nil
}

return SearchTypeInvalid, errors.New("no such element")
}
4 changes: 4 additions & 0 deletions explorer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const (
SearchTypeSiafundElement SearchType = "siafundElement"
// SearchTypeContract means we found a contract with the given ID.
SearchTypeContract SearchType = "contract"
// SearchTypeV2Contract means we found a V2 contract with the given ID.
SearchTypeV2Contract SearchType = "v2contract"
// SearchTypeHost means we found a host with the given pubkey.
SearchTypeHost SearchType = "host"
)

// A ResolutionType represents the type of a v2 file contract resolution.
Expand Down

0 comments on commit a736c8e

Please sign in to comment.