improve detection for own claims vs their claims

This commit is contained in:
Niko Storni 2019-10-01 16:55:43 +02:00
parent c7272e988a
commit d2bbb36312
3 changed files with 26 additions and 11 deletions

View file

@ -141,11 +141,10 @@ func (s *Sync) walletSetup() error {
return nil
}
func (s *Sync) ensureEnoughUTXOs() error {
func (s *Sync) getDefaultAccount() (string, error) {
accounts, err := s.daemon.AccountList()
if err != nil {
return errors.Err(err)
return "", errors.Err(err)
}
accountsNet := (*accounts).LBCMainnet
if logUtils.IsRegTest() {
@ -159,7 +158,15 @@ func (s *Sync) ensureEnoughUTXOs() error {
}
}
if defaultAccount == "" {
return errors.Err("No default account found")
return "", errors.Err("No default account found")
}
return defaultAccount, nil
}
func (s *Sync) ensureEnoughUTXOs() error {
defaultAccount, err := s.getDefaultAccount()
if err != nil {
return err
}
utxolist, err := s.daemon.UTXOList(&defaultAccount)

View file

@ -38,8 +38,12 @@ waiting:
func abandonSupports(s *Sync) (float64, error) {
totalPages := uint64(1)
var allSupports []jsonrpc.Claim
defaultAccount, err := s.getDefaultAccount()
if err != nil {
return 0, err
}
for page := uint64(1); page <= totalPages; page++ {
supports, err := s.daemon.SupportList(nil, page, 50)
supports, err := s.daemon.SupportList(&defaultAccount, page, 50)
if err != nil {
return 0, errors.Prefix("cannot list claims", err)
}
@ -53,7 +57,7 @@ func abandonSupports(s *Sync) (float64, error) {
if ok {
continue
}
supportOnTransferredClaim := support.Address == s.publishAddress
supportOnTransferredClaim := support.Address == s.publishAddress //todo: probably not needed anymore
if supportOnTransferredClaim {
continue
}
@ -98,7 +102,7 @@ func transferVideos(s *Sync) error {
StreamCreateOptions: &jsonrpc.StreamCreateOptions{
ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &s.publishAddress},
},
Bid: util.PtrToString("0.009"), // Todo - Dont hardcode
Bid: util.PtrToString("0.008"), // Todo - Dont hardcode
}
videoStatus := sdk.VideoStatus{

View file

@ -495,10 +495,14 @@ func (s *Sync) fixDupes(claims []jsonrpc.Claim) (bool, error) {
claimToAbandon = cl
videoIDs[videoID] = c
}
log.Debugf("abandoning %+v", claimToAbandon)
_, err := s.daemon.StreamAbandon(claimToAbandon.Txid, claimToAbandon.Nout, nil, false)
if err != nil {
return true, err
if claimToAbandon.Address != s.publishAddress && !s.syncedVideos[videoID].Transferred {
log.Debugf("abandoning %+v", claimToAbandon)
_, err := s.daemon.StreamAbandon(claimToAbandon.Txid, claimToAbandon.Nout, nil, false)
if err != nil {
return true, err
}
} else {
log.Debugf("lbrynet stream abandon --txid=%s --nout=%d", claimToAbandon.Txid, claimToAbandon.Nout)
}
abandonedClaims = true
//return true, nil