Extend claim search for use in livestreaming
This commit is contained in:
parent
5d62502bde
commit
a0391bec79
2 changed files with 36 additions and 18 deletions
|
@ -536,24 +536,35 @@ func (d *Client) Resolve(urls string) (*ResolveResponse, error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Client) ClaimSearch(claimName, claimID, txid *string, nout *uint, page uint64, pageSize uint64) (*ClaimSearchResponse, error) {
|
type ClaimSearchArgs struct {
|
||||||
response := new(ClaimSearchResponse)
|
|
||||||
args := struct {
|
|
||||||
ClaimID *string `json:"claim_id,omitempty"`
|
ClaimID *string `json:"claim_id,omitempty"`
|
||||||
TXID *string `json:"txid,omitempty"`
|
TXID *string `json:"txid,omitempty"`
|
||||||
Nout *uint `json:"nout,omitempty"`
|
Nout *uint `json:"nout,omitempty"`
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
IncludeProtobuf bool `json:"include_protobuf"`
|
ClaimType []string `json:"claim_type,omitempty"`
|
||||||
|
OrderBy []string `json:"order_by,omitempty"`
|
||||||
|
LimitClaimsPerChannel *int `json:"limit_claims_per_channel,omitempty"`
|
||||||
|
HasNoSource *bool `json:"has_no_source,omitempty"`
|
||||||
|
ReleaseTime string `json:"release_time,omitempty"`
|
||||||
|
ChannelIDs []string `json:"channel_ids,omitempty"`
|
||||||
|
NoTotals *bool `json:"no_totals,omitempty"`
|
||||||
|
IncludeProtobuf *bool `json:"include_protobuf,omitempty"`
|
||||||
|
AnyTags []string `json:"any_tags,omitempty"`
|
||||||
|
|
||||||
Page uint64 `json:"page"`
|
Page uint64 `json:"page"`
|
||||||
PageSize uint64 `json:"page_size"`
|
PageSize uint64 `json:"page_size"`
|
||||||
}{
|
}
|
||||||
ClaimID: claimID,
|
|
||||||
TXID: txid,
|
func (d *Client) ClaimSearch(args ClaimSearchArgs) (*ClaimSearchResponse, error) {
|
||||||
Nout: nout,
|
response := new(ClaimSearchResponse)
|
||||||
Name: claimName,
|
if args.NoTotals == nil {
|
||||||
IncludeProtobuf: true,
|
nototals := true
|
||||||
Page: page,
|
args.NoTotals = ¬otals
|
||||||
PageSize: pageSize,
|
}
|
||||||
|
|
||||||
|
if args.IncludeProtobuf == nil {
|
||||||
|
include := true
|
||||||
|
args.IncludeProtobuf = &include
|
||||||
}
|
}
|
||||||
structs.DefaultTagName = "json"
|
structs.DefaultTagName = "json"
|
||||||
return response, d.call(response, "claim_search", structs.Map(args))
|
return response, d.call(response, "claim_search", structs.Map(args))
|
||||||
|
|
|
@ -463,7 +463,14 @@ func TestClient_TxoSpendTest(t *testing.T) {
|
||||||
|
|
||||||
func TestClient_ClaimSearch(t *testing.T) {
|
func TestClient_ClaimSearch(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.ClaimSearch(nil, util.PtrToString(channelID), nil, nil, 1, 20)
|
got, err := d.ClaimSearch(ClaimSearchArgs{
|
||||||
|
ChannelIDs: []string{channelID},
|
||||||
|
ReleaseTime: ">1633350820",
|
||||||
|
HasNoSource: util.PtrToBool(true),
|
||||||
|
OrderBy: []string{"^release_time"},
|
||||||
|
Page: 1,
|
||||||
|
PageSize: 20,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue