From aa75680dcf153eb2d5b06014b37663e15b2755d2 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 3 Jan 2019 18:38:35 -0800 Subject: [PATCH] config: add minbackoff to mirror maxbackoff --- config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config.go b/config.go index afef1993..2441f110 100644 --- a/config.go +++ b/config.go @@ -53,6 +53,7 @@ const ( defaultInactiveChanTimeout = 20 * time.Minute defaultMaxLogFiles = 3 defaultMaxLogFileSize = 10 + defaultMinBackoff = time.Second defaultMaxBackoff = time.Hour defaultTorSOCKSPort = 9050 @@ -197,6 +198,7 @@ type config struct { ExternalIPs []net.Addr DisableListen bool `long:"nolisten" description:"Disable listening for incoming peer connections"` NAT bool `long:"nat" description:"Toggle NAT traversal support (using either UPnP or NAT-PMP) to automatically advertise your external IP address to the network -- NOTE this does not support devices behind multiple NATs"` + MinBackoff time.Duration `long:"minbackoff" description:"Shortest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."` MaxBackoff time.Duration `long:"maxbackoff" description:"Longest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."` DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify =,=,... to set the log level for individual subsystems -- Use show to list available subsystems"` @@ -300,6 +302,7 @@ func loadConfig() (*config, error) { }, MaxPendingChannels: defaultMaxPendingChannels, NoSeedBackup: defaultNoSeedBackup, + MinBackoff: defaultMinBackoff, MaxBackoff: defaultMaxBackoff, SubRPCServers: &subRPCServerConfigs{ SignRPC: &signrpc.Config{}, @@ -959,6 +962,13 @@ func loadConfig() (*config, error) { } } + // Ensure that the specified minimum backoff is below or equal to the + // maximum backoff. + if cfg.MinBackoff > cfg.MaxBackoff { + return nil, fmt.Errorf("maxbackoff must be greater than " + + "minbackoff") + } + // Finally, ensure that the user's color is correctly formatted, // otherwise the server will not be able to start after the unlocking // the wallet.