Fix crash when updating unavailable node

This commit is contained in:
Ingo Oppermann
2024-07-16 08:13:15 +02:00
parent b9796a46f2
commit 3d78122053

View File

@@ -66,21 +66,23 @@ func (n *Core) SetEssentials(address string, config *config.Config) {
n.lock.Lock() n.lock.Lock()
defer n.lock.Unlock() defer n.lock.Unlock()
if address != n.address { if n.address != address {
n.address = address n.address = address
n.client = nil // force reconnet n.client = nil // force reconnet
} }
if n.config == nil && config != nil { if config != nil {
if n.config == nil {
n.config = config n.config = config
n.client = nil // force reconnect n.client = nil // force reconnect
} }
if n.config.UpdatedAt != config.UpdatedAt { if n.config != nil && n.config.UpdatedAt != config.UpdatedAt {
n.config = config n.config = config
n.client = nil // force reconnect n.client = nil // force reconnect
} }
} }
}
func (n *Core) reconnect(ctx context.Context, interval time.Duration) { func (n *Core) reconnect(ctx context.Context, interval time.Duration) {
ticker := time.NewTicker(interval) ticker := time.NewTicker(interval)