diff --git a/go.mod b/go.mod index b39bb77..93b8dc6 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/hashicorp/serf v0.8.2 // indirect github.com/kr/pretty v0.1.0 // indirect github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c - github.com/lbryio/lbry.go v1.1.1-0.20190820035946-9ac18d083579 + github.com/lbryio/lbry.go v0.0.0-20190826222547-3a3377d0e5ec github.com/lbryio/reflector.go v1.0.6-0.20190806185326-2e4f235489f4 github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936 github.com/opencontainers/go-digest v1.0.0-rc1 // indirect diff --git a/go.sum b/go.sum index 3eee78b..fa04109 100644 --- a/go.sum +++ b/go.sum @@ -177,8 +177,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/lbry.go v0.0.0-20190109223729-30c312501602/go.mod h1:YEuFJD/oHNra6BFy+NfuvS84Wg6RMWJFGtiCCCc6MmQ= -github.com/lbryio/lbry.go v1.1.1-0.20190820035946-9ac18d083579 h1:3FKVv1m/J8mVQJTwIcF5BFv2E87y+nYqBqofJs6F720= -github.com/lbryio/lbry.go v1.1.1-0.20190820035946-9ac18d083579/go.mod h1:JtyI30bU51rm0LZ/po3mQuzf++14OWb6kR/6mMRAmKU= +github.com/lbryio/lbry.go v0.0.0-20190826222547-3a3377d0e5ec h1:wusAaT6POFVJwkwNA25I48Nr1DYTcuCAqmmum+WCYP8= +github.com/lbryio/lbry.go v0.0.0-20190826222547-3a3377d0e5ec/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/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo= github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI= diff --git a/manager/transfer.go b/manager/transfer.go index f2d3514..b230511 100644 --- a/manager/transfer.go +++ b/manager/transfer.go @@ -33,20 +33,34 @@ waiting: return nil } -func TransferChannelAndVideos(channel *Sync) error { - err := waitConfirmations(channel) +func abandonSupports(s *Sync) error { + totalPages := uint64(1) + var allSupports []jsonrpc.Claim + for page := uint64(1); page <= totalPages; page++ { + supports, err := s.daemon.SupportList(nil, page, 50) + if err != nil { + return errors.Prefix("cannot list claims", err) + } + allSupports = append(allSupports, (*supports).Items...) + totalPages = (*supports).TotalPages + } + return nil +} + +func transferVideos(s *Sync) error { + err := waitConfirmations(s) if err != nil { return err } cleanTransfer := true - for _, video := range channel.syncedVideos { + for _, video := range s.syncedVideos { if !video.Published || video.Transferred || video.MetadataVersion != LatestMetadataVersion { log.Debugf("skipping video: %s", video.VideoID) continue } //Todo - Wait for prior sync to see that the publish is confirmed in lbrycrd? - c, err := channel.daemon.ClaimSearch(nil, &video.ClaimID, nil, nil) + c, err := s.daemon.ClaimSearch(nil, &video.ClaimID, nil, nil) if err != nil { return errors.Err(err) } @@ -58,13 +72,13 @@ func TransferChannelAndVideos(channel *Sync) error { streamUpdateOptions := jsonrpc.StreamUpdateOptions{ StreamCreateOptions: &jsonrpc.StreamCreateOptions{ - ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &channel.publishAddress}, + ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.publishAddress}, }, Bid: util.PtrToString("0.009"), // Todo - Dont hardcode } videoStatus := sdk.VideoStatus{ - ChannelID: channel.YoutubeChannelID, + ChannelID: s.YoutubeChannelID, VideoID: video.VideoID, ClaimID: video.ClaimID, ClaimName: video.ClaimName, @@ -72,7 +86,7 @@ func TransferChannelAndVideos(channel *Sync) error { IsTransferred: util.PtrToBool(true), } - result, updateError := channel.daemon.StreamUpdate(video.ClaimID, streamUpdateOptions) + result, updateError := s.daemon.StreamUpdate(video.ClaimID, streamUpdateOptions) if updateError != nil { cleanTransfer = false videoStatus.FailureReason = updateError.Error() @@ -80,7 +94,7 @@ func TransferChannelAndVideos(channel *Sync) error { videoStatus.IsTransferred = util.PtrToBool(false) } log.Printf("TRANSFER RESULT %+v", *result) //TODO: actually check the results to be sure it worked - statusErr := channel.APIConfig.MarkVideoStatus(videoStatus) + statusErr := s.APIConfig.MarkVideoStatus(videoStatus) if statusErr != nil { return errors.Err(statusErr) } @@ -93,21 +107,24 @@ func TransferChannelAndVideos(channel *Sync) error { if !cleanTransfer { return errors.Err("A video has failed to transfer for the channel...skipping channel transfer") } - channelClaim, err := channel.daemon.ClaimSearch(nil, &channel.lbryChannelID, nil, nil) + return nil +} +func transferChannel(s *Sync) error { + channelClaim, err := s.daemon.ClaimSearch(nil, &s.lbryChannelID, nil, nil) if err != nil { return errors.Err(err) } if channelClaim == nil || len(channelClaim.Claims) == 0 { - return errors.Err("There is no channel claim for channel %s", channel.LbryChannelName) + return errors.Err("There is no channel claim for channel %s", s.LbryChannelName) } updateOptions := jsonrpc.ChannelUpdateOptions{ ChannelCreateOptions: jsonrpc.ChannelCreateOptions{ ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ - ClaimAddress: &channel.publishAddress, + ClaimAddress: &s.publishAddress, }, }, } - result, err := channel.daemon.ChannelUpdate(channel.lbryChannelID, updateOptions) + result, err := s.daemon.ChannelUpdate(s.lbryChannelID, updateOptions) log.Printf("TRANSFER RESULT %+v", *result) //TODO: actually check the results to be sure it worked return errors.Err(err) diff --git a/manager/ytsync.go b/manager/ytsync.go index 3c13e5e..980986a 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -316,7 +316,11 @@ func (s *Sync) FullCycle() (e error) { } if s.shouldTransfer() { - return TransferChannelAndVideos(s) + err = transferVideos(s) + if err != nil { + return err + } + return transferChannel(s) } return nil