make timeout configurable
don't republish thumbs that were published from previous channels
This commit is contained in:
parent
1fb03f82ce
commit
374ec482cd
5 changed files with 33 additions and 13 deletions
|
@ -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"
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
@ -12,11 +14,13 @@ type DbConfig struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
type Configs struct {
|
type Configs struct {
|
||||||
Chainquery DbConfig `json:"chainquery"`
|
Chainquery DbConfig `json:"chainquery"`
|
||||||
Speech DbConfig `json:"speech"`
|
Speech DbConfig `json:"speech"`
|
||||||
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
14
main.go
|
@ -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
10
util/slice.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in a new issue