ytsync/sources/shared.go
Niko Storni 30af4a0136 update lbry.go to v2 library
update modules
add slightly more LBCs for the channel claim to ensure fees are covered
2019-10-10 16:51:40 +02:00

31 lines
810 B
Go

package sources
import (
"strings"
"sync"
"github.com/lbryio/lbry.go/v2/extras/jsonrpc"
"github.com/lbryio/ytsync/namer"
)
type SyncSummary struct {
ClaimID string
ClaimName string
}
func publishAndRetryExistingNames(daemon *jsonrpc.Client, title, filename string, amount float64, options jsonrpc.StreamCreateOptions, namer *namer.Namer, walletLock *sync.RWMutex) (*SyncSummary, error) {
walletLock.RLock()
defer walletLock.RUnlock()
for {
name := namer.GetNextName(title)
response, err := daemon.StreamCreate(name, filename, amount, options)
if err != nil {
if strings.Contains(err.Error(), "failed: Multiple claims (") {
continue
}
return nil, err
}
PublishedClaim := response.Outputs[0]
return &SyncSummary{ClaimID: PublishedClaim.ClaimID, ClaimName: name}, nil
}
}