add channel takeover flag
This commit is contained in:
parent
27c5db03fb
commit
750313f00b
1 changed files with 16 additions and 9 deletions
11
ytsync.go
11
ytsync.go
|
@ -41,6 +41,7 @@ type Sync struct {
|
||||||
StopOnError bool
|
StopOnError bool
|
||||||
MaxTries int
|
MaxTries int
|
||||||
ConcurrentVideos int
|
ConcurrentVideos int
|
||||||
|
TakeOverExistingChannel bool
|
||||||
|
|
||||||
daemon *jsonrpc.Client
|
daemon *jsonrpc.Client
|
||||||
claimAddress string
|
claimAddress string
|
||||||
|
@ -397,13 +398,19 @@ func (s *Sync) ensureChannelOwnership() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
channelNotFound := (*resolveResp)[s.LbryChannelName].Error != nil && strings.Contains(*((*resolveResp)[s.LbryChannelName].Error), "cannot be resolved")
|
channel := (*resolveResp)[s.LbryChannelName]
|
||||||
|
channelBidAmount := channelClaimAmount
|
||||||
|
|
||||||
|
channelNotFound := channel.Error != nil && strings.Contains(*(channel.Error), "cannot be resolved")
|
||||||
if !channelNotFound {
|
if !channelNotFound {
|
||||||
|
if !s.TakeOverExistingChannel {
|
||||||
return errors.New("Channel exists and we don't own it. Pick another channel.")
|
return errors.New("Channel exists and we don't own it. Pick another channel.")
|
||||||
}
|
}
|
||||||
|
log.Println("Channel exists and we don't own it. Outbidding existing claim.")
|
||||||
|
channelBidAmount, _ = channel.Certificate.Amount.Add(decimal.NewFromFloat(channelClaimAmount)).Float64()
|
||||||
|
}
|
||||||
|
|
||||||
_, err = s.daemon.ChannelNew(s.LbryChannelName, channelClaimAmount)
|
_, err = s.daemon.ChannelNew(s.LbryChannelName, channelBidAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue