Compare commits

...
7 Commits
Author SHA1 Message Date
Niko Storni 0d473cc4f6 add support for transferring videos after transferring everything 2019-09-25 04:38:49 +02:00
Niko Storni 2f701a887a fix double counting
fix transferred check
2019-09-25 04:15:16 +02:00
Niko Storni 8d56ef852f fix e2e
fix database transferred flag
2019-09-25 03:30:07 +02:00
Niko Storni 849ff11bfd import public keys if available 2019-09-24 20:42:17 +02:00
Niko Storni 45982f30c5 fix e2e test 2019-09-24 19:09:39 +02:00
Niko Storni 07413b499a update SDK support
fix bug where videos would publish to the wrong address
2019-09-24 18:51:06 +02:00
Niko Storni 92d8ef75f8 update e2e test 2019-09-19 20:03:55 +02:00
9 changed files with 51 additions and 10 deletions

No files matched your search

+2 -2
View File
@@ -21,7 +21,7 @@ services:
## Wallet Server ##
###################
walletserver:
image: lbry/wallet-server:v0.39.3
image: lbry/wallet-server:v0.42.0
restart: always
environment:
- DB_DIRECTORY=/database
@@ -47,7 +47,7 @@ services:
## Lbrynet ##
#############
lbrynet:
image: lbry/lbrynet:v0.39.3
image: lbry/lbrynet:v0.42.0
restart: always
ports:
- "15100:5279"
+1 -1
View File
@@ -67,7 +67,7 @@ curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"generate","params
# Reset status for tranfer test
mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e "UPDATE youtube_data SET status = 'queued' WHERE id = 1"
# Trigger transfer api
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' 'http://localhost:15400/yt/transfer?auth_token=youtubertoken&address=n1Ygra2pyD6cpESv9GtPM9kDkr4bPeu1Dc'
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' 'http://localhost:15400/yt/transfer?auth_token=youtubertoken&address=n4eYeXAYmHo4YRUDEfsEhucy8y5LKRMcHg&public_key=tpubDA9GDAntyJu4hD3wU7175p7CuV6DWbYXfyb2HedBA3yuBp9HZ4n3QE4Ex6RHCSiEuVp2nKAL1Lzf2ZLo9ApaFgNaJjG6Xo1wB3iEeVbrDZp'
# Execute the transfer test!
./../bin/ytsync --channelID UCCyr5j8akeu9j4Q7urV0Lqw #Force channel intended...just in case. This channel lines up with the api container
# Check that the channel and the video are marked as transferred and that all supports are spent
+1 -1
View File
@@ -12,7 +12,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/go-ini/ini v1.41.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/lbryio/lbry.go v0.0.0-20190828131228-f3a1fbdd5303
github.com/lbryio/lbry.go v0.0.0-20190924183703-712e346bd209
github.com/lbryio/reflector.go v1.0.6-0.20190828131602-ce3d4403dbc6
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
github.com/mitchellh/mapstructure v1.1.2 // indirect
+2
View File
@@ -159,6 +159,8 @@ github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c h1:BhdcWGsuKif/Xo
github.com/lbryio/errors.go v0.0.0-20180223142025-ad03d3cc6a5c/go.mod h1:muH7wpUqE8hRA3OrYYosw9+Sl681BF9cwcjzE+OCNK8=
github.com/lbryio/lbry.go v0.0.0-20190828131228-f3a1fbdd5303 h1:CyDDxUMREhAxPlgP+mgcArgkGJKtdXssj7CXk7o3h84=
github.com/lbryio/lbry.go v0.0.0-20190828131228-f3a1fbdd5303/go.mod h1:qR+Ui0hYhemIU4fXqM3d1P9eiaRFlof777VJgV7KJ8w=
github.com/lbryio/lbry.go v0.0.0-20190924183703-712e346bd209 h1:idtWts2fhF8TiGK4W+REJtrj5r6EeXr8+77g/nz8snk=
github.com/lbryio/lbry.go v0.0.0-20190924183703-712e346bd209/go.mod h1:wnoiUIfkeUmbiIGR/dg3Xvb6a6Jz7vPxtUoENyyl5QE=
github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46 h1:LemfR+rMxhf7nnOrzy2HqS7Me7SZ5gEwOcNFzKC8ySQ=
github.com/lbryio/lbryschema.go v0.0.0-20190602173230-6d2f69a36f46/go.mod h1:dAzPCBj3CKKWBGYBZxK6tKBP5SCgY2tqd9SnQd/OyKo=
github.com/lbryio/ozzo-validation v0.0.0-20170323141101-d1008ad1fd04 h1:Nze+C2HbeKvhjI/kVn+9Poj/UuEW5sOQxcsxqO7L3GI=
+2
View File
@@ -142,6 +142,7 @@ func (s *SyncManager) Start() error {
namer: namer.NewNamer(),
Fee: channels[0].Fee,
publishAddress: channels[0].PublishAddress,
publicKey: channels[0].PublicKey,
transferState: channels[0].TransferState,
}
shouldInterruptLoop = true
@@ -184,6 +185,7 @@ func (s *SyncManager) Start() error {
namer: namer.NewNamer(),
Fee: c.Fee,
publishAddress: c.PublishAddress,
publicKey: c.PublicKey,
transferState: c.TransferState,
})
if q != StatusFailed {
+3 -3
View File
@@ -120,17 +120,17 @@ func (s *Sync) walletSetup() error {
}
}
claimAddress, err := s.daemon.AddressList(nil)
claimAddress, err := s.daemon.AddressList(nil, nil)
if err != nil {
return err
} else if claimAddress == nil {
return errors.Err("could not get unused address")
}
s.claimAddress = string((*claimAddress)[0]) //TODO: remove claimAddress completely
s.claimAddress = string((*claimAddress)[0].Address)
if s.claimAddress == "" {
return errors.Err("found blank claim address")
}
if s.transferState > 0 && s.publishAddress != "" {
if s.shouldTransfer() {
s.claimAddress = s.publishAddress
}
+7
View File
@@ -52,6 +52,10 @@ func abandonSupports(s *Sync) (float64, error) {
if ok {
continue
}
supportOnTransferredClaim := support.Address == s.publishAddress
if supportOnTransferredClaim {
continue
}
alreadyAbandoned[support.ClaimID] = true
summary, err := s.daemon.SupportAbandon(&support.ClaimID, nil, nil, nil, nil)
if err != nil {
@@ -136,6 +140,9 @@ func transferChannel(s *Sync) error {
if channelClaim == nil || len(channelClaim.Claims) == 0 {
return errors.Err("There is no channel claim for channel %s", s.LbryChannelName)
}
if channelClaim.Claims[0].Address == s.publishAddress {
return nil
}
updateOptions := jsonrpc.ChannelUpdateOptions{
ChannelCreateOptions: jsonrpc.ChannelCreateOptions{
ClaimCreateOptions: jsonrpc.ClaimCreateOptions{
+32 -3
View File
@@ -88,6 +88,7 @@ type Sync struct {
queue chan video
transferState int
publishAddress string
publicKey string
}
func (s *Sync) AppendSyncedVideo(videoID string, published bool, failureReason string, claimName string, claimID string, metadataVersion int8, size int64) {
@@ -361,9 +362,11 @@ func deleteSyncFolder(videoDirectory string) {
_ = util.SendToSlack(err.Error())
}
}
func (s *Sync) shouldTransfer() bool {
return s.transferState == 1 && s.publishAddress != "" && !s.Manager.SyncFlags.DisableTransfers
return s.transferState >= 1 && s.publishAddress != "" && !s.Manager.SyncFlags.DisableTransfers
}
func (s *Sync) setChannelTerminationStatus(e *error) {
var transferState *int
@@ -545,7 +548,7 @@ func (s *Sync) updateRemoteDB(claims []jsonrpc.Claim) (total, fixed, removed int
if !claimInDatabase {
log.Debugf("%s: Published but is not in database (%s - %s)", videoID, c.Name, c.ClaimID)
}
if s.syncedVideos[videoID].Transferred {
if s.syncedVideos[videoID].Transferred && s.publishAddress != c.Address {
log.Debugf("%s: Marked as transferred while in fact it's not (%s - %s). Publish address: %s, expected: %s", videoID, c.Name, c.ClaimID, c.Address, s.publishAddress)
}
if !claimInDatabase || metadataDiffers || claimIDDiffers || claimNameDiffers || claimMarkedUnpublished {
@@ -563,6 +566,7 @@ func (s *Sync) updateRemoteDB(claims []jsonrpc.Claim) (total, fixed, removed int
ClaimName: c.Name,
Size: util.PtrToInt64(int64(claimSize)),
MetaDataVersion: claimMetadataVersion,
IsTransferred: util.PtrToBool(s.publishAddress == c.Address),
})
if err != nil {
return count, fixed, 0, err
@@ -573,7 +577,6 @@ func (s *Sync) updateRemoteDB(claims []jsonrpc.Claim) (total, fixed, removed int
for vID, sv := range s.syncedVideos {
if sv.Transferred {
log.Infof("%s: claim was transferred, ignoring", vID)
count++ //still count them as publishes
continue
}
_, ok := videoIDMap[vID]
@@ -666,6 +669,10 @@ func (s *Sync) doSync() error {
if err != nil {
return errors.Prefix("could not set address reuse policy", err)
}
err = s.importPublicKey()
if err != nil {
return errors.Prefix("could not import the transferee public key", err)
}
err = s.walletSetup()
if err != nil {
return errors.Prefix("Initial wallet setup failed! Manual Intervention is required.", err)
@@ -1050,6 +1057,28 @@ func (s *Sync) processVideo(v video) (err error) {
return nil
}
func (s *Sync) importPublicKey() error {
if s.publicKey != "" {
accountsResponse, err := s.daemon.AccountList()
if err != nil {
return errors.Err(err)
}
accounts := accountsResponse.LBCMainnet
if logUtils.IsRegTest() {
accounts = accountsResponse.LBCRegtest
}
for _, a := range accounts {
if a.PublicKey == s.publicKey {
return nil
}
}
log.Infof("Could not find public key %s in the wallet. Importing it...", s.publicKey)
_, err = s.daemon.AccountAdd(s.LbryChannelName, nil, nil, &s.publicKey, util.PtrToBool(true), nil)
return errors.Err(err)
}
return nil
}
// waitForDaemonProcess observes the running processes and returns when the process is no longer running or when the timeout is up
func waitForDaemonProcess(timeout time.Duration) error {
processes, err := ps.Processes()
+1
View File
@@ -58,6 +58,7 @@ type YoutubeChannel struct {
ChannelClaimID string `json:"channel_claim_id"`
TransferState int `json:"transfer_state"`
PublishAddress string `json:"publish_address"`
PublicKey string `json:"public_key"`
}
func (a *APIConfig) FetchChannels(status string, cp *SyncProperties) ([]YoutubeChannel, error) {