From 0a2ad0f099e827023aa534c28ba3c67b60f8b86d Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Tue, 19 Dec 2023 23:11:54 +0300 Subject: [PATCH] fix working with public config --- liteapi/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/liteapi/client.go b/liteapi/client.go index df14e9d6..5e7f2db8 100644 --- a/liteapi/client.go +++ b/liteapi/client.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "errors" "fmt" + "math/rand" "net/http" "os" "sync" @@ -253,7 +254,12 @@ func NewClient(opts ...Option) (*Client, error) { if err != nil { continue } - liteclients = append(liteclients, liteclient.NewClient(c, liteclient.OptionTimeout(options.Timeout))) + lc := liteclient.NewClient(c, liteclient.OptionTimeout(options.Timeout)) + _, err = lc.LiteServerGetMasterchainInfo(options.InitCtx) + if err != nil { + continue + } + liteclients = append(liteclients, lc) if len(liteclients) >= options.MaxConnections { break } @@ -990,5 +996,8 @@ func downloadConfig(path string) (*config.GlobalConfigurationFile, error) { configCache[path] = o configCacheMutex.Unlock() } + rand.Shuffle(len(o.LiteServers), func(i, j int) { + o.LiteServers[i], o.LiteServers[j] = o.LiteServers[j], o.LiteServers[i] + }) return o, err }