adjust support management
adjust e2e script
This commit is contained in:
parent
7b23235f83
commit
3c3ea2138e
4 changed files with 42 additions and 14 deletions
|
@ -84,7 +84,7 @@ services:
|
|||
## Internal APIs ##
|
||||
###################
|
||||
internalapis:
|
||||
image: lbry/internal-apis:transfers
|
||||
image: lbry/internal-apis:master
|
||||
restart: "no"
|
||||
ports:
|
||||
- "15400:8080"
|
||||
|
|
|
@ -70,11 +70,11 @@ mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e "UPDATE youtube_data
|
|||
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' 'http://localhost:15400/yt/transfer?auth_token=youtubertoken&address=n1Ygra2pyD6cpESv9GtPM9kDkr4bPeu1Dc'
|
||||
# Execute the transfer test!
|
||||
./../bin/ytsync --channelID UCCyr5j8akeu9j4Q7urV0Lqw #Force channel intended...just in case. This channel lines up with the api container
|
||||
# ALSO CHECK THAT VIDEO IS MARKED TRANSFERRED
|
||||
# Check that the channel and the video are marked as transferred and that all supports are spent
|
||||
channelTransferStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT transfer_state FROM youtube_data WHERE id=1')
|
||||
videoTransferStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT transferred FROM synced_video WHERE id=1')
|
||||
nrUnspentSupports=$(mysql -u lbry -plbry -ss -D chainquery -h "127.0.0.1" -P 15600 -e 'SELECT COUNT(*) FROM chainquery.support INNER JOIN output ON output.transaction_hash = support.transaction_hash_id AND output.vout = support.vout WHERE output.is_spent = 0')
|
||||
if [[ $status != "synced" || $videoStatus != "published" || $channelTransferStatus != "2" || $videoTransferStatus != "1" || $nrUnspentSupports != "0" ]]; then
|
||||
if [[ $status != "synced" || $videoStatus != "published" || $channelTransferStatus != "2" || $videoTransferStatus != "1" || $nrUnspentSupports != "1" ]]; then
|
||||
echo "~~!!!~~~FAILED~~~!!!~~"
|
||||
echo "Channel Status: $status"
|
||||
echo "Video Status: $videoStatus"
|
||||
|
@ -88,6 +88,4 @@ if [[ $status != "synced" || $videoStatus != "published" || $channelTransferStat
|
|||
exit 1;
|
||||
else
|
||||
echo "SUCCESSSSSSSSSSSSS!"
|
||||
fi;
|
||||
|
||||
#perhaps query lbrynet again (should be restarted) to see if the claim and the channel are actually on the right address
|
||||
fi;
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/lbryio/lbry.go/extras/util"
|
||||
"github.com/lbryio/ytsync/sdk"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func waitConfirmations(s *Sync) error {
|
||||
|
@ -33,18 +34,19 @@ waiting:
|
|||
return nil
|
||||
}
|
||||
|
||||
func abandonSupports(s *Sync) error {
|
||||
func abandonSupports(s *Sync) (float64, error) {
|
||||
totalPages := uint64(1)
|
||||
var allSupports []jsonrpc.Claim
|
||||
for page := uint64(1); page <= totalPages; page++ {
|
||||
supports, err := s.daemon.SupportList(nil, page, 50)
|
||||
if err != nil {
|
||||
return errors.Prefix("cannot list claims", err)
|
||||
return 0, errors.Prefix("cannot list claims", err)
|
||||
}
|
||||
allSupports = append(allSupports, (*supports).Items...)
|
||||
totalPages = (*supports).TotalPages
|
||||
}
|
||||
alreadyAbandoned := make(map[string]bool, len(allSupports))
|
||||
totalAbandoned := 0.0
|
||||
for _, support := range allSupports {
|
||||
_, ok := alreadyAbandoned[support.ClaimID]
|
||||
if ok {
|
||||
|
@ -53,11 +55,19 @@ func abandonSupports(s *Sync) error {
|
|||
alreadyAbandoned[support.ClaimID] = true
|
||||
summary, err := s.daemon.SupportAbandon(&support.ClaimID, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
return errors.Err(err)
|
||||
return totalAbandoned, errors.Err(err)
|
||||
}
|
||||
log.Infof("Abandoned support of %s (%s total output) LBC for claim %s", support.Amount, summary.Outputs[0].Amount, support.ClaimID)
|
||||
if len(summary.Outputs) < 1 {
|
||||
return totalAbandoned, errors.Err("error abandoning supports: no outputs while abandoning %s", support.ClaimID)
|
||||
}
|
||||
outputAmount, err := strconv.ParseFloat(summary.Outputs[0].Amount, 64)
|
||||
if err != nil {
|
||||
return totalAbandoned, errors.Err(err)
|
||||
}
|
||||
totalAbandoned += outputAmount
|
||||
log.Infof("Abandoned supports of %.4f LBC for claim %s", outputAmount, support.ClaimID)
|
||||
}
|
||||
return nil
|
||||
return totalAbandoned, nil
|
||||
}
|
||||
|
||||
func transferVideos(s *Sync) error {
|
||||
|
|
|
@ -320,15 +320,35 @@ func (s *Sync) FullCycle() (e error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = abandonSupports(s)
|
||||
supportAmount, err := abandonSupports(s)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Prefix(fmt.Sprintf("%.6f LBCs were abandoned before failing", supportAmount), err)
|
||||
}
|
||||
err = transferVideos(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return transferChannel(s)
|
||||
err = transferChannel(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
reallocateSupports := supportAmount > 0.01
|
||||
if reallocateSupports {
|
||||
err = waitConfirmations(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isTip := true
|
||||
summary, err := s.daemon.SupportCreate(s.lbryChannelID, fmt.Sprintf("%.6f", supportAmount), &isTip, nil, nil)
|
||||
if err != nil {
|
||||
return errors.Err(err)
|
||||
}
|
||||
if len(summary.Outputs) < 1 {
|
||||
return errors.Err("something went wrong while tipping the channel for %.6f LBCs", supportAmount)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue