fix bug where newly published and transferred videos caused an error

rename variable for better clarity
This commit is contained in:
Niko Storni 2019-10-08 01:59:18 +02:00
parent 5171acc007
commit 44e6cb5ddc
4 changed files with 73 additions and 70 deletions

View file

@ -141,7 +141,7 @@ func (s *SyncManager) Start() error {
AwsS3Bucket: s.awsS3Bucket, AwsS3Bucket: s.awsS3Bucket,
namer: namer.NewNamer(), namer: namer.NewNamer(),
Fee: channels[0].Fee, Fee: channels[0].Fee,
publishAddress: channels[0].PublishAddress, clientPublishAddress: channels[0].PublishAddress,
publicKey: channels[0].PublicKey, publicKey: channels[0].PublicKey,
transferState: channels[0].TransferState, transferState: channels[0].TransferState,
} }
@ -184,7 +184,7 @@ func (s *SyncManager) Start() error {
AwsS3Bucket: s.awsS3Bucket, AwsS3Bucket: s.awsS3Bucket,
namer: namer.NewNamer(), namer: namer.NewNamer(),
Fee: c.Fee, Fee: c.Fee,
publishAddress: c.PublishAddress, clientPublishAddress: c.PublishAddress,
publicKey: c.PublicKey, publicKey: c.PublicKey,
transferState: c.TransferState, transferState: c.TransferState,
}) })

View file

@ -131,7 +131,7 @@ func (s *Sync) walletSetup() error {
return errors.Err("found blank claim address") return errors.Err("found blank claim address")
} }
if s.shouldTransfer() { if s.shouldTransfer() {
s.claimAddress = s.publishAddress s.claimAddress = s.clientPublishAddress
} }
err = s.ensureEnoughUTXOs() err = s.ensureEnoughUTXOs()

View file

@ -61,7 +61,7 @@ func abandonSupports(s *Sync) (float64, error) {
if ok { if ok {
continue continue
} }
supportOnTransferredClaim := support.Address == s.publishAddress //todo: probably not needed anymore supportOnTransferredClaim := support.Address == s.clientPublishAddress //todo: probably not needed anymore
if supportOnTransferredClaim { if supportOnTransferredClaim {
continue continue
} }
@ -87,7 +87,7 @@ func transferVideos(s *Sync) error {
cleanTransfer := true cleanTransfer := true
for _, video := range s.syncedVideos { for _, video := range s.syncedVideos {
if !video.Published || video.Transferred || video.MetadataVersion != LatestMetadataVersion { if !video.Published || video.Transferred || video.MetadataVersion != LatestMetadataVersion {
log.Debugf("skipping video: %s", video.VideoID) //log.Debugf("skipping video: %s", video.VideoID)
continue continue
} }
@ -102,9 +102,12 @@ func transferVideos(s *Sync) error {
return errors.Err("cannot transfer: too many claims. claimID: %s", video.ClaimID) return errors.Err("cannot transfer: too many claims. claimID: %s", video.ClaimID)
} }
if c.Claims[0].Address == s.clientPublishAddress {
continue
}
streamUpdateOptions := jsonrpc.StreamUpdateOptions{ streamUpdateOptions := jsonrpc.StreamUpdateOptions{
StreamCreateOptions: &jsonrpc.StreamCreateOptions{ StreamCreateOptions: &jsonrpc.StreamCreateOptions{
ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.publishAddress}, ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.clientPublishAddress},
}, },
Bid: util.PtrToString("0.005"), // Todo - Dont hardcode Bid: util.PtrToString("0.005"), // Todo - Dont hardcode
} }
@ -152,14 +155,14 @@ func transferChannel(s *Sync) error {
if channelClaim == nil || len(channelClaim.Claims) == 0 { if channelClaim == nil || len(channelClaim.Claims) == 0 {
return errors.Err("There is no channel claim for channel %s", s.LbryChannelName) 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 return nil
} }
updateOptions := jsonrpc.ChannelUpdateOptions{ updateOptions := jsonrpc.ChannelUpdateOptions{
Bid: util.PtrToString(fmt.Sprintf("%.6f", channelClaimAmount-0.005)), Bid: util.PtrToString(fmt.Sprintf("%.6f", channelClaimAmount-0.005)),
ChannelCreateOptions: jsonrpc.ChannelCreateOptions{ ChannelCreateOptions: jsonrpc.ChannelCreateOptions{
ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ ClaimCreateOptions: jsonrpc.ClaimCreateOptions{
ClaimAddress: &s.publishAddress, ClaimAddress: &s.clientPublishAddress,
}, },
}, },
} }

View file

@ -87,7 +87,7 @@ type Sync struct {
walletMux *sync.RWMutex walletMux *sync.RWMutex
queue chan video queue chan video
transferState int transferState int
publishAddress string clientPublishAddress string
publicKey string publicKey string
} }
@ -373,7 +373,7 @@ func deleteSyncFolder(videoDirectory string) {
} }
func (s *Sync) shouldTransfer() bool { 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) { func (s *Sync) setChannelTerminationStatus(e *error) {
@ -505,7 +505,7 @@ func (s *Sync) fixDupes(claims []jsonrpc.Claim) (bool, error) {
claimToAbandon = cl claimToAbandon = cl
videoIDs[videoID] = c 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) log.Debugf("abandoning %+v", claimToAbandon)
_, err := s.daemon.StreamAbandon(claimToAbandon.Txid, claimToAbandon.Nout, nil, false) _, err := s.daemon.StreamAbandon(claimToAbandon.Txid, claimToAbandon.Nout, nil, false)
if err != nil { if err != nil {