make timeout configurable

don't republish thumbs that were published from previous channels
This commit is contained in:
Niko Storni 2020-06-04 21:29:02 +02:00
parent 1fb03f82ce
commit 374ec482cd
5 changed files with 33 additions and 13 deletions

View file

@ -13,5 +13,11 @@
}, },
"channel_id": "", "channel_id": "",
"publish_address": "", "publish_address": "",
"reflector_server": "reflector.lbry.com:5567" "reflector_server": "reflector.lbry.com:5567",
"lbrynet_timeout": 300,
"previous_channel_ids": [
"4c971f1076e39845c1643cdcf41d2287e1ea4961",
"f2cf43b86b9d70175dc22dbb9ff7806241d90780",
"2ad860f494345417824e30eb85f4ce7d1fea9cff"
]
} }

View file

@ -1,6 +1,8 @@
package configs package configs
import ( import (
"time"
"github.com/lbryio/lbry.go/v2/extras/errors" "github.com/lbryio/lbry.go/v2/extras/errors"
"github.com/tkanos/gonfig" "github.com/tkanos/gonfig"
) )
@ -17,6 +19,8 @@ type Configs struct {
ChannelID string `json:"channel_id"` ChannelID string `json:"channel_id"`
PublishAddress string `json:"publish_address"` PublishAddress string `json:"publish_address"`
ReflectorServer string `json:"reflector_server"` ReflectorServer string `json:"reflector_server"`
LbrynetTimeout time.Duration `json:"lbrynet_timeout"`
PreviousChannelIds []string `json:"previous_channel_ids"`
} }
var Configuration *Configs var Configuration *Configs

14
main.go
View file

@ -20,7 +20,7 @@ import (
"voidwalker/blobsdownloader" "voidwalker/blobsdownloader"
"voidwalker/chainquery" "voidwalker/chainquery"
"voidwalker/configs" "voidwalker/configs"
ml "voidwalker/util" ml2 "voidwalker/util/ml"
"github.com/gabriel-vasile/mimetype" "github.com/gabriel-vasile/mimetype"
"github.com/gin-contrib/cors" "github.com/gin-contrib/cors"
@ -38,8 +38,8 @@ var cqApi *chainquery.CQApi
var downloadsDir string var downloadsDir string
var uploadsDir string var uploadsDir string
var blobsDir string var blobsDir string
var viewLock ml.MultipleLock var viewLock ml2.MultipleLock
var publishLock ml.MultipleLock var publishLock ml2.MultipleLock
func main() { func main() {
err := configs.Init("./config.json") err := configs.Init("./config.json")
@ -63,8 +63,8 @@ func main() {
uploadsDir = usr.HomeDir + "/Uploads/" uploadsDir = usr.HomeDir + "/Uploads/"
downloadsDir = usr.HomeDir + "/Downloads/" downloadsDir = usr.HomeDir + "/Downloads/"
blobsDir = usr.HomeDir + "/.lbrynet/blobfiles/" blobsDir = usr.HomeDir + "/.lbrynet/blobfiles/"
viewLock = ml.NewMultipleLock() viewLock = ml2.NewMultipleLock()
publishLock = ml.NewMultipleLock() publishLock = ml2.NewMultipleLock()
cache = &sync.Map{} cache = &sync.Map{}
@ -297,7 +297,7 @@ func publish(c *gin.Context) {
return return
} }
for _, claim := range *resolveRsp { for _, claim := range *resolveRsp {
if claim.SigningChannel != nil && claim.SigningChannel.ClaimID == channelID { if claim.SigningChannel != nil && util.InSlice(claim.SigningChannel.ClaimID, configs.Configuration.PreviousChannelIds) {
baseUrl := "https://spee.ch/" + claim.ClaimID[0:1] + "/" + checkSum[:16] baseUrl := "https://spee.ch/" + claim.ClaimID[0:1] + "/" + checkSum[:16]
extendedUrl := baseUrl + mimeType.Extension() extendedUrl := baseUrl + mimeType.Extension()
response := PublishResponse{ response := PublishResponse{
@ -420,5 +420,5 @@ type ClaimData struct {
func initLbrynet() { func initLbrynet() {
daemon = jsonrpc.NewClient("") daemon = jsonrpc.NewClient("")
daemon.SetRPCTimeout(1 * time.Minute) daemon.SetRPCTimeout(configs.Configuration.LbrynetTimeout * time.Minute)
} }

10
util/slice.go Normal file
View file

@ -0,0 +1,10 @@
package util
func StringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}