Add set channel cert on new channels.
This commit is contained in:
parent
0308da2e4c
commit
5e56ac0516
4 changed files with 44 additions and 2 deletions
4
go.mod
4
go.mod
|
@ -17,8 +17,8 @@ require (
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
github.com/kr/pretty v0.1.0 // indirect
|
||||||
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c
|
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c
|
||||||
github.com/lbryio/lbry.go v1.0.15
|
github.com/lbryio/lbry.go v1.0.16-0.20190726033352-f69bba9977f8
|
||||||
github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4
|
github.com/lbryio/reflector.go v1.0.6-0.20190710201919-7c7ed9da72ce
|
||||||
github.com/lusis/slack-test v0.0.0-20190408224659-6cf59653add2 // indirect
|
github.com/lusis/slack-test v0.0.0-20190408224659-6cf59653add2 // indirect
|
||||||
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
|
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
|
||||||
github.com/onsi/ginkgo v1.8.0 // indirect
|
github.com/onsi/ginkgo v1.8.0 // indirect
|
||||||
|
|
3
go.sum
3
go.sum
|
@ -191,8 +191,11 @@ github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpU
|
||||||
github.com/lbryio/lbry.go v0.0.0-20190109223729-30c312501602/go.mod h1:YEuFJD/oHNra6BFy+NfuvS84Wg6RMWJFGtiCCCc6MmQ=
|
github.com/lbryio/lbry.go v0.0.0-20190109223729-30c312501602/go.mod h1:YEuFJD/oHNra6BFy+NfuvS84Wg6RMWJFGtiCCCc6MmQ=
|
||||||
github.com/lbryio/lbry.go v1.0.15 h1:g4g9cDDUsobmWgTA+1jEIb5k2fRCP0/NvPOMXduP8xY=
|
github.com/lbryio/lbry.go v1.0.15 h1:g4g9cDDUsobmWgTA+1jEIb5k2fRCP0/NvPOMXduP8xY=
|
||||||
github.com/lbryio/lbry.go v1.0.15/go.mod h1:JtyI30bU51rm0LZ/po3mQuzf++14OWb6kR/6mMRAmKU=
|
github.com/lbryio/lbry.go v1.0.15/go.mod h1:JtyI30bU51rm0LZ/po3mQuzf++14OWb6kR/6mMRAmKU=
|
||||||
|
github.com/lbryio/lbry.go v1.0.16-0.20190726033352-f69bba9977f8 h1:oNQh5rAVygkVLLRYxLd098/smLHcMoKrn7ozfwFhx2Y=
|
||||||
|
github.com/lbryio/lbry.go v1.0.16-0.20190726033352-f69bba9977f8/go.mod h1:JtyI30bU51rm0LZ/po3mQuzf++14OWb6kR/6mMRAmKU=
|
||||||
github.com/lbryio/lbryschema.go v0.0.0-20190428231007-c54836bca002 h1:urfYK5ElpUrAv90auPLldoVC60LwiGAcY0OE6HJB9KI=
|
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/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/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04/go.mod h1:fbG/dzobG8r95KzMwckXiLMHfFjZaBRQqC9hPs2XAQ4=
|
||||||
github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4 h1:SpUbq2YBg3ncetkw8APUgn8nFF8dscKzzhyiWMM7XCc=
|
github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4 h1:SpUbq2YBg3ncetkw8APUgn8nFF8dscKzzhyiWMM7XCc=
|
||||||
github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4/go.mod h1:7Y3YYeAKS6egH2WzwfU8f6+uNGjVHfLzKvwn+Nv3VMY=
|
github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4/go.mod h1:7Y3YYeAKS6egH2WzwfU8f6+uNGjVHfLzKvwn+Nv3VMY=
|
||||||
|
|
|
@ -548,6 +548,16 @@ func (s *Sync) doSync() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Prefix("error updating remote database", err)
|
return errors.Prefix("error updating remote database", err)
|
||||||
}
|
}
|
||||||
|
if pubsOnWallet == 0 {
|
||||||
|
cert, err := s.daemon.ChannelExport(s.lbryChannelID, nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Prefix("error getting channel cert", err)
|
||||||
|
}
|
||||||
|
err = s.APIConfig.SetChannelCert(string(*cert), s.lbryChannelID)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Prefix("error setting channel cert", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if nFixed > 0 || nRemoved > 0 {
|
if nFixed > 0 || nRemoved > 0 {
|
||||||
err := s.setStatusSyncing()
|
err := s.setStatusSyncing()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
29
sdk/api.go
29
sdk/api.go
|
@ -11,6 +11,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/lbryio/lbry.go/extras/api"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/extras/errors"
|
"github.com/lbryio/lbry.go/extras/errors"
|
||||||
"github.com/lbryio/lbry.go/extras/null"
|
"github.com/lbryio/lbry.go/extras/null"
|
||||||
|
|
||||||
|
@ -98,6 +100,33 @@ func sanitizeFailureReason(s *string) {
|
||||||
*s = (*s)[:MaxReasonLength]
|
*s = (*s)[:MaxReasonLength]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *APIConfig) SetChannelCert(certHex string, channelID string) error {
|
||||||
|
|
||||||
|
endpoint := a.ApiURL + "/yt/channel_cert"
|
||||||
|
|
||||||
|
res, _ := http.PostForm(endpoint, url.Values{
|
||||||
|
"channel_id": {channelID},
|
||||||
|
"channel_cert": {certHex},
|
||||||
|
"auth_token": {a.ApiToken},
|
||||||
|
})
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
body, _ := ioutil.ReadAll(res.Body)
|
||||||
|
var response api.Response
|
||||||
|
err := json.Unmarshal(body, &response)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Err(err)
|
||||||
|
}
|
||||||
|
if response.Error != nil {
|
||||||
|
return errors.Err(response.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (a *APIConfig) SetChannelStatus(channelID string, status string, failureReason string) (map[string]SyncedVideo, map[string]bool, error) {
|
func (a *APIConfig) SetChannelStatus(channelID string, status string, failureReason string) (map[string]SyncedVideo, map[string]bool, error) {
|
||||||
type apiChannelStatusResponse struct {
|
type apiChannelStatusResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
|
Loading…
Reference in a new issue