more fixes
This commit is contained in:
parent
750313f00b
commit
ceb02c5248
1 changed files with 28 additions and 15 deletions
43
ytsync.go
43
ytsync.go
|
@ -172,7 +172,8 @@ func (s *Sync) FullCycle() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
initialAmount := float64(count)*publishAmount + channelClaimAmount + 5 // +5 for fees and such
|
initialAmount := float64(count)*publishAmount + channelClaimAmount
|
||||||
|
initialAmount += initialAmount * 0.1 // add 10% margin for fees, etc
|
||||||
|
|
||||||
log.Printf("Loading wallet with %f initial credits", initialAmount)
|
log.Printf("Loading wallet with %f initial credits", initialAmount)
|
||||||
lbrycrdd, err := lbrycrd.NewWithDefaultURL()
|
lbrycrdd, err := lbrycrd.NewWithDefaultURL()
|
||||||
|
@ -268,7 +269,8 @@ func (s *Sync) Go() error {
|
||||||
})
|
})
|
||||||
} else if s.MaxTries > 1 {
|
} else if s.MaxTries > 1 {
|
||||||
if strings.Contains(err.Error(), "non 200 status code received") ||
|
if strings.Contains(err.Error(), "non 200 status code received") ||
|
||||||
strings.Contains(err.Error(), " reason: 'This video contains content from") {
|
strings.Contains(err.Error(), " reason: 'This video contains content from") ||
|
||||||
|
strings.Contains(err.Error(), "Playback on other websites has been disabled by the video owner") {
|
||||||
log.Println("This error should not be retried at all")
|
log.Println("This error should not be retried at all")
|
||||||
} else if tryCount >= s.MaxTries {
|
} else if tryCount >= s.MaxTries {
|
||||||
log.Println("Video failed after " + strconv.Itoa(s.MaxTries) + " retries, exiting")
|
log.Println("Video failed after " + strconv.Itoa(s.MaxTries) + " retries, exiting")
|
||||||
|
@ -294,6 +296,24 @@ func (s *Sync) Go() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func allUTXOsConfirmed(utxolist *jsonrpc.UTXOListResponse) bool {
|
||||||
|
if utxolist == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*utxolist) < 1 {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
for _, utxo := range *utxolist {
|
||||||
|
if utxo.Height == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Sync) ensureEnoughUTXOs() error {
|
func (s *Sync) ensureEnoughUTXOs() error {
|
||||||
utxolist, err := s.daemon.UTXOList()
|
utxolist, err := s.daemon.UTXOList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -302,6 +322,11 @@ func (s *Sync) ensureEnoughUTXOs() error {
|
||||||
return errors.New("no response")
|
return errors.New("no response")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !allUTXOsConfirmed(utxolist) {
|
||||||
|
log.Println("Waiting for previous txns to confirm") // happens if you restarted the daemon soon after a previous publish run
|
||||||
|
s.waitUntilUTXOsConfirmed()
|
||||||
|
}
|
||||||
|
|
||||||
target := 50
|
target := 50
|
||||||
count := 0
|
count := 0
|
||||||
|
|
||||||
|
@ -357,19 +382,7 @@ func (s *Sync) waitUntilUTXOsConfirmed() error {
|
||||||
return errors.New("no response")
|
return errors.New("no response")
|
||||||
}
|
}
|
||||||
|
|
||||||
allConfirmed := true
|
if allUTXOsConfirmed(r) {
|
||||||
if len(*r) < 1 {
|
|
||||||
allConfirmed = false
|
|
||||||
} else {
|
|
||||||
for _, utxo := range *r {
|
|
||||||
if utxo.Height == 0 {
|
|
||||||
allConfirmed = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if allConfirmed {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue