diff --git a/manager/manager.go b/manager/manager.go index 176e5a6..6cf0a2d 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -126,24 +126,24 @@ func (s *SyncManager) Start() error { lbryChannelName := channels[0].DesiredChannelName syncs = make([]Sync, 1) syncs[0] = Sync{ - APIConfig: s.apiConfig, - YoutubeChannelID: s.syncProperties.YoutubeChannelID, - LbryChannelName: lbryChannelName, - lbryChannelID: channels[0].ChannelClaimID, - MaxTries: s.maxTries, - ConcurrentVideos: s.concurrentVideos, - Refill: s.refill, - Manager: s, - LbrycrdString: s.lbrycrdString, - AwsS3ID: s.awsS3ID, - AwsS3Secret: s.awsS3Secret, - AwsS3Region: s.awsS3Region, - AwsS3Bucket: s.awsS3Bucket, - namer: namer.NewNamer(), - Fee: channels[0].Fee, - publishAddress: channels[0].PublishAddress, - publicKey: channels[0].PublicKey, - transferState: channels[0].TransferState, + APIConfig: s.apiConfig, + YoutubeChannelID: s.syncProperties.YoutubeChannelID, + LbryChannelName: lbryChannelName, + lbryChannelID: channels[0].ChannelClaimID, + MaxTries: s.maxTries, + ConcurrentVideos: s.concurrentVideos, + Refill: s.refill, + Manager: s, + LbrycrdString: s.lbrycrdString, + AwsS3ID: s.awsS3ID, + AwsS3Secret: s.awsS3Secret, + AwsS3Region: s.awsS3Region, + AwsS3Bucket: s.awsS3Bucket, + namer: namer.NewNamer(), + Fee: channels[0].Fee, + clientPublishAddress: channels[0].PublishAddress, + publicKey: channels[0].PublicKey, + transferState: channels[0].TransferState, } shouldInterruptLoop = true } else { @@ -169,24 +169,24 @@ func (s *SyncManager) Start() error { for i, c := range channels { log.Infof("There are %d channels in the \"%s\" queue", len(channels)-i, q) syncs = append(syncs, Sync{ - APIConfig: s.apiConfig, - YoutubeChannelID: c.ChannelId, - LbryChannelName: c.DesiredChannelName, - lbryChannelID: c.ChannelClaimID, - MaxTries: s.maxTries, - ConcurrentVideos: s.concurrentVideos, - Refill: s.refill, - Manager: s, - LbrycrdString: s.lbrycrdString, - AwsS3ID: s.awsS3ID, - AwsS3Secret: s.awsS3Secret, - AwsS3Region: s.awsS3Region, - AwsS3Bucket: s.awsS3Bucket, - namer: namer.NewNamer(), - Fee: c.Fee, - publishAddress: c.PublishAddress, - publicKey: c.PublicKey, - transferState: c.TransferState, + APIConfig: s.apiConfig, + YoutubeChannelID: c.ChannelId, + LbryChannelName: c.DesiredChannelName, + lbryChannelID: c.ChannelClaimID, + MaxTries: s.maxTries, + ConcurrentVideos: s.concurrentVideos, + Refill: s.refill, + Manager: s, + LbrycrdString: s.lbrycrdString, + AwsS3ID: s.awsS3ID, + AwsS3Secret: s.awsS3Secret, + AwsS3Region: s.awsS3Region, + AwsS3Bucket: s.awsS3Bucket, + namer: namer.NewNamer(), + Fee: c.Fee, + clientPublishAddress: c.PublishAddress, + publicKey: c.PublicKey, + transferState: c.TransferState, }) if q != StatusFailed { continue queues diff --git a/manager/setup.go b/manager/setup.go index 5ce27fd..56710b6 100644 --- a/manager/setup.go +++ b/manager/setup.go @@ -131,7 +131,7 @@ func (s *Sync) walletSetup() error { return errors.Err("found blank claim address") } if s.shouldTransfer() { - s.claimAddress = s.publishAddress + s.claimAddress = s.clientPublishAddress } err = s.ensureEnoughUTXOs() diff --git a/manager/transfer.go b/manager/transfer.go index 6b3f37f..c17538b 100644 --- a/manager/transfer.go +++ b/manager/transfer.go @@ -61,7 +61,7 @@ func abandonSupports(s *Sync) (float64, error) { if ok { continue } - supportOnTransferredClaim := support.Address == s.publishAddress //todo: probably not needed anymore + supportOnTransferredClaim := support.Address == s.clientPublishAddress //todo: probably not needed anymore if supportOnTransferredClaim { continue } @@ -87,7 +87,7 @@ func transferVideos(s *Sync) error { cleanTransfer := true for _, video := range s.syncedVideos { if !video.Published || video.Transferred || video.MetadataVersion != LatestMetadataVersion { - log.Debugf("skipping video: %s", video.VideoID) + //log.Debugf("skipping video: %s", video.VideoID) continue } @@ -102,9 +102,12 @@ func transferVideos(s *Sync) error { return errors.Err("cannot transfer: too many claims. claimID: %s", video.ClaimID) } + if c.Claims[0].Address == s.clientPublishAddress { + continue + } streamUpdateOptions := jsonrpc.StreamUpdateOptions{ StreamCreateOptions: &jsonrpc.StreamCreateOptions{ - ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.publishAddress}, + ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.clientPublishAddress}, }, Bid: util.PtrToString("0.005"), // Todo - Dont hardcode } @@ -152,14 +155,14 @@ func transferChannel(s *Sync) error { if channelClaim == nil || len(channelClaim.Claims) == 0 { return errors.Err("There is no channel claim for channel %s", s.LbryChannelName) } - if channelClaim.Claims[0].Address == s.publishAddress { + if channelClaim.Claims[0].Address == s.clientPublishAddress { return nil } updateOptions := jsonrpc.ChannelUpdateOptions{ Bid: util.PtrToString(fmt.Sprintf("%.6f", channelClaimAmount-0.005)), ChannelCreateOptions: jsonrpc.ChannelCreateOptions{ ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ - ClaimAddress: &s.publishAddress, + ClaimAddress: &s.clientPublishAddress, }, }, } diff --git a/manager/ytsync.go b/manager/ytsync.go index da38421..a8b1383 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -63,32 +63,32 @@ func (a byPublishedAt) Less(i, j int) bool { return a[i].PublishedAt().Before(a[ // Sync stores the options that control how syncing happens type Sync struct { - APIConfig *sdk.APIConfig - YoutubeChannelID string - LbryChannelName string - MaxTries int - ConcurrentVideos int - Refill int - Manager *SyncManager - LbrycrdString string - AwsS3ID string - AwsS3Secret string - AwsS3Region string - AwsS3Bucket string - Fee *sdk.Fee - daemon *jsonrpc.Client - claimAddress string - videoDirectory string - syncedVideosMux *sync.RWMutex - syncedVideos map[string]sdk.SyncedVideo - grp *stop.Group - lbryChannelID string - namer *namer.Namer - walletMux *sync.RWMutex - queue chan video - transferState int - publishAddress string - publicKey string + APIConfig *sdk.APIConfig + YoutubeChannelID string + LbryChannelName string + MaxTries int + ConcurrentVideos int + Refill int + Manager *SyncManager + LbrycrdString string + AwsS3ID string + AwsS3Secret string + AwsS3Region string + AwsS3Bucket string + Fee *sdk.Fee + daemon *jsonrpc.Client + claimAddress string + videoDirectory string + syncedVideosMux *sync.RWMutex + syncedVideos map[string]sdk.SyncedVideo + grp *stop.Group + lbryChannelID string + namer *namer.Namer + walletMux *sync.RWMutex + queue chan video + transferState int + clientPublishAddress string + publicKey string } func (s *Sync) AppendSyncedVideo(videoID string, published bool, failureReason string, claimName string, claimID string, metadataVersion int8, size int64) { @@ -373,7 +373,7 @@ func deleteSyncFolder(videoDirectory string) { } func (s *Sync) shouldTransfer() bool { - return s.transferState >= 1 && s.publishAddress != "" && !s.Manager.SyncFlags.DisableTransfers + return s.transferState >= 1 && s.clientPublishAddress != "" && !s.Manager.SyncFlags.DisableTransfers } func (s *Sync) setChannelTerminationStatus(e *error) { @@ -505,7 +505,7 @@ func (s *Sync) fixDupes(claims []jsonrpc.Claim) (bool, error) { claimToAbandon = cl videoIDs[videoID] = c } - if claimToAbandon.Address != s.publishAddress && !s.syncedVideos[videoID].Transferred { + if claimToAbandon.Address != s.clientPublishAddress && !s.syncedVideos[videoID].Transferred { log.Debugf("abandoning %+v", claimToAbandon) _, err := s.daemon.StreamAbandon(claimToAbandon.Txid, claimToAbandon.Nout, nil, false) if err != nil {