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"`
FilePath string `json:"file_path,omitempty"`
FileSize *string `json:"file_size,omitempty"`
IncludeProtobuf bool `json:"include_protobuf"`
IncludeProtoBuf bool `json:"include_protobuf"`
*StreamCreateOptions `json:",flatten"`
}{
Name: name,
@ -316,19 +316,17 @@ type StreamUpdateOptions struct {
ClearTags *bool `json:"clear_tags,omitempty"`
ClearLanguages *bool `json:"clear_languages,omitempty"`
ClearLocations *bool `json:"clear_locations,omitempty"`
Name *string `json:"name"`
Name *string `json:"name,omitempty"`
FilePath *string `json:"file_path,omitempty"`
FileSize *string `json:"file_size,omitempty"`
Bid *string `json:"bid"`
FileSize *uint64 `json:"file_size,omitempty"`
Bid *string `json:"bid,omitempty"`
*StreamCreateOptions `json:",flatten"`
}
func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*PublishResponse, error) {
response := new(PublishResponse)
func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*TransactionSummary, error) {
response := new(TransactionSummary)
args := struct {
ClaimID string `json:"claim_id"`
FilePath string `json:"file_path,omitempty"`
Bid string `json:"bid"`
IncludeProtoBuf bool `json:"include_protobuf"`
*StreamUpdateOptions `json:",flatten"`
}{
@ -337,7 +335,7 @@ func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*Pub
StreamUpdateOptions: &options,
}
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) {
@ -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 {
return nil, errors.Err("pages start from 1")
}
response := new(ClaimListMineResponse)
response := new(ClaimListResponse)
err := d.call(response, "claim_list", map[string]interface{}{
"account_id": account,
"page": page,
"page_size": pageSize,
"account_id": account,
"page": page,
"page_size": pageSize,
"include_protobuf": true,
})
if err != nil {
return nil, err

View file

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

View file

@ -256,16 +256,6 @@ type Address string
type AddressUnusedResponse 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 {
Items []Transaction `json:"items"`
Page uint64 `json:"page"`
@ -284,27 +274,40 @@ type Support struct {
}
type Claim struct {
Address string `json:"address"`
Amount string `json:"amount"`
ChannelName *string `json:"channel_name,omitempty"`
ClaimID string `json:"claim_id"`
ClaimSequence int64 `json:"claim_sequence"`
DecodedClaim bool `json:"decoded_claim"`
Depth int64 `json:"depth"`
EffectiveAmount string `json:"effective_amount"`
HasSignature *bool `json:"has_signature,omitempty"`
Height int `json:"height"`
Hex string `json:"hex"`
Name string `json:"name"`
NormalizedName string `json:"normalized_name"`
Nout uint64 `json:"nout"`
PermanentUrl string `json:"permanent_url"`
SignatureIsValid *bool `json:"signature_is_valid,omitempty"`
Supports []Support `json:"supports"`
Txid string `json:"txid"`
Type string `json:"type"`
ValidAtHeight int `json:"valid_at_height"`
Value lbryschema.Claim `json:"protobuf"`
Address string `json:"address"`
Amount string `json:"amount"`
ClaimID string `json:"claim_id"`
ClaimOp string `json:"claim_op,omitempty"`
Confirmations int `json:"confirmations"`
Height int `json:"height"`
IsChange bool `json:"is_change,omitempty"`
IsChannelSignatureValid bool `json:"is_channel_signature_valid,omitempty"`
IsMine bool `json:"is_mine,omitempty"`
Name string `json:"name"`
Nout uint64 `json:"nout"`
PermanentURL string `json:"permanent_url"`
SigningChannel struct {
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"`
Type string `json:"type,omitempty"`
ValueType string `json:"value_type,omitempty"`
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/"
@ -361,15 +364,13 @@ func (c *Claim) GetStreamSizeByMagic() (uint64, error) {
return streamSize, nil
}
type ClaimListResponse []Claim
type ClaimListMineResponse struct {
type ClaimListResponse struct {
Claims []Claim `json:"items"`
Page uint64 `json:"page"`
PageSize uint64 `json:"page_size"`
TotalPages uint64 `json:"total_pages"`
}
type ClaimSearchResponse ClaimListMineResponse
type ClaimSearchResponse ClaimListResponse
type StatusResponse 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/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/lbryschema.go v0.0.0-20190422030648-322c658307e0 h1:/YWLlbbDefRGLs/ozyuRpvpwpFISYehwR4AAVlPthA8=
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 h1:urfYK5ElpUrAv90auPLldoVC60LwiGAcY0OE6HJB9KI=
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/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/go.mod h1:CG3wsDv5BiVYQd5i1Jp7wGsaVyjZTJshqXeWMVKsISE=
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=