From 9512d7036fe9d7bbedf2e3109803535126ff09e5 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 8 Feb 2019 19:39:00 -0800 Subject: [PATCH] config: add new backupfilepath argument for SCBs In this commit, we add a new config option: `backupfilepath` for the new SCB implementation. This argument allows users to specify a custom location for the SCB file such as NFS or distinct partition. --- config.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 4c8c3e31..2cb6da72 100644 --- a/config.go +++ b/config.go @@ -22,6 +22,7 @@ import ( "github.com/btcsuite/btcutil" flags "github.com/jessevdk/go-flags" "github.com/lightningnetwork/lnd/build" + "github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc/signrpc" @@ -210,10 +211,11 @@ type config struct { Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65535"` - DebugHTLC bool `long:"debughtlc" description:"Activate the debug htlc mode. With the debug HTLC mode, all payments sent use a pre-determined R-Hash. Additionally, all HTLCs sent to a node with the debug HTLC R-Hash are immediately settled in the next available state transition."` - UnsafeDisconnect bool `long:"unsafe-disconnect" description:"Allows the rpcserver to intentionally disconnect from peers with open channels. USED FOR TESTING ONLY."` - UnsafeReplay bool `long:"unsafe-replay" description:"Causes a link to replay the adds on its commitment txn after starting up, this enables testing of the sphinx replay logic."` - MaxPendingChannels int `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."` + DebugHTLC bool `long:"debughtlc" description:"Activate the debug htlc mode. With the debug HTLC mode, all payments sent use a pre-determined R-Hash. Additionally, all HTLCs sent to a node with the debug HTLC R-Hash are immediately settled in the next available state transition."` + UnsafeDisconnect bool `long:"unsafe-disconnect" description:"Allows the rpcserver to intentionally disconnect from peers with open channels. USED FOR TESTING ONLY."` + UnsafeReplay bool `long:"unsafe-replay" description:"Causes a link to replay the adds on its commitment txn after starting up, this enables testing of the sphinx replay logic."` + MaxPendingChannels int `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."` + BackupFilePath string `long:"backupfilepath" description:"The target location of the channel backup file"` Bitcoin *chainConfig `group:"Bitcoin" namespace:"bitcoin"` BtcdMode *btcdConfig `group:"btcd" namespace:"btcd"` @@ -814,7 +816,7 @@ func loadConfig() (*config, error) { } // We'll now construct the network directory which will be where we - // store all the data specifc to this chain/network. + // store all the data specific to this chain/network. networkDir = filepath.Join( cfg.DataDir, defaultChainSubDirname, registeredChains.PrimaryChain().String(), @@ -840,6 +842,14 @@ func loadConfig() (*config, error) { ) } + // Similarly, if a custom back up file path wasn't specified, then + // we'll update the file location to match our set network directory. + if cfg.BackupFilePath == "" { + cfg.BackupFilePath = filepath.Join( + networkDir, chanbackup.DefaultBackupFileName, + ) + } + // Append the network type to the log directory so it is "namespaced" // per network in the same fashion as the data directory. cfg.LogDir = filepath.Join(cfg.LogDir,