From 44ee0102f8d67be521c12898e7125220afe34a47 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Tue, 1 Feb 2022 16:05:39 -0500 Subject: [PATCH] add client pull loop + timeout --- netclient/functions/daemon.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/netclient/functions/daemon.go b/netclient/functions/daemon.go index 820aa7a8..f7801095 100644 --- a/netclient/functions/daemon.go +++ b/netclient/functions/daemon.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "os" "os/signal" "runtime" @@ -109,21 +108,19 @@ func MessageQueue(ctx context.Context, network string) { var cfg config.ClientConfig cfg.Network = network ncutils.Log("pulling latest config for " + cfg.Network) - var startTime float64 - startTime = 100 + sleepTime := 2 for { _, err := Pull(network, true) - if err != nil { - ncutils.Log(err.Error()) - startTime = math.Log2(startTime * startTime) - } else { + if err == nil { break } - sleepTime := int(startTime) if sleepTime > 3600 { sleepTime = 3600 } + ncutils.Log("failed to pull for network " + network) + ncutils.Log(fmt.Sprintf("waiting %d seconds to retry...", sleepTime)) time.Sleep(time.Second * time.Duration(sleepTime)) + sleepTime = sleepTime * 2 } time.Sleep(time.Second << 1) cfg.ReadConfig()