update claim structure

fix bug in stream update
This commit is contained in:
Niko Storni 2019-05-08 21:14:14 +02:00
parent 13ef7571b2
commit 7b0a5ae028
No known key found for this signature in database
GPG key ID: F37FE63398800368
4 changed files with 56 additions and 63 deletions

View file

@ -284,7 +284,7 @@ func (d *Client) StreamCreate(name, filePath string, bid float64, options Stream
Bid string `json:"bid"` Bid string `json:"bid"`
FilePath string `json:"file_path,omitempty"` FilePath string `json:"file_path,omitempty"`
FileSize *string `json:"file_size,omitempty"` FileSize *string `json:"file_size,omitempty"`
IncludeProtobuf bool `json:"include_protobuf"` IncludeProtoBuf bool `json:"include_protobuf"`
*StreamCreateOptions `json:",flatten"` *StreamCreateOptions `json:",flatten"`
}{ }{
Name: name, Name: name,
@ -316,19 +316,17 @@ type StreamUpdateOptions struct {
ClearTags *bool `json:"clear_tags,omitempty"` ClearTags *bool `json:"clear_tags,omitempty"`
ClearLanguages *bool `json:"clear_languages,omitempty"` ClearLanguages *bool `json:"clear_languages,omitempty"`
ClearLocations *bool `json:"clear_locations,omitempty"` ClearLocations *bool `json:"clear_locations,omitempty"`
Name *string `json:"name"` Name *string `json:"name,omitempty"`
FilePath *string `json:"file_path,omitempty"` FilePath *string `json:"file_path,omitempty"`
FileSize *string `json:"file_size,omitempty"` FileSize *uint64 `json:"file_size,omitempty"`
Bid *string `json:"bid"` Bid *string `json:"bid,omitempty"`
*StreamCreateOptions `json:",flatten"` *StreamCreateOptions `json:",flatten"`
} }
func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*PublishResponse, error) { func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*TransactionSummary, error) {
response := new(PublishResponse) response := new(TransactionSummary)
args := struct { args := struct {
ClaimID string `json:"claim_id"` ClaimID string `json:"claim_id"`
FilePath string `json:"file_path,omitempty"`
Bid string `json:"bid"`
IncludeProtoBuf bool `json:"include_protobuf"` IncludeProtoBuf bool `json:"include_protobuf"`
*StreamUpdateOptions `json:",flatten"` *StreamUpdateOptions `json:",flatten"`
}{ }{
@ -337,7 +335,7 @@ func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*Pub
StreamUpdateOptions: &options, StreamUpdateOptions: &options,
} }
structs.DefaultTagName = "json" structs.DefaultTagName = "json"
return response, d.call(response, "stream_create", structs.Map(args)) return response, d.call(response, "stream_update", structs.Map(args))
} }
func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) { func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blocking bool) (*ClaimAbandonResponse, error) {
@ -361,15 +359,16 @@ func (d *Client) AddressList(account *string) (*AddressListResponse, error) {
}) })
} }
func (d *Client) ClaimList(account *string, page uint64, pageSize uint64) (*ClaimListMineResponse, error) { func (d *Client) ClaimList(account *string, page uint64, pageSize uint64) (*ClaimListResponse, error) {
if page == 0 { if page == 0 {
return nil, errors.Err("pages start from 1") return nil, errors.Err("pages start from 1")
} }
response := new(ClaimListMineResponse) response := new(ClaimListResponse)
err := d.call(response, "claim_list", map[string]interface{}{ err := d.call(response, "claim_list", map[string]interface{}{
"account_id": account, "account_id": account,
"page": page, "page": page,
"page_size": pageSize, "page_size": pageSize,
"include_protobuf": true,
}) })
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -112,10 +112,6 @@ func TestClient_StreamCreate(t *testing.T) {
LicenseURL: nil, LicenseURL: nil,
ReleaseTime: nil, ReleaseTime: nil,
Duration: nil, Duration: nil,
ImageWidth: nil,
ImageHeight: nil,
VideoWidth: nil,
VideoHeight: nil,
Preview: nil, Preview: nil,
AllowDuplicateName: nil, AllowDuplicateName: nil,
ChannelName: nil, ChannelName: nil,
@ -143,8 +139,8 @@ func TestClient_ChannelCreate(t *testing.T) {
}}, }},
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"), ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
}, },
Email: util.PtrToString("niko@lbry.com"), ContactEmail: util.PtrToString("niko@lbry.com"),
WebsiteURL: util.PtrToString("https://lbry.com"), HomepageURL: util.PtrToString("https://lbry.com"),
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"), CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
}) })
if err != nil { if err != nil {
@ -169,8 +165,8 @@ func TestClient_ChannelAbandon(t *testing.T) {
}}, }},
ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"), ThumbnailURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
}, },
Email: util.PtrToString("niko@lbry.com"), ContactEmail: util.PtrToString("niko@lbry.com"),
WebsiteURL: util.PtrToString("https://lbry.com"), HomepageURL: util.PtrToString("https://lbry.com"),
CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"), CoverURL: util.PtrToString("https://scrn.storni.info/2019-04-12_15-43-25-001592625.png"),
}) })
if err != nil { if err != nil {

View file

@ -256,16 +256,6 @@ type Address string
type AddressUnusedResponse Address type AddressUnusedResponse Address
type AddressListResponse []Address type AddressListResponse []Address
type PublishResponse struct {
ClaimAddress string `json:"claim_address"`
ClaimID string `json:"claim_id"`
Output Transaction `json:"output"`
Success bool `json:"success"`
Tx TransactionSummary `json:"tx"`
}
type ChannelNewResponse PublishResponse
type ChannelListResponse struct { type ChannelListResponse struct {
Items []Transaction `json:"items"` Items []Transaction `json:"items"`
Page uint64 `json:"page"` Page uint64 `json:"page"`
@ -286,25 +276,38 @@ type Support struct {
type Claim struct { type Claim struct {
Address string `json:"address"` Address string `json:"address"`
Amount string `json:"amount"` Amount string `json:"amount"`
ChannelName *string `json:"channel_name,omitempty"`
ClaimID string `json:"claim_id"` ClaimID string `json:"claim_id"`
ClaimSequence int64 `json:"claim_sequence"` ClaimOp string `json:"claim_op,omitempty"`
DecodedClaim bool `json:"decoded_claim"` Confirmations int `json:"confirmations"`
Depth int64 `json:"depth"`
EffectiveAmount string `json:"effective_amount"`
HasSignature *bool `json:"has_signature,omitempty"`
Height int `json:"height"` Height int `json:"height"`
Hex string `json:"hex"` IsChange bool `json:"is_change,omitempty"`
IsChannelSignatureValid bool `json:"is_channel_signature_valid,omitempty"`
IsMine bool `json:"is_mine,omitempty"`
Name string `json:"name"` Name string `json:"name"`
NormalizedName string `json:"normalized_name"`
Nout uint64 `json:"nout"` Nout uint64 `json:"nout"`
PermanentUrl string `json:"permanent_url"` PermanentURL string `json:"permanent_url"`
SignatureIsValid *bool `json:"signature_is_valid,omitempty"` SigningChannel struct {
Supports []Support `json:"supports"` ClaimID string `json:"claim_id"`
Name string `json:"name"`
Value struct {
PublicKey string `json:"public_key"`
Title string `json:"title"`
} `json:"value"`
} `json:"signing_channel,omitempty"`
Timestamp int `json:"timestamp"`
Txid string `json:"txid"` Txid string `json:"txid"`
Type string `json:"type"` Type string `json:"type,omitempty"`
ValidAtHeight int `json:"valid_at_height"` ValueType string `json:"value_type,omitempty"`
Value lbryschema.Claim `json:"protobuf"` Value lbryschema.Claim `json:"protobuf,omitempty"`
AbsoluteChannelPosition int `json:"absolute_channel_position,omitempty"`
ChannelName string `json:"channel_name,omitempty"`
ClaimSequence int64 `json:"claim_sequence,omitempty"`
DecodedClaim bool `json:"decoded_claim,omitempty"`
EffectiveAmount string `json:"effective_amount,omitempty"`
HasSignature *bool `json:"has_signature,omitempty"`
SignatureIsValid *bool `json:"signature_is_valid,omitempty"`
Supports []Support `json:"supports,omitempty"`
ValidAtHeight int `json:"valid_at_height,omitempty"`
} }
const reflectorURL = "http://blobs.lbry.io/" const reflectorURL = "http://blobs.lbry.io/"
@ -361,15 +364,13 @@ func (c *Claim) GetStreamSizeByMagic() (uint64, error) {
return streamSize, nil return streamSize, nil
} }
type ClaimListResponse []Claim type ClaimListResponse struct {
type ClaimListMineResponse struct {
Claims []Claim `json:"items"` Claims []Claim `json:"items"`
Page uint64 `json:"page"` Page uint64 `json:"page"`
PageSize uint64 `json:"page_size"` PageSize uint64 `json:"page_size"`
TotalPages uint64 `json:"total_pages"` TotalPages uint64 `json:"total_pages"`
} }
type ClaimSearchResponse ClaimListMineResponse type ClaimSearchResponse ClaimListResponse
type StatusResponse struct { type StatusResponse struct {
BlobManager struct { BlobManager struct {

5
go.sum
View file

@ -50,13 +50,10 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c h1:BhdcWGsuKif/XoSZnqVGNqJ1iEmH0czWR5upj+AuR8M= github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c h1:BhdcWGsuKif/XoSZnqVGNqJ1iEmH0czWR5upj+AuR8M=
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8= github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
github.com/lbryio/lbryschema.go v0.0.0-20190422030648-322c658307e0 h1:/YWLlbbDefRGLs/ozyuRpvpwpFISYehwR4AAVlPthA8= github.com/lbryio/lbryschema.go v0.0.0-20190428231007-c54836bca002 h1:urfYK5ElpUrAv90auPLldoVC60LwiGAcY0OE6HJB9KI=
github.com/lbryio/lbryschema.go v0.0.0-20190422030648-322c658307e0/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo=
github.com/lbryio/lbryschema.go v0.0.0-20190428231007-c54836bca002/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo= github.com/lbryio/lbryschema.go v0.0.0-20190428231007-c54836bca002/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo=
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI= github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI=
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4= github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4=
github.com/lbryio/types v0.0.0-20190420150432-3af925981a5f h1:N8ErMlrpP87wK+NfDhkV1A84Ect8xYWdO+ozAdi1z7k=
github.com/lbryio/types v0.0.0-20190420150432-3af925981a5f/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c h1:m3O7561xBQ00lfUVayW4c6SnpVbUDQtPUwGcGYSUYQA= github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c h1:m3O7561xBQ00lfUVayW4c6SnpVbUDQtPUwGcGYSUYQA=
github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE= github.com/lbryio/types v0.0.0-20190422033210-321fb2abda9c/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU= github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=